Hi!
Moved to use Ubuntu and finally managed to install netcdf-fortran with parallel capacity, after many support-mails...
Now I'm trying to compile the upwelling case, but I have some linking problem. I don't know how to set the links.
Can I do this in the build.bash file, and if so, where do I do that?
Here is part of the error message;
close_io.f90:(.text+0x106e): undefined reference to `__netcdf_MOD_nf90_strerror'
The whole output is included in the attached errors.txt
I also attch the build.bash so you can see what I'm doing.
I find in the library;
per@UiT-HP-Z620:~/Projects/upwelling$ ls /usr/local/lib
libnetcdf.a libnetcdff.a libnetcdff.la libnetcdf.la libz.a libz.so libz.so.1 libz.so.1.2.8 pkgconfig python2.7 python3.4
Thankful for any help on this!
Help with linking netcdf library
Help with linking netcdf library
- Attachments
-
- build.bash
- (16.75 KiB) Downloaded 319 times
-
- errors.txt
- (185.58 KiB) Downloaded 334 times
Re: Help with linking netcdf library
You don't include the full output of the make so we can't see the final link command. The most common problem is not getting the -lnetcdff in the link and therefore not getting the library at all. If you have USE_NETCDF4, what is the output of "nc-config --flibs"?
Re: Help with linking netcdf library
Hi!
Thanks for your reply and sorry I'm such a newb here.
I tried to redirect the output using "./build.bash &>errors.txt", but apparently not all output goes in that file..?
Is there a better way?
The output from nc-config --all
per@UiT-HP-Z620:~/Projects/upwelling$ nc-config --all
This netCDF 4.3.2 has been built with the following features:
--cc -> mpicc
--cflags -> -I/usr/local/include -I/usr/include
--libs -> -L/usr/local/lib -L/usr/lib -lnetcdf -lm -lhdf5 -lz -ldl
--has-c++ -> no
--cxx ->
--has-c++4 -> no
--cxx4 ->
--fc ->
--fflags ->
--flibs ->
--has-f90 -> no
--has-dap -> no
--has-nc2 -> yes
--has-nc4 -> no
--has-hdf5 -> no
--has-hdf4 -> no
--has-pnetcdf-> no
--prefix -> /usr/local
--includedir-> /usr/local/include
--version -> netCDF 4.3.2
So, yes the lnetcdff is missing here. Where am I supposed to specify the links?
In the build.bash or somewhere else? The make-file? Which make-file?
All the best!
//Pär
Thanks for your reply and sorry I'm such a newb here.
I tried to redirect the output using "./build.bash &>errors.txt", but apparently not all output goes in that file..?
Is there a better way?
The output from nc-config --all
per@UiT-HP-Z620:~/Projects/upwelling$ nc-config --all
This netCDF 4.3.2 has been built with the following features:
--cc -> mpicc
--cflags -> -I/usr/local/include -I/usr/include
--libs -> -L/usr/local/lib -L/usr/lib -lnetcdf -lm -lhdf5 -lz -ldl
--has-c++ -> no
--cxx ->
--has-c++4 -> no
--cxx4 ->
--fc ->
--fflags ->
--flibs ->
--has-f90 -> no
--has-dap -> no
--has-nc2 -> yes
--has-nc4 -> no
--has-hdf5 -> no
--has-hdf4 -> no
--has-pnetcdf-> no
--prefix -> /usr/local
--includedir-> /usr/local/include
--version -> netCDF 4.3.2
So, yes the lnetcdff is missing here. Where am I supposed to specify the links?
In the build.bash or somewhere else? The make-file? Which make-file?
All the best!
//Pär
Re: Help with linking netcdf library
The thing invoking nc-config is the Makefile snippet for your system in the Compilers directory. For instance, ifort and Linux will have a file there. Please try nf-config instead of nc-config to see if that is working. If so, you can modify the file in the Compilers directory accordingly.
Re: Help with linking netcdf library
I had a similar problem with a Debian system (Ubuntu is based on Debian).
The nc-config command should be able to find the fortran-related libs by invoking nf-config as long as that is in the path. There is a very subtle system related problem with the way nc-config is invoked: It is a script using /bin/sh (see first line). On my system /bin/sh is a link to /bin/dash and not /bin/bash as expected. dash and bash are NOT compatible. dash obviously has a problem with the if-clause in nc-config which checks for the presence of nf-config. On my Debian system I was able to change this behaviour with the help of "dpkg-reconfigure bash" which basically relinked /bin/sh to /bin/bash. Then it worked!
Check on your Ubuntu system what /bin/sh actually is (executable or link to something) and redirect the link if necessary. Maybe "dpkg-reconfigure bash" also works on your system!
The nc-config command should be able to find the fortran-related libs by invoking nf-config as long as that is in the path. There is a very subtle system related problem with the way nc-config is invoked: It is a script using /bin/sh (see first line). On my system /bin/sh is a link to /bin/dash and not /bin/bash as expected. dash and bash are NOT compatible. dash obviously has a problem with the if-clause in nc-config which checks for the presence of nf-config. On my Debian system I was able to change this behaviour with the help of "dpkg-reconfigure bash" which basically relinked /bin/sh to /bin/bash. Then it worked!
Check on your Ubuntu system what /bin/sh actually is (executable or link to something) and redirect the link if necessary. Maybe "dpkg-reconfigure bash" also works on your system!
Re: Help with linking netcdf library
Thanks again!
I boldly (didn't exactly know what I was doing...)changed the Linux-gfrortran.mk by changing the line;
LIBS := -L$(NETCDF_LIBDIR) -lnetcdf
to;
LIBS := -L$(NETCDF_LIBDIR) -lnetcdff -lnetcdf #PJ
This solved my problem. The thing compiled without errors and now I have an "oceanM" file, which runs nicely on my 12 cores!!!!
Thats a huge step forward for me.
All the best!
//Pär
I boldly (didn't exactly know what I was doing...)changed the Linux-gfrortran.mk by changing the line;
LIBS := -L$(NETCDF_LIBDIR) -lnetcdf
to;
LIBS := -L$(NETCDF_LIBDIR) -lnetcdff -lnetcdf #PJ
This solved my problem. The thing compiled without errors and now I have an "oceanM" file, which runs nicely on my 12 cores!!!!
Thats a huge step forward for me.
All the best!
//Pär