[SOLVED] netcdf configure using gfortran
-
- Posts: 5
- Joined: Mon May 10, 2010 2:08 pm
- Location: Dept of Environmental Affairs - SA Governemt (& Oceanography SA)
[SOLVED] netcdf configure using gfortran
Hi,
I'm currently having trouble getting the upwelling test case to compile. I've successfully compiled and ran this case on another PC, so I'm confident that the error isnt related to the build.bash file.
I've read somewhere that it may be related to when I ran ./configure after installing latest version of netcdf.
I used
./configure --prefix=/home/username/local
but understand I may have needed to pass some more arguments to get it to configure with the gfortran compiler I use for ROMS.
Can someone here perhaps help me out with the correct ./configure command so I can reinstall netcdf ?
Thanks
I'm currently having trouble getting the upwelling test case to compile. I've successfully compiled and ran this case on another PC, so I'm confident that the error isnt related to the build.bash file.
I've read somewhere that it may be related to when I ran ./configure after installing latest version of netcdf.
I used
./configure --prefix=/home/username/local
but understand I may have needed to pass some more arguments to get it to configure with the gfortran compiler I use for ROMS.
Can someone here perhaps help me out with the correct ./configure command so I can reinstall netcdf ?
Thanks
Last edited by sbergman on Thu Jul 28, 2011 12:27 pm, edited 1 time in total.
Re: netcdf configure using gfortran
As ever, it depends. Here's what I used last (on Linux):
Code: Select all
configure FC=gfortran F77=gfortran F90=gfortran CXX=g++ --prefix=/u1/uaf/kate --enable-netcdf4 --enable-shared --with-hdf5=/u1/uaf/kate
- m.hadfield
- Posts: 521
- Joined: Tue Jul 01, 2003 4:12 am
- Location: NIWA
Re: netcdf configure using gfortran
With the latest release of netCDF-4 (4.1.3) you don't use "--with-hdf5" to specify the location of the HDF5 libraries, you use CPPFLAGS and LDFLAGS. Also, I don't think F77 and F90 are required (or possibly even allowed) with this version. The above command would becomekate wrote:As ever, it depends. Here's what I used last (on Linux):Code: Select all
configure FC=gfortran F77=gfortran F90=gfortran CXX=g++ --prefix=/u1/uaf/kate --enable-netcdf4 --enable-shared --with-hdf5=/u1/uaf/kate
Code: Select all
configure FC=gfortran CXX=g++ CPPFLAGS=-I/u1/uaf/kate/include LDFLAGS=-L/u1/uaf/kate/lib --prefix=/u1/uaf/kate --enable-netcdf4 --enable-shared
To the original poster, I suggest you do use 4.1.3, as the netCDF developers have put a lot of work into cleaning up the build process and the operation of the nc-config script.
Re: netcdf configure using gfortran
Thanks, Mark, my last build was way back at 4.1.1.
- m.hadfield
- Posts: 521
- Joined: Tue Jul 01, 2003 4:12 am
- Location: NIWA
Re: netcdf configure using gfortran
Ancient history.kate wrote:Thanks, Mark, my last build was way back at 4.1.1.
-
- Posts: 5
- Joined: Mon May 10, 2010 2:08 pm
- Location: Dept of Environmental Affairs - SA Governemt (& Oceanography SA)
Re: netcdf configure using gfortran
Hi again, thanks to both of you I've got netcdf-4.1.3 installed.
For the record, I did a
and then a
and then a
Note the: something went wrong if I enabled this. I didnt figure out why but it seems to work if I disable this option.
However when I compile the upwelling example, I still get underfined reference errors to files / routines with the double-underscore. The end of the error messages look like this
If you have any further suggestions, please let me know.
Regards,
- S
For the record, I did a
Code: Select all
make clean
Code: Select all
./configure FC=gfortran CXX=g++ CPPFLAGS=-I/home/sbergman/local/include LDFLAGS=-L/home/sbergman/local/lib --prefix=/home/sbergman/local --disable-netcdf-4 --enable-shared
Code: Select all
make check install
Code: Select all
--disable-netcdf-4
However when I compile the upwelling example, I still get underfined reference errors to files / routines with the double-underscore. The end of the error messages look like this
Code: Select all
mod_netcdf.f90:(.text+0x11474): undefined reference to `__netcdf_MOD_nf90_get_var_1d_eightbytereal'
mod_netcdf.f90:(.text+0x11925): undefined reference to `__netcdf_MOD_nf90_get_var_1d_eightbytereal'
/home/sbergman/MyROMSProjects/Upwelling/Build/libMODS.a(mod_netcdf.o): In function `T.2871':
mod_netcdf.f90:(.text+0x11a42): undefined reference to `__netcdf_MOD_nf90_inq_varid'
mod_netcdf.f90:(.text+0x11a8a): undefined reference to `__netcdf_MOD_nf90_get_var_eightbytereal'
/home/sbergman/MyROMSProjects/Upwelling/Build/libMODS.a(mod_netcdf.o): In function `__mod_netcdf_MOD_netcdf_check_dim':
mod_netcdf.f90:(.text+0x138b6): undefined reference to `__netcdf_MOD_nf90_inquire'
mod_netcdf.f90:(.text+0x1396a): undefined reference to `__netcdf_MOD_nf90_inquire_dimension'
collect2: ld returned 1 exit status
make: *** [/home/sbergman/MyROMSProjects/Upwelling/oceanS] Error 1
Regards,
- S
Re: netcdf configure using gfortran
See if this is helpful. It could be a "-fno-second-underscore" kind of answer or the -lnetcdff issue.
- m.hadfield
- Posts: 521
- Joined: Tue Jul 01, 2003 4:12 am
- Location: NIWA
Re: netcdf configure using gfortran
Hi sbergman
Have a look at the command that triggered those errors in building ROMS--post it here if you want. Does the linker command line have the options you expect? I would expect it to end with "-lnetcdff -lnetcdf". does it?
I don't think you need to worry about "-fno-second-underscore" or any of the other GCC options relating to code-generation conventions. (I think the two leading underscores in the undefined references are just part of the name-mangling for subroutines in the Fortran 90 interface and not related to the old G77-style name mangling, which added trailing underscores--either 1 or 2 depending on the day of the week or something. All ancient history now, I hope.)
The fact that you had to disable netcdf-4 in building netCDF shouldn't be a problem for now. It just means you have a netCDF-4 library that supports only the netCDF-3 interface. ROMS should be satisfied with that, until you try to use netCDF-4 output features. However it does suggest there was something wrong with these arguments in the configure command:
They are supposed to indicate where HDF5 is installed and the fact you couldn't build with --enable-netcdf-4 suggests this wasn't successful. Or some other problem.
PS: You did activate USE_NETCDF4 when building ROMS, didn't you?
Have a look at the command that triggered those errors in building ROMS--post it here if you want. Does the linker command line have the options you expect? I would expect it to end with "-lnetcdff -lnetcdf". does it?
I don't think you need to worry about "-fno-second-underscore" or any of the other GCC options relating to code-generation conventions. (I think the two leading underscores in the undefined references are just part of the name-mangling for subroutines in the Fortran 90 interface and not related to the old G77-style name mangling, which added trailing underscores--either 1 or 2 depending on the day of the week or something. All ancient history now, I hope.)
The fact that you had to disable netcdf-4 in building netCDF shouldn't be a problem for now. It just means you have a netCDF-4 library that supports only the netCDF-3 interface. ROMS should be satisfied with that, until you try to use netCDF-4 output features. However it does suggest there was something wrong with these arguments in the configure command:
Code: Select all
CPPFLAGS=-I/home/sbergman/local/include LDFLAGS=-L/home/sbergman/local/lib
PS: You did activate USE_NETCDF4 when building ROMS, didn't you?
-
- Posts: 5
- Joined: Mon May 10, 2010 2:08 pm
- Location: Dept of Environmental Affairs - SA Governemt (& Oceanography SA)
Re: netcdf configure using gfortran
Hi again. Thanks for the help so far.
I've got in my build.bash file. Am I correct in saying that its commented out cos I configured netcdf with the --disable-netcdf4 option? (and it's like that on the working pc...)
I tried doing a ./build.bash >> compilelog.txt and searched through that txt file for any clues.
The last line (where I assume) things went awry looks like this:
It looks like it was missing the -lnetcdff
I followed through kate's links, through the FAQ and ended up editing the file ~/ROMS/src/Compilers/Linux-gfortran.mk (on line 51 in my case) to
while there I also noticed that it was pointing to
and I changed this to where my lib and include should be (according to my netcdf configure command).
Good news is that it compiled, but bad news is that I now get a runtime error which says:
I've tried reinstalling netcdf and putting everything in /usr/local/.... so I undid those extra changes to Linux-gfortran.mk but the problem still arises.
I looked for the libnetcdff.so.5 in the /usr/local/lib folder and found that it links to a libnetcdff.so.5.1.0 in the same folder - both are definitely there.
Any further suggestions?
- S
I've got
Code: Select all
#export USE_NETCDF4=on # compile with NetCDF-4 library
I tried doing a ./build.bash >> compilelog.txt and searched through that txt file for any clues.
The last line (where I assume) things went awry looks like this:
Code: Select all
/usr/bin/gfortran -frepack-arrays -O3 -ffast-math /home/sbergman/MyROMSProjects/Upwelling/Build/esmf_roms.o /home/sbergman/MyROMSProjects/Upwelling/Build/master.o /home/sbergman/MyROMSProjects/Upwelling/Build/ocean_control.o /home/sbergman/MyROMSProjects/Upwelling/Build/ocean_coupler.o /home/sbergman/MyROMSProjects/Upwelling/Build/propagator.o /home/sbergman/MyROMSProjects/Upwelling/Build/roms_export.o /home/sbergman/MyROMSProjects/Upwelling/Build/roms_import.o -o /home/sbergman/MyROMSProjects/Upwelling/oceanS /home/sbergman/MyROMSProjects/Upwelling/Build/libUTIL.a /home/sbergman/MyROMSProjects/Upwelling/Build/libNLM.a /home/sbergman/MyROMSProjects/Upwelling/Build/libNLM_bio.a /home/sbergman/MyROMSProjects/Upwelling/Build/libNLM_sed.a /home/sbergman/MyROMSProjects/Upwelling/Build/libANA.a /home/sbergman/MyROMSProjects/Upwelling/Build/libUTIL.a /home/sbergman/MyROMSProjects/Upwelling/Build/libMODS.a -L/home/sbergman/local/lib -lnetcdf
I followed through kate's links, through the FAQ and ended up editing the file ~/ROMS/src/Compilers/Linux-gfortran.mk (on line 51 in my case) to
Code: Select all
LIBS := -L$(NETCDF_LIBDIR) -lnetcdff -lnetcdf
Code: Select all
NETCDF_INCDIR ?= /usr/local/include
NETCDF_LIBDIR ?= /usr/local/lib
Good news is that it compiled, but bad news is that I now get a runtime error which says:
Code: Select all
./oceanS: error while loading shared libraries: libnetcdff.so.5: cannot open shared object file: No such file or directory
I looked for the libnetcdff.so.5 in the /usr/local/lib folder and found that it links to a libnetcdff.so.5.1.0 in the same folder - both are definitely there.
Any further suggestions?
- S
Re: netcdf configure using gfortran
No, you want to have USE_NETCDF4 on so that you pick up the nc-config during the build - it knows to include -lnetcdff for you.sbergman wrote:I've gotin my build.bash file. Am I correct in saying that its commented out cos I configured netcdf with the --disable-netcdf4 option? (and it's like that on the working pc...)Code: Select all
#export USE_NETCDF4=on # compile with NetCDF-4 library
What is in your LD_LIBRARY_PATH environment variable? Are you running on the command line or from a batch script? Does the batch script have the right environment to find /usr/local?Good news is that it compiled, but bad news is that I now get a runtime error which says:Any further suggestions?Code: Select all
./oceanS: error while loading shared libraries: libnetcdff.so.5: cannot open shared object file: No such file or directory
-
- Posts: 5
- Joined: Mon May 10, 2010 2:08 pm
- Location: Dept of Environmental Affairs - SA Governemt (& Oceanography SA)
Re: netcdf configure using gfortran
Hi,
I think you guys have solved the problem:
There was no reference to LD_LIBRARY_PATH in my ~/.bashrc so I added the following:
and things fell into place. So the upwelling example is running at the moment.
Mind you, since yesterday I've also installed zlib, hdf and rebuilt netcdf to include those options, thinking that my initial problem was caused, for some reason, by NOT enabling netcdf4. Followed that entire process through and then found out about editing the .bashrc file. At least the spin-off advantage is that I've got netcdf-4 working now.
A side-issue is that I had a confusing problem after installing zlib - I got a segmentation fault on synaptic and after rebooting the pc, no login prompt would appear though the xserver would start. Turns out that zlib conflicts with gdm. I uninstalled zlib and reinstalled it somewhere under my /home directory (ie: ./configure --prefix=/home/sbergman/local/) hoping that it'd avoid the conflict... I guess it did.
Thanks for the assistance!
- S
I think you guys have solved the problem:
There was no reference to LD_LIBRARY_PATH in my ~/.bashrc so I added the following:
Code: Select all
LD_LIBRARY_PATH=/home/sbergman/local/lib
export LD_LIBRARY_PATH
Mind you, since yesterday I've also installed zlib, hdf and rebuilt netcdf to include those options, thinking that my initial problem was caused, for some reason, by NOT enabling netcdf4. Followed that entire process through and then found out about editing the .bashrc file. At least the spin-off advantage is that I've got netcdf-4 working now.
A side-issue is that I had a confusing problem after installing zlib - I got a segmentation fault on synaptic and after rebooting the pc, no login prompt would appear though the xserver would start. Turns out that zlib conflicts with gdm. I uninstalled zlib and reinstalled it somewhere under my /home directory (ie: ./configure --prefix=/home/sbergman/local/) hoping that it'd avoid the conflict... I guess it did.
Thanks for the assistance!
- S
- m.hadfield
- Posts: 521
- Joined: Tue Jul 01, 2003 4:12 am
- Location: NIWA
Re: [SOLVED] netcdf configure using gfortran
That zlib issue is an odd one! I guess it shows that life isn't meant to be easy. I'm glad you got it sorted out.