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: SHARED Clause

Purpose:

The SHARED clause declares variables in its list to be shared among all threads in the team.

Format:

Fortran

SHARED (list)

C/C++

shared (list)

Notes:

A shared variable exists in only one memory location and all threads can read or write to that address.

It is the programmer’s responsibility to ensure that multiple threads properly access SHARED variables (such as via CRITICAL sections).