An array section is a selected portion of an array. It is an array subobject that designates a set of elements from an array, or a specified substring or derived-type component from each of those elements. An array section is also an array.
A subscript can be a scalar real expression in XL Fortran.
An array section is formed from the array elements specified by the sequences of values from the individual subscripts, subscript triplets, and vector subscripts, arranged in column-major order. See Example 2.
Example 1
INTEGER, DIMENSION(5,5,5) :: A
A(1,2,3) = 100
A(1,3,3) = 101
PRINT *, A(1,2,3) ! A single array element, 100.
PRINT *, A(1,2:2,3) ! A one-element array section, (/ 100 /)
PRINT *, A(1,2:3,3) ! A two-element array section,
! (/ 100, 101 /)
Example 2
A(1,5,4) | | SECTION(1,1)
A(2,5,4) |----- First column -----| SECTION(2,1)
A(3,5,4) | | SECTION(3,1)
A(1,6,4) | | SECTION(1,2)
A(2,6,4) |----- Second column ----| SECTION(2,2)
A(3,6,4) | | SECTION(3,2)
A(1,5,4) | | SECTION(1,3)
A(2,5,4) |----- Third column -----| SECTION(2,3)
A(3,5,4) | | SECTION(3,3)
Example 3
INTEGER, DIMENSION(20,20) :: A
! These references to array sections require loops or multiple
! statements in FORTRAN 77.
PRINT *, A(1:5,1) ! Contiguous sequence of elements
PRINT *, A(1:20:2,10) ! Noncontiguous sequence of elements
PRINT *, A(:,5) ! An entire column
PRINT *, A( (/1,10,5/), (/7,3,1/) ) ! A 3x3 assortment of elements