
    ~Od$                         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 Zd ej                    j        z  ZdZdZ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                     t          |           r| gS t          |           sg S g }| d         D ]9}t          |          r|                    |           '|t          |          z   }:|S )Nbody)ismodulehasbodyappendfindf90modules)mretbs      7lib/python3.11/site-packages/numpy/f2py/f90mod_rules.pyr   r   "   sz    {{ s
1:: 	
CvY * *A;; 	*JJqMMMMq)))CCJ    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                    ddl m} g g g ddgddddgg d}d	g}|fd
}d	g}|fd}t          |           D 	]}g g g g |d         gg f\  }}	}
}}}g }g }g }t          |          r&|d         D ]}|                    |d                    |d                                         D ]a}|d         |         }||vrM t          t          t                    |          s*|                    |           |                    |           bt          d|d         z             |r%t          dd
                    |          z             d	g}|fd}d	g}|fd}t          j        |          } |d|d         z              |d|d         z             t          |          r=|d         }t          |t                    rd
                    |          } ||           |r |d           |D ])}|d         |         }|                    |           t          j        |          }t          j        |         }t          j        ||          }|d                             dd                                          }|                    dd                                          }|sd}t*          } |dt-          |          d|d         d|d |d!t          j        |          d"            |d#t          j        ||          z             t          |          r@|d         }t          |t                    rd
                    |          } |d$|z             t3          |          rM|	                    d%|d         d&|           |
                    |	d'                    |                    d(|z             |                    d)            |d*|d         d+|d,            |d-|	d'         z              |d.|d         d/t-          |          d            |d0           |d1         t4          z   |d1<   t7          dt9          |d                   dz             } |d2d3
                    d4 |D                       z             |d1         |z   |d1<    |d5|	d'         z             |	                    |           |                    d6|z             |                    d7            |d*|d         d8|d,           +|r |d9           t          |          r>|d         D ]4}t;          |          s#t          d:|d;          d|d          d           5|                    d<|d         z             |d         |d=<   |                    |          \  }} t?          |          r_|d1         | z   |d1<   |	                    d>|d         d?|d                    |                    tA          j!        |d@                     n| r_|d1         | z   |d1<   |	                    d>|d         d?|d                    |                    tA          j"        |d@                     n6|	                    |d                    |                    |	d'                    g |dA<   tG          ||          }!g |!dB<   g |!dC<   tI          ||!          } |d|d         dD|d         d?|d         dE|d         d?|d         d"           |                    d6|d         z             |                    dF            |d*|d         d8|d         d,           6 |dG            |dH           dI|d         dJd3
                    |          dK|d1         |d1<   d?|d         v rdL}"nd}" |dM|"dN|d         dO|d         %                                dPd3
                    |          dQ	            |dR|d         z              |dS|"dN|d         dO|d         %                                dT|d         dU	            |dV           |dW         |z   |z   |dW<   dX|d         dY|d         dZ|d         dQg|d[         z   |d[<    |d	            |d\|d         z             |r)tM          |          D ]}# |d.|d         d]|#           |r- |d
                    d^g|z                         |d_            |d`           |
r tM          |
          D ]}# |da|#z              |dbd3
                    tM          |	                    z              |dc|d         z              |d
                    |dd                                       dedf                     g |dd<   |dB                             dg|d         dhd3
                    tM          |                    di           	d	|dj<   g |dk<   g |dC<   |d1         |dd<   tO          |dB                   dk    rd	|dB<   ||d1         fS )lNr   )rulesF_FUNCzarrayobject.h
)	includes0includesz"Fortran 90/95 modules:\n")f90modhooksinitf90modhooksr   needseparatorsfordocslatexdoc c                 &    |d         d| |d<   d S )Nr   z
       liness     r   faddzbuildhooks.<locals>.fadd`   s    !"1tt,!r   c                 &    |d         d| |d<   d S Nr   r   r$   r%   s     r   daddzbuildhooks.<locals>.daddd   s    Q444&!r   namer   varsz.		Constructing F90 module support for "%s"...
z		  Variables: %s
 c                 &    |d         d| |d<   d S r*   r$   r%   s     r   caddzbuildhooks.<locals>.caddz        tttTT*AaDDDr   c                 &    |d         d| |d<   d S r*   r$   r%   s     r   iaddzbuildhooks.<locals>.iadd~   r1   r   z'static FortranDataDef f2py_%s_def[] = {z.\subsection{Fortran 90/95 module \texttt{%s}}
notez\begin{description}dimsr
   z-1:z	{"z",rankz,{{z}},z, z},z\item[]{{}\verb@%s@{}}z--- %sf2py_	_getdims_r   z.void (*%s)(int*,int*,void(*)(char*,int*),int*)z,void (*)(int*,int*,void(*)(char*,int*),int*)z	f2py_z_def[i_f2py++].func = ;z#subroutine %s(r,s,f2pysetdata,flag)zuse z, only: d => zinteger flag
