Unformatted text preview:

FORTRAN77 The first FORTRAN compiler was a milestone in the history of computing, at that time computers had very small memories (on the order of 15KB, it was common then to count memory capacities in bits), they were slow and had very primitive operating systems (if they had them at all). The pioneers of FORTRAN didn't invent the idea of writing programs in a High Level Language (HLL) and compiling the source code to object code with an optimizing compiler, but they produced the first successful HLL [1]. This wonderful first FORTRAN compiler was designed and written from scratch in 1954-57 by an IBM team. In 1977, a current version language FORTRAN77 came out. Since FORTRAN77 is quite good at handling character strings as well as numbers and also has powerful file-handling and input/output facilities, it is suitable for a much wider range of applications than before [2]. FORTRAN77 is very simple to learn and to use. Now let us see what the most basic concept of FORTRAN77 is. • All programs start with PROGRAM program-name, SUBROUTINE subroutine-name or FUNCTION function-name and end with END. • The first five characters on a line are reserved for line numbers; the sixth character is reserved for a continuation character. If the first character is a C, the line is just comment. • Common block used for global variables. • Throughout any program of more than one programming unit, no two of the following can have the same name: 1. Block data subprograms 2. Common blocks 3. Entry points 4. Function subprograms 5. Main program 6. Subroutines • There are different variable types: INTEGER Constants (+123, -344, 345, -0123), REAL Constants (1.098, -4.985, +. 00343, .423E5), CHARACTER*n Constant (‘12’, ‘STRING’, ‘WE’’D BEST’), LOGICAL Constants (.TRUE. or .FALSE.). • READ Statement and PRINT Statement (READ *, list or PRINT *, list). • FORTRAN77 does not use >, >=, <, <=, ==, /=, $$, ||, but .GT., .GE., .LT., .LE., .EQ., .NE. .AND. .OR. instead. • All arrays start at 1instead of 0. INTEGER A(3) has three elements A(1), A(2), A(3). INTEGER B(l:u) (l<u) means to set up an array named B whose first element is B(l) and whose last element is B(u). Negative values of l,u are allowed. • A value of zero for any of these quantities indicates that the value does not refer to an object. Zero is the FORTRAN77 equivalent of NULL. Any nonzero value is or should be a valid object reference. If the statement implicit none is used, all variables must be declared.• There are different types of loops in FORTRAN77. The common thread among all types is the LOOP … Repeat sequence with an exit condition included somewhere therein. 1. Read-loop: Read and Exit if “final data” 2. Pretest loop: Exit if “condition” 3. Posttest loop: Repeat if “condition” 4. DO-loop: For v=s, s+i, s+2i…e … • In addition to the ability to automatically repeat complex sequences of commands, computers can also select an appropriate list of operations based on the result of previous calculations. IF (test of condition) THEN or IF (test of condition) THEN Then-block Then-block ELSE ELSEIF (…) THEN Else-block Else-if-block ENDIF ELSE Else-block ENDIF • There are three types of subprograms: subroutines, functions, and block data subprograms. The subroutines and functions are called procedures, which are invoked from other procedures or from the main program. The block data subprograms are handled by the loader. • Subroutines: call of a subroutine: call integrate(test) will call the subroutine integrate with the argument test passed. If the function modifies test its value is returned. The use of functions is almost similar. • FUNCTIONS Statement: we assign the total tax to the name of the FUNCTION, as if the FUNCTION’s name were a memory cell. The value is then transmitted back to the statement that references the FUNCTION. Except for this, FUNCTIONs are written in the same way as SUBROUTINES: header statement, parameter declaration, body, and END. The primary difference between them is the contexts in which they are used. AFUNCTION returns one value; a SUBROUTINE may return any number of values (through its arguments). A FUNCTION reference looks like a mathematical operation; a SUBROUTINE CALL looks like a transfer of control [3].• A block data subprogram contains no executable statements. The purpose of a block data subprogram is to initialize COMMON regions via DATA statements. For example, BLOCK DATA REAL PI COMMON /CONST/ PI DATA PI /3.14159/ END FORTRAN77 doesn’t have libraries, pointers and recursion. It also can use in data structures. From the Fortran point of view, all information for input or output is organized in files. Files reside on I/O devices and may be connected for processing by a Fortran program. Compared with FORTRAN IV, FORTRAN77 added: DO loops with a decreasing control variable (index). Block if statements IF ... THEN ... ELSE ... ENDIF (before F77 there were only IF GOTO). Pretest of DO loops, before F77 DO loops were always executed at least once, so you had to add an IF GOTO before the loop. CHARACTER data type (before characters were always stored inside INTEGER variables). Apostrophe delimited character string constants. Main program termination without a STOP statement. From above we can tell FORTRAN77 is similar with C. They have similar data type and functions statement. FORTRAN 77 tends to be easier for non-experts to learn than C, because its 'mental model of the computer' is much simpler. FORTRAN 77 generally requires much less computer science knowledge of the programmer than C does, and is thus much easier to use. In the conclusion, we can say FORTRAN77 is a useful and basic language in modern programming. Fortran is now one of the most widely used computer languages in the world with compilers available for almost every type of computer on the market [1]. We should take a look at it and understand how to program through it. References 1 Code Tuning co-guide, 1998 Lahey Fortran Users' Conference , 1-1. Retrieved Feb. 15, 2003 from the World Wide Web: http://www.ibiblio.org/pub/languages/fortran/ch1-1.ht ml 2 Page, Clive G., UK (2001, December 21st). Professional Programmer's Guide to Fortran77, 1.2 (Article 1). Retrieved February 15, 2003 from the World Wide Web:


View Full Document

CUNY CISC 3160 - Lecture Notes

Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?