! 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 B.1.
  program L01
    implicit none
    real, dimension(:), allocatable :: A
    real :: Total
    integer :: N
! start program L01
    open (unit = 1, file = "l01.txt", status = "old", action = "read", position = "rewind")
    read (unit = 1, fmt = "(I5)" ) N
    allocate ( A(N) )
    read (unit = 1, fmt = "(E10.0)" ) A
    Total = sum (A, mask = (A > 0.0))
    write (unit = *, fmt = "(1X, E16.8)" ) Total
    stop
  end program L01
