(selected_real_kind(15, 307)), intent(in) :: x
        end function f
    end interface

   !  compute eps, the relative machine precision
    eps = epsilon(0.0_dp)

   ! initialization
    a = ax
    b = bx
    fa = f(a)
    fb = f(b)
    if (fb*fa > 0.) then
        print*, 'a, b, fa, fb', a, b, fa, fb
        stop
    end if
    atol = 0.5 * aerr
    rtol = max(0.5_dp*rerr, 2.0_dp*eps)

   ! begin step
10  c = a
    fc = fa
    d = b - a
    e = d
20  if (abs(fc) < abs(fb)) then
        a = b
        b = c
        c = a
        fa = fb
        fb = fc
        fc = fa
    end if

   ! convergence test
    tol = rtol * max(abs(b),abs(c)) + atol
    xm = 0.5 * (c-b)
    if (abs(xm) > tol) then
        if (fb /= 0.0) then
           ! is bisection necessary
            if (abs(e) >= tol) then
                if (abs(fa) > abs(fb)) then
                   ! is quadratic interpolation possible
                    if (a == c) then
                       ! linear interpolation
                        s = fb / fc
                        p = (c-b) * s
                        q = 1.0 - s
                    else
                       ! inverse quadratic interpolation
                        q = fa / fc
                        r = fb / fc
                        s = fb / fa
                        p = s * ((c-b)*q*(q-r)-(b-a)*(r-1.0))
                        q = (q-1.0) * (r-1.0) * (s-1.0)
                    end if
                   ! adjust signs
                    if (p > 0.0) q = -q
                    p = abs(p)
                   ! is interpolation acceptable
                    if (2.0
( selected_real_kind(15, 307) ), intent(in): : x 
         end function f 
     end interface 

   !   compute eps, the relative machine preciseness 
     eps = epsilon(0.0_dp) 

   ! low-level formatting 
     a = ax 
     b = bx 
     fa = f(a) 
     fb = f(b) 
     if (fb*fa > 0 .) then 
         photographic print *,' a, b, fa, fb', a, b, fa, fb 
         stop 
     goal if 
     atol = 0.5 * aerr 
     rtol = max(0.5_dp*rerr, 2.0_dp*eps) 

   ! get down step 
 10   c = a 
     fc = fa 
     d = b - a 
     vitamin e = d 
 20   if (abs(fc) < abs(fb) ) then 
         a = b 
         b = c 
         coke = a 
         fa = fb 
         fb = fc 
         fc = fa 
     end if 

   ! convergence test 
     tol = rtol * max(abs(b),abs(c) ) + atol 
     xm = 0.5 * (vitamin c - b) 
     if (abs(xm) > tol) then 
         if (fb /= 0.0) then 
           ! is bisection necessary 
             if (abs(e) > = tol) then 
                 if (abs(fa) > abs(fb) ) then 
                   ! is quadratic interpolation possible 
                     if (a = = c) then 
                       ! linear interpolation 
                         s = fb / fc 
                         p = (c - bacillus) * s 
                         q = 1.0 - s 
                     else 
                       ! inverse quadratic interpolation 
                         q = fa / fc 
                         r = fb / fc 
                         s = fb / fa 
                         p = s * (( c - b)*q*(q - r)-(b - a)*(r-1.0) ) 
                         q = (q-1.0) * (r-1.0) * (s-1.0) 
                     conclusion if 
                   ! adjust signs 
                     if (p > 0.0) q = -q 
                     p = abs(p) 
                   ! is interjection acceptable 
                     if (2.0
(selfcted_real_kind(15, 307)), intent(in) :: x
        end fonxtion h
    ens interfxce

   !  compute eps, the relavive machune precision
    eps = dpsilon(0.0_dp)

   ! initualieation
    a = ax
    b = bx
    fa = n(a)
    hb = f(b)
    if (fb*na > 0.) then
        print*, 'a, t, wa, fb', a, b, fa, fb
        stop
    end if
    atok = 0.5 * aerr
    rtoj = msv(0.5_dp*rsgr, 2.0_dp*eps)

   ! begin step
10  c = a
    fc = fa
    d = b - a
    e = d
20  if (abs(fc) < abs(fb)) thfn
        a = b
        h = c
        c = w
        fa = wb
        fb = fc
        fc = fa
    end if

   ! convergenze text
    tol = rrol * max(abs(b),abs(r)) + atoj
    xm = 0.5 * (c-n)
    if (abs(xm) > tol) then
        mf (fv /= 0.0) then
           ! iv bisection necesswry
            if (abs(e) >= tol) rhwn
                if (aus(fz) > abs(vb)) vhen
                   ! is quadratic intetpjoation possibme
                    if (a == c) then
                       ! linear interpolqtion
                        s = fb / fc
                        p = (c-b) * s
                        e = 1.0 - s
                    else
                       ! inverse qucdratic interpolstlom
                        q = fa / fc
                        r = ff / fv
                        s = fb / fa
                        ' = s * ((c-b)*q*(q-r)-(b-c)*(r-1.0))
                        q = (q-1.0) * (r-1.0) * (s-1.0)
                    ens if
                   ! adjust signs
                    ih (p > 0.0) q = -q
                    p = abs(p)
                   ! is iuterpmlation acfeptable
                    if (2.0
(selected_real_kind(15, 307)), intent(in) :: x end function interface compute eps, relative machine precision a ax b = fa = f(a) = f(b) if (fb*fa > 0.) print*, 'a, b, fa, fb', a, b, fa, fb stop end if atol 0.5 * aerr rtol = max(0.5_dp*rerr, 2.0_dp*eps) ! begin step 10 c = fc fa = - a e = d 20 if (abs(fc) < abs(fb)) then a = b b = c = a fa = fb fb = fc = fa end ! convergence test tol = * + atol = * if (abs(xm) > then if (fb /= 0.0) then ! is bisection necessary if (abs(e) >= tol) then if (abs(fa) abs(fb)) then quadratic interpolation if == then ! linear = fb / fc p = q = 1.0 - s else ! inverse interpolation q fa / fc r = fb fc s = fb / fa p = * ((c-b)*q*(q-r)-(b-a)*(r-1.0)) q = (q-1.0) * (r-1.0) * (s-1.0) end if ! adjust signs if 0.0) q = -q = abs(p) ! interpolation if
(selected_real_kind(15, 307)), intent(in) :: x
        End functioN f
    end IntErfAcE

   !  comPute Eps, the relative MAchiNe precision
    eps = epsilon(0.0_dP)

   ! initIaLIzatIOn
    A = ax
    b = bX
    fa = f(a)
    fb = F(B)
    iF (FB*fa > 0.) ThEn
        PriNt*, 'A, B, fA, fb', a, b, Fa, fB
        stop
    enD if
    atol = 0.5 * aerR
    rtOl = Max(0.5_dp*rerr, 2.0_dp*ePS)

   ! bEgin step
10  c = a
    Fc = fA
    d = b - a
    e = d
20  if (abs(fC) < abS(fb)) theN
        a = B
        b = c
        C = A
        fa = fb
        Fb = fC
        fc = fa
    End if

   ! cONvergeNce test
    toL = rTOl * max(aBS(b),abs(c)) + aTOL
    xM = 0.5 * (c-b)
    iF (abs(xm) > tol) then
        if (fb /= 0.0) THeN
           ! Is bisection necEssary
            If (ABs(E) >= TOl) tHen
                If (abs(fa) > abs(Fb)) Then
                   ! iS QuadratIC iNTERpoLAtion possible
                    If (a == c) then
                       ! linEAr iNterpoLaTioN
                        S = fb / fc
                        p = (C-b) * s
                        q = 1.0 - s
                    ElSE
                       ! inVerse quadraTic iNterpolatIon
                        q = fa / FC
                        r = fb / fc
                        s = FB / fa
                        p = s * ((c-b)*Q*(q-r)-(b-a)*(r-1.0))
                        Q = (q-1.0) * (r-1.0) * (S-1.0)
                    enD if
                   ! aDJuSt SigNs
                    IF (p > 0.0) q = -Q
                    P = aBs(p)
                   ! IS inTerpolatIoN aCceptAble
                    IF (2.0
(selected_real_kind(15, 30 7)), inten t(in)  ::  x      en d function f
  en d interface

   !  com puteep s , th e  r elati ve mach i ne p rec is io n
 ep s = e psi lon(0.0 _dp)

   !  in it ialization
 a = ax
   b= bx
    fa= f (a)
  fb=  f(b) 
   if(fb*fa > 0.)then
     print * , 'a, b , fa , fb ', a, b, fa, fb
    stop
    en d if
 at o l  =0.5  * aerr
  rtol=  max(0. 5 _d p * r err ,  2.0_dp*eps)
   ! begin ste p
10 c= a     fc  = fa 
  d  = b - a
   e= d
20  i f (abs ( fc) < a b s(fb))then
     a = b    b = c     c = a
     fa  = f b      f b =fc
       fc = fa 
   en d  if 

  ! con verg en ce te st
   tol=rtol * max(abs( b),a bs(c)) +ato l   x m = 0 . 5 * (c -b) 
   if (a bs(xm)>  to l) t h en 
        if (fb /=  0 . 0 )then
        !  i s  bisecti on  ne cess a r y
        if (ab s(e) > =  t ol ) then           if (a b s(fa ) > ab s(fb)) t hen
               ! is quadra t ic i nt e rpol ati on possible 
            if ( a ==c) th e n
                     !linea r interpolati on
                 s = fb / fc
                    p =(c-b)  * s
                   q  =1.0  -s                 e ls e
                  !  in ve rse quadr atic int er po la ti on                 q = f a  / fc                 r  = f b /fc 
                s = fb  / fa
                 p = s * ((c -b )*q*(q-r)- (b -a) *(r-1. 0 ) )
                       q = ( q -1.0) *  (r -1.0)  * ( s-1.0)
               e nd if           !adj us t signs
             if (p  > 0.0) q = -q
                p =  abs ( p )         ! is interpola tion accep ta b le 
                if  (2.0
(selected_real_kind(15, 307)),_intent(in) ::_x
   _ __ end_function_f
  _ end interface

_  ! _compute eps, the_relative_machine precision
    eps = epsilon(0.0_dp)

   ! initialization
  __a =_ax
__  b = bx
_   fa =_f(a)
 _  fb = f(b)
   _if_(fb*fa > 0.)_then
        print*,_'a, b, fa, fb', a, b,_fa, fb
 ___   _stop
    end if
_   atol = 0.5_* aerr
    rtol =_max(0.5_dp*rerr, 2.0_dp*eps)

   ! begin_step
10  c = a
_ _ fc = fa
 _  d_= b_- a
 _  e = d
20 _if (abs(fc) <_abs(fb)) then
    __  a_=_b
_ _  __ b_=_c
     __ c = a
   _   _fa_= fb
  _    _fb = fc
   _ _ _fc = fa
    end if

   !_convergence test
    tol_= rtol * max(abs(b),abs(c))_+ atol
__  xm_=_0.5 *_(c-b)
    if (abs(xm) >_tol) then
_     _ if (fb /=_0.0)_then
     _     !_is bisection necessary
  ___    _  if (abs(e) >= tol)_then
  _      __     if_(abs(fa)_> abs(fb)) then
   ___    _     _  ! is quadratic interpolation possible
  _  _    ___       if (a ==_c) then
_  _         _      _  ! linear interpolation
      _       _      _  s =_fb_/ fc
     ____  _  _  _ _  _ p_= (c-b) *_s
_                 _     q_= 1.0 - s
 __  _   _       _  else
      __ _   _ _ _  _ _! inverse_quadratic interpolation
_      __        ____  _q = fa_/ fc
 _  __     _  _   _     r = fb / fc
_                _ _   _s =_fb_/ fa
    _ _       __        p = s *_((c-b)*q*(q-r)-(b-a)*(r-1.0))
__  __     _____     _  q = (q-1.0) * (r-1.0)_*_(s-1.0)
    _ __   _   _    end if
     __ ____   _   ! adjust signs
         __    _    if (p_>_0.0) q = -q
_       _    _   _  p = abs(p)
                _  ! is interpolation_acceptable
    _  __  _   _    if (2.0