pearu / f2py

Automatically exported from code.google.com/p/f2py
Other
54 stars 37 forks source link

Fixed Form and AttributeError #50

Open Hbethray05 opened 5 years ago

Hbethray05 commented 5 years ago

Hello,

I have never had an issue using f2py to compile my 'helinerd.f' fortran code in the past, but now it seems it will not work. In the past when it worked I wrapped the fortran code for python by inputting this in terminal:


$ f2py helinerd.f -m helinerd -h helinerd.pyf


Then compiled the .pyf to get a .so:


$ f2py -c helinerd.pyf helinerd.f


Used to work like a charm.

Now I get a: Reading .f2py_f2cmap ... Successfully applied user defined changes from .f2py_f2cmap Signature file "./helinerd.pyf" exists!!! Use --overwrite-signature to overwrite. mba97427:Jorge_Routine hyq$ f2py helinerd.f -m helinerd -h helinerd.pyf Reading .f2py_f2cmap ... Successfully applied user defined changes from .f2py_f2cmap Reading fortran codes... Reading file 'helinerd.f' (format:fix,strict) Traceback (most recent call last): File "/Users/hyq/anaconda/bin/f2py", line 28, in main() File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/f2py2e.py", line 650, in main run_main(sys.argv[1:]) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/f2py2e.py", line 408, in run_main postlist = callcrackfortran(files, options) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/f2py2e.py", line 329, in callcrackfortran postlist = crackfortran.crackfortran(files) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/crackfortran.py", line 3247, in crackfortran readfortrancode(files, crackline) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/crackfortran.py", line 422, in readfortrancode 'this code is in fix form?\n\tline=%s' % repr(l)) Exception: readfortrancode: Found non-(space,digit) char in the first column. Are you sure that this code is in fix form? line='xc----------------------------------------------------------------------'

######################################################################### When I add '! -- f90 --' to the first line to fix for this error the error becomes:

Reading .f2py_f2cmap ... Successfully applied user defined changes from .f2py_f2cmap Reading fortran codes... Reading file 'helinerd.f' (format:free) Line #4 in helinerd.f:"c linerd Helium Line Ratio Diagnostic Subroutine " analyzeline: No name/args pattern found for line. Line #12 in helinerd.f:" subroutine helinerd(hryd,td_swtch,in_Te,in_Ne,ntexp,nexp," analyzeline: No name/args pattern found for line. Traceback (most recent call last): File "/Users/hyq/anaconda/bin/f2py", line 28, in main() File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/f2py2e.py", line 650, in main run_main(sys.argv[1:]) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/f2py2e.py", line 408, in run_main postlist = callcrackfortran(files, options) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/f2py2e.py", line 329, in callcrackfortran postlist = crackfortran.crackfortran(files) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/crackfortran.py", line 3247, in crackfortran readfortrancode(files, crackline) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/crackfortran.py", line 511, in readfortrancode dowithline(finalline) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/crackfortran.py", line 782, in crackline analyzeline(m, pat[1], line) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/crackfortran.py", line 1088, in analyzeline last_name = updatevars(typespec, selector, attr, edecl) File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/crackfortran.py", line 1544, in updatevars el = [x.strip() for x in markoutercomma(entitydecl).split('@,@')] File "/Users/hyq/anaconda/lib/python3.4/site-packages/numpy/f2py/crackfortran.py", line 822, in markoutercomma assert not f, repr((f, line, l, cc)) AssertionError: (1, ' daij = (/', ' daij = (/', ')')

This is a bit frustrating because I have never had this issue before until now. I need to recompile because I have changed things in the original helinerd.f code.

Any help would be greatly appreciated, Holly

Hbethray05 commented 5 years ago

I have narrowed down the issue. The problem seems to be in def markoutercomma in the script crackfortran.py . It does not know how to handle the '(/' in the first line of this section of the code::

  real(rprec), dimension(11), parameter :: dAij = (/
 &             dAij_319, dAij_389, dAij_447, dAij_471, dAij_492, 
 &             dAij_502, dAij_505, dAij_588, dAij_667, dAij_706,
 &             dAij_728/) 
Hbethray05 commented 5 years ago

Ok. I think this is the same issue as 'AssertionError when compiling dcuhre #47'. I missed where he said it was the empty spaces in the array. I only saw that there would be work toward fixing it. I am not sure what empty spaces in the array means, but I will give it a go.

pearu commented 5 years ago

While fixing this issue, note that the PR should be created against https://github.com/numpy/numpy