# 8.5 Functions, Subroutines, and Statement Functions

Functions, subroutines, and statement functions are user-written subprograms that perform computing procedures. The computing procedure can be either a series of arithmetic operations or a series of Fortran statements. A single subprogram can perform a computing procedure in several places in a program, to avoid duplicating a series of operations or statements in each place.

The following table shows the statements that define these subprograms, and how control is transferred to the subprogram:

Subprogram | Defining Statements | Control Transfer Method
--- | --- | ---
Function | FUNCTION or ENTRY | Function reference 1
Subroutine | SUBROUTINE or ENTRY | CALL statement 2
Statement function | Statement function definition | Function reference
1 A function can also be invoked by a defined operation (see Section 8.9.4). 2 A subroutine can also be invoked by a defined assignment (see Section 8.9.5).

A function reference is used in an expression to invoke a function; it consists of the function name and its actual arguments. The function reference returns a value to the calling expression that is used to evaluate the expression.

The following topics are described in this section:

- General rules for function and subroutine subprograms (Section 8.5.1)
- Functions (Section 8.5.2)
- Subroutines (Section 8.5.3)
- Statement functions (Section 8.5.4)

For More Information:

- On the ENTRY statement, see Section 8.11.
- On the CALL statement, see Section 7.2.

Previous Page Next Page Table of Contents