! 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.22. Linear max procedure.
  program F22
    use F22M
    implicit none
    integer, parameter :: ARRAY_SIZE = 20
    real, dimension(ARRAY_SIZE) :: Data_Array
    integer :: EoF, Loop
! start program F22
    open (unit = 1, file = "array.txt", status = "old", action = "read", position = "rewind")
    do Loop = 1, ARRAY_SIZE
      read (unit = 1, fmt =  *, iostat = EoF) Data_Array(Loop)
      if (EoF < 0) then
        exit
      end if
    end do
    write (unit = *, fmt = *) Linear_Max( Data_Array(: Loop - 1) )
    stop
  end program F22


