Netcdf folks,
I hope some folks might find this interesting:
We just discovered that we could use netcdf libraries and include
files that come with the Enthought Python Distribution to build NetCDF
applications that work with NetCDF4 (HDF5) and OPeNDAP. Since the
EPD is a single-click local install on 32 and 64 bit Linux, Mac, &
Windows, it's pretty convenient to be able to build this way if you
find yourself on a machine without the appropriate netcdf4 libraries.
In our case, we had a cluster where we do ocean simulations, which
generate NetCDF3 files. The netcdf libs on this system were also for
netcdf3. We installed the EPD and used the command-line tool
"nc3tonc4" from the EPD bin directory to convert the NetCDF3 files
into the much more highly-compressed netCDF4. But then our old
version of "NcView" didn't work to visualize them, since that app was
also built using a netCDF3 library without netCDF4 (HDF5) support.
Ordinarily at this point we would ask the sys admin to please build a
new version of the netcdf librarry with HDF5, because building this
can be a pain in the butt.
But EPD to the rescue! We found that all the necessary netcdf libs
and include files were in the <epd>/lib and
<epd>/include directories!
So to build a new version of NcView, we just did:
./configure --with-nc-config=/home/rsignell/bin/nc-config
where this "nc-config" was copied from another system, and just
changed the info at the top to reflect where we installed the EPD and
what the EPD 7.3 netcdf options were. This worked great, and as a
bonus, we are now able to use NcView to visualize OPeNDAP data, since
EPD 7.3 netcdf has that enabled also:
For example:
ncview http://geoport.whoi.edu/thredds/dodsC/bathy/gom15
The whole nc-config file is below. I told Enthought about this, and
they said they would modify their installer in future releases to
generate the nc-config file (the prefix is the only thing below would
change depending on where the EPD was installed).
-Rich
--
Dr. Richard P. Signell (508) 457-2229
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598
$ more /home/rsignell/bin/nc-config
#! /bin/sh
#
# This forms the basis for the nc-config utility, which tells you
# various things about the netCDF installation. This code was
# contributed by netCDF user Arlindo DaSilva. Thanks Arlindo!
#
# $Id: nc-config.in,v 1.17 2010/03/24 15:20:37 dmh Exp $
# specify your EPD 7.3 location here, and this should be it!
prefix=/home/rsignell/python27_epd
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
cc="gcc"
cxx="g++"
fc="gfortran"
cflags=" -I${includedir}"
fflags="-g -O2 -I${includedir}"
libs="-L${libdir} -lnetcdf -lhdf5_hl -lhdf5 -lz -lm -lcurl"
flibs="-L${libdir} -lnetcdf -lhdf5_hl -lhdf5 -lz -lm -lcurl"
has_dap="yes"
has_nc2="yes"
has_nc4="yes"
has_hdf4="no"
has_hdf5="yes"
has_f77="no"
has_f90="no"
has_cxx="yes"
has_szlib="no"
version="netCDF 4.1.3"
usage()
{
cat <<EOF
Usage: nc-config [OPTION]
Available values for OPTION include:
--help display this help message and exit
--all display all options
--cc C compiler
--cxx C++ compiler
--fc Fortran compiler
--cflags pre-processor and compiler flags
--fflags flags needed to compile a Fortran program
--has-dap whether OPeNDAP is enabled in this build
--has-nc2 whether NetCDF-2 API is enabled
--has-nc4 whether NetCDF-4/HDF-5 is enabled in this build
--has-hdf5 whether HDF5 is used in build (always the same as --has-nc4)
--has-hdf4 whether HDF4 was used in build
--has-f77 whether Fortran 77 API is enabled in this build
--has-f90 whether Fortran 90 API is enabled in this build
--has-c++ whether C++ API is enabled in this build
--has-szlib whether szlib is included in build
--libs library linking information for netcdf
--flibs libraries needed to link a Fortran program
--prefix Install prefix
--includedir Include directory
--version Library version
EOF
exit $1
}
all()
{
echo
echo "This $version has been built with the following features: "
echo
echo " --cc -> $cc"
echo " --cflags -> $cflags"
echo " --libs -> $libs"
echo
echo " --cxx -> $cxx"
echo " --has-c++ -> $has_cxx"
echo
echo " --fc -> $fc"
echo " --fflags -> $fflags"
echo " --flibs -> $flibs"
echo " --has-f77 -> $has_f77"
echo " --has-f90 -> $has_f90"
echo
echo " --has-dap -> $has_dap"
echo " --has-nc2 -> $has_nc2"
echo " --has-nc4 -> $has_nc4"
echo " --has-hdf5 -> $has_hdf5"
echo " --has-hdf4 -> $has_hdf4"
echo " --has-szlib -> $has_szlib"
echo
echo " --prefix -> $prefix"
echo " --includedir-> $includedir"
echo " --version -> $version"
echo
}
if test $# -eq 0; then
usage 1
fi
while test $# -gt 0; do
case "$1" in
# this deals with options in the style
# --option=value and extracts the value part
# [not currently used]
-*=*) value=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) value= ;;
esac
case "$1" in
--help)
usage 0
;;
--all)
all
;;
--cc)
echo $cc
;;
--cxx)
echo $cxx
;;
--fc)
echo $fc
;;
--cflags)
echo $cflags
;;
--fflags)
echo $fflags
;;
--libs)
echo $libs
;;
--flibs)
echo $flibs
;;
--has-dap)
echo $has_dap
;;
--has-nc2)
echo $has_nc2
;;
--has-nc4)
echo $has_nc4
;;
--has-hdf4)
echo $has_hdf4
;;
--has-hdf5)
echo $has_hdf5
;;
--has-f77)
echo $has_f77
;;
--has-f90)
echo $has_f90
;;
--has-c++)
echo $has_cxx
;;
--has-szlib)
echo $has_szlib
;;
--prefix)
echo "${prefix}"
;;
--includedir)
echo "${includedir}"
;;
--version)
echo $version
;;
*)
echo "unknown option: $1"
usage
exit 1
;;
esac
shift
done
exit 0