/* File: _geodesiclmmodule.c
 * This file is auto-generated with f2py (version:2).
 * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition,
 * written by Pearu Peterson <pearu@cens.ioc.ee>.
 * Generation date: Thu Aug 22 04:21:10 2019
 * Do not edit this file directly unless you know what you are doing!!!
 */

#ifdef __cplusplus
extern "C" {
#endif

/*********************** See f2py2e/cfuncs.py: includes ***********************/
#include "Python.h"
#include <stdarg.h>
#include "fortranobject.h"
#include <string.h>
#include <setjmp.h>
#include <math.h>

/**************** See f2py2e/rules.py: mod_rules['modulebody'] ****************/
static PyObject *_geodesiclm_error;
static PyObject *_geodesiclm_module;

/*********************** See f2py2e/cfuncs.py: typedefs ***********************/
typedef signed char signed_char;

/****************** See f2py2e/cfuncs.py: typedefs_generated ******************/
typedef void(*cb_callback_in_geodesiclm__user__routines_typedef)(int *,int *,double *,double *,double *,double *,double *,double *,double *,double *,double *,int *,int *);
typedef void(*cb_Avv_in_geodesiclm__user__routines_typedef)(int *,int *,double *,double *,double *);
typedef void(*cb_jacobian_in_geodesiclm__user__routines_typedef)(int *,int *,double *,double *);
typedef void(*cb_func_in_geodesiclm__user__routines_typedef)(int *,int *,double *,double *);

/********************** See f2py2e/cfuncs.py: cppmacros **********************/
#ifndef max
#define max(a,b) ((a > b) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) ((a < b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a > b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) ((a < b) ? (a) : (b))
#endif

#define PRINTPYOBJERR(obj)\
    fprintf(stderr,"_geodesiclm.error is related to ");\
    PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\
    fprintf(stderr,"\n");

\
#define FAILNULL(p) do {                                            \
    if ((p) == NULL) {                                              \
        PyErr_SetString(PyExc_MemoryError, "NULL pointer found");   \
        goto capi_fail;                                             \
    }                                                               \
} while (0)

#define MEMCOPY(to,from,n)\
    do { FAILNULL(to); FAILNULL(from); (void)memcpy(to,from,n); } while (0)

#define pyobj_from_int1(v) (PyInt_FromLong(v))
#ifdef DEBUGCFUNCS
#define CFUNCSMESS(mess) fprintf(stderr,"debug-capi:"mess);
#define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \
    PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\
    fprintf(stderr,"\n");
#else
#define CFUNCSMESS(mess)
#define CFUNCSMESSPY(mess,obj)
#endif

#define pyobj_from_double1(v) (PyFloat_FromDouble(v))
#define GETSCALARFROMPYTUPLE(tuple,index,var,ctype,mess) {\
        if ((capi_tmp = PyTuple_GetItem((tuple),(index)))==NULL) goto capi_fail;\
        if (!(ctype ## _from_pyobj((var),capi_tmp,mess)))\
            goto capi_fail;\
    }

#if defined(PREPEND_FORTRAN)
#if defined(NO_APPEND_FORTRAN)
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) _##F
#else
#define F_FUNC(f,F) _##f
#endif
#else
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) _##F##_
#else
#define F_FUNC(f,F) _##f##_
#endif
#endif
#else
#if defined(NO_APPEND_FORTRAN)
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) F
#else
#define F_FUNC(f,F) f
#endif
#else
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) F##_
#else
#define F_FUNC(f,F) f##_
#endif
#endif
#endif
#if defined(UNDERSCORE_G77)
#define F_FUNC_US(f,F) F_FUNC(f##_,F##_)
#else
#define F_FUNC_US(f,F) F_FUNC(f,F)
#endif

#define rank(var) var ## _Rank
#define shape(var,dim) var ## _Dims[dim]
#define old_rank(var) (PyArray_NDIM((PyArrayObject *)(capi_ ## var ## _tmp)))
#define old_shape(var,dim) PyArray_DIM(((PyArrayObject *)(capi_ ## var ## _tmp)),dim)
#define fshape(var,dim) shape(var,rank(var)-dim-1)
#define len(var) shape(var,0)
#define flen(var) fshape(var,0)
#define old_size(var) PyArray_SIZE((PyArrayObject *)(capi_ ## var ## _tmp))
/* #define index(i) capi_i ## i */
#define slen(var) capi_ ## var ## _len
#define size(var, ...) f2py_size((PyArrayObject *)(capi_ ## var ## _tmp), ## __VA_ARGS__, -1)

#define SWAP(a,b,t) {\
    t *c;\
    c = a;\
    a = b;\
    b = c;}

#define CHECKSCALAR(check,tcheck,name,show,var)\
    if (!(check)) {\
        char errstring[256];\
        sprintf(errstring, "%s: "show, "("tcheck") failed for "name, var);\
        PyErr_SetString(_geodesiclm_error,errstring);\
        /*goto capi_fail;*/\
    } else 

/************************ See f2py2e/cfuncs.py: cfuncs ************************/
static int f2py_size(PyArrayObject* var, ...)
{
  npy_int sz = 0;
  npy_int dim;
  npy_int rank;
  va_list argp;
  va_start(argp, var);
  dim = va_arg(argp, npy_int);
  if (dim==-1)
    {
      sz = PyArray_SIZE(var);
    }
  else
    {
      rank = PyArray_NDIM(var);
      if (dim>=1 && dim<=rank)
        sz = PyArray_DIM(var, dim-1);
      else
        fprintf(stderr, "f2py_size: 2nd argument value=%d fails to satisfy 1<=value<=%d. Result will be 0.\n", dim, rank);
    }
  va_end(argp);
  return sz;
}

static int int_from_pyobj(int* v,PyObject *obj,const char *errmess) {
    PyObject* tmp = NULL;
    if (PyInt_Check(obj)) {
        *v = (int)PyInt_AS_LONG(obj);
        return 1;
    }
    tmp = PyNumber_Int(obj);
    if (tmp) {
        *v = PyInt_AS_LONG(tmp);
        Py_DECREF(tmp);
        return 1;
    }
    if (PyComplex_Check(obj))
        tmp = PyObject_GetAttrString(obj,"real");
    else if (PyString_Check(obj) || PyUnicode_Check(obj))
        /*pass*/;
    else if (PySequence_Check(obj))
        tmp = PySequence_GetItem(obj,0);
    if (tmp) {
        PyErr_Clear();
        if (int_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}
        Py_DECREF(tmp);
    }
    {
        PyObject* err = PyErr_Occurred();
        if (err==NULL) err = _geodesiclm_error;
        PyErr_SetString(err,errmess);
    }
    return 0;
}

static int create_cb_arglist(PyObject* fun,PyTupleObject* xa,const int maxnofargs,const int nofoptargs,int *nofargs,PyTupleObject **args,const char *errmess) {
    PyObject *tmp = NULL;
    PyObject *tmp_fun = NULL;
    int tot,opt,ext,siz,i,di=0;
    CFUNCSMESS("create_cb_arglist\n");
    tot=opt=ext=siz=0;
    /* Get the total number of arguments */
    if (PyFunction_Check(fun))
        tmp_fun = fun;
    else {
        di = 1;
        if (PyObject_HasAttrString(fun,"im_func")) {
            tmp_fun = PyObject_GetAttrString(fun,"im_func");
        }
        else if (PyObject_HasAttrString(fun,"__call__")) {
            tmp = PyObject_GetAttrString(fun,"__call__");
            if (PyObject_HasAttrString(tmp,"im_func"))
                tmp_fun = PyObject_GetAttrString(tmp,"im_func");
            else {
                tmp_fun = fun; /* built-in function */
                tot = maxnofargs;
                if (xa != NULL)
                    tot += PyTuple_Size((PyObject *)xa);
            }
            Py_XDECREF(tmp);
        }
        else if (PyFortran_Check(fun) || PyFortran_Check1(fun)) {
            tot = maxnofargs;
            if (xa != NULL)
                tot += PyTuple_Size((PyObject *)xa);
            tmp_fun = fun;
        }
        else if (F2PyCapsule_Check(fun)) {
            tot = maxnofargs;
            if (xa != NULL)
                ext = PyTuple_Size((PyObject *)xa);
            if(ext>0) {
                fprintf(stderr,"extra arguments tuple cannot be used with CObject call-back\n");
                goto capi_fail;
            }
            tmp_fun = fun;
        }
    }
if (tmp_fun==NULL) {
fprintf(stderr,"Call-back argument must be function|instance|instance.__call__|f2py-function but got %s.\n",(fun==NULL?"NULL":Py_TYPE(fun)->tp_name));
goto capi_fail;
}
#if PY_VERSION_HEX >= 0x03000000
    if (PyObject_HasAttrString(tmp_fun,"__code__")) {
        if (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,"__code__"),"co_argcount"))
#else
    if (PyObject_HasAttrString(tmp_fun,"func_code")) {
        if (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,"func_code"),"co_argcount"))
#endif
            tot = PyInt_AsLong(PyObject_GetAttrString(tmp,"co_argcount")) - di;
        Py_XDECREF(tmp);
    }
    /* Get the number of optional arguments */
#if PY_VERSION_HEX >= 0x03000000
    if (PyObject_HasAttrString(tmp_fun,"__defaults__")) {
        if (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,"__defaults__")))
#else
    if (PyObject_HasAttrString(tmp_fun,"func_defaults")) {
        if (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,"func_defaults")))
#endif
            opt = PyTuple_Size(tmp);
        Py_XDECREF(tmp);
    }
    /* Get the number of extra arguments */
    if (xa != NULL)
        ext = PyTuple_Size((PyObject *)xa);
    /* Calculate the size of call-backs argument list */
    siz = MIN(maxnofargs+ext,tot);
    *nofargs = MAX(0,siz-ext);
#ifdef DEBUGCFUNCS
    fprintf(stderr,"debug-capi:create_cb_arglist:maxnofargs(-nofoptargs),tot,opt,ext,siz,nofargs=%d(-%d),%d,%d,%d,%d,%d\n",maxnofargs,nofoptargs,tot,opt,ext,siz,*nofargs);
#endif
    if (siz<tot-opt) {
        fprintf(stderr,"create_cb_arglist: Failed to build argument list (siz) with enough arguments (tot-opt) required by user-supplied function (siz,tot,opt=%d,%d,%d).\n",siz,tot,opt);
        goto capi_fail;
    }
    /* Initialize argument list */
    *args = (PyTupleObject *)PyTuple_New(siz);
    for (i=0;i<*nofargs;i++) {
        Py_INCREF(Py_None);
        PyTuple_SET_ITEM((PyObject *)(*args),i,Py_None);
    }
    if (xa != NULL)
        for (i=(*nofargs);i<siz;i++) {
            tmp = PyTuple_GetItem((PyObject *)xa,i-(*nofargs));
            Py_INCREF(tmp);
            PyTuple_SET_ITEM(*args,i,tmp);
        }
    CFUNCSMESS("create_cb_arglist-end\n");
    return 1;
