HELPLIB.HLB  —  FORTRAN  Data  Arrays  Sections
  An array section is a portion of an array that is an array itself.
  It is an array subobject.  A section subscript list (appended to
  the array or array component) determines which portion is being
  referred to.  A reference to an array section takes the following
  form:

     array [(sect-s-list)] [(substring-range)]

     array            Is the name of an array.

     sect-s-list      Is a list of one or more section
                      subscripts (subscripts, subscript
                      triplets, or vector subscripts)
                      indicating a set of elements along
                      a particular dimension.

                      At least one of the items in the section
                      subscript list must be a subscript
                      triplet or vector subscript. Each
                      subscript and subscript triplet must be
                      a scalar numeric expression. Each vector
                      subscript must be a rank-one integer
                      expression.

     substring-range  Is a substring range in the form
                      [expr]:[expr].  Each expression specified
                      must be a scalar numeric expression.

                      The array (or array component) preceding
                      the substring range must be of type character.

  If no section subscript list is specified, the rank and shape of
  the array section is the same as the parent array.

  Otherwise, the rank of the array section is the number of vector
  subscripts and subscript triplets that appear in the list.  Its
  shape is a rank-one array where each element is the number of
  integer values in the sequence indicated by the corresponding
  subscript triplet or vector subscript.

  If any of these sequences is empty, the array section has a size of
  zero.  The subscript order of the elements of an array section is
  that of the array object that the array section represents.

  Each array section inherits the type, kind type parameter, and
  certain attributes (INTENT, PARAMETER, and TARGET) of the parent
  array.  An array section cannot inherit the POINTER attribute.

  The following shows valid references to array sections:

    REAL, DIMENSION(20) :: B
    ...
    PRINT *, B(2:20:5)  ! the section consists of elements
                        !     B(2), B(7), B(12), and B(17)
    K = (/3, 1, 4/)

    B(K) = 0.0  ! section B(K) is a rank-one array with
                ! shape (3) and size 3. (0.0 is assigned to
                ! B(1), B(3), and B(4).)

  Consider the following declaration:

    CHARACTER(LEN=15) C(10,10)

  An array section referenced as C(:,:)(1:3) is an array of shape
  (10,10) whose elements are substrings of length 3 of the
  corresponding elements of C.

1  –  Triplets

  A subscript triplet consists of three parts:  the first two parts
  designate a range of subscript values and the third part designates
  the increment (stride) between each value.  It takes the following
  form:

    [subscript-1] : [subscript-2] [:stride]

    subscript-1   Is a scalar numeric expression representing
                  the first value in the subscript sequence.
                  If omitted, the declared lower bound of the
                  dimension is used.

    subscript-2   Is a scalar numeric expression representing
                  the last value in the subscript sequence.
                  If omitted, the declared upper bound of the
                  dimension is used.

                  When indicating sections of an assumed-size
                  array, this subscript must be specified.

    stride        Is a scalar numeric expression representing
                  the increment between successive subscripts
                  in the sequence.  It must have a nonzero value.
                  If it is omitted, it is assumed to be 1.

  The stride has the following effects:

   o  If the stride is positive, the subscript range starts with the
      first subscript and is incremented by the value of the stride,
      until the largest value less than or equal to the second
      subscript is attained.

      For example, if an array has been declared as B(6,3,2), the
      array section specified as B(2:4,1:2,2) is a rank-two array
      with shape (3,2) and size 6.  It consists of the following six
      elements:

          B(2,1,2)   B(2,2,2)
          B(3,1,2)   B(3,2,2)
          B(4,1,2)   B(4,2,2)

      If the first subscript is greater than the second subscript,
      the range is empty.

   o  If the stride is negative, the subscript range starts with the
      value of the first subscript and is decremented by the absolute
      value of the stride, until the smallest value greater than or
      equal to the second subscript is attained.

      For example, if an array has been declared as A(15), the array
      section specified as A(10:3:-2) is a rank-one array with shape
      (4) and size 4.  It consists of the following four elements:

          A(10)
          A(8)
          A(6)
          A(4)

      If the second subscript is greater than the first subscript,
      the range is empty.

  If a range specified by the stride is empty, the array section has
  a size of zero.

  A subscript in a subscript triplet need not be within the declared
  bounds for that dimension if all values used to select the array
  elements are within the declared bounds.  For example, if an array
  has been declared as A(15), the array section specified as
  A(4:16:10) is valid.  The section is a rank-one array with shape
  (2) and size 2.  It consists of elements A(4) and A(14).

  If the subscript triplet does not specify bounds or stride, but
  only a colon (:), the entire declared range for the dimension is
  used.

2  –  Vector Subscripts

  A vector subscript is a rank-one array of integer values (within
  the declared bounds for the dimension).  It is used to select a
  sequence of elements from a parent array.  The sequence does not
  have to be in order, and it 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/)
    C = (/2,1,1/)         ! Will result in 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.  A
  many-one section must not appear on the left of the equals 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:

   o  An internal file

   o  An actual argument associated with a dummy array that is
      defined or redefined (if the INTENT attribute is specified, it
      must be INTENT(IN))

   o  The target in a pointer assignment statement

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