/* File: _srfpackmodule.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: Wed May 15 20:50:31 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 <math.h>

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

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

/****************** See f2py2e/cfuncs.py: typedefs_generated ******************/
/*need_typedefs_generated*/

/********************** See f2py2e/cfuncs.py: cppmacros **********************/
#define pyobj_from_float1(v) (PyFloat_FromDouble(v))
#define PRINTPYOBJERR(obj)\
    fprintf(stderr,"_srfpack.error is related to ");\
    PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\
    fprintf(stderr,"\n");

#define pyobj_from_int1(v) (PyInt_FromLong(v))
#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)

#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

#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 CHECKSCALAR(check,tcheck,name,show,var)\
    if (!(check)) {\
        char errstring[256];\
        sprintf(errstring, "%s: "show, "("tcheck") failed for "name, var);\
        PyErr_SetString(_srfpack_error,errstring);\
        /*goto capi_fail;*/\
    } else 
/* New SciPy */
#define TRYPYARRAYTEMPLATECHAR case NPY_STRING: *(char *)(PyArray_DATA(arr))=*v; break;
#define TRYPYARRAYTEMPLATELONG case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break;
#define TRYPYARRAYTEMPLATEOBJECT case NPY_OBJECT: PyArray_SETITEM(arr,PyArray_DATA(arr),pyobj_from_ ## ctype ## 1(*v)); break;

#define TRYPYARRAYTEMPLATE(ctype,typecode) \
        PyArrayObject *arr = NULL;\
        if (!obj) return -2;\
        if (!PyArray_Check(obj)) return -1;\
        if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,"TRYPYARRAYTEMPLATE:");PRINTPYOBJERR(obj);return 0;}\
        if (PyArray_DESCR(arr)->type==typecode)  {*(ctype *)(PyArray_DATA(arr))=*v; return 1;}\
        switch (PyArray_TYPE(arr)) {\
                case NPY_DOUBLE: *(double *)(PyArray_DATA(arr))=*v; break;\
                case NPY_INT: *(int *)(PyArray_DATA(arr))=*v; break;\
                case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break;\
                case NPY_FLOAT: *(float *)(PyArray_DATA(arr))=*v; break;\
                case NPY_CDOUBLE: *(double *)(PyArray_DATA(arr))=*v; break;\
                case NPY_CFLOAT: *(float *)(PyArray_DATA(arr))=*v; break;\
                case NPY_BOOL: *(npy_bool *)(PyArray_DATA(arr))=(*v!=0); break;\
                case NPY_UBYTE: *(unsigned char *)(PyArray_DATA(arr))=*v; break;\
                case NPY_BYTE: *(signed char *)(PyArray_DATA(arr))=*v; break;\
                case NPY_SHORT: *(short *)(PyArray_DATA(arr))=*v; break;\
                case NPY_USHORT: *(npy_ushort *)(PyArray_DATA(arr))=*v; break;\
                case NPY_UINT: *(npy_uint *)(PyArray_DATA(arr))=*v; break;\
                case NPY_ULONG: *(npy_ulong *)(PyArray_DATA(arr))=*v; break;\
                case NPY_LONGLONG: *(npy_longlong *)(PyArray_DATA(arr))=*v; break;\
                case NPY_ULONGLONG: *(npy_ulonglong *)(PyArray_DATA(arr))=*v; break;\
                case NPY_LONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\
                case NPY_CLONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\
                case NPY_OBJECT: PyArray_SETITEM(arr, PyArray_DATA(arr), pyobj_from_ ## ctype ## 1(*v)); break;\
        default: return -2;\
        };\
        return 1


/************************ See f2py2e/cfuncs.py: cfuncs ************************/
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 = _srfpack_error;
        PyErr_SetString(err,errmess);
    }
    return 0;
}

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 try_pyarr_from_int(PyObject* obj,int* v) {
    TRYPYARRAYTEMPLATE(int,'i');
}

static int try_pyarr_from_float(PyObject* obj,float* v) {
    TRYPYARRAYTEMPLATE(float,'f');
}

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 = _srfpack_error;
        PyErr_SetString(err,errmess);
    }
    return 0;
}

static int float_from_pyobj(float* v,PyObject *obj,const char *errmess) {
    double d=0.0;
    if (double_from_pyobj(&d,obj,errmess)) {
        *v = (float)d;
        return 1;
    }
    return 0;
}


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

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


/* See f2py2e/rules.py */
extern void F_FUNC(gradg,GRADG)(int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,int*);
extern void F_FUNC(gradl,GRADL)(int*,int*,int*,int*,float*,float*,float*,int*,int*,int*,float*,float*,int*);
extern void F_FUNC(intrc0,INTRC0)(float*,float*,int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,int*);
extern void F_FUNC(intrc1,INTRC1)(float*,float*,int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,float*,int*,int*,float*,float*,float*,int*);
extern void F_FUNC(smsurf,SMSURF)(int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,float*,float*,float*,float*,float*,float*,int*);
extern void F_FUNC(zgradg,ZGRADG)(int*,int*,int*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,float*,int*);
extern void F_FUNC(zgradl,ZGRADL)(int*,int*,int*,int*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,float*,int*);
/*eof externroutines*/

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


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

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

/*********************************** gradg ***********************************/
static char doc_f2py_rout__srfpack_gradg[] = "\
ier = gradg(x,y,z,list,lptr,lend,iflgs,sigma,grad,[ncc,lcc,nit,dgmax])\n\nWrapper for ``gradg``.\
\n\nParameters\n----------\n"
"x : input rank-1 array('f') with bounds (n)\n"
"y : input rank-1 array('f') with bounds (n)\n"
"z : input rank-1 array('f') with bounds (n)\n"
"list : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lptr : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lend : input rank-1 array('i') with bounds (n)\n"
"iflgs : input int\n"
"sigma : input rank-1 array('f') with bounds (*)\n"
"grad : in/output rank-2 array('f') with bounds (2,n)\n"
"\nOther Parameters\n----------------\n"
"ncc : input int, optional\n    Default: 0\n"
"lcc : input rank-1 array('i') with bounds (ncc + 1)\n"
"nit : in/output rank-0 array(int,'i'), optional\n    Default: 3\n"
"dgmax : in/output rank-0 array(float,'f'), optional\n    Default: 0.001\n"
"\nReturns\n-------\n"
"ier : int";
/* extern void F_FUNC(gradg,GRADG)(int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,int*); */
static PyObject *f2py_rout__srfpack_gradg(const PyObject *capi_self,
                           PyObject *capi_args,
                           PyObject *capi_keywds,
                           void (*f2py_func)(int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,int*)) {
  PyObject * volatile capi_buildvalue = NULL;
  volatile int f2py_success = 1;
/*decl*/

  int ncc = 0;
  PyObject *ncc_capi = Py_None;
  int *lcc = NULL;
  npy_intp lcc_Dims[1] = {-1};
  const int lcc_Rank = 1;
  PyArrayObject *capi_lcc_tmp = NULL;
  int capi_lcc_intent = 0;
  PyObject *lcc_capi = Py_None;
  int n = 0;
  float *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;
  float *y = NULL;
  npy_intp y_Dims[1] = {-1};
  const int y_Rank = 1;
  PyArrayObject *capi_y_tmp = NULL;
  int capi_y_intent = 0;
  PyObject *y_capi = Py_None;
  float *z = NULL;
  npy_intp z_Dims[1] = {-1};
  const int z_Rank = 1;
  PyArrayObject *capi_z_tmp = NULL;
  int capi_z_intent = 0;
  PyObject *z_capi = Py_None;
  int *list = NULL;
  npy_intp list_Dims[1] = {-1};
  const int list_Rank = 1;
  PyArrayObject *capi_list_tmp = NULL;
  int capi_list_intent = 0;
  PyObject *list_capi = Py_None;
  int *lptr = NULL;
  npy_intp lptr_Dims[1] = {-1};
  const int lptr_Rank = 1;
  PyArrayObject *capi_lptr_tmp = NULL;
  int capi_lptr_intent = 0;
  PyObject *lptr_capi = Py_None;
  int *lend = NULL;
  npy_intp lend_Dims[1] = {-1};
  const int lend_Rank = 1;
  PyArrayObject *capi_lend_tmp = NULL;
  int capi_lend_intent = 0;
  PyObject *lend_capi = Py_None;
  int iflgs = 0;
  PyObject *iflgs_capi = Py_None;
  float *sigma = NULL;
  npy_intp sigma_Dims[1] = {-1};
  const int sigma_Rank = 1;
  PyArrayObject *capi_sigma_tmp = NULL;
  int capi_sigma_intent = 0;
  PyObject *sigma_capi = Py_None;
  int nit = 0;
  PyObject *nit_capi = Py_None;
  float dgmax = 0;
  PyObject *dgmax_capi = Py_None;
  float *grad = NULL;
  npy_intp grad_Dims[2] = {-1, -1};
  const int grad_Rank = 2;
  PyArrayObject *capi_grad_tmp = NULL;
  int capi_grad_intent = 0;
  PyObject *grad_capi = Py_None;
  int ier = 0;
  static char *capi_kwlist[] = {"x","y","z","list","lptr","lend","iflgs","sigma","grad","ncc","lcc","nit","dgmax",NULL};

/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
  if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
    "OOOOOOOOO|OOOO:_srfpack.gradg",\
    capi_kwlist,&x_capi,&y_capi,&z_capi,&list_capi,&lptr_capi,&lend_capi,&iflgs_capi,&sigma_capi,&grad_capi,&ncc_capi,&lcc_capi,&nit_capi,&dgmax_capi))
    return NULL;