capi_fail:
    if ((PyErr_Occurred())==NULL)
        PyErr_SetString(_geodesiclm_error,errmess);
    return 0;
}

static int double_from_pyobj(double* v,PyObject *obj,const char *errmess) {
    PyObject* tmp = NULL;
    if (PyFloat_Check(obj)) {
#ifdef __sgi
        *v = PyFloat_AsDouble(obj);
#else
        *v = PyFloat_AS_DOUBLE(obj);
#endif
        return 1;
    }
    tmp = PyNumber_Float(obj);
    if (tmp) {
#ifdef __sgi
        *v = PyFloat_AsDouble(tmp);
#else
        *v = PyFloat_AS_DOUBLE(tmp);
#endif
        Py_DECREF(tmp);
        return 1;
    }
    if (PyComplex_Check(obj))
        tmp = PyObject_GetAttrString(obj,"real");
    else if (PyString_Check(obj) || PyUnicode_Check(obj))
        /*pass*/;
    else if (PySequence_Check(obj))
        tmp = PySequence_GetItem(obj,0);
    if (tmp) {
        PyErr_Clear();
        if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}
        Py_DECREF(tmp);
    }
    {
        PyObject* err = PyErr_Occurred();
        if (err==NULL) err = _geodesiclm_error;
        PyErr_SetString(err,errmess);
    }
    return 0;
}


/********************* See f2py2e/cfuncs.py: userincludes *********************/
/*need_userincludes*/

/********************* See f2py2e/capi_rules.py: usercode *********************/


/* See f2py2e/rules.py */
extern void F_FUNC(geodesiclm,GEODESICLM)(cb_func_in_geodesiclm__user__routines_typedef,cb_jacobian_in_geodesiclm__user__routines_typedef,cb_Avv_in_geodesiclm__user__routines_typedef,double*,double*,double*,int*,int*,cb_callback_in_geodesiclm__user__routines_typedef,int*,int*,int*,int*,double*,double*,double*,int*,int*,int*,int*,int*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*,int*,int*,int*,int*,int*,double*,double*,double*,double*);
/*eof externroutines*/

/******************** See f2py2e/capi_rules.py: usercode1 ********************/


/******************* See f2py2e/cb_rules.py: buildcallback *******************/

/******************* cb_func_in_geodesiclm__user__routines *******************/
PyObject *cb_func_in_geodesiclm__user__routines_capi = NULL;/*was Py_None*/
PyTupleObject *cb_func_in_geodesiclm__user__routines_args_capi = NULL;
int cb_func_in_geodesiclm__user__routines_nofargs = 0;
jmp_buf cb_func_in_geodesiclm__user__routines_jmpbuf;
/*typedef void(*cb_func_in_geodesiclm__user__routines_typedef)(int *,int *,double *,double *);*/
static void cb_func_in_geodesiclm__user__routines (int *m_cb_capi,int *n_cb_capi,double *x,double *fvec) {
  PyTupleObject *capi_arglist = cb_func_in_geodesiclm__user__routines_args_capi;
  PyObject *capi_return = NULL;
  PyObject *capi_tmp = NULL;
  PyObject *capi_arglist_list = NULL;
  int capi_j,capi_i = 0;
  int capi_longjmp_ok = 1;
/*decl*/
  int m=(*m_cb_capi);
  int n=(*n_cb_capi);
  npy_intp x_Dims[1] = {-1};
  npy_intp fvec_Dims[1] = {-1};
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_clock();
#endif
  CFUNCSMESS("cb:Call-back function cb_func_in_geodesiclm__user__routines (maxnofargs=3(-2))\n");
  CFUNCSMESSPY("cb:cb_func_in_geodesiclm__user__routines_capi=",cb_func_in_geodesiclm__user__routines_capi);
  if (cb_func_in_geodesiclm__user__routines_capi==NULL) {
    capi_longjmp_ok = 0;
    cb_func_in_geodesiclm__user__routines_capi = PyObject_GetAttrString(_geodesiclm_module,"func");
  }
  if (cb_func_in_geodesiclm__user__routines_capi==NULL) {
    PyErr_SetString(_geodesiclm_error,"cb: Callback func not defined (as an argument or module _geodesiclm attribute).\n");
    goto capi_fail;
  }
  if (F2PyCapsule_Check(cb_func_in_geodesiclm__user__routines_capi)) {
  cb_func_in_geodesiclm__user__routines_typedef cb_func_in_geodesiclm__user__routines_cptr;
  cb_func_in_geodesiclm__user__routines_cptr = F2PyCapsule_AsVoidPtr(cb_func_in_geodesiclm__user__routines_capi);
  (*cb_func_in_geodesiclm__user__routines_cptr)(m_cb_capi,n_cb_capi,x,fvec);
  return;
  }
  if (capi_arglist==NULL) {
    capi_longjmp_ok = 0;
    capi_tmp = PyObject_GetAttrString(_geodesiclm_module,"func_extra_args");
    if (capi_tmp) {
      capi_arglist = (PyTupleObject *)PySequence_Tuple(capi_tmp);
      if (capi_arglist==NULL) {
        PyErr_SetString(_geodesiclm_error,"Failed to convert _geodesiclm.func_extra_args to tuple.\n");
        goto capi_fail;
      }
    } else {
      PyErr_Clear();
      capi_arglist = (PyTupleObject *)Py_BuildValue("()");
    }
  }
  if (capi_arglist == NULL) {
    PyErr_SetString(_geodesiclm_error,"Callback func argument list is not set.\n");
    goto capi_fail;
  }
/*setdims*/
  x_Dims[0]=n;
  fvec_Dims[0]=m;
#ifdef PYPY_VERSION
#define CAPI_ARGLIST_SETITEM(idx, value) PyList_SetItem((PyObject *)capi_arglist_list, idx, value)
  capi_arglist_list = PySequence_List(capi_arglist);
  if (capi_arglist_list == NULL) goto capi_fail;
#else
#define CAPI_ARGLIST_SETITEM(idx, value) PyTuple_SetItem((PyObject *)capi_arglist, idx, value)
#endif
/*pyobjfrom*/
  if (cb_func_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,x_Dims,NPY_DOUBLE,NULL,(char*)x,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_func_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(m)))
      goto capi_fail;
  if (cb_func_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(n)))
      goto capi_fail;
#undef CAPI_ARGLIST_SETITEM
#ifdef PYPY_VERSION
  CFUNCSMESSPY("cb:capi_arglist=",capi_arglist_list);
#else
  CFUNCSMESSPY("cb:capi_arglist=",capi_arglist);
#endif
  CFUNCSMESS("cb:Call-back calling Python function func.\n");
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_call_clock();
#endif
#ifdef PYPY_VERSION
  capi_return = PyObject_CallObject(cb_func_in_geodesiclm__user__routines_capi,(PyObject *)capi_arglist_list);
  Py_DECREF(capi_arglist_list);
  capi_arglist_list = NULL;
#else
  capi_return = PyObject_CallObject(cb_func_in_geodesiclm__user__routines_capi,(PyObject *)capi_arglist);
#endif
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_stop_call_clock();
#endif
  CFUNCSMESSPY("cb:capi_return=",capi_return);
  if (capi_return == NULL) {
    fprintf(stderr,"capi_return is NULL\n");
    goto capi_fail;
  }
  if (capi_return == Py_None) {
    Py_DECREF(capi_return);
    capi_return = Py_BuildValue("()");
  }
  else if (!PyTuple_Check(capi_return)) {
    capi_return = Py_BuildValue("(N)",capi_return);
  }
  capi_j = PyTuple_Size(capi_return);
  capi_i = 0;
/*frompyobj*/
  if (capi_j>capi_i) {
    PyArrayObject *rv_cb_arr = NULL;
    if ((capi_tmp = PyTuple_GetItem(capi_return,capi_i++))==NULL) goto capi_fail;
    rv_cb_arr =  array_from_pyobj(NPY_DOUBLE,fvec_Dims,1,F2PY_INTENT_IN
,capi_tmp);
    if (rv_cb_arr == NULL) {
      fprintf(stderr,"rv_cb_arr is NULL\n");
      goto capi_fail;
    }
    MEMCOPY(fvec,PyArray_DATA(rv_cb_arr),PyArray_NBYTES(rv_cb_arr));
    if (capi_tmp != (PyObject *)rv_cb_arr) {
      Py_DECREF(rv_cb_arr);
    }
  }
  CFUNCSMESS("cb:cb_func_in_geodesiclm__user__routines:successful\n");
  Py_DECREF(capi_return);
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_stop_clock();
#endif
  goto capi_return_pt;
capi_fail:
  fprintf(stderr,"Call-back cb_func_in_geodesiclm__user__routines failed.\n");
  Py_XDECREF(capi_return);
  Py_XDECREF(capi_arglist_list);
  if (capi_longjmp_ok)
    longjmp(cb_func_in_geodesiclm__user__routines_jmpbuf,-1);
capi_return_pt:
  ;
return;
}
/**************** end of cb_func_in_geodesiclm__user__routines ****************/


