A subscript triplet consists of two subscripts and a stride, and defines a sequence of numbers corresponding to array element positions along a single dimension.
If it is omitted, the lower array bound of that dimension is used.
If it is omitted, the upper array bound of that dimension is used. It is mandatory for the last dimension when specifying sections of an assumed-size array.
A stride can be a scalar real expression in XL Fortran.
Calculations of values in the sequence use the same steps as shown in Executing a DO statement.
INTEGER A(9)
PRINT *, A(1:9:2) ! Count from 1 to 9 by 2s: 1, 3, 5, 7, 9.
PRINT *, A(1:10:2) ! Count from 1 to 10 by 2s: 1, 3, 5, 7, 9.
! No element past A(9) is specified.
REAL, DIMENSION(10) :: A
INTEGER, DIMENSION(10,10) :: B
CHARACTER(10) STRING(1:100)
PRINT *, A(:) ! Print all elements of array.
PRINT *, A(:5) ! Print elements 1 through 5.
PRINT *, A(3:) ! Print elements 3 through 10.
PRINT *, STRING(50:100) ! Print all characters in
! elements 50 through 100.
! The following statement is equivalent to A(2:10:2) = A(1:9:2)
A(2::2) = A(:9:2) ! LHS = A(2), A(4), A(6), A(8), A(10)
! RHS = A(1), A(3), A(5), A(7), A(9)
! The statement assigns the odd-numbered
! elements to the even-numbered elements.
! The following statement is equivalent to PRINT *, B(1:4:3,1:7:6)
PRINT *, B(:4:3,:7:6) ! Print B(1,1), B(4,1), B(1,7), B(4,7)
PRINT *, A(10:1:-1) ! Print elements in reverse order.
PRINT *, A(10:1:1) ! These two are
PRINT *, A(1:10:-1) ! both zero-sized.
END