#! /bin/bash

# This script install mpich2 version 3.1.4 in the frontend of a Rocks Linux cluster in /share/apps/mpich2/3.1.4/intel

# Mandatory requirements:
# intel compilers
# openmpi-1.8.5 libraries are in /share/apps/openmpi-1.8.5/intel, which is compiled using intel compilers

# Procedure: Run this script as an user first, then cd ~/configrepo/mpich-3.1.4, as SU, make install 2>&1 | tee mi.txt





mkdir ~/configrepo
cd ~/configrepo
wget http://www2.fizik.usm.my/configrepo/howto/mpich2/mpich-3.1.4.tar.gz
tar -zxvf mpich-3.1.4.tar.gz
cp mpich-3.1.4 mpich-3.1.4_intel
cd mpich-3.1.4_intel

## ./configure --prefix=/share/apps/mpich2/3.1.4/gcc FC=gfortran  CC=cc 2>&1 | tee c.txt use this if possible. Else use the next with with disabled cxx

./configure --prefix=/share/apps/mpich2/3.1.4/intel FC=ifort  CC=/share/apps/openmpi-1.8.5/intel/bin/mpicc  LDFLAGS=-L/share/apps/openmpi-1.8.5/intel/libLIBS=-lmpi --disable-cxx 2>&1 | tee c.txt 

make 2>&1 | tee m.txt

make install 2>&1 | tee mi.txt