使用f2py将旧的Fortran77代码编译成Python模块。

huangapple go评论58阅读模式
英文:

Compile legacy fortran77 code as python module using f2py

问题

我能成功编译FORTRAN77代码,但只有在指定-std=legacy时才能成功:

gfortran -o -std=legacy -o model.exe model.FOR

没有-std=legacy会出现严重错误。我希望在尝试构建一个Python模块时能够类似地指定一个与陈旧的FORTRAN77代码兼容的传统编译器。目前,以下调用会生成与省略-std=legacy时相同的致命错误:

f2py -c -m pymodel model.FOR --fcompiler=gnu95

有关如何确保f2py使用与陈旧的FORTRAN77代码兼容的传统编译器的建议?

英文:

I am able to successfully compile FORTRAN77 code, but only when specifying -std=legacy in

gfortran -o -std=legacy -o model.exe model.FOR

Without -std=legacy, I get some fatal errors. I wish to similarly specify a legacy compiler when attempting to build a python module. Presently the following call generates the same fatal errors as those when omitting -std=legacy using gfortran.

f2py -c -m pymodel model.FOR --fcompiler=gnu95 

Any suggestions on how to ensure f2py uses a legacy compiler compatible with antiquated FORTRAN77 code?

答案1

得分: 1

Vladimir F提供了一个很好的参考。当将感兴趣的参数传递给--opt="__"时,f2py编译:

f2py -c --opt='-std=legacy' -m pymodel model.FOR --fcompiler=gnu95
英文:

> Are you actually just asking how to pass that flag to the compiler? stackoverflow.com/questions/28380548/…

Vladimir F provided a good reference. f2py compiles when passing the argument of interest into --opt="__":

f2py -c --opt='-std=legacy' -m pymodel model.FOR --fcompiler=gnu95 

huangapple
  • 本文由 发表于 2023年6月22日 04:33:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76526939.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定