next up previous contents index
Next: Statement Labels Up: Statements and Lines Previous: Continuation Lines

Comment Lines

  Comments form an important part of any computer program even though they are completely ignored by the compiler: their purpose is to help any human who has to read and understand the program (such as the original programmer six months later).

Comments in Fortran always occupy a separate line of text; they are marked by an asterisk in the first column. For example:

 
*Calculate the atmospheric refraction at PRESS mbar. 
       REF = PRESS * (0.1594 + 1.96E-2 * A + 2E-5 * A**2) 
*Correct for the temperature T (Celsius) 
       TCOR = (273.0 + T) * (1.0 + 0.505 * A + 8.45E-2 * A**2)
A comment may appear at any point in a program unit except after the END statement (unless another program unit follows, in which case it will form the first line of the next unit). A completely blank line is also allowed and is treated as a blank comment. This means that a blank line is not actually permitted after the last END statement of a program.

There is no limit to the number of consecutive comment lines which may be used; comments may also appear in the middle of a sequence of continuation lines. To conform to the Fortran Standard, comment lines should not be over 72 characters long, but this rule is rarely enforced.

Comments may include characters which are not in the Fortran character set. It helps to distinguish comments from code if they are mainly written in lower-case letters (where available). It is also good practice for comments to precede the statements they describe rather than follow them.

Some systems allow end-of-line comments, usually prefaced by an exclamation mark: this is not permitted by the Fortran standard. For compatibility with Fortran66 comments can also be denoted by the letter C in column 1.


next up previous contents index
Next: Statement Labels Up: Statements and Lines Previous: Continuation Lines
Helen Rowlands
8/27/1998