build_with_parallel_support.sh 3.15 KB
#!/bin/bash
#

if [ -z "${1}" ]; then
  echo "Usage : ${0} INSTALL_DIR"
  exit 1
else
  INSTALL_DIR=${1}
fi;

ZLIB_ARCHIVE_NAME="zlib-1.2.8"
ZLIB_ARCHIVE_PATH="../zlib/"$ZLIB_ARCHIVE_NAME".tar.gz"

MPICH_ARCHIVE_NAME="mpich-3.1.4"
MPICH_ARCHIVE_PATH="../mpich/"$MPICH_ARCHIVE_NAME".tar.gz"

HDF5_ARCHIVE_NAME="hdf5-1.8.15"
HDF5_ARCHIVE_PATH="../hdf5/"$HDF5_ARCHIVE_NAME".tar"

NETCDF_ARCHIVE_NAME="netcdf-4.3.3.1"
NETCDF_ARCHIVE_PATH="./"$NETCDF_ARCHIVE_NAME".tar.gz"

SCRIPT_DIR=`pwd`

TMP_DIR=$SCRIPT_DIR"/tmp"

mkdir -p $TMP_DIR
mkdir -p $INSTALL_DIR

echo "--------";
echo "| ZLIB |";
echo "--------";

tar xzf $ZLIB_ARCHIVE_PATH -C $TMP_DIR
if [[ $? != 0 ]]; then echo "[ERROR] Cannot decompress zlib archive"; exit $?; fi

cd $TMP_DIR"/"$ZLIB_ARCHIVE_NAME

./configure --prefix=$INSTALL_DIR
if [[ $? != 0 ]]; then echo "[ERROR] Cannot configure zlib"; exit $?; fi
make
if [[ $? != 0 ]]; then echo "[ERROR] Cannot compile zlib"; exit $?; fi
make install
if [[ $? != 0 ]]; then echo "[ERROR] Cannot install zlib"; exit $?; fi

echo "---------";
echo "| MPICH |";
echo "---------";

cd $SCRIPT_DIR
tar xzf $MPICH_ARCHIVE_PATH -C $TMP_DIR
if [[ $? != 0 ]]; then echo "[ERROR] Cannot decompress MPICH archive"; exit $?; fi

cd $TMP_DIR"/"$MPICH_ARCHIVE_NAME

./configure CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" --disable-fortran --prefix=$INSTALL_DIR |& tee c.txt
if [[ $? != 0 ]]; then echo "[ERROR] Cannot configure MPICH"; exit $?; fi
make 2>&1 | tee m.txt
if [[ $? != 0 ]]; then echo "[ERROR] Cannot compile MPICH"; exit $?; fi
make install |& tee mi.txt
if [[ $? != 0 ]]; then echo "[ERROR] Cannot install MPICH"; exit $?; fi

export PATH=$INSTALL_DIR"/bin":$PATH
export LD_LIBRARY_PATH=$INSTALL_DIR"/lib":$LD_LIBRARY_PATH

echo "------------------------------";
echo "| HDF5 with parallel support |";
echo "------------------------------";

cd $SCRIPT_DIR
tar xf $HDF5_ARCHIVE_PATH -C $TMP_DIR
if [[ $? != 0 ]]; then echo "[ERROR] Cannot decompress HDF5 archive"; exit $?; fi

cd $TMP_DIR"/"$HDF5_ARCHIVE_NAME

CC=$INSTALL_DIR/bin/mpicc ./configure --prefix=$INSTALL_DIR --enable-parallel --disable-fortran --with-zlib=$INSTALL_DIR
if [[ $? != 0 ]]; then echo "[ERROR] Cannot configure HDF5"; exit $?; fi
make
if [[ $? != 0 ]]; then echo "[ERROR] Cannot compile HDF5"; exit $?; fi
make check
if [[ $? != 0 ]]; then echo "[ERROR] Check error with HDF5"; exit $?; fi
make install
if [[ $? != 0 ]]; then echo "[ERROR] Cannot install HDF5"; exit $?; fi

echo "--------------------------------";
echo "| NetCDF with parallel support |";
echo "--------------------------------";

cd $SCRIPT_DIR
tar xzf $NETCDF_ARCHIVE_PATH -C $TMP_DIR
if [[ $? != 0 ]]; then echo "[ERROR] Cannot decompress NetCDF archive"; exit $?; fi

cd $TMP_DIR"/"$NETCDF_ARCHIVE_NAME

CPPFLAGS=-I$INSTALL_DIR/include LDFLAGS=-L$INSTALL_DIR/lib ./configure --prefix=$INSTALL_DIR
if [[ $? != 0 ]]; then echo "[ERROR] Cannot configure NetCDF"; exit $?; fi
make
if [[ $? != 0 ]]; then echo "[ERROR] Cannot compile NetCDF"; exit $?; fi
make check
if [[ $? != 0 ]]; then echo "[ERROR] Check error with NetCDF"; exit $?; fi
make install
if [[ $? != 0 ]]; then echo "[ERROR] Cannot install NetCDF"; exit $?; fi

echo "[DONE]"