! 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.

  module G32M
    use Element_M
    implicit none
    private
    public :: Look_Up
  contains
    subroutine Look_Up( Arg_BP, A_Name )
      type (Box_Type), pointer :: Arg_BP
      character (len = *), intent (in) :: A_Name
      type (Box_Type), pointer :: Trav_BP
  ! start subroutine Look_Up
      Trav_BP => Arg_BP  ! Copy to avoid destroying dummy argument pointer value.
      do
        if (.not. associated( Trav_BP )) then
          exit  ! Stop at nullified pointer.
        end if
        if (A_Name == Trav_BP % El % Element_Name) then
          write (unit = *, fmt = *) A_Name, " Found. "
          return
        else   ! Keep looking.
          Trav_BP => Trav_BP % Next_BP   ! Pointer assignment
          cycle   ! To next iteration of while loop
        end if
      end do
      write (unit = *, fmt = *) A_Name, " Not found. "
      return
    end subroutine Look_Up
  end module G32M

