! 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.18. (File input.) Compute square roots of input data values.
  program E18
    implicit none
    integer, parameter :: LIMIT = 10
    integer :: Loop
    real :: X
! start program E18
    open (unit = 1, file = "e18.txt", status = "old", action = "read", position = "rewind")
    do Loop = 1, LIMIT
      read (unit = 1, fmt = *) X
      if (X < 0) then
        cycle
      end if
      write (unit = *, fmt = *) " Square root of: ", X, " is: ", sqrt( X )
    end do
    stop
  end program E18
