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

San*_*huP 2 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
Run Code Online (Sandbox Code Playgroud)

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

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

cas*_*sey 5

这个输出是由于GCC的C预处理器(我认为这种行为最近有所介绍).

如果您通过显式调用并使用该标志来创建.f文件,则输出文件包含许可免责声明以及C注释中可能的其他信息.例如,跑步.Fcpp-C

% echo "end" | cpp -C -P
Run Code Online (Sandbox Code Playgroud)

产生输出:

/* 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
Run Code Online (Sandbox Code Playgroud)

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

例如,如果你看到类似的东西:

CPP = cpp -C -P -traditional
Run Code Online (Sandbox Code Playgroud)

编辑它看起来像:

CPP = cpp -P -traditional
Run Code Online (Sandbox Code Playgroud)

修复此问题后,您可以清理源树,并让make重新生成已处理的Fortran,它不应包含C样式的注释.