Netcdf undefined reference error

All things involving the setup (compiling, NetCDF, etc.) of the WRF Model itself.

Netcdf undefined reference error

Postby jpv2018 » Mon Jul 16, 2018 9:56 am

Hi, I am currently trying to compile wrf-hydro on ubuntu and in the process multiple error messages related to netcdf are generated. Here is an example of them. I am also attaching the nc-config and nf-config file. If any additional information is required to determine the possible source of error, please let me know. Thanks for your help!

Error message:

module_hrldas_netcdf_io.f90:(.text+0xaa): undefined reference to `__netcdf_MOD_nf90_inq_dimid'
module_hrldas_netcdf_io.f90:(.text+0xec): undefined reference to `__netcdf_MOD_nf90_inq_dimid'
module_hrldas_netcdf_io.f90:(.text+0x12e): undefined reference to `__netcdf_MOD_nf90_inq_dimid'
module_hrldas_netcdf_io.f90:(.text+0x18c): undefined reference to `__netcdf_MOD_nf90_inq_dimid'
module_hrldas_netcdf_io.f90:(.text+0x1ef): undefined reference to `__netcdf_MOD_nf90_inq_dimid'
../IO_code/module_hrldas_netcdf_io.o:module_hrldas_netcdf_io.f90:(.text+0x24f): more undefined references to `__netcdf_MOD_nf90_inq_dimid' follow
../IO_code/module_hrldas_netcdf_io.o: In function `__module_hrldas_netcdf_io_MOD_read_additional':
module_hrldas_netcdf_io.f90:(.text+0xa3e): undefined reference to `__netcdf_MOD_nf90_open'
module_hrldas_netcdf_io.f90:(.text+0xb42): undefined reference to `__netcdf_MOD_nf90_inq_varid'
module_hrldas_netcdf_io.f90:(.text+0xe53): undefined reference to `__netcdf_MOD_nf90_get_var_2d_fourbytereal'
module_hrldas_netcdf_io.f90:(.text+0xee3): undefined reference to `__netcdf_MOD_nf90_close'
../IO_code/module_hrldas_netcdf_io.o: In function `__module_hrldas_netcdf_io_MOD_error_handler':
module_hrldas_netcdf_io.f90:(.text+0x1089): undefined reference to `__netcdf_MOD_nf90_strerror'
../IO_code/module_hrldas_netcdf_io.o: In function `__module_hrldas_netcdf_io_MOD_get_from_restart_3d':
module_hrldas_netcdf_io.f90:(.text+0x12b3): undefined reference to `__netcdf_MOD_nf90_open'
module_hrldas_netcdf_io.f90:(.text+0x169b): undefined reference to `__netcdf_MOD_nf90_inq_varid'
module_hrldas_netcdf_io.f90:(.text+0x18b3): undefined reference to `__netcdf_MOD_nf90_get_var_3d_fourbytereal'
module_hrldas_netcdf_io.f90:(.text+0x1b0f): undefined reference to `__netcdf_MOD_nf90_inq_varid'
module_hrldas_netcdf_io.f90:(.text+0x1d12): undefined reference to `__netcdf_MOD_nf90_get_var_3d_fourbytereal'
module_hrldas_netcdf_io.f90:(.text+0x1e35): undefined reference to `__netcdf_MOD_nf90_close'
../IO_code/module_hrldas_netcdf_io.o: In function `__module_hrldas_netcdf_io_MOD_get_from_restart_2d_integer':
module_hrldas_netcdf_io.f90:(.text+0x1f7c): undefined reference to `__netcdf_MOD_nf90_open'
module_hrldas_netcdf_io.f90:(.text+0x2225): undefined reference to `__netcdf_MOD_nf90_inq_varid'


This netCDF has been built with the following features:

--cc -> gcc
--cflags -> -I/usr/local/include -I/usr/lib/x86_64-linux-gnu hdf5/serial/include
--libs -> -L/usr/local/lib -lnetcdf
--has-c++ -> no
--cxx ->
--has-c++4 -> no
--cxx4 ->
--has-fortran-> yes
--fc -> gfortran
--fflags -> -I/include
--flibs -> -L/lib -lnetcdff -L/usr/local/lib -lnetcdf -lnetcdf
--has-f90 -> no
--has-f03 -> yes
--has-dap -> no
--has-nc2 -> yes
--has-nc4 -> yes
--has-hdf5 -> yes
--has-hdf4 -> no
--has-logging-> no
--has-pnetcdf-> no
--has-szlib ->
--prefix -> /usr/local
--includedir-> /usr/local/include
--libdir -> /usr/local/lib
--version -> netCDF


This netCDF-Fortran 4.4.4 has been built with the following features:

--cc -> gcc
--cflags -> -I/include -I/usr/local/include
--fc -> gfortran
--fflags -> -I/include
--flibs -> -L/lib -lnetcdff -L/usr/local/lib -lnetcdf -lnetcdf
--has-f90 -> no
--has-f03 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--prefix ->
--includedir-> /include
--version -> netCDF-Fortran 4.4.4
Posts: 1
Joined: Mon Jul 16, 2018 9:44 am

Re: Netcdf undefined reference error

Postby sdegan » Mon Jul 30, 2018 3:19 pm

Do you store your NetCDF C and Fortran libraries in two different directories? If so, your compiler might not be seeing the Fortran libraries if it is only getting linking information to the C libraries. It looks to me that this may be the case.

The only way to tell would be to see error output prior to where you started your copy/paste.
Posts: 10
Joined: Wed Jan 09, 2013 8:17 pm

Return to Installation

Who is online

Users browsing this forum: No registered users and 8 guests