Vector subscripts

A vector subscript is an integer array expression of rank one, designating a sequence of subscripts that correspond to the values of the elements of the expression.

A vector subscript can be a real array expression of rank one in XL Fortran.

The sequence does not have to be in order, and may contain duplicate values:
INTEGER A(10), B(3), C(3)
PRINT *, A( (/ 10,9,8 /) ) ! Last 3 elements in reverse order
B = A( (/ 1,2,2 /) )       ! B(1) = A(1), B(2) = A(2), B(3) = A(2) also
END
An array section with a vector subscript in which two or more elements of the vector subscript have the same value is called a many-one section. Such a section must not:
Notes:
  1. An array section used as an internal file must not have a vector subscript.
  2. If you pass an array section with a vector subscript as an actual argument, the associated dummy argument must not be defined or redefined.
  3. An array section with a vector subscript must not be the target in a pointer assignment statement.
  4. Fortran 2008 beginsIn XL Fortran, a nonzero-sized array section containing a vector subscript is considered noncontiguous. For details, see Contiguity.Fortran 2008
! We can use the whole array VECTOR as a vector subscript for A and B
INTEGER, DIMENSION(3) :: VECTOR= (/ 1,3,2 /), A, B
INTEGER, DIMENSION(4) :: C = (/ 1,2,4,8 /)
A(VECTOR) = B            ! A(1) = B(1), A(3) = B(2), A(2) = B(3)
A = B( (/ 3,2,1 /) )     ! A(1) = B(3), A(2) = B(2), A(3) = B(1)
PRINT *, C(VECTOR(1:2))  ! Prints C(1), C(3)
END