2015-09-18 254 views
2

我想在Ubuntu 14.04上使用gfortran编译器的旧版CPMD-3.11.1版本。新的gfortran编译器无法编译旧的gfortran程序

当运行的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代码。

+0

您必须向我们显示您的代码。错误消息是不够的。 –

回答

2

这看起来像一个代码GPL许可证一般应该是评论,而不是地方,编译器会认为这是有效的源代码。

您需要首先检查代码,看看它是什么样的评论,如用c*(Fortran 77的样式)或一些奇怪的事情,如C风格的块注释(/* */)开头的行。

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

+0

+该错误似乎显示整行,因此它必须是某种块注释。如果只是这一个文件,你可以简单地为每一行添加一个“c”。从长远来看,比起预处理器而言更令人头疼。 – agentp

5

这个输出是由于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 

你解决这个问题之后,你可以清理你的源代码树,让使再生处理Fortran和它不应该包含C风格的评论。