problem compiling ROMS w/ linux-gfortran

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Message
Author
natarov
Posts: 2
Joined: Wed Feb 28, 2007 8:00 pm
Location: IPRC, University of Hawaii

problem compiling ROMS w/ linux-gfortran

#1 Unread post by natarov »

I get the following error message at the very end of the
"make" run:

[..]
gfortran -frepack-arrays -O3 -ffast-math Build/master.o Build/ocean_control.o Build/ocean_coupler.o Build/propagator.o -o Executable/oceanS Build/libNLM.a Build/libANA.a Build/libICE.a Build/libUTIL.a Build/libMODS.a -L/usr/local/lib -lnetcdf
Build/libNLM.a(output.o)(.text+0x340): In function `output_':
output.f90: undefined reference to `__netcdf__nf90_close'
Build/libNLM.a(output.o)(.text+0x466):output.f90: undefined reference to `__netcdf__nf90_close'
Build/libNLM.a(output.o)(.text+0x538):output.f90: undefined reference to `__netcdf__nf90_close'
Build/libUTIL.a(close_io.o)(.text+0x56): In function `close_io_':

.....
and then this continues for another hundred of lines or so.
Has anyone encountered a similar problem and knows how to resolve it?
Thank you.

jcwarner
Posts: 1200
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

#2 Unread post by jcwarner »

looks like you may need to build the netcdf f90 interface.
This forum contains many other posts from users whom had similar issues.
As a matter of fact, i copied the section of your error:
"undefined reference to `__netcdf__nf90_close' "
and pasted that into the roms google search engine, and it returned:

viewtopic.php?p=2349

that may be a place to start.

-john

otago

Netcdf missing F90 headers

#3 Unread post by otago »

Hi,

Debian/stable (Etch)'s netcdf 3.6.1 package was built only with support for F77.

The latest Debian/unstable and testing (Lenny) 3.6.2 package includes F90 support.

see:
http://packages.debian.org/changelogs/p ... /changelog

I am not sure about netcdf, but typically Ubuntu pacakges will be largely based on the Debian packages.

So if you are using Debian/stable (or a debian derived distro) and want F90 support, you have two choices: 1) rebuild the unstable package for stable. (AFAICS backports.org haven't already done this), or 2) rebuild the stable package to include F90 support.

There are many guides to doing (1) on the web so I won't go into that, but for us I had to use (2), as we use a lot of software that relies on GDAL (www.gdal.org), and I didn't want to have to rebuild the entire GDAL+GIS dependency toolchain, just produce a slot in replacement, but with the extra F90 support.

The basic way of doing that was to use the debian package building tools to retrieve the 3.6.1 package source, then apply some patches:

* bump the version number with a new entry in debian/changelog

* edit debian/rules and uncomment & reposition both "F90=gfortran \ "
and uncomment -lgfortran
and change both FC= to gfortran
and add "$(RM) -r debian/tmp-dev/usr/share/man/man3f90" after same man3f rule
-CPPFLAGS=-Df2cFortran -DNDEBUG -D_REENTRANT
+CPPFLAGS=-DpgiFortran -DNDEBUG -D_REENTRANT

(yes, "Dpgi" for gfortran, it works....)

* remove from debian/control
-Build-Depends: g77 | fortran77-compiler
-Build-Conflicts: gfortran-4.0, gfortran-4.1, gfortran
+Build-Depends: g77 | fortran77-compiler, gfortran

# build package
apt-get -b source netcdf


this gives you some new .debs to install.


Proper patches, more details, etc. available upon request.

I would still like to know how to keep a seond local copy of libnetcdf built with ifort on the same system as the gfortran built one (needed for GDAL et al.) without the two colliding, for use with a ifort compiled version of ROMS. Build ROMS on a clean system with no other netcdf then statically link in the library?

regards,
Hamish

twainwright

#4 Unread post by twainwright »

A couple other possibilities to check before you try re-installing netCDF:

1) When I installed netCDF from the UCAR tarball, by default the C and Fortran routines were in separate library archives. If this is the case, you need only add -lnetcdff (note the double "f") or possibly -lnetcdff90 to your linking command. (Look in /usr/local/lib for the corresponding files libnetcdff.*--if they are there, this might work; if not, you'll need to reinstall netcdf with Fortran support.)

2) It looks like your ROMS libraries are built with double-underscoring (gfortran option -fsecond_underscore). It's possible that your netcdf libraries were not. If this is the case, turn that option off for the ROMS build, and it might be able to find the netcdf routines.

However, on my system (SuSE 10.3), I found that nothing worked with the netcdf libraries that came with the distribution--I had to uninstall the netcdf packages, then build netcdf from the tar files from UCAR with build options identical to those used by ROMS.

Hope this helps!

Post Reply