
    *i=                       S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
   SSKrSSKJrJr  SSK7  \R"                  qSqSqSqSqSqS	qS	qSqSqSq/ qS	qS	qSq 0 q!S	q"Sq#Sq$Sq%[J        / 0q&S	q'/ q(S
q)/ q*Sq+S
q,/ q-/ q./ q/S r0SS jr1S\l2        0 r3S H
  r4SS0\3\4'   M     S H
  r4SS0\3\4'   M     0 r50 r6S H  r7\7S-   \5\7'   \7\6\7S-   '   M     S r8S r9S r:S r;\Rx                  " S\Rz                  5      R|                  r?\Rx                  " S\Rz                  5      R|                  r@\Rx                  " S\Rz                  5      R|                  rA\Rx                  " S\Rz                  5      R                  rC/ SQrD/ SQrES rFS  rG\HS4S! jrIS"rJS#rK\Rx                  " \JS	\K\KS$4-  \Rz                  5      S%4rL\Rx                  " \JS	\KS&-   \KS&-   S$4-  \Rz                  5      rM\Rx                  " \JS'-  \Rz                  5      S(4rN\Rx                  " \JS)-  \Rz                  5      S(4rOS*rP\Rx                  " \JS	\P\PS$4-  \Rz                  5      S(4rQ\PS+-   rR\Rx                  " \JS	\R\RS$4-  \Rz                  5      S(4rSS,rT\Rx                  " \JS	\T\TS$4-  \Rz                  5      S-4rUS.rV\Rx                  " \JS/\V\VS$4-  \Rz                  5      S04rWS1rX\Rx                  " \JS	\X\XS$4-  \Rz                  5      S24rY\Rx                  " \JS3-  \Rz                  5      S44rZ\Rx                  " \JS5-  \Rz                  5      S64r[\Rx                  " \JS7-  \Rz                  5      S84r\\Rx                  " \JS9-  \Rz                  5      S:4r]\Rx                  " \JS;-  \Rz                  5      S<4r^\Rx                  " \JS=-  \Rz                  5      S>4r_\Rx                  " \JS?-  \Rz                  5      S@4r`\Rx                  " \JSA-  \Rz                  5      SB4ra\Rx                  " \JSC-  \Rz                  5      SD4rb\Rx                  " \JSE-  \Rz                  5      SF4rc\Rx                  " \JSG-  \Rz                  5      SH4rd\Rx                  " \JSI-  \Rz                  5      SJ4re\Rx                  " \JSK-  \Rz                  5      SL4rf\Rx                  " \JSM-  \Rz                  5      SN4rg\Rx                  " \JSO-  \Rz                  5      SP4rh\Rx                  " \JSQ-  \Rz                  5      SR4ri\Rx                  " \JSS-  \Rz                  5      ST4rj\Rx                  " \JSU-  \Rz                  5      SV4rk\Rx                  " \JSW-  \Rz                  \R                  -  5      SX4rm\Rx                  " SY\R                  5      SZ4rnS[ roS\ rp\Rx                  " S]\Rz                  5      rq\Rx                  " S^\Rz                  5      rr\Rx                  " S_\Rz                  5      rsSS` jrtSa ruSSb jrvSc rwSSd jrx\Rx                  " Se\Rz                  5      ry\Rx                  " Sf\Rz                  5      rz\Rx                  " Sg\Rz                  5      r{\Rx                  " Sh\Rz                  5      r|\Rx                  " Si\Rz                  5      r}\Rx                  " Sj5      r~\Rx                  " Sk5      r\Rx                  " Sl\Rz                  5      rSm rSn rSo rSp rSq rSr rSs r\Rx                  " St\Rz                  5      r\Rx                  " Su\Rz                  5      r\Rx                  " Sv\Rz                  5      r\Rx                  " Sw\Rz                  5      r\Rx                  " Sx\Rz                  5      rSy rSz rS{ rS| rSS} jrSS~ jrSS jrSS jrS rS rSS jrSS jrSS jrS rS rSS jrS rSS jr\Rx                  " S\Rz                  5      rS r\Rx                  " S\Rz                  5      rS rS rS rS rS rSS jr0 4S jrS r\Rx                  " S5      R                  rS rS r\Rx                  " S\Rz                  5      rSS jrS r/ 4S jrS r\Rx                  " S\Rz                  5      r\Rx                  " S\Rz                  5      r\Rx                  " S\Rz                  5      r\Rx                  " S\Rz                  5      r\Rx                  " S\Rz                  5      rS r0 4S jrSS jrSS jrSS jrS rSS jr/ qS rS rS r/ S4S jrS rG[|        GR                  \5        \S:X  Ga  / r/ rSrSrSrSr\GR                  SS  GH  r\S	:X  a  M  \S   S:X  a  SrM  \S:X  a  SqSqM%  \S:X  a  SqSqM1  \S:X  a  [&        (       a	  \1" SS5        SqSqMQ  \S:X  a  SqM[  \S:X  a  SqMe  \S:X  a  SqSqMq  \S:X  a  SqSqSqM  \S:X  a  SrM  \S:X  a  SrM  \S:X  a  SrM  \S   S:X  a  \" S\" \5       S35        M  \(       a  Sr\qM  \(       a  Sr\qM  \(       a-   \" \5      GR                  5         \GR                  \5        GM  \GR                  \5        GM     [&        (       d  [2        (       a  [4        (       d	  \1" SS5        \" \5      r[0        (       aG  \1" S\" [0        5       S3S5        \" \5      r\" [0        S5       r\GR                  \5        SSS5        \(       a	  \H" \5        ggg! \ a    Sr GNf = f! \ a  r\" S\< S35         SrCGM  SrCff = f! , (       d  f       NQ= f)a  
crackfortran --- read fortran (77,90) code and extract declaration information.

Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
Copyright 2011 -- present NumPy Developers.
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.


Usage of crackfortran:
======================
Command line keys: -quiet,-verbose,-fix,-f77,-f90,-show,-h <pyffilename>
                   -m <module name for f77 routines>,--ignore-contains
Functions: crackfortran, crack2fortran
The following Fortran statements/constructions are supported
(or will be if needed):
   block data,byte,call,character,common,complex,contains,data,
   dimension,double complex,double precision,end,external,function,
   implicit,integer,intent,interface,intrinsic,
   logical,module,optional,parameter,private,public,
   program,real,(sequence?),subroutine,type,use,virtual,
   include,pythonmodule
Note: 'virtual' is mapped to 'dimension'.
Note: 'implicit integer (z) static (z)' is 'implicit static (z)' (this is minor bug).
Note: code after 'contains' will be ignored until its scope ends.
Note: 'common' statement is extended: dimensions are moved to variable definitions
Note: f2py directive: <commentchar>f2py<line> is read as <line>
Note: pythonmodule is introduced to represent Python module

Usage:
  `postlist=crackfortran(files)`
  `postlist` contains declaration information read from the list of files `files`.
  `crack2fortran(postlist)` returns a fortran code to be saved to pyf-file

  `postlist` has the following structure:
 *** it is a list of dictionaries containing `blocks':
     B = {'block','body','vars','parent_block'[,'name','prefix','args','result',
          'implicit','externals','interfaced','common','sortvars',
          'commonvars','note']}
     B['block'] = 'interface' | 'function' | 'subroutine' | 'module' |
                  'program' | 'block data' | 'type' | 'pythonmodule' |
                  'abstract interface'
     B['body'] --- list containing `subblocks' with the same structure as `blocks'
     B['parent_block'] --- dictionary of a parent block:
                             C['body'][<index>]['parent_block'] is C
     B['vars'] --- dictionary of variable definitions
     B['sortvars'] --- dictionary of variable definitions sorted by dependence (independent first)
     B['name'] --- name of the block (not if B['block']=='interface')
     B['prefix'] --- prefix string (only if B['block']=='function')
     B['args'] --- list of argument names if B['block']== 'function' | 'subroutine'
     B['result'] --- name of the return value (only if B['block']=='function')
     B['implicit'] --- dictionary {'a':<variable definition>,'b':...} | None
     B['externals'] --- list of variables being external
     B['interfaced'] --- list of variables being external and defined
     B['common'] --- dictionary of common blocks (list of objects)
     B['commonvars'] --- list of variables used in common blocks (dimensions are moved to variable definitions)
     B['from'] --- string showing the 'parents' of the current block
     B['use'] --- dictionary of modules used in current block:
         {<modulename>:{['only':<0|1>],['map':{<local_name1>:<use_name1>,...}]}}
     B['note'] --- list of LaTeX comments on the block
     B['f2pyenhancements'] --- optional dictionary
          {'threadsafe':'','fortranname':<name>,
           'callstatement':<C-expr>|<multi-line block>,
           'callprotoargument':<C-expr-list>,
           'usercode':<multi-line block>|<list of multi-line blocks>,
           'pymethoddef:<multi-line block>'
           }
     B['entry'] --- dictionary {entryname:argslist,..}
     B['varnames'] --- list of variable names given in the order of reading the
                       Fortran code, useful for derived types.
     B['saved_interface'] --- a string of scanned routine signature, defines explicit interface
 *** Variable definition is a dictionary
     D = B['vars'][<variable name>] =
     {'typespec'[,'attrspec','kindselector','charselector','=','typename']}
     D['typespec'] = 'byte' | 'character' | 'complex' | 'double complex' |
                     'double precision' | 'integer' | 'logical' | 'real' | 'type'
     D['attrspec'] --- list of attributes (e.g. 'dimension(<arrayspec>)',
                       'external','intent(in|out|inout|hide|c|callback|cache|aligned4|aligned8|aligned16)',
                       'optional','required', etc)
     K = D['kindselector'] = {['*','kind']} (only if D['typespec'] =
                         'complex' | 'integer' | 'logical' | 'real' )
     C = D['charselector'] = {['*','len','kind','f2py_len']}
                             (only if D['typespec']=='character')
     D['='] --- initialization expression string
     D['typename'] --- name of the type if D['typespec']=='type'
     D['dimension'] --- list of dimension bounds
     D['intent'] --- list of intent specifications
     D['depend'] --- list of variable names on which current variable depends on
     D['check'] --- list of C-expressions; if C-expr returns zero, exception is raised
     D['note'] --- list of LaTeX comments on the variable
 *** Meaning of kind/char selectors (few examples):
     D['typespec>']*K['*']
     D['typespec'](kind=K['kind'])
     character*C['*']
     character(len=C['len'],kind=C['kind'], f2py_len=C['f2py_len'])
     (see also fortran type declaration statement formats below)

Fortran 90 type declaration statement format (F77 is subset of F90)
====================================================================
(Main source: IBM XL Fortran 5.1 Language Reference Manual)
type declaration = <typespec> [[<attrspec>]::] <entitydecl>
<typespec> = byte                          |
             character[<charselector>]     |
             complex[<kindselector>]       |
             double complex                |
             double precision              |
             integer[<kindselector>]       |
             logical[<kindselector>]       |
             real[<kindselector>]          |
             type(<typename>)
<charselector> = * <charlen>               |
             ([len=]<len>[,[kind=]<kind>]) |
             (kind=<kind>[,len=<len>])
<kindselector> = * <intlen>                |
             ([kind=]<kind>)
<attrspec> = comma separated list of attributes.
             Only the following attributes are used in
             building up the interface:
                external
                (parameter --- affects '=' key)
                optional
                intent
             Other attributes are ignored.
<intentspec> = in | out | inout
<arrayspec> = comma separated list of dimension bounds.
<entitydecl> = <name> [[*<charlen>][(<arrayspec>)] | [(<arrayspec>)]*<charlen>]
                      [/<init_expr>/ | =<init_expr>] [,<entitydecl>]

In addition, the following attributes are used: check,depend,note

TODO:
    * Apply 'parameter' attribute (e.g. 'integer parameter :: i=2' 'real x(i)'
                                   -> 'real x(2)')
    The above may be solved by creating appropriate preprocessor program, for example.

    N)Path   )__version__symbolic)*fix     c                  x    Sq SqSqSqSqSqSqSqSqSq	/ q
Sq[        / 0qSqSqSq/ q0 qSqSqSq/ q/ q/ q/ qS qg )Nr   r   r   r	   r
   r   )	strictf77sourcecodeformquietverbosetabcharpyffilenamef77modulenameskipemptyendsignorecontainsdolowercasedebuggroupcounter	grouplistneededmoduleexpectbeginskipblocksuntilusermodulesf90modulevarsgotnextfilefilepositiontextcurrentfilenameskipfunctions	skipfuncs	onlyfuncsinclude_pathsprevious_context     U/var/www/html/ai-backend/venv/lib/python3.13/site-packages/numpy/f2py/crackfortran.pyreset_global_f2py_varsr*      s     INEGGKMMNKELr"ILKOKMKOMIIMr(   c                     [         (       d  g [        (       dJ  U(       a#  [        R                  R	                  [
        5        [        R                  R	                  U 5        g g N)r   r   sysstdoutwriter    )lineflags     r)   outmessr2      s>     75JJ-.

 r(   2   zabcdefghopqrstuvwxyz$_typespecrealijklmninteger)3intdoublefloatcharshortlongvoidcasewhilereturnsignedunsignediffortypedefsizeofunionstructstaticregisternewbreakdogotoswitchcontinueelseinlineexterndeleteconstautolenrankshapeindexslensize_imaxminflenfshapestringcomplex_doublefloat_doublestdinstderrr.   typedefault_bnc                 ^    U [         ;   a"  [        SU  S[         U     S35        [         U    $ U $ )Nzrmbadname1: Replacing "" with "".
)badnameserrmessnames    r)   
rmbadname1rr     s6    x)$x7GtLM~Kr(   c                 D    U  Vs/ s H  n[        U5      PM     sn$ s  snf r,   )rr   names_ms     r)   	rmbadnamerw     s    %*+UrJrNU+++   c                 ^    U [         ;   a"  [        SU  S[         U     S35        [         U    $ U $ )Nzundo_rmbadname1: Replacing "rl   rm   )invbadnamesro   rp   s    r)   undo_rmbadname1r{     s8    {.tfH[=N<OtTU4  Kr(   c                 D    U  Vs/ s H  n[        U5      PM     sn$ s  snf r,   )r{   rt   s     r)   undo_rmbadnamer}     s    */0%BOB%000rx   z-\*-\s*fortran\s*-\*-z-\*-\s*f90\s*-\*-z-\*-\s*fix\s*-\*-z[^c*]\s*[^\s\d\t])z.f90z.f95z.f03z.f08)z.forz.ftnz.f77z.fc                 p   [         b/  [         R                  " U 5      R                  5       R                  nO[	        S[
        R                  R                  U 5      5      n[        U S5       nUR                  U5      nUR                  [        R                  5      (       a  SnOpUR                  [        R                  [        R                  45      (       a  SnO9UR                  [        R                  [        R                   45      (       a  SnOSnSSS5        [        XWS9$ ! , (       d  f       N= f)	a:  Ensures that filename is opened with correct encoding parameter.

This function uses charset_normalizer package, when available, for
determining the encoding of the file to be opened. When charset_normalizer
is not available, the function detects only UTF encodings, otherwise, ASCII
encoding is used as fallback.
N    rbz	UTF-8-SIGzUTF-32zUTF-16ascii)encoding)charset_normalizer	from_pathbestr   r`   ospathgetsizeopenread
startswithcodecsBOM_UTF8BOM_UTF32_LEBOM_UTF32_BEBOM_LEBOM_BE)filenamemoder   nbytesfhandleraws         r)   openhookr   +  s     %%//9>>@II R23(D!W,,v&C~~foo..&!4!4f6I6I JKK# >??# # " 22 "!s   ,B)D''
D5c                    Sn[        U 5      R                  R                  5       [        ;   a  Sn[	        U S5       nUR                  5       nSn[        U5      (       a  SnO[        U5      (       a  SnSnUS:  aq  U(       aj  US   S:w  aB  UR                  5       (       a-  US-  nUS   S:w  a  [        US	S
 5      (       d	  USS S:X  a  SnOUR                  5       nUS:  a	  U(       a  Mj  S	S	S	5        U$ ! , (       d  f       U$ = f)z(Check if file is in free format Fortran.FTr   r   !r   	N   r   &)
r   suffixlowerCOMMON_FREE_EXTENSIONSr   readline_has_f_header_has_f90_headerstrip_free_f90_start)fnameresultr   r0   ns        r)   is_free_formatr   J  s     FE{!%;;	%	!AT""AF!eAw#~$**,,QGtORa(A(Ad2bkUXFX!F##%D !e 
 M 
	 Ms   B/C77
Dc           
         U(       d/  [         [        [        [        [        [
        [        [        [        4	nU / :X  a  g[        nSnSnSn[        R                  " S[        R                  5      n[        R                  " S5      n	[        R                  " S5      n
[        R                  " S5      nU(       a	  U" SS5        S	u  p|S
/[        S5       Vs/ s H  n[        U5      PM     sn-   nSq[        R                  " U [         S9n  UR#                  5       nU(       d  GOUR-                  5       (       Ga  SqUR)                  5       qSq UnSqSq[.        R0                  R3                  [        5      S   n[5        [        5      R6                  R9                  5       [:        ;   a#  [=        U5      (       d  [?        U5      (       d  SqO&[A        [        5      (       a  [?        U5      (       d  Sq[        (       a  [B        qO[D        q[G        S[I        [        5      < S[        < [        =(       a    S=(       d    S< S35        URK                  5       RM                  SS
5      nUS:X  d  US   S;  a  OUSS nUS:X  d  M  Sn[O        US5      u  nnUS
-  nUSS R9                  5       S:X  a  [O        US-   USS -   S5      u  nnSnURQ                  5       S:X  a  [        S:X  a  OSnGM  [        S:X  Ga)  US   S ;   a)  USS R9                  5       S!:X  a  S"USS -   nSnO&SnSnGM$  [        (       a  [S        U5      S#:  a  USS# nUS   U;  a  ['        S$[I        U5      -  5      eU(       a  [        (       a&  [S        U5      S:  a  US   S
:X  d  UUS%S -   nSnSnGOU	RU                  U5      nU(       a  URW                  S&5      nU(       a(  XzRU                  U5      RW                  S&5      -   nSnSnGO[S"USS -   nU(       a  UR9                  5       nOUnUnUnGO3[        S:X  Ga  U(       ds  WS':X  am  URU                  U5      (       aW  US(-   n UR#                  5       nU(       d  [Y        S)5        OUU-   nURU                  U5      (       a  OMA  UR[                  5       nU	RU                  U5      nU(       a  URW                  S&5      nU(       a'  XzRU                  U5      RW                  S&5      -   nSnSnO7U(       a*  U(       a  []        U5      (       d  UR9                  5       OUnOUnUnUnUSLnO[_        S*[I        [        5       35      eS+URa                  5       S-
  [        U4-  qURU                  U5      nU(       Ga  URW                  S,5      n[.        R0                  Rc                  U5      (       a  [e        UUSS-9  O[.        R0                  Rg                  [        5      /[h        -   nSnU HV  n[.        R0                  Rk                  UU5      n[.        R0                  Rc                  U5      (       d  MI  Sn[e        UUSS-9    O   U(       d:  [G        S.[I        U5      < S/[.        Rl                  Rk                  U5      < S035        OU" U5        UnGM  U(       a  UR9                  5       nOUnUnS+URa                  5       S-
  [        U4-  qURU                  U5      nU(       Ga  URW                  S,5      n[.        R0                  Rc                  U5      (       a  [e        UUSS-9  O[.        R0                  Rg                  [        5      /[h        -   nSnU HV  n[.        R0                  Rk                  UU5      n[.        R0                  Rc                  U5      (       d  MI  Sn[e        UUSS-9    O   U(       d:  [G        S.[I        U5      < S/[.        Rl                  Rk                  U5      < S035        OU" U5        SqURo                  5         U(       a
  U" SS5        gWu	  q qqqqqqqqgs  snf ! [$         a6  n['        SUR)                  5        SUR+                  5        SU S35      eSnAff = f)1z
Read fortran codes from files and
 1) Get rid of comments, line continuations, and empty lines; lower cases.
 2) Call dowithline(line) on every line.
 3) Recursively call itself when statement "include '<filename>'" is met.
NFr
   z*\s*include\s*(\'|")(?P<name>[^\'"]*)(\'|")z(?P<line>.*)&\s*\Zz(\s*&|)(?P<line>.*)z.*?'''r   )r
   r
    
   )r   Tzreadfortrancode: reading #z failed with
zu.
It is likely that installing charset_normalizer package will help f2py determine the input file encoding correctly.r   r   r   freez	Reading file z	 (format:z,strict)
    z
r   r   z!f2pyr	   )r   cr   Cr   f2pyz     H   zxreadfortrancode: Found non-(space,digit) char in the first column.
	Are you sure that this code is in fix form?
	line=%s   r0   .pyf
z.Unexpected end of file when reading multiline
z4Flag sourcecodeform must be either 'fix' or 'free': zLine #%d in %s:"%s"
	rq   )
dowithlineistopz-readfortrancode: could not find include file z in . Ignoring.
)8r   r    r!   r   r   beginpatternr   r   r   recompileIrangestr	fileinput	FileInputr   r   UnicodeDecodeError	Exceptionr   linenoisfirstliner   r   splitextr   r   r   COMMON_FIXED_EXTENSIONSr   _has_fix_headerr   beginpattern77beginpattern90r2   repr
expandtabsreplacesplit_by_unquotedr   rX   matchgroupro   rstripiscstyledirective
ValueError
filelinenoisfilereadfortrancodedirnamer%   joinpathsepclose)ffiler   r   saveglobalslocaldolowercasecont	finallinellincludelinecont1cont2
mline_markl1rv   spacedigitsfinlmsgextis_f2py_directiverl_origfinalliner   lcmfninclude_dirs	foundfileinc_dirfn1s                                  r)   r   r   d  s    !#3_nV_%+6{" DI	B**5rtt=KJJ,-EJJ-.EI&J2rFB%U2Y7Yr3r7Y77K


eh
7C
	A ??!!llnOKBI"N''""?3A6CO$++1137NN(++q/A/A	009K9K!'y--O,n!/i6B68 9 LLN""63/r'uH$#2A r'
 "#As+B	Sbq6<<>W$$Q[2ab6%93?DAq $779?'
  U"t00Qq6<<>V+!AB%A(,% D(-%q6B;#2At;& !GIMa!Q R R IICFQJqts{!AB%Z	 "KKNAkk!n226::B "I$&M  !AB%A'$&HHJ	$&	$&MBv%C6Mj.>.>q.A.AHBMOBA!''++  HHJAAGGFO++a...v66	 "# 4EIZ[]I^I^
egI "I "TMDFtNG[F\]_ _4NNq /287 7m,Bww~~b!!zC GGOOO4 68E F	+G'',,w3Cww~~c**$%	'
!L  , !R"**//,"?A B y!{ ~ HHJ		M01or43 3-(AWWV_77>>"B:Q?GGOOO<=MLI'ggll7B/77>>#&& !I#CJaH ( Hbjjool;= > 	9IIK2q 9D	6%	%+E 8 " 	+CLLN+;1SZZ\N  & 	s   `<a 
b1a<<bzN\s*(?P<before>%s(?=\s*(\b(%s)\b)))\s*(?P<this>(\b(%s)\b))\s*(?P<after>%s)\s*\Zzqcharacter|logical|integer|real|complex|double\s*(precision\s*(complex|)|complex)|type(?=\s*\([\w\s,=(*)]*\))|byte.*rh   z|static|automatic|undefined)z([a-z]+[\w\s(=*+-/)]*?|)functionr   r   begin)z	[a-z\s]*?
subroutiner   r   zprogram|block\s*datazM|module(?!\s*procedure)|python\s*module|(abstract|)\s*interface|type(?!\s*\()z\end|endprogram|endblockdata|endmodule|endpythonmodule|endinterface|endsubroutine|endfunctionendzDend\s*(if|do|where|select|while|forall|associate|critical|enum|team)z[\w]*?endifzmodule\s*proceduremoduleprocedure)r
   implicitr   r   r   )r
   dimension|virtualr  r   	dimension)r
   externalr  r   r  )r
   optionalr  r   r  )r
   requiredr  r   r  )r
   publicr  r   r  )r
   privater  r   r  )r
   	intrinsicr  r   r  )r
   intent|depend|note|checkr	  z\s*\(.*?\).*intent)r
   	parameterr  z\s*\(.*r  )r
   datar  r   r  )r
   callr  r   r  )r
   entryr  r   r  )r
   callfunr  r   r  )r
   commonr  r   r  )r
   user  r   r  )r
   containsr  r
   r  )r
   formatr  r   r  )r
   Kthreadsafe|fortranname|callstatement|callprotoargument|usercode|pymethoddefr  r   f2pyenhancementsz2\s*(?P<before>''')(?P<this>.*?)(?P<after>''')\s*\Z	multilinec           	      `   [        S5      [        U5      -  (       a   S5       e[        R                  " SR                  S[        R                  " U5       S3S[        R                  " U5       S3SSS	95      nUR                  U 5      nU(       a  UR                  5       nUS
   US   4$ U S4$ )z
Splits the line into (line[:i], line[i:]),
where i is the index of first occurrence of one of the characters
not within quotes, or len(line) if no such index exists
z"'zcannot split by unquoted quoteszR\A(?P<before>({single_quoted}|{double_quoted}|{not_quoted})*)(?P<after>{char}.*)\Zz[^"'][z('([^'\\]|(\\.))*')z("([^"\\]|(\\.))*"))
not_quotedr;   single_quoteddouble_quotedbeforeafterr
   )setr   r   r  escaper   	groupdict)r0   
charactersr   r   ds        r)   r   r     s     E
S_,P/PP-


	!!'ryy45Q7RYYz*+1-00	 "( "2	3A 	
AKKM(QwZ((":r(   c                     / n[        U 5      R                  S5       H/  nS H  nUR                  US5      nM     UR                  U5        M1     SR	                  U5      $ )N@,@z(),r   ,)markoutercommasplitr   appendr   )argslinear   r   s       r)   _simplifyargsr,    sV    
AH%++E2A		!S!A 	 3 88A;r(   z"\s*(?P<result>\b[a-z]+\w*\b)\s*=.*z \s*(?P<bind>\b[a-z]+\w*\b)\s*=.*zH\s*bind\(\s*(?P<lang>[^,]+)\s*,\s*name\s*=\s*"(?P<lang_name>[^"]+)"\s*\)c                    [        U S5      u  p#U(       a  [        S   R                  U 5      (       dy  [        S   R                  U 5      (       d\  US:X  d   [	        U5      5       e[        U S5      u  pU(       a%  [        X5        [        USS S5      u  pU(       a  M%  [        X5        gUS:  a_  Sq[        S0q[        0 0q[        / 0q	/ [        [           S'   0 [        [           S'   S[        [           S'   S[        [           S	'   S
q
S
qgUS:  Ga  Sn[        (       a  [        [        :X  a  Sn[        U:  a  [        S[	        [        5      < S[	        [        5      < S35        [        S5        [        [        S-
     R                  [        [           5        [        [           [        [        S-
     S
   S'   [        [        	 [        S-
  q[        U:  a  M  [        (       a  [        [        :X  a  [        [        S-
     R                  [        [           5        [        [           [        [        S-
     S
   S'   [        [        	 [        S-
  q[        [        S-
     R                  [        [           5        [        [           [        [        S-
     S
   S'   [        [        	 [        S-
  qS
q
gU S:X  a  gSn[        [         ["        [$        [&        [(        [*        [,        [.        [0        [2        [4        [6        [8        [:        [<        [>        [@        [B        [D        [F        [H        [J        [        [        [L        4 H%  nUS   R                  U 5      nU(       a    O	US-   nM'     W(       Gd  [N        n	S[        s=::  a  [        ::  a   g  S[        [           ;   Ga9  [        [           S    GH$  n
U
[P        ;   a	  [P        U
   n
S[        [           ;   a  U
[        [           S   ;   a  M>  [R        R                  " SU
-  [U        U 5      [R        RV                  5      nU(       d  My  U	R                  URY                  S5      5      n[[        URY                  S5      5      nU(       a  SU
 SU SURY                  S5       S3n O	SU
 SU S3n [\        S   R                  U 5      nU(       d  [        S[	        U 5       S35          g[_        USU 5          g   [`        S:  d2  [`        S:X  a<  [b        Re                  5       Rg                  S5      (       a  Sq4[        S[        -  5        gWS   S:X  GaP  S[        s=::  a
  [        :  a  O  O[        S-
  q[        [        ::  a  g[        S::  a  [k        S [        -  5      e[8        S   R                  U 5      nU(       ag  URY                  S!5      [        [           :X  dG  [k        S"[	        URY                  S!5      5      < S#[	        [        [           5      < S$[l        < 35      e[        [        :X  a  S
q[        [        S-
     R                  [        [           5        [        [           [        [        S-
     S
   S'   [        [        	 [        S-
  q[n        (       d  Sq8ggUS   S%:X  a6  S[        s=::  a
  [        ::  a  O  O
[        S-   qgSq9[_        XS   U 5        Sq8gUS   S&:X  a  gUS   S':X  a  [_        XS   U 5        gUS   S(:X  a+  [t        (       a  gS[        s=::  a  [        ::  a   g  [        qgS[        s=::  a  [        ::  a   g  [_        XS   U 5        g))z
reset=-1  --- initialize
reset=0   --- crack the line
reset=1   --- final check if mismatch of blocks occurred

Cracked data is saved in grouplist[0].
;r   r   Nr
   bodyvarsblockrq   r      zcrackline: groupcounter=z groupname=r   zYcrackline: Mismatch of blocks encountered. Trying to fix it by assuming "end" statement.
	externals
interfacedz5(?P<before>[^"]*)\b%s\b\s*@\(@(?P<args>[^@]*)@\)@.*\Zr  argszcallfun (z
) result (r   )z4crackline: could not resolve function call for line=.
r  r   z"crackline:%d: No pattern for line
r   z>crackline: groupcounter(=%s) is nonpositive. Check the blocks.thiszcrackline: End group z* does not match with previous Begin group z
	r   r   r   r  );r   f2pyenhancementspatternr   multilinepatternr   	crackliner   	groupname
groupcacher   r   r   r   r2   r)  dimensionpatternexternalpatternintentpatternoptionalpatternrequiredpatternparameterpatterndatapatternpublicpatternprivatepatternintrinsicpatternendifpattern
endpatternformatpatternr   functionpatternsubroutinepatternimplicitpatterntypespatterncommonpatterncallpattern
usepatterncontainspatternentrypatternmoduleprocedurepatterncrackline_re_1rz   r   markouterparenr   r   r,  callfunpatternanalyzeliner   r!   r   endswithr&   r   r    r   r   r   r   )r0   resetr   has_semicolonsemicolon_lineflr1   patr   re_1rq   m1m2r+  s                 r)   r<  r<    sD    )s3A5a8>>tDD/288>>z&4;&z0s;d"#4^AB5G#M D n 	$qy!2&	"B'
!2&	+-
< (+-
< (,.
< )+-
< (qy=\\9BR,'i: ;lnlQ&'..z,/GH6?6MIlQ&'+F3,''!+L R =\\9lQ&'..z,/GH6?6MIlQ&'+F3,''!+LlQ&'..z,/GH6?6MIlQ&'+F3,''!+LLrzD /=/ +}n jo/@}Z' & FLLax#$ /</ 0*\22"<0=;&&t,D:l#;;
S_H`amHn@nXXLtSUcdhUikmkokoq2BHHX$67B%bhhv&67A!)$q:bhhx>P=QQRS!)$q15&q)//5ARSWX\S]R^^abd9d3) >* Q;7a<O,A,A,C,L,LV,T,T#9\JK	Q5.,.'!+L,.1 0+- . . !_""4(&)Y|-DD!"((6"23T)L:Q5R-/  
 l* O,"#**:l+CD2;L2I	,"#B'/l##a'}K 	Q7	/</'!+LA1vt$	Q7		Q$	$A1vt$	Q:	>/</ 0&/</ 0A1vt$r(   c                     SnSnU  H8  nUS:X  a  US-   nUS:X  a  US-   nM  OUS:X  a  US-
  nUS:X  a  US-   nM4  X-   nM:     U$ )Nr
   r   r6  r   @(@r7  @)@r'   )r0   r   fr   s       r)   rW  rW  W  sq    
