! 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 4.1 (File input.)
  program E01 ! Find averages of ten number pairs.
    implicit none
    integer, parameter :: LIMIT = 10
    integer :: Loop
    real :: Average, X, Y
! start program E01
    open (unit = 1, file = "e01.txt", status = "old", action = "read", position = "rewind")
    do Loop = 1, LIMIT
      read (unit = 1, fmt = *) X, Y
      Average = (X +  Y) / 2.0
      write (unit = *, fmt = *) Loop, X, Y, Average
    end do
    stop
  end program E01