/***************** cb_jacobian_in_geodesiclm__user__routines *****************/
PyObject *cb_jacobian_in_geodesiclm__user__routines_capi = NULL;/*was Py_None*/
PyTupleObject *cb_jacobian_in_geodesiclm__user__routines_args_capi = NULL;
int cb_jacobian_in_geodesiclm__user__routines_nofargs = 0;
jmp_buf cb_jacobian_in_geodesiclm__user__routines_jmpbuf;
/*typedef void(*cb_jacobian_in_geodesiclm__user__routines_typedef)(int *,int *,double *,double *);*/
static void cb_jacobian_in_geodesiclm__user__routines (int *m_cb_capi,int *n_cb_capi,double *x,double *fjac) {
  PyTupleObject *capi_arglist = cb_jacobian_in_geodesiclm__user__routines_args_capi;
  PyObject *capi_return = NULL;
  PyObject *capi_tmp = NULL;
  PyObject *capi_arglist_list = NULL;
  int capi_j,capi_i = 0;
  int capi_longjmp_ok = 1;
/*decl*/
  int m=(*m_cb_capi);
  int n=(*n_cb_capi);
  npy_intp x_Dims[1] = {-1};
  npy_intp fjac_Dims[2] = {-1, -1};
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_clock();
#endif
  CFUNCSMESS("cb:Call-back function cb_jacobian_in_geodesiclm__user__routines (maxnofargs=3(-2))\n");
  CFUNCSMESSPY("cb:cb_jacobian_in_geodesiclm__user__routines_capi=",cb_jacobian_in_geodesiclm__user__routines_capi);
  if (cb_jacobian_in_geodesiclm__user__routines_capi==NULL) {
    capi_longjmp_ok = 0;
    cb_jacobian_in_geodesiclm__user__routines_capi = PyObject_GetAttrString(_geodesiclm_module,"jacobian");
  }
  if (cb_jacobian_in_geodesiclm__user__routines_capi==NULL) {
    PyErr_SetString(_geodesiclm_error,"cb: Callback jacobian not defined (as an argument or module _geodesiclm attribute).\n");
    goto capi_fail;
  }
  if (F2PyCapsule_Check(cb_jacobian_in_geodesiclm__user__routines_capi)) {
  cb_jacobian_in_geodesiclm__user__routines_typedef cb_jacobian_in_geodesiclm__user__routines_cptr;
  cb_jacobian_in_geodesiclm__user__routines_cptr = F2PyCapsule_AsVoidPtr(cb_jacobian_in_geodesiclm__user__routines_capi);
  (*cb_jacobian_in_geodesiclm__user__routines_cptr)(m_cb_capi,n_cb_capi,x,fjac);
  return;
  }
  if (capi_arglist==NULL) {
    capi_longjmp_ok = 0;
    capi_tmp = PyObject_GetAttrString(_geodesiclm_module,"jacobian_extra_args");
    if (capi_tmp) {
      capi_arglist = (PyTupleObject *)PySequence_Tuple(capi_tmp);
      if (capi_arglist==NULL) {
        PyErr_SetString(_geodesiclm_error,"Failed to convert _geodesiclm.jacobian_extra_args to tuple.\n");
        goto capi_fail;
      }
    } else {
      PyErr_Clear();
      capi_arglist = (PyTupleObject *)Py_BuildValue("()");
    }
  }
  if (capi_arglist == NULL) {
    PyErr_SetString(_geodesiclm_error,"Callback jacobian argument list is not set.\n");
    goto capi_fail;
  }
/*setdims*/
  x_Dims[0]=n;
  fjac_Dims[0]=m,fjac_Dims[1]=n;
#ifdef PYPY_VERSION
#define CAPI_ARGLIST_SETITEM(idx, value) PyList_SetItem((PyObject *)capi_arglist_list, idx, value)
  capi_arglist_list = PySequence_List(capi_arglist);
  if (capi_arglist_list == NULL) goto capi_fail;
#else
#define CAPI_ARGLIST_SETITEM(idx, value) PyTuple_SetItem((PyObject *)capi_arglist, idx, value)
#endif
/*pyobjfrom*/
  if (cb_jacobian_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,x_Dims,NPY_DOUBLE,NULL,(char*)x,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_jacobian_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(m)))
      goto capi_fail;
  if (cb_jacobian_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(n)))
      goto capi_fail;
#undef CAPI_ARGLIST_SETITEM
#ifdef PYPY_VERSION
  CFUNCSMESSPY("cb:capi_arglist=",capi_arglist_list);
#else
  CFUNCSMESSPY("cb:capi_arglist=",capi_arglist);
#endif
  CFUNCSMESS("cb:Call-back calling Python function jacobian.\n");
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_call_clock();
#endif
#ifdef PYPY_VERSION
  capi_return = PyObject_CallObject(cb_jacobian_in_geodesiclm__user__routines_capi,(PyObject *)capi_arglist_list);
  Py_DECREF(capi_arglist_list);
  capi_arglist_list = NULL;
#else
  capi_return = PyObject_CallObject(cb_jacobian_in_geodesiclm__user__routines_capi,(PyObject *)capi_arglist);
#endif
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_stop_call_clock();
#endif
  CFUNCSMESSPY("cb:capi_return=",capi_return);
  if (capi_return == NULL) {
    fprintf(stderr,"capi_return is NULL\n");
    goto capi_fail;
  }
  if (capi_return == Py_None) {
    Py_DECREF(capi_return);
    capi_return = Py_BuildValue("()");
  }
  else if (!PyTuple_Check(capi_return)) {
    capi_return = Py_BuildValue("(N)",capi_return);
  }
  capi_j = PyTuple_Size(capi_return);
  capi_i = 0;
/*frompyobj*/
  if (capi_j>capi_i) {
    PyArrayObject *rv_cb_arr = NULL;
    if ((capi_tmp = PyTuple_GetItem(capi_return,capi_i++))==NULL) goto capi_fail;
    rv_cb_arr =  array_from_pyobj(NPY_DOUBLE,fjac_Dims,2,F2PY_INTENT_IN
,capi_tmp);
    if (rv_cb_arr == NULL) {
      fprintf(stderr,"rv_cb_arr is NULL\n");
      goto capi_fail;
    }
    MEMCOPY(fjac,PyArray_DATA(rv_cb_arr),PyArray_NBYTES(rv_cb_arr));
    if (capi_tmp != (PyObject *)rv_cb_arr) {
      Py_DECREF(rv_cb_arr);
    }
  }
  CFUNCSMESS("cb:cb_jacobian_in_geodesiclm__user__routines:successful\n");
  Py_DECREF(capi_return);
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_stop_clock();
#endif
  goto capi_return_pt;
capi_fail:
  fprintf(stderr,"Call-back cb_jacobian_in_geodesiclm__user__routines failed.\n");
  Py_XDECREF(capi_return);
  Py_XDECREF(capi_arglist_list);
  if (capi_longjmp_ok)
    longjmp(cb_jacobian_in_geodesiclm__user__routines_jmpbuf,-1);
capi_return_pt:
  ;
return;
}
/************** end of cb_jacobian_in_geodesiclm__user__routines **************/


/******************** cb_Avv_in_geodesiclm__user__routines ********************/
PyObject *cb_Avv_in_geodesiclm__user__routines_capi = NULL;/*was Py_None*/
PyTupleObject *cb_Avv_in_geodesiclm__user__routines_args_capi = NULL;
int cb_Avv_in_geodesiclm__user__routines_nofargs = 0;
jmp_buf cb_Avv_in_geodesiclm__user__routines_jmpbuf;
/*typedef void(*cb_Avv_in_geodesiclm__user__routines_typedef)(int *,int *,double *,double *,double *);*/
static void cb_Avv_in_geodesiclm__user__routines (int *m_cb_capi,int *n_cb_capi,double *x,double *v,double *acc) {
  PyTupleObject *capi_arglist = cb_Avv_in_geodesiclm__user__routines_args_capi;
  PyObject *capi_return = NULL;
  PyObject *capi_tmp = NULL;
  PyObject *capi_arglist_list = NULL;
  int capi_j,capi_i = 0;
  int capi_longjmp_ok = 1;
/*decl*/
  int m=(*m_cb_capi);
  int n=(*n_cb_capi);
  npy_intp acc_Dims[1] = {-1};
  npy_intp x_Dims[1] = {-1};
  npy_intp v_Dims[1] = {-1};
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_clock();
#endif
  CFUNCSMESS("cb:Call-back function cb_Avv_in_geodesiclm__user__routines (maxnofargs=4(-2))\n");
  CFUNCSMESSPY("cb:cb_Avv_in_geodesiclm__user__routines_capi=",cb_Avv_in_geodesiclm__user__routines_capi);
  if (cb_Avv_in_geodesiclm__user__routines_capi==NULL) {
    capi_longjmp_ok = 0;
    cb_Avv_in_geodesiclm__user__routines_capi = PyObject_GetAttrString(_geodesiclm_module,"Avv");
  }
  if (cb_Avv_in_geodesiclm__user__routines_capi==NULL) {
    PyErr_SetString(_geodesiclm_error,"cb: Callback Avv not defined (as an argument or module _geodesiclm attribute).\n");
    goto capi_fail;
  }
  if (F2PyCapsule_Check(cb_Avv_in_geodesiclm__user__routines_capi)) {
  cb_Avv_in_geodesiclm__user__routines_typedef cb_Avv_in_geodesiclm__user__routines_cptr;
  cb_Avv_in_geodesiclm__user__routines_cptr = F2PyCapsule_AsVoidPtr(cb_Avv_in_geodesiclm__user__routines_capi);
  (*cb_Avv_in_geodesiclm__user__routines_cptr)(m_cb_capi,n_cb_capi,x,v,acc);
  return;
  }
  if (capi_arglist==NULL) {
    capi_longjmp_ok = 0;
    capi_tmp = PyObject_GetAttrString(_geodesiclm_module,"Avv_extra_args");
    if (capi_tmp) {
      capi_arglist = (PyTupleObject *)PySequence_Tuple(capi_tmp);
      if (capi_arglist==NULL) {
        PyErr_SetString(_geodesiclm_error,"Failed to convert _geodesiclm.Avv_extra_args to tuple.\n");
        goto capi_fail;
      }
    } else {
      PyErr_Clear();
      capi_arglist = (PyTupleObject *)Py_BuildValue("()");
    }
  }
  if (capi_arglist == NULL) {
    PyErr_SetString(_geodesiclm_error,"Callback Avv argument list is not set.\n");
    goto capi_fail;
  }
/*setdims*/
  acc_Dims[0]=m;
  x_Dims[0]=n;
  v_Dims[0]=n;
#ifdef PYPY_VERSION
#define CAPI_ARGLIST_SETITEM(idx, value) PyList_SetItem((PyObject *)capi_arglist_list, idx, value)
  capi_arglist_list = PySequence_List(capi_arglist);
  if (capi_arglist_list == NULL) goto capi_fail;
#else
#define CAPI_ARGLIST_SETITEM(idx, value) PyTuple_SetItem((PyObject *)capi_arglist, idx, value)
#endif
/*pyobjfrom*/
  if (cb_Avv_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,x_Dims,NPY_DOUBLE,NULL,(char*)x,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_Avv_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,v_Dims,NPY_DOUBLE,NULL,(char*)v,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_Avv_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(m)))
      goto capi_fail;
  if (cb_Avv_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(n)))
      goto capi_fail;
#undef CAPI_ARGLIST_SETITEM
#ifdef PYPY_VERSION
  CFUNCSMESSPY("cb:capi_arglist=",capi_arglist_list);
#else
  CFUNCSMESSPY("cb:capi_arglist=",capi_arglist);
#endif
  CFUNCSMESS("cb:Call-back calling Python function Avv.\n");
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_call_clock();
#endif
#ifdef PYPY_VERSION
  capi_return = PyObject_CallObject(cb_Avv_in_geodesiclm__user__routines_capi,(PyObject *)capi_arglist_list);
  Py_DECREF(capi_arglist_list);
  capi_arglist_list = NULL;
