a
    p=icS&                     @   sz   d Z ddd ZdZddlZddlmZ dd	lmZ dd
lm	Z	m
Z
 ddlT i Zdd Zde j ZdZdZdd ZdS )aJ  

Build F90 module support for f2py2e.

Copyright 2000 Pearu Peterson all rights reserved,
Pearu Peterson <pearu@ioc.ee>
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

z$Revision: 1.27 $
   zSee `f2py -v`    N   )	capi_maps)	func2subr)undo_rmbadnameundo_rmbadname1)*c                 C   sP   t | r| gS t| sg S g }| d D ]$}t |r>|| q&|t| }q&|S )Nbody)ismodulehasbodyappendfindf90modules)mretb r   h/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/numpy/f2py/f90mod_rules.pyr   "   s    r   a        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           $   
   C   s  ddl m} g g g ddgddddgg d}d	g}|fd
d}d	g}|fdd}t| D ]T}g g g g |d gg f\}}	}
}}}g }g }g }t|r|d D ]}||d  q|d  D ]:}|d | }||vrttt|s|| || qt	d|d   |r t	dd
|  d	g}|fdd}d	g}|fdd}t|}|d|d   |d|d   t|r|d }t|trd
|}|| |r|d |D ]b}|d | }|| t|}tj| }t||}|d dd }|dd }|sd}t}t|rd |v rld!|d  v rl|d"t||d# ||d  d! |f  t}n|d$t||d# ||f  n|d$t||d# ||f  |d%t||  t|r|d }t|trd
|}|d&|  t|r|	d'|d |f  |
|	d(  |d)|  |d* |d+|d |f  |d,|	d(   |d-|d t|f  |d. |d/ t |d/< tdt|d# d }|d0d1
d2d3 |D   |d/ | |d/< |d4|	d(   n6|	| |d5|  |d6 |d7|d |f  q|r$|d8 t|r|d D ]}t|sht	d9|d:  d|d  d q6|d;|d   |d |d<< ||\}} t |r|d/ |  |d/< |	d=|d |d f  |t!j"|dd> nb| r$|d/ |  |d/< |	d=|d |d f  |t!j#|dd> n|	|d  ||	d(  g |d?< t$||}!g |!d@< g |!dA< t%||!}|dB|d |d |d |d |d f  |d5|d   |dC |d7|d |d f  q6|dD |dE dF|d d1
||d/ f |d/< dG|d v rdH}"nd}"|dI|"|d |d & d1
|f  |dJ|d   |dK|"|d |d & |d f  |dL |dM | | |dM< dN|d |d |d f g|dO  |dO< |d	 |dP|d   |rt'|D ]}#|dQ|d |#f  q|r|d
dRg|  |dS |dT |
rBt'|
D ]}#|dU|#  q.|dVd1
t'|	  |dW|d   |d
|dX dYdZ g |dX< |d@ d[|d d1
t'|f  qXd	|d\< g |d]< g |dA< |d/ |dX< t(|d@ dkrd	|d@< ||d/ fS )^Nr   )rulesF_FUNCzarrayobject.h
)Z	includes0Zincludesz"Fortran 90/95 modules:\n")f90modhooksinitf90modhooksr
   ZneedZseparatorsfordocslatexdoc c                 S   s   d|d | f |d< d S )Nz%s
      %sr   r   linesr   r   r   fadd`   s    zbuildhooks.<locals>.faddc                 S   s   d|d | f |d< d S Nz%s
%sr   r   r   r   r   r   daddd   s    zbuildhooks.<locals>.daddnamer
   varsz.		Constructing F90 module support for "%s"...
z		  Variables: %s
 c                 S   s   d|d | f |d< d S r    r   r   r   r   r   caddz   s    zbuildhooks.<locals>.caddc                 S   s   d|d | f |d< d S r    r   r   r   r   r   iadd~   s    zbuildhooks.<locals>.iaddz'static FortranDataDef f2py_%s_def[] = {z.\subsection{Fortran 90/95 module \texttt{%s}}
notez\begin{description}dimsr	   z-1:Zcharselectorlenz	{"%s",%s,{{%s,%s}},%s},Zrankz	{"%s",%s,{{%s}},%s},z\item[]{{}\verb@%s@{}}z--- %szf2py_%s_getdims_%sr   z.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)zuse %s, only: d => %s
zinteger flag
r   z allocate(d(%s))
,c                 S   s   g | ]}d | qS )zs(%s)r   ).0ir   r   r   
<listcomp>       zbuildhooks.<locals>.<listcomp>zend subroutine %szchar *%szchar*z!	f2py_%s_def[i_f2py++].data = %s;z\end{description}z"f90mod_rules.buildhooks: skipping blockz%s()
modulenamezf2pywrap_%s_%s)	signatureZexternroutinesr   Zdocshortz_	{"%s",-1,{{-1}},0,NULL,(void *)f2py_rout_#modulename#_%s_%s,doc_f2py_rout_#modulename#_%s_%s},zchar *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}
r   zN	PyDict_SetItemString(d, "%s", PyFortranObject_New(f2py_%s_def,f2py_init_%s));r   z$subroutine f2pyinit%s(f2pysetupfunc)zuse %s, only : %s	interfacezend interfacezexternal f2pysetupfunczexternal %szcall f2pysetupfunc(%s)zend subroutine f2pyinit%s
r   z\subsection{z\subsubsection{z"	%s --- %s"Zroutine_defsdoc))r   r   r   r   r   keysZl_orZisintent_hideZ	isprivateZoutmessjoinr   Zmodsign2mapZhasnote
isinstancelistZgetctypeZ
c2capi_mapZ
getarrdimsreplacestrip	fgetdims2Zisstringarrayr   fgetdims2_saZgetarrdocsignZisallocatable	fgetdims1rangeint	isroutineZbuildapi
isfunctionr   ZcreatefuncwrapperZcreatesubrwrapperZ
applyrulesZ
dictappendupperr   r*   )$Zpymodr   r   Zfhooksr   r6   r!   r   ZsargsZfargsZefargsZmodobjsZnotvarsZonlyvarsZsargspZifargsZmfargsr   nvarZchooksr%   Zihooksr&   Zvrdr'   ctatdmZdmsZuse_fgetdims2apiwraparr   ar   r   r   
buildhooksW   s~   





















 



rN   )__doc____version__Zf2py_versionnumpynpr   r   r   Zcrackfortranr   r   Zauxfuncsoptionsr   Zintpitemsizer?   r=   r>   rN   r   r   r   r   <module>   s   
