subroutine minpack_hybrd(fcn, n, x, fvec, xtol, maxfev, ml, mu, epsfcn, diag, mode, &
& factor, nprint, info, nfev, fjac, ldfjac, r, lr, qtf, wa1, wa2, wa3, wa4, &
& udata) &
& bind(c)
procedure(minpack_func) :: fcn
integer(c_int), value :: n
integer(c_int), value :: maxfev
integer(c_int), value :: ml
integer(c_int), value :: mu
integer(c_int), value :: mode
integer(c_int), value :: nprint
integer(c_int), intent(out) :: info
integer(c_int), intent(out) :: nfev
integer(c_int), value :: ldfjac
integer(c_int), value :: lr
real(c_double), value :: xtol
real(c_double), value :: epsfcn
real(c_double), value :: factor
real(c_double), intent(inout) :: x(n)
real(c_double), intent(out) :: fvec(n)
real(c_double), intent(inout) :: diag(n)
real(c_double), intent(out) :: fjac(ldfjac, n)
real(c_double), intent(out) :: r(lr)
real(c_double), intent(out) :: qtf(n)
real(c_double), intent(inout) :: wa1(n)
real(c_double), intent(inout) :: wa2(n)
real(c_double), intent(inout) :: wa3(n)
real(c_double), intent(inout) :: wa4(n)
type(c_ptr), value :: udata
call hybrd(wrap_fcn, n, x, fvec, xtol, maxfev, ml, mu, epsfcn, diag, mode, &
& factor, nprint, info, nfev, fjac, ldfjac, r, lr, qtf, wa1, wa2, wa3, wa4)
contains
subroutine wrap_fcn(n, x, fvec, iflag)
integer, intent(in) :: n
real(wp), intent(in) :: x(n)
real(wp), intent(out) :: fvec(n)
integer, intent(inout) :: iflag
call fcn(n, x, fvec, iflag, udata)
end subroutine wrap_fcn
end subroutine minpack_hybrd