A	A8AAAvI  #XAAAvIE  Hr(   c                 6   SnSn[        XS-   5      u  pEX$-  nU(       a`  US   U:X  a  US:X  a  USU-   S-   -  nO$X%S   -  nUS   S:X  a  US-  nOUS   S:X  a  US-  n[        USS  US-   5      u  pEX$-  nU(       a  M`  U(       a   [        X0U45      5       eU$ )Nr
   r   ()@r6  r   r7  )r   r   )r0   commar   rf  r  r  s         r)   r'  r'  i  s    
A	A%dDL9MFKA
!HAFus""AqMAQx3QqSQ)%)UT\B	 % $$|$$5Hr(   c                 J    U R                  SS5      R                  SS5      nU$ )Nrd  r6  re  r7  )r   )r0   r   s     r)   unmarkouterparenrl  |  s$    UC ((4AHr(   c                    U (       d  0 n U(       d  U $ XL a  U $ [        UR                  5       5       H  nUS:X  a  U(       d  X0;  a  X   X'   M  M  US:X  a  X    H  n[        XU5      n M     M>  US:X  a  [        XU   U5      n MU  US:X  a  [	        XU   U5      n Ml  US;   a  U(       d  X0;  a  X   X'   M  M  US:X  a  M  US;   a  [        SU S	35        M  [        S
[        U5      -   5      e   U $ )Nr4   attrspeckindselectorcharselector)=typenamenote)r
  checkr  r  r  dependzappenddecl: "z" not implemented.
z-appenddecl: Unknown variable definition key: )listkeyssetattrspecsetkindselectorsetcharselectorro   r   r   )decldecl2forcekr   s        r)   
appenddeclr    s   }%**,
?( &*_X"4E2 . "4q59D. "4q59D##( &&[ ) )mA3&:;<KF# $ $)  , Kr(   zD\s*(?P<this>(@\(@.*?@\)@|\*[\d*]+|\*\s*@\(@.*?@\)@|))(?P<after>.*)\Zz[(?:,(?P<attributes>[\w(),]+))?(::)?(?P<name>\b[a-z$_][\w$]*\b)(?:\((?P<params>[\w,]*)\))?\Zz\s*(?P<name>\b[\w$]+\b)\s*(@\(@\s*(?P<args>[\w\s,]*)\s*@\)@|)\s*((result(\s*@\(@\s*(?P<result>\b[\w$]+\b)\s*@\)@|))|(bind\s*@\(@\s*(?P<bind>(?:(?!@\)@).)*)\s*@\)@))*\s*\ZzF\s*(?P<scheme>(operator|assignment))@\(@\s*(?P<name>[^)]+)\s*@\)@\s*\Zz9\s*(?P<name>\b[\w$]+\b)\s*@\(@\s*(?P<args>.*)\s*@\)@\s*\Zz4([-+]?(?:\d+(?:\.\d*)?|\d*\.\d+))[dD]((?:[-+]?\d+)?)zA([-+]?((?:\d+(?:\.\d*)?|\d*\.\d+))[eE]((?:[-+]?\d+)?)|(\d+\.\d*))zintent\s*\(.*?\bcallback\bc                 n    U R                  S/ 5       H  n[        R                  U5      (       d  M    g   g)Nrn  r   r   )get_intentcallbackpatternr   )vdeclr+  s     r)   _is_intent_callbackr    s0    YYz2&!''** ' r(   c                 x   SR                  U R                  5       5      n [        R                  U 5      n[	        X5        U(       ak  UR                  S5      nU(       a/  UR                  S5       Vs/ s H  o3R                  5       PM     snO/ nUR                  S5      X!R                  S5      4$ S / S 4$ s  snf )Nr
   
attributesr&  rq   params)r   r(  typedefpatternr   printr   r   )r0   ra  attrsr+  s       r)   _resolvetypedefpatternr    s    774::< D			d	#B	$O	&9>EKK$45$4q$45Bxx(:::T> 6s   2B7c                     [         R                  " S[         R                  5      nUR                  U 5      nS nU(       a7  UR	                  S5      nU S UR                  5        XR                  5       S  -   n X4$ )NzObind\(\s*(?P<lang>[^,]+)(?:\s*,\s*name\s*=\s*["\'](?P<name>[^"\']+)["\']\s*)?\)r   )r   r   r   searchr   startr   )r0   patternr   bind_statements       r)   parse_name_for_bindr    sh    jjkmomqmqrGNN4 ENQNU[[]#d99;<&88r(   c                    [        U 5      u  p[        U 5      n [        R                  U 5      nU(       a3  UR	                  S5      UR	                  S5      UR	                  S5      U4$ [
        R                  U 5      nU(       a/  UR	                  S5      S-   UR	                  S5      -   S-   nU/ S S 4$ [        R                  U 5      nU(       a$  UR	                  S5      UR	                  S5      S S 4$ S / S S 4$ )Nrq   r5  r   schemer6  r7  )r  rW  nameargspatternr   r   operatorpatterncallnameargspattern)r0   
bind_cnamera  rq   s       r)   _resolvenameargspatternr    s    *40D$D			t	$B	xx&!1288H3EzQQ			t	$B	xx!C'"((6*::S@Rt##		"	"4	(B	xx&!14==T4r(   c                 X<   U R                  S5      nUS:w  a  Sq[        (       a  US;  a  [        (       d  [        S:  a  [
        R                  R                  [        5      R                  S5      S   n[        SU S	35        Sq[        S-   qS
[        [        '   0 [        [        '   / [        [        '   / [        [           S'   0 [        [           S'   S
[        [           S'   U[        [           S'   S[        [           S'   SqUS;   G	aO  UR                  5       n[         R"                  " SU[         R$                  5      (       a  SnO[[         R"                  " SU[         R$                  5      (       a  SnO-[         R"                  " SU[         R$                  5      (       a  SnUS:X  a7  ['        U R                  S5      5      u  pVnSU0[        [           S   U'   / nSn	O[)        U R                  S5      5      u  pXpUc  US:X  a  SnOSnUS;  a  [        S5        X5[        4qU(       aC  [+        [-        U5      R                  S5       Vs/ s H  nUR/                  5       PM     sn5      nO/ nSU;   a*  SU;   a  UR1                  S5        SU;   a  M  [        S 5        SnSnUS!;   ae  SnS"[        [           ;  a  gU[        [           S"   ;  a  g[        [            H  nUS   U:X  d  M    g   U[        [           S#   ;   a  gS$S%S!.U   n[2        (       a'  [4        S&:X  a  [        S::  a  [        S'-   qSnUS(;  a  Sn[        S-   q0 [        [        '   / [        [        '   U(       a  [6        S:  a  [        S)[9        [2        5      -  S5        S*[        [        '   S[        [           S'   [2        [        [           S'   S[        [           S'   / [        [           S'   / [        [           S+'   / [        [           S#'   0 [        [           S'   [        S-   q0 [        [        '   / [        [        '   U(       a  [6        S:  a  [        S,[        -  S5        S-[        [        '   S-[        [           S'   S.[        [           S'   [        [        S-
     S   < S/[        [        S-
     S   < 3[        [           S'   / [        [           S'   / [        [           S+'   / [        [           S#'   0 [        [           S'   [        S-   q0 [        [        '   / [        [        '   U[        [        '   U[        [           S'   U(       d  S0UR;                  S1S25      -   nU R                  S35      [        [           S4'   [=        U5      [        [           S'   U	[        [           S5'   [        S:X  a  [        [        [           S'   O{[2        (       a7  [        S6:X  a-  [        [        S-
     S   < S/[        < 3[        [           S'   O9[        [        S-
     S   < S/[        [        S-
     S   < 3[        [           S'   [?        [        [           RA                  5       5       H(  n[        [           U   (       a  M  [        [           U	 M*     U[        [           S"'   / [        [           S'   / [        [           S+'   / [        [           S#'   0 [        [           S'   0 [        [           S7'   US:X  a  / [        [           S8'   US!;   a  U[        [        S'-
     S+   ;  a"  [        [        S'-
     S+   RC                  U5        [D        RF                  " [        [        S'-
     S   5      [        [           S'    [        [           S   U   [        [           S   U   S   RI                  S95      	 US:;   Gaf  W
(       a  [         RL                  " [N        U
5      nU(       ar  U0 0[        [           S;'   UR                  S<5      [        [           S;   U   S<'   UR                  S=5      (       a%  UR                  S=5      [        [           S;   U   S'    [Q        [        [           S   U   [        [        S'-
     S   S   5      [        [           S   U'   US>:X  a_  U	(       aX  U	[        [           S   ;   aD  XY:X  d?  [Q        [        [           S   U   [        [           S   U	   5      [        [           S   U'    [        [        S'-
     S#   RC                  U5        US%:X  aq  [R        S   R#                  U R                  S35      S1-   U-   5      nU(       a=  [U        UR                  S5      UR                  S5      5      u  nnnn[W        UUUU5        US!;   a  [        [        S-
     RC                  [        [           5        [        [           [        [        S-
     S&   S'   [        [        	 [        S-
  q[        [        S-
     RC                  [        [           5        [        [           [        [        S-
     S&   S'   [        [        	 [        S-
  qggUS7:X  a  [)        U R                  S5      5      u  pXpUb|  U(       aC  [+        [-        U5      R                  S5       Vs/ s H  nUR/                  5       PM     sn5      nO/ nU	b   [9        U	5      5       eU[        [           S7   U'   S7U[        4qggUS:X  a;  [U        X0R                  S5      5      u  nnnn[W        UUUU5      nUb
  S?U[        4qggUS@;   Ga  [        [           S   nU R                  S5      R/                  5       nURY                  SA5      nUS:  a  USB:X  a  [[        U5      RY                  SC5      S'-
  nUSUS-    SA-   UUS-   S -   nURY                  SA5      nUUS SA:X  aX  S"[        [           ;   aG  [        SDU R                  S5      < USU < SE35        USFR]                  [        [           S"   5      -   nUS:  a  SnSnOUSU R/                  5       nUUS'-   S n[-        U5      R                  S5      n[_        U5      S:  a%  US   n[        SGSFR]                  USS 5      -  5        Sn[-        U5      R                  S5       Vs/ s H  oR/                  5       PM     sn GH[  n[`        R#                  U5      nU(       dA  USH;   a  SnOR[c        U Re                  5       5        [        SIU< SJ[9        U5      < SK35        Ma  [=        UR                  S5      5      nUSH;   a  USL;   a  UUR                  S5      -  nUU;  a  0 UU'   USM:X  a  UUR                  S5      -   nUSB:X  a  U R                  S5      U-   n[f        R#                  U5      (       a  U[        [           S"   ;  a  [        S:  ax  SN[        [        S'-
     S   ;  a  [        SO5        U[        [           S   :w  aA  [        SPU< SQ[        [           S   < SR35        [        [           S"   RC                  U5        O[i        SSU ST35        O[i        SUU-  5        USV;   a  UnSUU   ;   a  UU   S   RC                  W5        O	W/UU   S'   US9:X  ay  [        [           S   S
:X  a  [        SW5        GM  U[        [           S"   ;  a  GM  S+[        [           ;  a  / [        [           S+'   [        [           S+   RC                  U5        UnGM^     U[        [           S'   Ub
  S?U[        4qggUSX:X  aM  U R                  S5      R                  SF5       Vs/ s H  oR/                  5       PM     sn[        [           SY'   gUSZ:X  GaW  [        [           S   nU R                  S5      R/                  5       SS& nSn[-        U5      R                  S5       GH  n UR                  S[5       Vs/ s H  oR/                  5       PM     snu  nn[k        U5      n[=        U5      nUU;  a  0 UU'   S[UU   ;   a*  UU   S[   U:X  d  [        S_U< S`UU   S[   < SaU< S	35        [m        UU5      nU(       a  URo                  Sb5      Sc:X  a  [?        U5      n [p        Rs                  U5       Hj  n [?        UU Ru                  5       U Rw                  5        R                  5       R;                  SdSe5      5      U U Ru                  5       U Rw                  5       & Ml     SR]                  U 5      nOHURo                  Sb5      Sf:X  a3  USS R                  5       R;                  SdSe5      R;                  SFSg5      n [y        U0 U5      n![9        U!5      UU   S['   SUU   ;   a  UU   S   RC                  SZ5        O	SZ/UU   S'   UnGM     U[        [           S'   Ub
  S?U[        4qggUSj:X  Ga  U R                  S5      R/                  5       R                  5       Sk:X  a  S[        [           Sj'   gU R                  S5      (       GaR  [        [           Ro                  Sj0 5      n#U#c  [        Sl5        0 n#[-        U R                  S5      5      R                  S5       GH  n0 n$[         R"                  " SmU[         R$                  5      nU(       d  [        SnU S^35        MD  [        R#                  UR                  S5      5      n%U%(       d  [        SoU S^35        M  [U        U%R                  S5      U%R                  S5      5      u  nnnn[        UU5      u  n&n'n(UU$Sb'   U&U$Sp'   U'U$Sq'   U(U$Sr'   [?        U$RA                  5       5       H  nU$U   (       a  M  U$U	 M     [-        UR                  S5      5      R                  S5       H  n)SsU);   a4   U)R                  Ss5       Vs/ s H  oR/                  5       PM     snu  n*n+OU)R/                  5       =n*n+[_        U*5      [_        U+5      s=:X  a  S:X  d  O  [        StU) Sv35        M  [        [        U*5      [        U+5      S-   5       H  n,U$U#[        U,5      '   M     M     GM     U#[        [           Sj'   ggUSw:X  GaE  / nSn-Sn.Sn/Sn0Sn1U R                  S5       H  n2U1(       d!  U2Sx:X  a  U0(       + n0U2Sy:X  a  U0(       a  U/S-   n/M+  U2Sz:X  a  U1S-   n1OU2S{:X  a  U1S-
  n1U/S:X  a  U-U2-   n-MO  U/S:X  a  U.U2-   n.M\  U/S':X  d  Md  U-R/                  5       n-U-R                  SF5      (       a  U-SS R/                  5       n-URC                  U-U./5        U2n-Sn.Sn/M     U/S':X  aL  U-R/                  5       n-U-R                  SF5      (       a  U-SS R/                  5       n-URC                  U-U./5        [        [           Ro                  S0 5      n3SnU GH  n4U4S   R/                  5       R                  SF5      U4S   R/                  5       sU4S'   U4S'   U4S   R                  Sz5      (       a  [        S|U4S    S}35        Mm  [        [+        [-        U4S   5      R                  S5       Vs/ s H  oR/                  5       PM     sn5      5       GH  u  n5n!U!R                  Sz5      (       a  [        S|U! S}35        M.  S~U4S   ;   a  [        SU4S    S}35        MK  U3R                  U!0 5        U3U!   Ro                  Sb5      n6[        U3U!   5      n7U6Sf:X  a  [         R                  " SU4S   5      OU4S   R                  SF5      n8 U7(       a  SSR]                  U85       S3OU8U5   n9U3U!   Ro                  S[5      n>U>(       a  U>U9:w  a  [        SU! S`U> SU9 S^35        U9U3U!   S['   U!nGM     GM     U3[        [           S'   U(       a
  S?U[        4qggUS:X  Ga.  U R                  S5      R/                  5       nUS   Sy:X  d  SU-   n/ n?[         R                  " SyUS'S9u  nn@nAU@R/                  5       n@U@(       d  Sn@U?RC                  W@WA/5        0 nBS[        [           ;   a  [        [           S   nBU? Hv  n2U2S   WB;  a  / WBU2S   '   [-        U2S   5      R                  S5       Vs/ s H  oR/                  5       PM     sn H#  nU(       d  M  WBU2S      RC                  U5        M%     Mx     WB[        [           S'   SW@[        4qgUS:X  Ga  [         R"                  " SU R                  S5      [         R$                  5      nU(       Gao  URe                  5       nCS[        [           ;  a  0 [        [           S'   UR                  S5      n0 [        [           S   U'   SnDSWC;   Ga  WCS   Gb  SWC;   a  WCS   c  SnDWD[        [           S   U   S'   WCS   R                  SF5       Vs/ s H  oR/                  5       PM     nn0 nEU H  n4S[U4;   a  [         R"                  " SU4[         R$                  5      n%U%(       a@  U%R                  S5      R/                  5       WEU%R                  S5      R/                  5       '   O[        S[9        U45       SE35        OU4WEU4'   WE[        [           S   U   S'   M     ggg[c        U Re                  5       5        [        S5        gUS;   a  S[        [           ;  a  0 [        [           S'   [        [           S   nFU R                  S5      S:X  aK  SWF;   aE  [        WFS   [        5      (       a	  WFS   /UFS'   WFS   RC                  U R                  S5      5        gU R                  S5      WFU R                  S5      '   gUS:X  aO  [        c  [6        (       a  [        S5        g[        nG[        [        UG   [        SS' U R                  S5      5        g[6        S:  a%  [c        U Re                  5       5        [        S5        ggs  snf ! [J         a     GNf = f! [J         a     GNf = f! [J         a     GNtf = fs  snf s  snf s  snf s  snf ! [J         a    [        S\U S]U S^35         GM  f = f! [z        [|        [~        4 a   n"[i        ShU< SiU"< SE35         Sn"A"GM  Sn"A"ff = fs  snf ! [J         a    [        StU) Su35         G	M5  f = fs  snf ! [         a    [        S U8 5       5      (       a  / n:U8 H  n;SU;;   as   U;R                  S5      u  n<n=U:R                  U=R/                  5       /[        U<5      -  5        ML  ! [         a#    U:RC                  U;R/                  5       5         Mx  f = fU:RC                  U;R/                  5       5        M     U:n8U7(       a  SSR]                  U85       S3OU8U5   n9 GNvf = fs  snf s  snf )a|  
Reads each line in the input file in sequence and updates global vars.

Effectively reads and collects information from the input file to the
global variable groupcache, a dictionary containing info about each part
of the fortran module.

At the end of analyzeline, information is filtered into the correct dict
keys, but parameter values and dimensions are not yet interpreted.
r9  r  N)r   r  r  rh   r   .r   z=analyzeline: no group yet. Creating program group with name "rm   programr/  r0  r1  rq   fromskyfrom)r   r  r  zblock\s*data
block datazpython\s*modulepython modulezabstract\s*interfaceabstract interfacerh   r  rn  _BLOCK_DATA_r
   )	interfacer  r  z2analyzeline: No name/args pattern found for line.
r%  z<analyzeline: argument list is malformed (missing argument).
)r  r  r5  r4  r   r   r   r2  r  r  z&analyzeline: Creating module block %s
moduler3  zDanalyzeline: Creating additional interface block (groupcounter=%s).
r  unknown_interface:unknown_r   r   r  prefixr      r  varnamesr  r   r   bindlanglang	lang_namer  variable)r  r
  r  r  r  r  r  r  ::r
  re  z"All arguments will have attribute r   r&  zXanalyzeline: cannot handle multiple attributes without type specification. Ignoring %r.
r  r  z&analyzeline: no name pattern found in z statement for . Skipping.
>   operator
assignmentr  __user__z8analyzeline: missing __user__ module (could be nothing)
z(analyzeline: appending intent(callback)  to z arguments
zanalyzeline: intent(callback) z is ignored
z=analyzeline: intent(callback) %s is already in argument list
)r  r  r  r  r  r  z(analyzeline: ignoring program arguments
r   implementedbyr  rq  zAanalyzeline: could not extract name,expr in parameter statement "" of ""
z1analyzeline: Overwriting the value of parameter "" ("z	") with "r4   r5   r#  ecomplexz+1j*(z analyzeline: Failed to evaluate z. Ignoring: r   nonez<analyzeline: Overwriting earlier "implicit none" statement.
z9\s*(?P<this>.*?)\s*(\(\s*(?P<after>[a-z-, ]+)\s*\)\s*|)\Zz@analyzeline: could not extract info of implicit statement part "zIanalyzeline: could not extract types pattern of implicit statement part "ro  rp  rr  -z2analyzeline: expected "<char>-<char>" instead of "z&" in range list of implicit statement
z*" in range list of implicit statement (2)
r  '/r6  r7  zanalyzeline: implied-DO list "z" is not supported. Skipping.
r   zComment line in declaration "z\(.*?\)(/, z/)c              3   ,   #    U  H
  nS U;   v   M     g7f)r   Nr'   ).0r   s     r)   	<genexpr>analyzeline.<locals>.<genexpr>  s     5W3!8Ws   r   z*analyzeline: changing init expression of "") to "r  z//)maxsplit_BLNK_r  zR\A\s*(?P<name>\b\w+\b)\s*((,(\s*\bonly\b\s*:|(?P<notonly>))\s*(?P<list>.*))|)\s*\Zrv  notonlyonlyz7\A\s*(?P<local>\b\w+\b)\s*=\s*>\s*(?P<use>\b\w+\b)\s*\Zlocalz-analyzeline: Not local=>use pattern found in mapz0analyzeline: Could not crack the use statement.
)r  r  usercodez-analyzeline: No context for multiline block.
z+analyzeline: No code implemented for line.
)Sr   r&   r   r   r   r   r   basenamer!   r(  r2   r   r=  r>  r   r   r   r   r   r  r  rw   r'  r   remover   r   r   r   r   rr   rv  rw  r)  copydeepcopyr[   r   r  crackline_bindlangr  rO  cracktypespec0
updatevarsfindrW  r   rX   namepatternr  r!  r  ro   get_parametersdetermineexprtyper  real16patternfinditerr  r   evalSyntaxError	NameError	TypeErrortypespattern4implicitcracktypespecr   ordchrr   removeprefix	enumerate
setdefaultgetdimensionfindall
IndexErroranyextendr8   r   
isinstancer   appendmultiline)Hr   r?   r0   r1  newnamerq   r  r   r5  r   	bindclinex
needmoduleneedinterfaceitr~  bindcdattr4   selectorattredecl	last_namer   iplchr  ra  apinitexprr  ttvr   implr{  rb  
kindselect
charselectrr  r   begcendcodlilrf  fcinpr   r0  r   idxvtypevdimmatchesnew_valexpanded_listr   
multipliervaluecurrent_valclbnol	commonkeymmisonlyr   r#  gcsH                                                                           r)   rY  rY    sb    GGFOE{{t#GG}!1''""?399#>qAKG9TXY	[#a'"+	,#%
< "$	,+-
< (+-
< (,5
< )+2
< (+4
< (++88OUBDD11 EXX(%66#EXX-ubdd;;(EF?3AGGG4DEND6@%5HJ|$V,T2DF,CAGGGDT,U)D<$%MMMN!6'5d';'A'A%'HJ'H!  ggi'HJ KD D:*B *OQ 
&&MZ55:l3F;;-f:% . z,/==)jA$GE=\R/LA4E'!+LJ?? !#a'#%
< "$	,{A]+,-.0&.Il#0?J|$W-/<J|$V,/1J|$V,/1J|$V,46J|$[157J|$\2/1J|$V,'!+L')J|$&(Il#{_ "#$&&1Il#0;J|$W-/BJ|$V,<!+,V4jPQAQ6RSY6Z0\J|$V,/1J|$V,46J|$[157J|$\2/1J|$V,'!+L')J|$&(Il#"'	,,1
< )c3 77D-.WWX->
< *+5d+;
< (-3
< *1/>J|$V,]|q0<!+,V4o0GJ|$V, <!+,V4jPQAQ6RSY6Z0\J|$V,j.3356Al+A..|,Q/ 7 ,0
< (+-
< (02
< -13
< .+-
< (,.
< )F?35J|$Z0&&:lQ&67DD<!+,[9@@F/3}}<!+,V406J|$V,|,V4T:|,V4T::FLLZXZ ..99%7C<@":J|,Z8IQX^I_J|,Z8>vF~~k22MU^^\gMh
<0<TB6J9C|,V4T:J|VWGW<XY_<`ac<d:f
<(06 y f
<(@(HH>AK&|4V<TBJ|D\]cDdekDlBn
<08><!+,\:AA$G JQ%%aggh&7#&=&DEA2@GGFOQWWW%537/(D%8XtU;&&lQ&'..z,/GH6?6MIlQ&'+F3,''!+LlQ&'..z,/GH6?6MIlQ&'+F3,''!+L ' 
 78H IF +9$+?+E+Ee+L"N+La #$'')+L"N O >/4</>6:J|$W-d3 '|<  
*8777#+%'(D%x4?	  *I|D !	n	n<(0WWW##%GGDMq5TX%r"''.2AFQUd"RAZ/BA!"v~&J|,D"D"Ra&2 3#((:l#;F#CDDq5ABBQBAEFBB%%e,r7Q;ABoAB " #	%3B%7%=%=e%DE%D'')%DEA""1%B00A!++-(d1g' (rxx/0,,6P1PRXXg&&~a{"BHHW--xWWV_r))//33
< 8 @@'!+)L1<L1Mf1UU '$_!a  !J|$<V$DD '@A:lC[\bCc)e !f *< 8 @ G G J#"@= QS   !69:!< =]]U1X%a$++B/(*ta$z!l+G4	AGHJ|4V<<j&>><>J|,[9<(5<<Q?Ii Fj ,1
< (  *I|D !	"	" ! 0 6 6s ;< ;1WWY ;< 	< 1		<(0WWW##%a+	#))%0A23''#,?,Qwwy,?8
 $E*F1A~aeAha(AuQx}h0 1!(F3A55$.hB*33H=04$QWWYquuw7==?GGSQ1S1779QUUW- >  "wwr{HUU:&)3'|113;;CEW- 2v.
 !GE!HSMU1X%a$++K8(3}a$II 1J ,1
< (  *I|D !		777!!#))+v537J|$Z0WWWl+//
B?D|SU#AGGG$45;;EBXXPRSUWUYUY[Z[\Z]]abd*00&1ABcdecffjkm2@HHV$bhhw&739/(D%3@h4(0
J#+Z '1^$'1^$#+Z diik*A77 G + ((9:@@GAax%=>WWS\)J\'')\)JJD$ '(ggi/tt9D	6Q6PQRPSS~A "3t9c$i!m<'+SV = H1 CP 48J|$Z0] ^ 
!A8B8AACxAgcAgAv!Va!VaXXZ==%%ABB		2r(#- ". 6B}}S!!V\\^IIr2h,'++FB7	A122371JAaD!A$ts##81>]^_#I.QRSTQUBVB\B\]bBc.dBcQwwyBc.d$efQ<<$$<QC?^_` !A$; ;AaD6A`ab2&QJ/#DG,:?9:L"**Z16RSTURVR\R\]`RaT=A499W#5"6b9ws|G& #1gkk#.K7$:H4P[}\cdkcllpqr&Q	W g b ,0
< ( *I|D 		www%%'Aw#~$;DhhsD15BXXZB
		2r(	z,//"<0:IAt9$"$	!A$)7!)=)C)CE)JK)JAggi)JK1adO**1- L  .7
< *$b,7	XXacdcjcjkrcsuwuyuy{BJ|4424
<(/88F#D46J|$U+D1F|6
 6?r)}'<F@F
<(/5f=)+F)9)9#)>?)>Aggi)>?AaxXXVXY[][_[_a<>HH %='',uw rxx06689 $"OPTUVPWyXZ [] !"1CEJ|,U3D9%@  !7|( !++- GH	%	%Z%==;=J|$%78|$%78776?j(Z1_!J---!":*jM  !12!"!1Aaggfo		#wHI
2(!,	) 
1akkm>? 
oJN      ."NL Ft = @ WXYWZZ`ac`ddhik0  I6 #S* +b *K( %#"TUVTWW~ A$%n /e* " T
 5W555(*%,E"e|!H8=C8H$5J$1$8$8%++-3z?9Z$['1 !H$1$8$8$G!H !. 4 4U[[] C &- #0=A499W#5"6b9ws|G#TV L& @sD  Aq!=7Aq& AAq7 ?"Ar ,Ar
ArAr#@Ar-@$Ar(@=Ar-F(AsP AtPAt	P,AtZ/At/^!At4c(Ax"h,Ax'q&
Aq4q3Aq4q7
ArrArr
ArrArr(Ar-r-AssAssAts&AttAtt	AttAt,t+At,t4.Axu#A Av%v#Axv%)AwwAxwAwwA	AxxAxc                 \    SU ;  a  0 U S'   U S   nX;  a  / X1'   X1   R                  U5        g )Nf2pymultilinesr)  )r   context_namemlr#  s       r)   r  r    s=    u$"$AO2r(   c                 h   S nS n[         R                  " SU [         R                  5      (       a  Sn OL[         R                  " SU [         R                  5      (       a  Sn OU R                  5       R	                  5       n [
        R                  [        U5      5      nU(       d  [        S5        g UR                  5       n[        UR                  5       5       H  n[        XV   5      XV'   M     U S;   a
  US   nUS   nUR                  S	5      nUS
:  a  US U R                  5       nXS-   S  nXX14$ )Nzdouble\s*complexdouble complexzdouble\s*precisionzdouble precisionz>cracktypespec0: no kind/char_selector pattern found for line.
)r  r7   logicalr5   	characterrh   r9  r  r  r   r2  )r   r   r   r   r   selectpatternrW  r2   r!  rv  rw  rl  r  )r4   r   r  r  ra  r#  r~  r  s           r)   r  r  !  s   HD	xx#Xrtt44#	'244	8	8%>>#))+			^B/	0BM	O
A!&&(^% QQV9wZ
AAv"1v||~AZt''r(   z)\s*(?P<name>\b\w+\b)\s*(?P<after>.*)\s*\ZzB\s*(\(\s*(kind\s*=)?\s*(?P<kind>.*)\s*\)|\*\s*(?P<kind2>.*?))\s*\Zz2\s*(\((?P<lenkind>.*)\)|\*\s*(?P<charlen>.*))\s*\Zz\s*(kind\s*=\s*(?P<kind>.*?)\s*(@,@\s*len\s*=\s*(?P<len>.*)|)|(len\s*=\s*|)(?P<len2>.*?)\s*(@,@\s*(kind\s*=\s*|)(?P<kind2>.*)|(f2py_len\s*=\s*(?P<f2py_len>.*))|))\s*\Zz\s*(@\(@\s*(?!/)\s*(?P<array>.*?)\s*@\)@\s*\*\s*(?P<len>.*?)|(\*\s*(?P<len2>.*?)|)\s*(@\(@\s*(?!/)\s*(?P<array2>.*?)\s*@\)@|))\s*(=\s*(?P<init>.*?)|(@\(@|)/\s*(?P<init2>.*?)\s*/(@\)@|)|)\s*\Zc                     U R                  5       n [        U 5      S::  a  U $ U S   n[        S[        U 5      S-
  5       H*  nX   S:X  a  XS-      S;   d  XS-
     S;   a  M#  XU   -   nM,     XS   -   nU$ )Nr   r   r   z()[]{}=+-/* r   )r   rX   r   )exprexpr2r  s      r)   removespacesr(  J  s    ::<D
4yA~GE1c$i!m$GsNq5k^+!e.Q % HELr(   c                     SnSnSnSnU  HM  nUS:X  a  US;   a  X-  nUnM  U(       d  US;   a  UnXS:X  a  U(       + nOUS:X  a  U(       a  US-  nMG  X-  nUnMO     U$ )	z
The function replace all spaces in the input variable line which are
surrounded with quotation marks, with the triplet "@_@".

For instance, for the input "a 'b c'" the function returns "a 'b@_@c'"

Parameters
----------
line : str

Returns
-------
str

r
   FN\)r*  r  ")r  r+  r   @_@r'   )r0   fragmentinsidecurrent_quoteescapedr   s         r)   markinnerspacesr1  Y  s      HFMGd?q$55MHG!{*MZF#X&H  Or(   c                 X   Sn[        X5      u  pVnU(       a  [        U5      R                  S5       Vs/ s H  oR                  5       PM     nn/ n	[        R
                  " S5      n
U Hd  nU(       d  M  U
R                  U5      nU(       a/  UR                  S5      R                  5       nX[        U5      S -   nU	R                  U5        Mf     U	n[        U5      R                  S5       Vs/ s H  oR                  5       PM     nn/ nU H}  n[        [        [        U5      5      SS9R                  S5       Vs/ s H  oR                  5       PM     sn H-  nU(       d  M  UR                  UR                  SS5      5        M/     M     U GH  n[        R                  U5      nU(       d  [        S	[!        U5       S
35        M:  [#        UR                  S5      5      n0 nU[$        [&           S   ;   Ga>  [$        [&           S   U   R)                  5       nSU;  nU(       a  U US'   O+U (       a$  U US   :X  d  [        SU< SUS   < SU < S35        SU;  a  [(        R(                  " U5      US'   OU(       a~  [+        UR-                  5       5       Ha  nUUS   ;   a6  UU   US   U   :X  d'  [        SU< SU< SUS   U   < SUU   < S3	5        MB  [(        R(                  " UU   5      US   U'   Mc     SU;  a)  U(       a"  U(       a  UUS'   O[/        SU< SU< S35        OU(       a~  [+        UR-                  5       5       Ha  nUUS   ;   a6  UU   US   U   :X  d'  [        SU< SU< SUS   U   < SUU   < S3	5        MB  [(        R(                  " UU   5      US   U'   Mc     SU;  a  UUS'   O+U(       a$  US   U:X  d  [        SU< SUS   < SU< S35        SU;  a  [(        R(                  " U5      US'   OU(       a(  U H"  nUUS   ;  d  M  US   R                  U5        M$     Oi[(        R(                  " U 5      US'   [(        R(                  " U5      US'   [(        R(                  " U5      US'   UUS'   [(        R(                  " U5      US'   SUR1                  S5      =(       d    / ;   aT  U[$        [&           S   ;   a@  S[$        [&           ;  a  / [$        [&           S'   [$        [&           S   R                  U5        UR                  S 5      (       Gav  [2        R                  [5        UR                  S 5      5      5      nU(       Ga!  UR7                  5       nS! H  nUUS"-      c  M  UUS"-      UU'   UUS"-   	 M!     [+        UR-                  5       5       H  nUU   b  [9        UU   5      UU'   M  UU	 M!     S#U;   a  S$U;   a  US#   S%:X  a  US$   US#'   US$	 OpU S&:X  a3  SU;  d
  US   (       d  0 US'   S#US   ;   a  US   S#	 US#   US   S''   US#	 O7US$   S(-   US#   -   US$'   US#	 [/        S)U < SU< S*U < SU< S+US$   < S,35        S#U;   ab  U S-;   a$  SU;  d
  US   (       d  0 US'   US#   US   S''   US#	 O8U S&:X  a2  SU;  d
  US   (       d  0 US'   S#US   ;   a  US   S#	 US#   US   S''   US#	 S.U;   a9  S/U;   a+  US/   US.   :X  d  [        S0U< SUS/   < SUS.   < S35        OUS.   US/'   S$U;   aq  S1US$    S23nSU;  d
  US   (       d  U/US'   OrUS   R                  U5        US    H4  nUSS3 S4:X  d  M  UU:w  d  M  US   S5	 [/        SU< S6U< S7U< S35          O#   O [        S8UUR                  S 5      -   -  5        [+        UR-                  5       5       H  nUU   (       a  M  UU	 M     U[$        [&           S   U'   S9[$        [&           ;   a  [$        [&           S9   R                  U5        UnGM     U$ s  snf s  snf s  snf ):z
Returns last_name, the variable name without special chars, parenthesis
    or dimension specifiers.

Alters groupcache to add the name, typespec, attrspec (and possibly value)
of current variable.
Nr%  z(?P<start>[a-zA-Z]+)r  r   rj  z@ @r,  z-updatevars: no name pattern found for entity=r  rq   r0  r4   z+updatevars: attempt to change the type of "r  r  z". Ignoring.
ro  z0updatevars: attempt to change the kindselector "r  rp  zupdatevars:z*: attempt to change empty charselector to r   z0updatevars: attempt to change the charselector "rr  z/updatevars: attempt to change the typename of "rn  r  r5  r3  r  )rX   arrayinit2rX   r4  r
   r#  r   r&  zupdatevars: "z" is mapped to "r6  z)"
r  r7   r"  r5   r5  rq  z6updatevars: attempt to change the init expression of "
dimension(r7  	   r  r   z: attempt to change r  z?updatevars: could not crack entity declaration "%s". Ignoring.
r  )r  r'  r(  r   r   r   r   r   r   rX   r)  r(  r1  r   r  r2   r   rr   r>  r   r  rv  rw  ro   r  lenarraypatternrW  r!  rl  )r4   r  rn  
entitydeclr  r  r  rr  r  r   r   r+  r   selel1r  e1enamer  not_has_typespecr~  ra  d1lkdmdm1s                              r)   r  r  ~  s
    I'4X'H$JH'5h'?'E'Ee'LM'L!GGI'LMJJ./A
AGGG$**,#a&'
NHHQK  +J7==eD	ED'')DB	E
C&4\/RSBT5U]`&a&g&ghm&no&n779&noBr

2::eS12 p  a ?QyVX1776?+J|,V44|,V4U;@@BE)6$,j!8uZ/@#@5,h8 9U*(,		*(=n%joo/0AE.11:a=ER`LabcLd;dueN&;A&>
1!O P 4899Z]3Kn-a0 1 U*z#,6E.)$j2 3joo/0AE.11:a=ER`LabcLd;dueN&;A&>
1!O P 4899Z]3Kn-a0 1 &$,j!5#4#@5,h8 9&$(IIh$7j!!Aj 11j)003 " !%		( 3E*$(IIj$9E.!$(IIj$9E.! (E* $		( 3E*%))J/5261
<@XY_@`;`*\"::8:
<(5|$[188;777 &&~aggg6F'GHB\\^2B"s(|/!#BH2rCxL 3 bggiA!u( 0A 71qE	 ) B;7b=%yB$&wK5	wK![0*%7~AV46E.1 E.$99 %n 5e <57Yn-c2uI&(kC&7"U)&C7uI$a5"W+!G H B;#LL*%7~AV46E.157Yn-c2uI![0*%7~AV46E.1 E.$99 %n 5e <57Yn-c2uIR<e|U3Z2f:-E!5:r&z!; < &(Zc
b=%bk]!4B!.uZ7H-/Dj)j)004#(#4C"2Aw+5#)$)*$5b$9 '+0#r); !< % $5 ZAGGG,,. /ejjl#A88!H $ 38
< (/L11|$Z077>	K L q N 
F ps   `/`">`'c                    S nS nS nU(       GaT  U S;   a  [         R                  U5      nU(       d  [        S[        U5       S35        g UR	                  5       nUS   US'   US	 [        UR                  5       5       H  nX%   (       a  M  X%	 M     [        UR                  5       5       H  u  pV[        U5      X%'   M     GOU S:X  Ga"  [        R                  U5      nU(       d  [        S[        U5       S35        g UR	                  5       nUS   US'   US	 US	   (       ah  [        R                  [        US	   5      5      nUR	                  5       nS
 H#  nXxS-      (       a	  XxS-      Xx'   Xx   X8'   XxS-   	 M%     US   b  US   US'   US		 [        UR                  5       5       H  nX5   (       a  M  X5	 M     [        UR                  5       5       H  u  pV[        U5      X5'   M     OwU S:X  aY  [        R                  " SU[        R                  5      nU(       a  UR                  S5      nO2[        S[        X-   5      -  5        O[        S[        U5       S35        X#U4$ )Nr7  z1cracktypespec: no kindselector pattern found for r   kind2r   r#  z1cracktypespec: no charselector pattern found for charlenlenkind)rX   kindr6  f2py_lenrh   z\s*\(\s*(?P<name>\w+)\s*\)rq   z'cracktypespec: no typename found in %s
z$cracktypespec: no selector used for )ro  r   r2   r   r!  rv  rw  itemsrr   rp  lenkindpatternr'  r   r   r   )	r4   r  r  r  rr  r~  r  rI  rC  s	            r)   r  r  '  s\   JJH@@%++H5JGXGWWYZ\#--/J(1JsO7#*//+,!}}" - Z--/0 *1
 1$%++H5JGXGWWYZ\#--/J(3JsO9%)$(..":i#89;!++-)BCx(&-3h&7%,[JNS)	 *
 :&2-4Z-@Jz*9%*//+,!}}" - Z--/0 *1
 1xx =xNH#>>&1Bh124 5 :4>:J"MN8++r(   c                    U (       d  0 n U(       d  U $ SU ;  a  U/U S'   U $ U(       a  U S   R                  U5        XS   ;   a  U $ US:X  a  SU S   ;  a  U S   R                  U5        U $ US:X  a  SU S   ;  a  U S   R                  U5        U $ US:X  a  SU S   ;  a  U S   R                  U5        U $ US:X  a  SU S   ;  a  U S   R                  U5        U $ U S   R                  U5        U $ )Nrn  rJ   	automaticr  r  r  )r{  r  r}  s      r)   rx  rx  b  s+    6ZZ%JxKtJ/??Z% K 
	j1A!AZ% K 
	D,,##D) K 
	4
++##D) K 	Z%Kr(   c                     U (       d  0 n U(       d  U $ SU ;  a  XS'   U $ [        UR                  5       5       H  nU(       d
  X0S   ;  d  M  X   U S   U'   M      U $ )Nro  rv  rw  r{  selr}  r~  s       r)   ry  ry  }  sa    T!"^#((*A.11&)fD #  Kr(   c                     U (       d  0 n U(       d  U $ SU ;  a  XS'   U $ [        UR                  5       5       H  nU(       d
  X0S   ;  d  M  X   U S   U'   M      U $ )Nrp  rQ  rR  s       r)   rz  rz    sa    T!"^#((*A.11&)fD #  Kr(   c                     SU ;   a  U S   $ U$ )Nrq   r'   )r1  unknowns     r)   getblocknamerW    s    V}Nr(   c                 D     SU S    SU S    S3q g ! [         a     g f = f)NzIn: r  r  rq   r   )r    r   )r1  s    r)   setmesstextrY    s6    !%-%-C s    
c                 f    0 nSU ;   a  [        U S   5      nSU ;   a  UR                  U S   5        U$ )Nparent_blockr  )get_usedictupdate)r1  usedicts     r)   r\  r\    s:    GeN34~uU|$Nr(   c           
         Uc  0 n[        U 5      nU(       d  U$ [        UR                  5       5       H  u  p4UR                  5       nU[        ;  a%  [        SU< SU R                  S5      < S35        MD  [        U   n[        U5      nU(       d  Ma  U(       a  [        SU S35        [        UR                  5       5       H4  u  pxXq;   a&  [        S[        U5      < S[        U5      < S35        XU'   M6     M     U$ )	Nzget_useparameters: no module z info used by rq   r   zget_useparameters: mapping for z not impl.
z(get_useparameters: overriding parameter z with value from module )
r\  rv  rL  r   r   r2   r  r  ro   r   )	r1  	param_mapr^  usenamemappingmvarsr  r~  r   s	            r)   get_useparametersrd    s     	% G 1--/-'eii/1 2g&&5gYlKL(DA~59!Wd7mM NaL	 ) 2& r(   c           	         [         (       d  U $ [        U [        5      (       a  U  Vs/ s H  n[        X1S-   US9PM     nnU$ [	        U 5        [        U SU S    S3S5        Uc  [        U 5      nUbW  SU ;   aQ  U S   n[        UR                  5       5       H/  nXV   nSU;   d  M  US   nS	U;   d  M  US	   n	X;   d  M(  X)   US	'   M1     U S
    V
s/ s H  n
[        XS-   US9PM     nn
XS
'   U $ s  snf s  sn
f )Nr   )tabr`  Block: rq   r   r   r0  ro  rJ  r/  )r   r  rv  
postcrack2rY  r2   rd  rw  )r1  rf  r`  gretr0  r   varrJ  valbnew_bodys               r)   rh  rh    s)    =%1 !tyA 	 
se75=/,a0%e,	5V}diik"A'C$>*T>v,C''0~V # v(&A 1*	B&  (&ML/&(s   C0C5c                 N   [        U [        5      (       a[  / n/ nU  HM  n[        U5        [        XRS-   S9nSU;   a  SUS   ;   a  UR	                  U5        M<  UR	                  U5        MO     XC-   $ [        U 5        [        U [
        5      (       d  SU ;  a  [        S[        U 5      -   5      eSU ;   a  U S   S:X  d  [        U SU S    S	3S
5        [        U 5      n [        U 5      n [        U 5      U S'   [        U S   5      U S'   U R                  S5      (       a  U S   n[        XUS9U S'   / nSU ;   a?  U S   n[        UR                  5       5       H  nSU;   d  M  UR	                  U5        M     O0 nSn	SU ;   a  U S   n	U R                  S5      (       Ga~  / n
SU ;   a  U S   n
[         R                   " U S   5      nU	(       a  U	S-   nOSnX;   a&  SnU SU 3U;   a  US-   nU SU 3U;   a  M  U SU 3nS/ 0 U	S-   S.nU S    H  nX;   a  / nSnU S    H  nUS-   nUS   S:X  d  M  SnUS    H7  nUS-   nSU;   d  M  US   U:X  d  M  [         R                   " U5      nUS   U	   O   U(       d  M^  US   (       d  U S   U	 XR#                  U5      	   O   US   R	                  U5        M  X;   d  M  [%        X   5      (       a  M  X   US   U'   M     US   (       d
  US   (       a(  XS'   SU/0 XS   S.n0 X|'   [&        R	                  U5        U(       a  XpS'   U $ )zY
TODO:
      function return values
      determine expression types if in argument list
r   rf  rq   r  r1  z0postcrack: Expected block dictionary instead of r  rg  r   r   r0  sortvarsr5  r/  r  r
   r3  r4  __user__routinesunknown__user__routinesr   r   r  _user_interface)r1  r/  r0  rq   r   r  )r1  r/  r0  rq   r4  )r  rv  rY  	postcrackr)  dictr   r   r2   analyzeargsanalyzecommonanalyzevarssortvarnamesr  analyzebodyrw  r  r[   
isexternalr   )r1  r5  rf  greturetri  userisdefineduseblockr~  rq   r4  rc  mnamer  r  r  edefjrm  bbmblocks                        r)   ru  ru    s~    %AN!t,A{zQvY6AA  {eT""we';JE
# $ 	$uV}0CC3%wuV}oR0!4E% E&E&M$U6]3E*yyV}5E&MM~<hmmo&AQ$$Q' ' DV}yy
5 |,J		%-(--E-E!AG1QC.M1E G1QC.M1gQqcNE)20A)AC	{#AvAAAz[0"#F)B !AA%|6
a'+yy}$%fIaL % #,  4#$V9$)&M!$4 *+;+;A+> ?! ' &!((.Jux$8$8',x	&!!$+ $, V	& 1",,.9$&;EWYF HOv&eLr(   c                    / n/ n[        U R                  5       5       H;  nSX   ;   a  X   S   (       a  UR                  U5        M*  UR                  U5        M=     [        U5      nSnU(       a  US   nSnUSS   H  nXpU   S   ;   d  M  Sn  O   U(       a;  USS  U/-   nUS-   nXT:  a'  [	        SSR                  U5      -   S-   5        X-   n U$ O#UR                  U5        USS  n[        U5      nSnU(       a  M  U$ )Nru  r   r   zTsortvarnames: failed to compute dependencies because of cyclic dependencies between r  r   )rv  rw  r)  rX   ro   r   )r0  indepdepr   r   r  r^  ws           r)   rz  rz  Q  s'   E
C$))+tw478#4JJqMLLO	 
 	CA	A
FQRAGH%%  ab'QC-CAAu ;))C.)+/0 1  L  LLOab'CCAA) #* Lr(   c           	         [        U 5      (       d  U $ / n[        U S   R                  5       5       GH  n/ nU S   U    GH  n[        R                  " SU[        R
                  5      nU(       Ga.  / nUR                  S5      (       aG  [        UR                  S5      5      R                  S5       Vs/ s H  nUR                  5       PM     nn[        UR                  S5      R                  5       5      nXS   ;   aZ  SU S   U   ;   a.  U S   U   S   R                  SS	R                  U5       S
35        ONSS	R                  U5       S
3/U S   U   S'   O.U(       a  SSS	R                  U5       S
3/0U S   U'   O0 U S   U'   X;  a  UR                  U5        OUn[        SU SU S35        UR                  U5        GM     X0S   U'   GM     SU ;  a  XS'   U $ U S   U-   U S'   U $ s  snf )Nr  z2\A\s*\b(?P<name>.*?)\b\s*(\((?P<dims>.*?)\)|)\s*\Zdimsr%  rq   r0  rn  r8  r&  r7  z:analyzecommon: failed to extract "<name>[(<dims>)]" from "z" in common /z/.

commonvars)	hascommonrv  rw  r   r   r   r   r'  r(  r   rr   r)  r   ro   )	r1  r  r~  comvarsr  r   r  r  r   s	            r)   rx  rx  s  s   UJ%/&&()x#AEq"$$PA776??%3AGGFO%D%J%J5%QS%Q GGI%Q  Sqwwv4467f%!U6]1%55fa(4;;($(8:< )$(8:8<fa(4"z#((4.1A%C$D(FE&M!$ (*E&M!$&%%a(PQRPSS`ab`ccghjNN17 $8 %h= *> 5 (l L $L1J>lL7Ss   4G.c                    [        U 5        U S   R                  5        VVs0 s H  u  p4SU;  d  SUS   ;  d  M  X4_M     nnn/ nU S    GH$  nXS'   US   S;   az  Ub  US   U;  a  M  US	   nUS   UR                  5       ;   a  [        R	                  US   5        US   [        ;   a  Mb  [
        (       a  US   [
        ;  a  M|  [        US
SS9US'   OUn[        XxUS-   S9nUS   S;   a(  US   (       d  UR                  S5      (       d  SU;  a  M  US   R                  SS5      S:X  a  [        R	                  U5        M  US   S:X  a  US   [        US   '   UR	                  U5        GM'     U$ s  snnf )Nr0  rn  r  r/  r[  r1  r  rq   r5  z
      Tas_interfacesaved_interfacer   rp  r  r  r  r   r
   pythonmoduler  )rY  rL  rw  r#   r)  r$   crack2fortrangenru  r  r   r   r   )	r1  r5  rf  keyr  maybe_privater/  rm  as_s	            r)   r{  r{    s      ---//JCU"heJ6G&G 	
/   D6]!.W:33AfIT$9iyM..00  6+yI%yQvYi7#3>$6A  Ca#*-W:<<y!7!7!*W:c2&.8q!zX%+,V9ai(KKN; < KKs
   E6E6c                 H   [        U 5        [        n0 nSU ;   a  U S   c*  S n[        S:  a  [        S[	        U S   5       S35        X4$ [        U S   R                  5       5       H7  nU S   U   R                  S5      S;  a  U S   U   X'   M*  U S   U   S   X#'   M9     X4$ )Nr   r   z2buildimplicitrules: no implicit rules for routine rq   r8  r4   )rJ   rO  )rY  defaultimplicitrulesr   r2   r   rv  rw  r  )r1  implicitrules	attrrulesr~  s       r)   buildimplicitrulesr    s    (MIU$ M{HeTZmI\H]]`ac ## %
+0023$Q'++J7?VV',Z'8';M$#(#4Q#7
#CIL	 4
 ##r(   c                 n    [        XU5      n[        U5      [        [        4;   a  U$ [	        SU< 35      e)z1Like `eval` but returns only integers and floats zr=)r  rh   r8   r:   r   )r  ri  r   r   s       r)   myevalr    s3    Q1AAw3,
r!Z
  r(   z\A\b\w+\b\Zc                 V    [        [        U 0 0 5      5      nSUS4$ ! [         a     Of = f[        R	                  U 5      (       a  SSU 4$ [        U 5      nU GHL  n[        U5      U:  a  M  [        R                  " SU-   S-   U 5      (       a  M9  [        R                  " SU-   S-   [        R                  5      nUR	                  U 5      nU(       d  M~   UR	                  U 5      nU(       aB  UR                  S5       S	S S
UR                  S5       3nUR	                  U5      nU(       a  MB  [        W0 0 5      n	UR	                  U 5      nU(       aB  UR                  S5       S	S S
UR                  S5       3nUR	                  U5      nU(       a  MB  [        U0 0 5      U	-
  n
UR	                  U 5      nU(       aB  UR                  S5       S	S S
UR                  S5       3nUR	                  U5      nU(       a  MB  [        U0 0 5      nUR	                  U 5      nU(       aB  UR                  S5       S	S S
UR                  S5       3nUR	                  U5      nU(       a  MB  [        U0 0 5      nU
S-  U	-   U:X  a  U
S-  U	-   U:X  a  XU4s  $ O! [         a     Of = f  g   g)a  
Obtain ``a`` and ``b`` when ``e == "a*x+b"``, where ``x`` is a symbol in
xset.

>>> getlincoef('2*x + 1', {'x'})
(2, 1, 'x')
>>> getlincoef('3*x + x*2 + 2 + 1', {'x'})
(5, 3, 'x')
>>> getlincoef('0', {'x'})
(0, 0, None)
>>> getlincoef('0*x', {'x'})
(0, 0, 'x')
>>> getlincoef('x*x', {'x'})
(None, None, None)

This can be tricked by sufficiently complex expressions

>>> getlincoef('(x - 0.5)*(x - 1.5)*(x - 1)*x + 2*x + 3', {'x'})
(2.0, 3.0, 'x')
r   Nr   z\w\s*\([^)]*\b\b(?P<before>.*?)\b\b(?P<after>.*)r  r6  r7  r  g      ?g      ?)NNN)r8   r  r   getlincoef_re_1r   rX   r   r  r   r   r   )r  xsetr   len_er  r`  r   ra  eerm  r+  c2s               r)   
getlincoefr    s   *q"b!"!Tz Q!QwFEq6E>99&*U2A66zz.25GGNJJqM1ZZ]HHX./q1RXXg5F4GHBBB b 2r2&ZZ]HHX./q1RXXg5F4GHBBB b 2r2&*ZZ]HHX./qQrxx7H6IJBBB b 2r2&ZZ]HHX./qQrxx7H6IJBBB b BB'GaK1$S1):7N I H s:    
**AJ2A%JA(JA%J*(J
J#"J#z\b[a-z][\w$]*\bc                    X;   a  X   R                  S/ 5      nSX   ;   aY  [        X   5      (       dG  [        R                  X   S   5       H)  nXC;  d  M
  XA;   d  M  X@:w  d  M  UR	                  U5        M+     US S   HG  nUR                  U/ 5      =(       d    [        XAU5       H  nXS;  d  M
  UR	                  U5        M     MI     O[        S[        U 5       S35        / nX2U '   U$ )Nru  rq  z)_get_depend_dict: no dependence info for r   )r  isstringword_patternr  r)  _get_depend_dictr2   r   )rq   r0  depswordswordr  s         r)   r  r  /	  s    |
x,$*Xdj%9%9$,,TZ_= $$,LL&	 >
 !HDXXdB' :'D9:>LLO:  	;DJ<rJKJLr(   c                 f    [        U R                  5       5      n0 nU H  n[        X0U5        M     U$ r,   )rv  rw  r  )r0  ru   depend_dictr   s       r)   _calc_depend_dictr  E	  s1    EK+. r(   c                    [        U 5      n/ n[        UR                  5       5       H!  nX   (       a  M  UR                  U5        X	 M#     U(       ad  [        UR	                  5       5       H>  u  p4U Vs/ s H  oUU;   d  M
  UPM     nnU(       d  UR                  U5        X	 M:  XaU'   M@     U(       a  Md  U Vs/ s H  o3U ;   d  M
  UPM     sn$ s  snf s  snf r,   )r  rv  rw  r)  rL  )r0  r  ru   rq   lstr   new_lsts          r)   get_sorted_namesr  M	  s    #D)KE[%%'(  LL! ) k//12ID"%:#Qk)9q#G:T"%$+D! 3 + #3UTdlDU33 ; 4s   5	CC;	CCc                     U S   S;   a  U SS n [         R                  U 5      (       a  g[        R                  U 5      (       a  gSU -   S-   $ )	Nr   '"r   r         zkind(r7  )r  r   real8pattern)rc   s    r)   
_kind_funcr  _	  sQ    ayE"6""			F	#	#Vc!!r(   c                 Z    SU -  nUS::  a  gUS::  a  gUS::  a  gUS::  a  g	USS
-  ::  a  gg)Nr      r   i   r2  l        r  l            r        r   r'   )r   r   s     r)   _selected_int_kind_funcr  j	  sD    
aAF{G|G|G|AH}r(   c                     U S:  a  gU S:  a  g[         R                  " 5       R                  5       nUR                  S5      (       a	  U S::  a  g g	U S:  a  gU S::  a  gg	)
N   r  r  r  )
aarch64alphaarm64	loongarchmipspowerppcriscvs390xsparc!      r   r   )platformmachiner   r   )pr   radixr  s       r)   _selected_real_kind_funcr  z	  sn     	1u2v &&(Gwxx7  	 
R	
br(   c           	         [         R                   " U5      n[         R                   " U5      nS[        4S[        4S[        44 H  u  pEXC;  d  M  XSU'   M     / n[	        U 5       H+  nSX   ;   d  M  SX   S   ;   d  M  UR                  U5        M-     [        R                  " S[        R                  5      n[        R                  " S[        R                  5      n	[        R                  " S[        R                  5      n
U GH)  nS	X   ;   Ga  X   S	   n[        X   5      (       a(  UR                  5       nS
 H  nUR                  " U6 nM     UR                  SU5      nU	R                  SU5      nSnSX   ;   aA  SX   S   ;   a6  [        U5      nUR                  SX   S   S   -   S5      n[        U5      U:  nU(       dy  U
R                  U5      (       dc  UR                  S5      n[        U5      S:  aC  SR!                  US S 5      R                  5       R                  US   R                  5       S5      n[#        X   5      (       a  [%        U5      n[&        R)                  U5       Hj  n[%        UUR+                  5       UR-                  5        R                  5       R                  SS5      5      UUR+                  5       UR-                  5       & Ml     SR!                  U5      nO![/        X   5      (       a  [1        SU S35        X   S    Vs/ s H:  nUR3                  S5      (       d  M  UR5                  S5      R7                  5       PM<     sn=(       d    S /S   n[&        R9                  U5      (       a  SnO[:        R9                  U5      (       a  Sn [=        XUUS9X''   [A        X   5      (       a&  [C        X'   [D        5      (       a  [G        X'   5      X''   UR                  5       nUU:w  a
  X'   UU'   GM	  GM  [I        X   5        [1        SU< S35        GM,     U$ s  snf ! [>         a!  nXU'   [1        SU SU< S35         S nANS nAff = f) NrJ  selected_int_kindselected_real_kindrn  r  z \bkind\s*\(\s*(?P<value>.*)\s*\)z-\bselected_int_kind\s*\(\s*(?P<value>.*)\s*\)z4\bselected_(int|real)_kind\s*\(\s*(?P<value>.*)\s*\)rq  ))z.false.False)z.true.Truez
kind("\1")zselected_int_kind(\1)Fro  r   r
   r   r   r#  r  zAget_parameters[TODO]: implement evaluation of complex expression r   r  r   r  r  )dimspeczget_parameters: got "" on zget_parameters:parameter z does not have value?!
)%r  r  r  r  r  r)  r   r   r   	islogicalr   r   subrX   r   r(  r   isdoublerv  r  r  r  r   	iscomplexr2   r   r  r   r  r  
param_evalr   r  r  r8   r  r  )r0  global_paramsr  g_paramsrq   funcparam_namesr   kind_reselected_int_kind_reselected_kind_rer   replis_replaced
orig_v_lenv_r  r   r<  r  r   nls                         r)   r  r  	  s   YY}%Fyy'H
++-DE,.FGK
 !TN	K
 Kd# [DGJ4G%Gq! $ jj<bddCG::8"$$@zz?G$'>A!!GGID
 		4(A M1-A$(()A1EA  K( TW^44!$QJ		#(?(G"GLA #&a&:"5K'--a00B2w{GGBsG,224<<RV\\^RP   !W&//2A,0!'')AEEG,224<<S#F-HBqwwy) 3 GGBK47## FFGSL M "&!45!4A,,{3 <{399;!45 ?9=CG ##A&&$$Q''C&qFGL	
   Z	3%?%?	N	BQw#Yr
  $'N/u4LMNa b M15  Cq	/uE!bABBCs$   P5<#P5)P::
Q%Q  Q%c                 &    U S;   a  g[        X5      $ )N)z(:)(*)r   r  )_eval_scalar)lengthr  s     r)   _eval_lengthr  	  s    $$''r(   z\d+_c                 v   [        U 5      (       a  U R                  S5      S   n  [        U 0 U5      n [        U [        5      (       a  [
        O[        " U 5      n U $ ! [        [        [        4 a    U s $ [         a:  n[        SU< SU < S[        UR                  5       5      < S35         S nAU $ S nAff = f)Nr   r   r+  z" in evaluating z (available names: r   )_is_kind_numberr(  r  r  r   r   r  r  r  r   ro   rv  rw  )r  r  r   s      r)   r  r  	  s    uC #	5UB'#E3//S8%@ L {I.  5tFKKM24 	5 	5 L	5s   4A B85	B8>/B33B8c                 "  ^@^A [        U 5        [        U 5      u  p[        R                  " U S   5      nU S   S:X  a  U S   U;  a  0 X0S   '   SU S   ;   as  US	 SU S   S   ;   ad  U S   S   S   n[        U5      U S    Vs1 s H  oUS   iM	     sn-   H1  nS H(  nXt;   d  M
  [	        UR                  U0 5      U5      X6'   M*     M3     / nU S	   n	U	 H  n
 X:     UR                  U
5        M     [        UR                  5       5       H  nXi;  d  M
  UR                  U5        M     [        U[        U 5      5      n0 n[        R                  " S
5      R                  n[        UR                  5       5       H9  nU" U5      nU(       d  M  XR                  5       UR!                  5        n X     M;     U G
H  nUS   [        UR                  5       5      ;   a  [	        X6   X&S      5      X6'   SX6   ;  a  SX6   ;   a  SX6   S   ;   d  U(       a  US   R%                  5       n[        UU   R                  5       5       HU  nUS:X  a  UU   U   S:X  a  M  XsU   ;  a  UU   U   X6   U'   M.  US:X  d  M6  UU   U    H  n[	        X6   U5      X6'   M     MW     O(X`S	   ;   a   ['        S[)        U5      < SU S   < S35        SX6   ;   a6  SX6   S   ;   a+  X6   S   S   n [+        [-        U0 U5      5      nUX6   S   S'   SX6   ;   a6  SX6   S   ;   a+  X6   S   S   n [+        [-        U0 U5      5      nUX6   S   S'   0 nSX6   ;   Ga  X6   S   nUR1                  5         / X6   S'   Su  nnnnnU GH  n
U
SS S:X  a  U
SS R3                  5       SS nOU
SS S:X  a  U
SS R3                  5       SS nOpU
SS S:X  a  U
SS R3                  5       SS nOPU
SS  S!:X  a  U
S S R3                  5       SS nO0U
SS" S#:X  a  U
S"S R3                  5       SS nO[	        X6   U
5      X6'   U(       a  SX6   ;  a  / X6   S'   [5        U5      R7                  S$5       Vs/ s H  nUR3                  5       PM     sn H8  nUR9                  S%S5      nUX6   S   ;  d  M"  X6   S   R                  U5        M:     SnU(       aM  UR9                  S&S'5      nUR9                  S(S)5      nS#X6   ;  a	  U/X6   S#'   OX6   S#   R                  U5        SnUb}  SX6   ;  a  / X6   S'   [;        [5        U5      R7                  S$5       Vs/ s H  nUR3                  5       PM     sn5       H&  nUX6   S   ;  d  M  X6   S   R                  U5        M(     SnUc  GM  S!X6   ;  a  / X6   S!'   [5        U5      R7                  S$5       Vs/ s H  nUR3                  5       PM     sn H&  nUX6   S!   ;  d  M  X6   S!   R                  U5        M(     SnGM     U(       Ga  SX6   ;  Ga  / X6   S'   [;        [5        U5      R7                  S$5       Vs/ s H  nUR3                  5       PM     sn5       GH  n [=        UU5      nUS+:X  a  S+OS,nUU:X  a  U/nO[5        US+5      R7                  S-5      n[C        U5      S.:X  a  S,U;   a  S,/nS,n[C        U5      S:X  a  US   U:w  a  S/US   /n[C        U5      S.:X  Ga'  [E        [F        RH                  RJ                  U5      u  nn U U-
  S-   n!U!RM                  [F        RN                  RP                  S09n0 n"U S    H  n[F        RR                  " U5      n#U!RU                  U#5      (       d  M1   U!RW                  U#5      u  pX4S1 jn$[        U
RY                  5       5      n%U%R[                  URY                  5       5        U% V#s1 s H!  n#U#R^                  U;   d  M  U#R^                  iM#     n'n#U$[        U'5      4U"U'   M     U"UU'   X6   S   R                  U5        GM     S!X6   ;  Ga  S	U ;   Ga  X`S	   ;   Ga  X6   R                  S/ 5      n(/ n)[a        [b        [d        [f        5      " X6   5      n*[i        X6   5      (       Ga  [k        X6   S   5       GH  u  n+nUR                  U5      m@T@c  GOU*(       Gaz  T@Rm                  5        GHe  u  nu  n,n-U@UA4S2 jmA[        5       n.TA" UU.5        UU(;   d  S3X>   ;   d  SX>   ;   a  M<  U,b~  UU.;  ax  S4n/U," [F        RR                  " S5U S6U+ S735      5      n0U0RM                  [F        RN                  RP                  S09n0U0X>   S3'   U/U--   X>   S'   S!X>   ;  a  S5U S6U+ S8U 3/X>   S!'   O]S9n/SX>   ;  a  / X>   S'   S:X>   S   ;  a  X>   S   R                  S:5        U(R                  U5        U)R                  S5U S6U+ S8U 35        X>   R                  S/ 5      n1S;U1;   d   S<U1;   d  U1R                  U/(       a  S<OS;5        U1(       d  GM^  U1X>   S'   GMh     T@c  GM  T@Rm                  5        H  u  nu  n,n-X>   R                  S/ 5      n'X>   R                  S/ 5       H]  n2U2Ro                  S5      (       d  M  SRq                  U2R7                  5       5      n2U'Rs                  U2S=S R7                  S>5      5        M_     U'(       a  [        [        U'5      5      X>   S'   UU';  d  M  U(R                  U5        M     GM     Ou[u        X6   5      (       ac  SX6   ;   a[  S,X6   S   ;   a  [w        X6   S   S,   U5      n3U3X6   S   S,'   O1SX6   S   ;   a&  [w        X6   S   S   U5      n3X6   S   S	 U3X6   S   S,'   U)(       a  U)X6   S!'   U((       a  [        [        U(5      5      X6   S'   S3X6   ;   d  G
M  SX6   ;  a  / X6   S'   S;X6   S   ;  a!  S<X6   S   ;  a  X6   S   R                  S;5        SX6   ;  ad  / X6   S'   [        URm                  5       5       H/  u  pU" X6   S3   5      (       d  M  X6   S   R                  U5        M1     X6   S   (       d  X6   S	 [y        X6   5      (       d  G
M  [{        X6   S3   U5      X6   S3'   G
M     [        UR                  5       5       GH  nX`S   :X  d  M  S#X6   ;   a
  X6   S#   U S#'   U S   S:X  d  M+  S?U ;   a  U S?   U;   a  [}        X6   X0S?      5      X6'   S@U ;   d  MW  U S@   n4U4R9                  SAS5      n5U4U5:X  + n6U5R9                  SBS5      n4U4U5:X  + n7[~        S   R                  U45      nU(       a  [        UR                  SC5      UR                  SD5      5      u  n8n9nn:[        U8U95      u  n;n<n=U8X6   S'    U S?   (       a
  U8X0S?      S'   U;(       a!  SU;;   a   [-        U;S   0 U5      U;S'   U;X6   S'   U<(       a  U<X6   S'   U=(       a  U=X6   SE'   U6(       a  [	        X6   SA5      X6'   U7(       a  [	        X6   SB5      X6'   GM{  GM~  ['        SF[)        U S@   5       SG35        GM     U S   SH;  Ga  SIU ;   a   [        R                  " U S	   U SI   -   5      n>O[        R                  " U S	   5      n>[        UR                  5       5       H7  n[a        [        [        5      " X6   5      (       d  M&  U>R                  U5        M9     SJU ;   av  U>Rs                  [        U SJ   R                  5       5      5        [        U SJ   R                  5       5       H+  nU SJ   U    H  nUU>;  d  M  U>R                  U5        M     M-     U S   S:X  a/  S?U ;   a  U>R                  U S?   5        OU>R                  U S   5        U S   SK;   a  U S   n?U?U;   a  SUU?   ;   a  UU?   S   U S'   U S   SL:X  a(  U>Rs                  [        UR                  5       5      5        [        UR                  5       5       H  nUU>;  d  M  X6	 M     U$ s  snf ! [         a     GMz  f = f! [         a9    [        R                  " SU-  [        R"                  5      R                  X'    GM  f = f! [.         a     GNf = f! [.         a     GNf = fs  snf s  snf s  snf s  snf ! [>        [@        [        4 a    ['        S*U< S)35         G
Nf = f! [\         a&  n&Sn$[        U!RY                  5       5      n% Sn&A&G	N[Sn&A&ff = fs  sn#f ! [.         a     GNrf = f! [.         a     GNbf = f)Mz@
Sets correct dimension information for each variable/parameter
r0  r1  r   rq   r
   rn  r/  r  r5  z[A-Za-z][\w$]*z.*\b%s\br   r4   r  	undefinedz"analyzevars: typespec of variable z is not defined in routine r8  rp  rX   ro  rJ  )NNNNNNr9  r  r   r   r   r
  ru  r   rt  r  rs  r%  r   z\n\nz

z\n r   z4analyzevars: could not parse dimension for variable r  r   z@:@r2  1)languagec                     X-
  U-  $ r,   r'   )r<  r+  rm  s      r)   solve_vanalyzevars.<locals>.solve_v
  s    01{(:r(   c                    > TR                  U S / /5      S    H#  nX!;  d  M
  UR                  U5        T" X!5        M%     g )Nr   )r  add)r   r  v1coeffs_and_depscompute_depss      r)   r  !analyzevars.<locals>.compute_deps
  s<    *9*=*=a$*LQ*OB')~(,(4R(> +Pr(   rq  Fzshape(r  r7  z) == Tinr  r  r  r&  r   r  pure	recursiver9  r  rr  zanalyzevars: prefix (z) were not used
)r  r  r  r  r  r  )r   r   rh   )ErY  r  r  r  rx  r  r)  KeyErrorrv  rw  r  rd  r   r   r   r  r   r   r   r2   r   r   r  r   reverser   r'  r(  r   rw   param_parser   r  rX   r  r   ExprparsetostringLanguager   	as_symbolr  linear_solvesymbolsr]  RuntimeErrorr  l_orisintent_inisintent_inoutisintent_inplaceisarrayr  rL  r   r   r  r  r  isscalarr  r  rO  r  r   r  isintent_callbackisintent_aux)Br1  r  r  r0  genrm  r   r~  svarsr5  r+  r  dep_matches
name_matchr   r   ln0r   dimension_exprsr  dimr
  ru  rt  rs  r  r   tmpr#  dim_charr  rB  d2dsizesolver_and_depsr<  r  all_symbolsr   v_depsn_depsn_checks
n_is_inputr  solverr  all_depsis_requiredr5  v_attraar  prpr1ispureisrecr4   r  r  r  r  rr  
neededvarsrq   r  r  sB                                                                   @@r)   ry  ry  

  s    1%8M99U6]#DW~#fT(A 6]	U6]Hvr**-#J/CYU6]!C]F)]!CC.Ax"-dhhq"oq"A / D E=D	GLLO  $))+=LLO  D"3E":;F K-.44J$))+qM1'')AEEG$AK  Q44	())!$'9qT?;DGTW$$')jDGJ<O.O A$**,C!-"4"9"9";<
?}S/A!/D/S$G+)6s);A)>DGAJ*_%23%7%:*5dgq*A &; = -'Qv0 1TW$//GN+E2DB/0A 23'.TW$00GN+F3DB/0A 34'/ 7:&DLLN"$DGJ/K,CRa5K'QR5;;=!B/CrUh&ekkmQr2FrUh&ekkmQr2FrUg%qrU[[]Ab1ErUf_abEKKM1R0D)$'15DGtw.,.)1?1G1M1Me1TU1TAaggi1TUiiR0dgh&77 GH-44S9	 V
 "F<<&9D<<5DTW,+/&..t4D%tw.,.)&>&;Q;W;WX];^'_;^a	;^'_`DGH$55 GH-44Q7 a "F$dg-+-(1?1F1L1LU1ST1SAaggi1STDGG$44 GG,33A6 U !EW X {$'1')$",:3,?,E,Ee,LM,Lq,LMA
 (62 '(3hsCHH}&Z+As399%@2w!|r	!U2w!|1(9!2a5\2w!|!$X]]%8%8"!=B "R!!NNH4E4E4G4GNH +-!&vA ( 2 21 5A$~~a00!G+0+=+=a+@DA56 %; 36aiik2BK$/$6$6qyy{$C 5@*74?q'(vv~ %+AFFK !' *7 6=d6l5J 2- "/: .=*GK(//2B $'!fo!V}:L
 W[[2.FHk>.0049Jtw%dgk&:;DAq&5&9&9!&<O&.# 2A1F1F1H-A~?
 (+uH(H5 !V$'47N$,$7
 !)%1ax6G /4'-h.@.@&,QCr!A$6/8 (9'+}}-5->->-@-@ (5 (B/3 67C$J 1#*$'#9 +12aSaS(A8CDGG$4 /3#+47#:8:DGH$5#'twx/@#@$(GH$5$<$<T$B &a 0 (&,QCr!E!$=!?%)W[[R%@F$.&$8'1V'; &2=J:!O%v6<
 3m 2In '21@1F1F1H-A~%)W[[2%>F&*gkk*b&A#%==#:#:)+)<B$*MM"Qr(..2E$F 'B  &48V4E 1  &a 0 2IE <X $'""!TW,dgn55!-dgn.Ec.J.4"67=/4$'."99!-dgn.Ee.L.4"6 GN3E:7=/4#+ $(V$5!$'>(&(
#$'*"55$'*"55
#**:6tw&$&! !2!2!45DA)003 6 wx()  +DGCL&A[ ^ $))+f  $fW~+u$xD)@($X2GHDGu$xB**VR0C"$mF["5B!#s]E$Q--b1A:HGGFOQWWW-=;?7(D%;H$h<08
J.6
+!$XDL8_ 5j A &%3!)9=(26(:B:HJv$6 7ADGN3%6@DGN3#2:DGJ/!&1$'6&BDG &1$';&GDG !  3Dx4I3JJ[\^U X W~VV5 5=53F#FGJ5=1Jdiik"A%|4TW==!!!$ # ed5>#6#6#89:%.--/0w*A
*"))!, + 1 >Z'5 !!%/2!!%-0>77=Dt|DJ 6"&t*X"6h>V#d499;/0diik"A
"G # Ki "D  		"  K!#K1,=rtt!D!J!JK2 !  ! 4 V" (` U N '
H= (()uB0F (4 !G /3G25emmo2FK!G*7t  ) ! ! (1 !)$(!)s   A@9A@>,AA ABAB'AB89AB=7AC>AC
$AC7AAC8AD+
$AD+
7AD0AE@>
AAAAAA>ABBABB
AB$B#AB$B'
AB5B4AB5C%AC5C4AC5C8
AD(	DAD#	D#AD(	D0
AD>D=AD>E
AEEAEz\A[a-z]+[\w$]*\Zc           	         Uc   [        XU5      nU$ [        U5      S:  d  USS[        U5      S-
  2   S:w  a  [	        SU S	35      eUSS
 R                  S5      n[        U5      S:X  a  US   R                  S5      n[        U5      S:X  a(  [        US   U5      n[        S[        U5      S-   5      nOO[        US   U5      n[        US   U5      n	[        [        U5      [        U	5      S-   5      nO[	        SU S35      eU R                  S5      (       a  U SS OU R                  S5      n / n
U  H!  n [        XU5      nU
R                  U5        M#     [        [        Xj5      5      nU$ ! [         a   nU n[        SU SU < S35         SnAU$ SnAff = f! [         a  n[        SU SU< S35         SnANzSnAff = f)a  
Creates a dictionary of indices and values for each parameter in a
parameter array to be evaluated later.

WARNING: It is not possible to initialize multidimensional array
parameters e.g. dimension(-3:1, 4, 3:5) at this point. This is because in
Fortran initialization through array constructor requires the RESHAPE
intrinsic function. Since the right-hand side of the parameter declaration
is not executed in f2py, but rather at the compiled c/fortran extension,
later, it is not possible to execute a reshape of a parameter array.
One issue remains: if the user wants to access the array parameter from
python, we should either
1) allow them to access the parameter array using python standard indexing
   (which is often incompatible with the original fortran indexing)
2) allow the parameter array to be accessed in python as a dictionary with
   fortran indices as keys
We are choosing 2 for now.
Nzparam_eval: got "r  r   r2  r   rh  zparam_eval: dimension z can't be parsedr   r&  r   r  z.param_eval: multidimensional array parameters z not supportedr  r   )r  r   r2   rX   r   r(  r  r   r8   r   r)  rv  zip)r   r  r  r  r  r   dimrangeboundlbounduboundv_evalitems               r)   r  r    s   & 	;Q&)A  7|a7#5S\A%5#56$>1':KLMMq}""3'H
8}A;$$S)x=AV4EQE
Q/H !f5F !f5FS[#f+/:HI#9N4 5 	5 LL&&1RA44S9AF	>/D 	d  	S"#AHK  	;A'uE!b9::	;>  	>'uE$<==	>s/   E1 :F1
F;FF
G(G  Gc                 "   SU ;   a]  U SU R                  S5       nX R                  S5      S-   U R                  S5       n[        [        X15      5      n[	        X   U   5      $ X;   a  [	        X   5      $ U H  n[
        R                  " SU-   S-   [
        R                  5      nUR                  U 5      nU(       d  MH  UR                  S5      [	        X   5      -   UR                  S5      -   n UR                  U 5      nU(       a  MK  M     U $ )	a  Recursively parse array dimensions.

Parses the declaration of an array variable or parameter
`dimension` keyword, and is called recursively if the
dimension for this array is a previously defined parameter
(found in `params`).

Parameters
----------
d : str
    Fortran expression describing the dimension of an array.
params : dict
    Previously parsed parameters declared in the Fortran source file.

Returns
-------
out : str
    Parsed dimension expression.

Examples
--------

* If the line being analyzed is

  `integer, parameter, dimension(2) :: pa = (/ 3, 5 /)`

  then `d = 2` and we return immediately, with

>>> d = '2'
>>> param_parse(d, params)
2

* If the line being analyzed is

  `integer, parameter, dimension(pa) :: pb = (/1, 2, 3/)`

  then `d = 'pa'`; since `pa` is a previously parsed parameter,
  and `pa = 3`, we call `param_parse` recursively, to obtain

>>> d = 'pa'
>>> params = {'pa': 3}
>>> param_parse(d, params)
3

* If the line being analyzed is

  `integer, parameter, dimension(pa(1)) :: pb = (/1, 2, 3/)`

  then `d = 'pa(1)'`; since `pa` is a previously parsed parameter,
  and `pa(1) = 3`, we call `param_parse` recursively, to obtain

>>> d = 'pa(1)'
>>> params = dict(pa={1: 3, 2: 5})
>>> param_parse(d, params)
3
r6  Nr   r7  r  r  r  r  )
r  rfindr8   r  r   r   r   r   r   r   )r#  r  dnameddimsr[   r  r`  r   s           r)   r  r    s    r ax,166#;&&+/!''#,/ K./6='((	
69~A::$q(+==rttD 

1A!GGH%	N#%&WWW%56JJqM !  r(   c                    U n[         R                  U 5      (       + nU(       a  [        U5      u  pV[        XS   U5      nSnU  H>  n	U	R	                  5       n	U	[
        R                  [
        R                  -   ;  a  Sn	X-   nM@     US   S:X  a  US-   nOUS-   nUn XS   ;   d  XS   ;   a  U S-   n XS   ;   a  M  XS   ;   a  M  X;   a;  S	n
U [        U
5      -   U;   a  U
S	-   n
U [        U
5      -   U;   a  M  U [        U
5      -   n U(       a
  WUS   U '   U $ XS   ;  a  US   R                  U0 5      US   U '   S
U;   a&  X1S
   US   -   ;   a  [        US   U    S5      US   U '   U $ )Nr0  e_r   r   r  _er5  r   r   r3  r4  r  )analyzeargs_re_1r   r  r  r   rc   ascii_lowercasedigitsr   r  rx  )r+  r1  r5  orig_a	a_is_exprr  r  atnar   r~  s              r)   	expr2namerH  "  s   F$**1--I#5e#< q-?A	A..>>B	 
 b6S=cBdB= Av$6CA = Av$6y#a&jD AA #a&jD AJfa H	 &M!$V}00<E&M!%FK.@5CV.V$V*5=+;ZHE&M!Hr(   c                    [        U 5        [        U 5      u  pSU ;  a  / U S'   / nU S    H   n[        X@U5      nUR                  U5        M"     X0S'   SU ;   a@  [	        U S   R                  5       5       H   u  pVU H  nX@S   ;  d  M  0 U S   U'   M     M"     U S    H>  nUS   U;   d  M  SU ;  a  / U S'   US   U S   ;  d  M'  U S   R                  US   5        M@     SU ;   a  U S   U S   ;  a  0 U S   U S   '   U $ )Nr5  r  r0  r/  rq   r3  r   )rY  r  rH  r)  rv  rL  )r1  r  r   r5  r+  r~  args1rm  s           r)   rw  rw  D  s)   )%0MUfD6]a%A  &M%U7^1134HA&M)')E&M!$  5
 6]V9%'%'k"yk 22k"))!F)4  5U8_E&MA)+feHo&Lr(   z\A\(.+?,.+?\)\Zz\A[+-]?\d+(_(?P<name>\w+)|)\Zz*\A[+-]?[\d.]+[-\d+de.]*(_(?P<name>\w+)|)\Zz
\A\(.*\)\Zz\A(?P<name>\w+)\s*\(.*?\)\s*\Zc                     [        U [        5      (       a  SS0$ [        U [        5      (       a  SS0$ [        U [        5      (       a  SS0$ [        U [        5      (       a  U $ [        [        U 5      5      e)Nr4   r7   r5   r  )r  r8   r:   r  rv  AssertionErrorr   )r   s    r)   _ensure_exprdictrM  g  sk    !SI&&!UF##!WI&&!T
a
!!r(   c                    X;   a  [        X   5      $ U R                  5       n [        R                  U 5      (       a  SS0$ [        R                  U 5      nU(       aF  SUR                  5       ;   a.  UR                  S5      (       a  [        S[        U 5       S35        SS0$ [        R                  U 5      nU(       aF  SUR                  5       ;   a.  UR                  S5      (       a  [        S[        U 5       S35        SS0$ S H\  n[        XS	9R                  S
U-   S
-   5       Vs/ s H  oUR                  5       PM     sn H  nXa;   d  M
  [        X   5      s  s  $    M^     0 n[        R                  U 5      (       a  [        U SS X5      nOx[        R                  U 5      nU(       a\  UR                  S5      n[        UR                  S5      X5      nU(       a	  SU;   a  US	 U(       d  US   U;   a  [        X(S      5      $ U S   S;   a  SSS0S.$ U(       d  [        S[        U 5       S35        U$ s  snf )Nr4   r  rq   z6determineexprtype: selected kind types not supported (r   r7   r5   )+r  r   r  r3  ri  r   r   rn  r   r  r#  r   )r4   rp  z4determineexprtype: could not determine expressions (z) type.
)rM  r   determineexprtype_re_1r   determineexprtype_re_2r!  r   r2   r   determineexprtype_re_3r'  r(  determineexprtype_re_4r  determineexprtype_re_5)	r&  r0  rulesr   opr  r  r  rns	            r)   r  r  s  s   |
++::<D##D))I&&$$T*AQ[[]"qwwvHdTWXZI&&$$T*AQ[[]"qwwvHdTWXZF##"%3D%C%I%I#PR(UX.%YZ%Y'')%YZAy'00 [ # 	A##D))d1Rj$6"((.B!!''&/4?AZ1_jMa5E>+EQ%L99Aw%'#sDDB4:,iX	ZH+ [s   *H<r   c                    [        U 5        Sn[        U [        5      (       aQ  U  HI  nU(       a2  US   S;   a)  US   [        ;   a  M"  [        (       a  US   [        ;  a  M<  U[        XAUS9-   nMK     U$ SnSnSnU S   nUS:X  a  g/ n	SU ;   a  U S   nSU ;   ag  U S   n
U S    H4  n[        XU	5      n[        X   5      (       a  M#  U	R                  U5        M6     U S   S	:X  d  U	(       a  S
SR                  U	5       S3nSnSU ;   a?  [        U S   R                  5       5       H  nU< U[        -   < U< SU S   U   < 3nM!     U R                  S/ 5      S S  nUS	:X  a  SU;   a  UR                  S5        U(       a&  U< U[        -   < SSR                  U5      < SU< 3nSnSU ;   a  [        U S   U[        -   5      nSnSU ;   a  [        U S   U[        -   5      nUS:X  a  SnSnSU ;   a&  SU S    S3nU S   U	;  a  U	R                  U S   5        [        U S   U[        -   US9n[!        X S   X[        -   US9n
SnSU ;   a  U(       d  SU S    3nSU ;   aP  Sn[        U S   R#                  5       5       H)  u  nnU U[        -    SU S
SR                  U5       S3nM+     UU-   nUS:X  a  US:X  a  SnU< U< U< SU< U< U< SU< U< U< U
< U< U< U< SU< SU< 3nU$ ) Nr
   r1  r  rq   r  r  r5  r0  r   r6  r&  r7  r  r   r
  callbackintent(z) r  r  r  r   z	 result (r/  r  z! in r  zentry r  r  zend )rY  r  rv  r#   r$   r  rH  r  r)  r   rw  r   r  r  use2fortrancommon2fortranvars2fortranrL  )r1  rf  r  rj  ri  r  rq   r5  	blocktypeargslr0  r+  r  r~  
intent_lstr  r  r   r/  messentry_stmtsr  s                         r)   r  r    s7    
C%AQwZ#==V9	)96)!;(lKKC  
FDDgIIEV}V}vA!E*A$TW--Q  >Z'5sxx'q)DU"e./4467A #-E:L4Ma4P R 8 8R(+JJ:#;*%,cGmHHZ0$8 C~%,g6F5hw?""F5U8_-Q/?%'LLx)E&M3=|TDV}e7]ODD|uV}o&%w--/0DAq(M#-qc388A;-qQK 1k!L T^%;VYdFD:JCQUW]_cehjsuy{CJr(   c           
          Sn[        U R                  5       5       HB  nUS:X  a  U U SSR                  X   5       3nM%  U U SU SSR                  X   5       3nMD     U$ )Nr
   r  zcommon r&  zcommon /z/ )rv  rw  r   )r  rf  rj  r~  s       r)   r\  r\    sp    
C&++- =E#gchhvy&9%:;CE#hqcCHHVY,?+@AC	 !
 Jr(   c                    Sn[        U R                  5       5       H  nU U SU S3nX   0 :X  a  U(       a  US   S:X  a  US S nM,  SX   ;   a  X   S   (       a  U S3nSX   ;   ab  X   S   (       aV  Sn[        X   S   R                  5       5       H2  nXPU   S   U   :X  a  U U U 3nSnM  U U U S	X   S   U    3nSnM4     U(       d  M  US   S:X  d  M  US S nM     U$ )
Nr
   zuse r&  r   r  z only:r  r   z=>rQ  )r  rf  rj  r   r   r~  s         r)   r[  r[    s   
C#((*cU$qc#6R<s2w#~#2hSVvE.CCF?sve}A#&-,,./Aua(( E!QC.CA E!QCr#&-*:);<CA 0 33r7c>cr(C% & Jr(   c                     U S   n/ nU H4  n [        5       SU 3   nU" U 5      (       a  UR                  U5        M4  M6     U$ ! [         a     MG  f = f)Nr
  	isintent_)globalsr)  r  )rk  r  rj  r
  rf  s        r)   true_intent_listrh    si    
h-C
C	#	IfX./A vv

6"   J  		s   A
AAc           	         [        U 5        Sn/ nU H  nXpS   ;   d  M  UR                  U5        M      SU ;   a:  U S    H1  nXq;   a  Xv;  a  UR                  U5        M   M"  [        SU S35        M3     SU ;   a  UR                  U S   5        U(       d8  [	        UR                  5       5       H  nXv;  d  M
  UR                  U5        M     U GH  nSX   ;   a>  X   S    H3  nX;   d  M
  SX   ;   d  M  XqU   S   ;   d  M!  [        SU S	U S
35        M5     SU ;   a  XpS   ;   a|  [        X   5      (       a	  U U SU 3nU U SU 3n[        X   5      (       a	  U U SU 3nXq;   a
  SX   ;  a  M  Sn	U S    H  n
XzS   :X  d  M  U
S   S:X  d  M  Sn	  O   U	(       a  M  Xq;  a  [        U5        [        SU S35        M  XpS   :X  a"  U S   S:w  d  U R                  S5      (       a  GM  SX   ;  aC  SX   ;   a  SX   S   ;   a  Xr;   a	  U U SU 3nGMK  [        X   5        [        SU S35        GMj  X   S   nUS:X  a  SX   ;   a  U SX   S    S3n0 nS X   ;   a  X   S    nOS!X   ;   a  X   S!   nS"U;   a   US"   S#;   a  U S$US"    S3nODU S"US"    3nO9S%U;   a"  U S&US%    3nS'U;   a  U S(US'    S3nOU S3nOS'U;   a  U S)US'    S3nS*nSX   ;   ab  X   S    Vs/ s H  nUS+;  d  M  UPM     nnU(       a  S,U;   a  S-U;   a  UR                  S-5        U(       a  U S.S/R                  U5       3nS/nS0X   ;   a   U U S1S/R                  X   S0   5       S3nS/nS2X   ;   a/  [        X   5      nU(       a  U U S3S/R                  U5       S3nS/nS4X   ;   a   U U S5S/R                  X   S4   5       S3nS/nSX   ;   a   U U S6S/R                  X   S   5       S3nS/nS7X   ;   aF  X   S7   nX   S   S8;   a)   [        U5      nSUR                   S/UR                    S3nU S9U S7U 3nOU S9U 3nU U U 3nGM     U$ s  snf ! ["         a     N2f = f):Nr
   r0  r  zvars2fortran: Confused?!: "z" is not defined in vars.
r  ru  z;vars2fortran: Warning: cross-dependence between variables "z" and "r  r3  zintent(callback) z	external z	optional r4   r   r/  rq   r1  r   r   z*vars2fortran: No definition for argument "rm   r   rn  r  z(vars2fortran: No typespec for argument "rh   rr  r6  r7  ro  rp  r   )r   r  z*(rX   z(len=rJ  z,kind=z(kind=r   )r  z
intent(in)zintent(out)r  r&  r  r8  r
  rZ  rt  zcheck(zdepend(rq  )r  r!  z :: )rY  r)  ro   r  rv  rw  r  
isoptionalshowr2   r  r  r   rh  r  r5   imagr   )r1  r0  r5  rf  r  rj  noutr+  r#  r   rm  vardefr  r   r   r  r  r   s                     r)   r]  r]    s   
CDfKKN  u|$Ay=KKN ! 1!4OPR % UE*%&diik"A}A # twWX&9TW!41gh>O9OUVWUXX_`a_bbfgi ' %A{);$; ))cU"3A37E#is+C$'""cU)A3/yZtw6D6]&	>ajJ&>D # =J@4HIfW~+uyy/B/B
 TW$TW$twz7J)J9 E#is3CM>qcFG$V
dg 5xq!4 5Q7FTW$w~.Htw&w~.H(?}
*"82hsm_A6"81Xc]O4hxuXe_$56F!"86(6*:);1="81xxvhv&6%7q9F #wz2 .2!, 2D . 4$9N M*"82chhtn%56$'!xs*SXXdgk6J-K,LANFAtw"47+C"8A3gchhsm_A>Adgxs&$''2B)C(DAFFAtwxs'#((4783D*E)FaHFA$'>Awz"&CCQAAFF81QVVHA.A xtA3as+FxtA3'FcU6(#I J JM.@ ! s   .
Q<Q(Q
Q,+Q,c                 6   [        SS5        [        U [        5        [        SS5        / q[	        [
        S   5      n[        SS5        [         H(  n[        SUR                   S3S5        [        X5      nM*     [        SS5        [        U5      n[        U-   $ )NzReading fortran codes...
r   zPost-processing...
z"Applying post-processing hooks...
z  r   zPost-processing (stage 2)...
)
r2   r   r<  r   ru  r   post_processing_hooks__name__traverserh  )filespostlisthooks      r)   crackfortranrv    s     (!,E9%"A&K1&H115%"T]]O2&*H+ & ,a0(#H!!r(   c                 B    [        U 5      S-   nSnS[        -  nX!-   U-   $ )Nr   zE!    -*- f90 -*-
! Note: the context of this file is case sensitive.
z
! This file was auto-generated with f2py (version:%s).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e
)r  f2py_version)r1  pyfheaderfooters       r)   crack2fortranr|    s:     5
!D
(CF 	F
 <&  r(   c                     [        U [        5      =(       a.    [        U 5      S:H  =(       a    [        U S   [        [        45      $ )Nr2  r   )r  tuplerX   r8   r   )objs    r)   _is_visit_pairr    s8    sE" /CA/3q6C:.0r(   c                    [        U 5      (       a6  U S   S:X  a  U $ U" XU/UQ70 UD6nUb  [        U5      (       d   eU$ U nU u  pOSU 4nSn[        U [        5      (       aE  / n[        U 5       H3  u  p[	        X4UX'/-   U/UQ70 UD6u  pUc  M"  UR                  U5        M5     OT[        U [        5      (       a=  0 nU R                  5        H&  u  p[	        X4UX'/-   U/UQ70 UD6u  pUc  M"  XU'   M(     OU nUc  U$ X4$ )a  Traverse f2py data structure with the following visit function:

def visit(item, parents, result, *args, **kwargs):
    """

    parents is a list of key-"f2py data structure" pairs from which
    items are taken from.

    result is a f2py data structure that is filled with the
    return value of the visit function.

    item is 2-tuple (index, value) if parents[-1][1] is a list
    item is 2-tuple (key, value) if parents[-1][1] is a dict

    The return value of visit must be None, or of the same kind as
    item, that is, if parents[-1] is a list, the return value must
    be 2-tuple (new_index, new_value), or if parents[-1] is a
    dict, the return value must be 2-tuple (new_key, new_value).

    If new_index or new_value is None, the return value of visit
    is ignored, that is, it will not be added to the result.

    If the return value is None, the content of obj will be
    traversed, otherwise not.
    """
r   r[  N)r  r  rv  r  rr  r)  rv  rL  )r  visitparentsr   r5  kwargs
new_resultparent
result_keyr[   r  	new_indexnew_itemr  new_key	new_values                   r)   rr  rr    sS   8 cq6^#J3A$A&A
!!*----
C
#t
%cNLE"*E>5+2X+=v#<,0#<4:#<I $!!(+ + 
C		
))+JC!)3,*1H*<f";+/";39";G "&/7# & 
!!r(   c                    US   u  pVU u  pxS n	US;   a  US   S   S:X  d   eUS   S   n
OUS:X  a  US	   S   S:X  d   eUS	   S   n
OS
n
S
nU
b6  UnU
R                  5        H  u  p[        U5      (       d  M  U	" X5      nM!     O_US:X  aY  US	   S   S   n
UnU
R                  5        H8  u  p[        U5      (       d  M  [        R                  " SU-   S-   SU-   U5      nM:     Ub!  X:w  a  [	        SU SU SU SU S3	S5        X{4$ g
)a  Previously, Fortran character was incorrectly treated as
character*1. This hook fixes the usage of the corresponding
variables in `check`, `dimension`, `=`, and `callstatement`
expressions.

The usage of `char*` in `callprotoargument` expression can be left
unchanged because C `character` is C typedef of `char`, although,
new implementations should use `character*` in the corresponding
expressions.

See https://github.com/numpy/numpy/pull/19388 for more information.

r   c                 z    [         R                  " SU -   S-   X5      n[         R                  " SU -   S-   X5      nU$ )Nz[*]\s*\br  z\b\s*[\[]\s*0\s*[\]])r   r  )varnamer  s     r)   	fix_usage8character_backward_compatibility_hook.<locals>.fix_usage  s>    {W,u4gEuw)@@'r(   )r  rt  r   r0  r   rq  r   Ncallstatementz
(?<![&])\br  r   zcharacter_bc_hook[r  z]: replaced `z` -> `z`
)rL  ischaracterr   r  r2   )r9  r  r   r5  r  
parent_keyparent_valuer  r  r  	vars_dictr  r  vds                 r)   %character_backward_compatibility_hookr    s`     'r{JJC ++r{1~'''BKN		r{1~'''BKN		I	$??,KG2%g9	 - 
	BKN6*		$??,KG2 FF!G+e3S7]IO		 - 
 (AcU ;""'yk>?@B r(   __main__r  z-quietz-verboser2  z-fixz?Use option -f90 before -fix if Fortran 90 code is in fix form.
z-skipemptyendsz--ignore-containsz-f77z-f90r   z-hz-showz-mr  zUnknown option z	OSError: a    Warning: You have specified module name for non Fortran 77 code that
  should not need one (expect if you are scanning F90 code for non
  module blocks but then you should use flag -skipemptyends and also
  be sure that the files do not contain programs without program
  statement).
zWriting fortran code to file r  )r   )r   )r&  )rV  r,   )r
   N)Nr
   )r
   )NN)r   r   )r   F)r
   F)__doc__r   r  r   r   r  r   rc   r-   pathlibr   r   ImportErrorr
   r   r   auxfuncsversionrx  r   r   r   r   r   r   r   r   r   r   r   r   r!   r   r   r    r   r>  r   r   r=  r%   r   r$   r&   r   r#   r"   r   r*   r2   	_MAXCACHEr  r   rn   rz   r   rr   rw   r{   r}   r   r   r  r   r   r   r   r   r   r   r   r   rk  r   beforethisafterfortrantypesrO  r  rL  rM  groupbegins77r   groupbegins90r   	groupendsrJ  endifsrI  moduleproceduresrU  rN  r?  r@  rB  rC  rF  rG  rH  rA  rD  rE  rQ  rT  rX  rP  rR  rS  rK  Sr:  r;  r   r,  rV  crackline_bind_1r  r<  rW  r'  rl  r  r$  r  r  r  r  r  r  r  r  r  r  r  rY  r  r  r  ro  rp  rM  r:  r(  r1  r  r  rx  ry  rz  rW  rY  r\  rd  rh  ru  rz  rx  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  ry  rA  r  r  rH  rw  rP  rQ  rR  rS  rT  rM  r  r  r\  r[  rh  r]  rp  rv  r|  r  rr  r  r)  rq  rs  funcsrf  f2f3showblocklistargvr   ro   r   r   r   OSErrordetailrt  ry  r/   r'   r(   r)   <module>r     s^  IT    	  	  
  $
 "" 		


  
2			 	#L  	!A)62 
"	A)95 

A e)HQKKE	
,1 

3RTT:AA**12448??**12448??**12448>> : 8 3>4 '+! _DF Dzzr<t<<bddDEKL

?44lEb6bdh6j $jkmkokoq  **_ 0? ?@BFGNOJJ 24  457TT;<CD  (r=->>FGNO r=->>FGNO7	ZZr9i66>?DE

 zzy&&$77?@GH ) r+-=tDDbddL  **88"$$@AKL::o 18 89;?@KL **88"$$@AKL**88"$$@AKL**88"$$@AKL

44bdd<=EF66>?HI::::BDDBCNO 

? .Q QRTRVRVXYab::@@"$$HITU jj00"$$89?@jj00"$$89?@zz22BDD:;BC66>?HI

44bdd<=EFZZ..67<=
**66>?IJ

44bdd<=EF **_ 8M &M OQ  OS  OS  VX  VZ  VZ  OZ[ ]oo ::9244ABMN ( A244H::A244H ZZ kmomqmqr [%|$&
@ 

KRTTS%&(dd, ** r  tv  tx  txy***+-441 jj@"$$H 

;=zzHJ $A244H    u@p(8 jjErttLzzI244Qzz9244A235449 ** G  IK  IM  IMN"JfR7,v6<@\~D'T*Z$&! **^RTT2AH zz,bdd3,4$" $ (* bJ( **W%++ DN ::12448 ;|M`   D6 $6= $DbddK 12449 M2448 $ErttL 	" )+ (ZGT0z@  ""!0 "$D ?"D9 x   B C zEE	A	
B	
BMXXab\7qTS[A(]EG*_GE&[yVXY[M"N""M%%N&[I"N&[I#NM$YB'\M$YBqTS[od1gYb12BKBM2QQ LLOc d 9}}  	 E"H{/[0A/B"EqIH%+s#qGGCL $X Q [m  Do  2)F:R0112" $#s5   l8 )mm)8mmm&m!!m&)
m7