! 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 8.4. Automatic array to save a copy of the dummy argument.
  program I04
    use I04M
    implicit none
    integer, parameter :: N = 4, M = 5
    real, dimension(N, M) :: Source_Array
    integer :: I, J
! start program I04
    open (unit = 1, file = "i04.txt", status = "old", action = "read", position = "rewind")
    read (unit = 1, fmt = *) Source_Array
    do
      read (unit = 1, fmt = *) I, J
      if (I == 0) then
        exit
      end if
      call Row_Swap( Source_Array, I, J )
      do I = 1, N  ! Write array by rows
        write (unit = *, fmt = *) Source_Array(I, :)
      end do
    end do
    stop
  end program I04
