Next: MIDAS procedures
Up: Coding rules
Previous: C code
FORTRAN code
Programs written in FORTRAN must conform to the ANSI FORTRAN-77
specifications defined by ISO Std. 1539-1980(E) [6]. Five
extensions may be used to improve readability and structure of the
code. They can be removed by the MIDAS utility esoext. The
five extensions are:
- IMPLICIT NONE statements must be specified in each file in order
to ensure all variables are declared explicitly.
- INCLUDE statements may be used to include files with common
definitions, etc.
- !-comments may be used to add comments at the end of a statement
line. All characters including and after an !-mark on a line will be
regarded as comments. The usage of such comments is strongly
encourage because it significantly improves the documentation.
- DO/ENDDO statements may be used for convenience instead of the
standard FORTRAN-77 DO/CONTINUE statements.
- Long identifiers with up to 16 character including underscores
may be used. The first five and the last character (excluding
underscores) must yield a unique identifier.
The usage of these extensions is not mandatory; however, the three first
extensions are recommended in order to ensure that all variables are
declared, definitions are common in all modules and that the code
is fully documented with in-line comments.
The FORTRAN code must obey the following rules:
- All variables must be declared explicitly with type. This may be
ensured by using the IMPLICIT NONE statement or using
a compiler option which checks this.
- Indentation of at least two columns must be made for each level
of IF/ELSE/ENDIF and DO/END/CONTINUE statements.
For long DO-loops, additional comments at their start
and end are strongly encouraged. Further, statement labels
must clearly indicate the loop structure and hierarchy.
- Statement labels should be given in increasing order and
reflect the logical structure of the program. The number range
80000-81000 should be avoided because it is used by the
MIDAS preprocessor.
- When using DO/CONTINUE statements, it is recommended to
terminate the statement label after the DO with a
','(ref. ANSI FORTRAN-77) to avoid misinterpretation
even through typing errors.
- Include files should not contain executable code statements.
- Each module must contain a comment header block which defines
name, purpose, author, version etc.
(see Section ).
- Subroutines and functions may share the source file with
a main program only if they are not used in any other module.
- Internal READ statements using free or list-directed format are
not allowed (e.g. READ(LINE,*)). The general usage
of internal READ is deprecated due to usage of explicit
editing formats.
To make the code easier to understand, the usage of frequent comments,
meaningful variable names and spaces between elements are recommended
whereas GOTO statements are strongly discouraged.
A number of FORTRAN-77 statements and features have been defined
obsolete by FORTRAN-90. Although they are still valid in FORTRAN-90,
they may be recommended for deletion in new revisions. The usage of
features on the FORTRAN-90 list of obsolescent features is deprecated
for MIDAS application written in FORTRAN in order to ensure the
longest possible life time of the code. The current list of
obsolescent features in FORTRAN-90 is:
- arithmetic IF;
- branching to an ENDIF statement from outside its block;
- real and double precision DO variables and control
expressions;
- shared DO termination, and DO termination on a
statement other than on a CONTINUE and an ENDDO statement;
- ASSIGN and the assigned GOTO;
- alternate RETURN;
- PAUSE statement; and
- assigned FORMAT specifiers.
It should be noted that all 5 ESO extensions to FORTRAN-77 are
included in FORTRAN-90.
Next: MIDAS procedures
Up: Coding rules
Previous: C code