The SECTIONS directive specifies one or more blocks of code that must be divided among threads in the team. Each section is executed once by a thread in the team.
The SECTIONS directive takes the following form:
See Section 15.2.2.3.
See Section 15.2.2.4.
See Section 15.2.2.5.
See Section 15.2.2.6.
You cannot branch into or out of the block.
Each section of code is preceded by a SECTION directive, although the directive is optional for the first section. The SECTION directives must appear within the lexical extent of the SECTIONS and END SECTIONS directive pair.
The last section ends at the END SECTIONS directive. Threads that complete execution of their SECTIONs encounter an implied barrier at the END SECTIONS directive unless NOWAIT is specified.
SECTIONS 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, subroutines XAXIS, YAXIS, and ZAXIS can be executed concurrently:
c$OMP PARALLEL
c$OMP SECTIONS
c$OMP SECTION
CALL XAXIS
c$OMP SECTION
CALL YAXIS
c$OMP SECTION
CALL ZAXIS
c$OMP END SECTIONS
c$OMP END PARALLEL