Fortran Coder

标题: make时的错误 [打印本页]

作者: Lizm    时间: 2021-4-26 17:09
标题: make时的错误
我在GitHub上面下载的一个数据转换的一个程序,根据他的README文件,需要更改上一层的路径过后,再从新make一下,但是我这怎么都不成功,一直报下面的错误:(我把源代码放附件里面了,请大家帮我看看到底是什么问题)
/lib/cpp -C -P module_dm.F > module_dm.f90
ifort -o module_dm.o -c  -I/home/lizm/Build_WRF/LIBRARIES/netcdf/include module_dm.f90
module_dm.f90(1): error #5082: Syntax error, found '/' when expecting one of: <LABEL> <END-OF-STATEMENT> ; <IDENTIFIER> TYPE MODULE ELEMENTAL IMPURE NON_RECURSIVE ...
/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
^
module_dm.f90(16): error #5145: Invalid blank/tab
   <https://www.gnu.org/licenses/>.  */
-----------------------------------^
module_dm.f90(18): error #5145: Invalid blank/tab
   include it implicitly at the start of every compilation.  It must
-----------------------------------------------------------^
module_dm.f90(24): error #5120: Unterminated character constant
/* glibc's intent is to support the IEC 559 math functionality, real
--------^
module_dm.f90(24): error #5144: Invalid character_kind_parameter. No underscore
/* glibc's intent is to support the IEC 559 math functionality, real
--------------------------------------------------------------------^
module_dm.f90(25): error #5145: Invalid blank/tab
   and complex.  If the GCC (4.9 and later) predefined macros
---------------^
module_dm.f90(27): error #5277: Syntax error, found ',' following statement keyword
   whether the overall intent is to support these features; otherwise,
----------------------------------------------------------------------^
module_dm.f90(29): error #5145: Invalid blank/tab
   define these macros by default.  */
----------------------------------^
module_dm.f90(30): error #5145: Invalid blank/tab
/* wchar_t uses Unicode 10.0.0.  Version 10.0 of the Unicode Standard is
-------------------------------^
module_dm.f90(1): catastrophic error: Could not recover from previous syntax error
compilation aborted for module_dm.f90 (code 1)
make: *** [Makefile:53:module_dm.o] 错误 1



WRFextraction.zip

15.9 KB, 下载次数: 3

源程序


作者: dfct    时间: 2021-4-26 20:32
本帖最后由 dfct 于 2021-4-26 20:42 编辑

尝试

Makefile 中  28 行

CPP     = /lib/cpp -cpp -E
或者 在 ifort 命令行里加 -fpp

作者: dfct    时间: 2021-4-26 20:36
dfct 发表于 2021-4-26 20:32
尝试

Makefile 中  28 行

我也是新手,不太懂,如果不行等会的人来看看吧~
作者: Lizm    时间: 2021-4-27 09:41
dfct 发表于 2021-4-26 20:32
尝试

Makefile 中  28 行

dfct,您好!我尝试了你提供的两种方法,make过后都报相同的错误,错误如下所示:

ifort  -o wrftoof -O3 -g -fpp wrftoof.o module_dm.o module_openfoam_bc.o -L/home/lizm/Build_WRF/LIBRARIES/netcdf/lib -lnetcdf
ld: wrftoof.o: in function `MAIN__':
/home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:142: undefined reference to `nf_open_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:144: undefined reference to `nf_get_att_real_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:147: undefined reference to `nf_get_att_int_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:150: undefined reference to `nf_get_att_int_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:153: undefined reference to `nf_get_att_int_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:175: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:177: undefined reference to `nf_inq_var_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:179: undefined reference to `nf_inq_dimlen_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:181: undefined reference to `nf_inq_dimlen_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:183: undefined reference to `nf_get_vara_text_'
ld: wrftoof.o: in function `getvar_real_..1':
/home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: wrftoof.o: in function `getvar_real_..0':
/home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: wrftoof.o: in function `getvar_real_':
/home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:457: undefined reference to `nf_inq_varid_'
ld: /home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:470: undefined reference to `nf_get_vara_real_'
ld: wrftoof.o: in function `ncderrcheck_':
/home/lizm/WRF-CFD/tools/WRFextraction/wrftoof.f90:436: undefined reference to `nf_strerror_'
make: *** [Makefile:32:wrftoof] 错误 1



怎么处理这个问题可以给我一些建议吗?
非常感谢!!!

作者: Lizm    时间: 2021-4-27 15:44
Lizm 发表于 2021-4-27 09:41
dfct,您好!我尝试了你提供的两种方法,make过后都报相同的错误,错误如下所示:

ifort  -o wrftoof -O ...

尊敬的dfct,就是在ifort后面加上了-fpp,后面的连接库在-lnetcdf 后面加上了   -lnetcdff ,然后编译成功了。

谢谢你给予我的帮助
作者: dfct    时间: 2021-4-27 16:14
Lizm 发表于 2021-4-27 15:44
尊敬的dfct,就是在ifort后面加上了-fpp,后面的连接库在-lnetcdf 后面加上了   -lnetcdff ,然后编译成 ...

知其然,知其所以然

CPP 的命令大概是想用预处理的手段将 .F 文件转成 .f90 文件,但是原来的命令得到的 f90 文件里有 C 语言的注释,就是 /* 开头的东西,这个 fortran 语法无法识别,所以一直报错

所以第一种方法尝试改变一下方式,希望 f90 里没有 C 语言的注释

第二种方法 ifort 加 -fpp 是让 ifort 在编译时开启 C 的预处理,这样 ifort 自己就能识别 C 的注释,就不会出问题了

至于  -lnetcdff,应该是要链接额外的库文件 netcdff,开始应该是名字打错了,找不到库文件所以出错




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2