! 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.21. Diagonal of a matrix.
  program F21
    use F21M
    implicit none
    integer, parameter :: IMAX = 3, JMAX = 4
    real, dimension (IMAX, JMAX) :: A
    integer :: I, J
! start program F21
    do I = 1, IMAX
      do J = 1, JMAX
        A(I, J) = (I - 1) * JMAX + J
      end do
      write (unit = *, fmt = *) I, A(I, :)
    end do
    write (unit = *, fmt = *) ">> ", Diagonal( A )
    stop
  end program F21

