next up previous contents
Next: The TAB Layout Up: The Layout of FORTRAN Previous: The Layout of FORTRAN

The Standard Layout

A FORTRAN program is made up of STATEMENTS. Usually a statement occupies one line in a source file but it can be extended over several if necessary. The layout of a statement is as follows:-

characters 1 to 5
A numeric label in the range 1 to 99999 or blank. The letter C as character 1 means a comment and the rest of the line is ignored.

character 6
A continuation character or blank. If non-blank then this line is a continuation.

characters 7 to 72
The statement.

Spaces may be included in the statement to make it more readable. Here are 3 examples of statements (the lines starting 123... are just to help show the character positions):-

12345678901234567890
 
10    A = B + C
      A=B+C
      A=
     1   B +
     1   C
 
12345678901234567890

The 3 statements all have the same effect. The first has a label and the last shows the use of continuation characters to extend a statement over 3 lines.

Exercise 1a

Type the following program into test.for (don't type the lines starting 123!)

12345678901234567890
C This program adds 2 numbers and types out the result
 
10    A = 1.0
      B = 2.0
      C =
     1  A+B
      PRINT *,'C = ',C
      STOP
      END
12345678901234567890
Then type:-
f77 -o test test.for

this will compile test.for i.e. convert it into machine code and store the results in test. Now type:-

./test
this runs the program in the file test and if all is well you should get the output:-
C = 3.000000

* * *


next up previous contents
Next: The TAB Layout Up: The Layout of FORTRAN Previous: The Layout of FORTRAN
n west (APC)
2000-03-08