#else
  capi_return = PyObject_CallObject(cb_Avv_in_geodesiclm__user__routines_capi,(PyObject *)capi_arglist);
#endif
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_stop_call_clock();
#endif
  CFUNCSMESSPY("cb:capi_return=",capi_return);
  if (capi_return == NULL) {
    fprintf(stderr,"capi_return is NULL\n");
    goto capi_fail;
  }
  if (capi_return == Py_None) {
    Py_DECREF(capi_return);
    capi_return = Py_BuildValue("()");
  }
  else if (!PyTuple_Check(capi_return)) {
    capi_return = Py_BuildValue("(N)",capi_return);
  }
  capi_j = PyTuple_Size(capi_return);
  capi_i = 0;
/*frompyobj*/
  if (capi_j>capi_i) {
    PyArrayObject *rv_cb_arr = NULL;
    if ((capi_tmp = PyTuple_GetItem(capi_return,capi_i++))==NULL) goto capi_fail;
    rv_cb_arr =  array_from_pyobj(NPY_DOUBLE,acc_Dims,1,F2PY_INTENT_IN
,capi_tmp);
    if (rv_cb_arr == NULL) {
      fprintf(stderr,"rv_cb_arr is NULL\n");
      goto capi_fail;
    }
    MEMCOPY(acc,PyArray_DATA(rv_cb_arr),PyArray_NBYTES(rv_cb_arr));
    if (capi_tmp != (PyObject *)rv_cb_arr) {
      Py_DECREF(rv_cb_arr);
    }
  }
  CFUNCSMESS("cb:cb_Avv_in_geodesiclm__user__routines:successful\n");
  Py_DECREF(capi_return);
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_stop_clock();
#endif
  goto capi_return_pt;
capi_fail:
  fprintf(stderr,"Call-back cb_Avv_in_geodesiclm__user__routines failed.\n");
  Py_XDECREF(capi_return);
  Py_XDECREF(capi_arglist_list);
  if (capi_longjmp_ok)
    longjmp(cb_Avv_in_geodesiclm__user__routines_jmpbuf,-1);
capi_return_pt:
  ;
return;
}
/**************** end of cb_Avv_in_geodesiclm__user__routines ****************/


/***************** cb_callback_in_geodesiclm__user__routines *****************/
PyObject *cb_callback_in_geodesiclm__user__routines_capi = NULL;/*was Py_None*/
PyTupleObject *cb_callback_in_geodesiclm__user__routines_args_capi = NULL;
int cb_callback_in_geodesiclm__user__routines_nofargs = 0;
jmp_buf cb_callback_in_geodesiclm__user__routines_jmpbuf;
/*typedef void(*cb_callback_in_geodesiclm__user__routines_typedef)(int *,int *,double *,double *,double *,double *,double *,double *,double *,double *,double *,int *,int *);*/
static void cb_callback_in_geodesiclm__user__routines (int *m_cb_capi,int *n_cb_capi,double *x,double *v,double *a,double *fvec,double *fjac,double *acc,double *lam_cb_capi,double *dtd,double *fvec_new,int *accepted_cb_capi,int *info_cb_capi) {
  PyTupleObject *capi_arglist = cb_callback_in_geodesiclm__user__routines_args_capi;
  PyObject *capi_return = NULL;
  PyObject *capi_tmp = NULL;
  PyObject *capi_arglist_list = NULL;
  int capi_j,capi_i = 0;
  int capi_longjmp_ok = 1;
/*decl*/
  int m=(*m_cb_capi);
  int n=(*n_cb_capi);
  double lam=(*lam_cb_capi);
  int accepted=(*accepted_cb_capi);
  int info=(*info_cb_capi);
  npy_intp x_Dims[1] = {-1};
  npy_intp fvec_Dims[1] = {-1};
  npy_intp v_Dims[1] = {-1};
  npy_intp a_Dims[1] = {-1};
  npy_intp fjac_Dims[2] = {-1, -1};
  npy_intp acc_Dims[1] = {-1};
  npy_intp dtd_Dims[2] = {-1, -1};
  npy_intp fvec_new_Dims[1] = {-1};
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_clock();
#endif
  CFUNCSMESS("cb:Call-back function cb_callback_in_geodesiclm__user__routines (maxnofargs=12(-2))\n");
  CFUNCSMESSPY("cb:cb_callback_in_geodesiclm__user__routines_capi=",cb_callback_in_geodesiclm__user__routines_capi);
  if (cb_callback_in_geodesiclm__user__routines_capi==NULL) {
    capi_longjmp_ok = 0;
    cb_callback_in_geodesiclm__user__routines_capi = PyObject_GetAttrString(_geodesiclm_module,"callback");
  }
  if (cb_callback_in_geodesiclm__user__routines_capi==NULL) {
    PyErr_SetString(_geodesiclm_error,"cb: Callback callback not defined (as an argument or module _geodesiclm attribute).\n");
    goto capi_fail;
  }
  if (F2PyCapsule_Check(cb_callback_in_geodesiclm__user__routines_capi)) {
  cb_callback_in_geodesiclm__user__routines_typedef cb_callback_in_geodesiclm__user__routines_cptr;
  cb_callback_in_geodesiclm__user__routines_cptr = F2PyCapsule_AsVoidPtr(cb_callback_in_geodesiclm__user__routines_capi);
  (*cb_callback_in_geodesiclm__user__routines_cptr)(m_cb_capi,n_cb_capi,x,v,a,fvec,fjac,acc,lam_cb_capi,dtd,fvec_new,accepted_cb_capi,info_cb_capi);
  return;
  }
  if (capi_arglist==NULL) {
    capi_longjmp_ok = 0;
    capi_tmp = PyObject_GetAttrString(_geodesiclm_module,"callback_extra_args");
    if (capi_tmp) {
      capi_arglist = (PyTupleObject *)PySequence_Tuple(capi_tmp);
      if (capi_arglist==NULL) {
        PyErr_SetString(_geodesiclm_error,"Failed to convert _geodesiclm.callback_extra_args to tuple.\n");
        goto capi_fail;
      }
    } else {
      PyErr_Clear();
      capi_arglist = (PyTupleObject *)Py_BuildValue("()");
    }
  }
  if (capi_arglist == NULL) {
    PyErr_SetString(_geodesiclm_error,"Callback callback argument list is not set.\n");
    goto capi_fail;
  }
/*setdims*/
  x_Dims[0]=n;
  fvec_Dims[0]=m;
  v_Dims[0]=n;
  a_Dims[0]=n;
  fjac_Dims[0]=m,fjac_Dims[1]=n;
  acc_Dims[0]=m;
  dtd_Dims[0]=n,dtd_Dims[1]=n;
  fvec_new_Dims[0]=m;
#ifdef PYPY_VERSION
#define CAPI_ARGLIST_SETITEM(idx, value) PyList_SetItem((PyObject *)capi_arglist_list, idx, value)
  capi_arglist_list = PySequence_List(capi_arglist);
  if (capi_arglist_list == NULL) goto capi_fail;
#else
#define CAPI_ARGLIST_SETITEM(idx, value) PyTuple_SetItem((PyObject *)capi_arglist, idx, value)
#endif
/*pyobjfrom*/
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,x_Dims,NPY_DOUBLE,NULL,(char*)x,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,v_Dims,NPY_DOUBLE,NULL,(char*)v,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,a_Dims,NPY_DOUBLE,NULL,(char*)a,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,fvec_Dims,NPY_DOUBLE,NULL,(char*)fvec,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,2,fjac_Dims,NPY_DOUBLE,NULL,(char*)fjac,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,acc_Dims,NPY_DOUBLE,NULL,(char*)acc,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_double1(lam)))
      goto capi_fail;
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,2,dtd_Dims,NPY_DOUBLE,NULL,(char*)dtd,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i) {
    int itemsize_ = NPY_DOUBLE == NPY_STRING ? 1 : 0;
    /*XXX: Hmm, what will destroy this array??? */
    PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,fvec_new_Dims,NPY_DOUBLE,NULL,(char*)fvec_new,itemsize_,NPY_ARRAY_FARRAY,NULL);


    if (tmp_arr==NULL)
      goto capi_fail;
    if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr))
      goto capi_fail;
}
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(accepted)))
      goto capi_fail;
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(m)))
      goto capi_fail;
  if (cb_callback_in_geodesiclm__user__routines_nofargs>capi_i)
    if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(n)))
      goto capi_fail;
#undef CAPI_ARGLIST_SETITEM
#ifdef PYPY_VERSION
  CFUNCSMESSPY("cb:capi_arglist=",capi_arglist_list);
#else
  CFUNCSMESSPY("cb:capi_arglist=",capi_arglist);
#endif
  CFUNCSMESS("cb:Call-back calling Python function callback.\n");
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_call_clock();
#endif
#ifdef PYPY_VERSION
  capi_return = PyObject_CallObject(cb_callback_in_geodesiclm__user__routines_capi,(PyObject *)capi_arglist_list);
  Py_DECREF(capi_arglist_list);
  capi_arglist_list = NULL;
#else
  capi_return = PyObject_CallObject(cb_callback_in_geodesiclm__user__routines_capi,(PyObject *)capi_arglist);
#endif
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_stop_call_clock();
#endif
  CFUNCSMESSPY("cb:capi_return=",capi_return);
  if (capi_return == NULL) {
    fprintf(stderr,"capi_return is NULL\n");
    goto capi_fail;
  }
  if (capi_return == Py_None) {
    Py_DECREF(capi_return);
    capi_return = Py_BuildValue("()");
  }
  else if (!PyTuple_Check(capi_return)) {
    capi_return = Py_BuildValue("(N)",capi_return);
  }
  capi_j = PyTuple_Size(capi_return);
  capi_i = 0;
/*frompyobj*/
  if (capi_j>capi_i)
    GETSCALARFROMPYTUPLE(capi_return,capi_i++,info_cb_capi,int,"int_from_pyobj failed in converting argument info of call-back function cb_callback_in_geodesiclm__user__routines to C int\n");
  CFUNCSMESS("cb:cb_callback_in_geodesiclm__user__routines:successful\n");
  Py_DECREF(capi_return);
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_stop_clock();
#endif
  goto capi_return_pt;
capi_fail:
  fprintf(stderr,"Call-back cb_callback_in_geodesiclm__user__routines failed.\n");
  Py_XDECREF(capi_return);
  Py_XDECREF(capi_arglist_list);
  if (capi_longjmp_ok)
    longjmp(cb_callback_in_geodesiclm__user__routines_jmpbuf,-1);
capi_return_pt:
  ;
return;
}
/************** end of cb_callback_in_geodesiclm__user__routines **************/


