        program doroot
        implicit none
        external f
        double precision a,b,f,tol
        integer flag
        print *,'enter bracketing interval endpoints a, b'
        read *,a,b
        print*,'enter tolerance'
        read*,tol
        call root(a,b,f,tol,flag)
        if ( flag .eq. -1) then
          print*,'fatal error: bad input data'
          stop
        elseif (flag .eq. 0) then
          print*,'tolerance achieved'
          print*,'root is approximately ',b,'  brackets with ',a
        elseif (flag .eq. 1) then
          print*,'tolerance unachievable'
          print*,'root is approximately ',b,'  brackets with ',a
        elseif (flag .eq. 2) then
          print*,'exact root (to machine precision) found'
          print*,'root is ',b
        endif
        end
