Next:
Elemental Reference of Up: Elemental Reference of Previous: Elemental Reference of


Elemental Reference of Pure Functions

A user-defined pure function may be referenced elementally, provided it satisfies the additional constraints that:

  1. Its dummy arguments (except procedure dummy arguments) and result are scalar and do not have the POINTER attribute.
  2. The length of any character dummy argument or result is independent of argument values (though it may be assumed, or depend on the lengths of other character arguments and/or a character result).

We call user-written pure functions that satisfy these constraints ``elemental non-intrinsic functions'', and use the term ``elemental function'' to include both elemental intrinsic and non-intrinsic functions.

The interpretation of an elemental reference of such a function is as follows (adapted from Section 12.4.3 of the Fortran 90 standard):

A reference to an elemental function is an elemental reference if one or more actual arguments are arrays and all array arguments have the same shape. If any actual argument is a function, its result must have the same shape as that of the corresponding function dummy procedure.

The result of such a reference has the same shape as the array arguments, and the value of each element of the result, if any, is obtained by evaluating the function using the scalar and procedure arguments and the corresponding elements of the array arguments. The elements of the result may be evaluated in any order.

Example: INTERFACE REAL, ELEMENTAL FUNCTION foo (x, y, z, dummy_func) REAL, INTENT(IN) :: x, y, z INTERFACE ! interface for 'dummy_func'' REAL, ELEMENTAL FUNCTION dummy_func (x) REAL, INTENT(IN) :: x END FUNCTION dummy_func END INTERFACE END FUNCTION foo END INTERFACE

REAL a(100), b(100), c(100)

c = foo (a, 0.0, b, sin)

paula@erc.msstate.edu
Thu May 5 15:11:02 CDT 1994