Program statements are grouped into two general classes: executable and nonexecutable. An executable statement specifies an action to be performed. A nonexecutable statement describes program attributes, such as the arrangement and characteristics of data, as well as editing and data-conversion information.
Order of Statements in a Program Unit
Figure 2-1 shows the required order of statements in a Fortran program unit. In this figure, vertical lines separate statement types that can be interspersed. For example, you can intersperse DATA statements with executable constructs.
Horizontal lines indicate statement types that cannot be interspersed. For example, you cannot intersperse DATA statements with CONTAINS statements.
PUBLIC and PRIVATE statements are only allowed in the scoping units of modules. Table 2-1 shows other statements restricted from different types of scoping units.
Scoping Unit | Restricted Statements |
---|---|
Main program | ENTRY and RETURN statements |
Module[1] | ENTRY, FORMAT, OPTIONAL, and INTENT statements, statement functions, and executable statements |
Block data program unit | CONTAINS, ENTRY, and FORMAT statements, interface blocks, statement functions, and executable statements |
Internal subprogram | CONTAINS and ENTRY statements |
Interface body | CONTAINS, DATA, ENTRY, SAVE, and FORMAT statements, statement functions, and executable statements |
[1] The scoping unit of a module does not include any module subprograms that the module contains. |
For details on scoping units, see Section 15.1.