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

3.2.5  Array Sections

An array section designates a subset of the elements in an array.

To specify an array section in an OpenMP directive, array subscript expressions are extended with one of the following syntaxes:
[ lower-bound : length : stride
[ lower-bound : length : 
[ lower-bound : length 
[ lower-bound : : stride
[ lower-bound : : 
[ lower-bound : 
[ : length : stride
[ : length : 
[ : length 
[ : : stride
[ : : 
[ : ]  

The array section must be a subset of the original array.

Array sections are allowed on multidimensional arrays. Base language array subscript expressions can be used to specify length-one dimensions of multidimensional array sections.

Each of the lower-bound, length, and stride expressions if specified must be an integral type expression of the base language. When evaluated they represent a set of integer values as follows:

{ lower-bound, lower-bound + stride, lower-bound + 2 * stride,... , lower-bound + ((length - 1) * stride) }

The length must evaluate to a non-negative integer.

The stride must evaluate to a positive integer.

When the size of the array dimension is not known, the length must be specified explicitly.

When the stride is absent it defaults to 1.

When the length is absent it defaults to ⌈⌈(size lower-bound)stride⌉⌉, where size is the size of the array dimension.

When the lower-bound is absent it defaults to 0.

The precedence of a subscript operator that uses the array section syntax is the same as the precedence of a subscript operator that does not use the array section syntax.

The following are examples of array sections:

Assume a is declared to be a 1-dimensional array with dimension size 11. The first two examples are equivalent, and the third and fourth examples are equivalent. The fifth example specifies a stride of 2 and therefore is not contiguous.

Assume b is declared to be a pointer to a 2-dimensional array with dimension sizes 10 and 10. The sixth example refers to all elements of the 2-dimensional array given by b[10]. The seventh example is a zero-length array section.

Assume c is declared to be a 3-dimensional array with dimension sizes 50, 50, and 50. The eighth example is contiguous, while the ninth and tenth examples are not contiguous.

The final four examples show array sections that are formed from more general base expressions.

The following are examples that are non-conforming array sections:  


For all three examples, a base language operator is applied in an undefined manner to an array section. The only operator that may be applied to an array section is a subscript operator for which the array section appears as the postfix expression.

Fortran has built-in support for array sections although some restrictions apply to their use in OpenMP directives, as enumerated in the following section.


Restrictions to array sections are as follows: