Visible to Intel only — GUID: GUID-A77C999A-2867-4D78-B60D-E5DD565E9A4D
Visible to Intel only — GUID: GUID-A77C999A-2867-4D78-B60D-E5DD565E9A4D
ELEMENTAL
Keyword: Asserts that a user-defined procedure is defined in scalar arguments that can be called with array arguments. Unless declared IMPURE, an ELEMENTAL procedure is by default PURE.
Description
An elemental procedure is an elemental intrinsic procedure, an intrinsic module procedure that is specified to be elemental, a user-defined procedure that is specified to be elemental, or a type-bound procedure that is bound to an elemental procedure. A procedure pointer or a dummy procedure cannot be specified to be elemental.
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 in ELEMENTAL procedures may appear in specification expressions in the procedure.
Dummy arguments have the following restrictions:
They must be scalar.
They cannot have the POINTER or ALLOCATABLE attribute.
They cannot be an alternate return specifier (*).
They cannot be dummy procedures.
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 by default 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
Consider the following example:
ELEMENTAL REAL FUNCTION F (A, B, ORDER)
REAL, INTENT (IN) :: A, B
INTEGER, INTENT (IN) :: ORDER
REAL :: TEMP (ORDER)
In the above, the size of TEMP depends on the specification expression that is the value of the ORDER dummy argument.