/*frompyobj*/
  /* Processing variable ncc */
  if (ncc_capi == Py_None) ncc = 0; else
    f2py_success = int_from_pyobj(&ncc,ncc_capi,"_srfpack.gradg() 1st keyword (ncc) can't be converted to int");
  if (f2py_success) {
  /* Processing variable x */
  ;
  capi_x_intent |= F2PY_INTENT_IN;
  capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi);
  if (capi_x_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 1st argument `x' of _srfpack.gradg to C/Fortran array" );
  } else {
    x = (float *)(PyArray_DATA(capi_x_tmp));

  /* Processing variable iflgs */
    f2py_success = int_from_pyobj(&iflgs,iflgs_capi,"_srfpack.gradg() 7th argument (iflgs) can't be converted to int");
  if (f2py_success) {
  /* Processing variable sigma */
  ;
  capi_sigma_intent |= F2PY_INTENT_IN;
  capi_sigma_tmp = array_from_pyobj(NPY_FLOAT,sigma_Dims,sigma_Rank,capi_sigma_intent,sigma_capi);
  if (capi_sigma_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 8th argument `sigma' of _srfpack.gradg to C/Fortran array" );
  } else {
    sigma = (float *)(PyArray_DATA(capi_sigma_tmp));

  /* Processing variable nit */
  if (nit_capi == Py_None) nit = 3; else
    f2py_success = int_from_pyobj(&nit,nit_capi,"_srfpack.gradg() 3rd keyword (nit) can't be converted to int");
  if (f2py_success) {
  /* Processing variable dgmax */
  if (dgmax_capi == Py_None) dgmax = 0.001; else
    f2py_success = float_from_pyobj(&dgmax,dgmax_capi,"_srfpack.gradg() 4th keyword (dgmax) can't be converted to float");
  if (f2py_success) {
  /* Processing variable ier */
  /* Processing variable lcc */
  lcc_Dims[0]=ncc + 1;
  capi_lcc_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL;
  capi_lcc_tmp = array_from_pyobj(NPY_INT,lcc_Dims,lcc_Rank,capi_lcc_intent,lcc_capi);
  if (capi_lcc_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd keyword `lcc' of _srfpack.gradg to C/Fortran array" );
  } else {
    lcc = (int *)(PyArray_DATA(capi_lcc_tmp));

  /* Processing variable n */
  n = len(x);
  /* Processing variable y */
  y_Dims[0]=n;
  capi_y_intent |= F2PY_INTENT_IN;
  capi_y_tmp = array_from_pyobj(NPY_FLOAT,y_Dims,y_Rank,capi_y_intent,y_capi);
  if (capi_y_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd argument `y' of _srfpack.gradg to C/Fortran array" );
  } else {
    y = (float *)(PyArray_DATA(capi_y_tmp));

  /* Processing variable z */
  z_Dims[0]=n;
  capi_z_intent |= F2PY_INTENT_IN;
  capi_z_tmp = array_from_pyobj(NPY_FLOAT,z_Dims,z_Rank,capi_z_intent,z_capi);
  if (capi_z_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 3rd argument `z' of _srfpack.gradg to C/Fortran array" );
  } else {
    z = (float *)(PyArray_DATA(capi_z_tmp));

  /* Processing variable list */
  list_Dims[0]=6 * n - 12;
  capi_list_intent |= F2PY_INTENT_IN;
  capi_list_tmp = array_from_pyobj(NPY_INT,list_Dims,list_Rank,capi_list_intent,list_capi);
  if (capi_list_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 4th argument `list' of _srfpack.gradg to C/Fortran array" );
  } else {
    list = (int *)(PyArray_DATA(capi_list_tmp));

  /* Processing variable lptr */
  lptr_Dims[0]=6 * n - 12;
  capi_lptr_intent |= F2PY_INTENT_IN;
  capi_lptr_tmp = array_from_pyobj(NPY_INT,lptr_Dims,lptr_Rank,capi_lptr_intent,lptr_capi);
  if (capi_lptr_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 5th argument `lptr' of _srfpack.gradg to C/Fortran array" );
  } else {
    lptr = (int *)(PyArray_DATA(capi_lptr_tmp));

  /* Processing variable lend */
  lend_Dims[0]=n;
  capi_lend_intent |= F2PY_INTENT_IN;
  capi_lend_tmp = array_from_pyobj(NPY_INT,lend_Dims,lend_Rank,capi_lend_intent,lend_capi);
  if (capi_lend_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 6th argument `lend' of _srfpack.gradg to C/Fortran array" );
  } else {
    lend = (int *)(PyArray_DATA(capi_lend_tmp));

  /* Processing variable grad */
  grad_Dims[0]=2,grad_Dims[1]=n;
  capi_grad_intent |= F2PY_INTENT_INOUT;
  capi_grad_tmp = array_from_pyobj(NPY_FLOAT,grad_Dims,grad_Rank,capi_grad_intent,grad_capi);
  if (capi_grad_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 9th argument `grad' of _srfpack.gradg to C/Fortran array" );
  } else {
    grad = (float *)(PyArray_DATA(capi_grad_tmp));

/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
        (*f2py_func)(&ncc,lcc,&n,x,y,z,list,lptr,lend,&iflgs,sigma,&nit,&dgmax,grad,&ier);
if (PyErr_Occurred())
  f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
    if (f2py_success) {
/*pyobjfrom*/
  f2py_success = try_pyarr_from_int(nit_capi,&nit);
  if (f2py_success) {
  f2py_success = try_pyarr_from_float(dgmax_capi,&dgmax);
  if (f2py_success) {
/*end of pyobjfrom*/
    CFUNCSMESS("Building return value.\n");
    capi_buildvalue = Py_BuildValue("i",ier);
/*closepyobjfrom*/
  } /*if (f2py_success) of dgmax pyobjfrom*/
  } /*if (f2py_success) of nit pyobjfrom*/
/*end of closepyobjfrom*/
    } /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
  if((PyObject *)capi_grad_tmp!=grad_capi) {
    Py_XDECREF(capi_grad_tmp); }
  }  /*if (capi_grad_tmp == NULL) ... else of grad*/
  /* End of cleaning variable grad */
  if((PyObject *)capi_lend_tmp!=lend_capi) {
    Py_XDECREF(capi_lend_tmp); }
  }  /*if (capi_lend_tmp == NULL) ... else of lend*/
  /* End of cleaning variable lend */
  if((PyObject *)capi_lptr_tmp!=lptr_capi) {
    Py_XDECREF(capi_lptr_tmp); }
  }  /*if (capi_lptr_tmp == NULL) ... else of lptr*/
  /* End of cleaning variable lptr */
  if((PyObject *)capi_list_tmp!=list_capi) {
    Py_XDECREF(capi_list_tmp); }
  }  /*if (capi_list_tmp == NULL) ... else of list*/
  /* End of cleaning variable list */
  if((PyObject *)capi_z_tmp!=z_capi) {
    Py_XDECREF(capi_z_tmp); }
  }  /*if (capi_z_tmp == NULL) ... else of z*/
  /* End of cleaning variable z */
  if((PyObject *)capi_y_tmp!=y_capi) {
    Py_XDECREF(capi_y_tmp); }
  }  /*if (capi_y_tmp == NULL) ... else of y*/
  /* End of cleaning variable y */
  /* End of cleaning variable n */
  if((PyObject *)capi_lcc_tmp!=lcc_capi) {
    Py_XDECREF(capi_lcc_tmp); }
  }  /*if (capi_lcc_tmp == NULL) ... else of lcc*/
  /* End of cleaning variable lcc */
  /* End of cleaning variable ier */
  } /*if (f2py_success) of dgmax*/
  /* End of cleaning variable dgmax */
  } /*if (f2py_success) of nit*/
  /* End of cleaning variable nit */
  if((PyObject *)capi_sigma_tmp!=sigma_capi) {
    Py_XDECREF(capi_sigma_tmp); }
  }  /*if (capi_sigma_tmp == NULL) ... else of sigma*/
  /* End of cleaning variable sigma */
  } /*if (f2py_success) of iflgs*/
  /* End of cleaning variable iflgs */
  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 */
  } /*if (f2py_success) of ncc*/
  /* End of cleaning variable ncc */
/*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 gradg ********************************/

/*********************************** gradl ***********************************/
static char doc_f2py_rout__srfpack_gradl[] = "\
dx,dy,ier = gradl(k,x,y,z,list,lptr,lend,[ncc,lcc])\n\nWrapper for ``gradl``.\
\n\nParameters\n----------\n"
"k : input int\n"
"x : input rank-1 array('f') with bounds (n)\n"
"y : input rank-1 array('f') with bounds (n)\n"
"z : input rank-1 array('f') with bounds (n)\n"
"list : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lptr : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lend : input rank-1 array('i') with bounds (n)\n"
"\nOther Parameters\n----------------\n"
"ncc : input int, optional\n    Default: 0\n"
"lcc : input rank-1 array('i') with bounds (ncc + 1)\n"
"\nReturns\n-------\n"
"dx : float\n"
"dy : float\n"
"ier : int";
/* extern void F_FUNC(gradl,GRADL)(int*,int*,int*,int*,float*,float*,float*,int*,int*,int*,float*,float*,int*); */
static PyObject *f2py_rout__srfpack_gradl(const PyObject *capi_self,
                           PyObject *capi_args,
                           PyObject *capi_keywds,
                           void (*f2py_func)(int*,int*,int*,int*,float*,float*,float*,int*,int*,int*,float*,float*,int*)) {
  PyObject * volatile capi_buildvalue = NULL;
  volatile int f2py_success = 1;
/*decl*/

  int k = 0;
  PyObject *k_capi = Py_None;
  int ncc = 0;
  PyObject *ncc_capi = Py_None;
  int *lcc = NULL;
  npy_intp lcc_Dims[1] = {-1};
  const int lcc_Rank = 1;
  PyArrayObject *capi_lcc_tmp = NULL;
  int capi_lcc_intent = 0;
  PyObject *lcc_capi = Py_None;
  int n = 0;
  float *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;
  float *y = NULL;
  npy_intp y_Dims[1] = {-1};
  const int y_Rank = 1;
  PyArrayObject *capi_y_tmp = NULL;
  int capi_y_intent = 0;
  PyObject *y_capi = Py_None;
  float *z = NULL;
  npy_intp z_Dims[1] = {-1};
  const int z_Rank = 1;
  PyArrayObject *capi_z_tmp = NULL;
  int capi_z_intent = 0;
  PyObject *z_capi = Py_None;
  int *list = NULL;
  npy_intp list_Dims[1] = {-1};
  const int list_Rank = 1;
  PyArrayObject *capi_list_tmp = NULL;
  int capi_list_intent = 0;
  PyObject *list_capi = Py_None;
  int *lptr = NULL;
  npy_intp lptr_Dims[1] = {-1};
  const int lptr_Rank = 1;
  PyArrayObject *capi_lptr_tmp = NULL;
  int capi_lptr_intent = 0;
  PyObject *lptr_capi = Py_None;
  int *lend = NULL;
  npy_intp lend_Dims[1] = {-1};
  const int lend_Rank = 1;
  PyArrayObject *capi_lend_tmp = NULL;
  int capi_lend_intent = 0;
  PyObject *lend_capi = Py_None;
  float dx = 0;
  float dy = 0;
  int ier = 0;
  static char *capi_kwlist[] = {"k","x","y","z","list","lptr","lend","ncc","lcc",NULL};

/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
  if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
    "OOOOOOO|OO:_srfpack.gradl",\
    capi_kwlist,&k_capi,&x_capi,&y_capi,&z_capi,&list_capi,&lptr_capi,&lend_capi,&ncc_capi,&lcc_capi))
    return NULL;
/*frompyobj*/
  /* Processing variable k */
    f2py_success = int_from_pyobj(&k,k_capi,"_srfpack.gradl() 1st argument (k) can't be converted to int");
  if (f2py_success) {
  /* Processing variable ncc */
  if (ncc_capi == Py_None) ncc = 0; else
    f2py_success = int_from_pyobj(&ncc,ncc_capi,"_srfpack.gradl() 1st keyword (ncc) can't be converted to int");
  if (f2py_success) {
  /* Processing variable x */
  ;
  capi_x_intent |= F2PY_INTENT_IN;
  capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi);
  if (capi_x_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd argument `x' of _srfpack.gradl to C/Fortran array" );
  } else {
    x = (float *)(PyArray_DATA(capi_x_tmp));

  /* Processing variable dx */
  /* Processing variable dy */
  /* Processing variable ier */
  /* Processing variable lcc */
  lcc_Dims[0]=ncc + 1;
  capi_lcc_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL;
  capi_lcc_tmp = array_from_pyobj(NPY_INT,lcc_Dims,lcc_Rank,capi_lcc_intent,lcc_capi);
  if (capi_lcc_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd keyword `lcc' of _srfpack.gradl to C/Fortran array" );
  } else {
    lcc = (int *)(PyArray_DATA(capi_lcc_tmp));

  /* Processing variable n */
  n = len(x);
  /* Processing variable y */
  y_Dims[0]=n;
  capi_y_intent |= F2PY_INTENT_IN;
  capi_y_tmp = array_from_pyobj(NPY_FLOAT,y_Dims,y_Rank,capi_y_intent,y_capi);
  if (capi_y_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 3rd argument `y' of _srfpack.gradl to C/Fortran array" );
  } else {
    y = (float *)(PyArray_DATA(capi_y_tmp));

  /* Processing variable z */
  z_Dims[0]=n;
  capi_z_intent |= F2PY_INTENT_IN;
  capi_z_tmp = array_from_pyobj(NPY_FLOAT,z_Dims,z_Rank,capi_z_intent,z_capi);
  if (capi_z_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 4th argument `z' of _srfpack.gradl to C/Fortran array" );
  } else {
    z = (float *)(PyArray_DATA(capi_z_tmp));

  /* Processing variable list */
  list_Dims[0]=6 * n - 12;
  capi_list_intent |= F2PY_INTENT_IN;
  capi_list_tmp = array_from_pyobj(NPY_INT,list_Dims,list_Rank,capi_list_intent,list_capi);
  if (capi_list_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 5th argument `list' of _srfpack.gradl to C/Fortran array" );
  } else {
    list = (int *)(PyArray_DATA(capi_list_tmp));

  /* Processing variable lptr */
  lptr_Dims[0]=6 * n - 12;
  capi_lptr_intent |= F2PY_INTENT_IN;
  capi_lptr_tmp = array_from_pyobj(NPY_INT,lptr_Dims,lptr_Rank,capi_lptr_intent,lptr_capi);
  if (capi_lptr_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 6th argument `lptr' of _srfpack.gradl to C/Fortran array" );
  } else {
    lptr = (int *)(PyArray_DATA(capi_lptr_tmp));

  /* Processing variable lend */
  lend_Dims[0]=n;
  capi_lend_intent |= F2PY_INTENT_IN;
  capi_lend_tmp = array_from_pyobj(NPY_INT,lend_Dims,lend_Rank,capi_lend_intent,lend_capi);
  if (capi_lend_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 7th argument `lend' of _srfpack.gradl to C/Fortran array" );
  } else {
    lend = (int *)(PyArray_DATA(capi_lend_tmp));

/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
        (*f2py_func)(&k,&ncc,lcc,&n,x,y,z,list,lptr,lend,&dx,&dy,&ier);
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("ffi",dx,dy,ier);
/*closepyobjfrom*/
/*end of closepyobjfrom*/
    } /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
  if((PyObject *)capi_lend_tmp!=lend_capi) {
    Py_XDECREF(capi_lend_tmp); }
  }  /*if (capi_lend_tmp == NULL) ... else of lend*/
  /* End of cleaning variable lend */
  if((PyObject *)capi_lptr_tmp!=lptr_capi) {
    Py_XDECREF(capi_lptr_tmp); }
  }  /*if (capi_lptr_tmp == NULL) ... else of lptr*/
  /* End of cleaning variable lptr */
  if((PyObject *)capi_list_tmp!=list_capi) {
    Py_XDECREF(capi_list_tmp); }
  }  /*if (capi_list_tmp == NULL) ... else of list*/
  /* End of cleaning variable list */
  if((PyObject *)capi_z_tmp!=z_capi) {
    Py_XDECREF(capi_z_tmp); }
  }  /*if (capi_z_tmp == NULL) ... else of z*/
  /* End of cleaning variable z */
  if((PyObject *)capi_y_tmp!=y_capi) {
    Py_XDECREF(capi_y_tmp); }
  }  /*if (capi_y_tmp == NULL) ... else of y*/
  /* End of cleaning variable y */
  /* End of cleaning variable n */
  if((PyObject *)capi_lcc_tmp!=lcc_capi) {
    Py_XDECREF(capi_lcc_tmp); }
  }  /*if (capi_lcc_tmp == NULL) ... else of lcc*/
  /* End of cleaning variable lcc */
  /* End of cleaning variable ier */
  /* End of cleaning variable dy */
  /* End of cleaning variable dx */
  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 */
  } /*if (f2py_success) of ncc*/
  /* End of cleaning variable ncc */
  } /*if (f2py_success) of k*/
  /* End of cleaning variable k */
/*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 gradl ********************************/

/*********************************** intrc0 ***********************************/
static char doc_f2py_rout__srfpack_intrc0[] = "\
pz,ier = intrc0(px,py,x,y,z,list,lptr,lend,ist,[ncc,lcc])\n\nWrapper for ``intrc0``.\
\n\nParameters\n----------\n"
"px : input float\n"
"py : input float\n"
"x : input rank-1 array('f') with bounds (n)\n"
"y : input rank-1 array('f') with bounds (n)\n"
"z : input rank-1 array('f') with bounds (n)\n"
"list : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lptr : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lend : input rank-1 array('i') with bounds (n)\n"
"ist : in/output rank-0 array(int,'i')\n"
"\nOther Parameters\n----------------\n"
"ncc : input int, optional\n    Default: 0\n"
"lcc : input rank-1 array('i') with bounds (ncc + 1)\n"
"\nReturns\n-------\n"
"pz : float\n"
"ier : int";
/* extern void F_FUNC(intrc0,INTRC0)(float*,float*,int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,int*); */
static PyObject *f2py_rout__srfpack_intrc0(const PyObject *capi_self,
                           PyObject *capi_args,
                           PyObject *capi_keywds,
                           void (*f2py_func)(float*,float*,int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,int*)) {
  PyObject * volatile capi_buildvalue = NULL;
  volatile int f2py_success = 1;
/*decl*/

  float px = 0;
  PyObject *px_capi = Py_None;
  float py = 0;
  PyObject *py_capi = Py_None;
  int ncc = 0;
  PyObject *ncc_capi = Py_None;
  int *lcc = NULL;
  npy_intp lcc_Dims[1] = {-1};
  const int lcc_Rank = 1;
  PyArrayObject *capi_lcc_tmp = NULL;
  int capi_lcc_intent = 0;
  PyObject *lcc_capi = Py_None;
  int n = 0;
  float *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;
  float *y = NULL;
  npy_intp y_Dims[1] = {-1};
  const int y_Rank = 1;
  PyArrayObject *capi_y_tmp = NULL;
  int capi_y_intent = 0;
  PyObject *y_capi = Py_None;
  float *z = NULL;
  npy_intp z_Dims[1] = {-1};
  const int z_Rank = 1;
  PyArrayObject *capi_z_tmp = NULL;
  int capi_z_intent = 0;
  PyObject *z_capi = Py_None;
  int *list = NULL;
  npy_intp list_Dims[1] = {-1};
  const int list_Rank = 1;
  PyArrayObject *capi_list_tmp = NULL;
  int capi_list_intent = 0;
  PyObject *list_capi = Py_None;
  int *lptr = NULL;
  npy_intp lptr_Dims[1] = {-1};
  const int lptr_Rank = 1;
  PyArrayObject *capi_lptr_tmp = NULL;
  int capi_lptr_intent = 0;
  PyObject *lptr_capi = Py_None;
  int *lend = NULL;
  npy_intp lend_Dims[1] = {-1};
  const int lend_Rank = 1;
  PyArrayObject *capi_lend_tmp = NULL;
  int capi_lend_intent = 0;
  PyObject *lend_capi = Py_None;
  int ist = 0;
  PyObject *ist_capi = Py_None;
  float pz = 0;
  int ier = 0;
  static char *capi_kwlist[] = {"px","py","x","y","z","list","lptr","lend","ist","ncc","lcc",NULL};

/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
  if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
    "OOOOOOOOO|OO:_srfpack.intrc0",\
    capi_kwlist,&px_capi,&py_capi,&x_capi,&y_capi,&z_capi,&list_capi,&lptr_capi,&lend_capi,&ist_capi,&ncc_capi,&lcc_capi))
    return NULL;
