CALL statement

Standard: (F77) F90 F95 F2003 F2008 F2018 Example program


<Syntax>

CALL proc-designator [ ( [ actual-arg-list ] ) ]

proc-designator ::= subroutine-name
| procedure-pointer-name
| variable % proc-component-name
| object % type-bound-procedure-name

actual-arg-list ::= actual-arg [ , actual-arg ]...

actual-arg ::= [ dummy-name = ] variable
| [ dummy-name = ] expression
| * label

<Semantics>

Calls the named subroutine. All the expressions in the actual argument list are evaluated before the call.

Keyword arguments (with “dummy-name=”) are only allowed for internal, intrinsic and module subroutines, and for subroutines declared with an INTERFACE block. After a keyword argument, all remaining arguments must also be keyword arguments. Keyword arguments were not available in Fortran 77.

The alternate return (“* label”) is considered to be obsolescent.

Fortran 2003 added procedure pointers. A named procedure pointer can be associated with different procedures at different times by using pointer assignment. An object-bound procedure is a procedure pointer component; like named procedure pointers, these are manipulated by pointer assignment.

Fortran 2003 also added type-bound procedures, declared in a type definition. If an object is polymorphic, the particular specific procedure invoked depends on the dynamic type of the object. Thus, both type-bound and object-bound procedures are invoked via an object, but the dynamic dispatch mechanism is via the dynamic type's definition for a type-bound procedure, and via the pointer for an object-bound procedure.

<Related>

Derived-type definition, ENTRY statement, INTENT attribute, INTERFACE statement, OPTIONAL attribute, RETURN statement, SUBROUTINE statement