gpt4 book ai didi

fortran - 新的 gfortran 编译器无法编译旧的 gfortran 程序

转载 作者:行者123 更新时间:2023-12-01 04:34:16 32 4
gpt4 key购买 nike

我正在尝试使用 gfortran 编译器在 Ubuntu 14.04 上使用旧的 CPMD-3.11.1 版本。

在运行 Makefile 时我遇到了这个错误:

Error:

Unclassifiable statement at (1) ./timec.f:10.28:

but WITHOUT ANY WARRANTY; without even the implied warranty of

1 Error: Unclassifiable statement at (1) ./timec.f:11.4:

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

1 Error: Non-numeric character in statement label at (1) ./timec.f:11.4:

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

1 Error: Unclassifiable statement at (1) ./timec.f:12.4:

Lesser General Public License for more details.

1 Error: Non-numeric character in statement label at (1) ./timec.f:12.4:

Lesser General Public License for more details.

1 Error: Unclassifiable statement at (1) ./timec.f:14.4:

You should have received a copy of the GNU Lesser General Public

1 Error: Non-numeric character in statement label at (1) ./timec.f:14.4:

You should have received a copy of the GNU Lesser General Public

1 Error: Unclassifiable statement at (1) Fatal Error: Error count reached limit of 25. make: *** [timec.o] Error 1

我注意到它没有读取语句部分,所以我删除了每个创建的 .f 文件的语句部分,但这非常耗时。

是否有任何其他选项可以使用更新的 gfortran 编译器安装旧的 Fortran 代码。

最佳答案

这个输出是由于 GCC 的 C 预处理器(我认为这个行为是最近引入的)。

如果您通过显式调用 cpp 并使用 -C.F 创建您的 .f 文件> 标志,输出文件包含许可证免责声明和 C 注释中可能的其他信息。例如,运行

% echo "end" | cpp -C -P

产生输出:

/* Copyright (C) 1991-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This header is separate from features.h so that the compiler can
include it implicitly at the start of every compilation. It must
not itself include <features.h> or any other header that includes
<features.h> because the implicit include comes before any feature
test macros that may be defined in a source file before it first
explicitly includes a system header. GCC knows the name of this
header in order to preinclude it. */
/* glibc's intent is to support the IEC 559 math functionality, real
and complex. If the GCC (4.9 and later) predefined macros
specifying compiler intent are available, use them to determine
whether the overall intent is to support these features; otherwise,
presume an older compiler has intent to support these features and
define these macros by default. */
/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
Unicode 6.0. */
/* We do not support C11 <threads.h>. */
end

使用 gcc 5.2。您的版本的确切输出可能有所不同,但仍然会有问题。此输出是无效的 Fortran 且不可编译。要获得 Fortran 编译器可以处理的输出,您至少需要省略 -C 并添加 -P。一个常见的其他标志是 -traditional。如果您的 makefile 定义了 CPP,请编辑它以删除 -C 标志。

例如,如果您看到如下内容:

CPP = cpp -C -P -traditional

编辑它看起来像:

CPP = cpp -P -traditional

修复此问题后,您可以清理源代码树并让 make 重新生成处理过的 Fortran,它不应包含 C 风格的注释。

关于fortran - 新的 gfortran 编译器无法编译旧的 gfortran 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32647429/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com