/*frompyobj*/
  /* Processing variable px */
    f2py_success = float_from_pyobj(&px,px_capi,"_srfpack.intrc0() 1st argument (px) can't be converted to float");
  if (f2py_success) {
  /* Processing variable py */
    f2py_success = float_from_pyobj(&py,py_capi,"_srfpack.intrc0() 2nd argument (py) can't be converted to float");
  if (f2py_success) {
  /* Processing variable ncc */
  if (ncc_capi == Py_None) ncc = 0; else
    f2py_success = int_from_pyobj(&ncc,ncc_capi,"_srfpack.intrc0() 1st keyword (ncc) can't be converted to int");
  if (f2py_success) {
  /* Processing variable x */
  ;
  capi_x_intent |= F2PY_INTENT_IN;
  capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi);
  if (capi_x_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 3rd argument `x' of _srfpack.intrc0 to C/Fortran array" );
  } else {
    x = (float *)(PyArray_DATA(capi_x_tmp));

  /* Processing variable ist */
    f2py_success = int_from_pyobj(&ist,ist_capi,"_srfpack.intrc0() 9th argument (ist) can't be converted to int");
  if (f2py_success) {
  /* Processing variable pz */
  /* Processing variable ier */
  /* Processing variable lcc */
  lcc_Dims[0]=ncc + 1;
  capi_lcc_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL;
  capi_lcc_tmp = array_from_pyobj(NPY_INT,lcc_Dims,lcc_Rank,capi_lcc_intent,lcc_capi);
  if (capi_lcc_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd keyword `lcc' of _srfpack.intrc0 to C/Fortran array" );
  } else {
    lcc = (int *)(PyArray_DATA(capi_lcc_tmp));

  /* Processing variable n */
  n = len(x);
  /* Processing variable y */
  y_Dims[0]=n;
  capi_y_intent |= F2PY_INTENT_IN;
  capi_y_tmp = array_from_pyobj(NPY_FLOAT,y_Dims,y_Rank,capi_y_intent,y_capi);
  if (capi_y_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 4th argument `y' of _srfpack.intrc0 to C/Fortran array" );
  } else {
    y = (float *)(PyArray_DATA(capi_y_tmp));

  /* Processing variable z */
  z_Dims[0]=n;
  capi_z_intent |= F2PY_INTENT_IN;
  capi_z_tmp = array_from_pyobj(NPY_FLOAT,z_Dims,z_Rank,capi_z_intent,z_capi);
  if (capi_z_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 5th argument `z' of _srfpack.intrc0 to C/Fortran array" );
  } else {
    z = (float *)(PyArray_DATA(capi_z_tmp));

  /* Processing variable list */
  list_Dims[0]=6 * n - 12;
  capi_list_intent |= F2PY_INTENT_IN;
  capi_list_tmp = array_from_pyobj(NPY_INT,list_Dims,list_Rank,capi_list_intent,list_capi);
  if (capi_list_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 6th argument `list' of _srfpack.intrc0 to C/Fortran array" );
  } else {
    list = (int *)(PyArray_DATA(capi_list_tmp));

  /* Processing variable lptr */
  lptr_Dims[0]=6 * n - 12;
  capi_lptr_intent |= F2PY_INTENT_IN;
  capi_lptr_tmp = array_from_pyobj(NPY_INT,lptr_Dims,lptr_Rank,capi_lptr_intent,lptr_capi);
  if (capi_lptr_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 7th argument `lptr' of _srfpack.intrc0 to C/Fortran array" );
  } else {
    lptr = (int *)(PyArray_DATA(capi_lptr_tmp));

  /* Processing variable lend */
  lend_Dims[0]=n;
  capi_lend_intent |= F2PY_INTENT_IN;
  capi_lend_tmp = array_from_pyobj(NPY_INT,lend_Dims,lend_Rank,capi_lend_intent,lend_capi);
  if (capi_lend_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 8th argument `lend' of _srfpack.intrc0 to C/Fortran array" );
  } else {
    lend = (int *)(PyArray_DATA(capi_lend_tmp));

/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
        (*f2py_func)(&px,&py,&ncc,lcc,&n,x,y,z,list,lptr,lend,&ist,&pz,&ier);
if (PyErr_Occurred())
  f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
    if (f2py_success) {
/*pyobjfrom*/
  f2py_success = try_pyarr_from_int(ist_capi,&ist);
  if (f2py_success) {
/*end of pyobjfrom*/
    CFUNCSMESS("Building return value.\n");
    capi_buildvalue = Py_BuildValue("fi",pz,ier);
/*closepyobjfrom*/
  } /*if (f2py_success) of ist pyobjfrom*/
/*end of closepyobjfrom*/
    } /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
  if((PyObject *)capi_lend_tmp!=lend_capi) {
    Py_XDECREF(capi_lend_tmp); }
  }  /*if (capi_lend_tmp == NULL) ... else of lend*/
  /* End of cleaning variable lend */
  if((PyObject *)capi_lptr_tmp!=lptr_capi) {
    Py_XDECREF(capi_lptr_tmp); }
  }  /*if (capi_lptr_tmp == NULL) ... else of lptr*/
  /* End of cleaning variable lptr */
  if((PyObject *)capi_list_tmp!=list_capi) {
    Py_XDECREF(capi_list_tmp); }
  }  /*if (capi_list_tmp == NULL) ... else of list*/
  /* End of cleaning variable list */
  if((PyObject *)capi_z_tmp!=z_capi) {
    Py_XDECREF(capi_z_tmp); }
  }  /*if (capi_z_tmp == NULL) ... else of z*/
  /* End of cleaning variable z */
  if((PyObject *)capi_y_tmp!=y_capi) {
    Py_XDECREF(capi_y_tmp); }
  }  /*if (capi_y_tmp == NULL) ... else of y*/
  /* End of cleaning variable y */
  /* End of cleaning variable n */
  if((PyObject *)capi_lcc_tmp!=lcc_capi) {
    Py_XDECREF(capi_lcc_tmp); }
  }  /*if (capi_lcc_tmp == NULL) ... else of lcc*/
  /* End of cleaning variable lcc */
  /* End of cleaning variable ier */
  /* End of cleaning variable pz */
  } /*if (f2py_success) of ist*/
  /* End of cleaning variable ist */
  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 */
  } /*if (f2py_success) of ncc*/
  /* End of cleaning variable ncc */
  } /*if (f2py_success) of py*/
  /* End of cleaning variable py */
  } /*if (f2py_success) of px*/
  /* End of cleaning variable px */
/*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 intrc0 *******************************/

/*********************************** intrc1 ***********************************/
static char doc_f2py_rout__srfpack_intrc1[] = "\
pz,pzx,pzy,ier = intrc1(px,py,x,y,z,list,lptr,lend,iflgs,sigma,grad,dflag,ist,[ncc,lcc])\n\nWrapper for ``intrc1``.\
\n\nParameters\n----------\n"
"px : input float\n"
"py : input float\n"
"x : input rank-1 array('f') with bounds (n)\n"
"y : input rank-1 array('f') with bounds (n)\n"
"z : input rank-1 array('f') with bounds (n)\n"
"list : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lptr : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lend : input rank-1 array('i') with bounds (n)\n"
"iflgs : input int\n"
"sigma : input rank-1 array('f') with bounds (*)\n"
"grad : input rank-2 array('f') with bounds (2,n)\n"
"dflag : input int\n"
"ist : in/output rank-0 array(int,'i')\n"
"\nOther Parameters\n----------------\n"
"ncc : input int, optional\n    Default: 0\n"
"lcc : input rank-1 array('i') with bounds (ncc + 1)\n"
"\nReturns\n-------\n"
"pz : float\n"
"pzx : float\n"
"pzy : float\n"
"ier : int";
/* extern void F_FUNC(intrc1,INTRC1)(float*,float*,int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,float*,int*,int*,float*,float*,float*,int*); */
static PyObject *f2py_rout__srfpack_intrc1(const PyObject *capi_self,
                           PyObject *capi_args,
                           PyObject *capi_keywds,
                           void (*f2py_func)(float*,float*,int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,float*,int*,int*,float*,float*,float*,int*)) {
  PyObject * volatile capi_buildvalue = NULL;
  volatile int f2py_success = 1;
/*decl*/

  float px = 0;
  PyObject *px_capi = Py_None;
  float py = 0;
  PyObject *py_capi = Py_None;
  int ncc = 0;
  PyObject *ncc_capi = Py_None;
  int *lcc = NULL;
  npy_intp lcc_Dims[1] = {-1};
  const int lcc_Rank = 1;
  PyArrayObject *capi_lcc_tmp = NULL;
  int capi_lcc_intent = 0;
  PyObject *lcc_capi = Py_None;
  int n = 0;
  float *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;
  float *y = NULL;
  npy_intp y_Dims[1] = {-1};
  const int y_Rank = 1;
  PyArrayObject *capi_y_tmp = NULL;
  int capi_y_intent = 0;
  PyObject *y_capi = Py_None;
  float *z = NULL;
  npy_intp z_Dims[1] = {-1};
  const int z_Rank = 1;
  PyArrayObject *capi_z_tmp = NULL;
  int capi_z_intent = 0;
  PyObject *z_capi = Py_None;
  int *list = NULL;
  npy_intp list_Dims[1] = {-1};
  const int list_Rank = 1;
  PyArrayObject *capi_list_tmp = NULL;
  int capi_list_intent = 0;
  PyObject *list_capi = Py_None;
  int *lptr = NULL;
  npy_intp lptr_Dims[1] = {-1};
  const int lptr_Rank = 1;
  PyArrayObject *capi_lptr_tmp = NULL;
  int capi_lptr_intent = 0;
  PyObject *lptr_capi = Py_None;
  int *lend = NULL;
  npy_intp lend_Dims[1] = {-1};
  const int lend_Rank = 1;
  PyArrayObject *capi_lend_tmp = NULL;
  int capi_lend_intent = 0;
  PyObject *lend_capi = Py_None;
  int iflgs = 0;
  PyObject *iflgs_capi = Py_None;
  float *sigma = NULL;
  npy_intp sigma_Dims[1] = {-1};
  const int sigma_Rank = 1;
  PyArrayObject *capi_sigma_tmp = NULL;
  int capi_sigma_intent = 0;
  PyObject *sigma_capi = Py_None;
  float *grad = NULL;
  npy_intp grad_Dims[2] = {-1, -1};
  const int grad_Rank = 2;
  PyArrayObject *capi_grad_tmp = NULL;
  int capi_grad_intent = 0;
  PyObject *grad_capi = Py_None;
  int dflag = 0;
  PyObject *dflag_capi = Py_None;
  int ist = 0;
  PyObject *ist_capi = Py_None;
  float pz = 0;
  float pzx = 0;
  float pzy = 0;
  int ier = 0;
  static char *capi_kwlist[] = {"px","py","x","y","z","list","lptr","lend","iflgs","sigma","grad","dflag","ist","ncc","lcc",NULL};

/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
  if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
    "OOOOOOOOOOOOO|OO:_srfpack.intrc1",\
    capi_kwlist,&px_capi,&py_capi,&x_capi,&y_capi,&z_capi,&list_capi,&lptr_capi,&lend_capi,&iflgs_capi,&sigma_capi,&grad_capi,&dflag_capi,&ist_capi,&ncc_capi,&lcc_capi))
    return NULL;
/*frompyobj*/
  /* Processing variable px */
    f2py_success = float_from_pyobj(&px,px_capi,"_srfpack.intrc1() 1st argument (px) can't be converted to float");
  if (f2py_success) {
  /* Processing variable py */
    f2py_success = float_from_pyobj(&py,py_capi,"_srfpack.intrc1() 2nd argument (py) can't be converted to float");
  if (f2py_success) {
  /* Processing variable ncc */
  if (ncc_capi == Py_None) ncc = 0; else
    f2py_success = int_from_pyobj(&ncc,ncc_capi,"_srfpack.intrc1() 1st keyword (ncc) can't be converted to int");
  if (f2py_success) {
  /* Processing variable x */
  ;
  capi_x_intent |= F2PY_INTENT_IN;
  capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi);
  if (capi_x_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 3rd argument `x' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    x = (float *)(PyArray_DATA(capi_x_tmp));

  /* Processing variable iflgs */
    f2py_success = int_from_pyobj(&iflgs,iflgs_capi,"_srfpack.intrc1() 9th argument (iflgs) can't be converted to int");
  if (f2py_success) {
  /* Processing variable sigma */
  ;
  capi_sigma_intent |= F2PY_INTENT_IN;
  capi_sigma_tmp = array_from_pyobj(NPY_FLOAT,sigma_Dims,sigma_Rank,capi_sigma_intent,sigma_capi);
  if (capi_sigma_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 10th argument `sigma' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    sigma = (float *)(PyArray_DATA(capi_sigma_tmp));

  /* Processing variable dflag */
    dflag = (int)PyObject_IsTrue(dflag_capi);
    f2py_success = 1;
  if (f2py_success) {
  /* Processing variable ist */
    f2py_success = int_from_pyobj(&ist,ist_capi,"_srfpack.intrc1() 13rd argument (ist) can't be converted to int");
  if (f2py_success) {
  /* Processing variable pz */
  /* Processing variable pzx */
  /* Processing variable pzy */
  /* Processing variable ier */
  /* Processing variable lcc */
  lcc_Dims[0]=ncc + 1;
  capi_lcc_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL;
  capi_lcc_tmp = array_from_pyobj(NPY_INT,lcc_Dims,lcc_Rank,capi_lcc_intent,lcc_capi);
  if (capi_lcc_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd keyword `lcc' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    lcc = (int *)(PyArray_DATA(capi_lcc_tmp));

  /* Processing variable n */
  n = len(x);
  /* Processing variable y */
  y_Dims[0]=n;
  capi_y_intent |= F2PY_INTENT_IN;
  capi_y_tmp = array_from_pyobj(NPY_FLOAT,y_Dims,y_Rank,capi_y_intent,y_capi);
  if (capi_y_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 4th argument `y' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    y = (float *)(PyArray_DATA(capi_y_tmp));

  /* Processing variable z */
  z_Dims[0]=n;
  capi_z_intent |= F2PY_INTENT_IN;
  capi_z_tmp = array_from_pyobj(NPY_FLOAT,z_Dims,z_Rank,capi_z_intent,z_capi);
  if (capi_z_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 5th argument `z' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    z = (float *)(PyArray_DATA(capi_z_tmp));

  /* Processing variable list */
  list_Dims[0]=6 * n - 12;
  capi_list_intent |= F2PY_INTENT_IN;
  capi_list_tmp = array_from_pyobj(NPY_INT,list_Dims,list_Rank,capi_list_intent,list_capi);
  if (capi_list_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 6th argument `list' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    list = (int *)(PyArray_DATA(capi_list_tmp));

  /* Processing variable lptr */
  lptr_Dims[0]=6 * n - 12;
  capi_lptr_intent |= F2PY_INTENT_IN;
  capi_lptr_tmp = array_from_pyobj(NPY_INT,lptr_Dims,lptr_Rank,capi_lptr_intent,lptr_capi);
  if (capi_lptr_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 7th argument `lptr' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    lptr = (int *)(PyArray_DATA(capi_lptr_tmp));

  /* Processing variable lend */
  lend_Dims[0]=n;
  capi_lend_intent |= F2PY_INTENT_IN;
  capi_lend_tmp = array_from_pyobj(NPY_INT,lend_Dims,lend_Rank,capi_lend_intent,lend_capi);
  if (capi_lend_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 8th argument `lend' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    lend = (int *)(PyArray_DATA(capi_lend_tmp));

  /* Processing variable grad */
  grad_Dims[0]=2,grad_Dims[1]=n;
  capi_grad_intent |= F2PY_INTENT_IN;
  capi_grad_tmp = array_from_pyobj(NPY_FLOAT,grad_Dims,grad_Rank,capi_grad_intent,grad_capi);
  if (capi_grad_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 11st argument `grad' of _srfpack.intrc1 to C/Fortran array" );
  } else {
    grad = (float *)(PyArray_DATA(capi_grad_tmp));

/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
        (*f2py_func)(&px,&py,&ncc,lcc,&n,x,y,z,list,lptr,lend,&iflgs,sigma,grad,&dflag,&ist,&pz,&pzx,&pzy,&ier);
if (PyErr_Occurred())
  f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
    if (f2py_success) {
/*pyobjfrom*/
  f2py_success = try_pyarr_from_int(ist_capi,&ist);
  if (f2py_success) {
/*end of pyobjfrom*/
    CFUNCSMESS("Building return value.\n");
    capi_buildvalue = Py_BuildValue("fffi",pz,pzx,pzy,ier);
/*closepyobjfrom*/
  } /*if (f2py_success) of ist pyobjfrom*/
/*end of closepyobjfrom*/
    } /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
  if((PyObject *)capi_grad_tmp!=grad_capi) {
    Py_XDECREF(capi_grad_tmp); }
  }  /*if (capi_grad_tmp == NULL) ... else of grad*/
  /* End of cleaning variable grad */
  if((PyObject *)capi_lend_tmp!=lend_capi) {
    Py_XDECREF(capi_lend_tmp); }
  }  /*if (capi_lend_tmp == NULL) ... else of lend*/
  /* End of cleaning variable lend */
  if((PyObject *)capi_lptr_tmp!=lptr_capi) {
    Py_XDECREF(capi_lptr_tmp); }
  }  /*if (capi_lptr_tmp == NULL) ... else of lptr*/
  /* End of cleaning variable lptr */
  if((PyObject *)capi_list_tmp!=list_capi) {
    Py_XDECREF(capi_list_tmp); }
  }  /*if (capi_list_tmp == NULL) ... else of list*/
  /* End of cleaning variable list */
  if((PyObject *)capi_z_tmp!=z_capi) {
    Py_XDECREF(capi_z_tmp); }
  }  /*if (capi_z_tmp == NULL) ... else of z*/
  /* End of cleaning variable z */
  if((PyObject *)capi_y_tmp!=y_capi) {
    Py_XDECREF(capi_y_tmp); }
  }  /*if (capi_y_tmp == NULL) ... else of y*/
  /* End of cleaning variable y */
  /* End of cleaning variable n */
  if((PyObject *)capi_lcc_tmp!=lcc_capi) {
    Py_XDECREF(capi_lcc_tmp); }
  }  /*if (capi_lcc_tmp == NULL) ... else of lcc*/
  /* End of cleaning variable lcc */
  /* End of cleaning variable ier */
  /* End of cleaning variable pzy */
  /* End of cleaning variable pzx */
  /* End of cleaning variable pz */
  } /*if (f2py_success) of ist*/
  /* End of cleaning variable ist */
  } /*if (f2py_success) of dflag*/
  /* End of cleaning variable dflag */
  if((PyObject *)capi_sigma_tmp!=sigma_capi) {
    Py_XDECREF(capi_sigma_tmp); }
  }  /*if (capi_sigma_tmp == NULL) ... else of sigma*/
  /* End of cleaning variable sigma */
  } /*if (f2py_success) of iflgs*/
  /* End of cleaning variable iflgs */
  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 */
  } /*if (f2py_success) of ncc*/
  /* End of cleaning variable ncc */
  } /*if (f2py_success) of py*/
  /* End of cleaning variable py */
  } /*if (f2py_success) of px*/
  /* End of cleaning variable px */
/*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 intrc1 *******************************/

/*********************************** smsurf ***********************************/
static char doc_f2py_rout__srfpack_smsurf[] = "\
f,fxfy,ier = smsurf(x,y,z,list,lptr,lend,iflgs,sigma,w,sm,smtol,gstol,[ncc,lcc])\n\nWrapper for ``smsurf``.\
\n\nParameters\n----------\n"
"x : input rank-1 array('f') with bounds (n)\n"
"y : input rank-1 array('f') with bounds (n)\n"
"z : input rank-1 array('f') with bounds (n)\n"
"list : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lptr : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lend : input rank-1 array('i') with bounds (n)\n"
"iflgs : input int\n"
"sigma : input rank-1 array('f') with bounds (*)\n"
"w : input rank-1 array('f') with bounds (n)\n"
"sm : input float\n"
"smtol : input float\n"
"gstol : input float\n"
"\nOther Parameters\n----------------\n"
"ncc : input int, optional\n    Default: 0\n"
"lcc : input rank-1 array('i') with bounds (ncc + 1)\n"
"\nReturns\n-------\n"
"f : rank-1 array('f') with bounds (n)\n"
"fxfy : rank-2 array('f') with bounds (2,n)\n"
"ier : int";
/* extern void F_FUNC(smsurf,SMSURF)(int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,float*,float*,float*,float*,float*,float*,int*); */
static PyObject *f2py_rout__srfpack_smsurf(const PyObject *capi_self,
                           PyObject *capi_args,
                           PyObject *capi_keywds,
                           void (*f2py_func)(int*,int*,int*,float*,float*,float*,int*,int*,int*,int*,float*,float*,float*,float*,float*,float*,float*,int*)) {
  PyObject * volatile capi_buildvalue = NULL;
  volatile int f2py_success = 1;
/*decl*/

  int ncc = 0;
  PyObject *ncc_capi = Py_None;
  int *lcc = NULL;
  npy_intp lcc_Dims[1] = {-1};
  const int lcc_Rank = 1;
  PyArrayObject *capi_lcc_tmp = NULL;
  int capi_lcc_intent = 0;
  PyObject *lcc_capi = Py_None;
  int n = 0;
  float *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;
  float *y = NULL;
  npy_intp y_Dims[1] = {-1};
  const int y_Rank = 1;
  PyArrayObject *capi_y_tmp = NULL;
  int capi_y_intent = 0;
  PyObject *y_capi = Py_None;
  float *z = NULL;
  npy_intp z_Dims[1] = {-1};
  const int z_Rank = 1;
  PyArrayObject *capi_z_tmp = NULL;
  int capi_z_intent = 0;
  PyObject *z_capi = Py_None;
  int *list = NULL;
  npy_intp list_Dims[1] = {-1};
  const int list_Rank = 1;
  PyArrayObject *capi_list_tmp = NULL;
  int capi_list_intent = 0;
  PyObject *list_capi = Py_None;
  int *lptr = NULL;
  npy_intp lptr_Dims[1] = {-1};
  const int lptr_Rank = 1;
  PyArrayObject *capi_lptr_tmp = NULL;
  int capi_lptr_intent = 0;
  PyObject *lptr_capi = Py_None;
  int *lend = NULL;
  npy_intp lend_Dims[1] = {-1};
  const int lend_Rank = 1;
  PyArrayObject *capi_lend_tmp = NULL;
  int capi_lend_intent = 0;
  PyObject *lend_capi = Py_None;
  int iflgs = 0;
  PyObject *iflgs_capi = Py_None;
  float *sigma = NULL;
  npy_intp sigma_Dims[1] = {-1};
  const int sigma_Rank = 1;
  PyArrayObject *capi_sigma_tmp = NULL;
  int capi_sigma_intent = 0;
  PyObject *sigma_capi = Py_None;
  float *w = NULL;
  npy_intp w_Dims[1] = {-1};
  const int w_Rank = 1;
  PyArrayObject *capi_w_tmp = NULL;
  int capi_w_intent = 0;
  PyObject *w_capi = Py_None;
  float sm = 0;
  PyObject *sm_capi = Py_None;
  float smtol = 0;
  PyObject *smtol_capi = Py_None;
  float gstol = 0;
  PyObject *gstol_capi = Py_None;
  float *f = NULL;
  npy_intp f_Dims[1] = {-1};
  const int f_Rank = 1;
  PyArrayObject *capi_f_tmp = NULL;
  int capi_f_intent = 0;
  float *fxfy = NULL;
  npy_intp fxfy_Dims[2] = {-1, -1};
  const int fxfy_Rank = 2;
  PyArrayObject *capi_fxfy_tmp = NULL;
  int capi_fxfy_intent = 0;
  int ier = 0;
  static char *capi_kwlist[] = {"x","y","z","list","lptr","lend","iflgs","sigma","w","sm","smtol","gstol","ncc","lcc",NULL};

/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
  if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
    "OOOOOOOOOOOO|OO:_srfpack.smsurf",\
    capi_kwlist,&x_capi,&y_capi,&z_capi,&list_capi,&lptr_capi,&lend_capi,&iflgs_capi,&sigma_capi,&w_capi,&sm_capi,&smtol_capi,&gstol_capi,&ncc_capi,&lcc_capi))
    return NULL;
