2.6. Ordering Requirements

Within program units and subprograms, there are ordering requirements for statements and constructs that were not fully described in the previous section. The ordering requirements are illustrated in Figure 2-2, and Figure 2-3.

Generally, data declarations and specifications must precede executable constructs and statements, although FORMAT, DATA, NAMELIST, and ENTRY statements can appear among the executable statements. USE statements, if any, must appear first. Internal or module subprograms, if any, must appear last following a CONTAINS statement.

Note: The Fortran standard does not allow NAMELIST statements to be intermixed with executable statements and constructs. The Cray Fortran Compiler does allow this.

In Figure 2-2 a vertical line separates statements and constructs that can be interspersed; a horizontal line separates statements that must not be interspersed.

Figure 2-2. Requirements on Statement Ordering

There are restrictions on the places where some statements may appear. Figure 2-3, summarizes these restrictions.

Note: Miscellaneous declarations are PARAMETER statements, IMPLICIT statements, type declaration statements, and specification statements.

Figure 2-3. Restrictions on the Appearance of Statements