! 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.20. Echo printing.
  program E20
    implicit none
    real :: Average, X, Y, Diameter
! start program E20
    open (unit = 11, file = "data.txt", status = "old", action = "read", position = "rewind")
    open (unit = 12, file = "e20.zzz", status = "new", action = "write")
    read (unit = 11, fmt = *) X, Y
    Average = (X + Y) / 2.0
    write (unit = 12, fmt = *) " The average of ", X, " and ", Y, " is ", Average
    read (unit = 11, fmt = *) Diameter
    write (unit = 12, fmt = *) " DIAMETER: ", Diameter
    write (unit = 12, fmt = *) " CIRCUMFERENCE: ", 3.1416 * Diameter
    stop
  end program E20
