FORTRAN Reference Manual

FORTRAN Reference Manual528615-001
4-1
4 Program Units
This section describes the format of FORTRAN external procedures and BLOCK DATA
subprograms. Topics covered in this section include:
The Main Program and Subprograms
A program unit consists of a sequence of statements and optional comment lines, and
ends with an END statement. Each program unit is either a main program or a
subprogram.
An executable FORTRAN program must contain exactly one main program unit. A
main program is a program unit that does not have a FUNCTION, SUBROUTINE, or
BLOCK DATA statement as its first statement. It can have a PROGRAM statement as
its first statement and must end with an END statement.
In mixed-language programs, the executable program’s main routine might be written
in a language other than FORTRAN. For more information, see Section 13, Mixed-
Language Programming.
Your program begins executing with the first executable statement in your main
program.
Subprograms other than BLOCK DATA are known collectively as procedures and
include:
External functions
Subroutines
Intrinsic functions
Statement functions
Topic Page
The Main Program and Subprograms
4-1
Communication Between Program Units 4-3
Function Subprograms 4-4
Subroutines 4-7
Recursion 4-10
Using Multiple Entry Points in Functions and Subroutines 4-10
Using Adjustable Dimensions for Arrays and String Variables 4-11
Using Common Blocks 4-14
The Block Data Subprogram 4-15