-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Description
Describe the issue:
f2py for the release numpy==1.26.0 fails to generate *.pyf files for the any event generator model in chromo project: impy-project/chromo#127. However, it works for numpy==1.26.0rc1.
For the simplest model sophia f2py fails to generate *.pyf file with traceback:
Traceback (most recent call last):
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/__main__.py", line 5, in <module>
main()
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 734, in main
run_main(sys.argv[1:])
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 462, in run_main
postlist = callcrackfortran(files, options)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 363, in callcrackfortran
postlist = crackfortran.crackfortran(files)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 3355, in crackfortran
readfortrancode(files, crackline)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 552, in readfortrancode
dowithline(finalline)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 858, in crackline
analyzeline(m, pat[1], line)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1452, in analyzeline
vtype = vars[v].get('typespec')
KeyError: 'pi'
Reading fortran codes...
Reading file 'CMakeFiles/_sophia.dir/SOPHIA20.f' (format:fix,strict)
Other models also have the similar problems related to vtype = vars[v].get('typespec') and giving KeyError: 'name_of_data' where name_of_data in Fortran code is kind of:
DATA name_of_data /some_value/For sophia it is :
DATA pi /3.141593D0/It seems all the problems are related to recently changed code in 0df1365 , specifically in the file numpy/f2py/crackfortran.py:
vtype = vars[v].get('typespec')
vdim = getdimension(vars[v])
if (vtype == 'complex'):
cmplxpat = r"\(.*?\)"
matches = re.findall(cmplxpat, l[1])
else:
matches = l[1].split(',')
if v not in vars:
vars[v] = {}
if '=' in vars[v] and not vars[v]['='] == matches[idx]:
outmess('analyzeline: changing init expression of "%s" ("%s") to "%s"\n' % (
v, vars[v]['='], matches[idx]))
if vdim is not None:
# Need to assign multiple values to one variable
vars[v]['='] = "(/{}/)".format(", ".join(matches))
else:
vars[v]['='] = matches[idx]
last_name = vReproduce the code example:
N/AError message:
Traceback (most recent call last):
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/__main__.py", line 5, in <module>
main()
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 734, in main
run_main(sys.argv[1:])
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 462, in run_main
postlist = callcrackfortran(files, options)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 363, in callcrackfortran
postlist = crackfortran.crackfortran(files)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 3355, in crackfortran
readfortrancode(files, crackline)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 552, in readfortrancode
dowithline(finalline)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 858, in crackline
analyzeline(m, pat[1], line)
File "/hetghome/antonpr/miniconda3/envs/env_test/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1452, in analyzeline
vtype = vars[v].get('typespec')
KeyError: 'pi'
Reading fortran codes...
Reading file 'CMakeFiles/_sophia.dir/SOPHIA20.f' (format:fix,strict)Runtime information:
1.26.0
Context for the issue:
Fixing the bug #22657 and backporting it to numpy==1.26.0rc1 allowed us finally successfully to compile all fotran code which our package interfaces. Before it since numpy==1.20 we needed some workarounds for compilation with f2py which stopped to work somewhere after numpy==1.23. However, we encountered a new problem in numpy==1.26.0, which is preventing us from releasing a stable version of our package.