XL Fortran for AIX 8.1

Language Reference

CALL

Purpose

The CALL statement invokes a subroutine to be executed.

Format



>>-CALL--name--+-------------------------------------+---------><
               '-(--+---------------------------+--)-'
                    '-actual_argument_spec_list-'
 
 

name
is the name of an internal, external, or module subroutine, an entry in an external or module subroutine, an intrinsic subroutine, or a generic name.

Rules

Executing a CALL statement results in the following order of events:

  1. Actual arguments that are expressions are evaluated.
  2. Actual arguments are associated with their corresponding dummy arguments.
  3. Control transfers to the specified subroutine.
  4. The subroutine is executed.
  5. Control returns from the subroutine.

A subprogram can call itself recursively, directly or indirectly, if the subroutine statement specifies the RECURSIVE keyword.

+-------------------------------IBM Extension--------------------------------+

An external subprogram can also refer to itself directly or indirectly if the -qrecur compiler option is specified.

+----------------------------End of IBM Extension----------------------------+

If a CALL statement includes one or more alternate return specifiers among its arguments, control may be transferred to one of the statement labels indicated, depending on the action specified by the subroutine in the RETURN statement.

+-------------------------------IBM Extension--------------------------------+

The argument list built-in functions %VAL and %REF are supplied to aid interlanguage calls by allowing arguments to be passed by value and by reference, respectively. They can only be specified in non-Fortran procedure references.

+----------------------------End of IBM Extension----------------------------+

Examples

INTERFACE
  SUBROUTINE SUB3(D1,D2)
    REAL D1,D2
  END SUBROUTINE
END INTERFACE
ARG1=7 ; ARG2=8
CALL SUB3(D2=ARG2,D1=ARG1)    ! subroutine call with argument keywords
END
 
SUBROUTINE SUB3(F1,F2)
  REAL F1,F2,F3,F4
  F3 = F1/F2
  F4 = F1-F2
  PRINT *, F3, F4
END SUBROUTINE

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]