! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

! Example 5.2. Array element names.
  program F02
    implicit none
    integer, parameter :: EXTENT = 20
    integer, parameter :: K1 = 1, L3 = 3, M1 = 1, I2 = 2, J1 = 1, L0 = 0, L16 = 16, I4 = 4, M2 = 2
    real :: X0
    real, dimension(EXTENT) :: X1
    real, dimension(EXTENT, EXTENT) :: X2
    real, dimension(EXTENT, EXTENT, EXTENT) :: X3
! start program F02
    read (unit = *, fmt = *) X1(6)
    write (unit = *, fmt = *) X1(I4 + 2), X1(3 * M2)
    read (unit = *, fmt = *) X3(L3 - 1, 2 * M1, 13 * I2 - 7)
    write (unit = *, fmt = *) X3(2, 2, 19)
    read (unit = *, fmt = *) X2(3 * J1 - 1, 3 * L0 + L16)
    write (unit = *, fmt = *) X2(2, 16)
    read (unit = *, fmt = *) X1(3)
    read (unit = *, fmt = *) X2(K1, L0 + 2)
    X1(1) = X1(3) + L16
    X1(I4) = 17.42
    X0 = X1(6) + X2(1, 2)
    write (unit = *, fmt = *) X1(K1), X1(4), X0
    stop
  end program F02