r   z allocate(d(%s))
,c                     g | ]}d |z  S )zs(%s)r$   ).0is     r   
<listcomp>zbuildhooks.<locals>.<listcomp>   s    999!999r   zend subroutine %szchar *%szchar*z_def[i_f2py++].data = z\end{description}z"f90mod_rules.buildhooks: skipping blockz%s()
modulename	f2pywrap__)	signatureexternroutinesr    docshortz4",-1,{{-1}},0,0,NULL,(void *)f2py_rout_#modulename#_z,doc_f2py_rout_#modulename#_zchar *z	{NULL}
};
}zstatic void f2py_setup_(z) {
	int i_f2py=0;	F_FUNC_USzextern void z	(f2pyinitz	,F2PYINITz)(void (*)(z));z static void f2py_init_%s(void) {	z)(f2py_setup_z);z}
r   z	PyDict_SetItemString(d, "z", PyFortranObject_New(f2py_z_def,f2py_init_r   z$subroutine f2pyinit%s(f2pysetupfunc)z	, only : 	interfacezend interfacezexternal f2pysetupfunczexternal %szcall f2pysetupfunc(%s)zend subroutine f2pyinit%s
r!   z\subsection{z\subsubsection{z"	z --- "routine_defsdoc)(r"   r   r   r   r   keysl_orisintent_hide	isprivateoutmessjoinr   modsign2maphasnote
isinstancelistgetctype
c2capi_map
getarrdimsreplacestrip	fgetdims2r	   
get_elsizegetarrdocsignisallocatable	fgetdims1rangeint	isroutinebuildapi
isfunctionr   createfuncwrappercreatesubrwrapper
applyrules
dictappendupperr   len)$pymodr   r   fhooksr(   rN   r+   r   sargsfargsefargsmodobjsnotvarsonlyvarssargspifargsmfargsr   nvarchooksr0   ihooksr3   vrdr4   ctatdmdmsuse_fgetdims2apiwraparr   as$                                       r   
buildhooksr   W   s   Ro.*.DAA12	 C
 TF - - - -$C ' ' ' 'E"" ZR ZR;=r2rfIL<8ufgw1:: 	*vY * *qy))))6!! 	! 	!AF)A,C  +I4y+I+I#+N+N """a   C6 	 	 	 	D+sxx/A/ABCCC 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ #A&&6!F)DEEE@AfINOOO1:: 	V9D$%% 'yyDJJJ 	)D'((( *	L *	LAF)A,CNN1#C((B%b)B%a--BV*$$S$//5577C++c4((..00C %MDD!!$$$$bjjj###rrr&s++++- . . . D+)!S113 4 4 4s|| (6{dD)) +99T??DX&'''S!! LQvYYYBCCCeBi(((DJL L LLMMMQvYYYJKKK:eBiHIIIiii!3!3!3!35 6 6 6%&&&"1I	1q	As2f:233)hh99S999::< = = ="1I5q	(E"I67777QZ1-...g&&&QvYYYJKKKK 	'D%&&&1:: "	-vY !- !- ||  D)*7D D67iD D D E E Ev63444"#F),!NN1--	Ta== 1 &q	D 0F1ILLLQvYYY&		!JKKKMM)"=a1"M"M"MNNNN 1$*1I$4q	6AfII%NOOO%7QGGGI I I I QvY///eBi000(*$%S))6
!#: b)) &			1V999aiii6AfIIIO P P P Z1V95666h'''iii6, - - - -S				fIIIsxxq		3q	!F) FFF&			1V9??#4#4#4#4chhv6F6F6F6FH 	I 	I 	I/1V9=>>>&			1V9??#4#4#4#4aiiiA 	B 	B 	BU /&86AMfIIIqyyy!F)))#- ".034E0F"GR3qyABBB 	;#F++ ; ;AfIIIqq9:::: 	"D;-&011222D!!!%&&& 	*#F++ * *]a())))%.2G2G)H)HIJJJ*ai8999TYYs:''///1 1 	2 	2 	2 JFaiii.1hh~g7N7N.O.O.O.OQ 	R 	R 	R 	R CCJC
O!fC
O
3v;1Fq	>r   )__doc____version__f2py_versionnumpynpr"   r   r   crackfortranr   r	   auxfuncsoptionsr   intpitemsizerb   r^   fgetdims2_sar   r$   r   r   <module>r      s     ""R%(                 9 9 9 9 9 9 9 9
    
  7  :A9K!L	$*		*q q q q qr   