ROMS3, g95, OS X 10.5.4, netcdf-3.6.3

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Message
Author
muenchow
Posts: 4
Joined: Wed Sep 24, 2008 8:49 pm
Location: University of Delaware

ROMS3, g95, OS X 10.5.4, netcdf-3.6.3

#1 Unread post by muenchow »

I sucessfully compiled netcdf-3.6.3 using fink's g95 compiler on a 2.4 GHz Intel Core 2 Duo MacBook Pro under OS X 10.5.4 (Darwin 9.4.0) and placed the relevant files netcdf.mod and typesizes.mod into the /usr/local/include directories while the libraries libnetcdf.a and libnetcdf.la are in the /usr/local/lib directories (no .dylib files present).

I modified the Compilers/Linux-g95.mk file to create a Darwin-g95.mk file and changed the fortran compiler specification in the ROMS root Makefile. Trying to compile ROMS, I get the following fatal error that I suspect relates to the way I set up the netcdf files ... or is there some fundamental problem with g95?
[roaming-188-233:~/test/ROMS] a2% make
makefile:231: INCLUDING FILE Compilers/make_macros.mk WHICH CONTAINS APPLICATION-DEPENDENT MAKE DEFINITIONS
cp -f /usr/local/include//netcdf.mod Build
cp -f /usr/local/include//typesizes.mod Build
./ROMS/Bin/sfmakedepend --cpp --fext=f90 --file=- --objdir=Build -DROMS_HEADER="upwelling.h" -I ROMS/Include -I ROMS/Nonlinear -I ROMS/Utility -I ROMS/Drivers -I ROMS/Functionals -I Master -I Compilers --silent --moddir Build ROMS/Nonlinear/bbl.F ROMS/Nonlinear/bc_2d.F ROMS/Nonlinear/bc_3d.F ROMS/Nonlinear/biology.F ROMS/Nonlinear/bulk_flux.F ROMS/Nonlinear/bvf_mix.F ROMS/Nonlinear/conv_2d.F ROMS/Nonlinear/conv_3d.F ROMS/Nonlinear/diag.F ROMS/Nonlinear/exchange_2d.F ROMS/Nonlinear/exchange_3d.F ROMS/Nonlinear/forcing.F ROMS/Nonlinear/get_data.F

... snip several screens of apparently successful compilations of sub-programs ...

/usr/bin/cpp -P -traditional -DDARWIN -DI386 -DG95 -D'ROOT_DIR="/Users/a2/test/ROMS"' -DUPWELLING -D'HEADER="upwelling.h"' -D'ROMS_HEADER="upwelling.h"' -DNestedGrids=1 -D'ANALYTICAL_DIR="/Users/a2/test/ROMS/ROMS/Functionals"' -D'SVN_REV="237M"' -IROMS/Include -IROMS/Nonlinear -IROMS/Utility -IROMS/Drivers -IROMS/Functionals -IMaster -ICompilers -D'HEADER_DIR="./ROMS/Include"' ROMS/Modules/mod_netcdf.F > Build/mod_netcdf.f90
ROMS/Bin/cpp_clean Build/mod_netcdf.f90
cd Build; /sw/bin/g95 -c -fno-second-underscore -O3 -ffast-math -pg mod_netcdf.f90
Fatal Error: While reading module 'netcdf' found module version 0, expected 6.
make: *** [Build/mod_netcdf.o] Error 1
Removing the profiling -pg option in the fatal last compile does not make a difference.

Any suggestion to this very green ROMS user are most welcome.

andreas

User avatar
hetland
Posts: 81
Joined: Thu Jul 03, 2003 3:39 pm
Location: TAMU,USA

Re: ROMS3, g95, OS X 10.5.4, netcdf-3.6.3

#2 Unread post by hetland »

