-
Notifications
You must be signed in to change notification settings - Fork 8
/
interpolateAll.sh
182 lines (156 loc) · 5.04 KB
/
interpolateAll.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
INPUT=$1
RESONANCE=$2
JOBLOGFILES="myout.txt myerr.txt"
# OUTFILES=""
DBG=2
SEUSERSUBDIR=""
SEOUTFILES=""
HN_NAME=`whoami`
USER_SRM_HOME="srm://t3se01.psi.ch:8443/srm/managerv2?SFN=/pnfs/psi.ch/cms/trivcat/store/user"
TOPWORKDIR=/scratch/`whoami`
JOBDIR=interpolateAll-$JOB_ID
#CMSSW_DIR="/mnt/t3nfs01/data01/shome/thaarres/EXOVVAnalysisRunII/LimitCode/CMSSW_7_1_5"
CMSSW_DIR="/cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/cmssw/CMSSW_8_0_20/"
BASEDIR=`pwd`
LOGDIRNAME=${BASEDIR}/${JOBDIR}
OUTDIR=${BASEDIR}/${JOBDIR}
#mkdir ${OUTDIR}
############ BATCH QUEUE DIRECTIVES ##############################
# Lines beginning with #$ are used to set options for the SGE
# queueing system (same as specifying these options to the qsub
# command
# Job name (defines name seen in monitoring by qstat and the
# job script's stderr/stdout names)
#$ -N interpolateAll_job
### Specify the queue on which to run
#$ -q short.q
# Change to the current working directory from which the job got
# submitted (will also result in the job report stdout/stderr being
# written to this directory)
#$ -cwd
# here you could change location of the job report stdout/stderr files
# if you did not want them in the submission directory
#$ -o $OUTDIR
#$ -e $OUTDIR
#################################################################
##### MONITORING/DEBUG INFORMATION ###############################
DATE_START=`date +%s`
echo "Job started at " `date`
cat <<EOF
################################################################
## QUEUEING SYSTEM SETTINGS:
HOME=$HOME
USER=$USER
JOB_ID=$JOB_ID
JOB_NAME=$JOB_NAME
HOSTNAME=$HOSTNAME
TASK_ID=$TASK_ID
QUEUE=$QUEUE
EOF
echo "################################################################"
if test 0"$DBG" -gt 0; then
echo "######## Environment Variables ##########"
env
echo "################################################################"
fi
##### SET UP WORKDIR AND ENVIRONMENT ######################################
STARTDIR=`pwd`
WORKDIR=$TOPWORKDIR/$JOBDIR
RESULTDIR=$STARTDIR/$JOBDIR
if test x"$SEUSERSUBDIR" = x; then
SERESULTDIR=$USER_SRM_HOME/$HN_NAME/$JOBDIR
else
SERESULTDIR=$USER_SRM_HOME/$HN_NAME/$SEUSERSUBDIR
fi
if test -e "$WORKDIR"; then
echo "ERROR: WORKDIR ($WORKDIR) already exists! Aborting..." >&2
exit 1
fi
mkdir -p $WORKDIR
if test ! -d "$WORKDIR"; then
echo "ERROR: Failed to create workdir ($WORKDIR)! Aborting..." >&2
exit 1
fi
cd $WORKDIR
cat <<EOF
################################################################
## JOB SETTINGS:
STARTDIR=$STARTDIR
WORKDIR=$WORKDIR
RESULTDIR=$RESULTDIR
SERESULTDIR=$SERESULTDIR
EOF
###########################################################################
## YOUR FUNCTIONALITY CODE GOES HERE
# set up CMS environment
RUNSCRIPT=${BASEDIR}/interpolateVV13TeV.py
INFILE=${BASEDIR}/${INPUT}
source $VO_CMS_SW_DIR/cmsset_default.sh
cd $CMSSW_DIR/src
eval `scramv1 runtime -sh`
if test $? -ne 0; then
echo "ERROR: Failed to source scram environment" >&2
exit 1
fi
cd $WORKDIR
echo "input: ${INPUT}" >> myout.txt 2>>myerr.txt
echo "infile: ${INFILE}" >> myout.txt 2>>myerr.txt
echo "python ${RUNSCRIPT} ${INFILE} ${RESONANCE} GeV" >> myout.txt 2>>myerr.txt
python ${RUNSCRIPT} ${INFILE} ${RESONANCE} GeV >> myout.txt 2>>myerr.txt
#### RETRIEVAL OF OUTPUT FILES AND CLEANING UP ############################
cd $WORKDIR
if test 0"$DBG" -gt 0; then
echo "########################################################"
echo "############# Working directory contents ###############"
echo "pwd: " `pwd`
ls -Rl
echo "########################################################"
echo "YOUR OUTPUT WILL BE MOVED TO $RESULTDIR"
echo "########################################################"
fi
if test x"$JOBLOGFILES" != x; then
mkdir -p $RESULTDIR
if test ! -e "$RESULTDIR"; then
echo "ERROR: Failed to create $RESULTDIR ...Aborting..." >&2
exit 1
fi
for n in $JOBLOGFILES; do
if test ! -e $WORKDIR/$n; then
echo "WARNING: Cannot find output file $WORKDIR/$n. Ignoring it" >&2
else
cp -a $WORKDIR/$n $RESULTDIR/$n
if test $? -ne 0; then
echo "ERROR: Failed to copy $WORKDIR/$n to $RESULTDIR/$n" >&2
fi
fi
done
fi
if test x"$OUTFILES" != x; then
if test 0"$DBG" -ge 2; then
srmdebug="-v"
fi
for n in $OUTFILES; do
if test ! -e $WORKDIR/$n; then
echo "WARNING: Cannot find output file $WORKDIR/$n. Ignoring it" >&2
else
cp -a $WORKDIR/$n $OUTDIR/$n
if test $? -ne 0; then
echo "ERROR: Failed to copy $WORKDIR/$n to $OUTDIR/$n" >&2
fi
fi
done
fi
echo "Cleaning up $WORKDIR"
rm -rf $WORKDIR
rm -rf $LOGDIRNAME/$JOBDIR
mv $STARTDIR/$JOBDIR $LOGDIRNAME/.
###########################################################################
DATE_END=`date +%s`
RUNTIME=$((DATE_END-DATE_START))
echo "################################################################"
echo "Job finished at " `date`
echo "Wallclock running time: $RUNTIME s"
cd ${BASEDIR}
mv interpolateAll_job.o$JOB_ID interpolateAll_job.e$JOB_ID $LOGDIRNAME/.
exit 0