| **OPENMP API Specification: "Version 5.2 -- GIT rev 95b2e3a44"**

An OpenMP context-speciﬁc structured block consists of statements that conform to speciﬁc restrictions so that OpenMP can treat them as a structured block or a structured block sequence. The restrictions depend on the context in which the context-speciﬁc structured block can be used.

An OpenMP allocator structured block consists of allocate-stmt, where allocate-stmt is a Fortran
ALLOCATE statement. Allocator structured blocks are considered strictly structured blocks for the purpose
of the allocators construct.

Cross References

- allocators directive, see Section 6.7

An OpenMP function dispatch structured block is a context-speciﬁc structured block that identiﬁes the location of a function dispatch.

Restrictions

Restrictions to the function dispatch structured blocks are as follows:The target-call expression can only be a direct call.

target-call must be a procedure name. target-call must not be a procedure pointer.

Cross References

- dispatch directive, see Section 7.6

An OpenMP atomic structured block is a context-speciﬁc structured block that can appear in an atomic construct. The form of an atomic structured block depends on the atomic semantics that the directive enforces.

In the following deﬁnitions:

x, r (result), and v (as applicable) are lvalue expressions with scalar type. e (expected) is
an expression with scalar type, d (desired) is an expression with scalar type. e and v may
refer to, or access, the same storage location. expr is an expression with scalar type. The
order operation, ordop, is one of <, or >. binop is one of +, *, -, /, &, ^, |, <<, or >>. ==
comparisons are performed by comparing the value representation of operand values for
equality after the usual arithmetic conversions; if the object representation does not have any
padding bits, the comparison is performed as if with memcmp. For forms that allow multiple
occurrences of x, the number of times that x is evaluated is unspeciﬁed but will be at least
one. For forms that allow multiple occurrences of expr, the number of times that expr is
evaluated is unspeciﬁed but will be at least one. The number of times that r is evaluated is
unspeciﬁed but will be at least one. Whether d is evaluated if x == e evaluates to false is
unspeciﬁed.

x, v, d and e (as applicable) are scalar variables of intrinsic type. expr is a scalar expression. expr-list is a
comma-separated, non-empty list of scalar expressions. intrinsic-procedure-name is one of MAX, MIN,
IAND, IOR, or IEOR. operator is one of +, *, -, /, .AND., .OR., .EQV., or .NEQV.. equalop is ==,
.EQ., or .EQV.. == or .EQ. comparisons are performed by comparing the physical representation of
operand values for equality after the usual conversions as described in the base language, while ignoring
padding bits, if any. .EQV. comparisons are performed as described in the base language. For forms that
allow multiple occurrences of x, the number of times that x is evaluated is unspeciﬁed but will be at least
one. For forms that allow multiple occurrences of expr, the number of times that expr is
evaluated is unspeciﬁed but will be at least one. The number of times that r is evaluated is
unspeciﬁed but will be at least one. Whether d is evaluated if x equalop e evaluates to false is
unspeciﬁed.

A read-atomic structured block can be speciﬁed for atomic directives that enforce atomic read semantics but not capture semantics.

A write-atomic structured block can be speciﬁed for atomic directives that enforce atomic write semantics but not capture semantics.

An update-atomic structured block can be speciﬁed for atomic directives that enforce atomic update semantics but not capture semantics.

A conditional-update-atomic structured block can be speciﬁed for atomic directives that enforce atomic conditional update semantics but not capture semantics.

A conditional-update-atomic structured block is either cond-expr-stmt, a conditional expression statement
that has one of the following forms:

x = expr ordop x ? expr : x;

x = x ordop expr ? expr : x;

x = x == e ? d : x;

or cond-update-stmt, a conditional update statement that has one of the following forms:

if(expr ordop x) { x = expr; }

if(x ordop expr) { x = expr; }

if(x == e) { x = d; }

A conditional-update-atomic structured block is conditional-update-statement, a conditional update
statement that has one of the following forms:

if (x equalop e) then

x = d

end if

if (x equalop e) x = d

read-atomic, write-atomic, update-atomic, and conditional-update-atomic structured blocks are considered strictly structured blocks for the purpose of the atomic construct.

A capture-atomic structured block can be speciﬁed for atomic directives that enforce capture semantics. They are further categorized as write-capture-atomic, update-capture-atomic, and conditional-update-capture-atomic structured blocks, which can be speciﬁed for atomic directives that enforce write, update or conditional update atomic semantics in addition to capture semantics.

A capture-atomic structured block is capture-stmt, a capture statement that has one of the following
forms:

v = expr-stmt

