Fortran Coder

查看: 19652|回复: 5
打印 上一主题 下一主题

[求助] make时的错误

[复制链接]

3

帖子

1

主题

0

精华

新人

F 币
20 元
贡献
9 点
跳转到指定楼层
楼主
发表于 2021-4-26 17:09:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我在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

源程序

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

5

帖子

0

主题

0

精华

入门

F 币
44 元
贡献
21 点
沙发
发表于 2021-4-26 20:32:04 | 只看该作者
本帖最后由 dfct 于 2021-4-26 20:42 编辑

尝试

Makefile 中  28 行

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

5

帖子

0

主题

0

精华

入门

F 币
44 元
贡献
21 点
板凳
发表于 2021-4-26 20:36:18 | 只看该作者
dfct 发表于 2021-4-26 20:32
尝试

Makefile 中  28 行

我也是新手,不太懂,如果不行等会的人来看看吧~

3

帖子

1

主题

0

精华

新人

F 币
20 元
贡献
9 点
地板
 楼主| 发表于 2021-4-27 09:41:24 | 只看该作者
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



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

3

帖子

1

主题

0

精华

新人

F 币
20 元
贡献
9 点
5#
 楼主| 发表于 2021-4-27 15:44:59 | 只看该作者
Lizm 发表于 2021-4-27 09:41
dfct,您好!我尝试了你提供的两种方法,make过后都报相同的错误,错误如下所示:

ifort  -o wrftoof -O ...

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

谢谢你给予我的帮助

5

帖子

0

主题

0

精华

入门

F 币
44 元
贡献
21 点
6#
发表于 2021-4-27 16:14:13 | 只看该作者
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,开始应该是名字打错了,找不到库文件所以出错
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-12-25 23:58

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表