FORTRAN Reference Manual

Introduction to Statements
FORTRAN Reference Manual528615-001
6-4
Statement Order
Table 6-2 lists the characteristics of each group of statements.
Statement Order
The order of statements in a FORTRAN program can determine whether the program
compiles successfully. The following list describes the order in which you can specify
statements in your FORTRAN program.
A PROGRAM statement can appear only as the first statement of a main program.
An END statement is required as the last statement of each program unit.
The first statement of a subprogram must be a FUNCTION, SUBROUTINE, or
BLOCK DATA statement.
Comments can appear anywhere in a program. FORTRAN associates comments
that follow an END statement with the program unit, if any, that begins after the
END statement.
Specification statements must precede executable statements, statement function
statements, and DATA statements in a program unit.
Within the specification statements, IMPLICIT statements must precede all other
specification statements except PARAMETER statements.
Statement function statements must precede all executable statements.
If the default type of the symbolic name of a constant is not the correct type, you
must specify the symbolic name’s type prior to its first appearance in a
PARAMETER statement.
The PARAMETER statement must precede any statement that refers to the entity
defined by the PARAMETER statement.
FORMAT statements can appear anywhere in a program unit.
ENTRY statements can appear anywhere in a program unit except in the body of a
block-IF or DO statement.
Table 6-2. FORTRAN Statement Types
Type Action
Program unit Nonexecutable. Marks the beginning or end of a program unit.
Specification Nonexecutable. Specifies the characteristics of the user-defined
symbolic names used in the program.
Assignment Executable. Defines or redefines the values of variables in a program.
Control Executable. Modifies the normal sequential flow of execution in a
program.
I/O Executable. Transfers data between your program and internal or
external files, and returns information about the status of files.