Function reference

A function reference is used as a primary in an expression:
Read syntax diagramSkip visual syntax diagram
                                        (1)     
>>-+-data_ref--separator-- binding_name-----+------------------->
   |                         (2)            |   
   +-procedure_component_ref----------------+   
   '-function_name--------------------------'   

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

Notes:
  1. Fortran 2003
  2. Fortran 2003
Executing a function reference 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 function.
  4. The function is executed.
  5. The value (or status or target, for pointer functions) of the function result variable is available to the referencing expression.

Fortran 2003 begins If the binding_name in a function reference is that of a specific function, the function referenced is the one identified by the binding with that name in the dynamic type of the data-ref.

If the binding_name in a function reference is that of a generic procedure, the generic binding with that name in the declared type of the data-ref is used to select a specific binding:
  1. If the reference is consistent with one of the specific bindings of that generic binding, that specific binding is selected.
  2. Otherwise, if the reference is consistent with an elemental reference to one of the specific bindings of that generic binding, that specific binding is selected.
The reference is to the procedure identified by the binding with the same name as the selected specific binding, in the dynamic type of the data-ref. Fortran 2003 ends

Execution of a function reference must not alter the value of any other data item within the statement in which the function reference appears. Invocation of a function reference in the logical expression of a logical IF statement or WHERE statement can affect entities in the statement that is executed when the value of the expression is true.

IBM extension begins 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 be specified in non-Fortran procedure references and in a subprogram statement in an interface body. (See %VAL and %REF (IBM extension).) See Statement Function and Recursion examples of function references. IBM extension ends

On entry to an allocatable function, the allocation status of the result variable becomes not allocated

The function result variable may be allocated and deallocated any number of times during the execution of the function. However, it shall be allocated and have a defined value on exit from the function. Automatic deallocation of the result variable does not occur immediately on exit from the function, but instead occurs after execution of the statement in which the function reference occurs.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us