This section defines several categories of directives and constructs. OpenMP directives are specified with a
directive-specification. A directive-specification consists of the directive-specifier and any clauses that may
optionally be associated with the OpenMP directive:
directive-specifier [[,] clause[ [,] clause] ... ]
directive-name
or for argument-modified directives:
directive-name[(directive-arguments)]
Some OpenMP directives specify a paired end directive, where the directive-name of the paired end directives is:
If directive-name starts with begin, the end-directive-name replaces begin with end
otherwise it is end directive-name unless otherwise specified.
The directive-specification of a paired end directive may include one or more optional end-clause:
directive-specifier [[,] end-clause[ [,] end-clause]...]
where end-clause has the end-clause property, which explicitly allows it on a paired end directive.
#pragma omp directive-specification new-line
_Pragma("omp directive-specification")
The use of omp as the first preprocessing token of a pragma directive is reserved for OpenMP directives that are defined in this specification. The use of ompx as the first preprocessing token of a pragma directive is reserved for implementation-defined extensions to the OpenMP directives.
White space can be used before and after the #. Preprocessing tokens in directive-specification of #pragma and _Pragma pragmas are subject to macro expansion.
[[ omp :: directive-attr ]]
[[ using omp : directive-attr ]]
directive( directive-specification )
sequence( [omp::]directive-attr [[, [omp::]directive-attr] ... ] )
Multiple attributes on the same statement are allowed. Attribute directives that apply to the same statement are unordered unless the sequence attribute is specified, in which case the right-to-left ordering applies. The omp:: namespace qualifier within a sequence attribute is optional. The application of multiple attributes in a sequence attribute is ordered as if each directive had been specified as a pragma directive on subsequent lines.
The use of omp as the attribute namespace of an attribute specifier, or as the optional namespace qualifier within a sequence attribute, is reserved for OpenMP directives that are defined in this specification. The use of ompx as the attribute namespace of an attribute specifier, or as the optional namespace qualifier within a sequence attribute, is reserved for implementation-defined extensions to the OpenMP directives.
The pragma and attribute forms are interchangeable for any OpenMP directive. Some OpenMP directives may be composed of consecutive attribute specifiers if specified in their syntax. Any two consecutive attribute specifiers may be reordered or expressed as a single attribute specifier, as permitted by the base language, without changing the behavior of the OpenMP directive.
sentinel directive-specification
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 3.1.1 and Section 3.1.2. In order to simplify the presentation, free form is used for the syntax of OpenMP directives for Fortran throughout this document, except as noted.
Directives are case insensitive. Directives cannot be embedded within continued statements, and statements cannot be embedded within directives. Each expression used in the OpenMP syntax inside of a clause must be a valid expression of the base language unless otherwise specified.
A directive may be categorized as one of the following:
meta
declarative
executable
informational
utility
subsidiary
Base language code can be associated with directives. The directive’s association can be categorized as:
none
block-associated
loop-associated
declaration-associated
delimited
separating
A directive and its associated base language code constitute a syntactic formation that follows the syntax given below. The end-directive in a specified formation refers to the paired end directive for the directive. An OpenMP construct is a formation for which the directive is executable.
Directives with an association of none are not associated with any base language code. The resulting
formation therefore has the following syntax:
directive
Formations that result from a block-associated directive have the following syntax:
directive
structured-block
[end-directive]
If structured-block is a loosely structured block, end-directive is required. If structured-block is a strictly structured block, end-directive is optional. An end-directive that immediately follows a directive and its associated strictly structured block is always paired with that directive.
Loop-associated directives are block-associated directives for which the associated structured-block is loop-nest, a canonical loop nest.
declaration-associated-specification
where declaration-associated-specification is either:
directive
function-definition-or-declaration
directive
declaration-associated-specification
In all cases the directive is associated with the function-definition-or-declaration.
If a directive appears in the specification part of a module then the behavior is as if that directive appears after any references to that module.
The formation that results from a delimited directive has the following syntax:
directive
base-language-code
end-directive
Separating directives may be used to separate a structured-block into multiple structured-block-sequences.
Separating directives and the containing structured block have the following syntax:
structured-block-sequence
directive
structured-block-sequence
[directive
structured-block-sequence ...]
wrapped in a single compound statement for C/C++ or optionally wrapped in a single BLOCK construct for Fortran.
Restrictions
Restrictions to directive format are as follows:Orphaned separating directives are prohibited. That is, the separating directives must appear within the structured block associated with the same construct with which it is associated and must not be encountered elsewhere in the region of that associated construct.
A stand-alone directive may be placed only at a point where a base language executable statement is allowed.