An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.


Home

OpenMP Directives: Data Scope Attribute Clauses: PRIVATE Clause

Purpose:

The PRIVATE clause declares variables in its list to be private to each thread.

Format:

Fortran

PRIVATE (list)

C/C++

private (list)

Notes:

  • PRIVATE variables behave as follows:
    • A new object of the same type is declared once for each thread in the team
    • All references to the original object are replaced with references to the new object
    • Variables declared PRIVATE should be assumed to be uninitialized for each thread
  • Comparison between PRIVATE and THREADPRIVATE:
PRIVATE THREADPRIVATE
Data Item C/C++: variable
Fortran: variable or common block
C/C++: variable
Fortran: common block
Where Declared At start of region or work-sharing group In declarations of each routine using block or global file scope
Persistent? No Yes
Extent Lexical only - unless passed as an argument to subroutine Dynamic
Initialized Use FIRSTPRIVATE Use COPYIN