Welcome to AE Resources
Converted document Converted document

FORTRAN 90+: COMMENTS

It is good practice to use comments to document a code and to make it flow more naturally. Comments can take two forms:
Any character after an exclamation point, “!” , on a line of code is ignored, unless the “!” is part of a quotation. Some valid comments include:
PROGRAM demo
!  Start the loop by initializing the start value
    x1 = 10.0			! This is the initial value of x
!
    x = x1 + 2.0
!
END PROGRAM demo
While the exclamation point can be used to create a blank line as a comment for spacing, it is not necessary. The Fortran compiler assumes that a blank line is a comment. Thus the code below is identical to the code above.
PROGRAM demo
!  Start the loop by initializing the start value
    x1 = 10.0			! This is the initial value of x
​
    x = x1 + 2.0
    
END PROGRAM demo