#! /bin/sh

# This shell script works for an 8 box cluster with 2 mono core CPUs
# per box running LAM Version 7.0.  The host node is named n0 and the
# subnodes are named n1, n2, n3, n4, n5, n6, n7.

echo n0  > lamhosts
echo n1 >> lamhosts
echo n2 >> lamhosts
echo n3 >> lamhosts
echo n4 >> lamhosts
echo n5 >> lamhosts
echo n6 >> lamhosts
echo n7 >> lamhosts

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 

rm -f core core.*

lamboot -v lamhosts

RC=$?

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

make -f makefile.mpi.lam_7.0 >snp_mpi.out 2>&1 && \
  mpirun -v -O -D -s h N N \
  ${PWD}/snp_mpi >>snp_mpi.out 2>snp_mpi.err

RC=$?

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