ELEMENTAL

Keyword: Asserts that a user-defined procedure is a restricted form of pure procedure. This is a Fortran 95 feature.

To specify an elemental procedure, use this keyword in a FUNCTION or SUBROUTINE statement.

An explicit interface must be visible to the caller of an ELEMENTAL procedure.

An elemental procedure can be passed an array, which is acted upon one element at a time.

For functions, the result must be scalar; it cannot have the POINTER attribute.

Dummy arguments have the following restrictions:

If the actual arguments are all scalar, the result is scalar. If the actual arguments are array valued, the values of the elements (if any) of the result are the same as if the function or subroutine had been applied separately, in any order, to corresponding elements of each array actual argument.

Elemental procedures are pure procedures and all rules that apply to pure procedures also apply to elemental procedures.

See Also: FUNCTION, SUBROUTINE, Determining When Procedures Require Explicit Interfaces, Optional Arguments

Examples

Consider the following:

  MIN (A, 0, B)             ! A and B are arrays of shape (S, T)

In this case, the elemental reference to the MIN intrinsic function is an array expression whose elements have the following values:

  MIN (A(I,J), 0, B(I,J)), I = 1, 2, ..., S, J = 1, 2, ..., T