#! /bin/sh
if [ "$MPIR_HOME" = "" ] ; then 
    MPIR_HOME=#MPIR_HOME#
fi
if [ "$MPIR_HOME" = "#""MPIR_HOME""#" ] ; then
    MPIR_HOME=`pwd`/..
fi
if [ "#MPIRUN_BIN#" = "#""MPIRUN_BIN""#" ] ; then 
    MPIRUN_HOME=$MPIR_HOME/bin
else
    MPIRUN_HOME=$MPIR_HOME/#MPIRUN_BIN#
fi
if [ "$argsset" = "" ] ; then
   . $MPIRUN_HOME/mpirun.args
   argsset=1
fi

if [ -z "$stdinfile" ] ; then
   stdinfile=/dev/null
fi
# Handle NQS, no default partition, and default partition Paragons
case $paragon_type in
    mkpart)
    # 2 = SIGINT and 3 = SIGQUIT, we hope
    trap "rmpart ${LOGNAME}$$" 2 3
    $Show mkpart -sz $np ${LOGNAME}$$
    $Show $progname -pn ${LOGNAME}$$ $cmdLineArgs < $stdinfile
    $Show rmpart ${LOGNAME}$$
    trap 2 3
    ;;

    nqs|NQS)
    cat >>NQS$$ <<.
#! /bin/sh
mkpart -sz $np ${LOGNAME}$$
$progname -pn ${LOGNAME}$$ < $stdinfile
rmpart ${LOGNAME}$$
/bin/rm -f `pwd`/NQS$$
.
    chmod a+x NQS$$
    $Show qsub -lP $np -lT ${max_time}:0 `pwd`/NQS$$
    echo "Job has been SUBMITTED to NQS,  Use qstat to see if"
    echo "it has run"
    ;;

    crossrun)
    $Show rsh $pgonname '"'"( cd $PWD_TRIAL ; $progname -sz $np $paragon_pn $cmdLineArgs < $stdinfile )"'"'
    ;;

    default)
    $Show $progname -sz $np $paragon_pn $cmdLineArgs
    ;;

    *)
    echo "Unrecongnized Paragon run type $paragon_type"
    exit 1
    ;;
esac
