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.8.4).
|
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 which is used to evaluate the expression.
The following topics are described in this section: