Gfortran 版本 4.1.2 和 4.2.3

发布于 2024-09-25 09:53:54 字数 394 浏览 4 评论 0原文

大家好,我正在将我的代码从在 ubuntu 上运行的集群部署到具有相同硬件的集群上,但使用的是 Red Hat,并且看起来较旧的 gfortran 编译器。源代码实际上是由 ifort 编译的,但由于它没有安装在 red had 集群上,因此我可能必须切换到 gfortran。

现在的问题是代码无法编译。在类型中存在“可分配”的东西,我可以在我的代码部分中修复它,但其他人也有其他贡献,没有准备好使他们的代码适应旧标准。

我的问题:

  1. 我如何部署到其他系统上,希望不要做太多改变?
  2. 当使用相同版本的编译,只是不同的颠覆时,还有什么让我惊讶的呢?
  3. 我怎样才能保证类似的事情不再发生?该代码应该可以部署到各种系统上,而无需诉诸暴力。

谢谢你的建议和鼓励

Hey everybody, i am deploying my code from a cluster running on ubuntu onto a cluster with identical hardware, but with red hat and as it seems older gfortran compiler. The source is actually compiled by ifort, but since it is not installed on the red had cluster, i may have to switch to gfortran.

Now the problem is that the code does not compile. There is this thing with "allocatable" inside a type that i could fix in my portion of the code, but there are also other contributions by other people not as ready to adapt their code to the older standard.

My question :

  1. How do i deploy nonetheless onto the other system, hopefully without changing much?
  2. What other surprised wait for me when using the compile from the same version, just different subversion?
  3. How do i enforce that something like this does not happen again? The code should be deployable onto a variety of systems without resorting to violence.

Thanks for your advice and cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

零崎曲识 2024-10-02 09:53:54

gfortran 从 4.0 版本开始。版本 4.1 和 4.2 很旧,缺少许多功能,并且可能存在错误。您可能会遇到代码使用的其他缺失功能。我建议,如果可能的话,将编译器升级到当前的稳定版本,即 4.5。

支持所有版本的 gfortran 会给你的代码带来很多限制。最好确定最早可用的版本并将该信息添加到文档中。对于我的代码,该版本是 4.3,因为我广泛使用了 ISO C 绑定。

gfortran wiki,http://gcc.gnu.org/wiki/GFortran,有一个变更日志按版本可以帮助您确定您需要哪个版本。唯一可靠的方法就是测试。

如果您想强制执行版本要求,可以从 Fortran 内部进行测试。您可以运行一个小型测试程序作为 make 过程的一部分,如果 gfortran 版本太早则中止。

以下代码片段显示了从 Fortran 程序输出 gfortran 版本号的两种方法。将程序命名为文件类型“.F90”,以便 gfortran 调用预处理器。

#ifdef __GFORTRAN__ 
    write (*, '( "gfortran" )' )
    write (*, '( I0, ".", I0 )' )  __GNUC__, __GNUC_MINOR__

! Merged version number:
#define GCC_VERSION (__GNUC__ * 10000  + __GNUC_MINOR__ * 100  + __GNUC_PATCHLEVEL__)
    write (*, '( I0 )' )  GCC_VERSION

#endif

gfortran started with version 4.0. Versions 4.1 and 4.2 are old and missing many features and may have bugs. You may run into additional missing features that are used by your code. I suggest, if at all possible, getting the compiler upgraded to the current stable version, which is 4.5.

Supporting all versions of gfortran will lead to many restrictions on your code. It might be better to identify the earliest version that works and add that information to the documentation. For my code, that version is 4.3 since I make extensive use of the ISO C Binding.

The gfortran wiki, http://gcc.gnu.org/wiki/GFortran, has a changelog by version that might help you identify which version you need. The only sure way is to test.

If you want to enforce a version requirement, you can test from within Fortran. You could run a small test program as part of the make process and abort if the gfortran version is too early.

The following code fragment shows two ways of outputting the gfortran version number from a Fortran program. Name the program with filetype ".F90" so that gfortran will invoke the preprocessor.

#ifdef __GFORTRAN__ 
    write (*, '( "gfortran" )' )
    write (*, '( I0, ".", I0 )' )  __GNUC__, __GNUC_MINOR__

! Merged version number:
#define GCC_VERSION (__GNUC__ * 10000  + __GNUC_MINOR__ * 100  + __GNUC_PATCHLEVEL__)
    write (*, '( I0 )' )  GCC_VERSION

#endif
为人所爱 2024-10-02 09:53:54

我认为你有3个选择:

  1. 交叉编译:即编译
    您的开发机器
    在您的部署上执行
    机器;我不知道这是不是
    可能与您的设置有关,但它是
    如果你还没有的话值得研究一下
    已经这样做了。
  2. 对所有编译器中实现的 Fortran 功能集进行编程 - 这意味着重写代码以删除 4.2.3 实现而 4.1.2 未实现的任何功能。
  3. 升级部署计算机上的编译器以匹配开发计算机上的编译器。

其中我认为(1)可能比较困难;如果是的话我会选择(3)。如果这是不可能的,那么它必须是(2)——我没有看到任何其他选择。

现在回答您的问题:

  1. 上面已经回答了。
  2. 不确定,但 Gfortran 的发行说明应该告诉您 4.2.3 实现了哪些 Fortran 语言功能,而 4.1.2 没有实现。
  3. 仅使用可在目标平台上编译的 Fortran 版本进行编程。

I think you have 3 choices:

  1. Cross-compilation: ie compile on
    your development machine for
    execution on your deployment
    machine; I don't know if this is
    possible with your setup but it is
    worth investigating if you haven't
    already done so.
  2. Program to the set of Fortran features implemented in all your compilers -- which would mean re-writing the code to take out whatever features 4.2.3 implements that 4.1.2 doesn't.
  3. Upgrade the compiler on your deployment machine to match the one on your development machine.

Of these I think that (1) might be difficult; if it is then I'd go for (3). If that is not possible, then it has to be (2) -- I don't see any other options.

Now to answer your questions:

  1. Answered above.
  2. Not sure, but the release notes for Gfortran should tell you what Fortran language features 4.2.3 implements which 4.1.2 doesn't.
  3. Only program with the version of Fortran for which you can compile on your target platforms.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文