# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"
!Sergey's
module divide_bob
  use weight
  use solver_mod
  use cgstep_mod
  implicit none
  contains
  subroutine divide_apply (doprec, nd, num, den, rat, eps, niter, prec&
    &, nprec,res,wt_me)
    logical, intent (in) :: doprec
    integer, intent (in) :: nd, nprec, niter
    real, intent (in) :: eps
    real, dimension (nd), intent (in) :: num, den
    real, dimension (nd), intent (out) :: rat,res
    real, pointer :: wt_me(:)
    interface
      integer function prec (adj, add, x, dat)
        logical, intent (in) :: adj, add
        real, dimension (:) :: x, dat
      end function
    end interface
    real, dimension (:), pointer :: wt
    allocate (wt (nd))
    wt = den
    call weight_init (wt)
    if (doprec) then
      call solver_prec (weight_lop, cgstep, prec, nprec,x = rat, dat =&
        & num, niter = niter, eps = eps,res=res,wt=wt_me)
    else
      call solver_reg (weight_lop, cgstep, prec, nprec,x = rat, dat =&
        & num, niter = niter, eps = eps,res=res,wt=wt_me)
    end if
    call cgstep_close ()
    deallocate (wt)
  end subroutine
end module
