3 #----------------------------------------------------------------------
4 # Submit jobs for calculating GENIE eA cross section splines to be used
5 # with GENIE's validation programs comparing GENIE against electron
9 # shell% perl submit_eA_xsec_calc_jobs.pl <options>
12 # --version : GENIE version number
13 # [--arch] : <SL4.x86_32, SL5.x86_64, SL6.x86_64, ...>, default: SL6.x86_64
14 # [--production] : default: <version>
15 # [--cycle] : default: 01
16 # [--use-valgrind] : default: off
17 # [--batch-system] : <PBS, LSF, slurm, none>, default: PBS
18 # [--queue] : default: prod
19 # [--softw-topdir] : top level dir for softw installations, default: /opt/ppd/t2k/softw/GENIE/
20 # [--jobs-topdir] : top level dir for job files, default: /opt/ppd/t2k/scratch/GENIE/
23 # Costas Andreopoulos <costas.andreopoulos \st stfc.ac.uk>
24 # University of Liverpool & STFC Rutherford Appleton Laboratory
27 # Copyright (c) 2003-2020, The GENIE Collaboration
28 # For the full text of the license visit http://copyright.genie-mc.org
29 #----------------------------------------------------------------------
37 if($_ eq '--version') { $genie_version = $ARGV[$iarg+1]; }
38 if($_ eq '--arch') { $arch = $ARGV[$iarg+1]; }
39 if($_ eq '--production') { $production = $ARGV[$iarg+1]; }
40 if($_ eq '--cycle') { $cycle = $ARGV[$iarg+1]; }
41 if($_ eq '--use-valgrind') { $use_valgrind = $ARGV[$iarg+1]; }
42 if($_ eq '--batch-system') { $batch_system = $ARGV[$iarg+1]; }
43 if($_ eq '--queue') { $queue = $ARGV[$iarg+1]; }
44 if($_ eq '--softw-topdir') { $softw_topdir = $ARGV[$iarg+1]; }
45 if($_ eq '--jobs-topdir') { $jobs_topdir = $ARGV[$iarg+1]; }
48 die("** Aborting [Undefined GENIE version. Use the --version option]")
49 unless defined $genie_version;
51 $use_valgrind = 0 unless defined $use_valgrind;
52 $arch = "SL6.x86_64" unless defined $arch;
53 $production = "$genie_version" unless defined $production;
54 $cycle = "01" unless defined $cycle;
55 $batch_system = "PBS" unless defined $batch_system;
56 $queue = "prod" unless defined $queue;
57 $softw_topdir = "/opt/ppd/t2k/softw/GENIE" unless defined $softw_topdir;
58 $jobs_topdir = "/opt/ppd/t2k/scratch/GENIE/" unless defined $jobs_topdir;
59 $genie_setup = "$softw_topdir/generator/builds/$arch/$genie_version-setup";
60 $jobs_dir = "$jobs_topdir/xsec\_eA-$production\_$cycle/";
61 $time_limit = "60:00:00";
70 'He3' => '1000020030',
71 'He4' => '1000020040',
72 'C12' => '1000060120',
73 'N14' => '1000070140',
74 'O16' => '1000080160',
75 'Ne20' => '1000100200',
76 'Al27' => '1000130270',
77 'Ca40' => '1000200400',
78 'Ca48' => '1000200480',
79 'Fe56' => '1000260560',
80 'Kr83' => '1000360830',
81 'Xe131' => '1000541310',
82 'Au197' => '1000791970',
83 'Pb208' => '1000822080',
84 'U238' => '1000922380' );
86 # make the jobs directory
88 mkpath ($jobs_dir, {verbose => 1, mode=>0777});
91 # loop over nuclear targets & submit jobs
93 while( my ($tgt_name, $tgt_code) = each %targets ) {
95 $fntemplate = "$jobs_dir/job_$tgt_name";
96 $grep_pipe = "grep -B 100 -A 30 -i \"warn\\|error\\|fatal\"";
97 $gmkspl_opt = "-p $probes -t $tgt_code -n $nkots -e $emax -o gxspl_emode_$tgt_name.xml --event-generator-list EM";
98 $gmkspl_cmd = "gmkspl $gmkspl_opt | $grep_pipe &> $fntemplate.mkspl.log";
99 print "@@ exec: $gmkspl_cmd \n";
102 if($batch_system eq 'PBS') {
103 $batch_script = "$fntemplate.pbs";
104 open(PBS, ">$batch_script") or die("Can not create the PBS batch script");
105 print PBS "#!/bin/bash \n";
106 print PBS "#PBS -N $tgt_name \n";
107 print PBS "#PBS -o $fntemplate.pbsout.log \n";
108 print PBS "#PBS -e $fntemplate.pbserr.log \n";
109 print PBS "source $genie_setup \n";
110 print PBS "cd $jobs_dir \n";
111 print PBS "$gmkspl_cmd \n";
113 `qsub -q $queue $batch_script`;
117 if($batch_system eq 'LSF') {
118 $batch_script = "$fntemplate.sh";
119 open(LSF, ">$batch_script") or die("Can not create the LSF batch script");
120 print LSF "#!/bin/bash \n";
121 print LSF "#BSUB-j $tgt_name \n";
122 print LSF "#BSUB-q $queue \n";
123 print LSF "#BSUB-o $fntemplate.lsfout.log \n";
124 print LSF "#BSUB-e $fntemplate.lsferr.log \n";
125 print LSF "source $genie_setup \n";
126 print LSF "cd $jobs_dir \n";
127 print LSF "$gmkspl_cmd \n";
129 `bsub < $batch_script`;
133 if($batch_system eq 'slurm') {
134 my $time_lim = `sinfo -h -p batch -o %l`;
135 my ($days, $hours, $remainder) = $time_lim =~ /([0]+)-([0-9]+):(.*)/;
136 my $newhours = $days * 24 + $hours;
137 my $new_time_lim = "$newhours:$remainder";
138 $time_limit = $new_time_lim lt $time_limit ? $new_time_lim : $time_limit;
139 $batch_script = "$fntemplate.sh";
140 open(SLURM, ">$batch_script") or die("Can not create the SLURM batch script");
141 print SLURM "#!/bin/bash \n";
142 print SLURM "#SBATCH-p $queue \n";
143 print SLURM "#SBATCH-o $fntemplate.lsfout.log \n";
144 print SLURM "#SBATCH-e $fntemplate.lsferr.log \n";
145 print SLURM "#SBATCH-t $time_limit \n";
146 print SLURM "source $genie_setup \n";
147 print SLURM "cd $jobs_dir \n";
148 print SLURM "$gmkspl_cmd \n";
150 `sbatch --job-name=$tgt_name $batch_script`;
153 # no batch system, run jobs interactively
154 if($batch_system eq 'none') {
155 system("source $genie_setup; cd $jobs_dir; $gmkspl_cmd");