OpenMP* Fortran Compiler Directive: Provides an abbreviated way to specify a parallel region containing a single DO directive.
Syntax
c$OMP PARALLEL DO [clause[[,] clause] ... ]
do-loop
[c$OMP END PARALLEL DO]
c
Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).
clause
Can be any of the clauses accepted by the DO or PARALLEL directives.
do-loop
Is a DO iteration (a DO loop). It cannot be a DO WHILE or a DO loop without loop control. The DO loop iteration variable must be of type integer.
You cannot branch out of a DO loop associated with a DO directive.
Description
If the END PARALLEL DO directive is not specified, the PARALLEL DO is assumed to end with the DO loop that immediately follows the PARALLEL DO directive. If used, the END PARALLEL DO directive must appear immediately after the end of the DO loop.
The semantics are identical to explicitly specifying a PARALLEL directive immediately followed by a DO directive.
See Also
OpenMP Fortran Compiler Directives, Optimizing Applications: Rules for General Directives that Affect DO Loops, Optimizing Applications: Combined Parallel and Worksharing Constructs, Optimizing Applications: COPYIN Clause, Optimizing Applications: DEFAULT Clause, Optimizing Applications: OpenMP* Directives and Clauses Summary, Optimizing Applications: PRIVATE, FIRSTPRIVATE, and LASTPRIVATE Clauses, Optimizing Applications: REDUCTION Clause, Optimizing Applications: SHARED Clause, Optimizing Applications: Synchronization Constructs
Examples
In the following example, the loop iteration variable is private by default and it is not necessary to explicitly declare it. The END PARALLEL DO directive is optional:
c$OMP PARALLEL DO
DO I=1,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
c$OMP END PARALLEL DO
The following example shows how to use the REDUCTION clause in a PARALLEL DO directive:
c$OMP PARALLEL DO DEFAULT(PRIVATE) REDUCTION(+: A,B)
DO I=1,N
CALL WORK(ALOCAL,BLOCAL)
A = A + ALOCAL
B = B + BLOCAL
END DO
c$OMP END PARALLEL DO