{ v = x; expr-stmt }

{ expr-stmt v = x; }

If expr-stmt is write-expr-stmt or expr-stmt is update-expr-stmt as speciﬁed above then it is an
update-capture-atomic structured block. If expr-stmt is cond-expr-stmt as speciﬁed above then it is a
conditional-update-capture-atomic structured block. In addition, a conditional-update-capture-atomic
structured block can have one of the following forms:

{ v = x; cond-update-stmt }

{ cond-update-stmt v = x; }

if(x == e) { x = d; } else { v = x; }

{ r = x == e; if(r) { x = d; } }

{ r = x == e; if(r) { x = d; } else { v = x; } }

A capture-atomic structured block has one of the following forms:

statement

capture-statement

capture-statement

statement

where capture-statement has the following form:

v = x

If statement is write-statement as speciﬁed above then it is a write-capture-atomic structured block. If
statement is update-statement as speciﬁed above then it is an update-capture-atomic structured block. If
statement is conditional-update-statement as speciﬁed above then it is a conditional-update-capture-atomic
structured block. In addition, for a conditional-update-capture-atomic structured block, statement can have
the following form:

x = expr

In addition, a conditional-update-capture-atomic structured block can have the following form:

if (x equalop e) then

x = d

else

v = x

end if

All capture-atomic structured blocks are considered loosely structured blocks for the purpose of the atomic construct.

Restrictions

Restrictions to OpenMP atomic structured blocks are as follows:In forms where e is assigned it must be an lvalue. r must be of integral type. During the execution of an
atomic region, multiple syntactic occurrences of x must designate the same storage location. During the
execution of an atomic region, multiple syntactic occurrences of r must designate the same storage
location. During the execution of an atomic region, multiple syntactic occurrences of expr
must evaluate to the same value. None of v, x, r, d and expr (as applicable) may access the
storage location designated by any other symbol in the list. In forms that capture the original
value of x in v, v and e may not refer to, or access, the same storage location. binop, binop=,
ordop, ==, ++, and -- are not overloaded operators. The expression x binop expr must be
numerically equivalent to x binop (expr). This requirement is satisﬁed if the operators in expr have
precedence greater than binop, or by using parentheses around expr or subexpressions of expr. The
expression expr binop x must be numerically equivalent to (expr) binop x. This requirement is
satisﬁed if the operators in expr have precedence equal to or greater than binop, or by using
parentheses around expr or subexpressions of expr. The expression x ordop expr must be
numerically equivalent to x ordop (expr). This requirement is satisﬁed if the operators in expr have
precedence greater than ordop, or by using parentheses around expr or subexpressions of expr. The
expression expr ordop x must be numerically equivalent to (expr) ordop x. This requirement
is satisﬁed if the operators in expr have precedence equal to or greater than ordop, or by
using parentheses around expr or subexpressions of expr. The expression x == e must be
numerically equivalent to x == (e). This requirement is satisﬁed if the operators in e have
precedence equal to or greater than ==, or by using parentheses around e or subexpressions of
e.

x must not have the ALLOCATABLE attribute. During the execution of an atomic region, multiple
syntactic occurrences of x must designate the same storage location. During the execution of an atomic
region, multiple syntactic occurrences of r must designate the same storage location. During the
execution of an atomic region, multiple syntactic occurrences of expr must evaluate to the same value.
None of v, expr, and expr-list (as applicable) may access the same storage location as x. None of
x, expr, and expr-list (as applicable) may access the same storage location as v. In forms
that capture the original value of x in v, v may not access the same storage location as e.
If intrinsic-procedure-name refers to IAND, IOR, or IEOR, exactly one expression must
appear in expr-list. The expression x operator expr must be, depending on its type, either
mathematically or logically equivalent to x operator (expr). This requirement is satisﬁed if the
operators in expr have precedence greater than operator, or by using parentheses around
expr or subexpressions of expr. The expression expr operator x must be, depending on its
type, either mathematically or logically equivalent to (expr) operator x. This requirement is
satisﬁed if the operators in expr have precedence equal to or greater than operator, or by using
parentheses around expr or subexpressions of expr. The expression x equalop e must be,
depending on its type, either mathematically or logically equivalent to x equalop (e). This
requirement is satisﬁed if the operators in e have precedence equal to or greater than equalop, or
by using parentheses around e or subexpressions of e. intrinsic-procedure-name must refer
to the intrinsic procedure name and not to other program entities. operator must refer to
the intrinsic operator and not to a user-deﬁned operator. All assignments must be intrinsic
assignments.

Cross References

- atomic directive, see Section 15.8.4