! 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 9.9. Unformatted data transfer.
  program J10
    use J10M
    implicit none
    real, dimension(2) :: A
    integer, dimension(3)  :: J
    logical :: Flag
    type (Person) :: Author
! start program J10
    A = (/ 1.23, 4.56 /)
    J = (/ 33, 44, 55 /)
    Flag = .true.
    Author = Person("Charles Dickens", 199)
    write (unit = *, fmt = *) A, J, Flag, Author
    open (unit = 1, form = "unformatted", status = "scratch", &
      action = "readwrite", position = "rewind")
    write (unit = 1) A, J, Flag, Author   ! Unformatted write
    A = 0.0
    J = 0
    Flag = .false.
    Author = Person("", 0)
    rewind (unit = 1)
    read (unit = 1) A, J, Flag, Author   ! Unformatted read
    write (unit = *, fmt = *) A, J, Flag, Author
    stop
  end program J10
