U C^z&@sdZddlmZmZmZdddZdZddlZdd l m Z dd l m Z dd l m Z mZdd lTiZd dZdejadadZddZdS)aJ Build F90 module support for f2py2e. Copyright 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/02/03 19:30:23 $ Pearu Peterson )divisionabsolute_importprint_functionz$Revision: 1.27 $ z See `f2py -v`N) capi_maps) func2subr)undo_rmbadnameundo_rmbadname1)*cCsPt|r|gSt|sgSg}|dD]$}t|r>||q&|t|}q&|S)Nbody)ismodulehasbodyappendfindf90modules)mretbr:/tmp/pip-install-6_kvzl1k/numpy/numpy/f2py/f90mod_rules.pyr$s  ra external f2pysetdata logical ns integer r,i integer(%d) s(*) ns = .FALSE. if (allocated(d)) then do i=1,r if ((size(d,i).ne.s(i)).and.(s(i).ge.0)) then ns = .TRUE. end if end do if (ns) then deallocate(d) end if end if if ((.not.allocated(d)).and.(s(1).ge.1)) thenz end if if (allocated(d)) then do i=1,r s(i) = size(d,i) end do end if flag = 1 call f2pysetdata(d,allocated(d))z end if if (allocated(d)) then do i=1,r s(i) = size(d,i) end do !s(r) must be equal to len(d(1)) end if flag = 2 call f2pysetdata(d,allocated(d))c$ Csddlm}gggddgddddggd}d g}|fd d }d g}|fd d }t|D]D}gggg|dggf\}} } } } } g}g}g}t|r|dD]}| |dq|dD]:}|d|}|| krttt|s| |||qt d|d| r t dd | d g}|fdd}d g}|fdd}t |}|d|d|d|dt |r|d}t|trd |}||| r|d| D]\}|d|}| |t |}t j|}t ||}|ddd}|dd}|sd}t}t|rd |krld!|d krl|d"t||d#||d d!|ft}n|d$t||d#||fn|d$t||d#||f|d%t ||t |r|d}t|trd |}|d&|t|r| d'|d|f| | d(|d)||d*|d+|d|f|d,| d(|d-|dt|f|d.|d/t|d/<td0|d#}|d1d2 d3d4|D|d/||d/<|d5| d(n6| ||d6||d7|d8|d|fq| r|d9t|r|dD]}t|sXtd:|d;|dq0| d<|d|d|d=<||\}} t |r|d/| |d/<| d>|d|df|t!j"|dd?nb| r|d/| |d/<| d>|d|df|t!j#|dd?n| |d|| d(g|d@<t$||}!g|!dA<g|!dB<t%||!}|dC|d|d|d|d|df|d6|d|dD|d8|d|dfq0|dE|dFdG|dd2 ||d/f|d/<dH|dkrdI}"nd}"|dJ|"|d|d&d2 |f|dK|d|dL|"|d|d&|df|dM|dN|||dN<dO|d|d|dfg|dP|dP<|d |dQ|d|rt'|D]}#|dR|d|#fq|r|d dSg||dT|dU| r2t'| D]}#|dV|#q|dWd2 t'| |dX|d|d |dYdZd[g|dY<|dAd\|dd2 t'| fqXd |d]<g|d^<g|dB<|d/|dY<t(|dAdkrd |dA<||d/fS)_Nr)rulesF_FUNCz arrayobject.h )Z includes0Zincludesz"Fortran 90/95 modules:\n") f90modhooksinitf90modhooksr ZneedZ separatorsfordocslatexdoccSsd|d|f|d<dS)Nz %s %srrlinesrrrfaddcszbuildhooks..faddcSsd|d|f|d<dSNz%s %srrrrrrdaddgszbuildhooks..daddnamer varsz. Constructing F90 module support for "%s"... z Variables: %s  cSsd|d|f|d<dSr#rrrrrcadd}szbuildhooks..caddcSsd|d|f|d<dSr#rrrrriaddszbuildhooks..iaddz'static FortranDataDef f2py_%s_def[] = {z.\subsection{Fortran 90/95 module \texttt{%s}} notez\begin{description}Zdimsr z-1:Z charselectorlenz {"%s",%s,{{%s,%s}},%s},Zrankz {"%s",%s,{{%s}},%s},z\item[]{{}\verb@%s@{}}z--- %szf2py_%s_getdims_%srz.void (*%s)(int*,int*,void(*)(char*,int*),int*)z,void (*)(int*,int*,void(*)(char*,int*),int*)z! f2py_%s_def[i_f2py++].func = %s;z#subroutine %s(r,s,f2pysetdata,flag)zuse %s, only: d => %s z integer flag rz range(1,%s+1)z allocate(d(%s)) ,cSsg|] }d|qS)zs(%s)r).0irrr szbuildhooks..zend subroutine %szchar *%szchar*z! f2py_%s_def[i_f2py++].data = %s;z\end{description}ZSkippingblockz%s() modulenamezf2pywrap_%s_%s) signatureZexternroutinesrZdocshortz_ {"%s",-1,{{-1}},0,NULL,(void *)f2py_rout_#modulename#_%s_%s,doc_f2py_rout_#modulename#_%s_%s},zchar *z {NULL} }; }z0static void f2py_setup_%s(%s) { int i_f2py=0;%s_Z F_FUNC_USz4extern void %s(f2pyinit%s,F2PYINIT%s)(void (*)(%s));z static void f2py_init_%s(void) {z* %s(f2pyinit%s,F2PYINIT%s)(f2py_setup_%s);z} rzN PyDict_SetItemString(d, "%s", PyFortranObject_New(f2py_%s_def,f2py_init_%s));rz$subroutine f2pyinit%s(f2pysetupfunc)zuse %s, only : %sZ interfacez end interfacezexternal f2pysetupfuncz external %szcall f2pysetupfunc(%s)zend subroutine f2pyinit%s rz \subsection{z\subsubsection{z " %s --- %s"Z routine_defsdoc))rrrrrkeysZl_orZ isintent_hideZ isprivateZoutmessjoinrZ modsign2mapZhasnote isinstancelistZgetctypeZ c2capi_mapZ getarrdimsreplacestrip fgetdims2Z isstringarrayr fgetdims2_saZ getarrdocsignZ isallocatable fgetdims1eval isroutineprintZbuildapi isfunctionr ZcreatefuncwrapperZcreatesubrwrapperZ applyrulesZ dictappendupperr r,)$ZpymodrrZfhooksr"r6r$rZsargsZfargsZefargsZmodobjsZnotvarsZonlyvarsZsargspZifargsZmfargsrnvarZchooksr(Zihooksr)Zvrdr*ctatdmZdmsZ use_fgetdims2apiwraparrarrr buildhooksYs                                            rN)__doc__ __future__rrr __version__Z f2py_versionZnumpynprrr Z crackfortranr r ZauxfuncsoptionsrZintpitemsizer?r=r>rNrrrrs