#!/bin/bash

# ./mre 4 x100    restarts x100 with mpirun -np 4

function errmsg {
  echo ""
  echo "Please supply the number of processors as 1st command line argument."
  echo "for example, ./mre 4 x100    restarts x100 with mpirun -np 4"
  echo ""
}

function check_okay {
	if [ $? -ne 0 ]
	then
	  errmsg
		exit 1
	fi
}

if test -z "$2"
then
  errmsg
  exit 1
fi

if test -z "$1"
then
  exit 1
fi

echo $2
cp photos/$2 restart_photo
check_okay
date
#mpirun -machinefile $PBS_NODEFILE -np $1 ./star
mpirun -np $1 ./star
date
