#! /bin/csh

############################################################################
# install_netcdf: Uncompress, configure, compile, test and install netcdf
#                 library on Linux and Macintosh OS X systems.
#
# Usage: ./install_netcdf
############################################################################

if (`uname` == 'Linux') then
  set dir = "`pwd`/linux"
  setenv FC "ifort"
  setenv F90 "ifort"
  setenv FFLAGS "-O -mp"
  setenv F90FLAGS ""
  setenv CPPFLAGS "-DNDEBUG -DpgiFortran"
else if (`uname` == 'Darwin') then
  set dir = "`pwd`/macosx"
  setenv FC "xlf"
  setenv F90 "xlf90"
  setenv F90FLAGS "-qsuffix=cpp=f90"
  setenv CC "/usr/bin/gcc-3.3"
  setenv CPPFLAGS "-DIBMR2Fortran"
else
  echo ""
  echo "ERROR: Unsupported platform"
  echo ""
  exit 1
endif

tar zxvf netcdf.tar.gz

pushd netcdf-3.6.0-p1/src > /dev/null
./configure --prefix=$dir
make
make test
make install
popd > /dev/null

rm -rf netcdf-3.6.0-p1