/*********************** See f2py2e/rules.py: buildapi ***********************/

/********************************* geodesiclm *********************************/
static char doc_f2py_rout__geodesiclm_geodesiclm[] = "\
geodesiclm(func,jacobian,Avv,x,fvec,fjac,callback,info,analytic_jac,analytic_Avv,center_diff,h1,h2,dtd,damp_mode,niters,nfev,njev,naev,maxiter,maxfev,maxjev,maxaev,maxlam,minlam,artol,Cgoal,gtol,xtol,xrtol,ftol,frtol,converged,print_level,print_unit,imethod,iaccel,ibold,ibroyden,initialfactor,factoraccept,factorreject,avmax,[n,m,func_extra_args,jacobian_extra_args,Avv_extra_args,callback_extra_args])\n\nWrapper for ``geodesiclm``.\
\n\nParameters\n----------\n"
"func : call-back function\n"
"jacobian : call-back function\n"
"Avv : call-back function\n"
"x : input rank-1 array('d') with bounds (n)\n"
"fvec : input rank-1 array('d') with bounds (m)\n"
"fjac : input rank-2 array('d') with bounds (m,n)\n"
"callback : call-back function\n"
"info : input rank-1 array('i') with bounds (1)\n"
"analytic_jac : input int\n"
"analytic_Avv : input int\n"
"center_diff : input int\n"
"h1 : input float\n"
"h2 : input float\n"
"dtd : input rank-2 array('d') with bounds (n,n)\n"
"damp_mode : input int\n"
"niters : input rank-1 array('i') with bounds (1)\n"
"nfev : input rank-1 array('i') with bounds (1)\n"
"njev : input rank-1 array('i') with bounds (1)\n"
"naev : input rank-1 array('i') with bounds (1)\n"
"maxiter : input int\n"
"maxfev : input int\n"
"maxjev : input int\n"
"maxaev : input int\n"
"maxlam : input float\n"
"minlam : input float\n"
"artol : input float\n"
"Cgoal : input float\n"
"gtol : input float\n"
"xtol : input float\n"
"xrtol : input float\n"
"ftol : input float\n"
"frtol : input float\n"
"converged : input rank-1 array('i') with bounds (1)\n"
"print_level : input int\n"
"print_unit : input int\n"
"imethod : input int\n"
"iaccel : input int\n"
"ibold : input int\n"
"ibroyden : input int\n"
"initialfactor : input float\n"
"factoraccept : input float\n"
"factorreject : input float\n"
"avmax : input float\n"
"\nOther Parameters\n----------------\n"
"func_extra_args : input tuple, optional\n    Default: ()\n"
"jacobian_extra_args : input tuple, optional\n    Default: ()\n"
"Avv_extra_args : input tuple, optional\n    Default: ()\n"
"n : input int, optional\n    Default: len(x)\n"
"m : input int, optional\n    Default: len(fvec)\n"
"callback_extra_args : input tuple, optional\n    Default: ()\n"
"\nNotes\n-----\nCall-back functions::\n\n"
"  def func(x,[m,n]): return fvec\n\
  Required arguments:\n"
"    x : input rank-1 array('d') with bounds (n)\n"
"  Optional arguments:\n"
"    m : input int, optional\n    Default: len(fvec)\n"
"    n : input int, optional\n    Default: len(x)\n"
"  Return objects:\n"
"    fvec : rank-1 array('d') with bounds (m)\n"
"  def jacobian(x,[m,n]): return fjac\n\
  Required arguments:\n"
"    x : input rank-1 array('d') with bounds (n)\n"
"  Optional arguments:\n"
"    m : input int, optional\n    Default: shape(fjac,0)\n"
"    n : input int, optional\n    Default: len(x)\n"
"  Return objects:\n"
"    fjac : rank-2 array('d') with bounds (m,n)\n"
"  def Avv(x,v,[m,n]): return acc\n\
  Required arguments:\n"
"    x : input rank-1 array('d') with bounds (n)\n"
"    v : input rank-1 array('d') with bounds (n)\n"
"  Optional arguments:\n"
"    m : input int, optional\n    Default: len(acc)\n"
"    n : input int, optional\n    Default: len(x)\n"
"  Return objects:\n"
"    acc : rank-1 array('d') with bounds (m)\n"
"  def callback(x,v,a,fvec,fjac,acc,lam,dtd,fvec_new,accepted,[m,n]): return info\n\
  Required arguments:\n"
"    x : input rank-1 array('d') with bounds (n)\n"
"    v : input rank-1 array('d') with bounds (n)\n"
"    a : input rank-1 array('d') with bounds (n)\n"
"    fvec : input rank-1 array('d') with bounds (m)\n"
"    fjac : input rank-2 array('d') with bounds (m,n)\n"
"    acc : input rank-1 array('d') with bounds (m)\n"
"    lam : input float\n"
"    dtd : input rank-2 array('d') with bounds (n,n)\n"
"    fvec_new : input rank-1 array('d') with bounds (m)\n"
"    accepted : input int\n"
"  Optional arguments:\n"
"    m : input int, optional\n    Default: len(fvec)\n"
"    n : input int, optional\n    Default: len(x)\n"
"  Return objects:\n"
"    info : int";
/* extern void F_FUNC(geodesiclm,GEODESICLM)(cb_func_in_geodesiclm__user__routines_typedef,cb_jacobian_in_geodesiclm__user__routines_typedef,cb_Avv_in_geodesiclm__user__routines_typedef,double*,double*,double*,int*,int*,cb_callback_in_geodesiclm__user__routines_typedef,int*,int*,int*,int*,double*,double*,double*,int*,int*,int*,int*,int*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*,int*,int*,int*,int*,int*,double*,double*,double*,double*); */
static PyObject *f2py_rout__geodesiclm_geodesiclm(const PyObject *capi_self,
                           PyObject *capi_args,
                           PyObject *capi_keywds,
                           void (*f2py_func)(cb_func_in_geodesiclm__user__routines_typedef,cb_jacobian_in_geodesiclm__user__routines_typedef,cb_Avv_in_geodesiclm__user__routines_typedef,double*,double*,double*,int*,int*,cb_callback_in_geodesiclm__user__routines_typedef,int*,int*,int*,int*,double*,double*,double*,int*,int*,int*,int*,int*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*,int*,int*,int*,int*,int*,double*,double*,double*,double*)) {
  PyObject * volatile capi_buildvalue = NULL;
  volatile int f2py_success = 1;
/*decl*/

  PyObject *func_capi = Py_None;
  PyTupleObject *func_xa_capi = NULL;
  PyTupleObject *func_args_capi = NULL;
  int func_nofargs_capi = 0;
  cb_func_in_geodesiclm__user__routines_typedef func_cptr;
  PyObject *jacobian_capi = Py_None;
  PyTupleObject *jacobian_xa_capi = NULL;
  PyTupleObject *jacobian_args_capi = NULL;
  int jacobian_nofargs_capi = 0;
  cb_jacobian_in_geodesiclm__user__routines_typedef jacobian_cptr;
  PyObject *Avv_capi = Py_None;
  PyTupleObject *Avv_xa_capi = NULL;
  PyTupleObject *Avv_args_capi = NULL;
  int Avv_nofargs_capi = 0;
  cb_Avv_in_geodesiclm__user__routines_typedef Avv_cptr;
  double *x = NULL;
  npy_intp x_Dims[1] = {-1};
  const int x_Rank = 1;
  PyArrayObject *capi_x_tmp = NULL;
  int capi_x_intent = 0;
  PyObject *x_capi = Py_None;
  double *fvec = NULL;
  npy_intp fvec_Dims[1] = {-1};
  const int fvec_Rank = 1;
  PyArrayObject *capi_fvec_tmp = NULL;
  int capi_fvec_intent = 0;
  PyObject *fvec_capi = Py_None;
  double *fjac = NULL;
  npy_intp fjac_Dims[2] = {-1, -1};
  const int fjac_Rank = 2;
  PyArrayObject *capi_fjac_tmp = NULL;
  int capi_fjac_intent = 0;
  PyObject *fjac_capi = Py_None;
  int n = 0;
  PyObject *n_capi = Py_None;
  int m = 0;
  PyObject *m_capi = Py_None;
  PyObject *callback_capi = Py_None;
  PyTupleObject *callback_xa_capi = NULL;
  PyTupleObject *callback_args_capi = NULL;
  int callback_nofargs_capi = 0;
  cb_callback_in_geodesiclm__user__routines_typedef callback_cptr;
  int *info = NULL;
  npy_intp info_Dims[1] = {-1};
  const int info_Rank = 1;
  PyArrayObject *capi_info_tmp = NULL;
  int capi_info_intent = 0;
  PyObject *info_capi = Py_None;
  int analytic_jac = 0;
  PyObject *analytic_jac_capi = Py_None;
  int analytic_Avv = 0;
  PyObject *analytic_Avv_capi = Py_None;
  int center_diff = 0;
  PyObject *center_diff_capi = Py_None;
  double h1 = 0;
  PyObject *h1_capi = Py_None;
  double h2 = 0;
  PyObject *h2_capi = Py_None;
  double *dtd = NULL;
  npy_intp dtd_Dims[2] = {-1, -1};
  const int dtd_Rank = 2;
  PyArrayObject *capi_dtd_tmp = NULL;
  int capi_dtd_intent = 0;
  PyObject *dtd_capi = Py_None;
  int damp_mode = 0;
  PyObject *damp_mode_capi = Py_None;
  int *niters = NULL;
  npy_intp niters_Dims[1] = {-1};
  const int niters_Rank = 1;
  PyArrayObject *capi_niters_tmp = NULL;
  int capi_niters_intent = 0;
  PyObject *niters_capi = Py_None;
  int *nfev = NULL;
  npy_intp nfev_Dims[1] = {-1};
  const int nfev_Rank = 1;
  PyArrayObject *capi_nfev_tmp = NULL;
  int capi_nfev_intent = 0;
  PyObject *nfev_capi = Py_None;
  int *njev = NULL;
  npy_intp njev_Dims[1] = {-1};
  const int njev_Rank = 1;
  PyArrayObject *capi_njev_tmp = NULL;
  int capi_njev_intent = 0;
  PyObject *njev_capi = Py_None;
  int *naev = NULL;
  npy_intp naev_Dims[1] = {-1};
  const int naev_Rank = 1;
  PyArrayObject *capi_naev_tmp = NULL;
  int capi_naev_intent = 0;
  PyObject *naev_capi = Py_None;
  int maxiter = 0;
  PyObject *maxiter_capi = Py_None;
  int maxfev = 0;
  PyObject *maxfev_capi = Py_None;
  int maxjev = 0;
  PyObject *maxjev_capi = Py_None;
  int maxaev = 0;
  PyObject *maxaev_capi = Py_None;
  double maxlam = 0;
  PyObject *maxlam_capi = Py_None;
  double minlam = 0;
  PyObject *minlam_capi = Py_None;
  double artol = 0;
  PyObject *artol_capi = Py_None;
  double Cgoal = 0;
  PyObject *Cgoal_capi = Py_None;
  double gtol = 0;
  PyObject *gtol_capi = Py_None;
  double xtol = 0;
  PyObject *xtol_capi = Py_None;
  double xrtol = 0;
  PyObject *xrtol_capi = Py_None;
  double ftol = 0;
  PyObject *ftol_capi = Py_None;
  double frtol = 0;
  PyObject *frtol_capi = Py_None;
  int *converged = NULL;
  npy_intp converged_Dims[1] = {-1};
  const int converged_Rank = 1;
  PyArrayObject *capi_converged_tmp = NULL;
  int capi_converged_intent = 0;
  PyObject *converged_capi = Py_None;
  int print_level = 0;
  PyObject *print_level_capi = Py_None;
  int print_unit = 0;
  PyObject *print_unit_capi = Py_None;
  int imethod = 0;
  PyObject *imethod_capi = Py_None;
  int iaccel = 0;
  PyObject *iaccel_capi = Py_None;
  int ibold = 0;
  PyObject *ibold_capi = Py_None;
  int ibroyden = 0;
  PyObject *ibroyden_capi = Py_None;
  double initialfactor = 0;
  PyObject *initialfactor_capi = Py_None;
  double factoraccept = 0;
  PyObject *factoraccept_capi = Py_None;
  double factorreject = 0;
  PyObject *factorreject_capi = Py_None;
  double avmax = 0;
  PyObject *avmax_capi = Py_None;
  static char *capi_kwlist[] = {"func","jacobian","Avv","x","fvec","fjac","callback","info","analytic_jac","analytic_Avv","center_diff","h1","h2","dtd","damp_mode","niters","nfev","njev","naev","maxiter","maxfev","maxjev","maxaev","maxlam","minlam","artol","Cgoal","gtol","xtol","xrtol","ftol","frtol","converged","print_level","print_unit","imethod","iaccel","ibold","ibroyden","initialfactor","factoraccept","factorreject","avmax","n","m","func_extra_args","jacobian_extra_args","Avv_extra_args","callback_extra_args",NULL};

/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
  if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
    "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO|OOO!O!O!O!:_geodesiclm.geodesiclm",\
    capi_kwlist,&func_capi,&jacobian_capi,&Avv_capi,&x_capi,&fvec_capi,&fjac_capi,&callback_capi,&info_capi,&analytic_jac_capi,&analytic_Avv_capi,&center_diff_capi,&h1_capi,&h2_capi,&dtd_capi,&damp_mode_capi,&niters_capi,&nfev_capi,&njev_capi,&naev_capi,&maxiter_capi,&maxfev_capi,&maxjev_capi,&maxaev_capi,&maxlam_capi,&minlam_capi,&artol_capi,&Cgoal_capi,&gtol_capi,&xtol_capi,&xrtol_capi,&ftol_capi,&frtol_capi,&converged_capi,&print_level_capi,&print_unit_capi,&imethod_capi,&iaccel_capi,&ibold_capi,&ibroyden_capi,&initialfactor_capi,&factoraccept_capi,&factorreject_capi,&avmax_capi,&n_capi,&m_capi,&PyTuple_Type,&func_xa_capi,&PyTuple_Type,&jacobian_xa_capi,&PyTuple_Type,&Avv_xa_capi,&PyTuple_Type,&callback_xa_capi))
    return NULL;