/*frompyobj*/
  /* Processing variable ncc */
  if (ncc_capi == Py_None) ncc = 0; else
    f2py_success = int_from_pyobj(&ncc,ncc_capi,"_srfpack.smsurf() 1st keyword (ncc) can't be converted to int");
  if (f2py_success) {
  /* Processing variable x */
  ;
  capi_x_intent |= F2PY_INTENT_IN;
  capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi);
  if (capi_x_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 1st argument `x' of _srfpack.smsurf to C/Fortran array" );
  } else {
    x = (float *)(PyArray_DATA(capi_x_tmp));

  /* Processing variable iflgs */
    f2py_success = int_from_pyobj(&iflgs,iflgs_capi,"_srfpack.smsurf() 7th argument (iflgs) can't be converted to int");
  if (f2py_success) {
  /* Processing variable sigma */
  ;
  capi_sigma_intent |= F2PY_INTENT_IN;
  capi_sigma_tmp = array_from_pyobj(NPY_FLOAT,sigma_Dims,sigma_Rank,capi_sigma_intent,sigma_capi);
  if (capi_sigma_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 8th argument `sigma' of _srfpack.smsurf to C/Fortran array" );
  } else {
    sigma = (float *)(PyArray_DATA(capi_sigma_tmp));

  /* Processing variable sm */
    f2py_success = float_from_pyobj(&sm,sm_capi,"_srfpack.smsurf() 10th argument (sm) can't be converted to float");
  if (f2py_success) {
  /* Processing variable smtol */
    f2py_success = float_from_pyobj(&smtol,smtol_capi,"_srfpack.smsurf() 11st argument (smtol) can't be converted to float");
  if (f2py_success) {
  /* Processing variable gstol */
    f2py_success = float_from_pyobj(&gstol,gstol_capi,"_srfpack.smsurf() 12nd argument (gstol) can't be converted to float");
  if (f2py_success) {
  /* Processing variable ier */
  /* Processing variable lcc */
  lcc_Dims[0]=ncc + 1;
  capi_lcc_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL;
  capi_lcc_tmp = array_from_pyobj(NPY_INT,lcc_Dims,lcc_Rank,capi_lcc_intent,lcc_capi);
  if (capi_lcc_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd keyword `lcc' of _srfpack.smsurf to C/Fortran array" );
  } else {
    lcc = (int *)(PyArray_DATA(capi_lcc_tmp));

  /* Processing variable n */
  n = len(x);
  /* Processing variable y */
  y_Dims[0]=n;
  capi_y_intent |= F2PY_INTENT_IN;
  capi_y_tmp = array_from_pyobj(NPY_FLOAT,y_Dims,y_Rank,capi_y_intent,y_capi);
  if (capi_y_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd argument `y' of _srfpack.smsurf to C/Fortran array" );
  } else {
    y = (float *)(PyArray_DATA(capi_y_tmp));

  /* Processing variable z */
  z_Dims[0]=n;
  capi_z_intent |= F2PY_INTENT_IN;
  capi_z_tmp = array_from_pyobj(NPY_FLOAT,z_Dims,z_Rank,capi_z_intent,z_capi);
  if (capi_z_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 3rd argument `z' of _srfpack.smsurf to C/Fortran array" );
  } else {
    z = (float *)(PyArray_DATA(capi_z_tmp));

  /* Processing variable list */
  list_Dims[0]=6 * n - 12;
  capi_list_intent |= F2PY_INTENT_IN;
  capi_list_tmp = array_from_pyobj(NPY_INT,list_Dims,list_Rank,capi_list_intent,list_capi);
  if (capi_list_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 4th argument `list' of _srfpack.smsurf to C/Fortran array" );
  } else {
    list = (int *)(PyArray_DATA(capi_list_tmp));

  /* Processing variable lptr */
  lptr_Dims[0]=6 * n - 12;
  capi_lptr_intent |= F2PY_INTENT_IN;
  capi_lptr_tmp = array_from_pyobj(NPY_INT,lptr_Dims,lptr_Rank,capi_lptr_intent,lptr_capi);
  if (capi_lptr_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 5th argument `lptr' of _srfpack.smsurf to C/Fortran array" );
  } else {
    lptr = (int *)(PyArray_DATA(capi_lptr_tmp));

  /* Processing variable lend */
  lend_Dims[0]=n;
  capi_lend_intent |= F2PY_INTENT_IN;
  capi_lend_tmp = array_from_pyobj(NPY_INT,lend_Dims,lend_Rank,capi_lend_intent,lend_capi);
  if (capi_lend_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 6th argument `lend' of _srfpack.smsurf to C/Fortran array" );
  } else {
    lend = (int *)(PyArray_DATA(capi_lend_tmp));

  /* Processing variable w */
  w_Dims[0]=n;
  capi_w_intent |= F2PY_INTENT_IN;
  capi_w_tmp = array_from_pyobj(NPY_FLOAT,w_Dims,w_Rank,capi_w_intent,w_capi);
  if (capi_w_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 9th argument `w' of _srfpack.smsurf to C/Fortran array" );
  } else {
    w = (float *)(PyArray_DATA(capi_w_tmp));

  /* Processing variable f */
  f_Dims[0]=n;
  capi_f_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE;
  capi_f_tmp = array_from_pyobj(NPY_FLOAT,f_Dims,f_Rank,capi_f_intent,Py_None);
  if (capi_f_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting hidden `f' of _srfpack.smsurf to C/Fortran array" );
  } else {
    f = (float *)(PyArray_DATA(capi_f_tmp));

  /* Processing variable fxfy */
  fxfy_Dims[0]=2,fxfy_Dims[1]=n;
  capi_fxfy_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE;
  capi_fxfy_tmp = array_from_pyobj(NPY_FLOAT,fxfy_Dims,fxfy_Rank,capi_fxfy_intent,Py_None);
  if (capi_fxfy_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting hidden `fxfy' of _srfpack.smsurf to C/Fortran array" );
  } else {
    fxfy = (float *)(PyArray_DATA(capi_fxfy_tmp));

/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
        (*f2py_func)(&ncc,lcc,&n,x,y,z,list,lptr,lend,&iflgs,sigma,w,&sm,&smtol,&gstol,f,fxfy,&ier);
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("NNi",capi_f_tmp,capi_fxfy_tmp,ier);
/*closepyobjfrom*/
/*end of closepyobjfrom*/
    } /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
  }  /*if (capi_fxfy_tmp == NULL) ... else of fxfy*/
  /* End of cleaning variable fxfy */
  }  /*if (capi_f_tmp == NULL) ... else of f*/
  /* End of cleaning variable f */
  if((PyObject *)capi_w_tmp!=w_capi) {
    Py_XDECREF(capi_w_tmp); }
  }  /*if (capi_w_tmp == NULL) ... else of w*/
  /* End of cleaning variable w */
  if((PyObject *)capi_lend_tmp!=lend_capi) {
    Py_XDECREF(capi_lend_tmp); }
  }  /*if (capi_lend_tmp == NULL) ... else of lend*/
  /* End of cleaning variable lend */
  if((PyObject *)capi_lptr_tmp!=lptr_capi) {
    Py_XDECREF(capi_lptr_tmp); }
  }  /*if (capi_lptr_tmp == NULL) ... else of lptr*/
  /* End of cleaning variable lptr */
  if((PyObject *)capi_list_tmp!=list_capi) {
    Py_XDECREF(capi_list_tmp); }
  }  /*if (capi_list_tmp == NULL) ... else of list*/
  /* End of cleaning variable list */
  if((PyObject *)capi_z_tmp!=z_capi) {
    Py_XDECREF(capi_z_tmp); }
  }  /*if (capi_z_tmp == NULL) ... else of z*/
  /* End of cleaning variable z */
  if((PyObject *)capi_y_tmp!=y_capi) {
    Py_XDECREF(capi_y_tmp); }
  }  /*if (capi_y_tmp == NULL) ... else of y*/
  /* End of cleaning variable y */
  /* End of cleaning variable n */
  if((PyObject *)capi_lcc_tmp!=lcc_capi) {
    Py_XDECREF(capi_lcc_tmp); }
  }  /*if (capi_lcc_tmp == NULL) ... else of lcc*/
  /* End of cleaning variable lcc */
  /* End of cleaning variable ier */
  } /*if (f2py_success) of gstol*/
  /* End of cleaning variable gstol */
  } /*if (f2py_success) of smtol*/
  /* End of cleaning variable smtol */
  } /*if (f2py_success) of sm*/
  /* End of cleaning variable sm */
  if((PyObject *)capi_sigma_tmp!=sigma_capi) {
    Py_XDECREF(capi_sigma_tmp); }
  }  /*if (capi_sigma_tmp == NULL) ... else of sigma*/
  /* End of cleaning variable sigma */
  } /*if (f2py_success) of iflgs*/
  /* End of cleaning variable iflgs */
  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 */
  } /*if (f2py_success) of ncc*/
  /* End of cleaning variable ncc */
/*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 smsurf *******************************/

/*********************************** zgradg ***********************************/
static char doc_f2py_rout__srfpack_zgradg[] = "\
ier = zgradg(x,y,list,lptr,lend,iflgs,sigma,z,grad,[ncc,lcc,nit,dzmax])\n\nWrapper for ``zgradg``.\
\n\nParameters\n----------\n"
"x : input rank-1 array('f') with bounds (n)\n"
"y : input rank-1 array('f') with bounds (n)\n"
"list : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lptr : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lend : input rank-1 array('i') with bounds (n)\n"
"iflgs : input int\n"
"sigma : input rank-1 array('f') with bounds (*)\n"
"z : in/output rank-1 array('f') with bounds (n)\n"
"grad : in/output rank-2 array('f') with bounds (2,n)\n"
"\nOther Parameters\n----------------\n"
"ncc : input int, optional\n    Default: 0\n"
"lcc : input rank-1 array('i') with bounds (ncc + 1)\n"
"nit : in/output rank-0 array(int,'i'), optional\n    Default: 3\n"
"dzmax : in/output rank-0 array(float,'f'), optional\n    Default: 0.001\n"
"\nReturns\n-------\n"
"ier : int";
/* extern void F_FUNC(zgradg,ZGRADG)(int*,int*,int*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,float*,int*); */
static PyObject *f2py_rout__srfpack_zgradg(const PyObject *capi_self,
                           PyObject *capi_args,
                           PyObject *capi_keywds,
                           void (*f2py_func)(int*,int*,int*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,float*,int*)) {
  PyObject * volatile capi_buildvalue = NULL;
  volatile int f2py_success = 1;
/*decl*/

  int ncc = 0;
  PyObject *ncc_capi = Py_None;
  int *lcc = NULL;
  npy_intp lcc_Dims[1] = {-1};
  const int lcc_Rank = 1;
  PyArrayObject *capi_lcc_tmp = NULL;
  int capi_lcc_intent = 0;
  PyObject *lcc_capi = Py_None;
  int n = 0;
  float *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;
  float *y = NULL;
  npy_intp y_Dims[1] = {-1};
  const int y_Rank = 1;
  PyArrayObject *capi_y_tmp = NULL;
  int capi_y_intent = 0;
  PyObject *y_capi = Py_None;
  int *list = NULL;
  npy_intp list_Dims[1] = {-1};
  const int list_Rank = 1;
  PyArrayObject *capi_list_tmp = NULL;
  int capi_list_intent = 0;
  PyObject *list_capi = Py_None;
  int *lptr = NULL;
  npy_intp lptr_Dims[1] = {-1};
  const int lptr_Rank = 1;
  PyArrayObject *capi_lptr_tmp = NULL;
  int capi_lptr_intent = 0;
  PyObject *lptr_capi = Py_None;
  int *lend = NULL;
  npy_intp lend_Dims[1] = {-1};
  const int lend_Rank = 1;
  PyArrayObject *capi_lend_tmp = NULL;
  int capi_lend_intent = 0;
  PyObject *lend_capi = Py_None;
  int iflgs = 0;
  PyObject *iflgs_capi = Py_None;
  float *sigma = NULL;
  npy_intp sigma_Dims[1] = {-1};
  const int sigma_Rank = 1;
  PyArrayObject *capi_sigma_tmp = NULL;
  int capi_sigma_intent = 0;
  PyObject *sigma_capi = Py_None;
  int nit = 0;
  PyObject *nit_capi = Py_None;
  float dzmax = 0;
  PyObject *dzmax_capi = Py_None;
  float *z = NULL;
  npy_intp z_Dims[1] = {-1};
  const int z_Rank = 1;
  PyArrayObject *capi_z_tmp = NULL;
  int capi_z_intent = 0;
  PyObject *z_capi = Py_None;
  float *grad = NULL;
  npy_intp grad_Dims[2] = {-1, -1};
  const int grad_Rank = 2;
  PyArrayObject *capi_grad_tmp = NULL;
  int capi_grad_intent = 0;
  PyObject *grad_capi = Py_None;
  int ier = 0;
  static char *capi_kwlist[] = {"x","y","list","lptr","lend","iflgs","sigma","z","grad","ncc","lcc","nit","dzmax",NULL};

/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
  if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
    "OOOOOOOOO|OOOO:_srfpack.zgradg",\
    capi_kwlist,&x_capi,&y_capi,&list_capi,&lptr_capi,&lend_capi,&iflgs_capi,&sigma_capi,&z_capi,&grad_capi,&ncc_capi,&lcc_capi,&nit_capi,&dzmax_capi))
    return NULL;
/*frompyobj*/
  /* Processing variable ncc */
  if (ncc_capi == Py_None) ncc = 0; else
    f2py_success = int_from_pyobj(&ncc,ncc_capi,"_srfpack.zgradg() 1st keyword (ncc) can't be converted to int");
  if (f2py_success) {
  /* Processing variable x */
  ;
  capi_x_intent |= F2PY_INTENT_IN;
  capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi);
  if (capi_x_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 1st argument `x' of _srfpack.zgradg to C/Fortran array" );
  } else {
    x = (float *)(PyArray_DATA(capi_x_tmp));

  /* Processing variable iflgs */
    f2py_success = int_from_pyobj(&iflgs,iflgs_capi,"_srfpack.zgradg() 6th argument (iflgs) can't be converted to int");
  if (f2py_success) {
  /* Processing variable sigma */
  ;
  capi_sigma_intent |= F2PY_INTENT_IN;
  capi_sigma_tmp = array_from_pyobj(NPY_FLOAT,sigma_Dims,sigma_Rank,capi_sigma_intent,sigma_capi);
  if (capi_sigma_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 7th argument `sigma' of _srfpack.zgradg to C/Fortran array" );
  } else {
    sigma = (float *)(PyArray_DATA(capi_sigma_tmp));

  /* Processing variable nit */
  if (nit_capi == Py_None) nit = 3; else
    f2py_success = int_from_pyobj(&nit,nit_capi,"_srfpack.zgradg() 3rd keyword (nit) can't be converted to int");
  if (f2py_success) {
  CHECKSCALAR(nit>0,"nit>0","3rd keyword nit","zgradg:nit=%d",nit) {
  /* Processing variable dzmax */
  if (dzmax_capi == Py_None) dzmax = 0.001; else
    f2py_success = float_from_pyobj(&dzmax,dzmax_capi,"_srfpack.zgradg() 4th keyword (dzmax) can't be converted to float");
  if (f2py_success) {
  /* Processing variable ier */
  /* Processing variable lcc */
  lcc_Dims[0]=ncc + 1;
  capi_lcc_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL;
  capi_lcc_tmp = array_from_pyobj(NPY_INT,lcc_Dims,lcc_Rank,capi_lcc_intent,lcc_capi);
  if (capi_lcc_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd keyword `lcc' of _srfpack.zgradg to C/Fortran array" );
  } else {
    lcc = (int *)(PyArray_DATA(capi_lcc_tmp));

  /* Processing variable n */
  n = len(x);
  /* Processing variable y */
  y_Dims[0]=n;
  capi_y_intent |= F2PY_INTENT_IN;
  capi_y_tmp = array_from_pyobj(NPY_FLOAT,y_Dims,y_Rank,capi_y_intent,y_capi);
  if (capi_y_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd argument `y' of _srfpack.zgradg to C/Fortran array" );
  } else {
    y = (float *)(PyArray_DATA(capi_y_tmp));

  /* Processing variable list */
  list_Dims[0]=6 * n - 12;
  capi_list_intent |= F2PY_INTENT_IN;
  capi_list_tmp = array_from_pyobj(NPY_INT,list_Dims,list_Rank,capi_list_intent,list_capi);
  if (capi_list_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 3rd argument `list' of _srfpack.zgradg to C/Fortran array" );
  } else {
    list = (int *)(PyArray_DATA(capi_list_tmp));

  /* Processing variable lptr */
  lptr_Dims[0]=6 * n - 12;
  capi_lptr_intent |= F2PY_INTENT_IN;
  capi_lptr_tmp = array_from_pyobj(NPY_INT,lptr_Dims,lptr_Rank,capi_lptr_intent,lptr_capi);
  if (capi_lptr_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 4th argument `lptr' of _srfpack.zgradg to C/Fortran array" );
  } else {
    lptr = (int *)(PyArray_DATA(capi_lptr_tmp));

  /* Processing variable lend */
  lend_Dims[0]=n;
  capi_lend_intent |= F2PY_INTENT_IN;
  capi_lend_tmp = array_from_pyobj(NPY_INT,lend_Dims,lend_Rank,capi_lend_intent,lend_capi);
  if (capi_lend_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 5th argument `lend' of _srfpack.zgradg to C/Fortran array" );
  } else {
    lend = (int *)(PyArray_DATA(capi_lend_tmp));

  /* Processing variable z */
  z_Dims[0]=n;
  capi_z_intent |= F2PY_INTENT_INOUT;
  capi_z_tmp = array_from_pyobj(NPY_FLOAT,z_Dims,z_Rank,capi_z_intent,z_capi);
  if (capi_z_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 8th argument `z' of _srfpack.zgradg to C/Fortran array" );
  } else {
    z = (float *)(PyArray_DATA(capi_z_tmp));

  /* Processing variable grad */
  grad_Dims[0]=2,grad_Dims[1]=n;
  capi_grad_intent |= F2PY_INTENT_INOUT;
  capi_grad_tmp = array_from_pyobj(NPY_FLOAT,grad_Dims,grad_Rank,capi_grad_intent,grad_capi);
  if (capi_grad_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 9th argument `grad' of _srfpack.zgradg to C/Fortran array" );
  } else {
    grad = (float *)(PyArray_DATA(capi_grad_tmp));

/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
        (*f2py_func)(&ncc,lcc,&n,x,y,list,lptr,lend,&iflgs,sigma,&nit,&dzmax,z,grad,&ier);
if (PyErr_Occurred())
  f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
    if (f2py_success) {
/*pyobjfrom*/
  f2py_success = try_pyarr_from_int(nit_capi,&nit);
  if (f2py_success) {
  f2py_success = try_pyarr_from_float(dzmax_capi,&dzmax);
  if (f2py_success) {
/*end of pyobjfrom*/
    CFUNCSMESS("Building return value.\n");
    capi_buildvalue = Py_BuildValue("i",ier);
/*closepyobjfrom*/
  } /*if (f2py_success) of dzmax pyobjfrom*/
  } /*if (f2py_success) of nit pyobjfrom*/
/*end of closepyobjfrom*/
    } /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
  if((PyObject *)capi_grad_tmp!=grad_capi) {
    Py_XDECREF(capi_grad_tmp); }
  }  /*if (capi_grad_tmp == NULL) ... else of grad*/
  /* End of cleaning variable grad */
  if((PyObject *)capi_z_tmp!=z_capi) {
    Py_XDECREF(capi_z_tmp); }
  }  /*if (capi_z_tmp == NULL) ... else of z*/
  /* End of cleaning variable z */
  if((PyObject *)capi_lend_tmp!=lend_capi) {
    Py_XDECREF(capi_lend_tmp); }
  }  /*if (capi_lend_tmp == NULL) ... else of lend*/
  /* End of cleaning variable lend */
  if((PyObject *)capi_lptr_tmp!=lptr_capi) {
    Py_XDECREF(capi_lptr_tmp); }
  }  /*if (capi_lptr_tmp == NULL) ... else of lptr*/
  /* End of cleaning variable lptr */
  if((PyObject *)capi_list_tmp!=list_capi) {
    Py_XDECREF(capi_list_tmp); }
  }  /*if (capi_list_tmp == NULL) ... else of list*/
  /* End of cleaning variable list */
  if((PyObject *)capi_y_tmp!=y_capi) {
    Py_XDECREF(capi_y_tmp); }
  }  /*if (capi_y_tmp == NULL) ... else of y*/
  /* End of cleaning variable y */
  /* End of cleaning variable n */
  if((PyObject *)capi_lcc_tmp!=lcc_capi) {
    Py_XDECREF(capi_lcc_tmp); }
  }  /*if (capi_lcc_tmp == NULL) ... else of lcc*/
  /* End of cleaning variable lcc */
  /* End of cleaning variable ier */
  } /*if (f2py_success) of dzmax*/
  /* End of cleaning variable dzmax */
  } /*CHECKSCALAR(nit>0)*/
  } /*if (f2py_success) of nit*/
  /* End of cleaning variable nit */
  if((PyObject *)capi_sigma_tmp!=sigma_capi) {
    Py_XDECREF(capi_sigma_tmp); }
  }  /*if (capi_sigma_tmp == NULL) ... else of sigma*/
  /* End of cleaning variable sigma */
  } /*if (f2py_success) of iflgs*/
  /* End of cleaning variable iflgs */
  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 */
  } /*if (f2py_success) of ncc*/
  /* End of cleaning variable ncc */
/*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 zgradg *******************************/

/*********************************** zgradl ***********************************/
static char doc_f2py_rout__srfpack_zgradl[] = "\
dx,dy,ier = zgradl(k,x,y,list,lptr,lend,ndv,z,npts,ds,[ncc,lcc])\n\nWrapper for ``zgradl``.\
\n\nParameters\n----------\n"
"k : input int\n"
"x : input rank-1 array('f') with bounds (n)\n"
"y : input rank-1 array('f') with bounds (n)\n"
"list : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lptr : input rank-1 array('i') with bounds (6 * n - 12)\n"
"lend : input rank-1 array('i') with bounds (n)\n"
"ndv : in/output rank-0 array(int,'i')\n"
"z : in/output rank-1 array('f') with bounds (n)\n"
"npts : in/output rank-1 array('i') with bounds (len(npts))\n"
"ds : in/output rank-1 array('f') with bounds (len(npts))\n"
"\nOther Parameters\n----------------\n"
"ncc : input int, optional\n    Default: 0\n"
"lcc : input rank-1 array('i') with bounds (ncc + 1)\n"
"\nReturns\n-------\n"
"dx : float\n"
"dy : float\n"
"ier : int";
/* extern void F_FUNC(zgradl,ZGRADL)(int*,int*,int*,int*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,float*,int*); */
static PyObject *f2py_rout__srfpack_zgradl(const PyObject *capi_self,
                           PyObject *capi_args,
                           PyObject *capi_keywds,
                           void (*f2py_func)(int*,int*,int*,int*,float*,float*,int*,int*,int*,int*,float*,int*,float*,float*,float*,int*)) {
  PyObject * volatile capi_buildvalue = NULL;
  volatile int f2py_success = 1;
/*decl*/

  int k = 0;
  PyObject *k_capi = Py_None;
  int ncc = 0;
  PyObject *ncc_capi = Py_None;
  int *lcc = NULL;
  npy_intp lcc_Dims[1] = {-1};
  const int lcc_Rank = 1;
  PyArrayObject *capi_lcc_tmp = NULL;
  int capi_lcc_intent = 0;
  PyObject *lcc_capi = Py_None;
  int n = 0;
  float *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;
  float *y = NULL;
  npy_intp y_Dims[1] = {-1};
  const int y_Rank = 1;
  PyArrayObject *capi_y_tmp = NULL;
  int capi_y_intent = 0;
  PyObject *y_capi = Py_None;
  int *list = NULL;
  npy_intp list_Dims[1] = {-1};
  const int list_Rank = 1;
  PyArrayObject *capi_list_tmp = NULL;
  int capi_list_intent = 0;
  PyObject *list_capi = Py_None;
  int *lptr = NULL;
  npy_intp lptr_Dims[1] = {-1};
  const int lptr_Rank = 1;
  PyArrayObject *capi_lptr_tmp = NULL;
  int capi_lptr_intent = 0;
  PyObject *lptr_capi = Py_None;
  int *lend = NULL;
  npy_intp lend_Dims[1] = {-1};
  const int lend_Rank = 1;
  PyArrayObject *capi_lend_tmp = NULL;
  int capi_lend_intent = 0;
  PyObject *lend_capi = Py_None;
  int ndv = 0;
  PyObject *ndv_capi = Py_None;
  float *z = NULL;
  npy_intp z_Dims[1] = {-1};
  const int z_Rank = 1;
  PyArrayObject *capi_z_tmp = NULL;
  int capi_z_intent = 0;
  PyObject *z_capi = Py_None;
  int *npts = NULL;
  npy_intp npts_Dims[1] = {-1};
  const int npts_Rank = 1;
  PyArrayObject *capi_npts_tmp = NULL;
  int capi_npts_intent = 0;
  PyObject *npts_capi = Py_None;
  float *ds = NULL;
  npy_intp ds_Dims[1] = {-1};
  const int ds_Rank = 1;
  PyArrayObject *capi_ds_tmp = NULL;
  int capi_ds_intent = 0;
  PyObject *ds_capi = Py_None;
  float dx = 0;
  float dy = 0;
  int ier = 0;
  static char *capi_kwlist[] = {"k","x","y","list","lptr","lend","ndv","z","npts","ds","ncc","lcc",NULL};

/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
  if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
    "OOOOOOOOOO|OO:_srfpack.zgradl",\
    capi_kwlist,&k_capi,&x_capi,&y_capi,&list_capi,&lptr_capi,&lend_capi,&ndv_capi,&z_capi,&npts_capi,&ds_capi,&ncc_capi,&lcc_capi))
    return NULL;
