It is always very good practice to add descriptive comments to programs.
On any line a !
character indicates that all subsequent characters up to
the end of the line are commentary. Such commentary is ignored by the
compiler. Comments are part of the program source but are intended for
the human reader and not for the machine.
PROGRAM Saddo ! ! Program to evaluate marriage potential ! LOGICAL :: TrainSpotter ! Do we spot trains? LOGICAL :: SmellySocks ! Have we smelly socks? INTEGER :: i, j ! Loop variables
The one exception to above is if the ! appears in a character context, for example, in
PRINT*, "No chance of ever marrying!!!"
the ! does not initiate a comment.
A comment can contain any of the characters available on the computer being used. A comment is not restricted to use the Fortran character set. A program containing comments using characters outside this set may still be portable but the comments may look somewhat odd if the program is moved to another system with a different extended set of characters.
With modern compilation systems it is often possible to give the compiler `hints' by annotating programs with specifically structured comments which are interpreted and acted upon to produce efficient code. The HPF (High Performance Fortran) language is implemented in this way.
! Next line is an HPF directive !HPF$ PROCESSORS P(3,3,3) ! Switch to fixed format !DIR$ FIXED_FORM
Return to corresponding overview page