Functions are invoked by a function reference in an expression or by a defined operation.
A function reference takes the following form:
Each actual argument must be a variable, an expression, or the name of a procedure. (It must not be the name of an internal procedure, statement function, or the generic name of a procedure.)
Rules and Behavior
When a function is referenced, each actual argument is associated with the corresponding dummy argument by its position in the argument list or by the name of its keyword. The arguments must agree in type and kind parameters.
Execution of the function produces a result that is assigned to the function name or to the result name, depending on whether the RESULT keyword was specified.
The program unit uses the result value to complete the evaluation of the expression containing the function reference.
If positional arguments and argument keywords are specified, the argument keywords must appear last in the actual argument list.
If a dummy argument is optional, the actual argument can be omitted.
If a dummy argument is specified with the INTENT attribute, its use may be limited. A dummy argument whose intent is not specified is subject to the limitations of its associated actual argument.
An actual argument associated with a dummy procedure must be the specific name of a procedure, or be another dummy procedure. Certain specific intrinsic function names must not be used as actual arguments (see Table 9-1).
Consider the following example:
X = 2.0 NEW_COS = COS(X) ! A function reference
Intrinsic function COS calculates the cosine of 2.0. The value -0.4161468 is returned (in place of COS(X)) and assigned to NEW_COS.
For More Information: