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

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

joboption_lrms="lsf"
lrms_options="lsf_architecture lsf_bin_path"

# 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

# bkill
LSF_BKILL='bkill'
if [ ! -z "$LSF_BIN_PATH" ] ; then
  LSF_BKILL="${LSF_BIN_PATH}/${LSF_BKILL} -s 9 "
fi

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

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