submit_intranuke_validation_mc_jobs.pl
Go to the documentation of this file.
1 #!/usr/bin/perl
2 
3 #-----------------------------------------------------------------------------------------------------------
4 # Submit jobs to generate data needed for validating GENIE's hadron transport model
5 #
6 # Syntax:
7 # perl submit_intranuke_validation_mc_jobs.pl <options>
8 #
9 # Options:
10 # --version : GENIE version number
11 # --run : Runs to submit (Can be a run number, or a comma separated list of run numbers.)
12 # Use `--run all' to submit all jobs.
13 # Can also specify runs used for comparisons with data from a specific author using
14 # the author name, eg `--run iwamoto', or `--run iwamoto,ingram'.
15 # Can also specify runs by probe, eg `--run piplus', or `--run piplus,piminus,proton'.
16 # [--inuke-model] : Physics model, <hA, hN>, default: hA
17 # [--model-enum] : Physics model enumeration, default: 01
18 # [--nsubruns] : Number of subruns per run, default: 1
19 # [--arch] : <SL4.x86_32, SL5.x86_64, SL6.x86_64, ...>, default: SL6.x86_64
20 # [--production] : Production name, default: <model>_<version>
21 # [--cycle] : Cycle in current production, default: 01
22 # [--use-valgrind] : Use valgrind? default: off
23 # [--batch-system] : <PBS, LSF, slurm, HTCondor, HTCondor_PBS, none>, default: PBS
24 # [--queue] : Batch queue, default: prod
25 # [--softw-topdir] : top level dir for softw installations, default: /opt/ppd/t2k/softw/GENIE/
26 # [--jobs-topdir] : top level dir for job files, default: /opt/ppd/t2k/scratch/GENIE/
27 #
28 # EVENT SAMPLES:
29 #
30 # Run number key: PPTTTEEEEEMMxx
31 #
32 # PP : probe (10:pi+, 11:pi0, 12:pi-, 20:K+, 21:K0, 22:K-, 30:gamma, 40:p, 41:n)
33 # TTT : target (002: He4, 006:C12, 008:O16, 013:Al27, 020:Ca40, 026:Fe56: 028:Ni58, 029:Cu63, 082:Pb208, 083:Bi209)
34 # EEEEE : kinetic energy (MeV)
35 # MM : physics model enumeration, default: 01
36 # xx : sub-run ID, 00-99, 100k events each
37 #
38 #.......................................................................................
39 # run number | init state | kin energy | req. | group of |
40 # | | (GeV) | stat | runs |
41 # | | |(# evt)| runs |
42 #.......................................................................................
43 # 1002600870MMxx | pi+ + Fe56 | 0.870 | 0.5M | iwamoto |
44 # 1202600870MMxx | pi- + Fe56 | 0.870 | 1.0M | iwamoto |
45 # 1008200870MMxx | pi+ + Pb208 | 0.870 | 1.0M | iwamoto |
46 # 1002602100MMxx | pi+ + F56 | 2.100 | 1.0M | iwamoto |
47 # 1000601400MMxx | pi+ + C12 | 1.400 | 1.0M | shibata |
48 # 1002901400MMxx | pi+ + Cu63 | 1.400 | 1.0M | shibata |
49 # 1008201400MMxx | pi+ + Pb208 | 1.400 | 1.0M | shibata |
50 # 1000600220MMxx | pi+ + C12 | 0.220 | 1.0M | mckeown,levenson |
51 # 1002800220MMxx | pi+ + Ni58 | 0.220 | 1.0M | mckeown,levenson |
52 # 1008200220MMxx | pi+ + Pb208 | 0.220 | 1.0M | mckeown,levenson |
53 # 1000600160MMxx | pi+ + C12 | 0.160 | 1.0M | mckeown,levenson |
54 # 1002800160MMxx | pi+ + Ni58 | 0.160 | 1.0M | mckeown,levenson |
55 # 1008200160MMxx | pi+ + Pb208 | 0.160 | 1.0M | mckeown,levenson |
56 # 1000600100MMxx | pi+ + C12 | 0.100 | 1.0M | mckeown,levenson |
57 # 1002800100MMxx | pi+ + Ni58 | 0.100 | 1.0M | mckeown,levenson |
58 # 1008200100MMxx | pi+ + Pb208 | 0.100 | 1.0M | mckeown,levenson |
59 # 1200600220MMxx | pi- + C12 | 0.220 | 1.0M | mckeown |
60 # 1202800220MMxx | pi- + Ni58 | 0.220 | 1.0M | mckeown |
61 # 1208200220MMxx | pi- + Pb208 | 0.220 | 1.0M | mckeown |
62 # 1200600160MMxx | pi- + C12 | 0.160 | 1.0M | mckeown |
63 # 1202800160MMxx | pi- + Ni58 | 0.160 | 1.0M | mckeown |
64 # 1208200160MMxx | pi- + Pb208 | 0.160 | 1.0M | mckeown |
65 # 1200600100MMxx | pi- + C12 | 0.100 | 1.0M | mckeown |
66 # 1202800100MMxx | pi- + Ni58 | 0.100 | 1.0M | mckeown |
67 # 1208200100MMxx | pi- + Pb208 | 0.100 | 1.0M | mckeown |
68 # 1000600500MMxx | pi+ + C12 | 0.500 | 1.0M | zumbro |
69 # 1200600500MMxx | pi- + C12 | 0.500 | 1.0M | ouyang |
70 # 1208300500MMxx | pi- + Bi209 | 0.500 | 1.0M | ouyang |
71 # 1000600300MMxx | pi+ + C12 | 0.300 | 1.0M | levenson |
72 # 1000200300MMxx | pi+ + He4 | 0.300 | 1.0M | mckeown,levenson |
73 # 1000200220MMxx | pi+ + He4 | 0.220 | 1.0M | mckeown,levenson |
74 # 1000200160MMxx | pi+ + He4 | 0.160 | 1.0M | mckeown,levenson |
75 # 1000200100MMxx | pi+ + He4 | 0.100 | 1.0M | mckeown,levenson |
76 # 1000800114MMxx | pi+ + O16 | 0.114 | 1.0M | ingram |
77 # 1000800163MMxx | pi+ + O16 | 0.163 | 1.0M | ingram |
78 # 1000800240MMxx | pi+ + O16 | 0.240 | 1.0M | ingram |
79 # 4000600800MMxx | p + C12 | 0.800 | 1.0M | mcgill,amian |
80 # 4002901400MMxx | p + Cu63 | 1.400 | 1.0M | shibata |
81 # 4008201400MMxx | p + Pb208 | 1.400 | 1.0M | shibata |
82 # 4000601400MMxx | p + C12 | 1.400 | 1.0M | shibata |
83 # 4002000800MMxx | p + Ca40 | 0.800 | 1.0M | mcgill |
84 # 4002000800MMxx | p + Pb208 | 0.800 | 1.0M | mcgill |
85 # 4000600730MMxx | p + C12 | 0.730 | 3.0M | cochran |
86 # 4001300730MMxx | p + Al27 | 0.730 | 3.0M | cochran |
87 # 4002900730MMxx | p + Cu63 | 0.730 | 3.0M | cochran |
88 # 4008200730MMxx | p + Pb208 | 0.730 | 3.0M | cochran |
89 # 4000600800MMxx | p + C12 | 0.800 | 1.0M | amian |
90 # 4008200800MMxx | p + Pb208 | 0.800 | 1.0M | amian |
91 # 4000600597MMxx | p + C12 | 0.597 | 1.0M | amian |
92 # 4008200597MMxx | p + Pb208 | 0.597 | 1.0M | amian |
93 # 4002600558MMxx | p + Fe56 | 0.558 | 1.0M | beck |
94 # 4002600558MMxx | p + Pb208 | 0.558 | 1.0M | beck |
95 # 4000600300MMxx | p + C12 | 0.300 | 1.0M | kin |
96 # 4000600392MMxx | p + C12 | 0.392 | 1.0M | kin |
97 # 4002600065MMxx | p + Fe56 | 0.065 | 1.0M | bertrand |
98 # 4001300256MMxx | p + Al27 | 0.256 | 1.0M | stamer |
99 # 4008200256MMxx | p + Pb208 | 0.256 | 1.0M | stamer |
100 # 4000600200MMxx | p + C12 | 0.200 | 0.5M | carman |
101 # 4000600197MMxx | p + C12 | 0.197 | 0.5M | hautala |
102 # 4000600113MMxx | p + C12 | 0.113 | 0.5M | meier |
103 # 4002600113MMxx | p + Fe56 | 0.113 | 0.5M | meier |
104 # 4008200113MMxx | p + Pb208 | 0.113 | 0.5M | meier |
105 # 1008200220MMxx | pi+ + Pb208 | 0.220 | 1.0M | levenson |
106 #.......................................................................................
107 #
108 # OUTPUTS:
109 # - gntp.<inuke_mode>.<PPTTTEEEEEMMxx>.ghep.root GHEP event file
110 # - gntp.<inuke_mode>.<PPTTTEEEEEMMxx>.ginuke.root GINUKE summary/analysis ntuple
111 #
112 #
113 # Examples:
114 #
115 # (1) Submit (in an LSF farm) 10-subruns (100k events each) of run 4000600597, using GENIE v2.7.1:
116 # % perl submit_intranuke_validation_mc_jobs.pl --version v2.7.1 \
117 # --nsubruns 10 --batch-system LSF --run 4000600597
118 #
119 # (2) Submit (in an LSF farm) 10-subruns (100k events each) of runs 4000600597,1002600870 and 1000800240,
120 # using GENIE v2.7.1:
121 # % perl submit_intranuke_validation_mc_jobs.pl --version v2.7.1
122 # --nsubruns 10 --batch-system LSF --run 4000600597,1002600870,1000800240
123 #
124 # (3) Submit (in an LSF farm) 10-subruns (100k events each) of *all* runs, using GENIE v2.7.1:
125 # % perl submit_intranuke_validation_mc_jobs.pl --version v2.7.1 \
126 # --nsubruns 10 --batch-system LSF --run all
127 #
128 # (4) Submit (in an LSF farm) 10-subruns (100k events each) of all runs used for comparisons with the
129 # `iwamoto' data, using GENIE v2.7.1:
130 # % perl submit_intranuke_validation_mc_jobs.pl --version v2.7.1 \
131 # --nsubruns 10 --batch-system LSF --run iwamoto
132 #
133 # (5) Submit (in an LSF farm) 10-subruns (100k events each) of all runs with a pi+ or pi- probe,
134 # using GENIE v2.7.1:
135 # % perl submit_intranuke_validation_mc_jobs.pl --version v2.7.1 \
136 # --nsubruns 10 --batch-system LSF --run piplus,piminus
137 #
138 # Author:
139 # Costas Andreopoulos <costas.andreopoulos \st stfc.ac.uk>
140 # University of Liverpool & STFC Rutherford Appleton Laboratory
141 #
142 # Copyright:
143 # Copyright (c) 2003-2020, The GENIE Collaboration
144 # For the full text of the license visit http://copyright.genie-mc.org
145 #-----------------------------------------------------------------------------------------------------------
146 
147 use File::Path;
148 
149 # inputs
150 #
151 $iarg=0;
152 foreach (@ARGV) {
153  if($_ eq '--nsubruns') { $nsubruns = $ARGV[$iarg+1]; }
154  if($_ eq '--run') { $runnu = $ARGV[$iarg+1]; }
155  if($_ eq '--inuke-model') { $inuke_model = $ARGV[$iarg+1]; }
156  if($_ eq '--model-enum') { $model_enum = $ARGV[$iarg+1]; }
157  if($_ eq '--version') { $genie_version = $ARGV[$iarg+1]; }
158  if($_ eq '--arch') { $arch = $ARGV[$iarg+1]; }
159  if($_ eq '--production') { $production = $ARGV[$iarg+1]; }
160  if($_ eq '--cycle') { $cycle = $ARGV[$iarg+1]; }
161  if($_ eq '--use-valgrind') { $use_valgrind = $ARGV[$iarg+1]; }
162  if($_ eq '--batch-system') { $batch_system = $ARGV[$iarg+1]; }
163  if($_ eq '--queue') { $queue = $ARGV[$iarg+1]; }
164  if($_ eq '--softw-topdir') { $softw_topdir = $ARGV[$iarg+1]; }
165  if($_ eq '--jobs-topdir') { $jobs_topdir = $ARGV[$iarg+1]; }
166  $iarg++;
167 }
168 die("** Aborting [Undefined GENIE version. Use the --version option]")
169 unless defined $genie_version;
170 die("** Aborting [You need to specify which runs to submit. Use the --run option]")
171 unless defined $runnu;
172 
173 $inuke_model = "hA" unless defined $inuke_model;
174 $model_enum = "01" unless defined $model_enum;
175 $nsubruns = 1 unless defined $nsubruns;
176 $use_valgrind = 0 unless defined $use_valgrind;
177 $arch = "SL6.x86_64" unless defined $arch;
178 $production = "$model_enum\_$genie_version" unless defined $production;
179 $cycle = "01" unless defined $cycle;
180 $batch_system = "PBS" unless defined $batch_system;
181 $queue = "prod" unless defined $queue;
182 $softw_topdir = "/opt/ppd/t2k/softw/GENIE/" unless defined $softw_topdir;
183 $jobs_topdir = "/opt/ppd/t2k/scratch/GENIE/" unless defined $jobs_topdir;
184 $time_limit = "60:00:00";
185 $genie_setup = "$softw_topdir/generator/builds/$arch/$genie_version-setup";
186 $jobs_dir = "$jobs_topdir/vld\_inuke-$production\_$cycle";
187 $mcseed = 210921029;
188 $nev_per_subrun = 100000;
189 
190 # inputs for event generation jobs
191 %evg_probepdg_hash = (
192  '1002600870' => '211',
193  '1202600870' => '-211',
194  '1008200870' => '211',
195  '1002602100' => '211',
196  '1000601400' => '211',
197  '1002901400' => '211',
198  '1008201400' => '211',
199  '1000600220' => '211',
200  '1002800220' => '211',
201  '1008200220' => '211',
202  '1000600160' => '211',
203  '1002800160' => '211',
204  '1008200160' => '211',
205  '1000600100' => '211',
206  '1002800100' => '211',
207  '1008200100' => '211',
208  '1200600220' => '-211',
209  '1202800220' => '-211',
210  '1208200220' => '-211',
211  '1200600160' => '-211',
212  '1202800160' => '-211',
213  '1208200160' => '-211',
214  '1200600100' => '-211',
215  '1202800100' => '-211',
216  '1208200100' => '-211',
217  '1000600500' => '211',
218  '1200600500' => '211',
219  '1208300500' => '211',
220  '1000600300' => '211',
221  '1000200300' => '211',
222  '1000200220' => '211',
223  '1000200160' => '211',
224  '1000200100' => '211',
225  '1000800114' => '211',
226  '1000800163' => '211',
227  '1000800240' => '211',
228  '4000601400' => '211',
229  '4002901400' => '211',
230  '4008201400' => '211',
231  '4000600800' => '2212',
232  '4002000800' => '2212',
233  '4000600730' => '2212',
234  '4001300730' => '2212',
235  '4002900730' => '2212',
236  '4008200730' => '2212',
237  '4000600597' => '2212',
238  '4008200597' => '2212',
239  '4000600800' => '2212',
240  '4008200800' => '2212',
241  '4002600558' => '2212',
242  '4008200558' => '2212',
243  '4000600300' => '2212',
244  '4000600392' => '2212',
245  '4002600065' => '2212',
246  '4001300256' => '2212',
247  '4008200256' => '2212',
248  '4000600200' => '2212',
249  '4000600197' => '2212',
250  '4000600113' => '2212',
251  '4002600113' => '2212',
252  '4008200113' => '2212',
253 );
254 %evg_tgtpdg_hash = (
255  '1002600870' => '1000260560',
256  '1202600870' => '1000260560',
257  '1008200870' => '1000822080',
258  '1002602100' => '1000260560',
259  '1000601400' => '1000060120',
260  '1002901400' => '1000290630',
261  '1008201400' => '1000822080',
262  '1000600220' => '1000060120',
263  '1002800220' => '1000280580',
264  '1008200220' => '1000822080',
265  '1000600160' => '1000060120',
266  '1002800160' => '1000280580',
267  '1008200160' => '1000822080',
268  '1000600100' => '1000060120',
269  '1002800100' => '1000280580',
270  '1008200100' => '1000822080',
271  '1200600220' => '1000060120',
272  '1202800220' => '1000280580',
273  '1208200220' => '1000822080',
274  '1200600160' => '1000060120',
275  '1202800160' => '1000280580',
276  '1208200160' => '1000822080',
277  '1200600100' => '1000060120',
278  '1202800100' => '1000280580',
279  '1208200100' => '1000822080',
280  '1000600500' => '1000060120',
281  '1200600500' => '1000060120',
282  '1208300500' => '1000832090',
283  '1000600300' => '1000060120',
284  '1000200300' => '1000020040',
285  '1000200220' => '1000020040',
286  '1000200160' => '1000020040',
287  '1000200100' => '1000020040',
288  '1000800114' => '1000080160',
289  '1000800163' => '1000080160',
290  '1000800240' => '1000080160',
291  '4000601400' => '1000060120',
292  '4002901400' => '1000290630',
293  '4008201400' => '1000822080',
294  '4002000800' => '1000200400',
295  '4000600800' => '1000060120',
296  '4000600730' => '1000060120',
297  '4001300730' => '1000130270',
298  '4002900730' => '1000290630',
299  '4008200730' => '1000822080',
300  '4008200800' => '1000822080',
301  '4000600597' => '1000060120',
302  '4008200597' => '1000822080',
303  '4002600558' => '1000260560',
304  '4008200558' => '1000822080',
305  '4000600300' => '1000060120',
306  '4000600392' => '1000060120',
307  '4002600065' => '1000260560',
308  '4001300256' => '1000130270',
309  '4008200256' => '1000822080',
310  '4000600200' => '1000060120',
311  '4000600197' => '1000060120',
312  '4002600113' => '1000260560',
313  '4008200113' => '1000822080',
314 );
315 %evg_kinetic_energy_hash = (
316  '1002600870' => '0.870',
317  '1202600870' => '0.870',
318  '1008200870' => '0.870',
319  '1002602100' => '2.100',
320  '1000601400' => '1.400',
321  '1002901400' => '1.400',
322  '1008201400' => '1.400',
323  '1000600220' => '0.220',
324  '1002800220' => '0.220',
325  '1008200220' => '0.220',
326  '1000600160' => '0.160',
327  '1002800160' => '0.160',
328  '1008200160' => '0.160',
329  '1000600100' => '0.100',
330  '1002800100' => '0.100',
331  '1008200100' => '0.100',
332  '1202800220' => '0.220',
333  '1208200220' => '0.220',
334  '1200600160' => '0.160',
335  '1202800160' => '0.160',
336  '1208200160' => '0.160',
337  '1200600100' => '0.100',
338  '1202800100' => '0.100',
339  '1208200100' => '0.100',
340  '1000600500' => '0.500',
341  '1200600500' => '0.500',
342  '1208300500' => '0.500',
343  '1000600300' => '0.300',
344  '1000200300' => '0.300',
345  '1000200220' => '0.220',
346  '1000200160' => '0.160',
347  '1000200100' => '0.100',
348  '1000800114' => '0.114',
349  '1000800163' => '0.163',
350  '1000800240' => '0.240',
351  '4000601400' => '1.400',
352  '4002901400' => '1.400',
353  '4008201400' => '1.400',
354  '4000600800' => '0.800',
355  '4002000800' => '0.800',
356  '4000600730' => '0.730',
357  '4001300730' => '0.730',
358  '4002900730' => '0.730',
359  '4008200730' => '0.730',
360  '4008200800' => '0.800',
361  '4000600597' => '0.597',
362  '4008200597' => '0.597',
363  '4002600558' => '0.558',
364  '4008200558' => '0.558',
365  '4000600300' => '0.300',
366  '4000600392' => '0.392',
367  '4002600065' => '0.065',
368  '4001300256' => '0.256',
369  '4008200256' => '0.256',
370  '4000600800' => '0.200',
371  '4000600197' => '0.197',
372  '4000600113' => '0.113',
373  '4002600113' => '0.113',
374  '4008200113' => '0.113',
375 );
376 %vld_group_hash = (
377  '1002600870' => 'iwamoto',
378  '1202600870' => 'iwamoto',
379  '1008200870' => 'iwamoto',
380  '1002602100' => 'iwamoto',
381  '1000601400' => 'shibata',
382  '1002901400' => 'shibata',
383  '1008201400' => 'shibata',
384  '1000600220' => 'mckeown,levenson',
385  '1002800220' => 'mckeown,levenson',
386  '1008200220' => 'mckeown,levenson',
387  '1000600160' => 'mckeown,levenson',
388  '1002800160' => 'mckeown,levenson',
389  '1008200160' => 'mckeown,levenson',
390  '1000600100' => 'mckeown,levenson',
391  '1002800100' => 'mckeown,levenson',
392  '1008200100' => 'mckeown,levenson',
393  '1000600220' => 'mckeown',
394  '1002800220' => 'mckeown',
395  '1008200220' => 'mckeown',
396  '1000600160' => 'mckeown',
397  '1002800160' => 'mckeown',
398  '1008200160' => 'mckeown',
399  '1000600100' => 'mckeown',
400  '1002800100' => 'mckeown',
401  '1008200100' => 'mckeown',
402  '1000600500' => 'zumbro',
403  '1200600500' => 'ouyang',
404  '1200600500' => 'ouyang',
405  '1000600300' => 'levenson',
406  '1000200300' => 'mckeown,levenson',
407  '1000200220' => 'mckeown,levenson',
408  '1000200160' => 'mckeown,levenson',
409  '1000200100' => 'mckeown,levenson',
410  '1000800114' => 'ingram',
411  '1000800163' => 'ingram',
412  '1000800240' => 'ingram',
413  '4000601400' => 'shibata',
414  '4002901400' => 'shibata',
415  '4008201400' => 'shibata',
416  '4000600800' => 'mcgill,amian',
417  '4002000800' => 'mcgill',
418  '4000600730' => 'cochran',
419  '4001300730' => 'cochran',
420  '4002900730' => 'cochran',
421  '4008200730' => 'cochran',
422  '4008200800' => 'amian',
423  '4000600597' => 'amian',
424  '4008200597' => 'amian',
425  '4002600558' => 'beck',
426  '4008200558' => 'beck',
427  '4000600300' => 'kin',
428  '4000600392' => 'kin',
429  '4002600065' => 'bertrand',
430  '4001300256' => 'stamer',
431  '4008200256' => 'stamer',
432  '4000600200' => 'carman',
433  '4000600197' => 'hautala',
434  '4000600113' => 'meier',
435  '4002600113' => 'meier',
436  '4008200113' => 'meier',
437 );
438 
439 # make the jobs directory
440 #
441 mkpath ($jobs_dir, {verbose => 1, mode=>0777});
442 
443 #
444 # submit event generation jobs
445 #
446 
447 # run loop
448 for my $curr_runnu (keys %evg_probepdg_hash) {
449 
450  #
451  # get runnu-dependent info
452  #
453  $probe = $evg_probepdg_hash {$curr_runnu};
454  $tgt = $evg_tgtpdg_hash {$curr_runnu};
455  $ke = $evg_kinetic_energy_hash {$curr_runnu};
456  $vldgrp = $vld_group_hash {$curr_runnu};
457 
458  # check whether to commit current run
459  print "checking whether to submit run: $curr_runnu \n";
460 
461  $do_submit =
462  ( $runnu=~m/$curr_runnu/ ) ||
463  ( $runnu eq "all" ) ||
464  ( $vldgrp=~m/$runnu/ ) ||
465  ( $probe eq '22' && $runnu=~m/gamma/ ) ||
466  ( $probe eq '211' && $runnu=~m/piplus/ ) ||
467  ( $probe eq '-211' && $runnu=~m/piminus/ ) ||
468  ( $probe eq '111' && $runnu=~m/pi0/ ) ||
469  ( $probe eq '311' && $runnu=~m/Kplus/ ) ||
470  ( $probe eq '-311' && $runnu=~m/Kminus/ ) ||
471  ( $probe eq '2212' && $runnu=~m/proton/ ) ||
472  ( $probe eq '2112' && $runnu=~m/neutron/ );
473 
474  if($do_submit) {
475  print "** submitting event generation run: $curr_runnu \n";
476 
477  # submit subruns
478  for($isubrun = 0; $isubrun < $nsubruns; $isubrun++) {
479 
480  # Run number key: PPTTTEEEEEMMxx
481  $curr_subrunnu = 10000 * $curr_runnu + 100 * $model_enum + $isubrun;
482 # $grep_pipe = "grep -B 20 -A 30 -i \"warn\\|error\\|fatal\"";
483  $grep_pipe = "grep -B 20 -A 30 -i fatal";
484  $filename_template = "$jobs_dir/inuke-$inuke_model-$curr_subrunnu";
485  $curr_seed = $mcseed + $isubrun;
486  $valgrind_cmd = "valgrind --tool=memcheck --error-limit=no --leak-check=yes --show-reachable=yes";
487  $gntp_prefix = "gntp.$inuke_model";
488  $evgen_cmd = "gevgen_hadron -n $nev_per_subrun -m $inuke_model -k $ke -p $probe -t $tgt -r $curr_subrunnu --seed $curr_seed -o $gntp_prefix --message-thresholds Messenger_laconic.xml";
489  $conv_cmd = "gntpc -f ginuke -i $gntp_prefix.$curr_subrunnu.ghep.root --message-thresholds Messenger_laconic.xml";
490  $evgen_cmd = "$evgen_cmd | $grep_pipe &> $filename_template.evgen.log";
491  $conv_cmd = "$conv_cmd | $grep_pipe &> $filename_template.conv.log ";
492 
493  print "@@ exec: $evgen_cmd \n";
494  print "@@ exec: $conv_cmd \n\n";
495 
496  #
497  # submit
498  #
499 
500  # PBS case
501  if($batch_system eq 'PBS' || $batch_system eq 'HTCondor_PBS') {
502  $batch_script = "$filename_template.pbs";
503  open(PBS, ">$batch_script") or die("Can not create the PBS batch script");
504  print PBS "#!/bin/bash \n";
505  print PBS "#PBS -N inuke-$curr_subrunnu \n";
506  print PBS "#PBS -l cput=$time_limit \n";
507  print PBS "#PBS -o $filename_template.pbsout.log \n";
508  print PBS "#PBS -e $filename_template.pbserr.log \n";
509  print PBS "source $genie_setup \n";
510  print PBS "cd $jobs_dir \n";
511  print PBS "$evgen_cmd \n";
512  print PBS "$conv_cmd \n";
513  close(PBS);
514  $job_submission_command = "qsub";
515  if($batch_system eq 'HTCondor_PBS') {
516  $job_submission_command = "condor_qsub";
517  }
518  `$job_submission_command -q $queue $batch_script`;
519  } # PBS
520 
521  # LSF case
522  if($batch_system eq 'LSF') {
523  $batch_script = "$filename_template.sh";
524  open(LSF, ">$batch_script") or die("Can not create the LSF batch script");
525  print LSF "#!/bin/bash \n";
526  print LSF "#BSUB-j inuke-$curr_subrunnu \n";
527  print LSF "#BSUB-q $queue \n";
528  print LSF "#BSUB-c $time_limit \n";
529  print LSF "#BSUB-o $filename_template.lsfout.log \n";
530  print LSF "#BSUB-e $filename_template.lsferr.log \n";
531  print LSF "source $genie_setup \n";
532  print LSF "cd $jobs_dir \n";
533  print LSF "$evgen_cmd \n";
534  print LSF "$conv_cmd \n";
535  close(LSF);
536  `bsub < $batch_script`;
537  } # LSF
538 
539  # HTCondor
540  if($batch_system eq 'HTCondor') {
541  $batch_script = "$filename_template.htc";
542  open(HTC, ">$batch_script") or die("Can not create the Condor submit description file: $batch_script");
543  print HTC "Universe = vanilla \n";
544  print HTC "Executable = $softw_topdir/generator/builds/$arch/$genie_version/src/scripts/production/batch/htcondor_exec.sh \n";
545  print HTC "Arguments = $genie_setup $jobs_dir $evgen_cmd $conv_cmd\n";
546  print HTC "Log = $filename_template.log \n";
547  print HTC "Output = $filename_template.out \n";
548  print HTC "Error = $filename_template.err \n";
549  print HTC "Request_memory = 2 GB \n";
550  print HTC "Queue \n";
551  close(HTC);
552  `condor_submit $batch_script`;
553  } #HTCondor
554 
555  # slurm case
556  if($batch_system eq 'slurm') {
557  my $time_lim = `sinfo -h -p batch -o %l`;
558  my ($days, $hours, $remainder) = $time_lim =~ /([0]+)-([0-9]+):(.*)/;
559  my $newhours = $days * 24 + $hours;
560  my $new_time_lim = "$newhours:$remainder";
561  $time_limit = $new_time_lim lt $time_limit ? $new_time_lim : $time_limit;
562  $batch_script = "$filename_template.sh";
563  open(SLURM, ">$batch_script") or die("Can not create the SLURM batch script");
564  print SLURM "#!/bin/bash \n";
565  print SLURM "#SBATCH-p $queue \n";
566  print SLURM "#SBATCH-o $filename_template.lsfout.log \n";
567  print SLURM "#SBATCH-e $filename_template.lsferr.log \n";
568  print SLURM "#SBATCH-t $time_limit \n";
569  print SLURM "source $genie_setup \n";
570  print SLURM "cd $jobs_dir \n";
571  print SLURM "$evgen_cmd \n";
572  print SLURM "$conv_cmd \n";
573  close(SLURM);
574  `sbatch --job-name=inuke-$curr_subrunnu $batch_script`;
575  } # slurm
576 
577  # no batch system, run jobs interactively
578  if($batch_system eq 'none') {
579  system("source $genie_setup; cd $jobs_dir; $evgen_cmd; $conv_cmd");
580  } # interactive mode
581 
582  } # loop over subruns
583 
584  } #checking whether to submit current run
585 } # loop over runs
586