DO CONCURRENT construct
Standard: F77 F90 F95 F2003 F2008 F2018 Example program
<Syntax>
A DO CONCURRENT construct is a DO construct that begins with a DO CONCURRENT statement.
The syntax of a DO CONCURRENT statement is as follows:
[ do-construct-name : ] DO [ label ] [ , ] CONCURRENT concurrent-header
where concurrent-header is
( [ integer-type-spec :: ] concurrent-control-list [ , mask-expr ] )
where concurrent-control-list is a comma-separated list of concurrent-control, which is
index-name = expr1 : expr2 [ : expr3 ]
Each expression exprn must be scalar integer, and the mask-expr (if present) must be scalar logical.
<Semantics>
A DO CONCURRENT construct is a DO loop with restrictions and semantics intended to allow efficient execution. The iterations of a DO CONCURRENT construct may be executed in any order, and possibly even in parallel.
Each loop index variable (index-name) is local to the construct; if integer-type-spec appears, each index-name has that type and kind, otherwise it has the type and kind of a variable with the same name outside the construct (and that type shall be Integer).
The set of values of a concurrent-control has size
N = MAX( 0, (expr1 − expr2 ) ÷ expr3)
where expr3 is equal to 1 if it is not present.
The index variable of a concurrent-control takes on the values in the set
{ it{expr}1+(i−1)×expr3, for i = 1 to N }
The set of iterations of a DO CONCURRENT construct is the set of all possible index variable value combinations implied by the concurrent-controls. If there is a mask-expr, only those iterations for which the mask-expr is true are executed.
The restrictions on the DO CONCURRENT construct are:
- no branch is allowed from within the construct to outside of it (RETURN and STOP are also forbidden, but ERROR STOP is allowed);
- the EXIT statement cannot be used to terminate the loop;
- the CYCLE statement cannot refer to an outer loop;
-
there must be no dependencies between loop iterations — this means that
- if a variable is assigned to by any iteration, it is not allowed to be referenced by another iteration unless that iteration assigns it a value first,
- if a pointer has its association changed by any iteration, it is not allowed to be referenced by another iteration unless that iteration changes its association first;
- if an allocatable variable is allocated by more than one iteration, it must be unallocated by the end of every iteration, and
- if an allocatable variable is used in any iteration, it must either be previously allocated by that iteration, or not allocated or deallocated by any iteration;
- all procedures referenced within the construct must be pure;
- no reference to IEEE_GET_FLAG or IEEE_SET_HALTING_MODE is allowed.
<Related>
DO construct, FORALL construct, INTEGER type, PURE attribute