Intel® Fortran Compiler 16.0 User and Reference Guide

ELEMENTAL

Keyword: Asserts that a user-defined procedure is defined on scalar arguments that may be called with array arguments. An elemental procedure may be a pure procedure or an impure procedure.

Description

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 or ALLOCATABLE 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, unless you specify that the elemental procedure is IMPURE. In that case, the rules for pure procedures do not apply.

Example

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

See Also