HOME
| OPENMP API Specification: Version 5.0 November 2018

2.1  Directive Format

SVG-Viewer needed.

OpenMP directives for C/C++ are specified with #pragma directives. The syntax of an OpenMP directive is as follows:  

 
#pragma omp directive-name [clause[ [,] clause] ... ] new-line  

Each directive starts with #pragma omp. The remainder of the directive follows the conventions of the C and C++ standards for compiler directives. In particular, white space can be used before and after the #, and sometimes white space must be used to separate the words in a directive. Preprocessing tokens following #pragma omp are subject to macro replacement.

Some OpenMP directives may be composed of consecutive #pragma directives if specified in their syntax.

Directives are case-sensitive.

Each of the expressions used in the OpenMP syntax inside of the clauses must be a valid assignment-expression of the base language unless otherwise specified.

SVG-Viewer needed.

SVG-Viewer needed.

Directives may not appear in constexpr functions or in constant expressions. Variadic parameter packs cannot be expanded into a directive or its clauses except as part of an expression argument to be evaluated by the base language, such as into a function call inside an if clause.

SVG-Viewer needed.

SVG-Viewer needed.

OpenMP directives for Fortran are specified as follows:  

 
sentinel directive-name [clause[ [,] clause]...]  

All OpenMP compiler directives must begin with a directive sentinel. The format of a sentinel differs between fixed form and free form source files, as described in Section 2.1.1 on page 111 and Section 2.1.2 on page 112.

Directives are case insensitive. Directives cannot be embedded within continued statements, and statements cannot be embedded within directives.

Each of the expressions used in the OpenMP syntax inside of the clauses must be a valid expression of the base language unless otherwise specified.

In order to simplify the presentation, free form is used for the syntax of OpenMP directives for Fortran in the remainder of this document, except as noted.

SVG-Viewer needed.

Only one directive-name can be specified per directive (note that this includes combined directives, see Section 2.13 on page 531). The order in which clauses appear on directives is not significant. Clauses on directives may be repeated as needed, subject to the restrictions listed in the description of each clause.

Some clauses accept a list, an extended-list, or a locator-list. A list consists of a comma-separated collection of one or more list items. An extended-list consists of a comma-separated collection of one or more extended list items. A locator-list consists of a comma-separated collection of one or more locator list items.

SVG-Viewer needed.

A list item is a variable or an array section. An extended list item is a list item or a function name. A locator list item is any lvalue expression, including variables, or an array section.

SVG-Viewer needed.

SVG-Viewer needed.

A list item is a variable, array section or common block name (enclosed in slashes). An extended list item is a list item or a procedure name. A locator list item is a list item.

When a named common block appears in a list, it has the same meaning as if every explicit member of the common block appeared in the list. An explicit member of a common block is a variable that is named in a COMMON statement that specifies the common block name and is declared in the same scoping unit in which the clause appears.

Although variables in common blocks can be accessed by use association or host association, common block names cannot. As a result, a common block name specified in a data-sharing attribute, a data copying or a data-mapping attribute clause must be declared to be a common block in the same scoping unit in which the clause appears.

If a list item that appears in a directive or clause is an optional dummy argument that is not present, the directive or clause for that list item is ignored.

If the variable referenced inside a construct is an optional dummy argument that is not present, any explicitly determined, implicitly determined, or predetermined data-sharing and data-mapping attribute rules for that variable are ignored. Otherwise, if the variable is an optional dummy argument that is present, it is present inside the construct.

SVG-Viewer needed.

For all base languages, a list item, an extended list item, or a locator list item is subject to the restrictions specified in Section 2.1.5 on page 118 and in each of the sections describing clauses and directives for which the list, the extended-list, or the locator-list appears.

Some executable directives include a structured block. A structured block:

  2.1.1  Fixed Source Form Directives
  2.1.2  Free Source Form Directives
  2.1.3  Stand-Alone Directives
  2.1.4  Array Shaping
  2.1.5  Array Sections
  2.1.6  Iterators

RestrictionsRestrictions to structured blocks are as follows:

SVG-Viewer needed.