# 6 Subprograms: Subroutines and Functions

A subprogram is a program unit that can be invoked from another program unit to perform a specific task. These subprograms are either written by the user or supplied as part of the Fortran library.

User-written subprograms include the following:

- Statement functions: A computing procedure defined by a single statement that is similar in form to an assignment statement. A statement function is invoked by a function reference in a main program unit or a subprogram unit.

- Function subprograms: Program units, also called functions, that contain a set of commonly used computations. A function subprogram's first statement is a FUNCTION statement, optionally preceded by an OPTIONS statement. A function subprogram is invoked by a function reference in a main program unit or a subprogram unit.

- Subroutine subprograms: Program units, also called subroutines, that contain a set of commonly used computations. A subroutine subprogram's first statement is a SUBROUTINE statement, optionally preceded by an OPTIONS statement. A subroutine subprogram receives control when it is invoked with a CALL statement and returns control with a RETURN statement.

Subprograms supplied as part of the Fortran library are called intrinsic subprograms (or procedures). They perform mathematical, numeric, bit manipulation, character, and miscellaneous functions.

For More Information:

- On user-written subprograms, see Section 6.2.

- On intrinsic functions, see Section C.2.

Previous Page Next Page Table of Contents