Directive clauses

You can use directive clauses to specify additional information to directives.

Global rules for directive clauses

You must not specify a variable or common block name more than once in a clause.

A variable, common block name, or variable name that is a member of a common block must not appear in more than one clause on the same directive, with the following exceptions:
  • You can define a named common block or named variable as FIRSTPRIVATE and LASTPRIVATE for the same directive.
  • A variable appearing in a NUM_THREADS clause can appear in another clause for the same directive.
  • A variable appearing in a IF clause can appear in another clause for the same directive.

If you do not specify a clause that changes the scope of a variable, the default scope for variables affected by a directive is SHARED.

A local variable with the SAVE or STATIC attribute declared in a procedure referenced a parallel region has an implicit SHARED attribute. A local variable without the SAVE or STATIC attribute declared in a procedure referenced a parallel region has an implicit PRIVATE attribute.

Members of common blocks and variables of modules declared in a procedure referenced within the dynamic extent of a parallel region have an implicit SHARED attribute, unless they are THREADLOCAL or THREADPRIVATE common blocks and module variables.

While a parallel or work-sharing construct is running, a variable or variable subobject used in a PRIVATE, FIRSTPRIVATE, LASTPRIVATE or REDUCTION clause of the directive must not be referenced, become defined, become undefined, have its association status or allocation status changed, or appear as an actual argument:
  • In a scoping unit other than the one in which the directive construct appears
  • In a variable format expression
You can declare a variable as PRIVATE, FIRSTPRIVATE, LASTPRIVATE, or REDUCTION, even if that variable is already storage associated with other variables. Storage association may exist for variables declared in EQUIVALENCE statements or in COMMON blocks. If a variable is storage associated with a PRIVATE, FIRSTPRIVATE, LASTPRIVATE, or REDUCTION variable, then:
  • The contents, allocation status and association status of the variable that is storage associated with the PRIVATE, FIRSTPRIVATE, LASTPRIVATE or REDUCTION variable are undefined on entry to the parallel construct.
  • The allocation status, association status and the contents of the associated variable become undefined if you define the PRIVATE, FIRSTPRIVATE, LASTPRIVATE or REDUCTION variable or if you define that variable's allocation or association status.
  • The allocation status, association status and the contents of the PRIVATE, FIRSTPRIVATE, LASTPRIVATE or REDUCTION variable become undefined if you define the associated variable or if you define the associated variable's allocation or association status.

Pointers and OpenMP API

OpenMP API allows a variable or variable subobject of a PRIVATE clause to have the POINTER or ALLOCATABLE attribute. The association status of the pointer is undefined at thread creation and when the thread is destroyed.

See the following topics for more information about the directive clauses:



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us