-
Notifications
You must be signed in to change notification settings - Fork 1
/
MakeSherpaLibs.sh
executable file
·682 lines (603 loc) · 22.7 KB
/
MakeSherpaLibs.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
#!/bin/bash
#
# file: MakeSherpaLibs.sh
# description: BASH script handling the SHERPA data cards for the
# library production and cross section calculation
# uses: the required SHERPA data cards (+ libraries) [see below]
#
# author: Markus Merschmeyer, Philipp Millet, Sebastian Thueer, RWTH Aachen
# date: 5th Nov 2015
# version: 4.4
#
set +o posix
# +-----------------------------------------------------------------------------------------------+
# function definitions
# +-----------------------------------------------------------------------------------------------+
print_help() {
echo "" && \
echo "MakeSherpaLibs version 4.4" && echo && \
echo "options: -d path (optional) path to your SHERPA installation (otherwise the SHERPA" && \
echo " package belonging to the release under '\$CMSSW_BASE' is used)" && \
echo " -> ( "${shr}" )" && \
echo " -i path path to SHERPA datacard (and library, see -o) files" && \
echo " -> ( "${inc}" )" && \
echo " -p process SHERPA process/dataset name ( "${prc}" )" && \
echo " -o option library/cross section options ( "${lbo}" )" && \
echo " [ 'LBCR' : generate libraries and cross sections ]" && \
echo " [ 'LIBS' : generate libraries only ]" && \
echo " [ 'CRSS' : generate cross sections, needs libraries! ]" && \
echo " [ 'EVTS' : generate events, needs libs + crss. sec.! ]" && \
echo " -f path output path for SHERPA library & cross section files" && \
echo " -> ( "${fin}" )" && \
echo " -D filename (optional) name of data card file ( "${cfdc}" )" && \
echo " -L filename (optional) name of library file ( "${cflb}" )" && \
echo " -C filename (optional) name of cross section file ( "${cfcr}" )" && \
echo " -A switch on multiple interactions in Run.dat card ( "${FLGAMISIC}" )" && \
echo " -v verbose mode ( "${verbose}" )" && \
echo " -T disable library compilation in multithreading mode ( "${nomultithread}" )" && \
echo " -m command enable running in MPI mode with command ( "${ML_MPICMD}" )" && \
echo " -M option additional options for MPI command: ( "${ML_MPIOPT}" )" && \
echo " -e # evts. number of events to be produced ( "${NEVTS}" )" && \
echo " -h display this help and exit" && \
echo ""
}
check_occurence() {
# $1: name of a text file
# $2: string to search in file named $1
# returns: number of occurences of string $2 in file $1
if [ -e $1 ]; then
cnt=0
if [ $# -eq 3 ]; then
cnt=`cat $1 | grep -i $2 | grep -i -c $3`
else
cnt=`cat $1 | grep -i $2 | grep -i -c $2`
fi
if [ $cnt -gt 0 ]; then
echo 1
else
echo 0
fi
else
echo " <E> file "$1" not found!"
fi
}
clean_libs() {
DIRS=`find Process -name P?_?`" "`find Process -name P?_??`
BASEDIR=`pwd`
for J in $DIRS ; do
echo "."
echo "======================"
echo "$J";
echo "======================"
cd $J
# make clean
rm config* Makefile*
# rm *.tex
# rm aclocal.m4 ChangeLog depcomp install-sh libtool ltmain.sh missing
rm aclocal.m4 ChangeLog depcomp install-sh ltmain.sh missing
rm AUTHORS COPYING INSTALL NEWS README
rm -rf autom4te.cache
find ./ -type f -name 'Makefile*' -exec rm -rf {} \;
find ./ -type d -name '.deps' -exec rm -rf {} \;
find ./ -type f -name '*.C' -exec rm -rf {} \;
find ./ -type f -name '*.H' -exec rm -rf {} \;
cd $BASEDIR
done
}
# +-----------------------------------------------------------------------------------------------+
# start of the script
# +-----------------------------------------------------------------------------------------------+
# save current path
HDIR=`pwd`
# dummy setup (if all options are missing)
shr=${HDIR}/SHERPA_1.4.2 # path to SHERPA installation
scrloc=`which scramv1 &> tmp.tmp; cat tmp.tmp | cut -f1 -d"/"; rm tmp.tmp`
if [ "${scrloc}" = "" ]; then
shr=`scramv1 tool info sherpa | grep "SHERPA_BASE" | cut -f2 -d"="`
shrinit=$shr
fi
pth="TMP" # name of SHERPA data card directory
prc="XXX" # SHERPA process name
lbo="LIBS" # library/cross section option
inc=${HDIR} # path to SHERPA datacards (libraries)
cfdc="" # custom data card file name
cflb="" # custom library file name
cfcr="" # custom cross section file name
fin=${HDIR} # output path for SHERPA libraries & cross sections
FLGAMISIC="FALSE" # switch on multiple interactions for production
FLGAMEGIC="FALSE" # flag to indicate the usage of AMEGIC -> library compilation required
verbose="FALSE" # controls verbose mode
nomultithread="FALSE" # disables multithread mode of Sherpa library compilation
ML_MPICMD="" # standard MPI running command
ML_MPIOPT="" # additional MPI options
NEVTS=0 # number of events to be produced
# get & evaluate options
while getopts :d:i:p:o:f:m:e:D:L:C:M:AhvT OPT
do
case $OPT in
d) shr=$OPTARG ;;
i) inc=$OPTARG ;;
p) prc=$OPTARG ;;
o) lbo=$OPTARG ;;
f) fin=$OPTARG ;;
D) cfdc=$OPTARG ;;
L) cflb=$OPTARG ;;
C) cfcr=$OPTARG ;;
A) FLGAMISIC="TRUE" ;;
v) verbose="TRUE" ;;
T) nomultithread="TRUE" ;;
# m) ML_MPICMD="$OPTARG" ;;
m) echo "XXX: "$OPTARG && ML_MPICMD=`echo $OPTARG` ;;
M) ML_MPIOPT="$OPTARG "${ML_MPIOPT} ;;
e) NEVTS=$OPTARG ;;
h) print_help && exit 0 ;;
\?)
shift `expr $OPTIND - 1`
if [ "$1" = "--help" ]; then print_help && exit 0;
else
echo -n "MakeSherpaLibs: error: unrecognized option "
if [ $OPTARG != "-" ]; then echo "'-$OPTARG'. try '-h'"
else echo "'$1'. try '-h'"
fi
print_help && exit 1
fi
shift 1
OPTIND=1
esac
done
# make sure to use absolute path names...
cd ${shr} && shr=`pwd`; cd ${HDIR}
cd ${inc} && inc=`pwd`; cd ${HDIR}
cd ${fin} && fin=`pwd`; cd ${HDIR}
# test whether to take $shr from CMSSW installation
if [ ! "$CMSSW_BASE" = "" ] && [ "$shr" = "$shrinit" ]; then
newshr=""
cd $CMSSW_BASE &&
newshr=`scramv1 tool info sherpa | grep BASE | cut -f 2 -d "="`
if [ "${newshr}" = "" ]; then
echo " <E> no 'sherpa' tool defined in CMSSW, are you sure that"
echo " <E> 1. the command 'scramv1' is available ?"
echo " <E> 2. the path to your CMSSW is correct ?"
echo " <E> 3. there exists a SHERPA package in your CMSSW ?"
exit 0
fi
shr=${newshr}
cd ${HDIR}
fi
if [ "${SHERPA_SHARE_PATH}" = "" ]; then export SHERPA_SHARE_PATH=${shr}/share/SHERPA-MC; fi
if [ "${SHERPA_INCLUDE_PATH}" = "" ]; then export SHERPA_INCLUDE_PATH=${shr}/include/SHERPA-MC; fi
if [ "${SHERPA_LIBRARY_PATH}" = "" ]; then export SHERPA_LIBRARY_PATH=${shr}/lib/SHERPA-MC; fi
# find 'Run' directory
shrun=${HDIR}/SHERPATMP_${prc}
mkdir -p ${shrun}
pth=${shrun}/${pth} #SHERPA 1.3.0 needs full path, MN 070611
echo " -> SHERPA path: '"${shr}"'"
echo " -> SHERPA run path: '"${shrun}"'"
echo " -> PROCESS name: '"${prc}"'"
echo " -> Library & cross section otions: '"${lbo}"'"
echo " -> include path: '"${inc}"'"
echo " -> custom data card file name: '"${cfdc}"'"
echo " -> custom library file name: '"${cflb}"'"
echo " -> custom cross section file name: '"${cfcr}"'"
echo " -> output path: '"${fin}"'"
echo " -> MPI running command: '"${ML_MPICMD}"'"
echo " -> additional MPI options: '"${ML_MPIOPT}"'"
echo " -> No. of events: '"${NEVTS}"'"
# get the number of CPU cores
FLGMCORE="TRUE"
POPTS=""
nprc=1
if [ "$FLGMCORE" == "TRUE" ]; then
nprc=`cat /proc/cpuinfo | grep -c processor`
let nprc=$nprc+1
if [ $nprc -gt 2 ]; then
echo " <I> multiple CPU cores detected: "$nprc"-1"
POPTS=" -j"$nprc" "
fi
fi
# enable multithreading for library compilation
multithread_opt="-j $((nprc-1))"
if [ "$nomultithread" == "TRUE" ]; then
multithread_opt=""
POPTS=""
fi
### go to 'Run' subdirectory of SHERPA
cd ${shrun}
### set base name for SHERPA output file(s) and directories
runfile="Run.dat"
runcardfile=Run.dat_${prc}
outflbs=sherpa_${prc}
cardfile=${outflbs}_cards.tgz # input card file (master -> libraries)
if [ "${lbo}" = "CRSS" ]; then
cardfile=${outflbs}_crdC.tgz
elif [ "${lbo}" = "EVTS" ]; then
cardfile=${outflbs}_crdE.tgz
fi
libsfile=${outflbs}_libs.tgz # output libs
crssfile=${outflbs}_crss.tgz # output cross sections
evtsfile=${outflbs}_evts.tgz # output events
if [ ! "${cfdc}" = "" ]; then
cardfile=${cfdc} # custom input data card file
echo " <I> using custom data card file: "${cardfile}
fi
if [ ! "${cflb}" = "" ]; then
libsfile=${cflb} # custom input library file
echo " <I> using custom library file: "${libsfile}
fi
if [ ! "${cfcr}" = "" ]; then
crssfile=${cfcr} # custom input cross section file
echo " <I> using custom cross section file: "${crssfile}
fi
crdlfile=${outflbs}_crdL.tgz # output cardfile (-> from library production)
crdcfile=${outflbs}_crdC.tgz # output cardfile (-> from cross section calculation)
crdefile=${outflbs}_crdE.tgz # output cardfile (-> from event generation)
loglfile=${outflbs}_logL.tgz # output messages (-> from library production)
logcfile=${outflbs}_logC.tgz # output messages (-> from cross section calculation)
logefile=${outflbs}_logE.tgz # output messages (-> from event generation)
#
gridfile=${outflbs}_migr.tgz # multiple interactions phase-space grid
#
dir1="Process" # SHERPA process directory name
dir2="Result" # SHERPA results directory name
dir3="Analysis" # SHERPA analysis directory name
### clean up existing xsection files
for FILE in `ls xsections_*.dat 2> /dev/null`; do
echo " <W> deleting existing cross section file: "${FILE}
rm ${FILE}
done
### test whether PATH exists
if [ -e ${pth} ]; then
echo " path '"${pth}"' exists,"
echo " -> cleaning path '"${pth}"'"
rm -rf ${pth}/*
else
echo " path '"${pth}"' does not exist,"
echo " -> creating path '"${pth}"'"
mkdir ${pth}
fi
#MM() pth="./"$pth
cd ${pth}
#MM() pth=`pwd`
### get data card (+ library) tarball(s) from include path
if [ -e ${inc}/${cardfile} ]; then
cp ${inc}/${cardfile} ./
else
if [ -e ${inc}/${runcardfile} ]; then
cp ${inc}/${runcardfile} ./
fi
fi
if [ "${lbo}" == "CRSS" ]; then
cp ${inc}/${libsfile} ./
fi
if [ "${lbo}" == "EVTS" ]; then
cp ${inc}/${libsfile} ./
cp ${inc}/${crssfile} ./
cp ${inc}/${gridfile} ./
fi
### check existence of data card file
if [ -e ${cardfile} ]; then
echo " data card file '"${cardfile}"' exists,"
echo " -> unpacking data card file"
tar -xzf ${cardfile}
else
if [ -e ${runcardfile} ]; then
mv ${runcardfile} ${runfile}
else
echo " <E> no data card file found"
echo " -> stopping..."
exit
fi
fi
### find out whether COMIX or AMEGIC is being used
if [ -e ${runfile} ]; then
iamegic=`check_occurence ${runfile} "ME_SIGNAL_GENERATOR" "AMEGIC"`
if [ ${iamegic} -gt 0 ]; then
FLGAMEGIC="TRUE" # using AMEGIC
echo " <I> using AMEGIC ME generator"
else
# FLGAMEGIC="FALSE" # not using AMEGIC
echo " <I> using COMIX/internal ME generator"
### lbo="LBCR"
fi
fi
###exit
### find out if openloops is used
if [ -e ${runfile} ]; then
iopenloops=`check_occurence ${runfile} "OpenLoops"`
if [ ${iopenloops} -gt 0 ]; then
echo " <I> using OpenLoops as loop generator"
iopenloopsprefix=`check_occurence ${runfile} "OL_PREFIX"`
if [ ${iopenloopsprefix} -gt 0 ]; then
echo " <I> OL_PREFIX prefix specified in RunCard."
else
echo " <I> NO OL_PREFIX specified in RunCard."
ol_prefix=$(scram tool info openloops | grep OPENLOOPS_BASE)
ol_prefix=$(echo $ol_prefix | sed -e "s/OPENLOOPS_BASE/OL_PREFIX/g")
echo " <I> Will use ${ol_prefix}"
sed -i -e"/ME_SIGNAL_GENERATOR/a \ \ $ol_prefix" ${runfile}
fi
fi
fi
###exit
### reject mixed occurences of Sherpa's "Enhance" options
#runfile="Run.dat"
if [ -e ${runfile} ]; then
nenhfac=0; nenhfac=`check_occurence ${runfile} "enhance_factor"`
nenhfnc=0; nenhfnc=`check_occurence ${runfile} "enhance_function"`
nenhobs=0; nenhobs=`check_occurence ${runfile} "enhance_observable"`
sumenh=0; let sumenh=$nenhfac+$nenhfnc+$nenhobs
if [ ${sumenh} -gt 1 ]; then
echo " <E> mixed occurence of enhance options in "${runfile}
echo " -> stopping..."
exit
fi
flgwgt=0; flgwgt=`check_occurence ${runfile} "EVENT_GENERATION_MODE" "Weighted"`
if [ ${flgwgt} -eq 0 ] && [ ${nenhfnc} -eq 1 ]; then
echo " <E> unweighted production and enhance_function not supported by Sherpa!"
echo " -> stopping..."
exit
fi
if [ ${flgwgt} -eq 0 ] && [ ${nenhobs} -eq 1 ]; then
echo " <E> unweighted production and enhance_observable currently not supported!"
echo " -> stopping..."
exit
fi
fi
###exit
### check required subdirectories
## generate/clean 'Process' subdirectory
if [ ! -e ${dir1} ]; then
echo " '"${dir1}"' subdirectory does not exist and will be created"
mkdir ${dir1}
else
echo " cleaning '"${dir1}"' subdirectory"
rm -rf ${dir1}/*
fi
## generate/clean 'Results' subdirectory
if [ ! -e ${dir2} ]; then
echo " '"${dir2}"' subdirectory does not exist and will be created"
mkdir ${dir2}
else
echo " cleaning '"${dir2}"' subdirectory"
rm -rf ${dir2}/*
fi
### check, whether only cross sections have to be calculated
if [ "${lbo}" = "CRSS" ] || [ "${lbo}" = "EVTS" ]; then
if [ -e ${libsfile} ]; then
echo " <I> library file '"${libsfile}"' exists,"
echo " -> unpacking library file"
tar -xzf ${libsfile}
else
echo " <E> no library file found"
echo " -> stopping..."
exit
fi
fi
### check, whether only events have to be generated
if [ "${lbo}" = "EVTS" ]; then
if [ -e ${crssfile} ]; then
echo " <I> cross section file '"${crssfile}"' exists,"
echo " -> unpacking cross section file"
tar -xzf ${crssfile}
else
echo " <E> no cross section file found"
echo " -> stopping..."
exit
fi
if [ -e ${gridfile} ]; then
echo " <I> MI grid file '"${gridfile}"' exists,"
echo " -> unpacking phase-space grid"
tar -xzf ${gridfile}
else
echo " <W> no MI grid file found"
echo " -> will be recreated..."
fi
fi
### generate process-specific libraries -> redirect output (stdout, stderr) to files
sherpaexe=`find ${shr} -type f -name Sherpa`
echo " <I> Sherpa executable is "${sherpaexe}
cd ${pth}
# create logfiles
touch ${shrun}/${outflbs}_pass${lbo}.out
touch ${shrun}/${outflbs}_pass${lbo}.err
if [ "${FLGAMEGIC}" == "TRUE" ]; then
touch ${shrun}/${outflbs}_mklib.out
touch ${shrun}/${outflbs}_mklib.err
touch ${shrun}/${outflbs}_cllib.out
touch ${shrun}/${outflbs}_cllib.err
fi
#Executes a command and logs its stdout and stderr outputs to files.
#If global variable verbose is TRUE, then output is also display on the terminal
#Usage exec_log2 [-a] stdout_file stderr_file cmd args ....
# -a: append outputs to the files.
exec_log2(){
local append_opt=""
if [ $1 = -a ]; then
append_opt=-a
shift
else
unset append_opt
fi
local fout=$1
local ferr=$2
shift 2;
if [ "$verbose" = "TRUE" ]; then
$@ 1> >(tee $append_opt $fout) 2> >(tee $append_opt $ferr >&2)
elif [ -n "$append_opt" ]; then
"$@" >> "$fout" 2>> "$ferr"
else
"$@" > "$fout" 2> "$ferr"
fi
}
## first pass (loop if AMEGIC + NLO loop generators are used)
if [ "${lbo}" == "LIBS" ] || [ "${lbo}" == "LBCR" ]; then
# force Sherpa to only determine the processes & compile the libraries
SHERPAOPTS="-MNone -FOff INIT_ONLY=1"
echo " <I> creating library code..."
echo " ...Logs stored in ${shrun}/${outflbs}_pass${lbo}.out and ${shrun}/${outflbs}_pass${lbo}.err."
exec_log2 -a ${shrun}/${outflbs}_pass${lbo}.out ${shrun}/${outflbs}_pass${lbo}.err ${sherpaexe} -p ${pth} -r ${dir2} ${SHERPAOPTS}
if [ "${FLGAMEGIC}" == "TRUE" ]; then
FLGNEWCODE="TRUE"
FLGWRITLIB="TRUE"
while [ "${FLGNEWCODE}" == "TRUE" ] || [ "${FLGWRITLIB}" == "TRUE" ]; do
# compile created library code
echo " <I> compiling libraries..."
echo " ...Logs stored in ${shrun}/${outflbs}_mklib.out and ${shrun}/${outflbs}_mklib.err."
exec_log2 -a ${shrun}/${outflbs}_mklib.out ${shrun}/${outflbs}_mklib.err ./makelibs ${POPTS} -i $SHERPA_INCLUDE_PATH
# get gross size of created libraries
nf=`du -sh | grep -o "\." | grep -c "\."`
lsize=`du -sh | cut -f 1-${nf} -d "."`
echo " <I> -> raw size: "${lsize}
echo " <I> cleaning libraries..."
echo " ...Logs stored in ${shrun}/${outflbs}_cllib.out and ${shrun}/${outflbs}_cllib.err."
exec_log2 -a ${shrun}/${outflbs}_cllib.out ${shrun}/${outflbs}_cllib.err clean_libs
# get net size of created libraries
nf=`du -sh | grep -o "\." | grep -c "\."`
lsize=`du -sh | cut -f 1-${nf} -d "."`
echo " <I> -> clean size: "${lsize}
# reinvoke Sherpa
echo " <I> re-invoking Sherpa for futher library/cross section calculation..."
echo " ...Logs stored in ${shrun}/${outflbs}_pass${lbo}.out and ${shrun}/${outflbs}_pass${lbo}.err."
exec_log2 -a ${shrun}/${outflbs}_pass${lbo}.out ${shrun}/${outflbs}_pass${lbo}.err ${sherpaexe} -p ${pth} -r ${dir2} ${SHERPAOPTS}
# newly created process code by AMEGIC?
cd ${dir1}
lastdir=`ls -C1 -drt * | tail -1`
npdir=`echo ${lastdir} | grep -c "P2"`
if [ ${npdir} -gt 0 ]; then
echo " <I> (AMEGIC) library code was created in (at least) "${lastdir}
FLGNEWCODE="TRUE"
else
FLGNEWCODE="FALSE"
fi
cd ${pth}
# mentioning of "" in last 100 lines output file?
nlines=200
# nphbw=`tail -${nlines} ${shrun}/${outflbs}_pass${lbo}.out | grep -c "has been written"`
# npasw=`tail -${nlines} ${shrun}/${outflbs}_pass${lbo}.out | grep -c "AMEGIC::Single_Process::WriteLibrary"`
npnlc=`tail -${nlines} ${shrun}/${outflbs}_pass${lbo}.out | grep -c "New libraries created. Please compile."`
# if [ ${nphbw} -gt 0 ] || [ ${npasw} -gt 0 ] || [ ${npnlc} -gt 0 ] ; then
if [ ${npnlc} -gt 0 ] ; then
echo " <I> (AMEGIC) detected library writing: "${nphbw}" (HBW), "${npasw}" (ASW), "${npnlc}" (NLC)"
FLGWRITLIB="TRUE"
else
FLGWRITLIB="FALSE"
fi
done
fi
### cd ${shrun}
fi
if [ "${lbo}" == "LBCR" ] || [ "${lbo}" == "CRSS" ]; then
# ...only calculate a few events for a sanity check of the libraries + cross sections
SHERPAOPTS="-e ${NEVTS}"
echo " <I> calculating cross sections... Logs stored in ${shrun}/${outflbs}_pass${lbo}.out and ${shrun}/${outflbs}_pass${lbo}.err."
if [ "$ML_MPICMD" == "" ]; then
exec_log2 ${shrun}/${outflbs}_pass${lbo}.out ${shrun}/${outflbs}_pass${lbo}.err ${sherpaexe} -p ${pth} -r ${dir2} ${SHERPAOPTS}
else
echo " <I> ...using MPI"
exec_log2 ${shrun}/${outflbs}_pass${lbo}.out ${shrun}/${outflbs}_pass${lbo}.err ${ML_MPICMD} ${ML_MPIOPT} ${sherpaexe} -p ${pth} -r ${dir2} ${SHERPAOPTS}
fi
fi
## last pass (event generation)
if [ "${lbo}" == "EVTS" ]; then
SHEVTOPT=""
if [ ${NEVTS} -gt 0 ]; then
SHEVTOPT="-e "${NEVTS}
else
NEVTS="default -> run card"
fi
echo " <I> generating events (${NEVTS})... Logs stored in ${shrun}/${outflbs}_pass${lbo}.out and ${shrun}/${outflbs}_pass${lbo}.err."
if [ "$ML_MPICMD" == "" ]; then
exec_log2 ${shrun}/${outflbs}_pass${lbo}.out ${shrun}/${outflbs}_pass${lbo}.err ${sherpaexe} -p ${pth} -r ${dir2} ${SHEVTOPT}
else
echo " <I> ...using MPI"
exec_log2 ${shrun}/${outflbs}_pass${lbo}.out ${shrun}/${outflbs}_pass${lbo}.err ${ML_MPICMD} ${ML_MPIOPT} ${sherpaexe} -p ${pth} -r ${dir2} ${SHEVTOPT}
fi
fi
## generate tar balls with data cards, libraries, cross sections, events
cd ${pth}
## libraries & cross sections
if [ "${lbo}" == "LIBS" ] || [ "${lbo}" = "LBCR" ]; then
touch ${libsfile}.tmp
find ./${dir1}/ -name '*' > tmp.lst && tar --no-recursion -rf ${libsfile}.tmp -T tmp.lst; rm tmp.lst
gzip -9 ${libsfile}.tmp && mv ${libsfile}.tmp.gz ${libsfile}
mv ${libsfile} ${shrun}/
fi
if [ "${lbo}" == "LBCR" ] || [ "${lbo}" = "CRSS" ]; then
touch ${crssfile}.tmp
find ./${dir2}/ -name '*' > tmp.lst
if [ -e Result.db ]; then
echo Result.db >> tmp.lst
fi
tar --no-recursion -rf ${crssfile}.tmp -T tmp.lst; rm tmp.lst
if [ -e ${dir3} ]; then
find ./${dir3}/ -name '*' > tmp.lst && tar --no-recursion -rf ${crssfile}.tmp -T tmp.lst; rm tmp.lst
fi
gzip -9 ${crssfile}.tmp && mv ${crssfile}.tmp.gz ${crssfile}
mv ${crssfile} ${shrun}/
fi
#### create tarball with multiple interactions grid files
if [ ! "${lbo}" == "EVTS" ]; then
migdir=`find ./ -name MIG\*`
echo " <I> MPI (mult. part. int.) grid located in "${migdir}
migfil=`find ./ -type f -name MPI\*.dat`
echo " <I> MPI (mult. part. int.) file found: "${migfil}
if [ -d "${migdir}" ] || [ -e "${migdir}" ]; then
if [ -e "${migfil}" ]; then
tar -czf ${gridfile} ${migdir} ${migfil}
else
tar -czf ${gridfile} ${migdir}
fi
mv ${gridfile} ${shrun}/
fi
fi
####
if [ "${lbo}" == "EVTS" ]; then
rm ${libsfile}
rm ${crssfile}
rm ${gridfile}
tar -czf ${evtsfile} *.*
mv ${evtsfile} ${shrun}/
fi
#rm -rf ${dir1}/*
#rm -rf ${dir2}/*
#rm -rf ${dir3}/*
#rm *.md5
## data cards
FILES=`ls *.md5 *.dat *slha.out 2> /dev/null`
if [ "${lbo}" == "LIBS" ]; then
tar -czf ${crdefile} ${FILES}
mv ${crdefile} ${shrun}/
elif [ "${lbo}" == "LBCR" ]; then
if [ "${FLGAMISIC}" == "TRUE" ]; then
sed -e 's:MI_HANDLER.*:MI_HANDLER = Amisic:' < Run.dat > Run.dat.tmp
mv Run.dat.tmp Run.dat
fi
tar -czf ${crdefile} ${FILES}
mv ${crdefile} ${shrun}/
elif [ "${lbo}" == "CRSS" ]; then
if [ "${FLGAMISIC}" == "TRUE" ]; then
sed -e 's:MI_HANDLER.*:MI_HANDLER = Amisic:' < Run.dat > Run.dat.tmp
mv Run.dat.tmp Run.dat
fi
tar -czf ${crdefile} ${FILES}
mv ${crdefile} ${shrun}/
elif [ "${lbo}" == "EVTS" ]; then
echo ""
fi
## log files
cd ${shrun}
FILES=`ls *.err *.out 2> /dev/null`
if [ "${lbo}" == "LIBS" ]; then
tar -czf ${loglfile} ${FILES}
elif [ "${lbo}" == "LBCR" ]; then
tar -czf ${loglfile} ${FILES}
elif [ "${lbo}" == "CRSS" ]; then
tar -czf ${logcfile} ${FILES}
elif [ "${lbo}" == "EVTS" ]; then
tar -czf ${logefile} ${FILES}
fi
#rm *.err *.out
mv *.tgz ${fin}/
# go back to original directory
cd ${HDIR}
rm -rf ${shrun}