4. Basic program structure
- Free-form source code is allowed. Statements may begin in
- Lines may extend to 132 characters.
- More than one statement may be placed on a line. A
semicolon is used as the delimiter to separate
- In-line comments are allowed. These comments begin with
an exclamation point and extend to the end of the line.
- Continuation statements are indicated by the placement of
an ampersand (&) as the last non-blank character in
the line being continued. Up to 39 continuations are
- Variable names may consist of up to 31 characters. Valid
characters include all letters, digits, and the
underscore symbol (_). The first character of a variable
name must be a letter.
- The command IMPLICIT NONE is allowed. This feature
cancels the default naming convention. When invoked,
program variables MUST be specified explicitly.
- Modified type specification statements may be used to
initialize variables or parameters, e.g.,
REAL :: Area = 0.
INTEGER :: Num_Months = 12
REAL, PARAMETER :: Pi = 3.1415927
declares Area to be a real variable with initial value
0., Num_Months to be an integer variable with the initial
value 12, and Pi a real parameter with the value
- The separator :: is required in a type specification
statement whenever it is used to initialize a variable or
to declare a special attribute (such as PARAMETER). It
may be omitted in other cases. For example, to declare
the variable Area_circle to be real, we may say
REAL :: Area_circle
The latter form is preferred for the purpose of
uniform programming style.
- The precision of a real, integer, complex, or logical
variable may be specified using a kind type parameter.
For example, to declare a variable A to be a real number
with at least 10 decimal places of precision with a range
of at least -10^34 to 10^34, do the following:
REAL(KIND = SELECTED_REAL_KIND(10,34)) :: A
If the processor you are using is unable to support a
variable with this type specification, a compile-time
error will result.
To declare a real variable to have the equivalent of
Fortran 77 accuracy DOUBLE PRECISION, simply do this:
INTEGER, PARAMETER :: DP = SELECTED_REAL_KIND(14)
REAL(KIND = DP) :: A
This declares the variable A to be of type real and
have at least 14 decimal places of accuracy.
The basic form of a Fortran 90 program is as follows:
Copyright © 1996-7 by Stanford University. All rights