Intel® Fortran Compiler 18.0 Developer Guide and Reference

FIRSTPRIVATE

Parallel Directive Clause: Provides a superset of the functionality provided by the PRIVATE clause. It declares one or more variables to be private to each thread in a team, and initializes each of them with the value of the corresponding original variable.

FIRSTPRIVATE (list)

list

Is the name of one or more variables or common blocks that are accessible to the scoping unit. Subobjects cannot be specified. Each name must be separated by a comma, and a named common block must appear between slashes (/ /).

Variables that appear in a FIRSTPRIVATE list are subject to PRIVATE clause semantics. In addition, private (local) copies of each variable in the different threads are initialized to the value the variable had upon entering the parallel region.

To avoid race conditions, which are caused by unintended sharing of data, concurrent updates of the original variable must be synchronized with the read of the original variable that occurs as a result of the FIRSTPRIVATE clause.

If the original variable has the POINTER attribute, the new variable receives the same association status of the original variable as if by pointer assignment.

If the original variable does not have the POINTER attribute, initialization of the new variable occurs as if by intrinsic assignment, unless the original variable has the allocation status of "not currently allocated". In this case, the new variable also has the status of " not currently un allocated".

The following are restrictions for the FIRSTPRIVATE clause:

NOTE

If a variable appears in both FIRSTPRIVATE and LASTPRIVATE clauses, the update required for LASTPRIVATE occurs after all initializations for FIRSTPRIVATE..

Example

Consider the following:

A = 3
B = 4
!$OMP PARALLEL PRIVATE(A) FIRSTPRIVATE(B)

In this case, variable A has an undefined value at the beginning of the parallel region. However, variable B has the value 4, which was specified in the serial region preceding the parallel region.

See Also