3 #---------------------------------------------------------------------------------------------------------------------
4 # Submit standard neutrino event generation jobs for GENIE release validation
5 # The outputs can be compared with outputs from past releases using the GENIE/Generator gevcomp app.
6 # Sanity checks can be performed using the GENIE/Generator gevscan app.
9 # shell% perl submit_standard_neutrino_mc_test_jobs.pl <options>
12 # --version : GENIE version number
13 # --run : Comma separated list of run numbers
14 # [--arch] : <SL4.x86_32, SL5.x86_64, SL6.x86_64, ...>, default: SL6.x86_64
15 # [--production] : default: routine_validation
16 # [--cycle] : default: 01
17 # [--ref-samples] : Path for reference samples, default: no reference samples / no plots will be generated
18 # [--use-valgrind] : default: off
19 # [--batch-system] : <PBS, LSF, slurm, HTCondor, HTCondor_PBS, none>, default: PBS
20 # [--queue] : default: prod
21 # [--softw-topdir] : top level dir for softw installations, default: /opt/ppd/t2k/softw/GENIE/
22 # [--jobs-topdir] : top level dir for job files, default: /opt/ppd/t2k/scratch/GENIE/
26 #......................................................................
27 # run | nev | init state | energy | processes
28 # nu. | | | (GeV) | enabled
29 #......................................................................
30 # 1000 | 100k | numu + n | 0.5 | all
31 # 1001 | 100k | numu + n | 1 | all
32 # 1002 | 100k | numu + n | 5 | all
33 # 1003 | 100k | numu + n | 50 | all
34 # 1101 | 100k | numubar + p | 1 | all
35 # 1102 | 100k | numubar + p | 5 | all
36 # 1103 | 100k | numubar + p | 50 | all
37 # 2001 | 100k | numu + Fe56 | 1 | all
38 # 2002 | 100k | numu + Fe56 | 5 | all
39 # 2003 | 100k | numu + Fe56 | 50 | all
40 # 2101 | 100k | numubar + Fe56 | 1 | all
41 # 2102 | 100k | numubar + Fe56 | 5 | all
42 # 2103 | 100k | numubar + Fe56 | 50 | all
43 # 9001 | 100k | numu + Fe56 | 5 | DIS charm
44 # 9002 | 100k | numu + Fe56 | 5 | QEL charm
45 # 9101 | 100k | numu + Fe56 | 2 | COH CC+NC
46 # 9201 | 100k | nue + Fe56 | 1 | ve elastic
47 # 9202 | 100k | numu + Fe56 | 1 | ve elastic
48 # 9203 | 50k | numu + Fe56 | 20 | IMD
49 # 9204 | 50k | nuebar + Fe56 | 20 | IMD (annihilation)
50 #......................................................................
54 # shell% perl submit_standard_neutrino_mc_test_jobs.pl \
55 # --production 2.5.1_prelease_tests --cycle 01 --version v2.5.1 --run 1001
56 # shell% perl submit_standard_neutrino_mc_test_jobs.pl \
57 # --production 2.5.1_prelease_tests --cycle 01 --version v2.5.1 --run 1000,1001,9203
58 # shell% perl submit_standard_neutrino_mc_test_jobs.pl \
59 # --production 2.5.1_prelease_tests --cycle 01 --version v2.5.1 --run all
61 # Tested at the RAL/PPD Tier2 PBS batch farm.
63 # Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
64 # STFC, Rutherford Appleton Lab
65 #---------------------------------------------------------------------------------------------------------------------
75 if($_ eq '--version') { $genie_version = $ARGV[$iarg+1]; }
76 if($_ eq '--run') { $runnu = $ARGV[$iarg+1]; }
77 if($_ eq '--arch') { $arch = $ARGV[$iarg+1]; }
78 if($_ eq '--production') { $production = $ARGV[$iarg+1]; }
79 if($_ eq '--cycle') { $cycle = $ARGV[$iarg+1]; }
80 if($_ eq '--ref-samples') { $ref_sample_path = $ARGV[$iarg+1]; }
81 if($_ eq '--use-valgrind') { $use_valgrind = $ARGV[$iarg+1]; }
82 if($_ eq '--batch-system') { $batch_system = $ARGV[$iarg+1]; }
83 if($_ eq '--queue') { $queue = $ARGV[$iarg+1]; }
84 if($_ eq '--softw-topdir') { $softw_topdir = $ARGV[$iarg+1]; }
85 if($_ eq '--jobs-topdir') { $jobs_topdir = $ARGV[$iarg+1]; }
88 die("** Aborting [Undefined benchmark runs #. Use the --run option]")
89 unless defined $runnu;
90 die("** Aborting [Undefined GENIE version. Use the --version option]")
91 unless defined $genie_version;
93 $use_valgrind = 0 unless defined $use_valgrind;
94 $arch = "SL6.x86_64" unless defined $arch;
95 $production = "routine_validation" unless defined $production;
96 $cycle = "01" unless defined $cycle;
97 $batch_system = "PBS" unless defined $batch_system;
98 $queue = "prod" unless defined $queue;
99 $softw_topdir = "/opt/ppd/t2k/softw/GENIE/" unless defined $softw_topdir;
100 $jobs_topdir = "/opt/ppd/t2k/scratch/GENIE/" unless defined $jobs_topdir;
101 $time_limit = "60:00:00";
102 $ref_sample_path = 0 unless defined $ref_sample_path;
103 $genie_setup = "$softw_topdir/generator/builds/$arch/$genie_version-setup";
104 $xspl_file = "$softw_topdir/data/job_inputs/xspl/gxspl-vA-$genie_version.xml";
105 $jobs_dir = "$jobs_topdir/$genie_version-$production\_$cycle-mctest";
155 '1000' => '1000000010',
156 '1001' => '1000000010',
157 '1002' => '1000000010',
158 '1003' => '1000000010',
159 '1101' => '1000010010',
160 '1102' => '1000010010',
161 '1103' => '1000010010',
162 '2001' => '1000260560',
163 '2002' => '1000260560',
164 '2003' => '1000260560',
165 '2101' => '1000260560',
166 '2102' => '1000260560',
167 '2103' => '1000260560',
168 '9001' => '1000260560',
169 '9002' => '1000260560',
170 '9101' => '1000260560',
171 '9201' => '1000260560',
172 '9202' => '1000260560',
173 '9203' => '1000260560',
174 '9204' => '1000260560'
214 '9001' => 'CharmCCDIS',
215 '9002' => 'CharmCCQE',
217 '9201' => 'NuEElastic',
218 '9202' => 'NuEElastic',
223 # make the jobs directory
225 mkpath ($jobs_dir, {verbose => 1, mode=>0777});
227 print "Input runs: $runnu \n";
229 for my $curr_runnu (keys %gevgl_hash) {
230 # print "Checking benchmark run: ...... $curr_runnu \n";
232 if($runnu=~m/$curr_runnu/ || $runnu eq "all") {
233 print "** matched -> submitting job \n";
236 # get runnu-dependent info
238 $nev = $nevents_hash {$curr_runnu};
239 $nu = $nupdg_hash {$curr_runnu};
240 $tgt = $tgtpdg_hash {$curr_runnu};
241 $en = $energy_hash {$curr_runnu};
242 $gevgl = $gevgl_hash {$curr_runnu};
244 $jobname = "mctest-$curr_runnu";
245 $filename_template = "$jobs_dir/$jobname";
246 # $grep_pipe = "grep -B 20 -A 30 -i \"warn\\|error\\|fatal\"";
247 $grep_pipe = "grep -B 20 -A 10 -i fatal";
248 $valgrind_cmd = "valgrind --tool=memcheck --error-limit=no --leak-check=yes --show-reachable=yes";
249 $evgen_opt = "-n $nev -e $en -p $nu -t $tgt -r $curr_runnu --seed $mcseed --cross-sections $xspl_file --event-generator-list $gevgl";
250 $evgen_cmd = "gevgen $evgen_opt | $grep_pipe &> $filename_template.evgen.log";
251 $conv_cmd = "gntpc -f gst -i gntp.$curr_runnu.ghep.root | $grep_pipe &> $filename_template.conv.log";
252 $comp_cmd = "gevcomp -f gntp.$curr_runnu.gst.root -r $ref_sample_path/gntp.$curr_runnu.gst.root | $grep_pipe &> $filename_template.comp.log";
254 print "@@ exec: $evgen_cmd \n";
261 if($batch_system eq 'PBS' || $batch_system eq 'HTCondor_PBS') {
262 $batch_script = "$filename_template.pbs";
263 open(PBS, ">$batch_script") or die("Can not create the PBS batch script");
264 print PBS "#!/bin/bash \n";
265 print PBS "#PBS -N $jobname \n";
266 print PBS "#PBS -o $filename_template.pbsout.log \n";
267 print PBS "#PBS -e $filename_template.pbserr.log \n";
268 print PBS "source $genie_setup \n";
269 print PBS "cd $jobs_dir \n";
270 print PBS "$evgen_cmd \n";
271 print PBS "$conv_cmd \n";
272 if(-d $ref_sample_path) {
273 print PBS "$comp_cmd \n";
276 $job_submission_command = "qsub";
277 if($batch_system eq 'HTCondor_PBS') {
278 $job_submission_command = "condor_qsub";
280 `$job_submission_command -q $queue $batch_script`;
284 if($batch_system eq 'LSF') {
285 $batch_script = "$filename_template.sh";
286 open(LSF, ">$batch_script") or die("Can not create the LSF batch script");
287 print LSF "#!/bin/bash \n";
288 print PBS "#BSUB-j $jobname \n";
289 print LSF "#BSUB-q $queue \n";
290 print LSF "#BSUB-o $filename_template.lsfout.log \n";
291 print LSF "#BSUB-e $filename_template.lsferr.log \n";
292 print LSF "source $genie_setup \n";
293 print LSF "cd $jobs_dir \n";
294 print LSF "$evgen_cmd \n";
295 print LSF "$conv_cmd \n";
296 if(-d $ref_sample_path) {
297 print LSF "$comp_cmd \n";
300 `bsub < $batch_script`;
304 if($batch_system eq 'HTCondor') {
305 $batch_script = "$filename_template.htc";
306 open(HTC, ">$batch_script") or die("Can not create the Condor submit description file: $batch_script");
307 print HTC "Universe = vanilla \n";
308 print HTC "Executable = $softw_topdir/generator/builds/$arch/$genie_version/src/scripts/production/batch/htcondor_exec.sh \n";
309 print HTC "Arguments = $genie_setup $jobs_dir $evgen_cmd $conv_cmd";
310 if(-d $ref_sample_path) {
311 print HTC " $comp_cmd";
314 print HTC "Log = $filename_template.log \n";
315 print HTC "Output = $filename_template.out \n";
316 print HTC "Error = $filename_template.err \n";
317 print HTC "Request_memory = 2 GB \n";
318 print HTC "Queue \n";
320 `condor_submit $batch_script`;
324 if($batch_system eq 'slurm') {
325 my $time_lim = `sinfo -h -p batch -o %l`;
326 my ($days, $hours, $remainder) = $time_lim =~ /([0]+)-([0-9]+):(.*)/;
327 my $newhours = $days * 24 + $hours;
328 my $new_time_lim = "$newhours:$remainder";
329 $time_limit = $new_time_lim lt $time_limit ? $new_time_lim : $time_limit;
330 $batch_script = "$filename_template.sh";
331 open(SLURM, ">$batch_script") or die("Can not create the SLURM batch script");
332 print SLURM "#!/bin/bash \n";
333 print SLURM "#SBATCH-p $queue \n";
334 print SLURM "#SBATCH-o $filename_template.lsfout.log \n";
335 print SLURM "#SBATCH-e $filename_template.lsferr.log \n";
336 print SLURM "#SBATCH-t $time_limit \n";
337 print SLURM "source $genie_setup \n";
338 print SLURM "cd $jobs_dir \n";
339 print SLURM "$evgen_cmd \n";
340 print SLURM "$conv_cmd \n";
341 if(-d $ref_sample_path) {
342 print SLURM "$comp_cmd \n";
345 `sbatch --job-name=$jobname $batch_script`;
348 # no batch system, run jobs interactively
349 if($batch_system eq 'none') {
350 system("source $genie_setup; cd $jobs_dir; $evgen_cmd; $conv_cmd");
351 if(-d $ref_sample_path){