-
Notifications
You must be signed in to change notification settings - Fork 15
/
submit-sbsdig-job.sh
executable file
·85 lines (75 loc) · 2.83 KB
/
submit-sbsdig-job.sh
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# ------------------------------------------------------------------------- #
# This script runs sbsdig jobs on ifarm or submits them to batch farm. #
# --------- #
# P. Datta <[email protected]> CREATED 11-09-2022 #
# --------- #
# ** Do not tamper with this sticker! Log any updates to the script above. #
# ------------------------------------------------------------------------- #
# Setting necessary environments via setenv.sh
source setenv.sh
# Filebase of the g4sbs output file (w/o file extention)
g4sbsfilebase=$1
# Directory at which g4sbs output files are existing which we want to digitize
g4sbsfiledir=$2
gemconfig=$3 # GEM config (Valid options: 8,10,12)
fjobid=$4 # first job id
njobs=$5 # total no. of jobs to submit
run_on_ifarm=$6 # 1=>Yes (If true, runs all jobs on ifarm)
# workflow name
workflowname=
# Checking the environments
if [[ ! -d $SCRIPT_DIR ]]; then
echo -e '\nERROR!! Please set "SCRIPT_DIR" path properly in setenv.sh script!\n'; exit;
elif [[ ! -d $LIBSBSDIG ]]; then
echo -e '\nERROR!! Please set "LIBSBSDIG" path properly in setenv.sh script!\n'; exit;
fi
# Validating the number of arguments provided
if [[ "$#" -ne 6 ]]; then
echo -e "\n--!--\n Illegal number of arguments!!"
echo -e " This script expects 6 arguments: <g4sbsfilebase> <g4sbsfiledir> <gemconfig> <fjobid> <njobs> <run_on_ifarm>\n"
exit;
else
if [[ $run_on_ifarm -ne 1 ]]; then
echo -e '\n------'
echo -e ' Check the following variable(s):'
echo -e ' "workflowname" : '$workflowname''
while true; do
read -p "Do they look good? [y/n] " yn
echo -e ""
case $yn in
[Yy]*)
break; ;;
[Nn]*)
read -p "Enter desired workflowname : " temp1
workflowname=$temp1
break; ;;
esac
done
fi
fi
# Creating the workflow
if [[ $run_on_ifarm -ne 1 ]]; then
swif2 create $workflowname
else
echo -e "\nRunning all jobs on ifarm!\n"
fi
# creating jobs
for ((i=$fjobid; i<$((fjobid+njobs)); i++))
do
txtfile=$g4sbsfilebase'_job_'$i'.txt'
sbsdigjobname=$g4sbsfilebase'_digi_job_'$i
sbsdiginfile=$g4sbsfiledir'/'$g4sbsfilebase'_job_'$i'.root'
sbsdigscript=$SCRIPT_DIR'/run-sbsdig.sh'' '$txtfile' '$sbsdiginfile' '$gemconfig' '$run_on_ifarm' '$G4SBS' '$LIBSBSDIG' '$ANAVER' '$useJLABENV' '$JLABENV
if [[ $run_on_ifarm -ne 1 ]]; then
swif2 add-job -workflow $workflowname -partition production -name $sbsdigjobname -cores 1 -disk 5GB -ram 1500MB $sbsdigscript
else
$sbsdigscript
fi
done
# run the workflow and then print status
if [[ $run_on_ifarm -ne 1 ]]; then
swif2 run $workflowname
echo -e "\n Getting workflow status.. [may take a few minutes!] \n"
swif2 status $workflowname
fi