Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Program Units and Procedures

A Fortran program consists of one or more program units. There are four types of program units:

  • Main program

    The program unit that denotes the beginning of execution. It may or may not have a PROGRAM statement as its first statement.

  • External procedures

    Program units that are either user-written functions or subroutines.

  • Modules and submodules

    Program units that contain declarations, type definitions, procedures, or interfaces that can be shared by other program units. A module can be extended by one or more program units called submodules. A submodule can in turn be extended by one or more submodules.

  • Block data program units

    Program units that provide initial values for variables in named common blocks.

A program unit does not have to contain executable statements; for example, it can be a module containing interface blocks for subroutines.

A procedure can be invoked during program execution to perform a specific task. It specifies the EXTERNAL attribute for all procedure entities in the procedure declaration list. A procedure declaration is denoted by a PROCEDURE statement.

There are several kinds of procedures, as follows:

Kind of Procedure

Description

External Procedure

A procedure that is not part of any other program unit.

Module Procedure

A procedure defined within a module.

Internal Procedure1

A procedure (other than a statement function) contained within a main program, function, or subroutine.

Intrinsic Procedure

A procedure defined by the Fortran language.

Dummy Procedure

A dummy argument specified as a procedure or appearing in a procedure reference. A dummy procedure with the POINTER attribute is a dummy procedure pointer.

Procedure Pointer

A procedure that has the EXTERNAL and POINTER attributes. It may be pointer associated with an external procedure, a module procedure, an intrinsic procedure, or a dummy procedure that is not a procedure pointer.

Statement function

A computing procedure defined by a single statement.

1 The program unit that contains an internal procedure is called its host.

A function is invoked in an expression using the name of the function or a defined operator. It returns a a single value (function result) that is used to evaluate the expression.

A subroutine is invoked in a CALL statement or by a defined assignment statement. It does not directly return a value, but values can be passed back to the calling program unit through arguments (or variables) known to the calling program.

Recursion (direct or indirect) is permitted for functions and subroutines.

A procedure interface refers to the properties of a procedure that interact with or are of concern to the calling program. A procedure interface can be explicitly defined in interface blocks. All program units, except block data program units, can contain interface blocks.