3 from subprocess
import call
10 njobs = int(sys.argv[2])
11 nevents = int(sys.argv[3])
12 do_submition = bool(sys.argv[4])
14 sphenix_build_tag =
'new'
15 local_build_tag =
'install'
17 condor_base_path =
'/gpfs/mnt/gpfs04/sphenix/user/yuhw/workspace/TargetSim/TargetSim'
18 macros_path = condor_base_path
19 output_path = condor_base_path +
'/output/' +
'/{}/'.format(jobname)
20 condor_work_dir_base = condor_base_path +
'/work/' +
'/{}/'.format(jobname)
22 condor_local = condor_base_path +
'/temp/'
25 condor_local =
'${_CONDOR_SCRATCH_DIR}'
27 call([
"mkdir",
"-p",output_path])
33 for ijob
in range(0, njobs) :
38 condor_work_dir = condor_work_dir_base +
'/{}/'.format(ijob)
41 call([
"mkdir",
"-p",condor_work_dir])
45 runscript = condor_work_dir +
'/run.csh'
46 RUNSCRIPT = open(runscript,
'w')
47 RUNSCRIPT.write(
'#!/bin/tcsh -f\n')
48 RUNSCRIPT.write(
'#automagically generated by submit.py\n')
49 RUNSCRIPT.write(
'unsetenv OFFLINE_MAIN \n')
50 RUNSCRIPT.write(
'unsetenv ONLINE_MAIN\n')
51 RUNSCRIPT.write(
'unsetenv ROOTSYS\n')
52 RUNSCRIPT.write(
'unsetenv LD_LIBRARY_PATH\n')
53 RUNSCRIPT.write(
'source /opt/sphenix/core/bin/sphenix_setup.csh -n {} \n'.format(sphenix_build_tag))
54 RUNSCRIPT.write(
'setenv LD_LIBRARY_PATH $GITHUB_ROOT/HaiwangYu/{}/lib/:$LD_LIBRARY_PATH \n'.format(local_build_tag))
55 RUNSCRIPT.write(
'source /opt/phenix/bin/odbcini_setup.csh \n')
56 RUNSCRIPT.write(
'echo $OFFLINE_MAIN \n')
58 RUNSCRIPT.write(
'cp {}/*.C {} \n'.format(macros_path,condor_local))
59 RUNSCRIPT.write(
'cp {}/*.cfg {} \n'.format(macros_path,condor_local))
61 RUNSCRIPT.write(
'cd {} \n'.format(condor_local))
63 cmd =
'time root -l -b -q Fun4All_G4_BNL_R1.C\\({}\\)'.format(nevents)
64 RUNSCRIPT.write(cmd +
' | tee {}.out \n'.format(ijob))
66 cmd =
'time root -l -b -q ana.C\\(\\)'
67 RUNSCRIPT.write(cmd +
' | tee -a {}.out \n'.format(ijob))
69 RUNSCRIPT.write(
'cp DSTReader.root {}/dstr_{:06d}.root \n'.format(output_path,ijob))
70 RUNSCRIPT.write(
'cp eval.root {}/eval_{:06d}.root \n'.format(output_path,ijob))
71 RUNSCRIPT.write(
'cp hist.root {}/hist_{:06d}.root \n'.format(output_path,ijob))
72 RUNSCRIPT.write(
'cp *.out {} \n'.format(output_path))
76 call([
'chmod',
'0755',runscript])
78 condorfile = condor_work_dir +
'/condor.job'
79 logfile = condor_work_dir +
'/log.txt'
80 outfile = condor_work_dir +
'/out.txt'
81 errfile = condor_work_dir +
'/err.txt'
83 CONDORFILE = open(condorfile,
'w')
84 CONDORFILE.write(
'#automagically generated by submit.py\n')
85 CONDORFILE.write(
'Executable = ' + runscript +
'\n')
86 CONDORFILE.write(
'Universe = vanilla\n')
87 CONDORFILE.write(
'GetEnv = True\n')
88 CONDORFILE.write(
'Requirements = (CPU_Experiment == "phenix")\n')
89 CONDORFILE.write(
'+Experiment = \"phenix\"\n')
90 CONDORFILE.write(
'+Job_Type = \"cas\"\n')
92 CONDORFILE.write(
'Initialdir = ' + condor_work_dir +
'\n')
93 CONDORFILE.write(
'Output = ' + outfile +
'\n')
94 CONDORFILE.write(
'Error = ' + errfile +
'\n')
95 CONDORFILE.write(
'Log = ' + logfile +
'\n')
96 CONDORFILE.write(
'Notification = Never\n')
97 CONDORFILE.write(
'Queue \n')
101 call([
'/usr/bin/condor_submit',condorfile])