I have recently written down the steps I needed to build netcdf3, hdf5, and netcdf4 on my Mac using both ifort and [gfortran](http://r.research.att.com/tools/). Details follow
-------
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/netcdf/docs/other-builds.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).
No comments:
Post a Comment