The SINGLE directive specifies that a block of code is to be executed by only one thread in the team. It takes the following form:
See Section 15.2.2.3.
See Section 15.2.2.5.
Threads in the team that are not executing this directive wait at the END SINGLE directive unless NOWAIT is specified.
SINGLE directives must be encountered by all threads in a team or by none at all. It must also be encountered in the same order by all threads in a team.
Examples
In the following example, the first thread that encounters the SINGLE directive executes subroutines OUTPUT and INPUT:
c$OMP PARALLEL DEFAULT(SHARED)
CALL WORK(X)
c$OMP BARRIER
c$OMP SINGLE
CALL OUTPUT(X)
CALL INPUT(Y)
c$OMP END SINGLE
CALL WORK(Y)
c$OMP END PARALLEL
You should not make assumptions as to which thread executes the SINGLE section. All other threads skip the SINGLE section and stop at the barrier at the END SINGLE construct. If other threads can proceed without waiting for the thread executing the SINGLE section, you can specify NOWAIT in the END SINGLE directive.