/*frompyobj*/
  /* Processing variable k */
    f2py_success = int_from_pyobj(&k,k_capi,"_srfpack.zgradl() 1st argument (k) can't be converted to int");
  if (f2py_success) {
  /* Processing variable ncc */
  if (ncc_capi == Py_None) ncc = 0; else
    f2py_success = int_from_pyobj(&ncc,ncc_capi,"_srfpack.zgradl() 1st keyword (ncc) can't be converted to int");
  if (f2py_success) {
  /* Processing variable x */
  ;
  capi_x_intent |= F2PY_INTENT_IN;
  capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi);
  if (capi_x_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd argument `x' of _srfpack.zgradl to C/Fortran array" );
  } else {
    x = (float *)(PyArray_DATA(capi_x_tmp));

  /* Processing variable ndv */
    f2py_success = int_from_pyobj(&ndv,ndv_capi,"_srfpack.zgradl() 7th argument (ndv) can't be converted to int");
  if (f2py_success) {
  /* Processing variable dx */
  /* Processing variable dy */
  /* Processing variable ier */
  /* Processing variable lcc */
  lcc_Dims[0]=ncc + 1;
  capi_lcc_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL;
  capi_lcc_tmp = array_from_pyobj(NPY_INT,lcc_Dims,lcc_Rank,capi_lcc_intent,lcc_capi);
  if (capi_lcc_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 2nd keyword `lcc' of _srfpack.zgradl to C/Fortran array" );
  } else {
    lcc = (int *)(PyArray_DATA(capi_lcc_tmp));

  /* Processing variable n */
  n = len(x);
  /* Processing variable y */
  y_Dims[0]=n;
  capi_y_intent |= F2PY_INTENT_IN;
  capi_y_tmp = array_from_pyobj(NPY_FLOAT,y_Dims,y_Rank,capi_y_intent,y_capi);
  if (capi_y_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 3rd argument `y' of _srfpack.zgradl to C/Fortran array" );
  } else {
    y = (float *)(PyArray_DATA(capi_y_tmp));

  /* Processing variable list */
  list_Dims[0]=6 * n - 12;
  capi_list_intent |= F2PY_INTENT_IN;
  capi_list_tmp = array_from_pyobj(NPY_INT,list_Dims,list_Rank,capi_list_intent,list_capi);
  if (capi_list_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 4th argument `list' of _srfpack.zgradl to C/Fortran array" );
  } else {
    list = (int *)(PyArray_DATA(capi_list_tmp));

  /* Processing variable lptr */
  lptr_Dims[0]=6 * n - 12;
  capi_lptr_intent |= F2PY_INTENT_IN;
  capi_lptr_tmp = array_from_pyobj(NPY_INT,lptr_Dims,lptr_Rank,capi_lptr_intent,lptr_capi);
  if (capi_lptr_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 5th argument `lptr' of _srfpack.zgradl to C/Fortran array" );
  } else {
    lptr = (int *)(PyArray_DATA(capi_lptr_tmp));

  /* Processing variable lend */
  lend_Dims[0]=n;
  capi_lend_intent |= F2PY_INTENT_IN;
  capi_lend_tmp = array_from_pyobj(NPY_INT,lend_Dims,lend_Rank,capi_lend_intent,lend_capi);
  if (capi_lend_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 6th argument `lend' of _srfpack.zgradl to C/Fortran array" );
  } else {
    lend = (int *)(PyArray_DATA(capi_lend_tmp));

  /* Processing variable z */
  z_Dims[0]=n;
  capi_z_intent |= F2PY_INTENT_INOUT;
  capi_z_tmp = array_from_pyobj(NPY_FLOAT,z_Dims,z_Rank,capi_z_intent,z_capi);
  if (capi_z_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 8th argument `z' of _srfpack.zgradl to C/Fortran array" );
  } else {
    z = (float *)(PyArray_DATA(capi_z_tmp));

  /* Processing variable npts */
  npts_Dims[0]=len(npts);
  capi_npts_intent |= F2PY_INTENT_INOUT;
  capi_npts_tmp = array_from_pyobj(NPY_INT,npts_Dims,npts_Rank,capi_npts_intent,npts_capi);
  if (capi_npts_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 9th argument `npts' of _srfpack.zgradl to C/Fortran array" );
  } else {
    npts = (int *)(PyArray_DATA(capi_npts_tmp));

  /* Processing variable ds */
  ds_Dims[0]=len(npts);
  capi_ds_intent |= F2PY_INTENT_INOUT;
  capi_ds_tmp = array_from_pyobj(NPY_FLOAT,ds_Dims,ds_Rank,capi_ds_intent,ds_capi);
  if (capi_ds_tmp == NULL) {
    if (!PyErr_Occurred())
      PyErr_SetString(_srfpack_error,"failed in converting 10th argument `ds' of _srfpack.zgradl to C/Fortran array" );
  } else {
    ds = (float *)(PyArray_DATA(capi_ds_tmp));

/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
        (*f2py_func)(&k,&ncc,lcc,&n,x,y,list,lptr,lend,&ndv,z,npts,ds,&dx,&dy,&ier);
if (PyErr_Occurred())
  f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
    if (f2py_success) {
/*pyobjfrom*/
  f2py_success = try_pyarr_from_int(ndv_capi,&ndv);
  if (f2py_success) {
/*end of pyobjfrom*/
    CFUNCSMESS("Building return value.\n");
    capi_buildvalue = Py_BuildValue("ffi",dx,dy,ier);
/*closepyobjfrom*/
  } /*if (f2py_success) of ndv pyobjfrom*/
/*end of closepyobjfrom*/
    } /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
  if((PyObject *)capi_ds_tmp!=ds_capi) {
    Py_XDECREF(capi_ds_tmp); }
  }  /*if (capi_ds_tmp == NULL) ... else of ds*/
  /* End of cleaning variable ds */
  if((PyObject *)capi_npts_tmp!=npts_capi) {
    Py_XDECREF(capi_npts_tmp); }
  }  /*if (capi_npts_tmp == NULL) ... else of npts*/
  /* End of cleaning variable npts */
  if((PyObject *)capi_z_tmp!=z_capi) {
    Py_XDECREF(capi_z_tmp); }
  }  /*if (capi_z_tmp == NULL) ... else of z*/
  /* End of cleaning variable z */
  if((PyObject *)capi_lend_tmp!=lend_capi) {
    Py_XDECREF(capi_lend_tmp); }
  }  /*if (capi_lend_tmp == NULL) ... else of lend*/
  /* End of cleaning variable lend */
  if((PyObject *)capi_lptr_tmp!=lptr_capi) {
    Py_XDECREF(capi_lptr_tmp); }
  }  /*if (capi_lptr_tmp == NULL) ... else of lptr*/
  /* End of cleaning variable lptr */
  if((PyObject *)capi_list_tmp!=list_capi) {
    Py_XDECREF(capi_list_tmp); }
  }  /*if (capi_list_tmp == NULL) ... else of list*/
  /* End of cleaning variable list */
  if((PyObject *)capi_y_tmp!=y_capi) {
    Py_XDECREF(capi_y_tmp); }
  }  /*if (capi_y_tmp == NULL) ... else of y*/
  /* End of cleaning variable y */
  /* End of cleaning variable n */
  if((PyObject *)capi_lcc_tmp!=lcc_capi) {
    Py_XDECREF(capi_lcc_tmp); }
  }  /*if (capi_lcc_tmp == NULL) ... else of lcc*/
  /* End of cleaning variable lcc */
  /* End of cleaning variable ier */
  /* End of cleaning variable dy */
  /* End of cleaning variable dx */
  } /*if (f2py_success) of ndv*/
  /* End of cleaning variable ndv */
  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 */
  } /*if (f2py_success) of ncc*/
  /* End of cleaning variable ncc */
  } /*if (f2py_success) of k*/
  /* End of cleaning variable k */