/*frompyobj*/
  /* Processing variable func */
if(F2PyCapsule_Check(func_capi)) {
  func_cptr = F2PyCapsule_AsVoidPtr(func_capi);
} else {
  func_cptr = cb_func_in_geodesiclm__user__routines;
}

  func_nofargs_capi = cb_func_in_geodesiclm__user__routines_nofargs;
  if (create_cb_arglist(func_capi,func_xa_capi,3,2,&cb_func_in_geodesiclm__user__routines_nofargs,&func_args_capi,"failed in processing argument list for call-back func.")) {
    jmp_buf func_jmpbuf;
    CFUNCSMESS("Saving jmpbuf for `func`.\n");
    SWAP(func_capi,cb_func_in_geodesiclm__user__routines_capi,PyObject);
    SWAP(func_args_capi,cb_func_in_geodesiclm__user__routines_args_capi,PyTupleObject);
    memcpy(&func_jmpbuf,&cb_func_in_geodesiclm__user__routines_jmpbuf,sizeof(jmp_buf));
  /* Processing variable jacobian */
if(F2PyCapsule_Check(jacobian_capi)) {
  jacobian_cptr = F2PyCapsule_AsVoidPtr(jacobian_capi);
} else {
  jacobian_cptr = cb_jacobian_in_geodesiclm__user__routines;
}

  jacobian_nofargs_capi = cb_jacobian_in_geodesiclm__user__routines_nofargs;
  if (create_cb_arglist(jacobian_capi,jacobian_xa_capi,3,2,&cb_jacobian_in_geodesiclm__user__routines_nofargs,&jacobian_args_capi,"failed in processing argument list for call-back jacobian.")) {
    jmp_buf jacobian_jmpbuf;
    CFUNCSMESS("Saving jmpbuf for `jacobian`.\n");
    SWAP(jacobian_capi,cb_jacobian_in_geodesiclm__user__routines_capi,PyObject);
    SWAP(jacobian_args_capi,cb_jacobian_in_geodesiclm__user__routines_args_capi,PyTupleObject);
    memcpy(&jacobian_jmpbuf,&cb_jacobian_in_geodesiclm__user__routines_jmpbuf,sizeof(jmp_buf));
  /* Processing variable Avv */
if(F2PyCapsule_Check(Avv_capi)) {
  Avv_cptr = F2PyCapsule_AsVoidPtr(Avv_capi);
} else {
  Avv_cptr = cb_Avv_in_geodesiclm__user__routines;
}

  Avv_nofargs_capi = cb_Avv_in_geodesiclm__user__routines_nofargs;
  if (create_cb_arglist(Avv_capi,Avv_xa_capi,4,2,&cb_Avv_in_geodesiclm__user__routines_nofargs,&Avv_args_capi,"failed in processing argument list for call-back Avv.")) {
    jmp_buf Avv_jmpbuf;
    CFUNCSMESS("Saving jmpbuf for `Avv`.\n");
    SWAP(Avv_capi,cb_Avv_in_geodesiclm__user__routines_capi,PyObject);
    SWAP(Avv_args_capi,cb_Avv_in_geodesiclm__user__routines_args_capi,PyTupleObject);
    memcpy(&Avv_jmpbuf,&cb_Avv_in_geodesiclm__user__routines_jmpbuf,sizeof(jmp_buf));
  /* Processing variable x */
  ;
  capi_x_intent |= F2PY_INTENT_IN;
  capi_x_tmp = array_from_pyobj(NPY_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi);
  if (capi_x_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 4th argument `x' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    x = (double *)(PyArray_DATA(capi_x_tmp));

  /* Processing variable fvec */
  ;
  capi_fvec_intent |= F2PY_INTENT_IN;
  capi_fvec_tmp = array_from_pyobj(NPY_DOUBLE,fvec_Dims,fvec_Rank,capi_fvec_intent,fvec_capi);
  if (capi_fvec_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 5th argument `fvec' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    fvec = (double *)(PyArray_DATA(capi_fvec_tmp));

  /* Processing variable callback */
if(F2PyCapsule_Check(callback_capi)) {
  callback_cptr = F2PyCapsule_AsVoidPtr(callback_capi);
} else {
  callback_cptr = cb_callback_in_geodesiclm__user__routines;
}

  callback_nofargs_capi = cb_callback_in_geodesiclm__user__routines_nofargs;
  if (create_cb_arglist(callback_capi,callback_xa_capi,12,2,&cb_callback_in_geodesiclm__user__routines_nofargs,&callback_args_capi,"failed in processing argument list for call-back callback.")) {
    jmp_buf callback_jmpbuf;
    CFUNCSMESS("Saving jmpbuf for `callback`.\n");
    SWAP(callback_capi,cb_callback_in_geodesiclm__user__routines_capi,PyObject);
    SWAP(callback_args_capi,cb_callback_in_geodesiclm__user__routines_args_capi,PyTupleObject);
    memcpy(&callback_jmpbuf,&cb_callback_in_geodesiclm__user__routines_jmpbuf,sizeof(jmp_buf));
  /* Processing variable info */
  info_Dims[0]=1;
  capi_info_intent |= F2PY_INTENT_IN;
  capi_info_tmp = array_from_pyobj(NPY_INT,info_Dims,info_Rank,capi_info_intent,info_capi);
  if (capi_info_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 8th argument `info' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    info = (int *)(PyArray_DATA(capi_info_tmp));

  /* Processing variable analytic_jac */
    analytic_jac = (int)PyObject_IsTrue(analytic_jac_capi);
    f2py_success = 1;
  if (f2py_success) {
  /* Processing variable analytic_Avv */
    analytic_Avv = (int)PyObject_IsTrue(analytic_Avv_capi);
    f2py_success = 1;
  if (f2py_success) {
  /* Processing variable center_diff */
    center_diff = (int)PyObject_IsTrue(center_diff_capi);
    f2py_success = 1;
  if (f2py_success) {
  /* Processing variable h1 */
    f2py_success = double_from_pyobj(&h1,h1_capi,"_geodesiclm.geodesiclm() 12nd argument (h1) can't be converted to double");
  if (f2py_success) {
  /* Processing variable h2 */
    f2py_success = double_from_pyobj(&h2,h2_capi,"_geodesiclm.geodesiclm() 13rd argument (h2) can't be converted to double");
  if (f2py_success) {
  /* Processing variable damp_mode */
    f2py_success = int_from_pyobj(&damp_mode,damp_mode_capi,"_geodesiclm.geodesiclm() 15th argument (damp_mode) can't be converted to int");
  if (f2py_success) {
  /* Processing variable niters */
  niters_Dims[0]=1;
  capi_niters_intent |= F2PY_INTENT_IN;
  capi_niters_tmp = array_from_pyobj(NPY_INT,niters_Dims,niters_Rank,capi_niters_intent,niters_capi);
  if (capi_niters_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 16th argument `niters' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    niters = (int *)(PyArray_DATA(capi_niters_tmp));

  /* Processing variable nfev */
  nfev_Dims[0]=1;
  capi_nfev_intent |= F2PY_INTENT_IN;
  capi_nfev_tmp = array_from_pyobj(NPY_INT,nfev_Dims,nfev_Rank,capi_nfev_intent,nfev_capi);
  if (capi_nfev_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 17th argument `nfev' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    nfev = (int *)(PyArray_DATA(capi_nfev_tmp));

  /* Processing variable njev */
  njev_Dims[0]=1;
  capi_njev_intent |= F2PY_INTENT_IN;
  capi_njev_tmp = array_from_pyobj(NPY_INT,njev_Dims,njev_Rank,capi_njev_intent,njev_capi);
  if (capi_njev_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 18th argument `njev' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    njev = (int *)(PyArray_DATA(capi_njev_tmp));

  /* Processing variable naev */
  naev_Dims[0]=1;
  capi_naev_intent |= F2PY_INTENT_IN;
  capi_naev_tmp = array_from_pyobj(NPY_INT,naev_Dims,naev_Rank,capi_naev_intent,naev_capi);
  if (capi_naev_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 19th argument `naev' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    naev = (int *)(PyArray_DATA(capi_naev_tmp));

  /* Processing variable maxiter */
    f2py_success = int_from_pyobj(&maxiter,maxiter_capi,"_geodesiclm.geodesiclm() 20th argument (maxiter) can't be converted to int");
  if (f2py_success) {
  /* Processing variable maxfev */
    f2py_success = int_from_pyobj(&maxfev,maxfev_capi,"_geodesiclm.geodesiclm() 21st argument (maxfev) can't be converted to int");
  if (f2py_success) {
  /* Processing variable maxjev */
    f2py_success = int_from_pyobj(&maxjev,maxjev_capi,"_geodesiclm.geodesiclm() 22nd argument (maxjev) can't be converted to int");
  if (f2py_success) {
  /* Processing variable maxaev */
    f2py_success = int_from_pyobj(&maxaev,maxaev_capi,"_geodesiclm.geodesiclm() 23rd argument (maxaev) can't be converted to int");
  if (f2py_success) {
  /* Processing variable maxlam */
    f2py_success = double_from_pyobj(&maxlam,maxlam_capi,"_geodesiclm.geodesiclm() 24th argument (maxlam) can't be converted to double");
  if (f2py_success) {
  /* Processing variable minlam */
    f2py_success = double_from_pyobj(&minlam,minlam_capi,"_geodesiclm.geodesiclm() 25th argument (minlam) can't be converted to double");
  if (f2py_success) {
  /* Processing variable artol */
    f2py_success = double_from_pyobj(&artol,artol_capi,"_geodesiclm.geodesiclm() 26th argument (artol) can't be converted to double");
  if (f2py_success) {
  /* Processing variable Cgoal */
    f2py_success = double_from_pyobj(&Cgoal,Cgoal_capi,"_geodesiclm.geodesiclm() 27th argument (Cgoal) can't be converted to double");
  if (f2py_success) {
  /* Processing variable gtol */
    f2py_success = double_from_pyobj(&gtol,gtol_capi,"_geodesiclm.geodesiclm() 28th argument (gtol) can't be converted to double");
  if (f2py_success) {
  /* Processing variable xtol */
    f2py_success = double_from_pyobj(&xtol,xtol_capi,"_geodesiclm.geodesiclm() 29th argument (xtol) can't be converted to double");
  if (f2py_success) {
  /* Processing variable xrtol */
    f2py_success = double_from_pyobj(&xrtol,xrtol_capi,"_geodesiclm.geodesiclm() 30th argument (xrtol) can't be converted to double");
  if (f2py_success) {
  /* Processing variable ftol */
    f2py_success = double_from_pyobj(&ftol,ftol_capi,"_geodesiclm.geodesiclm() 31st argument (ftol) can't be converted to double");
  if (f2py_success) {
  /* Processing variable frtol */
    f2py_success = double_from_pyobj(&frtol,frtol_capi,"_geodesiclm.geodesiclm() 32nd argument (frtol) can't be converted to double");
  if (f2py_success) {
  /* Processing variable converged */
  converged_Dims[0]=1;
  capi_converged_intent |= F2PY_INTENT_IN;
  capi_converged_tmp = array_from_pyobj(NPY_INT,converged_Dims,converged_Rank,capi_converged_intent,converged_capi);
  if (capi_converged_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 33rd argument `converged' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    converged = (int *)(PyArray_DATA(capi_converged_tmp));

  /* Processing variable print_level */
    f2py_success = int_from_pyobj(&print_level,print_level_capi,"_geodesiclm.geodesiclm() 34th argument (print_level) can't be converted to int");
  if (f2py_success) {
  /* Processing variable print_unit */
    f2py_success = int_from_pyobj(&print_unit,print_unit_capi,"_geodesiclm.geodesiclm() 35th argument (print_unit) can't be converted to int");
  if (f2py_success) {
  /* Processing variable imethod */
    f2py_success = int_from_pyobj(&imethod,imethod_capi,"_geodesiclm.geodesiclm() 36th argument (imethod) can't be converted to int");
  if (f2py_success) {
  /* Processing variable iaccel */
    f2py_success = int_from_pyobj(&iaccel,iaccel_capi,"_geodesiclm.geodesiclm() 37th argument (iaccel) can't be converted to int");
  if (f2py_success) {
  /* Processing variable ibold */
    f2py_success = int_from_pyobj(&ibold,ibold_capi,"_geodesiclm.geodesiclm() 38th argument (ibold) can't be converted to int");
  if (f2py_success) {
  /* Processing variable ibroyden */
    f2py_success = int_from_pyobj(&ibroyden,ibroyden_capi,"_geodesiclm.geodesiclm() 39th argument (ibroyden) can't be converted to int");
  if (f2py_success) {
  /* Processing variable initialfactor */
    f2py_success = double_from_pyobj(&initialfactor,initialfactor_capi,"_geodesiclm.geodesiclm() 40th argument (initialfactor) can't be converted to double");
  if (f2py_success) {
  /* Processing variable factoraccept */
    f2py_success = double_from_pyobj(&factoraccept,factoraccept_capi,"_geodesiclm.geodesiclm() 41st argument (factoraccept) can't be converted to double");
  if (f2py_success) {
  /* Processing variable factorreject */
    f2py_success = double_from_pyobj(&factorreject,factorreject_capi,"_geodesiclm.geodesiclm() 42nd argument (factorreject) can't be converted to double");
  if (f2py_success) {
  /* Processing variable avmax */
    f2py_success = double_from_pyobj(&avmax,avmax_capi,"_geodesiclm.geodesiclm() 43rd argument (avmax) can't be converted to double");
  if (f2py_success) {
  /* Processing variable n */
  if (n_capi == Py_None) n = len(x); else
    f2py_success = int_from_pyobj(&n,n_capi,"_geodesiclm.geodesiclm() 1st keyword (n) can't be converted to int");
  if (f2py_success) {
  CHECKSCALAR(len(x)>=n,"len(x)>=n","1st keyword n","geodesiclm:n=%d",n) {
  /* Processing variable m */
  if (m_capi == Py_None) m = len(fvec); else
    f2py_success = int_from_pyobj(&m,m_capi,"_geodesiclm.geodesiclm() 2nd keyword (m) can't be converted to int");
  if (f2py_success) {
  CHECKSCALAR(len(fvec)>=m,"len(fvec)>=m","2nd keyword m","geodesiclm:m=%d",m) {
  /* Processing variable dtd */
  dtd_Dims[0]=n,dtd_Dims[1]=n;
  capi_dtd_intent |= F2PY_INTENT_IN;
  capi_dtd_tmp = array_from_pyobj(NPY_DOUBLE,dtd_Dims,dtd_Rank,capi_dtd_intent,dtd_capi);
  if (capi_dtd_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 14th argument `dtd' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    dtd = (double *)(PyArray_DATA(capi_dtd_tmp));

  /* Processing variable fjac */
  fjac_Dims[0]=m,fjac_Dims[1]=n;
  capi_fjac_intent |= F2PY_INTENT_IN;
  capi_fjac_tmp = array_from_pyobj(NPY_DOUBLE,fjac_Dims,fjac_Rank,capi_fjac_intent,fjac_capi);
  if (capi_fjac_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_geodesiclm_error,"failed in converting 6th argument `fjac' of _geodesiclm.geodesiclm to C/Fortran array" );
  } else {
    fjac = (double *)(PyArray_DATA(capi_fjac_tmp));

/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
    if ((setjmp(cb_func_in_geodesiclm__user__routines_jmpbuf)) || (setjmp(cb_jacobian_in_geodesiclm__user__routines_jmpbuf)) || (setjmp(cb_Avv_in_geodesiclm__user__routines_jmpbuf)) || (setjmp(cb_callback_in_geodesiclm__user__routines_jmpbuf))) {
      f2py_success = 0;
    } else {
        (*f2py_func)(func_cptr,jacobian_cptr,Avv_cptr,x,fvec,fjac,&n,&m,callback_cptr,info,&analytic_jac,&analytic_Avv,&center_diff,&h1,&h2,dtd,&damp_mode,niters,nfev,njev,naev,&maxiter,&maxfev,&maxjev,&maxaev,&maxlam,&minlam,&artol,&Cgoal,&gtol,&xtol,&xrtol,&ftol,&frtol,converged,&print_level,&print_unit,&imethod,&iaccel,&ibold,&ibroyden,&initialfactor,&factoraccept,&factorreject,&avmax);
    }
if (PyErr_Occurred())
  f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
    if (f2py_success) {
/*pyobjfrom*/
/*end of pyobjfrom*/
    CFUNCSMESS("Building return value.\n");
    capi_buildvalue = Py_BuildValue("");
/*closepyobjfrom*/
/*end of closepyobjfrom*/
    } /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
  if((PyObject *)capi_fjac_tmp!=fjac_capi) {
    Py_XDECREF(capi_fjac_tmp); }
  }  /*if (capi_fjac_tmp == NULL) ... else of fjac*/
  /* End of cleaning variable fjac */
  if((PyObject *)capi_dtd_tmp!=dtd_capi) {
    Py_XDECREF(capi_dtd_tmp); }
  }  /*if (capi_dtd_tmp == NULL) ... else of dtd*/
  /* End of cleaning variable dtd */
  } /*CHECKSCALAR(len(fvec)>=m)*/
  } /*if (f2py_success) of m*/
  /* End of cleaning variable m */
  } /*CHECKSCALAR(len(x)>=n)*/
  } /*if (f2py_success) of n*/
  /* End of cleaning variable n */
  } /*if (f2py_success) of avmax*/
  /* End of cleaning variable avmax */
  } /*if (f2py_success) of factorreject*/
  /* End of cleaning variable factorreject */
  } /*if (f2py_success) of factoraccept*/
  /* End of cleaning variable factoraccept */
  } /*if (f2py_success) of initialfactor*/
  /* End of cleaning variable initialfactor */
  } /*if (f2py_success) of ibroyden*/
  /* End of cleaning variable ibroyden */
  } /*if (f2py_success) of ibold*/
  /* End of cleaning variable ibold */
  } /*if (f2py_success) of iaccel*/
  /* End of cleaning variable iaccel */
  } /*if (f2py_success) of imethod*/
  /* End of cleaning variable imethod */
  } /*if (f2py_success) of print_unit*/
  /* End of cleaning variable print_unit */
  } /*if (f2py_success) of print_level*/
  /* End of cleaning variable print_level */
  if((PyObject *)capi_converged_tmp!=converged_capi) {
    Py_XDECREF(capi_converged_tmp); }
  }  /*if (capi_converged_tmp == NULL) ... else of converged*/
  /* End of cleaning variable converged */
  } /*if (f2py_success) of frtol*/
  /* End of cleaning variable frtol */
  } /*if (f2py_success) of ftol*/
  /* End of cleaning variable ftol */
  } /*if (f2py_success) of xrtol*/
  /* End of cleaning variable xrtol */
  } /*if (f2py_success) of xtol*/
  /* End of cleaning variable xtol */
  } /*if (f2py_success) of gtol*/
  /* End of cleaning variable gtol */
  } /*if (f2py_success) of Cgoal*/
  /* End of cleaning variable Cgoal */
  } /*if (f2py_success) of artol*/
  /* End of cleaning variable artol */
  } /*if (f2py_success) of minlam*/
  /* End of cleaning variable minlam */
  } /*if (f2py_success) of maxlam*/
  /* End of cleaning variable maxlam */
  } /*if (f2py_success) of maxaev*/
  /* End of cleaning variable maxaev */
  } /*if (f2py_success) of maxjev*/
  /* End of cleaning variable maxjev */
  } /*if (f2py_success) of maxfev*/
  /* End of cleaning variable maxfev */
  } /*if (f2py_success) of maxiter*/
  /* End of cleaning variable maxiter */
  if((PyObject *)capi_naev_tmp!=naev_capi) {
    Py_XDECREF(capi_naev_tmp); }
  }  /*if (capi_naev_tmp == NULL) ... else of naev*/
  /* End of cleaning variable naev */
  if((PyObject *)capi_njev_tmp!=njev_capi) {
    Py_XDECREF(capi_njev_tmp); }
  }  /*if (capi_njev_tmp == NULL) ... else of njev*/
  /* End of cleaning variable njev */
  if((PyObject *)capi_nfev_tmp!=nfev_capi) {
    Py_XDECREF(capi_nfev_tmp); }
  }  /*if (capi_nfev_tmp == NULL) ... else of nfev*/
  /* End of cleaning variable nfev */
  if((PyObject *)capi_niters_tmp!=niters_capi) {
    Py_XDECREF(capi_niters_tmp); }
  }  /*if (capi_niters_tmp == NULL) ... else of niters*/
  /* End of cleaning variable niters */
  } /*if (f2py_success) of damp_mode*/
  /* End of cleaning variable damp_mode */
  } /*if (f2py_success) of h2*/
  /* End of cleaning variable h2 */
  } /*if (f2py_success) of h1*/
  /* End of cleaning variable h1 */
  } /*if (f2py_success) of center_diff*/
  /* End of cleaning variable center_diff */
  } /*if (f2py_success) of analytic_Avv*/
  /* End of cleaning variable analytic_Avv */
  } /*if (f2py_success) of analytic_jac*/
  /* End of cleaning variable analytic_jac */
  if((PyObject *)capi_info_tmp!=info_capi) {
    Py_XDECREF(capi_info_tmp); }
  }  /*if (capi_info_tmp == NULL) ... else of info*/
  /* End of cleaning variable info */
    CFUNCSMESS("Restoring jmpbuf for `callback`.\n");
    cb_callback_in_geodesiclm__user__routines_capi = callback_capi;
    Py_DECREF(cb_callback_in_geodesiclm__user__routines_args_capi);
    cb_callback_in_geodesiclm__user__routines_args_capi = callback_args_capi;
    cb_callback_in_geodesiclm__user__routines_nofargs = callback_nofargs_capi;
    memcpy(&cb_callback_in_geodesiclm__user__routines_jmpbuf,&callback_jmpbuf,sizeof(jmp_buf));
  }
  /* End of cleaning variable callback */
  if((PyObject *)capi_fvec_tmp!=fvec_capi) {
    Py_XDECREF(capi_fvec_tmp); }
  }  /*if (capi_fvec_tmp == NULL) ... else of fvec*/
  /* End of cleaning variable fvec */
  if((PyObject *)capi_x_tmp!=x_capi) {
    Py_XDECREF(capi_x_tmp); }
  }  /*if (capi_x_tmp == NULL) ... else of x*/
  /* End of cleaning variable x */
    CFUNCSMESS("Restoring jmpbuf for `Avv`.\n");
    cb_Avv_in_geodesiclm__user__routines_capi = Avv_capi;
    Py_DECREF(cb_Avv_in_geodesiclm__user__routines_args_capi);
    cb_Avv_in_geodesiclm__user__routines_args_capi = Avv_args_capi;
    cb_Avv_in_geodesiclm__user__routines_nofargs = Avv_nofargs_capi;
    memcpy(&cb_Avv_in_geodesiclm__user__routines_jmpbuf,&Avv_jmpbuf,sizeof(jmp_buf));
  }
  /* End of cleaning variable Avv */
    CFUNCSMESS("Restoring jmpbuf for `jacobian`.\n");
    cb_jacobian_in_geodesiclm__user__routines_capi = jacobian_capi;
    Py_DECREF(cb_jacobian_in_geodesiclm__user__routines_args_capi);
    cb_jacobian_in_geodesiclm__user__routines_args_capi = jacobian_args_capi;
    cb_jacobian_in_geodesiclm__user__routines_nofargs = jacobian_nofargs_capi;
    memcpy(&cb_jacobian_in_geodesiclm__user__routines_jmpbuf,&jacobian_jmpbuf,sizeof(jmp_buf));
  }
  /* End of cleaning variable jacobian */
    CFUNCSMESS("Restoring jmpbuf for `func`.\n");
    cb_func_in_geodesiclm__user__routines_capi = func_capi;
    Py_DECREF(cb_func_in_geodesiclm__user__routines_args_capi);
    cb_func_in_geodesiclm__user__routines_args_capi = func_args_capi;
    cb_func_in_geodesiclm__user__routines_nofargs = func_nofargs_capi;
    memcpy(&cb_func_in_geodesiclm__user__routines_jmpbuf,&func_jmpbuf,sizeof(jmp_buf));
  }
  /* End of cleaning variable func */
