#!/bin/sh
#
# Submit script example for GridSolve using Torque/OpenPBS.
#
# Arguments:  GridSolve will pass one argument to the submit
# script, which is the name of the batch executable to be run.
# Also you should pass one argument to the batch executable,
# which is the request directory.  You should normally use $PWD
# since this script would be invoked by the service process
# which is already in the request directory, but the batch
# executable needs to know where to begin.
#
# Whatever back-end system you submit to, this script should
# only produce one line on stdout: a job identifier that can
# be used by the probe and cancel scripts to check status and
# kill the job, respectively.
#
# GridSolve submit scripts should exit with status 0 on success
# and non-zero on error.
#

TMP_SCRIPT=gs_tmp_script
/bin/rm -f ${TMP_SCRIPT}

cat << EOF > ${TMP_SCRIPT}
#!/bin/bash
#PBS -l nodes=1:ppn=2
#PBS -l walltime=01:00:00

foo=\`cat \$PBS_NODEFILE | awk -F: '{print \$1}'\`
ssh \${foo} $1 $PWD
EOF

qsub ${TMP_SCRIPT}