/*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 zgradl *******************************/
/*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[] = {
  {"gradg",-1,{{-1}},0,(char *)F_FUNC(gradg,GRADG),(f2py_init_func)f2py_rout__srfpack_gradg,doc_f2py_rout__srfpack_gradg},
  {"gradl",-1,{{-1}},0,(char *)F_FUNC(gradl,GRADL),(f2py_init_func)f2py_rout__srfpack_gradl,doc_f2py_rout__srfpack_gradl},
  {"intrc0",-1,{{-1}},0,(char *)F_FUNC(intrc0,INTRC0),(f2py_init_func)f2py_rout__srfpack_intrc0,doc_f2py_rout__srfpack_intrc0},
  {"intrc1",-1,{{-1}},0,(char *)F_FUNC(intrc1,INTRC1),(f2py_init_func)f2py_rout__srfpack_intrc1,doc_f2py_rout__srfpack_intrc1},
  {"smsurf",-1,{{-1}},0,(char *)F_FUNC(smsurf,SMSURF),(f2py_init_func)f2py_rout__srfpack_smsurf,doc_f2py_rout__srfpack_smsurf},
  {"zgradg",-1,{{-1}},0,(char *)F_FUNC(zgradg,ZGRADG),(f2py_init_func)f2py_rout__srfpack_zgradg,doc_f2py_rout__srfpack_zgradg},
  {"zgradl",-1,{{-1}},0,(char *)F_FUNC(zgradl,ZGRADL),(f2py_init_func)f2py_rout__srfpack_zgradl,doc_f2py_rout__srfpack_zgradl},

/*eof routine_defs*/
  {NULL}
};

