Transfers control and passes arguments to a subprogram. Statement
format:
CALL sub[([a][,[a]]...)]
sub Is the name of the subroutine subprogram or other
external procedure, or a dummy argument associated
with a subroutine subprogram or other external
procedure.
a Is an actual argument optionally preceded by [keyword=],
where "keyword" is the name of a dummy argument in the
explicit interface for the subroutine. The keyword is
assigned a value when the procedure is invoked.
Each actual argument must be a variable, an expression, the name of
a procedure, or an alternate return specifier. (It must not be the
name of an internal procedure, statement function, or the generic
name of a procedure.)
An alternate return specifier is an asterisk (*) or ampersand (&)
followed by the label of an executable branch target statement in
the same scoping unit as the CALL statement.
NOTE
An alternate return is an obsolescent feature in
Fortran 95 and Fortran 90. VSI Fortran fully
supports this feature.
When the CALL statement is executed, any expressions in the actual
argument list are evaluated, then control is passed to the first
executable statement or construct in the subroutine. When the
subroutine finishes executing, control returns to the next
executable statement following the CALL statement, or to a
statement identified by an alternate return label (if any).
If an argument list appears, 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 type parameters.
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.
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 the HP Fortran for OpenVMS Language
Reference Manual.)
You can use a CALL statement to invoke a function as long as the
function is not one of the following types:
o REAL(8)
o REAL(16)
o COMPLEX(8)
o COMPLEX(16)
o CHARACTER
EXAMPLES:
The following example shows a subroutine with argument keywords:
PROGRAM KEYWORD_EXAMPLE
INTERFACE
SUBROUTINE TEST_C(I, L, J, KYWD2, D, F, KYWD1)
INTEGER I, L(20), J, KYWD1
REAL, OPTIONAL :: D, F
COMPLEX KYWD2
...
END SUBROUTINE TEST_C
END INTERFACE
INTEGER I, J, K
INTEGER L(20)
COMPLEX Z1
CALL TEST_C(I, L, J, KYWD1 = K, KYWD2 = Z1)
...
The first three actual arguments are associated with their
corresponding dummy arguments by position. The argument keywords
are associated by keyword name, so they can appear in any order.
Note that the interface to subroutine TEST has two optional
arguments that have been omitted in the CALL statement.