#! /bin/sh -f
# set -x
# 
#  Cancel job running in PBS.
#  Input: grami file (same as Globus)
# 
#  Based on globus submission script for pbs
#
# 

echo "----- starting cancel_pbs_job -----" 1>&2
joboption_lrms=PBS
##############################################################
# These should be set automatically
##############################################################
# Path to pbs commands
PBS_BIN_PATH=${PBS_BIN_PATH:-/usr/bin}
# Where to store temporary files on gatekeeper
TMP_DIR=${TMP_DIR:-/tmp}
# Where runtime scripts can be found on computing nodes (empty if does not exist)
RUNTIME_CONFIG_DIR=${RUNTIME_CONFIG_DIR:-}
# Description of (cross-)mounted disc space on cluster
RUNTIME_LOCAL_SCRATCH_DIR=${RUNTIME_LOCAL_SCRATCH_DIR:-}
RUNTIME_FRONTEND_SEES_NODE=${RUNTIME_FRONTEND_SEES_NODE:-}
#RUNTIME_NODE_SEES_FRONTEND=${RUNTIME_NODE_SEES_FRONTEND:-}
RUNTIME_NODE_SEES_FRONTEND=${RUNTIME_NODE_SEES_FRONTEND:-yes}


arg_file=$1
##############################################################
# Source the argument file. 
##############################################################
if [ -z "$arg_file" ] ; then
   echo "Arguments file should be specified" 1>&2
   exit 1
fi
if [ ! -f $arg_file ] ; then
   echo "Missing arguments file" 1>&2
   exit 1
fi
. $arg_file

PBS_QDEL='qdel'
if [ ! -z "$PBS_BIN_PATH" ] ; then
  PBS_QDEL="${PBS_BIN_PATH}/${PBS_QDEL}"
fi

tmpdir=${TMP_DIR:-/tmp}

echo executing qdel with job id $joboption_jobid 1>&2
"${PBS_QDEL}" "${joboption_jobid}"

echo "----- exiting cancel_pbs_job -----" 1>&2
echo "" 1>&2
exit 0







