-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: crackfortran.py fails with 'common' blocks with Numpy version > 1.20 #22648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can't seem to reproduce this as an error. The f2py -v
1.24.0.dev0+943.g0075d59ce
f2py -c bug.pyf -m iri16py
python -c "import iri16py; print(iri16py.fircom.eden)"
0.0 This has the same result in NumPy 1.20 f2py -v
2
f2py -c bug.pyf -m iri16py
python -c "import iri16py; print(iri16py.fircom.eden)"
0.0 @jarau-de could you mention the exact EDIT: I think I see the issue, sorry, thanks for catching this! The problem is that the if f77modulename and neededmodule == groupcounter:
fl = 2
while groupcounter > fl:
outmess('crackline: groupcounter=%s groupname=%s\n' %
(repr(groupcounter), repr(groupname)))
outmess(
'crackline: Mismatch of blocks encountered. Trying to fix it by assuming "end" statement.\n')
grouplist[groupcounter - 1].append(groupcache[groupcounter])
grouplist[groupcounter - 1][-1]['body'] = grouplist[groupcounter]
del grouplist[groupcounter]
groupcounter = groupcounter - 1
if f77modulename and neededmodule == groupcounter:
grouplist[groupcounter - 1].append(groupcache[groupcounter])
grouplist[groupcounter - 1][-1]['body'] = grouplist[groupcounter]
del grouplist[groupcounter]
groupcounter = groupcounter - 1 # end interface
grouplist[groupcounter - 1].append(groupcache[groupcounter])
grouplist[groupcounter - 1][-1]['body'] = grouplist[groupcounter]
del grouplist[groupcounter]
groupcounter = groupcounter - 1 # end module
neededmodule = -1
return Takes the first ( NumPy 1.20 --> |
Thanks for looking into this. We suffer from the same issue. Is there a hotfix available that we could try out locally? |
I found a temporary hotfix. Install the latest version of numpy. Replace the folder |
@HaoZeke Would it be possible to increasing the priority of this issue? This is a critical bug that makes f2py unusable in recent numpy releases. |
@HDembinski, @jarau-de, sorry for the wait, the fix on #22657 now works. The actual issue can be traced to e6dab4f where the parser was updated to include the Fortran 2008 |
Thank you very much! Should I test-run this PR on my setup or do you think it is not necessary? |
@HDembinski if it would be possible to test the PR that would help give confidence that the fix is correct. |
Describe the issue:
It seems Fortran 77 'COMMON' blocks are not matched correctly. I got the following error message:
crackline: groupcounter=1 groupname={0: '', 1: 'python module', 2: 'interface', 3: 'block data', 4: 'subroutine'}
crackline: Mismatch of blocks encountered. Trying to fix it by assuming "end" statement.
Following code causes the error:
python module iri16py ! in
interface ! in :iri16py
block data ! in :iri16py:iridreg_modified.for
COMMON /fircom/ eden,tabhe,tabla,tabmo,tabza,tabfl
end block data
end interface
end python module iri16py
Unfortunately all interface signature code after the common block will be ignored. With Numpy <= 1.20 it runs smooth. All versions above causes this error. If I document out the 'common' line all behaves fine. Please fix that soon. I tried to find out the reason in crackfortran.py, but it seems a bit too complex for me.
f2py seems also to be fine if one removes the space between end block data -> end blockdata.
Reproduce the code example:
Error message:
NumPy/Python version information:
1.21 and above
Context for the issue:
I use a Python module which make use of old Fortran 77 code. Since f2py ignore all signature code after the COMMON block, the Python module routine gets not compiled in and the load of module fails. Without a fix to this issue I am forced to stay at Numpy 1.20 but I would like to update.
The text was updated successfully, but these errors were encountered: