
    KhB                       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  SSK7  SSKJr  \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,-   S--   rR\Rx                  " \JS
\R\RS%4-  \Rz                  5      S)4rSS.rT\Rx                  " \JS
\T\TS%4-  \Rz                  5      S/4rUS0rV\Rx                  " \JS1\V\VS%4-  \Rz                  5      S24rWS3rX\Rx                  " \JS
\X\XS%4-  \Rz                  5      S44rY\Rx                  " \JS5-  \Rz                  5      S64rZ\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r`\Rx                  " \JSC-  \Rz                  5      SD4ra\Rx                  " \JSE-  \Rz                  5      SF4rb\Rx                  " \JSG-  \Rz                  5      SH4rc\Rx                  " \JSI-  \Rz                  5      SJ4rd\Rx                  " \JSK-  \Rz                  5      SL4re\Rx                  " \JSM-  \Rz                  5      SN4rf\Rx                  " \JSO-  \Rz                  5      SP4rg\Rx                  " \JSQ-  \Rz                  5      SR4rh\Rx                  " \JSS-  \Rz                  5      ST4ri\Rx                  " \JSU-  \Rz                  5      SV4rj\Rx                  " \JSW-  \Rz                  5      SX4rk\Rx                  " \JSY-  \Rz                  \R                  -  5      SZ4rm\Rx                  " S[\R                  5      S\4rnS] roS^ rp\Rx                  " S_\Rz                  5      rq\Rx                  " S`\Rz                  5      rr\Rx                  " Sa\Rz                  5      rsSSb jrtSc ruSSd jrvSe rwSSf jrx\Rx                  " Sg\Rz                  5      ry\Rx                  " Sh\Rz                  5      rz\Rx                  " Si\Rz                  5      r{\Rx                  " Sj\Rz                  5      r|\Rx                  " Sk\Rz                  5      r}\Rx                  " Sl5      r~\Rx                  " Sm5      r\Rx                  " Sn\Rz                  5      rSo rSp rSq rSr rSs rSt rSu r\Rx                  " Sv\Rz                  5      r\Rx                  " Sw\Rz                  5      r\Rx                  " Sx\Rz                  5      r\Rx                  " Sy\Rz                  5      r\Rx                  " Sz\Rz                  5      rS{ rS| 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      -  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        (       aF  \1" S\" [0        5      -  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     I/var/www/html/env/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                 b    U [         ;   a$  [        SU < S[         U    < S35        [         U    $ U $ )Nzrmbadname1: Replacing "" with "".
)badnameserrmessnames    r)   
rmbadname1rr   
  s/    xx~' 	(~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                 b    U [         ;   a$  [        SU < S[         U    < S35        [         U    $ U $ )Nzundo_rmbadname1: Replacing "rl   rm   )invbadnamesro   rp   s    r)   undo_rmbadname1r{     s1    {T*, 	-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   K  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      -  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
z6Flag sourcecodeform must be either 'fix' or 'free': %sz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   e  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 .Y4"46 7 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H4P^K__a a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*dataz@|module(?!\s*procedure)|python\s*module|(abstract|)\s*interface|z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                  [        R                  " U5      5      SR                  [        R                  " U5      5      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('([^'\\]|(\\.))*')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5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a=  [        [           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      -  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   )z8crackline: could not resolve function call for line=%s.
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)   r9  r9    s-    )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 !RXXh%7 9  48;&q)//5AWZ^_cZddf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   r4  r   @(@r5  @)@r'   )r0   r   fr   s       r)   rT  rT  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   ()@r4  r   r5  )r   r   )r0   commar   rc  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$ )Nra  r4  rb  r5  )r   )r0   r   s     r)   unmarkouterparenri  |  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-  5        M  [        S	[        U5      -   5      e   U $ )
Nr4   attrspeckindselectorcharselector)=typenamenote)r
  checkr  r  r  dependz"appenddecl: "%s" 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##( &&[ ) )9A=>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)Nrk  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   r^  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   r3  r   schemer4  r5  )r  rT  nameargspatternr   r   operatorpatterncallnameargspattern)r0   
bind_cnamer^  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                 <   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-  5        Sq[        S-   qS	[        [        '   0 [        [        '   / [        [        '   / [        [           S
'   0 [        [           S'   S	[        [           S'   U[        [           S'   S[        [           S'   SqUS;   G	aT  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  a<  ['        U R                  S5      5      u  pVn[)        US9[        [           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R1                  5       PM     sn5      nO/ nSU;   a*  SU;   a  UR3                  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[4        (       a'  [6        S%:X  a  [        S::  a  [        S&-   qSnUS';  a  Sn[        S-   q0 [        [        '   / [        [        '   U(       a  [8        S:  a  [        S([;        [4        5      -  S5        S)[        [        '   S[        [           S'   [4        [        [           S'   S[        [           S'   / [        [           S
'   / [        [           S*'   / [        [           S"'   0 [        [           S'   [        S-   q0 [        [        '   / [        [        '   U(       a  [8        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  S/UR=                  S0S15      -   nU R                  S25      [        [           S3'   [?        U5      [        [           S'   U	[        [           S4'   [        S:X  a  [        [        [           S'   O{[4        (       a7  [        S5:X  a-  [        [        S-
     S   < S.[        < 3[        [           S'   O9[        [        S-
     S   < S.[        [        S-
     S   < 3[        [           S'   [A        [        [           RC                  5       5       H(  n[        [           U   (       a  M  [        [           U	 M*     U[        [           S!'   / [        [           S
'   / [        [           S*'   / [        [           S"'   0 [        [           S'   0 [        [           S6'   US:X  a  / [        [           S7'   US ;   a  U[        [        S&-
     S*   ;  a"  [        [        S&-
     S*   RE                  U5        [F        RH                  " [        [        S&-
     S   5      [        [           S'    [        [           S   U   [        [           S   U   S8   RK                  S95      	 US:;   Gaf  W
(       a  [         RN                  " [P        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'    [S        [        [           S   U   [        [        S&-
     S   S   5      [        [           S   U'   US>:X  a_  U	(       aX  U	[        [           S   ;   aD  XY:X  d?  [S        [        [           S   U   [        [           S   U	   5      [        [           S   U'    [        [        S&-
     S"   RE                  U5        US$:X  aq  [T        S   R#                  U R                  S25      S0-   U-   5      nU(       a=  [W        UR                  S5      UR                  S5      5      u  nnnn[Y        UUUU5        US ;   a  [        [        S-
     RE                  [        [           5        [        [           [        [        S-
     S%   S
'   [        [        	 [        S-
  q[        [        S-
     RE                  [        [           5        [        [           [        [        S-
     S%   S
'   [        [        	 [        S-
  qggUS6:X  a  [+        U R                  S5      5      u  pXpUb|  U(       aC  [-        [/        U5      R                  S5       Vs/ s H  nUR1                  5       PM     sn5      nO/ nU	b   [;        U	5      5       eU[        [           S6   U'   S6U[        4qggUS:X  a;  [W        X0R                  S5      5      u  nnnn[Y        UUUU5      nUb
  S?U[        4qggUS@;   Ga   [        [           S   nU R                  S5      R1                  5       nUR[                  SA5      nUS:  a  USB:X  a  []        U5      R[                  SC5      S&-
  nUSUS-    SA-   UUS-   S -   nUR[                  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 R1                  5       nUUS&-   S n[/        U5      R                  S5      n[a        U5      S:  a%  US   n[        SGSFR_                  USS 5      -  5        Sn[/        U5      R                  S5       Vs/ s H  oR1                  5       PM     sn GH`  n[b        R#                  U5      nU(       dA  USH;   a  SnOR[e        U Rg                  5       5        [        SIU< SJ[;        U5      < SK35        Ma  [?        UR                  S5      5      nUSH;   a   USL:X  d  USM:X  a  UUR                  S5      -  nUU;  a  0 UU'   USN:X  a  UUR                  S5      -   nUSB:X  a  U R                  S5      U-   n[h        R#                  U5      (       a  U[        [           S!   ;  a  [        S:  ax  SO[        [        S&-
     S   ;  a  [        SP5        U[        [           S   :w  aA  [        SQU< SR[        [           S   < SS35        [        [           S!   RE                  U5        O[k        STU-  5        O[k        SUU-  5        USV;   a  UnS8UU   ;   a  UU   S8   RE                  W5        O	W/UU   S8'   US9:X  ay  [        [           S   S	:X  a  [        SW5        GM  U[        [           S!   ;  a  GM  S*[        [           ;  a  / [        [           S*'   [        [           S*   RE                  U5        UnGMc     U[        [           S'   Ub
  S?U[        4qggUSX:X  aM  U R                  S5      R                  SF5       Vs/ s H  oR1                  5       PM     sn[        [           SY'   gUSZ:X  GaW  [        [           S   nU R                  S5      R1                  5       SS% nSn[/        U5      R                  S5       GH  n UR                  S[5       Vs/ s H  oR1                  5       PM     snu  nn[m        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< Sb35        [o        UU5      nU(       a  URq                  Sc5      Sd:X  a  [A        U5      n [r        Ru                  U5       Hj  n [A        UU Rw                  5       U Ry                  5        R                  5       R=                  SeSf5      5      U U Rw                  5       U Ry                  5       & Ml     SR_                  U 5      nOHURq                  Sc5      Sg:X  a3  USS R                  5       R=                  SeSf5      R=                  SFSh5      n [{        U0 U5      n![;        U!5      UU   S['   S8UU   ;   a  UU   S8   RE                  SZ5        O	SZ/UU   S8'   UnGM     U[        [           S'   Ub
  S?U[        4qggUSk:X  Ga  U R                  S5      R1                  5       R                  5       Sl:X  a  S[        [           Sk'   gU R                  S5      (       GaV  Sk[        [           ;   a  [        [           Sk   n#O0 n#U#c  [        Sm5        0 n#[/        U R                  S5      5      R                  S5       GH  n0 n$[         R"                  " SnU[         R$                  5      nU(       d  [        SoU-  5        MC  [        R#                  UR                  S5      5      n%U%(       d  [        SpU-  5        M~  [W        U%R                  S5      U%R                  S5      5      u  nnnn[        UU5      u  n&n'n(UU$Sc'   U&U$Sq'   U'U$Sr'   U(U$Ss'   [A        U$RC                  5       5       H  nU$U   (       a  M  U$U	 M     [/        UR                  S5      5      R                  S5       H  n)StU);   a4   U)R                  St5       Vs/ s H  oR1                  5       PM     snu  n*n+OU)R1                  5       =n*n+[a        U*5      [a        U+5      s=:X  a  S:X  d  O  [        SvU)-  5        M  [        [        U*5      [        U+5      S-   5       H  n,U$U#[        U,5      '   M     M     GM     U#[        [           Sk'   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-R1                  5       n-U-R                  SF5      (       a  U-SS R1                  5       n-URE                  U-U./5        U2n-Sn.Sn/M     U/S&:X  aL  U-R1                  5       n-U-R                  SF5      (       a  U-SS R1                  5       n-URE                  U-U./5        [        [           Rq                  S0 5      n3SnU GH  n4U4S   R1                  5       U4S   R1                  5       sU4S'   U4S'   U4S   R                  SF5      (       a  U4S   SS U4S'   U4S   R                  Sz5      (       a  [        S|U4S   -  5        M  [        [-        [/        U4S   5      R                  S5       Vs/ s H  oR1                  5       PM     sn5      5       GH!  u  n5n!U!R                  Sz5      (       a  [        S|U!-  5        M-  S}U4S   ;   a  [        S~U4S   -  5        MI  U3R                  U!0 5        U3U!   Rq                  Sc5      n6[        U3U!   5      n7U6Sg:X  a  [         R                  " SU4S   5      OU4S   R                  SF5      n8 U7(       a   SR                  SR_                  U85      5      OU8U5   n9U3U!   Rq                  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      R1                  5       nUS   Sy:X  d  SU-   n/ n?[         R                  " SyUS&S9u  nn@nAU@R1                  5       n@U@(       d  Sn@U?RE                  W@WA/5        0 nBS[        [           ;   a  [        [           S   nBU? Hv  n2U2S   WB;  a  / WBU2S   '   [/        U2S   5      R                  S5       Vs/ s H  oR1                  5       PM     sn H#  nU(       d  M  WBU2S      RE                  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am  URg                  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  oR1                  5       PM     nn0 nEU H  n4S[U4;   a  [         R"                  " SU4[         R$                  5      n%U%(       a@  U%R                  S5      R1                  5       WEU%R                  S5      R1                  5       '   O[        S[;        U45      -  5        OU4WEU4'   WE[        [           S   U   S'   M     gg[e        U Rg                  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   RE                  U R                  S5      5        gU R                  S5      WFU R                  S5      '   gUS:X  aO  [        c  [8        (       a  [        S5        g[        nG[        [        UG   [        SS& U R                  S5      5        g[8        S:  a%  [e        U Rg                  5       5        [        S5        ggs  snf ! [L         a     GNf = f! [L         a     GNf = f! [L         a     GNf = fs  snf s  snf s  snf s  snf ! [L         a    [        S\U< S]U< S^35         GM  f = f! [|        [~        [        4 a   n"[k        SiU< SjU"< SE35         Sn"A"GM  Sn"A"ff = fs  snf ! [L         a    [        SuU)-  5         G	MS  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=R1                  5       /[        U<5      -  5        ML  ! [         a#    U:RE                  U;R1                  5       5         Mx  f = fU:RE                  U;R1                  5       5        M     U:n8U7(       a   SR                  SR_                  U85      5      OU8U5   n9 GNf = 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.
r6  r  N)r   r  r  rh   r   .r   zBanalyzeline: no group yet. Creating program group with name "%s".
programr-  r.  r/  rq   fromskyfrom)r   r  r  zblock\s*data
block datazpython\s*modulepython modulezabstract\s*interfaceabstract interfacerh   r  )rk  _BLOCK_DATA_r
   )	interfacer  r  z2analyzeline: No name/args pattern found for line.
r#  z<analyzeline: argument list is malformed (missing argument).
)r  r  r3  r2  r   r   r   r0  r  r  z&analyzeline: Creating module block %s
moduler1  zDanalyzeline: Creating additional interface block (groupcounter=%s).
r  unknown_interface:unknown_r   r   r  prefixr      r  varnamesrk  r  r   r   bindlanglang	lang_namer  variable)r  r
  r  r  r  r  r  r  ::r
  rb  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 z. Skipping.
operator
assignmentr  __user__z8analyzeline: missing __user__ module (could be nothing)
z(analyzeline: appending intent(callback)  to z arguments
z,analyzeline: intent(callback) %s 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  rn  zAanalyzeline: could not extract name,expr in parameter statement "" of ""
z1analyzeline: Overwriting the value of parameter "" ("z	") with "rm   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*|)\ZzDanalyzeline: could not extract info of implicit statement part "%s"
zManalyzeline: could not extract types pattern of implicit statement part "%s"
rl  rm  ro  -zZanalyzeline: expected "<char>-<char>" instead of "%s" in range list of implicit statement
z^analyzeline: expected "<char>-<char>" instead of "%s" in range list of implicit statement (2)
r  '/r4  r5  z>analyzeline: implied-DO list "%s" is not supported. Skipping.
r   z=Comment line in declaration "%s" is not supported. Skipping.
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*\Zrs  notonlyonlyz7\A\s*(?P<local>\b\w+\b)\s*=\s*>\s*(?P<use>\b\w+\b)\s*\Zlocalz0analyzeline: Not local=>use pattern found in %s
mapz0analyzeline: Could not crack the use statement.
)r  r  usercodez-analyzeline: No context for multiline block.
z+analyzeline: No code implemented for line.
)Tr   r&   r   r   r   r   r   basenamer!   r&  r2   r   r:  r;  r   r   r   r   r   r  dictr  rw   r%  r   remover   r   r   r   r   rr   rs  rt  r'  copydeepcopyr[   r   r  crackline_bindlangr|  rL  cracktypespec0
updatevarsfindrT  r   rX   namepatternr  r  r  ro   get_parametersdetermineexprtyper~  real16patternfinditerr  r   evalSyntaxError	NameError	TypeErrortypespattern4implicitcracktypespecr   ordchrr   	enumerate
setdefaultgetdimensionfindallr  
IndexErroranyextendr8   r   
isinstancer   appendmultiline)Hr   r?   r0   r/  newnamerq   r  r   r3  r   	bindclinex
needmoduleneedinterfaceitr{  bindcdattr4   selectorattredecl	last_namer   iplchr  r^  apinitexprr  ttvr   implrx  r_  
kindselect
charselectro  r   begcendcodlilrc  fcinpr   r.  r   idxvtypevdimmatchesnew_valexpanded_listr   
multipliervaluecurrent_valclbnol	commonkeymmisonlyr   r!  gcsH                                                                           r)   rV  rV    sK    GGFOE{{t#GG}!1''""?399#>qAQT[[	]#a'"+	,#%
< "$	,+-
< (+-
< (,5
< )+2
< (+4
< (++88OUBDD11 EXX(%66#EXX-ubdd;;(EF?3AGGG4DEND59U5KJ|$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,}!2|a/08/4K
<(0 |a/08*\TUEU:VW]:^4`
<(0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<@2;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 ' 
6qwww7GH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,,Z1#4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# OST UW   !69:!< =]]U1X%a$++B/(*ta$z!l+G4	AGHJ|4V<<j&>><>J|,[9<(5<<Q?Ik Fl ,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Z55!,/
;|SU#AGGG$45;;EBXXPRSUWUYUY[_cdeg*00&1ABhlmnp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}  AB  BC "3t9c$i!m<'+SV = H1 CP 48J|$Z0c d 
!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qtzz|JAaD!A$ts##tABx!ts##Y\]^_\``a#I.QRSTQUBVB\B\]bBc.dBcQwwyBc.d$efQ<<$$]`aab !A$; \_`ab_ccd2&QJ/#DG,:?9:L"**Z16RSTURVR\R\]`Ra\EIhoodii.@AwWZ|G& #1gkk#.K7$:`acnpwxy&Q	W g f ,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 $ SVZ[\V] ]_ !"1CEJ|,U3D9%@  !++- GH	%	%Z%==;=J|$%78|$%78776?j(Z1_!J---!":*jM  !12!"!1Aaggfo		#wHI
2(!,	) Q;!++- BC CJP      ."NL Fv = @ hikmnp0  I6 #S* +h *K( %# }  AB  !BC$%r /e* " \
 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EIhoodii.@AwWZ|G#\V L& @sD  Ar7Ar AAr" "Ar3 0AsAs	As@As@-AsAAsF1As>PAt;P!At6P:At;[Au^&,Au dAyiAyr
ArrArr"
Ar0r/Ar0r3
Ass AssAssAs;s:As;s>At3tAt.t.At3t6At;t;AuuAuu .AyvA AwwAyw)Aw>w:Ayw=Aw>w>AAyyAy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   r6  r  r  r   r0  )r   r   r   r   r   selectpatternrT  r2   r  rs  rt  ri  r  )r4   r   r  r  r^  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#  R  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$ )	a   
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)   markinnerspacesr,  a  s      HFMGd?q$55MHG!{*MZF#X&H  Or(   c                 T   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      -  5        M9  [#        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au  [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  [        S/U< SUS.   < SUS-   < S35        OUS-   US.'   S#U;   ap  S0US#   -  nSU;  d
  US   (       d  U/US'   OrUS   R                  U5        US    H4  nUSS1 S2:X  d  M  UU:w  d  M  US   S3	 [/        SU< S4U< S5U< S35          O#   O [        S6UUR                  S5      -   -  5        [+        UR-                  5       5       H  nUU   (       a  M  UU	 M     U[$        [&           S   U'   S7[$        [&           ;   a  [$        [&           S7   R                  U5        UnGM     U$ s  snf s  snf s  snf )8z
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   rg  z@ @r'  z;updatevars: no name pattern found for entity=%s. Skipping.
rq   r.  r4   z+updatevars: attempt to change the type of "r  r  z". Ignoring.
rl  z0updatevars: attempt to change the kindselector "r  rm  zupdatevars:z*: attempt to change empty charselector to r   z0updatevars: attempt to change the charselector "ro  z/updatevars: attempt to change the typename of "rk  r  r3  r1  r  )rX   arrayinit2rX   r/  r
   r  r   r$  zupdatevars: "z" is mapped to "r4  z)"
r  r7   r  r5   r0  rn  z6updatevars: attempt to change the init expression of "dimension(%s)	   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#  r,  r   r  r2   r   rr   r;  r   r  rs  rt  ro   r~  lenarraypatternrT  r  ri  )r4   r  rk  
entitydeclr  r  r  ro  r  r   r   r)  r   selel1r  e1enamer  not_has_typespecr{  r^  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 NRVWXRYZ\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=(2g;6B!.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aQ  U S;   a  [         R                  U5      nU(       d  [        S[        U5      -  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      -  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     OvU S:X  aY  [        R                  " SU[        R                  5      nU(       a  UR                  S5      nO1[        S[        X-   5      -  5        O[        S[        U5      -  5        X#U4$ )Nr2  z4cracktypespec: no kindselector pattern found for %s
kind2r   r  z4cracktypespec: no charselector pattern found for %s
charlenlenkind)rX   kindr1  f2py_lenrh   z\s*\(\s*(?P<name>\w+)\s*\)rq   z'cracktypespec: no typename found in %s
z'cracktypespec: no selector used for %s
)rl  r   r2   r   r  rs  rt  itemsrr   rm  lenkindpatternr%  r   r   r   )	r4   r  r  r  ro  r{  r  rD  r>  s	            r)   r  r  /  sR   JJH@@%++H5JKtT\~^`#--/J(1JsO7#*//+,!}}" - Z--/0 *1
 1$%++H5JKtT\~^`#--/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 >(^% &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 $ )Nrk  rJ   	automaticr  r  r  )rx  r  rz  s      r)   ru  ru  k  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 $ )Nrl  rs  rt  rx  selrz  r{  s       r)   rv  rv    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 $ )Nrm  rL  rM  s       r)   rw  rw    sa    T!"^#((*A.11&)fD #  Kr(   c                     SU ;   a  U S   $ U$ )Nrq   r'   )r/  unknowns     r)   getblocknamerR    s    V}Nr(   c                 F    SU S   < SU S   < S3q g ! [         a     g f = f)NzIn: r  r  rq   r   )r    r   )r/  s    r)   setmesstextrT    s,    ,1&M5=I 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)r/  usedicts     r)   rW  rW    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-  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 %s not impl.
z(get_useparameters: overriding parameter z with value from module )
rW  rs  rG  r   r   r2   r~  r  ro   r   )	r/  	param_maprY  usenamemappingmvarsr  r{  r  s	            r)   get_useparametersr_    s     	% G 1--/-'eii/1 2g&&CwOP(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   r.  rl  rE  r-  )r   r  rs  
postcrack2rT  r2   r_  rt  )r/  ra  r[  gretr.  r   varrE  valbnew_bodys               r)   rc  rc    s!    =%1 !tyA 	 
sE&M2A6%e,	5V}diik"A'C$>*T>v,C''0~V # v(&A 1*	B&  (&ML/&(s   C2C7c                 L   [        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SX4-  U;   a  US-   nSX4-  U;   a  M  SX4-  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   ra  rq   r  r/  z0postcrack: Expected block dictionary instead of r  rb  r   r   r.  sortvarsr3  r-  r  r
   r1  r2  __user__routinesunknown__user__routinesr   z%s_%ir  _user_interface)r/  r-  r.  rq   r   r  )r/  r-  r.  rq   r2  )r  rs  rT  	postcrackr'  r  r   r   r2   analyzeargsanalyzecommonanalyzevarssortvarnamesr~  analyzebodyrt  r  r[   
isexternalr   )r/  r3  ra  greturetrd  userisdefineduseblockr{  rq   r2  r^  mnamer  r  r  edefjrh  bbmblocks                        r)   rp  rp    sm    %AN!t,A{zQvY6AA  {eT""we';JE
# $ 	$uV}0CC3f6:E% E&E&M$U6]3E*yyV}5E&MM~<hmmo&AQ$$Q' ' DV}yy
5 |,J		%-(--E-E!AUJ&-7E UJ&-7uj(E)20A)AC	{#AvAAAz[0"#F)B !AA%|6
a'+yy}$%fIaL % #,  4#$V9$)&M!$4 *+;+;A+> ?! ' &!((.:j&:&:+08If%a(- $. 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$ )Nrr  r   r   zTsortvarnames: failed to compute dependencies because of cyclic dependencies between r  r   )rs  rt  r'  rX   ro   r   )r.  indepdepr  r   r  r[  ws           r)   rt  rt  [  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   ;   aX  SU S   U   ;   a-  U S   U   S   R                  SS	R                  U5      -  5        OLSS	R                  U5      -  /U S   U   S'   O-U(       a  SSS	R                  U5      -  /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   r.  rk  r3  r$  z:analyzecommon: failed to extract "<name>[(<dims>)]" from "z" in common /z/.

commonvars)	hascommonrs  rt  r   r   r   r   r%  r&  r   rr   r'  r   ro   )	r/  r  r{  comvarsr  r   r  r  r   s	            r)   rr  rr  }  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;;+sxx~>@ ,sxx~>8@fa(4 &CHHTN)K(L,Nfa( ,.fa(&%%a(ijlmnpNN19 $: %h? *@ 5 (l L $L1J>lL9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 )Nr.  rk  r  r-  rV  r/  r  rq   r3  z
      Tas_interfacesaved_interfacer   rk  r  r  r  r   r
   pythonmoduler  )rT  rG  rt  r#   r'  r$   crack2fortrangenrp  r~  r   r   r   )	r/  r3  ra  keyr  maybe_privater-  rh  as_s	            r)   ru  ru    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                 F   [        U 5        [        n0 nSU ;   a  U S   c)  S n[        S:  a  [        S[	        U S   5      -  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   z6buildimplicitrules: no implicit rules for routine %s.
rq   r4   )rJ   rJ  )rT  defaultimplicitrulesr   r2   r   rs  rt  r~  )r/  implicitrules	attrrulesr{  s       r)   buildimplicitrulesr    s    (MIU$ M{MPTUZ[aUbPcce ## %
+0023$Q'++J7?VV',Z'8';M$#(#4Q#7
#CIL	 4
 ##r(   c                 l    [        XU5      n[        U5      [        [        4;   a  U$ [	        SU-  5      e)z1Like `eval` but returns only integers and floats zr=%r)r  rh   r8   r:   r   )r  rd  r   r   s       r)   myevalr    s1    Q1AAw3,
Vq\
""r(   z\A\b\w+\b\Zc                 n    [        [        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HX  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(       aE  UR                  S5      < S	S< S
UR                  S5      < 3nUR	                  U5      nU(       a  ME  [        W0 0 5      n	UR	                  U 5      nU(       aE  UR                  S5      < S	S< S
UR                  S5      < 3nUR	                  U5      nU(       a  ME  [        U0 0 5      U	-
  n
UR	                  U 5      nU(       aE  UR                  S5      < S	S< S
UR                  S5      < 3nUR	                  U5      nU(       a  ME  [        U0 0 5      nUR	                  U 5      nU(       aE  UR                  S5      < S	S< S
UR                  S5      < 3nUR	                  U5      nU(       a  ME  [        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  r4  r5  r  g      ?g      ?)NNN)r8   r  r   getlincoef_re_1r   rX   r   r  r   r   r   )r  xsetr   len_er  r]  r   r^  eerh  r)  c2s               r)   
getlincoefr    sk   *q"b!"!Tz Q!QwFEq6E>99&*U2A66zz.25GGNJJqM1ZZ]*Arxx/@BBBB b 2r2&ZZ]*Arxx/@BBBB b 2r2&*ZZ]*C'1BDBBB b 2r2&ZZ]*C'1BDBBB b BB'GaK1$S1):7N Q P s:    
**AJ"5A(J"A+J"A(J"6(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      -  5        / nX2U '   U$ )Nrr  rn  z,_get_depend_dict: no dependence info for %s
)r~  isstringword_patternr  r'  _get_depend_dictr2   r   )rq   r.  depswordswordr  s         r)   r  r  =	  s    |
x,$*Xdj%9%9$,,TZ_= $$,LL&	 >
 !HDXXdB' :'D9:>LLO:  	?4:NOJLr(   c                 f    [        U R                  5       5      n0 nU H  n[        X0U5        M     U$ r,   )rs  rt  r  )r.  ru   depend_dictr   s       r)   _calc_depend_dictr  S	  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  rs  rt  r'  rG  )r.  r  ru   rq   lstr   new_lsts          r)   get_sorted_namesr  [	  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(r5  )r  r   real8pattern)rc   s    r)   
_kind_funcr  m	  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   r0  l        r  l            r        r   r'   )r   r   s     r)   _selected_int_kind_funcr  x	  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  	  sn     	1u2v &&(Gwxx7  	 r6"W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) NrE  selected_int_kindselected_real_kindrk  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*\)rn  ))z.false.False)z.true.Truez
kind("\1")zselected_int_kind(\1)Frl  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   isdoublers  r  r  r  r   	iscomplexr2   r   removeprefixr   r  r  
param_evalr   r  r  r8   r  r  )r.  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   r7  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   rs  rt  )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      mAU S   S:X  a  U S   TA;  a  0 TAU S   '   SU S   ;   aq  TAS	 SU S   S   ;   ab  U S   S   S   n[        TA5      [        S U S    5       5      -   H2  nS	 H)  nXS;   d  M
  [	        TAR                  U0 5      U5      TAU'   M+     M4     / nU S
   nU H  n TAU     UR                  U5        M     [        TAR                  5       5       H  nXG;  d  M
  UR                  U5        M     [        TA[        U 5      5      n	0 n
[        R                  " S5      R                  n[        TAR                  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  [	        TAU   X$S      5      TAU'   STAU   ;  a  STAU   ;   a  STAU   S   ;   d  U(       a  US   R%                  5       n[        X   R                  5       5       HV  nUS:X  a  X   U   S:X  a  M  UTAU   ;  a  X   U   TAU   U'   M.  US:X  d  M6  X   U    H  n[	        TAU   U5      TAU'   M     MX     O(X@S
   ;   a   ['        S[)        U5      < SU S   < S35        STAU   ;   a9  STAU   S   ;   a-  TAU   S   S   n [+        [-        U0 U	5      5      nUTAU   S   S'   STAU   ;   a9  STAU   S   ;   a-  TAU   S   S   n [+        [-        U0 U	5      5      nUTAU   S   S'   0 nSTAU   ;   Ga  TAU   S   nUR1                  5         / TAU   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OrUSS S :X  a  USS R3                  5       SS nORUSS! S":X  a  US!S R3                  5       SS nO2USS# S$:X  a  US#S R3                  5       SS nO[	        TAU   U5      TAU'   U(       a  STAU   ;  a  / TAU   S'   [5        U5      R7                  S%5       Vs/ s H  nUR3                  5       PM     sn H:  nUR9                  S&S5      nUTAU   S   ;  d  M#  TAU   S   R                  U5        M<     SnU(       aP  UR9                  S'S(5      nUR9                  S)S*5      nS$TAU   ;  a
  U/TAU   S$'   OTAU   S$   R                  U5        SnUb  S TAU   ;  a  / TAU   S '   [;        [5        U5      R7                  S%5       Vs/ s H  nUR3                  5       PM     sn5       H(  nUTAU   S    ;  d  M  TAU   S    R                  U5        M*     SnUc  GM(  S"TAU   ;  a  / TAU   S"'   [5        U5      R7                  S%5       Vs/ s H  nUR3                  5       PM     sn H(  nUTAU   S"   ;  d  M  TAU   S"   R                  U5        M*     SnGM     U(       Ga	  STAU   ;  Ga  / TAU   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  S0U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                  S19n0 n U S    H  n[F        RR                  " U5      n!URU                  U!5      (       d  M1   URW                  U!5      u  nn"UU"4S2 jn#[        URY                  5       5      n$U$R[                  U"RY                  5       5        [        UA4S3 jU$ 5       5      n&U#[        U&5      4U U'   M     U UU'   TAU   S   R                  U5        GM     S"TAU   ;  Ga  S
U ;   Ga  X@S
   ;   Ga  TAU   R                  S / 5      n'/ n([_        [`        [b        [d        5      " TAU   5      n)[g        TAU   5      (       Ga  [i        TAU   S   5       GH  u  n*nUR                  U5      m?T?c  GOU)(       Ga  T?Rk                  5        GHq  u  nu  n+n,U?U@4S4 jm@[        5       n-T@" UU-5        UU';   d  S5TAU   ;   d	  S TAU   ;   a  M>  U+b  UU-;  a|  S6n.U+" [F        RR                  " S7U S8U* S935      5      n/U/RM                  [F        RN                  RP                  S19n/U/TAU   S5'   U/U,-   TAU   S '   S"TAU   ;  a  S7U S8U* S:U 3/TAU   S"'   OaS;n.STAU   ;  a  / TAU   S'   S<TAU   S   ;  a  TAU   S   R                  S<5        U'R                  U5        U(R                  S7U S8U* S:U 35        TAU   R                  S/ 5      n0S=U0;   d   S>U0;   d  U0R                  U.(       a  S>OS=5        U0(       d  GMi  U0TAU   S'   GMt     T?c  GM  T?Rk                  5        H  u  nu  n+n,TAU   R                  S / 5      n&TAU   R                  S/ 5       H]  n1U1Rm                  S 5      (       d  M  SRo                  U1R7                  5       5      n1U&Rq                  U1S?S R7                  S@5      5        M_     U&(       a  [        [        U&5      5      TAU   S '   UU&;  d  M  U'R                  U5        M     GM     O~[s        TAU   5      (       ak  STAU   ;   ab  S-TAU   S   ;   a!  [u        TAU   S   S-   U	5      n2U2TAU   S   S-'   O5STAU   S   ;   a)  [u        TAU   S   S   U	5      n2TAU   S   S	 U2TAU   S   S-'   U((       a  U(TAU   S"'   U'(       a  [        [        U'5      5      TAU   S '   S5TAU   ;   d  G
ML  STAU   ;  a  / TAU   S'   S=TAU   S   ;  a#  S>TAU   S   ;  a  TAU   S   R                  S=5        S TAU   ;  ai  / TAU   S '   [        U
Rk                  5       5       H1  u  pU" TAU   S5   5      (       d  M  TAU   S    R                  U5        M3     TAU   S    (       d  TAU   S 	 [w        TAU   5      (       d  GM  [y        TAU   S5   U	5      TAU   S5'   GM/     [        TAR                  5       5       GH  nX@S   :X  d  M  S$TAU   ;   a  TAU   S$   U S$'   U S   S:X  d  M-  SAU ;   a!  U SA   TA;   a  [{        TAU   TAU SA      5      TAU'   SBU ;   d  M\  U SB   n3U3R9                  SCS5      n4U3U4:X  + n5U4R9                  SDS5      n3U3U4:X  + n6[|        S   R                  U35      nU(       a  [        UR                  SE5      UR                  SF5      5      u  n7n8nn9[        U7U85      u  n:n;n<U7TAU   S'    U SA   (       a  U7TAU SA      S'   U:(       a"  SU:;   a   [-        U:S   0 U	5      U:S'   U:TAU   S'   U;(       a  U;TAU   S'   U<(       a  U<TAU   SG'   U5(       a  [	        TAU   SC5      TAU'   U6(       a  [	        TAU   SD5      TAU'   GM  GM  ['        SH[)        U SB   5      -  5        GM     U S   SI;  Ga  SJU ;   a   [        R                  " U S
   U SJ   -   5      n=O[        R                  " U S
   5      n=[        TAR                  5       5       H8  n[_        [        [        5      " TAU   5      (       d  M'  U=R                  U5        M:     SKU ;   av  U=Rq                  [        U SK   R                  5       5      5        [        U SK   R                  5       5       H+  nU SK   U    H  nUU=;  d  M  U=R                  U5        M     M-     U S   S:X  a/  SAU ;   a  U=R                  U SA   5        OU=R                  U S   5        U S   SL;   a  U S   n>U>TA;   a  STAU>   ;   a  TAU>   S   U S'   U S   SM:X  a(  U=Rq                  [        TAR                  5       5      5        [        TAR                  5       5       H  nUU=;  d  M  TAU	 M     TA$ ! [         a     GM  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! [.         a     GNpf = f! [.         a     GN`f = f)Nz@
Sets correct dimension information for each variable/parameter
r.  r/  r   rq   r
   rk  c              3   *   #    U  H	  oS    v   M     g7f)rq   Nr'   )r  rh  s     r)   r  analyzevars.<locals>.<genexpr>)
  s     $F1vYs   r-  r  r3  z[A-Za-z][\w$]*z.*\b%s\br   r4   r  	undefinedz"analyzevars: typespec of variable z is not defined in routine z.
rm  rX   rl  rE  )NNNNNNr4  r  r   r   r   r
  rr  r   rq  r  rp  r#  r   z\n\nz

z\n r   z4analyzevars: could not parse dimension for variable r  r   z@:@r0  1)languagec                     X-
  U-  $ r,   r'   )r7  r)  rh  s      r)   solve_vanalyzevars.<locals>.solve_v
  s    01{(:r(   c              3   `   >#    U  H#  nUR                   T;   d  M  UR                   v   M%     g 7fr,   )r  )r  r7  r.  s     r)   r  r  
  s(      -74?q'(vv~ %+AFFKs   ..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(   rn  Fzshape(r  r5  z) == Tinr  r  r  r$  r   r  pure	recursiver6  r  ro  z'analyzevars: prefix (%s) were not used
)r  r  r  r  r  r  )r   r   rh   )DrT  r  r  r  ru  r~  r'  KeyErrorrs  rt  r  r_  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symbolsrX  RuntimeErrorl_orisintent_inisintent_inoutisintent_inplaceisarrayr  rG  r   r   r  r  r  isscalarr  r|  rL  r  r   r  isintent_callbackisintent_aux)Br/  r  r  genr   r{  svarsr3  r)  r  dep_matches
name_matchr  r   ln0r   dimension_exprsr  dimr
  rr  rq  rp  r  r   tmpr!  dim_charr  r=  d2dsizesolver_and_depsr7  rh  r  all_symbolsr   v_depsn_depsn_checks
n_is_inputr  solverr  all_depsis_requiredr0  v_attraar  prpr1ispureisrecr4   r  r  r  r  ro  
neededvarsrq   r  r  r.  sB                                                                  @@@r)   rs  rs  
  sH    1%8M99U6]#DW~#fT(A U6]	U6]Hvr**-#J/CY$Ff$F!FF.Ax"-dhhq"oq"AQ / G E=D	GLLO  $))+=LLO  D"3E":;F K-.44J$))+qM1'')AEEG$AK  Q44	())!$q'9qT?;DGT!W$a(Z47:;N-N A$**,C!-"4"9"9";<
?}/A!/D/S$DG+)6);A)>DGAJ*_%2%7%:*5d1gq*AQ &; = -'Qv0 1T!W$Q//GN+E2DB/0A 23Q'.T!W$a00GN+F3DB/0A 34Q'/a 7:&DLLN"$DGJ/K,CRa5K'QR5;;=!B/CrUh&ekkmQr2FrUh&ekkmQr2FrUg%qrU[[]Ab1ErUf_abEKKM1R0D)$q'15DGtAw.,.Q)1?1G1M1Me1TU1TAaggi1TUiiR0d1gh&77 GH-44S9	 V
 "F<<&9D<<5DT!W,+/&QQ..t4D%tAw.,.Q)&>&;Q;W;WX];^'_;^a	;^'_`DGH$55 GH-44Q7 a "F$d1g-+-Q(1?1F1L1LU1ST1SAaggi1STDGG$44 GG,33A6 U !EW X {$q'1')Q$",: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+@DAq56! %; 36aiik2BK$/$6$6qyy{$C *- -74?-7 *7 6=d6l5J 2- "/: .=*GK(//2B $q'!fo!V}:L
 !W[[2.FHk>.004Q9JtAw%d1gk&:;DAq&5&9&9!&<O&.# 2A1F1F1H-A~?
 (+uH(H5 !V$'47N$,Q$7
 !)%1ax6G /4'-h.@.@&,QCr!A$6/8 (9'+}}-5->->-@-@ (5 (B/3Q 67C$JQ 1#*$q'#9 +12aSaS(A8CDGG$4 /3#+47#:8:DGH$5#'tAwx/@#@$(GH$5$<$<T$B &a 0 (&,QCr!E!$=!?%)!W[[R%@F$.&$8'1V'; &2=J:!O%v6<Q
 3m 2In '21@1F1F1H-A~%)!W[[2%>F&*1gkk*b&A#%==#:#:)+)<B$*MM"Qr(..2E$F 'B  &48V4EQ 1  &a 0 2IE <X $q'""!T!W,d1gn55!-d1gn.Ec.J.4"67=Q/4$q'."99!-d1gn.Ee.L.4"6 GN3E:7=Q/4#+Q $(V$5Q!$q'>a(&(Q
#$q'*"55$q'*"55Q
#**:6tAw&$&Q! !2!2!45DAaQ)003 6 Awx(Q)Q  +DGCL&AQ[ ^ $))+fa  $QfW~+u$xD)@(a$uX2GHDGu$xB**VR0C"$mF["5B!#s]E$Q--b1A:HGGFOQWWW-=;?7(D%;H$h<08
J.6Q
+!$XDLU8_ 5j A &%3!)9=(26(:B:HJv$6 7ADGN3%6@DGN3#2:DGJ/!&1$q'6&BDG &1$q';&GDG !  FeT\oI^^`U X W~VV5 5=53F#FGJ5=1Jdiik"A%|4T!W==!!!$ # 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 # KU  		"  K!#K1,=rtt!D!J!JK2 !  ! 4 V" (` U N '
H= (()uB0F (4 !G /3G25emmo2FK!GD  ) ! ! (1 !)$(!)s   AB-AB)AC+AC-,AC>ADAD"AD
ADAAD>9AE1AFB
ABBABB>ACCACC
AC*C)AC*C-
AC;C:AC;D%AD;D:AD;D>
AE.	EAE)	E)AE.	E1
AE?E>AE?F
AFFAF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   r0  r   re  zparam_eval: dimension z can't be parsedr   r$  r   r  z.param_eval: multidimensional array parameters z not supportedz(/r   )r  r   r2   rX   r   r&  r  r   r8   r   r'  r  zip)r  r  r  r  r  r   dimrangeboundlbounduboundv_evalitems               r)   r  r    s   & 	;Q&)A  7|a7#3S\!^#34<1':KLMMq}""3'H
8}A;$$S)x=AV4EQE
1-H !f5F !f5FS[#f+a-8H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
r4  Nr   r5  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#;&&+a-- 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  X1S   ;   a  US   U   US   U '   O0 US   U '   S
U;   a&  X1S
   US   -   ;   a  [        US   U    S5      US   U '   U $ )Nr.  e_r   r   r  _er3  r   r   r1  r2  r  )
analyzeargs_re_1r   r  r  r   rc   ascii_lowercasedigitsr   ru  )r)  r/  r3  orig_a	a_is_exprr  r  atnar   r{  s              r)   	expr2namerF  1  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&#(=#8fa #%fa %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 $ )Nr3  r  r.  r-  rq   r1  r   )rT  r  rF  r'  rs  rG  )r/  r  r   r3  r)  r{  args1rh  s           r)   rq  rq  V  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  r  AssertionErrorr   )r   s    r)   _ensure_exprdictrK  x  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(       aE  SUR                  5       ;   a-  UR                  S5      (       a  [        S[        U 5      -  5        SS0$ [        R                  U 5      nU(       aE  SUR                  5       ;   a-  UR                  S5      (       a  [        S[        U 5      -  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      -  5        U$ s  snf )Nr4   r  rq   z:determineexprtype: selected kind types not supported (%s)
r7   r5   )+r  r   r  r.  rf  r   r   rk  r   r  r  r   )r4   rm  z>determineexprtype: could not determine expressions (%s) type.
)rK  r   determineexprtype_re_1r   determineexprtype_re_2r  r   r2   r   determineexprtype_re_3r%  r&  determineexprtype_re_4r  determineexprtype_re_5)	r!  r.  rulesr   opr  r  r  rns	            r)   r  r    s   |
++::<D##D))I&&$$T*AQ[[]"qwwvMPTUYPZZ\I&&$$T*AQ[[]"qwwvMPTUYPZ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MQUVZQ[\	^H+ [s   (H9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 ;   af  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      -  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   -  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   -  nSU ;   aT  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
   r/  r  rq   r  r  r3  r.  r   z(%s)r$  r  r   r
  callbackintent(z) r  r  r  r   z result (%s)r-  r  z! in %sr  zentry r4  r5  r  r  zend )rT  r  rs  r#   r$   r  rF  r  r'  r   rt  r   r~  r  use2fortrancommon2fortranvars2fortranrG  )r/  ra  r  re  rd  r  rq   r3  	blocktypeargslr.  r)  r  r{  
intent_lstr  r  r   r-  messentry_stmtsr  s                         r)   r  r    s"    
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CHHUO+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%/1?%'LLx)E&M3=|TDV}e7]ODD|5=(%w--/0DAq(#-CHHQKIK 1 k!L T^%;VYdFD:JCQUW]_cehjsuy{CJr(   c           
          Sn[        U R                  5       5       HI  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MK     U$ )Nr
   r  zcommon r$  zcommon /z/ )rs  rt  r   )r  ra  re  r{  s       r)   rZ  rZ    sZ    
C&++- =%(#sxx	/BCC*-sAsxx	7JKC	 !
 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  SU-  nSX   ;   ai  X   S   (       a]  Sn[        X   S   R                  5       5       H9  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M;     U(       d  M  US   S:X  d  M  US S nM     U$ )
Nr
   zuse r$  r   r  z%s only:r  r   z=>rL  )r  ra  re  r   r   r{  s         r)   rY  rY    s   
C#((*"C+6R<s2w#~#2hSVv$CCF?sve}A#&-,,./Aua((&)1a0CA*-q!SVE]15EFCA 0 33r7c>cr(C% & Jr(   c                     U S   n/ nU H4  n [        5       SU-     nU" U 5      (       a  UR                  U5        M4  M6     U$ ! [         a     MG  f = f)Nr
  zisintent_%s)globalsr'  r  )rf  r  re  r
  rc  s        r)   true_intent_listre    sg    
h-C
C	#	-&01A 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 ;   a9  U S    H0  nXq;   a  Xv;  a  UR                  U5        M   M"  [        SU-  5        M2     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    H5  nX;   d  M
  SX   ;   d  M  XqU   S   ;   d  M!  [        SU< SU< S	35        M7     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-  5        M  XpS   :X  a"  U S   S:w  d  U R                  S5      (       a  GM)  SX   ;  aE  SX   ;   a  SX   S   ;   a  Xr;   a  U< U< SU< 3nGMX  [        X   5        [        SU-  5        GMv  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OLU< S US    < 3nO?S#U;   a&  U< S$US#   < 3nS%U;   a  U< S&US%   < S3nOS'U-  nOS%U;   a  U< S(US%   < S3nS)nSX   ;   ad  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S/X   ;   a#  U< U< S0S.R                  X   S/   5      < S3nS.nS1X   ;   a2  [        X   5      nU(       a  U< U< S2S.R                  U5      < S3nS.nS3X   ;   a#  U< U< S4S.R                  X   S3   5      < S3nS.nSX   ;   a#  U< U< S5S.R                  X   S   5      < S3nS.nS6X   ;   aK  X   S6   nX   S   S7;   a+   [        U5      nSUR                  < S.UR                   < S3nU< S8U< S6U< 3nO	U< S8U< 3nU< U< U< 3nGM     U$ s  snf ! ["         a     N:f = f)9Nr
   r.  r  z7vars2fortran: Confused?!: "%s" is not defined in vars.
r  rr  z;vars2fortran: Warning: cross-dependence between variables "z" and "r  r1  zintent(callback) z	external z	optional r4   r   r-  rq   r/  r   r   z/vars2fortran: No definition for argument "%s".
r   rk  r  z-vars2fortran: No typespec for argument "%s".
rh   ro  r4  r5  rl  rm  r   )r   r  z*(rX   z(len=rE  z,kind=z%s)z(kind=r   )r  z
intent(in)zintent(out)r  r$  r  z
dimension(r
  rX  rq  zcheck(zdepend(rn  )r  r  z :: )rT  r'  ro   r  rs  rt  r  
isoptionalshowr2   r~  r  r   re  r  r5   imagr   )r/  r.  r3  ra  r  re  noutr)  r!  r   rh  vardefr  r   r   r  r  r  s                     r)   r[  r[  ,  s   
CDfKKN  u|$Ay=KKN ! NQRRT % UE*%&diik"A}A # twWX&9TW!41gh>O9Oghjkln ' %A{);$; ))36Q?'*C3C$'""+.Q7yZtw6D6]&	>ajJ&>D # =JFJKfW~+uyy/B/B
 TW$TW$twz7J)J9/2C;CMDqHI$V
dg 5!')<=FTW$w~.Htw&w~.H(?}
*&,hsm<$*HSM: (.@X%.4hv6FGF"f-F8#*0(62BC #wz2 .2!, 2D . 4$9N M*%+SXXd^<$'!388DGK$89;FAtw"47+C-3QFAdg(.388DGG<L3MNFAtw388DGH$568FA$'>Awz"&CCQA%&VVQVV4A '-a3F#)1-FsF+O P JQ.D ! s   
R	R	6*R
RR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   r9  r   rp  r   post_processing_hooks__name__traverserc  )filespostlisthooks      r)   crackfortranrs    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)r/  pyfheaderfooters       r)   crack2fortranry    s:     5
!D
(CF 	F
 <&  r(   c                     [        U [        5      =(       a.    [        U 5      S:H  =(       a    [        U S   [        [        45      $ )Nr0  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      (       aF  / n[        U 5       H4  u  p[	        X4U/UQ7X'/-   US.UD6u  pUc  M#  UR                  U5        M6     O][        U [        5      (       aF  [        5       nU R                  5        H'  u  p[	        X4U/UQ7X'/-   US.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   rV  N)parentsr   )r}  r  rs  r  ro  r'  r  rG  )r|  visitr  r   r3  kwargs
new_resultparent
result_keyr[   r  	new_indexnew_itemr  new_key	new_values                   r)   ro  ro    si   8 cq6^#J3A$A&A
!!*----
C
#t
%cNLE"*E>5 #K;?#K3:X3E28#KCI#KI $!!(+ + 
C		V
))+JC!)3, "J:>"J29H2D17"JBH"J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  rq  r   r.  r   rn  r   Ncallstatementz
(?<![&])\br  r   zcharacter_bc_hook[r  z]: replaced `z` -> `z`
)rG  ischaracterr   r  r2   )r7  r  r   r3  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-verboser0  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 %s
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 %s
r  )r   )r   )r$  )rQ  r,   )r
   N)Nr
   )r
   )NN)r   r   )r   F)r
   F)__doc__r-   rc   r   r   r   r  r  r   pathlibr   r   ImportErrorr
   r   auxfuncsr   versionru  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   rh  r   beforethisafterfortrantypesrL  r  rI  rJ  groupbegins77r   groupbegins90r   	groupendsrG  endifsrF  moduleproceduresrR  rK  r<  r=  r?  r@  rC  rD  rE  r>  rA  rB  rN  rQ  rU  rM  rO  rP  rH  Sr7  r8  r   r*  rS  crackline_bind_1r  r9  rT  r%  ri  r|  r  r  r  r  r  r  r  r  r  r  r  r  rV  r  r  r  rl  rm  rH  r5  r#  r,  r  r  ru  rv  rw  rR  rT  rW  r_  rc  rp  rt  rr  ru  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rs  r?  r  r  rF  rq  rN  rO  rP  rQ  rR  rK  r  r  rZ  rY  re  r[  rm  rs  ry  r}  ro  r  r'  rn  rp  funcsrc  f2f3showblocklistargvr   ro   r   r   r   OSErrordetailrq  rv  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D 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GH 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    DD(4 jjErttLzzI244Qzz9244A235449 ** G  IK  IM  IMN"JfR8,x6<@]@D(V*Z$&# **^RTT2EP zz,bdd3,4$" & (* bJ( **W%++ DN ::12448 ;|M`   "J4 $6= $DbddK 12449 M2448 $ErttL 	" )+ (ZHV0}F  ""!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[)DG34BKBM2QQ LLOc d 9}}  	 E"H{3d;6GGKH%+s#qGGCL $X Q Gn  po  2)F:R0112" $#s5   l= %)mm.=m	m	m+m&&m+.
m<