/*end of cleanupfrompyobj*/
  if (capi_buildvalue == NULL) {
/*routdebugfailure*/
  } else {
/*routdebugleave*/
  }
  CFUNCSMESS("Freeing memory.\n");
/*freemem*/
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_clock();
#endif
  return capi_buildvalue;
}
/***************************** end of geodesiclm *****************************/
/*eof body*/

/******************* See f2py2e/f90mod_rules.py: buildhooks *******************/
/*need_f90modhooks*/

/************** See f2py2e/rules.py: module_rules['modulebody'] **************/

/******************* See f2py2e/common_rules.py: buildhooks *******************/

/*need_commonhooks*/

/**************************** See f2py2e/rules.py ****************************/

static FortranDataDef f2py_routine_defs[] = {
  {"geodesiclm",-1,{{-1}},0,(char *)F_FUNC(geodesiclm,GEODESICLM),(f2py_init_func)f2py_rout__geodesiclm_geodesiclm,doc_f2py_rout__geodesiclm_geodesiclm},

/*eof routine_defs*/
  {NULL}
};

static PyMethodDef f2py_module_methods[] = {

  {NULL,NULL}
};

#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef moduledef = {
  PyModuleDef_HEAD_INIT,
  "_geodesiclm",
  NULL,
  -1,
  f2py_module_methods,
  NULL,
  NULL,
  NULL,
  NULL
};
#endif