static PyMethodDef f2py_module_methods[] = {

  {NULL,NULL}
};

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

#if PY_VERSION_HEX >= 0x03000000
#define RETVAL m
PyMODINIT_FUNC PyInit__srfpack(void) {
#else
#define RETVAL
PyMODINIT_FUNC init_srfpack(void) {
#endif
  int i;
  PyObject *m,*d, *s;
#if PY_VERSION_HEX >= 0x03000000
  m = _srfpack_module = PyModule_Create(&moduledef);
#else
  m = _srfpack_module = Py_InitModule("_srfpack", f2py_module_methods);
#endif
  Py_TYPE(&PyFortran_Type) = &PyType_Type;
  import_array();
  if (PyErr_Occurred())
    {PyErr_SetString(PyExc_ImportError, "can't initialize module _srfpack (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 '_srfpack' is auto-generated with f2py (version:2).\nFunctions:\n"
"  ier = gradg(x,y,z,list,lptr,lend,iflgs,sigma,grad,ncc=0,lcc=,nit=3,dgmax=0.001)\n"
"  dx,dy,ier = gradl(k,x,y,z,list,lptr,lend,ncc=0,lcc=)\n"
"  pz,ier = intrc0(px,py,x,y,z,list,lptr,lend,ist,ncc=0,lcc=)\n"
"  pz,pzx,pzy,ier = intrc1(px,py,x,y,z,list,lptr,lend,iflgs,sigma,grad,dflag,ist,ncc=0,lcc=)\n"
"  f,fxfy,ier = smsurf(x,y,z,list,lptr,lend,iflgs,sigma,w,sm,smtol,gstol,ncc=0,lcc=)\n"
"  ier = zgradg(x,y,list,lptr,lend,iflgs,sigma,z,grad,ncc=0,lcc=,nit=3,dzmax=0.001)\n"
"  dx,dy,ier = zgradl(k,x,y,list,lptr,lend,ndv,z,npts,ds,ncc=0,lcc=)\n"
".");
  PyDict_SetItemString(d, "__doc__", s);
  _srfpack_error = PyErr_NewException ("_srfpack.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*)"_srfpack");
#endif

  return RETVAL;
}
#ifdef __cplusplus
}
#endif
