Intel® Fortran Compiler 18.0 Developer Guide and Reference
Statement: Specifies that there are no data dependencies between the iterations of a DO loop. It takes the following form:
[name:] DO[,] CONCURRENT forall-header
block
[END DO [name]]
name |
(Optional) Is the name of the DO CONCURRENT construct. |
forall-header |
Is ( [ type :: ] forall-spec [, mask-expr] ) |
type |
(Optional) Is an integer data type. |
forall-spec |
Is an assignment using a triplet specification in the form index-name = forall-limit : forall-limit [ : forall-step] |
index-name |
Is a named scalar variable of type integer. It becomes defined when the index-name value set is evaluated. It has the scope of the construct. |
forall-limit |
Is a scalar integer expression. |
forall-step |
(Optional) Is a scalar integer expression. |
mask-expr |
(Optional) Is a mask expression that is scalar and of type logical. |
block |
Is a sequence of zero or more statements or constructs that make up the DO range. |
If a construct name is specified in a DO CONCURRENT statement, the same name must appear in a terminal END DO statement. If no construct name is specified in the DO CONCURRENT statement, no name can appear in the terminal END DO statement, if one is specified.
The DO CONCURRENT range is executed for every active combination of the index-name values.
Each execution of the range is an iteration. The executions can occur in any order.
If END DO is specified, it terminates the construct. If END DO is not specified, when all of the iterations have completed execution, the loop terminates, and the DO construct becomes inactive.
When the DO CONCURRENT construct terminates, a variable that is defined or becomes undefined during more than one iteration of the construct becomes undefined.
Execution of a CYCLE statement that belongs to a DO CONCURRENT construct completes execution of that iteration of the construct.
A branch within a DO CONCURRENT construct must not have a branch target that is outside the construct.
If type appears, the index-name has the specified type and type parameters. Otherwise, it has the type and type parameters that it would have if it were the name of a variable in the innermost executable construct or scoping unit.
If type does not appear, the index-name must not be the same as a local identifier, an accessible global identifier, or an identifier of an outer construct entity, except for a common block name or a scalar variable name.
The index-name of a contained FORALL or DO CONCURRENT construct must not be the same as an index-name of any of its containing FORALL or DO CONCURRENT constructs.
The following cannot appear in a DO CONCURRENT construct:
A RETURN statement
An image control statement
A reference to a nonpure procedure
A reference to module IEEE_EXCEPTIONS procedure IEEE_GET_FLAG, IEEE_SET_HALTING_MODE, or IEEE_GET_HALTING_MODE
An EXIT statement must not appear within a DO CONCURRENT construct if it belongs to that construct or an outer construct.
The following are additional rules for DO CONCURRENT constructs:
A variable that is referenced in an iteration must be previously defined during that iteration, or it must not be defined or become undefined during any other iteration.
A variable that is defined or becomes undefined by more than one iteration becomes undefined when the loop terminates.
An allocatable object that is allocated in more than one iteration must be subsequently deallocated during the same iteration in which it was allocated.
An object that is allocated or deallocated in only one iteration must not be referenced, allocated, deallocated, defined, or become undefined in a different iteration.
A pointer that is referenced in an iteration must have been pointer associated previously during that iteration, or it must not have its pointer association changed during any iteration.
A pointer that has its pointer association changed in more than one iteration has an association status of undefined when the construct terminates.
An input/output statement must not write data to a file record or position in one iteration and read from the same record or position in a different iteration.
Records written by output statements in the range of the loop to a sequential-access file appear in the file in an indeterminate order.
The restrictions on referencing variables defined in an iteration of a DO CONCURRENT construct also apply to any procedure invoked within the loop.
These restrictions ensure no interdependencies occur that might affect code optimizations.
Note that if compiler option -parallel (Linux* and macOS*) or /Qparallel (Windows*) is specified, the compiler will attempt to parallelize the construct.
The following shows a DO CONCURRENT construct:
REAL :: Q
DO CONCURRENT (I = 1:N)
Q = B(I) + C(I)
D(I) = Q + SIN(Q) + 2
END DO