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

时间:2015-09-18 08:34:26

标签: fortran

我正在尝试使用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代码。

2 个答案:

答案 0 :(得分:5)

此输出是由GCC的C预处理器引起的(我认为这种行为最近有所介绍)。

如果您通过显式调用.f并使用.F标志从cpp创建-C文件,则输出文件包含许可免责声明和其他可能的信息。 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风格的注释。

答案 1 :(得分:2)

这看起来像代码中的GPL许可证,通常应该是注释,而不是编译器认为它是有效源代码的地方。

您需要首先检查代码以查看它是什么类型的注释,例如以c*开头的行(Fortran 77样式)或类似C样式块注释的奇怪内容(/* */)。

如果是后者,请使用-cpp选项gfortran(或调用文件timec.F,该文件来自非常延伸的内存,自动调用预处理器)