6 import os, optparse, random, shutil, tarfile, sys
7 import subprocess, string
9 CACHE_PNFS_AREA =
"/pnfs/nova/scratch/users/{USER}/grid_cache/".
format(USER = os.getenv(
"USER"))
10 PWD = os.getenv(
"PWD")
16 OUTDIR =
"/pnfs/nova/persistent/users/{USER}/ppfx/test/".
format(USER = os.getenv(
"USER"))
18 INPUT_OPTIONS =
"scripts/inputs_default.xml" 20 INDIR =
"/pnfs/nova/data/flux/g4numi/v6r1" 21 TARFILE_NAME =
"local_install.tar.gz" 22 BEAMCONFIG =
"me000z200i" 29 cache_folder = CACHE_PNFS_AREA +
str(random.randint(10000,99999)) +
"/" 30 os.makedirs(cache_folder)
32 os.makedirs(options.outdir)
34 print "\nTarring up local area..." 37 shutil.move(TARFILE_NAME, cache_folder)
38 shutil.copy(
"ppfx_job.sh", cache_folder)
40 print "\nTarball of local area:", cache_folder + TARFILE_NAME
42 logfile = options.outdir +
"/ppfx_{BEAMCONFIG}_\$PROCESS.log".
format(BEAMCONFIG = options.beamconfig)
44 print "\nOutput logfile(s):",logfile
46 submit_command = (
"jobsub_submit {GRID} {MEMORY} -N {NJOBS} -dPPFX {OUTDIR} " 48 "-e BEAMCONFIG={BEAMCONFIG} " 50 "-e INPUT_OPTIONS={INPUT_OPTIONS} " 54 "file://{CACHE}/ppfx_job.sh".
format(
55 GRID = (
"--OS=SL6 -g " 56 "--resource-provides=usage_model=DEDICATED,OPPORTUNISTIC " 58 MEMORY =
"--memory 200MB ",
59 NJOBS = options.n_jobs,
60 OUTDIR = options.outdir,
61 BEAMCONFIG = options.beamconfig,
63 INPUT_OPTIONS = options.input_options,
65 TARFILE = cache_folder + TARFILE_NAME,
71 print "\nSubmitting to grid:\n"+submit_command+
"\n" 72 status = subprocess.call(submit_command, shell=
True)
75 parser = optparse.OptionParser(usage=
"usage: %prog [options]")
76 grid_group = optparse.OptionGroup(parser,
"Grid Options")
78 grid_group.add_option(
"--outdir",
80 help =
"Output flux histograms location. Default = %default.")
82 grid_group.add_option(
"--n_jobs",
84 help =
"Number of g4numi jobs. Default = %default.")
86 beam_group = optparse.OptionGroup(parser,
"Beam Options")
88 beam_group.add_option(
'--beamconfig', default = BEAMCONFIG,
89 help=
"Select the neutrino beam: me000z200i, me000z-200i me000z000i.Default = %default.")
91 run_group = optparse.OptionGroup(parser,
"Run Options")
93 run_group.add_option(
"--input_options",
94 default = INPUT_OPTIONS,
95 help =
"PPFX input: number of universes, MIPP on/off, etc. Default = %default.")
97 run_group.add_option(
"--idet",
99 help =
"Index of the detector to be used (see at location.name in dkmetaTree->Show(0)). Default = %default.")
101 parser.add_option_group(grid_group)
102 parser.add_option_group(beam_group)
103 parser.add_option_group(run_group)
105 options, remainder = parser.parse_args()
110 tar = tarfile.open(output_filename,
"w:gz")
111 for i
in os.listdir(source_dir):
115 if __name__ ==
"__main__":
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
def make_tarfile(output_filename, source_dir)