#! /bin/sh

# This shell script works for a quad board machine with AMD Opteron 
# sixteen core processors running CentOS 6 and OpenMPI Version 1.4.3.

export PATH="$PATH:/usr/lib64/compat-openmpi/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/compat-openmpi/lib"
export C_INCLUDE_PATH="$C_INCLUDE_PATH:/usr/include/compat-openmpi-x86_64"

echo "localhost cpu=64" > OpenMPIhosts

test -f summary.dat && cat summary.dat >> summary.bak
test -f control.dat && cat control.dat >> control.bak
test -f detail.dat  && mv -f detail.dat   detail.bak
test -f snp_mpi.err && mv -f snp_mpi.err  snp_mpi.err.bak
test -f snp_mpi.out && mv -f snp_mpi.out  snp_mpi.out.bak 
test -f pathname.h  && mv -f pathname.h   pathname.h.bak

cp null.dat summary.dat
cp null.dat detail.dat

rm -f core core.*

make -f makefile.mpi.OpenMPI_1.4.3 >snp_mpi.out 2>&1 && \
  mpirun --hostfile OpenMPIhosts ${PWD}/snp_mpi >>snp_mpi.out 2>snp_mpi.err

RC=$?

case $RC in
  0) exit 0 ;;
  esac
exit 1;
~
