-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbatchSubRerunLHE.sh
79 lines (58 loc) · 1.84 KB
/
batchSubRerunLHE.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
#!/bin/bash
echo "Begin at `date`"
[ "$USER" == "estrauss" ] && HomeDir=${PWD} && InputDir=/u/at/estrauss/atlint02/logs_madgraph/ && OutputDir=/u/at/estrauss/atlint02/logs_madgraph_v2_fixed/
SubFileLoc=`pwd`/_batchRerunLHE.sh
echo '
#!/bin/bash
INDEX=`echo $LSB_BATCH_JID | sed -e "s/^[0-9]*//; s/\[//; s/\]//"`
BASENAME=$2
OUTPUT=$3/`basename ${BASENAME}`
ID=`uuidgen`
[[ -e /tmp ]] && WORKDIR=/tmp/${USER}/${ID}
[[ -e /scratch ]] && WORKDIR=/scratch/${USER}/${ID}
echo "Index: $INDEX"
echo "Basename: $BASENAME"
echo "Output: $OUTPUT"
echo "WorkDir: $WORKDIR"
cd $1
if [ `ls ${BASENAME}_${INDEX}.* | wc -l` == 0 ]; then
echo "No such file ${BASENAME}_${INDEX}.*"
exit 0
fi
. setup_env.sh
T=$(($RANDOM%600))
echo "Sleep for $T seconds"
sleep $T
mkdir -p ${WORKDIR}
if [[ "$?" != "0" ]]; then
echo "Could not create WorkDir"
exit 1
fi
cd ${WORKDIR}
LOGNAME=`tar -xzvf ${BASENAME}_${INDEX}.*`
awk "/Start LHE File/{x=\"F\"++i;next}{print > \"${LOGNAME}_split\"x;}" ${LOGNAME}
for FILE in `ls ${LOGNAME}_splitF*`; do
echo "Process ${FILE}"
echo "@@ Start LHE File" >> regen.log
awk "//{f=1;}f&&/End LHE File/{exit}f" ${FILE} >> regen.log
echo "@@ END LHE File" >> regen.log
`grep "Called as" ${FILE} | sed -e "s/Called as: //; s/LHEFile=.*lhe/LHEFile=${FILE}/"` >> regen.log
done
tar -czvf ${OUTPUT}_${INDEX}.tgz regen.log
cd $1
rm -rf ${WORKDIR}
' > $SubFileLoc
chmod u+x $SubFileLoc
mkdir -p ${OutputDir}
SAMPLES=`ls $InputDir/* | sed -e 's/_[0-9]*.\(log\|tgz\)//' | sort -u`
for SAMPLE in $SAMPLES; do
while [[ `bjobs|wc -l` -ge 100 ]]; do
echo "More than 100 jobs on the queues, waiting for some to clear"
sleep 300
done
echo "Submit $SAMPLE"
N=`ls ${SAMPLE}* | wc -l`
bsub -q long -J `basename ${SAMPLE}`[1-$N] -R rhel50 $SubFileLoc $HomeDir $SAMPLE $OutputDir
sleep 30
done
echo "Done at `date`"