! 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.30. Expanding list as an array of structures.
  program G30
    use Element_M
    use G30M
    implicit none
    type (Chem_El_Type_1) :: Element
    logical :: Flag
    integer :: EoF
! start program G30
    Element = Chem_El_Type_1 (" ", "X", 0, 0.0)  ! Structure constructor
    open (unit = 1, file = "compound.txt", status = "old", action = "read", position = "rewind")
    do
      read (unit = 1, fmt = *, iostat = EoF) Element % Element_Name
      if (EoF < 0) then
        exit
      else
        call Find( Element, Flag )
        if (.not. Flag) then
          exit
        end if
      end if
    end do  ! Exit when EoF < 0 or on attempt to insert in full list.
    call Print_List( )
    stop
  end program G30

