Hi,
I am having an issue compiling ROMS, to do with the paths to the netcdf library.
Firstly I got the error:
cp -f /apps/netcdf/4.2.1.1/include/netcdf.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/netcdf.mod': No such file or directory
cp -f /apps/netcdf/4.2.1.1/include/typesizes.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/typesizes.mod': No such file or directory
I overcame this by adding the line below, specifying the path to the directory that these files are in directly, in the build script
export NETCDF_INCDIR=/apps/netcdf/4.2.1.1/include/Intel
I now get the error
...... /home/561/cgk561/eac/normalizations/build/libANA.a /home/561/cgk561/eac/normalizations/build/libUTIL.a /home/561/cgk561/eac/normalizations/build/libMODS.a -L/apps/netcdf/4.2.1.1/lib -lnetcdff -lnetcdf -lnetcdf
/usr/bin/ld: cannot find -lnetcdff
make: *** [/home/561/cgk561/eac/normalizations/oceanG] Error 1
In my build script I have now specified the following, but I still get the same error.
export NETCDF_INCDIR=/apps/netcdf/4.2.1.1/include/Intel
export NETCDF_LIBDIR=/apps/netcdf/4.2.1.1/lib/Intel
export HDF5_LIBDIR=/apps/hdf5/1.8.10/lib
The files in the /apps/netcdf/4.2.1.1/lib/Intel directory are libnetcdff.a libnetcdff.la libnetcdff.so libnetcdff.so.5 libnetcdff.so.5.3.1. From what I understand, it is looking for a library netcdff in /apps/netcdf/4.2.1.1/lib. There is no such library here and I'm not sure how to change the path it is looking at.
I have been running on another system and have not needed to specify the paths to the netcdf or hdf5 libraries in the build script at all.
Hope you can help,
Colette
/usr/bin/ld: cannot find -lnetcdff
Re: /usr/bin/ld: cannot find -lnetcdff
Which version of ROMS do you use? A recent version of ROMS uses NC-config so for netCDF4, you don't need to specify the location of library files.In my build script I have now specified the following, but I still get the same error.
export NETCDF_INCDIR=/apps/netcdf/4.2.1.1/include/Intel
export NETCDF_LIBDIR=/apps/netcdf/4.2.1.1/lib/Intel
Also, have you checked the following post?
viewtopic.php?f=31&t=1992
If you use an older version of ROMS (or use NetCDF3) and set up the path as you said in your build file, ROMS should be able to find the library. In the build script, there are lots of "if" loops so make sure you set up your netcdf path at the right loop! (That happened to me before).
DJ
Re: /usr/bin/ld: cannot find -lnetcdff
I use a recent version of ROMS and netcdf4.
My build script uses nc-config to specify the netcdf library files, export NC_CONFIG=nc-config, which had the library and include directories specified as
prefix=/apps/netcdf/4.2.1.1
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
However, the files the code requires, and is looking for in these directories, are in /apps/netcdf/4.2.1.1/include/Intel and /apps/netcdf/4.2.1.1/lib/Intel.
I edited nc-config to specify these paths, but I still get the same error.
-L/apps/netcdf/4.2.1.1/lib -lnetcdff -lnetcdf -lnetcdf
/usr/bin/ld: cannot find -lnetcdff
make: *** [/home/561/cgk561/eac/normalizations/oceanM] Error 1
i.e. it is still looking in the wrong directory.
Also, the command nc-config --flibs gives me
-L/apps/netcdf/4.2.1.1/lib -lnetcdff -lnetcdf -lnetcdf
and nc-config --libs gives
-L/apps/netcdf/4.2.1.1/lib/Intel -lnetcdff -lnetcdf
I tried changing nc-config such that nc-config --libs gives
-L/apps/netcdf/4.2.1.1/lib/ -lnetcdff -lnetcdf -lnetcdf
But I still get the same error.
Also, I always need to specify
export NETCDF_INCDIR=/apps/netcdf/4.2.1.1/include/Intel
in the build script, even if I change this path in nc-config, otherwise I get the error
cp -f /apps/netcdf/4.2.1.1/include/netcdf.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/netcdf.mod': No such file or directory
cp -f /apps/netcdf/4.2.1.1/include/typesizes.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/typesizes.mod': No such file or directory
So even if I specify /apps/netcdf/4.2.1.1/include/Intel in nc-config, it still looks in /apps/netcdf/4.2.1.1/include, unless I directly specify in the build script.
I hope somebody can help me debug this problem.
Would it be better to compile netcdf it my own home directory, rather than relying on the netcdf on the server I am using?
Thanks,
Colette
My build script uses nc-config to specify the netcdf library files, export NC_CONFIG=nc-config, which had the library and include directories specified as
prefix=/apps/netcdf/4.2.1.1
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
However, the files the code requires, and is looking for in these directories, are in /apps/netcdf/4.2.1.1/include/Intel and /apps/netcdf/4.2.1.1/lib/Intel.
I edited nc-config to specify these paths, but I still get the same error.
-L/apps/netcdf/4.2.1.1/lib -lnetcdff -lnetcdf -lnetcdf
/usr/bin/ld: cannot find -lnetcdff
make: *** [/home/561/cgk561/eac/normalizations/oceanM] Error 1
i.e. it is still looking in the wrong directory.
Also, the command nc-config --flibs gives me
-L/apps/netcdf/4.2.1.1/lib -lnetcdff -lnetcdf -lnetcdf
and nc-config --libs gives
-L/apps/netcdf/4.2.1.1/lib/Intel -lnetcdff -lnetcdf
I tried changing nc-config such that nc-config --libs gives
-L/apps/netcdf/4.2.1.1/lib/ -lnetcdff -lnetcdf -lnetcdf
But I still get the same error.
Also, I always need to specify
export NETCDF_INCDIR=/apps/netcdf/4.2.1.1/include/Intel
in the build script, even if I change this path in nc-config, otherwise I get the error
cp -f /apps/netcdf/4.2.1.1/include/netcdf.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/netcdf.mod': No such file or directory
cp -f /apps/netcdf/4.2.1.1/include/typesizes.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/typesizes.mod': No such file or directory
So even if I specify /apps/netcdf/4.2.1.1/include/Intel in nc-config, it still looks in /apps/netcdf/4.2.1.1/include, unless I directly specify in the build script.
I hope somebody can help me debug this problem.
Would it be better to compile netcdf it my own home directory, rather than relying on the netcdf on the server I am using?
Thanks,
Colette
Re: /usr/bin/ld: cannot find -lnetcdff
If you look in one of the machine-dependent files in the Compilers directory, they have something like:
The NETCDF_LIBDIR is being ignored when USE_NETCDF4 is defined. You have choices:
* See if 'nf_config --flibs' gives the right thing.
* Turn off USE_NETCDF4 and add -lnetcdff to LIBS in the "else" section.
* Keep USE_NETCDF4 and hack that section.
* Compile your own Netcdf.
Code: Select all
ifdef USE_NETCDF4
NC_CONFIG ?= nc-config
NETCDF_INCDIR ?= $(shell $(NC_CONFIG) --prefix)/include
LIBS := $(shell $(NC_CONFIG) --flibs)
else
NETCDF_INCDIR ?= /usr/local/include
NETCDF_LIBDIR ?= /usr/local/lib
LIBS := -L$(NETCDF_LIBDIR) -lnetcdf
endif
* See if 'nf_config --flibs' gives the right thing.
* Turn off USE_NETCDF4 and add -lnetcdff to LIBS in the "else" section.
* Keep USE_NETCDF4 and hack that section.
* Compile your own Netcdf.
Re: /usr/bin/ld: cannot find -lnetcdff
Hi Kate,
Thanks a lot for the help.
I tried option 3, hacking the ifdef USE_NETCDF4 loop
ifdef USE_NETCDF4
NC_CONFIG ?= nc-config
NETCDF_INCDIR ?= $(shell $(NC_CONFIG) --prefix)/include/Intel
NETCDF_LIBDIR=/apps/netcdf/4.2.1.1/lib/Intel:/apps/netcdf/4.2.1.1/lib
LIBS :="-L/apps/netcdf/4.2.1.1/lib -lnetcdf -L/apps/netcdf/4.2.1.1/lib/Intel -lnetcdff"
else
NETCDF_INCDIR ?= /usr/local/include
NETCDF_LIBDIR ?= /usr/local/lib
LIBS := -L$(NETCDF_LIBDIR) -lnetcdff -lnetcdf
endif
netcdf is in /apps/netcdf/4.2.1.1/lib, but netcdff is in /apps/netcdf/4.2.1.1/lib/Intel, so I added both.
That solved one problem but now I get
.......
mod_netcdf.f90:(.text+0x20009): undefined reference to `netcdf_mp_nf90_get_att_text_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_close_':
mod_netcdf.f90:(.text+0x201f5): undefined reference to `netcdf_mp_nf90_close_'
mod_netcdf.f90:(.text+0x20418): undefined reference to `netcdf_mp_nf90_get_att_text_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_create_':
mod_netcdf.f90:(.text+0x205b3): undefined reference to `netcdf_mp_nf90_create_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_enddef_':
mod_netcdf.f90:(.text+0x2081b): undefined reference to `netcdf_mp_nf90_enddef_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_redef_':
mod_netcdf.f90:(.text+0x20c42): undefined reference to `netcdf_mp_nf90_redef_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_sync_':
mod_netcdf.f90:(.text+0x20e62): undefined reference to `netcdf_mp_nf90_sync_'
make: *** [/home/561/cgk561/eac/normalizations/oceanM] Error 1
M Compilers/Linux-ifort.mk
I abandoned and decided to compile my own netcdf. I also built my own hdf5 and zlib libraries, following
http://www.unidata.ucar.edu/software/ne ... tions.html
However, with my new installation I don't have netcdf.mod or typesizes.mod anywhere, so I am back to my original error
cp -f /apps/netcdf/4.2.1.1/include/netcdf.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/netcdf.mod': No such file or directory
cp -f /apps/netcdf/4.2.1.1/include/typesizes.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/typesizes.mod': No such file or directory
and I am unable to fix it as I don't have these *.mod files. I don't want to use the ones in /apps/netcdf/4.2.1.1/include/Intel as the whole point here was to install my own netcdf.
I obviously did something wrong with the installation. Are there any instructions on how to install netcdf from scratch so that it works with ROMS? I can't find anything other than what I followed in the unidata site. There are many different versions, I tried netcdf-4.3.2 but don't know which one I was supposed to use.
Thanks a lot for the help.
I tried option 3, hacking the ifdef USE_NETCDF4 loop
ifdef USE_NETCDF4
NC_CONFIG ?= nc-config
NETCDF_INCDIR ?= $(shell $(NC_CONFIG) --prefix)/include/Intel
NETCDF_LIBDIR=/apps/netcdf/4.2.1.1/lib/Intel:/apps/netcdf/4.2.1.1/lib
LIBS :="-L/apps/netcdf/4.2.1.1/lib -lnetcdf -L/apps/netcdf/4.2.1.1/lib/Intel -lnetcdff"
else
NETCDF_INCDIR ?= /usr/local/include
NETCDF_LIBDIR ?= /usr/local/lib
LIBS := -L$(NETCDF_LIBDIR) -lnetcdff -lnetcdf
endif
netcdf is in /apps/netcdf/4.2.1.1/lib, but netcdff is in /apps/netcdf/4.2.1.1/lib/Intel, so I added both.
That solved one problem but now I get
.......
mod_netcdf.f90:(.text+0x20009): undefined reference to `netcdf_mp_nf90_get_att_text_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_close_':
mod_netcdf.f90:(.text+0x201f5): undefined reference to `netcdf_mp_nf90_close_'
mod_netcdf.f90:(.text+0x20418): undefined reference to `netcdf_mp_nf90_get_att_text_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_create_':
mod_netcdf.f90:(.text+0x205b3): undefined reference to `netcdf_mp_nf90_create_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_enddef_':
mod_netcdf.f90:(.text+0x2081b): undefined reference to `netcdf_mp_nf90_enddef_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_redef_':
mod_netcdf.f90:(.text+0x20c42): undefined reference to `netcdf_mp_nf90_redef_'
/home/561/cgk561/eac/normalizations/build/libMODS.a(mod_netcdf.o): In function `mod_netcdf_mp_netcdf_sync_':
mod_netcdf.f90:(.text+0x20e62): undefined reference to `netcdf_mp_nf90_sync_'
make: *** [/home/561/cgk561/eac/normalizations/oceanM] Error 1
M Compilers/Linux-ifort.mk
I abandoned and decided to compile my own netcdf. I also built my own hdf5 and zlib libraries, following
http://www.unidata.ucar.edu/software/ne ... tions.html
However, with my new installation I don't have netcdf.mod or typesizes.mod anywhere, so I am back to my original error
cp -f /apps/netcdf/4.2.1.1/include/netcdf.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/netcdf.mod': No such file or directory
cp -f /apps/netcdf/4.2.1.1/include/typesizes.mod /home/561/cgk561/eac/normalizations/build
cp: cannot stat `/apps/netcdf/4.2.1.1/include/typesizes.mod': No such file or directory
and I am unable to fix it as I don't have these *.mod files. I don't want to use the ones in /apps/netcdf/4.2.1.1/include/Intel as the whole point here was to install my own netcdf.
I obviously did something wrong with the installation. Are there any instructions on how to install netcdf from scratch so that it works with ROMS? I can't find anything other than what I followed in the unidata site. There are many different versions, I tried netcdf-4.3.2 but don't know which one I was supposed to use.
Re: /usr/bin/ld: cannot find -lnetcdff
Many of the Netcdf versions work well, but at some point they split out the Fortran stuff. You need to also download netcdf-fortran, which should provide you with netcdf.mod, typesizes.mod and also libnetcdff.so.
Re: /usr/bin/ld: cannot find -lnetcdff
What OS do you use? Linux? If so, typeHowever, with my new installation I don't have netcdf.mod or typesizes.mod anywhere, so I am back to my original error
>> locate netcdf.mod
and see if you can find it somewhere. Or maybe the installation was not completed?
I installed netCDF3/4 many times and netcdf.mod/trapezoid.mod were installed every time.
You need to use netCDF compiled by the exactly same version and vendor of Fortran as that used by ROMS. i.e. if you use Intel Fortran XE 2011.5.309 (or whatever) to compile ROMS, NetCDF also needs to be compiled by the same version of Fortran (no Gfortran or other version of Intel Fortran). So was the version of Fortran used for both the same?netcdf is in /apps/netcdf/4.2.1.1/lib, but netcdff is in /apps/netcdf/4.2.1.1/lib/Intel, so I added both.
Details of NetCDF installation can be obtained from the following.
http://www.unidata.ucar.edu/software/ne ... f-install/
A couple of more things.
You said ROMS could not find netCDF library. What will happen if you include the path on LD_LIBRARY_PATH in .bashrc or .bash_profile?
The other thing.
You may want to install netCDF3 to see if that works. It is easier than netCDF4 (to me).
I haven't seen benefits using netCDF4 on ROMS (compression is not so good and NetCDF4 CLASSIC has limitations and NetCDF4 format sucks).
Good luck.
DJ@TAMU
Re: /usr/bin/ld: cannot find -lnetcdff
Thank you.
I did not know that I had to install the Fortran netCDF library and the netCDF C library separately.
I installed netcdf-fortran and now I have netcdf.mod, typesizes.mod and libnetcdff.so as you said, and can compile ROMS!
Thanks so much for your help.
I did not know that I had to install the Fortran netCDF library and the netCDF C library separately.
I installed netcdf-fortran and now I have netcdf.mod, typesizes.mod and libnetcdff.so as you said, and can compile ROMS!
Thanks so much for your help.