subroutine minpack_lmstr(fcn, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, maxfev, &
& diag, mode, factor, nprint, info, nfev, njev, ipvt, qtf, wa1, wa2, wa3, wa4, &
& udata) &
& bind(c)
procedure(minpack_fcn_lmstr) :: fcn
integer(c_int), value :: m
integer(c_int), value :: n
integer(c_int), value :: ldfjac
integer(c_int), value :: maxfev
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), intent(out) :: njev
integer(c_int), intent(out) :: ipvt(n)
real(c_double), value :: ftol
real(c_double), value :: xtol
real(c_double), value :: gtol
real(c_double), value :: factor
real(c_double), intent(inout) :: x(n)
real(c_double), intent(out) :: fvec(m)
real(c_double), intent(out) :: fjac(ldfjac, n)
real(c_double), intent(inout) :: diag(n)
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(m)
type(c_ptr), value :: udata
call lmstr(wrap_fcn, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, maxfev, &
& diag, mode, factor, nprint, info, nfev, njev, ipvt, qtf, wa1, wa2, wa3, wa4)
contains
subroutine wrap_fcn(m, n, x, fvec, fjrow, iflag)
integer, intent(in) :: m
integer, intent(in) :: n
integer, intent(inout) :: iflag
real(wp), intent(in) :: x(n)
real(wp), intent(inout) :: fvec(m)
real(wp), intent(inout) :: fjrow(n)
call fcn(m, n, x, fvec, fjrow, iflag, udata)
end subroutine wrap_fcn
end subroutine minpack_lmstr