f2py
f2py copied to clipboard
f2py compile multiple files, Exception: Check the blocks
I am trying to compile three fortran 77 files with f2py. I know the files compile with ifort and gfortran.
f2py produces a long trail of warnings and ends with a message to "Check the blocks":
[emason@marula r_tools]$ f2py -verbose -c -m --fcompiler=intelem *.F
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "rfact.F" sources
f2py options: []
f2py:> /tmp/tmp_QlXua/src.linux-x86_64-2.7/rfact/Fmodule.c
creating /tmp/tmp_QlXua/src.linux-x86_64-2.7
creating /tmp/tmp_QlXua/src.linux-x86_64-2.7/rfact
Reading fortran codes...
Reading file 'roms_read_write.F' (format:fix,strict)
Traceback (most recent call last):
File "/usr/bin/f2py", line 28, in <module>
main()
File "/usr/lib64/python2.7/site-packages/numpy/f2py/f2py2e.py", line 648, in main
run_compile()
File "/usr/lib64/python2.7/site-packages/numpy/f2py/f2py2e.py", line 633, in run_compile
setup(ext_modules=[ext])
File "/usr/lib64/python2.7/site-packages/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib64/python2.7/site-packages/numpy/distutils/command/build.py", line 47, in run
old_build.run(self)
File "/usr/lib64/python2.7/distutils/command/build.py", line 127, in run
self.run_command(cmd_name)
File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib64/python2.7/site-packages/numpy/distutils/command/build_src.py", line 147, in run
self.build_sources()
File "/usr/lib64/python2.7/site-packages/numpy/distutils/command/build_src.py", line 164, in build_sources
self.build_extension_sources(ext)
File "/usr/lib64/python2.7/site-packages/numpy/distutils/command/build_src.py", line 326, in build_extension_sources
sources = self.f2py_sources(sources, ext)
File "/usr/lib64/python2.7/site-packages/numpy/distutils/command/build_src.py", line 563, in f2py_sources
['-m', ext_name]+f_sources)
File "/usr/lib64/python2.7/site-packages/numpy/f2py/f2py2e.py", line 408, in run_main
postlist = callcrackfortran(files, options)
File "/usr/lib64/python2.7/site-packages/numpy/f2py/f2py2e.py", line 329, in callcrackfortran
postlist = crackfortran.crackfortran(files)
File "/usr/lib64/python2.7/site-packages/numpy/f2py/crackfortran.py", line 3216, in crackfortran
readfortrancode(files, crackline)
File "/usr/lib64/python2.7/site-packages/numpy/f2py/crackfortran.py", line 511, in readfortrancode
dowithline(finalline)
File "/usr/lib64/python2.7/site-packages/numpy/f2py/crackfortran.py", line 748, in crackline
% (groupcounter))
Exception: crackline: groupcounter(=0) is nonpositive. Check the blocks.
[emason@marula r_tools]$
I have found one post from 2004 that addresses this error http://osdir.com/ml/python.f2py.user/2004-04/msg00000.html but it's not clear to me if this relevant for my case. I'd be grateful for any suggestions, thanks.
Could you show us the header and footer portion of the file roms_read_write.F?
Btw, f2py option -m requires specification of module name which is missing in your case.
For example, try
f2py -c -m foo --fcompiler=intelem *.F
I am having the same error. Even after aligning the do loops in the code, the error resurfaces. Does anyone have insights on this crackline error?