#if PY_VERSION_HEX >= 0x03000000
#define RETVAL m
PyMODINIT_FUNC PyInit__geodesiclm(void) {
#else
#define RETVAL
PyMODINIT_FUNC init_geodesiclm(void) {
#endif
  int i;
  PyObject *m,*d, *s;
#if PY_VERSION_HEX >= 0x03000000
  m = _geodesiclm_module = PyModule_Create(&moduledef);
#else
  m = _geodesiclm_module = Py_InitModule("_geodesiclm", f2py_module_methods);
#endif
  Py_TYPE(&PyFortran_Type) = &PyType_Type;
  import_array();
  if (PyErr_Occurred())
    {PyErr_SetString(PyExc_ImportError, "can't initialize module _geodesiclm (failed to import numpy)"); return RETVAL;}
  d = PyModule_GetDict(m);
  s = PyString_FromString("$Revision: $");
  PyDict_SetItemString(d, "__version__", s);
#if PY_VERSION_HEX >= 0x03000000
  s = PyUnicode_FromString(
#else
  s = PyString_FromString(
#endif
    "This module '_geodesiclm' is auto-generated with f2py (version:2).\nFunctions:\n"
"  geodesiclm(func,jacobian,Avv,x,fvec,fjac,callback,info,analytic_jac,analytic_Avv,center_diff,h1,h2,dtd,damp_mode,niters,nfev,njev,naev,maxiter,maxfev,maxjev,maxaev,maxlam,minlam,artol,Cgoal,gtol,xtol,xrtol,ftol,frtol,converged,print_level,print_unit,imethod,iaccel,ibold,ibroyden,initialfactor,factoraccept,factorreject,avmax,n=len(x),m=len(fvec),func_extra_args=(),jacobian_extra_args=(),Avv_extra_args=(),callback_extra_args=())\n"
".");
  PyDict_SetItemString(d, "__doc__", s);
  _geodesiclm_error = PyErr_NewException ("_geodesiclm.error", NULL, NULL);
  Py_DECREF(s);
  for(i=0;f2py_routine_defs[i].name!=NULL;i++)
    PyDict_SetItemString(d, f2py_routine_defs[i].name,PyFortranObject_NewAsAttr(&f2py_routine_defs[i]));

/*eof initf2pywraphooks*/
/*eof initf90modhooks*/

/*eof initcommonhooks*/


#ifdef F2PY_REPORT_ATEXIT
  if (! PyErr_Occurred())
    on_exit(f2py_report_on_exit,(void*)"_geodesiclm");
#endif

  return RETVAL;
}
#ifdef __cplusplus
}
#endif
