#!/bin/bash
set -x
cd ~/mpich2*
./configure --prefix=/usr/local/mpich2 --enable-sharedlibs=gcc 
make
#make 2>&1 | tee m.txt
sudo make install
#/usr/local/bin/sbin/mpeuninstall may be used to remove the installation
echo 'export PATH=/usr/local/mpich2/bin:${PATH}' >> ~/.bashrc
echo 'export MANPATH=${MANPATH}:/usr/local/mpich2/share/man' >> ~/.bashrc
#One way to safely create this file is to do the following:
#cd $HOME
touch ~/.mpd.conf
chmod 600 ~/.mpd.conf
#and then use an editor to insert a line like
echo 'MPD_SECRETWORD=chentong' >> ~/.mpd.conf
#into the file.  
sudo touch /etc/profile.d/mpich.sh
sudo ln -s /usr/local/mpich2/bin/mpicc /usr/bin/mpicc
sudo ln -s /usr/local/mpich2/bin/mpicxx /usr/bin/mpicxx
sudo ln -s /usr/local/mpich2/bin/mpirun /usr/bin/mpirun
sudo ln -s /usr/local/mpich2/bin/mpd /usr/bin/mpd