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



我正在尝试在Ubuntu 14.04上安装带有gfortran编译器的旧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文件删除语句部分,但这非常耗时。

是否有其他的选择来安装旧的Fortran代码与更新的gfortran编译器。

这个输出是由于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风格的注释。

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

您需要首先检查代码,看看它是什么类型的注释,比如以c* (Fortran 77风格)开头的行,或者像c风格的块注释(/* */)这样的奇怪的东西。

如果是后者,使用-cpp选项到gfortran(或调用文件timec.F,从非常拉伸内存,自动调用预处理器)。

最新更新