2015-09-18 296 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風格的評論。