There abound many types and versions of FORTRAN Programming Language such as FORTRAN IV, FORTRAN 77, FORTRAN 88, FORTRAN 90, WATFOR (or WATLOO FORTRAN), Microsoft FORTRAN, etc. but for the purpose of uniformly and proper understanding, only FORTRAN 77 is used in this website. So, where FORTRAN is used in this site, it means FORTRAN 77.
FORTRAN Character Set
FORTRAN statements, keywords or reserved word are from a set of characters. These characters are the 26 English alphabets (both uppercase lowercase letters A,B,C…,X,Y,Z, a,b,c…,x,y,z; the ten digits 0 to 9; the blank space; and the following special characters:
, * / + - . ( ) : ' =
The uses of the special characters will be explored as we forge ahead. However, any character can be used where string literals or comments are involved.
FORTRAN coding Sheet

Column 1 (first column) in a line is used to indicate a comment line. The letter C or an asterisk (*) is used in the column to indicate that the line is a comment line. Columns 1 to 5 are used for statement labels (statement labels are usually positive numbers such as the statement line numbers or FORMAT line numbers. Note that some few versions of FORTRAN restrict the statement label columns to columns 2 to 5 only.). Column 6 is used to indicate the continuation of statement that exceeds the 72nd column. Any character, except blank and zero, can be placed in column 6 to indicate the continuation of a statement begun on the preceding line(s). However, if the statement fits into one line, then column 6 must be left blank. FORTRAN statement itself appears between columns 7 and 72 inclusively. Any character in a FORTRAN statement line beyond column 72 are ignored. Therefore, columns 73 and above may be used by the programmer for a sequential line numbering or other identifications or anything else or they may be left blank.
Except with a literal string, blank columns in a FORTRAN statement have no meaning and therefore should be use freely to improve the appearance of the program. For example, we can use extra blanks on each side of an operator such as + or *, and wee can indent some lines of our program to make the structure of the program to be much obvious. These extra blanks makes the program easier to understand but they are ignored by the FORTRAN compiler.
Placement of FORTRAN Program statement
Though we have not written any program yet, it is wise we know from the beginning which type of statements should precede or follow a given statement in a program.
The order in which statements should be placed in a program is as below
1.PROGRAM: The first statement, except the comment line which can appear anywhere in a program, should be the PROGRAM statement. Likewise, in a function and a subroutine, the first statement must be FUNCTION and SUBROUTINE, respectively.
2. The data type declaration such as IMPLICIT, PARAMETER, REAL, INTEGER CHARACTER. LOGICAL, DOUBLE PRECISION, and DIMENSION statements should come after the PROGRAM statement.
3. The COMMON and EQUIVALENCE statements should follow
4. DATA statements.
5. Statement Function definition
6. FORTRAN Executable Statements, including FORMAT statement
7. END statement.
In general, all declarations and definitions (except the FORMAT declaration) must precede the executable statements.
Note that if the above order is not followed, then “statement out of sequence” error during compilation of the program will occur.
The order in which statements should be placed in a program is as below
1.PROGRAM: The first statement, except the comment line which can appear anywhere in a program, should be the PROGRAM statement. Likewise, in a function and a subroutine, the first statement must be FUNCTION and SUBROUTINE, respectively.
2. The data type declaration such as IMPLICIT, PARAMETER, REAL, INTEGER CHARACTER. LOGICAL, DOUBLE PRECISION, and DIMENSION statements should come after the PROGRAM statement.
3. The COMMON and EQUIVALENCE statements should follow
4. DATA statements.
5. Statement Function definition
6. FORTRAN Executable Statements, including FORMAT statement
7. END statement.
In general, all declarations and definitions (except the FORMAT declaration) must precede the executable statements.
Note that if the above order is not followed, then “statement out of sequence” error during compilation of the program will occur.
No comments:
Post a Comment