FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-6
Statement Function
3. It computes a value for expression.
4. It converts the resulting value to the data type of the function name.
When execution of the statement function terminates, FORTRAN assigns the
resulting value to the function name in the referencing statement.
In the following example, FORTRAN uses the value of (DIAMETER/2) in the
referencing statement to obtain a value for the statement function:
volume(radius) = 4.189 * radius**3 <-- statement function
sphere = volume(diameter/2) <-- referencing
statement
Note that statement function definitions and assignment statements with an array
element on the left of the equals sign look exactly the same. The difference
between them depends upon whether the name at the beginning of the statement
has been declared as an array name. Thus, the compiler interprets the following
statement
name (a, b) = expression
as a statement function definition if name has not been declared as an array name.
Each symbolic name in the expression of a statement function can reference either
a variable within the same program unit or a dummy argument of the statement
function.
You can reference a dummy argument of a function or subroutine statement in the
expression of a statement function within the same subprogram.
You can reference the dummy argument of an ENTRY statement in the expression
of a statement function only if the ENTRY statement precedes the statement
function in the same subprogram.
A statement function’s dummy argument names have the scope of the statement
function definition.