« previous next»

2.1    Basic Fortran

    There is some basic information that everyone should know when beginning to use Fortran.  First of all, Fortran 90 is case insensitive, meaning A is the same as a, WriTe is the same as WRITe, etc..  However, when programming it is common (i.e. good) practice to use uppercase when writing Fortran keywords (i.e. WRITE, REAL, PARAMETER, etc.).  Also, you should always be consistent when using upper of lowercase.  It makes your code more readable and less confusing to others (like the graders) when deciphering your code.

      The available character set for Fortran 90 is given in A.1.1.

    Fortran 90 is free source form, unlike FORTRAN 77 which was fixed source.  Fixed form, which dates back to the use of punch cards, meant that statement labels had to appear in the first five columns, column six was used for a continuation indicator, and statements appeared on lines 7-72.   In Fortran 90 free source form means you are free to type comments and commands wherever you want. An exclamation point, ! (also known as a "bang"), is used to indicate a comment statement.  The comment statement follows the bang and continues to the end of the line.  Comment statements are ignored by the compiler, but are very important for documenting your program.  It is important to use comments frequently to clarify the procedures intended in a program.  Comments can be of great assistance to debugging and revising computer programs.

    A line of Fortran 90 code can have a maximum of 132 characters.  An ampersand (&) is placed at the end of a line to indicate that it continues on the next line.  At most 39 continuation lines are permitted.  If continuing a character string an ampersand must be placed at the end of the first line and the beginning of the next.  Only with character strings is the ampersand needed at the start of the next line. 

Example:

PROGRAM test
! This line is a comment
! Comments are ignored by the compiler
a = 3.0 + 4.0 + &
     13.0
! After execution variable a will have the value 20.0
PRINT* a
END

« previous next»