! 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.3. (File input.) Print index value at normal termination.
  program E03
    implicit none
    integer :: I
    real :: Total, Datum
    integer, parameter :: LIMIT = 40
! start program E03
    Total = 0
    open (unit = 1, file = "e03.txt", status = "old", action = "read", position = "rewind")
    do I = 1, LIMIT
      read (unit = 1, fmt = *) Datum
      Total = Total + Datum
    end do
    write (unit = *, fmt = *) I, Total
    stop
  end program E03
