Program units, procedures, and subprograms

A program unit is a sequence of one or more lines, organized as statements, comments, and directives. A subprogram is either a function or a subroutine, and is either an internal, external, or module subprogram. Specifically, a program unit can be:
  • The main program
  • A module
  • Fortran 2008 beginsA submoduleFortran 2008 ends
  • A block data program unit
  • An external function subprogram
  • An external subroutine subprogram

An executable program is a collection of program units consisting of one main program and any number of external subprograms, modules, Fortran 2008 beginssubmodulesFortran 2008 ends, and block data program units.

A subprogram can be invoked by a main program or by another subprogram to perform a particular activity. When a procedure is invoked, the referenced subprogram is executed.

An external or module subprogram can contain multiple ENTRY statements. The subprogram defines a procedure for the SUBROUTINE or FUNCTION statement, as well as one procedure for each ENTRY statement.

An external procedure is defined either by an external subprogram or by a program unit in a programming language other than Fortran.

Main programs, external procedures, block data program units, common blocks, entities with binding labels, modules, and Fortran 2008 beginssubmodulesFortran 2008 ends are global entities. Internal and module procedures are local entities.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us