Skip to content

Instantly share code, notes, and snippets.

@TakashiUNUMA
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TakashiUNUMA/da5ba6ca3f5f371d3b6e to your computer and use it in GitHub Desktop.
Save TakashiUNUMA/da5ba6ca3f5f371d3b6e to your computer and use it in GitHub Desktop.
An automated shell script for compiling and installing NetCDF ver. 4.1.3, ZLIB ver. 1.2.5 and HDF5 ver. 1.8.7. For more information of this script, please see the top level of this script.
#!/bin/sh
#
# autobuild_netcdf4.sh
#
# original script coded by Takashi Unuma, Kyoto Univ.
# Last modified: 2014/07/07
#
# -------------------------------------------------------
# required commands:
# wget, tar, make
#
# required compiler:
# icc, icpc, ifort ver. 10.0 or higher
#
# checked operating systems:
# CentOS 5.8 x86_64, Ubuntu 13.10 x86_64
# -------------------------------------------------------
#
# Note: zlib, hdf5, and netcdf libraries will be installed
# under the following directories;
#
# ${HOME}/usr/local/netcdf-4.1.3-intel
# ${HOME}/usr/local/hdf5-1.8.7-intel
# ${HOME}/usr/local/zlib-1.2.5-intel
#
# -------------------------------------------------------
#
# USAGE: Just run this script as follows;
#
# $ sh autobuild_netcdf4.sh
#
# An estimated time for installing libraries is about 20 minutes,
# which depends on your machine spec (e.g. CPU clock, Memory capacity, etc).
#
# After running this script, you MUST write the environmental settings
# in your ".bashrc" as follows;
#
# ### ZLIB
# export ZLIB="${HOME}/usr/local/zlib-1.2.5-intel"
# export LD_LIBRARY_PATH="${ZLIB}/lib:${LD_LIBRARY_PATH}"
# export INCLUDE="${ZLIB}/include:${INCLUDE}"
#
# ### HDF
# export HDF="${HOME}/usr/local/hdf5-1.8.7-intel"
# export PATH="${HDF}/bin:${PATH}"
# export LD_LIBRARY_PATH="${HDF}/lib:${LD_LIBRARY_PATH}"
# export INCLUDE="${HDF}/include:${INCLUDE}"
# export MANPATH="${HDF}/man:${MANPATH}"
#
# ### NetCDF
# export NETCDF="${HOME}/usr/local/netcdf-4.1.3-intel"
# export NCHOME="${NETCDF}"
# export NETCDFHOME="${NETCDF}"
# export PATH="${NETCDF}/bin:${PATH}"
# export LD_LIBRARY_PATH="${NETCDF}/lib:${LD_LIBRARY_PATH}"
# export INCLUDE="${NETCDF}/include:${INCLUDE}"
# export MANPATH="${NETCDF}/man:${MANPATH}"
#
#cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
# download source codes
#cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
wget -nc ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.1.3.tar.gz
wget -nc http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.7/src/hdf5-1.8.7.tar.gz
wget -nc https://github.com/madler/zlib/archive/v1.2.5.tar.gz -O zlib-1.2.5.tar.gz
#cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
# --- build zlib
#cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
if test ! -s zlib-1.2.5.tar.gz ; then
echo "Error: zlib-1.2.5.tar.gz is not found"
exit 100
fi
tar -zxvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
pwd
export INSTDIR=${HOME}/usr/local/zlib-1.2.5-intel
export CC=icc
export CXX=icpc
export CFLAGS='-fPIC'
export CXXFLAGS='-fPIC'
export F77=ifort
export FFLAGS='-fPIC'
export CPP='icc -E'
export CXXCPP='icpc -E'
./configure --prefix=${INSTDIR}
make
make check
make install
cd ../
pwd
### ZLIB
export ZLIB="${HOME}/usr/local/zlib-1.2.5-intel"
export LD_LIBRARY_PATH="${ZLIB}/lib:${LD_LIBRARY_PATH}"
export INCLUDE="${ZLIB}/include:${INCLUDE}"
#cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
# --- build hdf5
#cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
if test ! -s hdf5-1.8.7.tar.gz ; then
echo "Error: hdf5-1.8.7.tar.gz is not found"
exit 200
fi
tar -zxvf hdf5-1.8.7.tar.gz
cd hdf5-1.8.7
pwd
export INSTDIR=${HOME}/usr/local/hdf5-1.8.7-intel
export ZLIB=${HOME}/usr/local/zlib-1.2.5-intel
ZLIB=${HOME}/usr/local/zlib-1.2.5-intel
export CC=icc
export FC=ifort
./configure --with-zlib=${ZLIB}/include,${ZLIB}/lib --prefix=${INSTDIR}
make libs progs
make check
make install
cd ../
pwd
### HDF
export HDF="${HOME}/usr/local/hdf5-1.8.7-intel"
export PATH="${HDF}/bin:${PATH}"
export LD_LIBRARY_PATH="${HDF}/lib:${LD_LIBRARY_PATH}"
export INCLUDE="${HDF}/include:${INCLUDE}"
export MANPATH="${HDF}/man:${MANPATH}"
#cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
# --- build netcdf
#cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
if test ! -s netcdf-4.1.3.tar.gz ; then
echo "Error: netcdf-4.1.3.tar.gz is not found"
exit 300
fi
tar -zxvf netcdf-4.1.3.tar.gz
cd netcdf-4.1.3
pwd
export INSTDIR=${HOME}/usr/local/netcdf-4.1.3-intel
export ZLIB=${HOME}/usr/local/zlib-1.2.5-intel
export HDF5=${HOME}/usr/local/hdf5-1.8.7-intel
export CC=icc
export CXX=icpc
export F77=ifort
export FC=ifort
export CPP='icc -E'
export CXXCPP='icpc -E'
export CPPFLAGS="-DNDEBUG -DpgiFortran -I${ZLIB}/include -I${HDF5}/include"
export LDFLAGS="-L${ZLIB}/lib -L${HDF5}/lib"
./configure --prefix=${INSTDIR} --disable-dap
make
make check
make install
cd ../
pwd
### NetCDF
export NETCDF="${HOME}/usr/local/netcdf-4.1.3-intel"
export NCHOME="${NETCDF}"
export NETCDFHOME="${NETCDF}"
export PATH="${NETCDF}/bin:${PATH}"
export LD_LIBRARY_PATH="${NETCDF}/lib:${LD_LIBRARY_PATH}"
export INCLUDE="${NETCDF}/include:${INCLUDE}"
export MANPATH="${NETCDF}/man:${MANPATH}"
# --- end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment