Intel® Fortran Compiler 17.0 Developer Guide and Reference

Vector Subscripts

A vector subscript is a one-dimensional (rank one) array of integer values (within the declared bounds for the dimension) that selects a section of a whole (parent) array. The elements in the section do not have to be in order and the section can contain duplicate values.

For example, A is a rank-two array of shape (4,6). B and C are rank-one arrays of shape (2) and (3), respectively, with the following values:

  B = (/1,4/)           ! Syntax (/.../) denotes an array constructor
  C = (/2,1,1/)         ! This constructor produces a many-one array section

Array section A(3,B) consists of elements A(3,1) and A(3,4). Array section A(C,1) consists of elements A(2,1), A(1,1), and A(1,1). Array section A(B,C) consists of the following elements:

  A(1,2)    A(1,1)    A(1,1)
  A(4,2)    A(4,1)    A(4,1)

An array section with a vector subscript that has two or more elements with the same value is called a many-one array section. For example:

  REAL A(3, 3), B(4)
  INTEGER K(4)
  ! Vector K has repeated values
  K = (/3, 1, 1, 2/)
  ! Sets all elements of A to 5.0
  A = 5.0
  B = A(3, K)

The array section A(3,K) consists of the elements:

  A(3, 3)  A(3, 1)  A(3, 1)  A(3, 2)

A many-one section must not appear on the left of the equal sign in an assignment statement, or as an input item in a READ statement.

The following assignments to C also show examples of vector subscripts:

  INTEGER A(2), B(2), C(2)
  ...
  B    = (/1,2/)
  C(B) = A(B)
  C    = A((/1,2/))

An array section with a vector subscript must not be any of the following:

If the sequence specified by the vector subscript is empty, the array section has a size of zero.

See Also