! 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 7.5. Adaptive Quadrature
  program H05
    use H05M1
    use H05M2
    implicit none
    type(Result_Type) :: I
    integer :: TE, ME
! start program H05
    do
      write (unit = *, fmt = *) " Enter exp of Tol & M_Int."
      read (unit = *, fmt = *) TE, ME
      if (TE * ME == 0) then
        stop
      end if
      TE = min( TE, 14 )
      ME = min( ME, 2 * TE, 8 )      
      I = Quadrature( 1.0_HI, 3.0_HI , 10.0_HI ** (-TE), 10.0_HI ** (-ME) )
      if (I % Error) then
        write (unit = *, fmt = *) " Tol: ", TE, " M_Int: ", ME, " Error loc: ", I % Err_Loc
      else
        write (unit = *, fmt = *) " Tol: ", TE, " M_Int: ", ME, " Integral:  ", I % X
      end if
    end do
    stop
  end program H05