I would use gfortran (found here: http://r.research.att.com/tools/) instead of g95. I experimented with a number of gnu fortran variants on Mac OS X a while ago, and gfortran is definately the way to go.

Here are some instructions for compiling all the stuff you need using ifort and gfortran:

http://pong.tamu.edu/~rob/?p=110

Note, my server has been flaky lately, so if it doesn't work, try again in a few minutes... (I promise to fix this soon..) Just to make sure, I'll copy the directions here:




Notes for making netcdf3, hdf5, netcdf4, and openMPI:

These libraries will be put into:

/opt/netcdf3/ifort
/opt/netcdf3/gfortran

/opt/netcdf4/ifort
/opt/netcdf4/gfortran

/opt/hdf5/ifort
/opt/hdf5/gfortran

/opt/openmpi/ifort
/opt/openmpi/gfortran
NETCDF3 [version 3.6.2]

To start with, this site has a long list of options for various compilers and systems:

http://www.unidata.ucar.edu/software/ne ... uilds.html
First, netcdf3 with ifort uses the environmental variables:

export FC=ifort
export FFLAGS='-O3'
./configure --prefix=/opt/netcdf3/ifort
Some options for FFLAGS might include: -O3 -xT -ip -no-prec-div -static (based on a build from the other builds site.) This is similar to the -fast option, which sets: -ipo, -O3, -no-prec-div, -static, and -xP. It seems that -ipo causes configure to fail, so it is left out of the options

-xT builds for 64bit duo processors, -xP for 32 bit. The default is fine, so nothing is set.
-static builds static libs (not needed, as make knows when to do this is seems)
-no-prec-div uses faster division algorithms at the expense of accuracy. Why do this?
So the only flag left standing is ‘-O3′. This could probably be set to ‘-O2′ without much trouble.

To make netcdf3 gfortran, simply do

export FC=gfortran
export FFLAGS='-O3'
./configure --prefix=/opt/netcdf3/gfortran

Both can be made in parallel with make -j, and both pass make check.

HDF5 [version 1.8.0]

Environmental settings used are similar to netcdf3:

export FC=ifort
export F77=ifort
export F90=ifort
export FFLAGS='-O3'
./configure --prefix=/opt/hdf5/ifort --enable-hl --enable-fortran

Admittedly, setting all of FC, F77, and F90 is like wearing suspenders and a belt, but it seems to work in most cases, so it’s what I recommend. The key is the –enable-hl flag, which allows the high-level language API needed by netcdf4. This cannot be built in full parallel, but make -j 2 seems to work fine. Passes make check, after a long, long time. For gfortran:

export FC=gfortran
export F77=gfortran
export F90=gfortran
export FFLAGS='-O3'
./configure --prefix=/opt/hdf5/gfortran --enable-hl --enable-fortran

Also passes make check

NETCDF4 [version snapshot2008031713]

Again, environmental settings used are similar to netcdf3:

export FC=ifort
export F77=ifort
export F90=ifort
export FFLAGS='-O3'
./configure --prefix=/opt/netcdf4/ifort -enable-netcdf-4 --with-hdf5=/opt/hdf5/ifort

The key is here is obviously the –enable-netcdf-4 command, otherwise netcdf4 is not really built. Here parallel make -j seems to work fine. Passes make check. For gfortran, no surprises:

export FC=gfortran
export F77=gfortran
export F90=gfortran
export FFLAGS='-O3'
./configure --prefix=/opt/netcdf4/gfortran -enable-netcdf-4 --with-hdf5=/opt/hdf5/gfortran

Also passes make check.

OpenMPI [version 1.2.5]

export F77=ifort
export FC=ifort
export FFLAGS='-O3'
export FCFLAGS='-O3'
./configure --prefix=/opt/openmpi/ifort --disable-mpi-profile

for gfortran

export F77=gfortran
export FC=gfortran
export FFLAGS='-O3'
export FCFLAGS='-O3'
./configure --prefix=/opt/openmpi/gfortran --disable-mpi-profile

Note that the –disable-mpi-profile is because of a poorly linked file in the profiling directory (the link refers to the parent directory instead of a file).

muenchow
Posts: 4
Joined: Wed Sep 24, 2008 8:49 pm
Location: University of Delaware

Re: ROMS3, g95, OS X 10.5.4, netcdf-3.6.3

#3 Unread post by muenchow »

Ok. Downloading the gfortan compiler from the above site, I compiled the netcdf installation without a problem. I made a new makefile Compilers/Darwin-gfortran.mk, but now the ROMS compilation choked over the -ffree-form-line-length-huge option as in my configuration it expects a positve integer. Changing "huge" to "132" and the compilation works without a hitch. Test case running as we speak.

Thank you, Rob, for a fast and wonderful response that contains so many more pointers that will take me some time to explore more fully.

User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: ROMS3, g95, OS X 10.5.4, netcdf-3.6.3

#4 Unread post by m.hadfield »

The -ffree-line-length-huge option is g95-specific. The gfortran counterpart is -ffree-line-length-none. Setting the limit to 132 has no effect, as that is value in the Fortran standard. You only need line lengths > 132 if some of your source code files have very long path names.

I agree with Rob that Gfortran is a better option these days, overall, than G95. Gfortran comes bundled with GCC 4, it produces faster code, and it supports OpenMP. G95 has better debugging output and is friendlier in some minor ways. I use both.

This may be of only historical interest, but the module version mismatch error suggests (oddly enough) a mismatch in the module format between the compiler used to build netCDF and the compiler being used to build ROMS. This has changed from time to time in G95 and is now at version 8 in recent snapshots (but at 6, I think, in the lastest stable release, 0.91). I don't know why your error message refers to version 0.

pmaccc
Posts: 74
Joined: Wed Oct 22, 2003 6:59 pm
Location: U. Wash., USA

Re: ROMS3, g95, OS X 10.5.4, netcdf-3.6.3

#5 Unread post by pmaccc »

Following the suggestions of Andreas and Rob, I got ROMS3.# running on my relatively new MacBook Pro. For reference I have written up the exact steps I used, at:
http://www.ocean.washington.edu/people/ ... notes.html

Cheers, Parker

Post Reply