15.2.3.14 THREADPRIVATE Directive (TU*X only)

The THREADPRIVATE directive specifies named common blocks to be private (local) to a thread; they are global within the thread. It takes the following form:

c$OMP THREADPRIVATE( /cb/ [, /cb/]...)

c
Is one of the following: C (or c), !, or * (see Section 15.2.1).


cb
Is the name of the common block you want made private to a thread. Only named common blocks can be made thread private. Note that the slashes ( / ) are required.

Rules and Behavior

Each thread gets its own copy of the common block, so data written to the common block by one thread is not directly visible to other threads.

During serial portions and MASTER sections of the program, accesses are to the master thread copy of the common block. On entry to the first parallel region, data in the THREADPRIVATE common blocks should be assumed to be undefined unless a COPYIN clause is specified in the PARALLEL directive.

When a common block (which is initialized using DATA statements) appears in a THREADPRIVATE directive, each thread copy is initialized once prior to its first use. For subsequent parallel regions, data in THREADPRIVATE common blocks are guaranteed to persist only if the dynamic threads mechanism has been disabled and if the number of threads are the same for all the parallel regions.

A THREADPRIVATE common block or its constituent variables can appear only in a COPYIN clause. They are not permitted in a PRIVATE, FIRSTPRIVATE, LASTPRIVATE, SHARED, or REDUCTION clause. They are not affected by the DEFAULT clause.

Examples

In the following example, the common blocks BLK1 and FIELDS are specified as thread private:

        COMMON /BLK/ SCRATCH
        COMMON /FIELDS/ XFIELD, YFIELD, ZFIELD
  c$OMP THREADPRIVATE(/BLK/,/FIELDS/)
  c$OMP PARALLEL DEFAULT(PRIVATE) COPYIN(/BLK1/,ZFIELD)


Previous Page Next Page Table of Contents