HP Fortran Programmer's Reference (September 2007)

Program units and procedures
Terminology and concepts
Chapter 7 155
Terminology and concepts
The following sections define the terms and explain the concepts that are mentioned
throughout this chapter.
Program units
A program consists of the following program units:
Main program unit
External procedure, which can be either a subroutine or a function
Module program unit
Block data program unit
A complete executable program contains one (and only one) main program unit and zero or
more other program units, each of which is separately compilable. A program unit is an
ordered set of constructs, statements, comments, and INCLUDE lines. The heading statement
identifies the kind of program unit; it is optional in a main program unit only. An END
statement marks the end of a program unit.
The only executable program units are the main program and external procedures.
Program execution begins with the first executable statement in the main program and ends
(typically) with the last. During execution, if the main program references an external
procedure, control passes to the procedure, which executes and returns control to the main
program. An executing procedure can also reference other procedures or even reference itself
recursively.
The main program unit is described in “Main program” on page 158, and external procedures
are described in “External procedures” on page 161.
The nonexecutable program units are:
The module program unit, which contains data declarations, user-defined type
definitions, procedure interfaces, common block declarations, namelist group declarations,
and subprogram definitions used by other program units. Modules are described in
“Modules” on page 190.
The block data program unit, which specifies initial values for variables in named
common blocks. Block data program units are described in “Block data program unit” on
page 198.