! 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 6.33. Binary search tree.
  program G33
    use G33M
    implicit none
    type (Node_Type), pointer :: Root_NP
    integer :: EoF
  ! start program G33
    nullify( Root_NP )
    open (unit = 1, file = "simply.txt", status = "old", action = "read", position = "rewind")
  Input_Loop: &
    do
      read (unit = 1, fmt = *, iostat = EoF) New_Key
      if (EoF < 0) then
        exit Input_Loop
      end if
      call Look_Up( Root_NP )
    end do Input_Loop
  ! This point is reached at end of input file.
    call Print_Tree( Root_NP )
    stop
  end program G33
