### 15.2.3.12 SECTIONS Directive (TU*X only)

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:

  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 Section 15.2.1).
  clause
  Is one of the following:
  - FIRSTPRIVATE (list)

    See Section 15.2.2.3.

  - LASTPRIVATE (list)

    See Section 15.2.2.4.

  - PRIVATE (list)

    See Section 15.2.2.5.

  - REDUCTION ( operator | intrinsic : list )

    See Section 15.2.2.6.

  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.

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

Previous Page Next Page Table of Contents