#!/bin/sh
# set -x
# 
#  Cancel job running in SGE.
# 

echo "----- starting cancel_sge_job -----" 1>&2

joboption_lrms="sge"
lrms_options="sge_root sge_cell sge_qmaster_port sge_execd_port sge_bin_path sge_jobopts"
queue_options="sge_jobopts"

# ARC1 passes first the config file.
if [ "$1" = "--config" ]; then shift; ARC_CONFIG=$1; shift; fi
GRAMI_FILE=$1

# define paths and config parser
basedir=`dirname $0`
basedir=`cd $basedir > /dev/null && pwd` || exit $?
. "${basedir}/lrms_common.sh"

# load common cancel functions
. "${pkgdatadir}/cancel_common.sh" || exit $?

# run common init
#  * parse grami
#  * parse config
#  * load LRMS-specific env
common_init

# qdel
echo executing $SGE_BIN_PATH/qdel with job id $joboption_jobid 1>&2
$SGE_BIN_PATH/qdel "${joboption_jobid}"

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