【发布时间】:2015-07-01 01:50:10
【问题描述】:
首先我已经阅读了这个主题,但我无法编译我的代码。 Compiling Fortran netCDF programs on Ubuntu
我在 UBUNTU 14.04 上编译一个使用 NetCDF 的 fortran 程序。我有这样的编译错误:
terrain.f:(.text+0x17efd): undefined reference to 'ncopn_'
terrain.f:(.text+0x18111): undefined reference to 'ncopn_'
terrain.f:(.text+0x187cc): undefined reference to 'ncclos_'
terrain.f:(.text+0x187ea): undefined reference to 'ncclos_'
它肯定说我没有 netcdf fortran 库。但是我根据这些网页安装了 zlib、HDF5、netcdf C 和 netcdf Fortran,并带有禁用共享和禁用 dap 选项。
http://www.unidata.ucar.edu/software/netcdf/docs/build_default.html http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-fortran-install.html
这是 nc-config --libs 命令的结果:
-L/usr/local/lib -L/usr/local -lnetcdf -lhdf5_hl -lhdf5 -ldl -lm -lz
这是 nf-config --flibs 命令的结果:
-L/usr/local/lib -lnetcdff -L/usr/local/lib -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lz
我用这个命令构建我的项目:
gfortran terrain.f -I/usr/local/include -L/usr/local/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz -lm -ldl
这有什么问题?
编辑: 我在配置 netcdf C 和 netcdf fortran 时使用 --disable-netcdf-4 选项,我可以编译我的代码。所以这是HDF5的问题。
【问题讨论】:
-
你能告诉我们你的 Fortran 代码吗?或者更好的是一个最小的例子?
-
我的代码太长了。但我可以在其他一些系统上运行它,并且它有适当的包含。我现在在我的系统中运行它而不安装 hdf5 和 --disable-netcdf-4 选项。
-
让我吃惊的是,引用是
ncopn_,而不是nf90_open__或类似的东西。 -
这些是旧语法,你可以在 unidata 网站上看到它们。
标签: compilation fortran netcdf