-
Notifications
You must be signed in to change notification settings - Fork 3
/
submit
executable file
·70 lines (55 loc) · 2.15 KB
/
submit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
UI_WORKING_DIR=$1
nJobs=`tail -1 $UI_WORKING_DIR/share/filelist | cut -d ' ' -f 1`
jobName=${2:-test}
queue=${3:-cmscaf1nd}
jobID=$4
usage(){
echo "`basename $0` UI_WORKING_DIR jobName queue"
echo " - this version submits all the jobs"
echo "`basename $0` UI_WORKING_DIR jobName queue jobID"
echo " - this version resumits a single job"
}
# options may be followed by one colon to indicate they have a required argument
if ! options=$(getopt -u -o h -l help -- "$@")
then
# something went wrong, getopt will put out an error message for us
exit 1
fi
set -- $options
while [ $# -gt 0 ]
do
case $1 in
-h|--help) usage; exit 0;;
(--) shift; break;;
(-*) usage; echo "$0: error - unrecognized option $1" 1>&2; usage >> /dev/stderr; exit 1;;
(*) break;;
esac
shift
done
if [ -n "${jobID}" ]; then
jName="${jobName}[${jobID}-${jobID}]"
echo "$jobID SUBMITTED" > $UI_WORKING_DIR/res/$jobID.status
else
jName="${jobName}[1-${nJobs}]"
for jobid in `seq 1 ${nJobs}`
do
if [ -e "${UI_WORKING_DIR}/res/$jobid.status" ];then
echo "[WARNING `basename $0`] Jobs for $UI_WORKING_DIR have been already submitted" >> /dev/stderr
exit 1
fi
echo "$jobid SUBMITTED" > $UI_WORKING_DIR/res/$jobid.status
done
fi
# exit status 92 is a job with xrootd failing, try the automatic requeue of the job
if voms-proxy-info | grep -q "timeleft : 00:00:00" ; then
voms-proxy-list
fi
cp /tmp/x509up_u${UID} $UI_WORKING_DIR/share/ || exit 1
bsub -q $queue -Q 92 \
-oo ${UI_WORKING_DIR}/res/%I-stdout.log \
-eo ${UI_WORKING_DIR}/res/%I-stderr.log \
-J "${jName}" -P $jobName \
"UI_WORKING_DIR=$PWD/$UI_WORKING_DIR; echo \"\${LSB_JOBINDEX} RUNNING\" > \$UI_WORKING_DIR/res/\${LSB_JOBINDEX}.status; cp \$UI_WORKING_DIR/share/* .; cp x509* /tmp/; voms-proxy-info; ./CMSSW.sh \$LSB_JOBINDEX filelist $CMSSW_VERSION; EXITSTATUS=\$?; echo \"\${LSB_JOBINDEX} \$EXITSTATUS\" > \${UI_WORKING_DIR}/res/\${LSB_JOBINDEX}.status" | tee $UI_WORKING_DIR/bsub.log || exit 1
JOBID=`grep "submitted to queue" $UI_WORKING_DIR/bsub.log | sed 's|Job <\([0-9]*\)> is submitted to queue <cmscaf1nd>.|\1|' | head -1`
echo $JOBID >> $UI_WORKING_DIR/JOBID