U C^2@sTdZddlmZmZmZdddZddlmZejaddl Z ddl Z ddl Z dd l m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZIdd lmJZJdd lmKZKdd lmLZLdd lmMZMddlmNZNddlmOZOiaPiZQdD]ZRdeQeR<qeSe jTUde ZVde We XeVdeddeddeddeddeddedd ed!d"ed#d$ed%d&ed'd(ed)d*ed+d,ed-d.ed/d0ed1d2d3d.d.d4d5d6d7gd8d9gd:ZYd;dd?d@dAdBdBedCeEedBidD gZZeQdEdFdGdHdIdJdKdLdMdNgedOidPdQgdRgdS Z[ddddddTdddddUddddddVdBdBdBdBdBdBdWdXdBdBdBdBdYdZd[d\d]d^d_d`dBdBdBdadbgdcddgdedfdgdhdidBdBdBdBdBdBdBdBdBdBdBdBdBedjeEedBidk/dldmdBeEe2dndodpdBe2dndqeDeEeFe2e$eEedreDeEe2e$eEedse2dBedBieEeFe2e$edteDeEe2e$eEedueDeEe2edvieDeEeFe2e$eEedwiedxgiedyiedeBde=de@de?deCdeAde6di Z]deQidedigde]dŜdediedieDe5eEedɜddddeDe5eEee*d͜dediedМddgdge7dԜdddgdediedMigedԜdeDeeEeideDeeEee)ide"dBdڜde?dBdڜdeCdBdڜdeAdBdڜdedBdڜedide8dݜgZ^deQidedigddBe]dߜeDe3e)dieDe4e)die*dieDe3e)dedjigieDe4e)dedjigie*deDee'djeDee)digidBdddeDe)eEe3ddddeDe)e3ddde*de)die)die)didde)diddddeEe%dige)die4die3die)die4die3diddeEe%diddgedeEe%die%didedeEe%digidgdddgedBdded ie$deEe$d ie*dieDe5eEed edieDe5eEed de4die3die4die3die(d ie(die(dieDe5eEee)d edddBieDe3eEedddBieEe,die,digdeEe,dieDe5eEee)dBdedie]eDe5eEee'dBded ieDe5eEedBdde$deEe$d iedie*diedde4die3die4die3die(die(die(dieDee)d ed ieDe3eEedidgd!dgeDee)dBde*dieDee'd"edieDee'dBde*d#idged$ediedBddddgdd%ed&ie*didge7d'd(d)dddge7dBde4die3die4die3die(d*ie(die(dieDe7e)d+deDe7e'ied&ie7dBddddאd,d-gde*d.ided/d0d1d2d3d4d5d6eDee+d7d8eDee+dBdd9d1d2d3d:d5d;eDee&d7d8eDee&dBdediedMigedBdڜde4die3die4die3dieDee)d<d=d>e'd?ie)d@idAee)dBie'dCiedDidEgigdFeEeFe*e'dGieDe'eEe*dHiedIigedBdJdeDeeEeideDeeEee)ide"dBdڜde?dBdڜdeCdBdڜdeAdBdڜdedBdڜedide8dݜg*Z_edKidӐdLdMdNdOeDe5eEedBdPdQdRdSe7dBdPdTdUdVedBdWdXdYdZd[gZ`d\d]Zad^d_d`dadadadadadadadb ZbdcddZcdS(eaG Rules for building C/API module with f2py2e. Here is a skeleton of a new wrapper function (13Dec2001): wrapper_function(args) declarations get_python_arguments, say, `a' and `b' get_a_from_python if (successful) { get_b_from_python if (successful) { callfortran if (successful) { put_a_to_python if (successful) { put_b_to_python if (successful) { buildvalue = ... } } } } cleanup_b } cleanup_a return buildvalue Copyright 1999,2000 Pearu Peterson all rights reserved, Pearu Peterson Permission to use, modify, and distribute this software is given under the terms of the NumPy License. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. $Date: 2005/08/30 08:58:42 $ Pearu Peterson )divisionabsolute_importprint_functionz$Revision: 1.129 $ ) __version__N)= applyrules debugcapi dictappenderrmessgentitlegetargs2hascallstatement hasexternals hasinitvaluehasnote hasresultnoteisarrayisarrayofstrings iscomplexiscomplexarrayiscomplexfunctioniscomplexfunction_warnisdummyroutine isexternal isfunctionisfunction_wrap isint1array isintent_aux isintent_cisintent_callback isintent_copy isintent_hideisintent_inoutisintent_nothide isintent_outisintent_overwrite islogicalislong_complex islong_doubleislong_doublefunction islong_longislong_longfunctionismoduleroutine isoptional isrequiredisscalarissigned_long_longarrayisstring isstringarrayisstringfunction issubroutineissubroutine_wrap isthreadsafe isunsignedisunsigned_charisunsigned_chararrayisunsigned_long_longisunsigned_long_longarrayisunsigned_shortisunsigned_shortarrayl_andl_notl_oroutmessreplace stripcomma) capi_maps)cfuncs) common_rules) use_rules) f90mod_rules) func2subr)decl frompyobjcleanupfrompyobjtopyarrmethod pyobjfromclosepyobjfromfreemem userincludes includes0includestypedefstypedefs_generated cppmacrosrG callbackslatexdocrestdoc routine_defsexternroutinesinitf2pywraphooks commonhooksinitcommonhooks f90modhooksinitf90modhooks SOURCE_DATE_EPOCHz/* File: #modulename#module.c * This file is auto-generated with f2py (version:#f2py_version#). * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition, * written by Pearu Peterson . * Generation date: zv * Do not edit this file directly unless you know what you are doing!!! */ #ifdef __cplusplus extern "C" { #endif zSee f2py2e/cfuncs.py: includesz #includes# #includes0# z,See f2py2e/rules.py: mod_rules['modulebody']zM static PyObject *#modulename#_error; static PyObject *#modulename#_module; zSee f2py2e/cfuncs.py: typedefsz #typedefs# z(See f2py2e/cfuncs.py: typedefs_generatedz #typedefs_generated# zSee f2py2e/cfuncs.py: cppmacrosz #cppmacros# zSee f2py2e/cfuncs.py: cfuncsz #cfuncs# z"See f2py2e/cfuncs.py: userincludesz #userincludes# z"See f2py2e/capi_rules.py: usercodez9 #usercode# /* See f2py2e/rules.py */ #externroutines# z#See f2py2e/capi_rules.py: usercode1z #usercode1# z%See f2py2e/cb_rules.py: buildcallbackz #callbacks# zSee f2py2e/rules.py: buildapiz #body# z&See f2py2e/f90mod_rules.py: buildhooksz #f90modhooks# z/See f2py2e/rules.py: module_rules['modulebody'] z&See f2py2e/common_rules.py: buildhooksz #commonhooks# zSee f2py2e/rules.pya static FortranDataDef f2py_routine_defs[] = { #routine_defs# {NULL} }; static PyMethodDef f2py_module_methods[] = { #pymethoddef# {NULL,NULL} }; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "#modulename#", NULL, -1, f2py_module_methods, NULL, NULL, NULL, NULL }; #endif #if PY_VERSION_HEX >= 0x03000000 #define RETVAL m PyMODINIT_FUNC PyInit_#modulename#(void) { #else #define RETVAL PyMODINIT_FUNC init#modulename#(void) { #endif int i; PyObject *m,*d, *s, *tmp; #if PY_VERSION_HEX >= 0x03000000 m = #modulename#_module = PyModule_Create(&moduledef); #else m = #modulename#_module = Py_InitModule("#modulename#", f2py_module_methods); #endif Py_TYPE(&PyFortran_Type) = &PyType_Type; import_array(); if (PyErr_Occurred()) {PyErr_SetString(PyExc_ImportError, "can't initialize module #modulename# (failed to import numpy)"); return RETVAL;} d = PyModule_GetDict(m); s = PyString_FromString("$RaHevision: $"); PyDict_SetItemString(d, "__version__", s); Py_DECREF(s); #if PY_VERSION_HEX >= 0x03000000 s = PyUnicode_FromString( #else s = PyString_FromString( #endif "This module '#modulename#' is auto-generated with f2py (version:#f2py_version#).\nFunctions:\n" #docs#"."); PyDict_SetItemString(d, "__doc__", s); Py_DECREF(s); #modulename#_error = PyErr_NewException ("#modulename#.error", NULL, NULL); /* * Store the error object inside the dict, so that it could get deallocated. * (in practice, this is a module, so it likely will not and cannot.) */ PyDict_SetItemString(d, "_#modulename#_error", #modulename#_error); Py_DECREF(#modulename#_error); for(i=0;f2py_routine_defs[i].name!=NULL;i++) { tmp = PyFortranObject_NewAsAttr(&f2py_routine_defs[i]); PyDict_SetItemString(d, f2py_routine_defs[i].name, tmp); Py_DECREF(tmp); } #initf2pywraphooks# #initf90modhooks# #initcommonhooks# #interface_usercode# #ifdef F2PY_REPORT_ATEXIT if (! PyErr_Occurred()) on_exit(f2py_report_on_exit,(void*)"#modulename#"); #endif return RETVAL; } #ifdef __cplusplus } #endif )r[r\z*\section{Module \texttt{#texmodulename#}} z #modnote# z #latexdoc#zdModule #modulename# ================================================================================z #restdoc#) modulebody separatorsforr[r\z /*eof body*/z/*eof method*/z/*eof externroutines*/z/*eof routine_defs*/z/*eof initf90modhooks*/z/*eof initf2pywraphooks*/z/*eof initcommonhooks*/z#note#) bodyrPr^r]rcr_rar[r\Zmodnotea #begintitle# static char doc_#apiname#[] = "\ #docreturn##name#(#docsignatureshort#)\n\nWrapper for ``#name#``.\ \n#docstrsigns#"; /* #declfortranroutine# */ static PyObject *#apiname#(const PyObject *capi_self, PyObject *capi_args, PyObject *capi_keywds, #functype# (*f2py_func)(#callprotoargument#)) { PyObject * volatile capi_buildvalue = NULL; volatile int f2py_success = 1; #decl# static char *capi_kwlist[] = {#kwlist##kwlistopt##kwlistxa#NULL}; #usercode# #routdebugenter# #ifdef F2PY_REPORT_ATEXIT f2py_start_clock(); #endif if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ "#argformat##keyformat##xaformat#:#pyname#",\ capi_kwlist#args_capi##keys_capi##keys_xa#)) return NULL; #frompyobj# /*end of frompyobj*/ #ifdef F2PY_REPORT_ATEXIT f2py_start_call_clock(); #endif #callfortranroutine# 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("#returnformat#"#return#); /*closepyobjfrom*/ #closepyobjfrom# } /*if (f2py_success) after callfortranroutine*/ /*cleanupfrompyobj*/ #cleanupfrompyobj# if (capi_buildvalue == NULL) { #routdebugfailure# } else { #routdebugleave# } CFUNCSMESS("Freeing memory.\n"); #freemem# #ifdef F2PY_REPORT_ATEXIT f2py_stop_clock(); #endif return capi_buildvalue; } #endtitle# z #routine_def#z#initf2pywraphook#z#declfortranroutine#z!#docreturn##name#(#docsignature#)z&#docreturn##name#(#docsignatureshort#)z'" #docreturn##name#(#docsignature#)\n" z arrayobject.hZ CFUNCSMESSZMINMAXz#define DEBUGCFUNCSz1\subsection{Wrapper function \texttt{#texname#}} zk \noindent{{}\verb@#docreturn##name#@{}}\texttt{(#latexdocsignatureshort#)} #routnote# #latexdocstrsigns# zlWrapped function ``#name#`` --------------------------------------------------------------------------------) rhrjr]r_r^docdocshortZdocsneedrYr[r\z || z\n" ")callfortranroutineroutdebugenterrLroutdebugleaveroutdebugfailure setjmpbuf docstrreq docstropt docstrout docstrcbs docstrsignslatexdocstrsignslatexdocstrreqlatexdocstroptlatexdocstroutlatexdocstrcbsz/*decl*/z /*freemem*/z\nParameters\n----------z$\nOther Parameters\n----------------z\nReturns\n-------z'\nNotes\n-----\nCall-back functions::\nz\noindent Required arguments:z\noindent Optional arguments:z\noindent Return objects:z\noindent Call-back functions:z /*frompyobj*/z/*end of cleanupfrompyobj*/z /*pyobjfrom*/z/*end of closepyobjfrom*/z /*topyarr*/z/*routdebugleave*/z/*routdebugenter*/z/*routdebugfailure*/z/*callfortranroutine*/z --- #note#)/rhkwlist kwlistopt callfortrancallfortranappenddocsign docsignoptrLrSZ docsignshortdocsignoptshortrwrxrsrtrurvryrzr{r| args_capi keys_capifunctyperMrNrQrRrOrprorqrn argformat keyformatZ need_cfuncs docreturnreturn returnformatZrformatkwlistxakeys_xaxaformat docsignxadocsignxashortinitf2pywraphookZroutnotezf2py_rout_#modulename#_#name#z#modulename#.#name#)ZapinameZpynamerL_checkz-f2py_rout_#modulename#_#f90modulename#_#name#z##modulename#.#f90modulename#.#name#voidzGextern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);z/extern void #fortranname#(#callprotoargument#);zn {"#name#",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},zV {"#name#",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},zE {"#name#",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},ZF_FUNCzR fprintf(stderr,"debug-capi:Fortran subroutine `#fortranname#(#callfortran#)'\n");z4 if (#setjmpbuf#) { f2py_success = 0; } else {z Py_BEGIN_ALLOW_THREADSz9 #callstatement#; /*(*f2py_func)(#callfortran#);*/z (*f2py_func)(#callfortran#);z Py_END_ALLOW_THREADSz })rdeclfortranroutine routine_defrmrnrzFextern void #F_WRAPPEDFUNC#(#name_lower#,#NAME#)(#callprotoargument#);zm {"#name#",-1,{{-1}},0,(char *)#F_WRAPPEDFUNC#(#name_lower#,#NAME#),(f2py_init_func)#apiname#,doc_#apiname#},a { extern #ctype# #F_FUNC#(#name_lower#,#NAME#)(void); PyObject* o = PyDict_GetItemString(d,"#name#"); tmp = F2PyCapsule_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL); PyObject_SetAttrString(o,"_cpointer", tmp); Py_DECREF(tmp); #if PY_VERSION_HEX >= 0x03000000 s = PyUnicode_FromString("#name#"); #else s = PyString_FromString("#name#"); #endif PyObject_SetAttrString(o,"__name__", s); Py_DECREF(s); } Z F_WRAPPEDFUNCzY fprintf(stderr,"debug-capi:Fortran subroutine `f2pywrap#name_lower#(#callfortran#)'\n");z1 if (#setjmpbuf#) { f2py_success = 0; } else {z Py_BEGIN_ALLOW_THREADSz (*f2py_func)(#callfortran#);z3 #callstatement#; /*(*f2py_func)(#callfortran#);*/z Py_END_ALLOW_THREADSz })rrrrrmrnra { extern void #F_FUNC#(#name_lower#,#NAME#)(void); PyObject* o = PyDict_GetItemString(d,"#name#"); tmp = F2PyCapsule_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL); PyObject_SetAttrString(o,"_cpointer", tmp); Py_DECREF(tmp); #if PY_VERSION_HEX >= 0x03000000 s = PyUnicode_FromString("#name#"); #else s = PyString_FromString("#name#"); #endif PyObject_SetAttrString(o,"__name__", s); Py_DECREF(s); } z#ctype#z#rname#,z#pydocsignout#z"\item[]{{}\verb@#pydocsignout#@{}}z--- #resultnote#z#ifdef USESCOMPAQFORTRAN fprintf(stderr,"debug-capi:Fortran function #ctype# #fortranname#(#callcompaqfortran#)\n"); #else fprintf(stderr,"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\n"); #endif zW fprintf(stderr,"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\n"); )rrrur{rnrzJextern #ctype# #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);z2extern #ctype# #fortranname#(#callprotoargument#);z# #ctype# #name#_return_value={0,0};z #ctype# #name#_return_value=0;z. PyObject *#name#_return_value_capi = Py_None;zJ #callstatement#; /* #name#_return_value = (*f2py_func)(#callfortran#);*/ z3 #name#_return_value = (*f2py_func)(#callfortran#);zV fprintf(stderr,"#routdebugshowvalue#\n",#name#_return_value.r,#name#_return_value.i);z> fprintf(stderr,"#routdebugshowvalue#\n",#name#_return_value);zE #name#_return_value_capi = pyobj_from_#ctype#1(#name#_return_value);zpyobj_from_#ctype#1Z long_longZ long_doublez #rformat#z,#name#_return_value_capiz,#name#_return_value) rrrLrnrQrmrrrz$ #ctype# #name#_return_value = NULL;z! int #name#_return_value_len = 0;z,#name#_return_value,#name#_return_value_len,z% #name#_return_value_len = #rlength#;z` if ((#name#_return_value = (string)malloc(sizeof(char)*(#name#_return_value_len+1))) == NULL) {z6 PyErr_SetString(PyExc_MemoryError, "out of memory");z f2py_success = 0;z } else {z8 (#name#_return_value)[#name#_return_value_len] = '\0';z if (f2py_success) {z Py_BEGIN_ALLOW_THREADSzj#ifdef USESCOMPAQFORTRAN (*f2py_func)(#callcompaqfortran#); #else (*f2py_func)(#callfortran#); #endif z Py_END_ALLOW_THREADSzW fprintf(stderr,"#routdebugshowvalue#\n",#name#_return_value_len,#name#_return_value);z/ } /* if (f2py_success) after (string)malloc */z! STRINGFREE(#name#_return_value);Z STRINGFREE) rrrLrrnrrrSrmrzZ fprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#(#docsignature#)\n");zW fprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#: successful.\n");zT fprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#: failure.\n");)rorprqrZcomplex_long_doubleZ unsigned_charZunsigned_shortZunsignedZunsigned_long_longrhz. /* Processing auxiliary variable #varname# */z$ fprintf(stderr,"#vardebuginfo#\n");z) /* End of cleaning variable #varname# */)rMrNrmz #ctype# #varname# = 0;zmath.hz #varname# = #init#;)rLrmrMrz ,#varname#z #outvarname#,z #varrformat#)rrurrrz #ctype# #varname#;z0 #varname#.r = #init.r#, #varname#.i = #init.i#;)rLrMrz #ctype# #varname# = NULL;z int slen(#varname#);zlen..)rLrmrz #ctype# *#varname# = NULL;z1 npy_intp #varname#_Dims[#rank#] = {#rank*[-1]#};z# const int #varname#_Rank = #rank#;Zforcombr)rmr_dependzflen(#varname#),string)rrmrz$ /* Processing variable #varname# */)rMrNrrmz #pydocsign#z\item[]{{}\verb@#pydocsign#@{}}z--- See above.)rtrsrurzryr{Zdependz "#varname#",z #varname#,)r}rrz#varname#=#showinit#,)r~rrr)rrrz#varname#_extra_args=(),z#varname#_extra_args,z=#varname#_extra_args : input tuple, optional\n Default: ()z #cbdocstr#z\item[] #cblatexdocstr#z}\item[]{{}\verb@#varname#_extra_args := () input tuple@{}} --- Extra arguments for call-back function {{}\verb@#varname#@{}}.z$ PyObject *#varname#_capi = Py_None;z) PyTupleObject *#varname#_xa_capi = NULL;z+ PyTupleObject *#varname#_args_capi = NULL;z int #varname#_nofargs_capi = 0;z! #cbname#_typedef #varname#_cptr;z"#varname#_extra_args",OzO!z,&#varname#_capiz!,&PyTuple_Type,&#varname#_xa_capiz(setjmp(#cbname#_jmpbuf))z#varname#_cptr,z#cbname#zsetjmp.h)rrrtrvr|rzrLrrrrrrrrrrrmrzif(F2PyCapsule_Check(#varname#_capi)) { #varname#_cptr = F2PyCapsule_AsVoidPtr(#varname#_capi); } else { #varname#_cptr = #cbname#; } aif (#varname#_capi==Py_None) { #varname#_capi = PyObject_GetAttrString(#modulename#_module,"#varname#"); if (#varname#_capi) { if (#varname#_xa_capi==NULL) { if (PyObject_HasAttrString(#modulename#_module,"#varname#_extra_args")) { PyObject* capi_tmp = PyObject_GetAttrString(#modulename#_module,"#varname#_extra_args"); if (capi_tmp) { #varname#_xa_capi = (PyTupleObject *)PySequence_Tuple(capi_tmp); Py_DECREF(capi_tmp); } else { #varname#_xa_capi = (PyTupleObject *)Py_BuildValue("()"); } if (#varname#_xa_capi==NULL) { PyErr_SetString(#modulename#_error,"Failed to convert #modulename#.#varname#_extra_args to tuple.\n"); return NULL; } } } } if (#varname#_capi==NULL) { PyErr_SetString(#modulename#_error,"Callback #varname# not defined (as an argument or module #modulename# attribute).\n"); return NULL; } } a #varname#_nofargs_capi = #cbname#_nofargs; if (create_cb_arglist(#varname#_capi,#varname#_xa_capi,#maxnofargs#,#nofoptargs#,&#cbname#_nofargs,&#varname#_args_capi,"failed in processing argument list for call-back #varname#.")) { jmp_buf #varname#_jmpbuf;z fprintf(stderr,"debug-capi:Assuming %d arguments; at most #maxnofargs#(-#nofoptargs#) is expected.\n",#cbname#_nofargs); CFUNCSMESSPY("for #varname#=",#cbname#_capi);zE fprintf(stderr,"#vardebugshowvalue# (call-back in C).\n",#cbname#);z CFUNCSMESS("Saving jmpbuf for `#varname#`.\n"); SWAP(#varname#_capi,#cbname#_capi,PyObject); SWAP(#varname#_args_capi,#cbname#_args_capi,PyTupleObject); memcpy(&#varname#_jmpbuf,&#cbname#_jmpbuf,sizeof(jmp_buf));a CFUNCSMESS("Restoring jmpbuf for `#varname#`.\n"); #cbname#_capi = #varname#_capi; Py_DECREF(#cbname#_args_capi); #cbname#_args_capi = #varname#_args_capi; #cbname#_nofargs = #varname#_nofargs_capi; memcpy(&#cbname#_jmpbuf,&#varname#_jmpbuf,sizeof(jmp_buf)); }ZSWAPZcreate_cb_arglist)rMrNrmrrz3 fprintf(stderr,"#vardebugshowvalue#\n",#varname#);z &#varname#,)rLrQrrr)rmrzW f2py_success = try_pyarr_from_#ctype#(#varname#_capi,&#varname#); if (f2py_success) {z/ } /*if (f2py_success) of #varname# pyobjfrom*/ztry_pyarr_from_#ctype#) rLrrrrrQrRrmrz8 if (#varname#_capi == Py_None) #varname# = #init#; elserz if (#varname#_capi != Py_None)z f2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,"#pyname#() #nth# (#varname#) can't be converted to #ctype#"); if (f2py_success) {z` #varname# = (#ctype#)PyObject_IsTrue(#varname#_capi); f2py_success = 1; if (f2py_success) {z% } /*if (f2py_success) of #varname#*/z#ctype#_from_pyobj)rMrmrr)rMrrzA fprintf(stderr,"#vardebugshowvalue#\n",#varname#.r,#varname#.i);z,#varname#_capi)rLrrQrrzY f2py_success = try_pyarr_from_#ctype#(#varname#_capi,&#varname#); if (f2py_success) {z0 } /*if (f2py_success) of #varname# pyobjfrom*/) rLrrrrrmrQrRrzT if (#varname#_capi==Py_None) {#varname#.r = #init.r#, #varname#.i = #init.i#;} elsez0 } /*if (f2py_success) of #varname# frompyobj*/)rLrz1 #varname#_capi = pyobj_from_#ctype#1(#varname#);)rQrmrzslen(#varname#),zC fprintf(stderr,"#vardebugshowvalue#\n",slen(#varname#),#varname#);)rLrrrQrrmrz slen(#varname#) = #length#; f2py_success = #ctype#_from_pyobj(&#varname#,&slen(#varname#),#init#,#varname#_capi,"#ctype#_from_pyobj failed in converting #nth# `#varname#' of #pyname# to C #ctype#"); if (f2py_success) {z? STRINGFREE(#varname#); } /*if (f2py_success) of #varname#*/zV f2py_success = try_pyarr_from_#ctype#(#varname#_capi,#varname#); if (f2py_success) {)rrrrrQrRrmrz* PyArrayObject *capi_#varname#_tmp = NULL;z int capi_#varname#_intent = 0;z,capi_#varname#_tmp)rLrrrmrz" int capi_overwrite_#varname# = 1;z"overwrite_#varname#",iz,&capi_overwrite_#varname#zoverwrite_#varname#=1,zoverwrite_#varname#,z9overwrite_#varname# : input int, optional\n Default: 1)rLrrrrrrtrzH capi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);z" int capi_overwrite_#varname# = 0;zoverwrite_#varname#=0,z9overwrite_#varname# : input int, optional\n Default: 0)rLrrrrrz #setdims#;z# capi_#varname#_intent |= #intent#;zl capi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,Py_None);zs capi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,#varname#_capi);z if (capi_#varname#_tmp == NULL) { if (!PyErr_Occurred()) PyErr_SetString(#modulename#_error,"failed in converting #nth# `#varname#' of #pyname# to C/Fortran array" ); } else { #varname# = (#ctype# *)(PyArray_DATA(capi_#varname#_tmp)); z! if (#varname#_capi == Py_None) {z {z #ctype# capi_c;a int *_i,capi_i=0; CFUNCSMESS("#name#: Initializing #varname#=#init#\n"); if (initforcomb(PyArray_DIMS(capi_#varname#_tmp),PyArray_NDIM(capi_#varname#_tmp),1)) { while ((_i = nextforcomb())) #varname#[capi_i++] = #init#; /* fortran way */ } else { if (!PyErr_Occurred()) PyErr_SetString(#modulename#_error,"Initialization of #nth# #varname# failed (initforcomb)."); f2py_success = 0; } } if (f2py_success) {z= } /*if (capi_#varname#_tmp == NULL) ... else of #varname#*/zY if((PyObject *)capi_#varname#_tmp!=#varname#_capi) { Py_XDECREF(capi_#varname#_tmp); }z! Py_XDECREF(capi_#varname#_tmp);z+ } /*if (f2py_success) of #varname# init*/)rMrNrrz3 fprintf(stderr,"debug-capi:Checking `#check#'\n");)rMrmzN CHECKSCALAR(#check#,"#check#","#nth# #varname#","#varshowvalue#",#varname#) {z } /*CHECKSCALAR(#check#)*/Z CHECKSCALAR)rMrNrmr_breakzN CHECKSTRING(#check#,"#check#","#nth# #varname#","#varshowvalue#",#varname#) {z } /*CHECKSTRING(#check#)*/Z CHECKSTRINGZ CHECKARRAYz2 CHECKARRAY(#check#,"#check#","#nth# #varname#") {z } /*CHECKARRAY(#check#)*/)rmrMrNrrZ CHECKGENERICz4 CHECKGENERIC(#check#,"#check#","#nth# #varname#") {z } /*CHECKGENERIC(#check#)*/)rmrMrNc Cs8td|di}tdd}t|}tdti|}g}g}|dD]}d} |dD]<} | ddksrtd qX| dD]} | d|krz| } qXqzqX| std |qH| g} d | kr| d D]2\} }t | }|d =| |d<||d <| |q| D]J} t | \}}|r0t | r&| |n | |t ||}t||}qqHt|\}}|rf| |t ||}t||}t|\}}|r| |t ||}t||}|D](}t||d |d}t||}qt}i}|D]6}g||<||D]} d}| tjkr&tj| }n| tjkr>tj| }n| tjkrVtj| }n| tjkrntj| }n| tjkrtj| }n| tjkrtj| }nt| tjkrtj| }n\| tjkrtj| }nD| tjkrtj| }n,| tjkrtj| }ntdt| q|| |qq| ||D]>}d|krR|d|s\d|kr6t |||}t||}q6t t |}t!j"#t$d|d}||d<t%|d}|&|d'ddW5QRXtd|d|ft$drNt!j"#t$d|dd}t%|d$}|&d|&d#|dW5QRXtdt$d|dft$d rt!j"#t$d|dd!}||d"<t%|dP}|&d#td$t$kr|&d%|&d#|d&d$t$kr|&d'W5QRXtd(t$d|df|rt!j"#t$d|d)}||d*<t%|d}|&d+|&d,t|&d-g}d.#|d(dD]l}|r|d/d0krt)|d1kr| |dd1d2|d1d}qt| |dn| |dq\d#|'d3d}|&|W5QRXtd4||r4t!j"#t$dd5|d}||d*<t%|d}|&d6|&d7t|&d8g}d.#|d(dD]}t)|d9kr|d/d0kr| |dd9d:|d9d}t)|d1kr| |dd1d:|d1d}q| |dn| |dqjd#|'d3d}|&|W5QRXtd;||S)td;|d<ntd=|d<||fS)>Nvarsz, Constructing wrapper function "%s.%s"... rrz( Constructing wrapper function "%s"... r)rrrrz argumentnthz keywordhiddenrrcheckrNrRz #docsign##docsignopt##docsignxa#rrr)rrrZ docsignaturez#docsignopt##docsignxa#rr)rrriz #docsign#Zdocsignatureshortz#docsign#[#docsignopt#])rr_z\_Zlatexdocsignatureshort,z, z #callfortran##callfortranappend#rr)rrz##callfortran# 0,#callfortranappend#Zcallcompaqfortranrz #docreturn#z = rwrx)rsrtrurvZlatexrz\begin{description}z\end{description}rrr|z %s rlz %s )rKZassubrrrFdepargsr.rCZ routsign2mapr rout_rulesr Zsign2mapr aux_rules arg_rulesr#r/rstnd check_rules isinstancelistreverserErDrrstrAssertionErrortype routine_rules)ZroutrrrvarrrrrrZnthkZsavevrdrZ_rulesrZoptargsZcfsrrrrrrPs        &    &               r)d__doc__ __future__rrrrriversionrrtimerZauxfuncsr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrZsepdictrintenvirongetZgenerationtimeasctimegmtimerrrrZtypedef_need_dictrrrrrrrrrrsj3           !!$$**--00336688;;h8R (    + +       (   +     X         0 ?    "           !  / & " 3