f2py 在使用感叹号注释连接 Fortran77 文件时引发 'Assertion error'
f2py raises 'Assertion error' while interfacing Fortran77 file with exclamation mark comments
我的任务是将 Fortran 77 代码封装到 python3 中。我试着用下面的命令包装它
f2py -c mum1_6.f -m mum
f2py 引发了以下错误
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 "mum" sources
f2py options: []
f2py:> /tmp/tmp79t4vbg0/src.linux-x86_64-3.5/mummodule.c
creating /tmp/tmp79t4vbg0/src.linux-x86_64-3.5
Reading fortran codes...
Reading file 'mum1_6.f' (format:fix,strict)
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
Post-processing...
Block: mum
Block: init_mu
Block: prinfo
Block: med_cons
Block: spl1
Block: dspl1
Block: spl2
Traceback (most recent call last):
File "/home/veniamin/.local/bin/f2py", line 11, in <module>
sys.exit(main())
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 683, in main
run_compile()
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 650, in run_compile
setup(ext_modules=[ext])
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/core.py", line 171, in setup
return old_setup(**new_attr)
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build.py", line 47, in run
old_build.run(self)
File "/usr/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 148, in run
self.build_sources()
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 165, in build_sources
self.build_extension_sources(ext)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 325, in build_extension_sources
sources = self.f2py_sources(sources, ext)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 562, in f2py_sources
['-m', ext_name]+f_sources)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 425, in run_main
postlist = callcrackfortran(files, options)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 329, in callcrackfortran
postlist = crackfortran.crackfortran(files)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 3254, in crackfortran
postlist = postcrack(grouplist[0])
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 1891, in postcrack
g = postcrack(g, tab=tab + '\t')
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 1910, in postcrack
block['body'] = analyzebody(block, args, tab=tab)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 2072, in analyzebody
b = postcrack(b, as_, tab=tab + '\t')
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 1910, in postcrack
block['body'] = analyzebody(block, args, tab=tab)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 2072, in analyzebody
b = postcrack(b, as_, tab=tab + '\t')
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 1906, in postcrack
block['vars'] = analyzevars(block)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 2653, in analyzevars
for d in rmbadname([x.strip() for x in markoutercomma(dim).split('@,@')]):
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 833, in markoutercomma
assert not f, repr((f, line, l))
AssertionError: (-1, '9) !---> array which contains dimensions for output ', '9) !---> array which contains dimensions for output ')
对应部分代码:
DIMENSION NXG(9),NYG(9),X0G(9),SXG(9),Y0G(9),SYG(9) ! -> arrays which
c contain values for above referenced initial values, number of values and
c steps (see above commons /sok_2_1/, /sok_2_2/, /sok_2_3/ etc.).
DIMENSION IJ(9) !---> array which contains dimensions for output 1-di-
c mentional arrays with splains. Dimension of output array should be equal
c to (I+2)*(J+2), where I and J are dimensions for corresponding input 2-di-
c mensional array.
我不明白的是 '!' 有什么问题注释?如果我删除它们,则不会引发错误。还有很多行带有相同的“!”这部分代码之前的注释。实际上,我打包的文件很大,几乎每一行都有这样的注释。我不知道为什么 f2py 只有一部分有问题。
我试图考虑所有这些并得出结论,这些注释实际上不是 Fortran 77 标准的一部分,而且可能是这种情况。所以我决定再次将扩展名更改为“.f90”和 运行 f2py。问题似乎解决了。正如我在几个网站上看到的那样,Fortran 77 代码是 Fortran 90 的子集,所以我确信一切正常。但是一段时间后,我尝试将一些 Fortran 77 代码(不是使用 f2py,而是直接使用编译器)编译为 Fortran 90 代码,我发现这并不是那么简单。至少,F90 编译器不会以这种方式接受老式的 'c' 注释。
所以我有两个问题:
1) 是否可以用'!' 以某种方式解决这些问题?内联注释而不将文件编译为 f90?
2) 将我的“.f”文件作为“.f90”提供给 f2py 是否正确? f2py 是否在同一文件中分隔不同的 'code standards' 并以正确的方式包装?
不幸的是,我正在谈论的代码非常大,无法将其附加到代码片段中。
所以,我没有运气将程序与 f2py 作为 F77 接口。我尝试将它作为 F90 文件提供给 f2py,它对我来说效果很好,因为 Fortran 90 编译器理解固定形式的表示法。
我的任务是将 Fortran 77 代码封装到 python3 中。我试着用下面的命令包装它
f2py -c mum1_6.f -m mum
f2py 引发了以下错误
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 "mum" sources
f2py options: []
f2py:> /tmp/tmp79t4vbg0/src.linux-x86_64-3.5/mummodule.c
creating /tmp/tmp79t4vbg0/src.linux-x86_64-3.5
Reading fortran codes...
Reading file 'mum1_6.f' (format:fix,strict)
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
rmbadname1: Replacing "len" with "len_bn".
Post-processing...
Block: mum
Block: init_mu
Block: prinfo
Block: med_cons
Block: spl1
Block: dspl1
Block: spl2
Traceback (most recent call last):
File "/home/veniamin/.local/bin/f2py", line 11, in <module>
sys.exit(main())
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 683, in main
run_compile()
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 650, in run_compile
setup(ext_modules=[ext])
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/core.py", line 171, in setup
return old_setup(**new_attr)
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build.py", line 47, in run
old_build.run(self)
File "/usr/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 148, in run
self.build_sources()
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 165, in build_sources
self.build_extension_sources(ext)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 325, in build_extension_sources
sources = self.f2py_sources(sources, ext)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 562, in f2py_sources
['-m', ext_name]+f_sources)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 425, in run_main
postlist = callcrackfortran(files, options)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 329, in callcrackfortran
postlist = crackfortran.crackfortran(files)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 3254, in crackfortran
postlist = postcrack(grouplist[0])
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 1891, in postcrack
g = postcrack(g, tab=tab + '\t')
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 1910, in postcrack
block['body'] = analyzebody(block, args, tab=tab)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 2072, in analyzebody
b = postcrack(b, as_, tab=tab + '\t')
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 1910, in postcrack
block['body'] = analyzebody(block, args, tab=tab)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 2072, in analyzebody
b = postcrack(b, as_, tab=tab + '\t')
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 1906, in postcrack
block['vars'] = analyzevars(block)
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 2653, in analyzevars
for d in rmbadname([x.strip() for x in markoutercomma(dim).split('@,@')]):
File "/home/veniamin/.local/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 833, in markoutercomma
assert not f, repr((f, line, l))
AssertionError: (-1, '9) !---> array which contains dimensions for output ', '9) !---> array which contains dimensions for output ')
对应部分代码:
DIMENSION NXG(9),NYG(9),X0G(9),SXG(9),Y0G(9),SYG(9) ! -> arrays which
c contain values for above referenced initial values, number of values and
c steps (see above commons /sok_2_1/, /sok_2_2/, /sok_2_3/ etc.).
DIMENSION IJ(9) !---> array which contains dimensions for output 1-di-
c mentional arrays with splains. Dimension of output array should be equal
c to (I+2)*(J+2), where I and J are dimensions for corresponding input 2-di-
c mensional array.
我不明白的是 '!' 有什么问题注释?如果我删除它们,则不会引发错误。还有很多行带有相同的“!”这部分代码之前的注释。实际上,我打包的文件很大,几乎每一行都有这样的注释。我不知道为什么 f2py 只有一部分有问题。
我试图考虑所有这些并得出结论,这些注释实际上不是 Fortran 77 标准的一部分,而且可能是这种情况。所以我决定再次将扩展名更改为“.f90”和 运行 f2py。问题似乎解决了。正如我在几个网站上看到的那样,Fortran 77 代码是 Fortran 90 的子集,所以我确信一切正常。但是一段时间后,我尝试将一些 Fortran 77 代码(不是使用 f2py,而是直接使用编译器)编译为 Fortran 90 代码,我发现这并不是那么简单。至少,F90 编译器不会以这种方式接受老式的 'c' 注释。
所以我有两个问题:
1) 是否可以用'!' 以某种方式解决这些问题?内联注释而不将文件编译为 f90?
2) 将我的“.f”文件作为“.f90”提供给 f2py 是否正确? f2py 是否在同一文件中分隔不同的 'code standards' 并以正确的方式包装?
不幸的是,我正在谈论的代码非常大,无法将其附加到代码片段中。
所以,我没有运气将程序与 f2py 作为 F77 接口。我尝试将它作为 F90 文件提供给 f2py,它对我来说效果很好,因为 Fortran 90 编译器理解固定形式的表示法。