SECTIONS (TU*X only)

OpenMP Parallel Compiler 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.

Syntax

c$OMP SECTIONS [clause[[,] clause] ... ]
[c$OMP SECTION]
     block
[c$OMP SECTION
     block] ...
c$OMP END SECTIONS [NOWAIT]


c
Is one of the following: C (or c), !, or * (see Syntax Rules for Parallel Directives).


clause
Is one of the following:



block
Is a structured block (section) of statements or constructs. Any constituent section must also be a structured block.

You cannot branch into or out of the block.

Rules and Behavior

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.

See Also: Parallel Directives for Tru64 UNIX Systems, OpenMP Fortran API Compiler Directives (TU*X only), Compaq Fortran Parallel Compiler Directives (TU*X only)

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