All HP Fortran statements are fully described in
alphabetical order in Chapter 10, “HP Fortran Statements.”
The required order
for statements in a standard Fortran 90 program unit is
illustrated in Table 2-2 “Statement order in a program unit”. Vertical
lines separate statements that can be interspersed, and horizontal
lines separate statements that cannot be interspersed. For example,
the DATA statement can appear among executable statements
but may not be interspersed with CONTAIN statements. Also, the USE statement, if present, must immediately follow
the program unit heading.
Table 2-2 Statement order in a program unit
| PROGRAM, FUNCTION, SUBROUTINE, MODULE, or BLOCK DATA statement |
| USE statement |
| | IMPLICIT NONE statement |
| | PARAMETER statement | IMPLICIT statement |
| FORMAT | | Derived-type definitions, |
| and | PARAMETER and | Interface blocks, |
| ENTRY | DATA statements | Type declarations, |
| statements | | Statement functions, and |
| | | Specification statements |
| | DATA statements | Executable constructs |
| CONTAINS statement |
| Internal subprograms or module
subprograms |
| END statement |
Table 2-2 “Statement order in a program unit” does not show where comments, the
INCLUDE line, and directives may appear. Comments may
appear anywhere in a source file, including after the END statement. The INCLUDE line may appear anywhere before the END PROGRAM statement.
Table 2-3 “Statements allowed in scoping units” identifies which statements
may appear within a scoping unit; a check mark indicates that a
statement is allowed in the specified scoping unit. For the purpose
of this table, type declarations include the
PARAMETER statement, the IMPLICIT statement, type declaration statements, derived-type
definitions, and specification statements.
Table 2-3 Statements allowed in scoping units
| | Scoping units |
|---|
| Statements | Main program | External procedure | Module | Module procedure | Internal procedure | Interface body | Block data program
unit |
|---|
| CONTAINS | ✓ | ✓ | ✓ | ✓ | | | |
| DATA | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ |
| ENTRY | | ✓ | | ✓ | | | |
| Executable | ✓ | ✓ | | ✓ | ✓ | | |
| FORMAT | ✓ | ✓ | | ✓ | ✓ | | |
| Interface block | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Statement function | ✓ | ✓ | | ✓ | ✓ | | |
| Type declaration | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| USE | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |