MPICH

Check and see if you already have an MPI wrapper available on your machine. One simple way of doing so, is to perform a which on the three necessary MPI wrapper binaries:


which mpicc mpicxx mpif90 | wc -l

If the above command returns '3', then you may skip the MPICH section. However, if you ended up building your own GCC compiler above, you will want to NOT skip this step. With the reason being, it is generally best to build an MPI wrapper based on the compiler you plan to use.

Download MPICH 3.2

cd $STACK_SRC
curl -L -O http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz
tar -xf mpich-3.2.tar.gz -C .

Now we create an out-of-tree build location, configure, build, and install it

mkdir $STACK_SRC/mpich-3.2/gcc-build
cd $STACK_SRC/mpich-3.2/gcc-build

../configure --prefix=$PACKAGES_DIR/mpich-3.2 \
--enable-shared \
--enable-sharedlibs=gcc \
--enable-fast=O2 \
--enable-debuginfo \
--enable-totalview \
--enable-two-level-namespace \
CC=gcc \
CXX=g++ \
FC=gfortran \
F77=gfortran \
F90='' \
CFLAGS='' \
CXXFLAGS='' \
FFLAGS='' \
FCFLAGS='' \
F90FLAGS='' \
F77FLAGS=''

make -j # (where # is the number of cores available)

make install
note

In order to utilize our newly built MPI wrapper, we need to set some variables:

export PATH=$PACKAGES_DIR/mpich-3.2/bin:$PATH
export CC=mpicc
export CXX=mpicxx
export FC=mpif90
export F90=mpif90
export C_INCLUDE_PATH=$PACKAGES_DIR/mpich-3.2/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$PACKAGES_DIR/mpich-3.2/include:$CPLUS_INCLUDE_PATH
export FPATH=$PACKAGES_DIR/mpich-3.2/include:$FPATH
export MANPATH=$PACKAGES_DIR/mpich-3.2/share/man:$MANPATH
export LD_LIBRARY_PATH=$PACKAGES_DIR/mpich-3.2/lib:$LD_LIBRARY_PATH