! 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 E19M
  implicit none
  public :: Search
  integer, parameter, private :: List_Length = 10
  integer, public, dimension(List_Length) :: List
  integer, public :: Search_Key
contains
  function Search( ) result( Search_R )
    character (len = 9) :: Search_R
    integer :: I
! start function Search
    do I = 1, List_Length
      if (List(I) == Search_Key) then
        Search_R = "FOUND"
        return
      else if (List(I) > Search_Key) then
        Search_R = "NOT FOUND"  ! Or exit
        return
      else  ! Continue searching
      end if
    end do
    Search_R = "NOT FOUND"
    return
  end function Search
end module E19M
