submit_flux.py
Go to the documentation of this file.
1 ##################################################
2 ##
3 ## submit_flux.py
4 ##
5 ## Laura Fields
6 ## Aug 2012
7 ##
8 ## Submits g4lbne flux jobs using macro, input, number of
9 ## protons, number of jobs and output directory
10 ## specified by user
11 ##
12 ###################################################
13 
14 from optparse import OptionParser
15 import sys, os, subprocess, datetime
16 
17 ###################################################
18 ##
19 ## Helper Functions
20 ##
21 ###################################################
22 def remove_file(myfile):
23  print "REMOVING",myfile
24 # if myfile.startswith("/pnfs/"):
25  os.system("ifdh rm "+myfile)
26 
27 
28 
29 ###################################################
30 #
31 # Determine default g4lbne directory
32 # (the directory this script is in)
33 #
34 ###################################################
35 scriptdir = os.path.abspath(sys.argv[0]+"/../..")
36 print "default g4lbne directory:",scriptdir
37 
38 ###################################################
39 #
40 # Setup parser that reads in options
41 #
42 ###################################################
43 
44 usage = "usage: %prog [options]"
45 parser = OptionParser(usage=usage)
46 
47 parser.add_option("-g", "--g4lbne_dir", dest="g4lbne_dir",
48  help="g4lbne directory", default=scriptdir)
49 parser.add_option("-p", "--physics_list", dest="physics_list",
50  help="Geant4 Physics List", default="QGSP_BERT");
51 parser.add_option("-m", "--macro", dest="macro",
52  help="Template Macro", default="Nominal")
53 parser.add_option("-d", "--mode", dest="mode",
54  help="neutrino or antineutrino", default="neutrino")
55 parser.add_option("-n", "--n_events", dest="n_events",
56  help="Number of events per job", default=100000)
57 parser.add_option("-f", "--first_job", dest="first_job",
58  help="First job number", default="1")
59 parser.add_option("-l", "--last_job", dest="last_job",
60  help="Last job number", default="1")
61 parser.add_option("-o", "--output_dir", dest="output_dir",
62  help="Output directory", default="/pnfs/dune/scratch/users/$USER/fluxfiles/g4lbne")
63 parser.add_option("-a", "--macro_dir", dest="macro_dir",
64  help="Macro directory", default="macros")
65 parser.add_option("-v", "--interactive", dest="interactive",action="store_true",
66  help="Run interactively", default=False)
67 parser.add_option("-s","--osg",dest="osg",action="store_true",help="Option to run on OSG. Does not work yet", default=False)
68 parser.add_option("-t", "--notuples", dest="notuples",action="store_true",help="Don't write ntuple output",default=False)
69 parser.add_option("-e","--test",dest="xtest",action="store_true",help="Option for running a test job. Runs a little quicker",default=False)
70 parser.add_option("-P","--ppfx_options",dest="ppfx_options",action="store_true",
71  help="Create ppfx ntuples parallely with g4lbnf",default=False)
72 parser.add_option("-M","--MODE",dest="MODE",help="specify the setup mode for ppfx (REF or OPT)",default="NA")
73 
74 (options, args) = parser.parse_args()
75 
76 # Expand environment variables if necessary
77 if options.g4lbne_dir.find("$USER")>=0:
78  options.g4lbne_dir = options.g4lbne_dir.replace("$USER",os.getenv("USER"));
79 if options.output_dir.find("$USER")>=0:
80  options.output_dir = options.output_dir.replace("$USER",os.getenv("USER"));
81 
82 ###################################################
83 #
84 # Determine G4LBNE Version
85 #
86 ###################################################
87 version="v3r5p5"
88 
89 ###################################################
90 #
91 # Check validity of specified options
92 #
93 ###################################################
94 g4lbne_executable=options.g4lbne_dir+"/g4lbnf";
95 ppfx_dir = options.g4lbne_dir+"/ppfx/";
96 ppfx_executable = ppfx_dir+"bin/doReweight_dk2nu_dune"
97 if not os.path.exists(g4lbne_executable):
98  print "ERROR: I can't find a g4lbne executable at "+g4lbne_executable
99  sys.exit()
100 
101 ppfx_setup = options.g4lbne_dir+"/ppfx/setup_for_dune_cvmfs.sh "+options.MODE
102 ppfx_xml = options.g4lbne_dir+"/ppfx/scripts/inputs_default.xml"
103 if options.ppfx_options:
104  if not os.path.exists(ppfx_xml):
105  print "ERROR: I cannot find the ppfx option file at "+ppfx_xml
106  sys.exit()
107  if not os.path.exists(ppfx_setup):
108  print "ERROR: I cannot find ppfx setup script at "+ppfx_setup
109  sys.exit()
110 
111 if options.ppfx_options:
112  if not os.path.exists(options.g4lbne_dir+"/ppfx/setup_for_dune_cvmfs.sh"):
113  print "I can't find a ppfx setup at "+ppfx_setup
114  sys.exit()
115  mode=str(options.MODE)
116  print mode
117  if mode=="REF":
118  print "Reference mode for ppfx"
119  elif mode=="OPT":
120  print "Optimized mode for ppfx"
121  else:
122  print "Specify REF or OPT mode to execute ppfx setup script (option -M)"
123  sys.exit()
124 
125 
126 g4lbne_setup=options.g4lbne_dir+"/setups/setup_g4lbne_cvmfs.sh"
127 if not os.path.exists(g4lbne_setup):
128  print "ERROR: I can't find a g4lbne setup script at "+g4lbne_setup
129  sys.exit()
130 
131 macro_template = options.macro_dir+"/"+options.macro+".mac"
132 if options.macro.startswith("Optimizations"):
133  splitmacro = options.macro.split("-")
134  print splitmacro
135  macro_template = options.macro_dir+"/Optimizations/"+splitmacro[1]+"/"+splitmacro[1]+"_"+splitmacro[2]+".mac"
136 if not os.path.exists(macro_template):
137  print "ERROR: I can't find a macro at "+macro_template
138  sys.exit()
139 
140 histomaker_macro=options.g4lbne_dir+"/ProductionScripts/makeFluxHistogramsL";
141 if not os.path.exists(histomaker_macro):
142  print "ERROR: I can't find a histogram macro at "+histomaker_macro
143  sys.exit()
144 
145 physics_list = options.physics_list
146 print "Using GEANT4 physics list",physics_list
147 
148 ###################################################
149 #
150 # Print options
151 #
152 ###################################################
153 if options.interactive:
154  print "Running",str(int(options.last_job)-int(options.first_job)+1),"jobs starting with JobID",options.first_job,"."
155  print "Submitting",str(int(options.last_job)-int(options.first_job)+1),"jobs starting with JobID",options.first_job,"."
156 print "Using the g4lbne installed at",options.g4lbne_dir
157 print "Each job will have",options.n_events,"protons on target."
158 print "Using macro template:",macro_template
159 print "Output will be written to:",options.output_dir
160 if options.notuples:
161  print "Will only write histogram output -- no ntuples"
162 
163 ###################################################
164 #
165 # Create Directories
166 #
167 ###################################################
168 
169 output_macro_dir = "/pnfs/dune/scratch/users/"+os.getenv("USER")+"/fluxfiles/g4lbne/"+version+"/"+physics_list+"/"+options.macro+"/"+str(options.mode)+"/macros/"
170 output_wrapper_dir = "/pnfs/dune/scratch/users/"+os.getenv("USER")+"/fluxfiles/g4lbne/"+version+"/"+physics_list+"/"+options.macro+"/"+str(options.mode)+"/wrappers/"
171 output_executable_dir = "/pnfs/dune/scratch/users/"+os.getenv("USER")+"/fluxfiles/g4lbne/"+version+"/"+physics_list+"/"+options.macro+"/"+str(options.mode)+"/executables/"
172 flux_dir = options.output_dir+"/"+version+"/"+physics_list+"/"+options.macro+"/"+str(options.mode)+"/flux/"
173 log_dir = options.output_dir+"/"+version+"/"+physics_list+"/"+options.macro+"/"+str(options.mode)+"/logfiles/"
174 ppfx_flux_dir = options.output_dir+"/"+version+"/"+physics_list+"/"+options.macro+"/"+str(options.mode)+"/ppfx/"
175 ppfx_hadron_dir = ppfx_flux_dir+"hadron/flux/"
176 ppfx_hadron_log = ppfx_flux_dir+"hadron/logfiles/"
177 ppfx_imap_dir = ppfx_flux_dir+"imap/flux/"
178 ppfx_imap_log = ppfx_flux_dir+"imap/logfiles/"
179 print "Creating",output_macro_dir
180 if not os.path.exists(output_macro_dir):
181  os.makedirs(output_macro_dir)
182 print "Creating",output_wrapper_dir
183 if not os.path.exists(output_wrapper_dir):
184  os.makedirs(output_wrapper_dir)
185 print "Creating",output_executable_dir
186 if not os.path.exists(output_executable_dir):
187  os.makedirs(output_executable_dir)
188 print "Creating",flux_dir
189 if not os.path.exists(flux_dir):
190  os.makedirs(flux_dir)
191 if not os.path.exists(flux_dir+"/histos/"):
192  os.makedirs(flux_dir+"/histos/")
193 print "Creating",log_dir
194 if not os.path.exists(log_dir):
195  os.makedirs(log_dir)
196 if options.ppfx_options:
197  print "Creating",ppfx_hadron_dir
198  if not os.path.exists(ppfx_hadron_dir):
199  os.makedirs(ppfx_hadron_dir)
200  print "Creating",ppfx_hadron_log
201  if not os.path.exists(ppfx_hadron_log):
202  os.makedirs(ppfx_hadron_log)
203 ###########################################
204 #
205 #Uncomment the following lines if you want interaction map from ppfx
206 #
207 ############################################
208 """ print "Creating",ppfx_imap_dir
209  if not os.path.exists(ppfx_imap_dir):
210  os.makedirs(ppfx_imap_dir)
211  print "Creating",ppfx_imap_log
212  if not os.path.exists(ppfx_imap_log):
213  os.makedirs(ppfx_imap_log)
214 """
215 
216 if not os.path.exists(output_macro_dir):
217  print "ERROR: could not create macro directory: "+output_macro_dir
218  sys.exit()
219 
220 if not os.path.exists(output_wrapper_dir):
221  print "ERROR: could not create macro directory: "+output_wrapper_dir
222  sys.exit()
223 
224 if not os.path.exists(output_executable_dir):
225  print "ERROR: could not create executable directory: "+output_executable_dir
226  sys.exit()
227 
228 if not os.path.exists(flux_dir):
229  print "ERROR: could not create flux directory: "+flux_dir
230  sys.exit()
231 
232 if not os.path.exists(log_dir):
233  print "ERROR: could not create log directory: "+log_dir
234  sys.exit()
235 if options.ppfx_options:
236  if not os.path.exists(ppfx_hadron_dir):
237  print "ERROR: could not create macro directory: "+ppfx_hadron_dir
238  sys.exit()
239  if not os.path.exists(ppfx_hadron_log):
240  print "ERROR: could not create macro directory: "+ppfx_hadron_log
241  sys.exit()
242 
243 ###########################################
244 #
245 #Uncomment the following lines if you want interaction map from ppfx
246 #
247 ############################################
248 """ if not os.path.exists(ppfx_imap_flux):
249  print "ERROR: could not create flux directory: "+ppfx_imap_flux
250  sys.exit()
251 
252  if not os.path.exists(ppfx_imap_log):
253  print "ERROR: could not create log directory: "+ppfx_imap_log
254  sys.exit()"""
255 os.chmod(output_macro_dir,0777)
256 os.chmod(output_executable_dir,0777)
257 os.chmod(output_wrapper_dir,0777)
258 os.chmod(flux_dir,0777)
259 os.chmod(flux_dir+"/histos/",0777)
260 os.chmod(log_dir,0777)
261 
262 temp_dir = " "
263 if not options.interactive:
264  temp_dir = "$_CONDOR_SCRATCH_DIR/"
265 
266 ###################################################
267 #
268 # Make a tar file of the user's executable, setup area
269 #
270 ###################################################
271 cwd = os.getcwd()
272 os.chdir(options.g4lbne_dir)
273 if not options.ppfx_options:
274  os.system("tar -czf local_install.tar.gz ProductionScripts CMakeFiles shared_libraries g4lbnf build setups g4lbnfCint_rdict.pcm include locations")
275 else:
276  #and we assume that we also need ppfx..assumes that ppfx is installed in ppfx directory
277  os.system("tar -czf local_install.tar.gz ProductionScripts CMakeFiles shared_libraries g4lbnf build setups g4lbnfCint_rdict.pcm include locations ppfx" )
278 
279 executable_file = output_executable_dir+"g4lbne_"+version+"_"+physics_list+"_"+options.macro+"_"+str(options.mode)+".tar.gz"
280 if os.path.exists(executable_file):
281  os.remove(executable_file)
282 os.system("cp local_install.tar.gz "+executable_file)
283 os.remove("local_install.tar.gz")
284 
285 
286 ###################################################
287 #
288 # Loop over requested jobs
289 #
290 ###################################################
291 file_prefix = "g4lbne_"+version+"_"+physics_list+"_"+options.macro+"_"+str(options.mode)
292 for i in range(int(options.first_job),int(options.last_job)+1):
293 
294  if 1>0:
295  # Write macro file
296  oldmac = open(macro_template)
297  new_macro_filename = output_macro_dir+os.path.basename(macro_template).replace(".mac","_"+str(i).zfill(3)+".mac")
298 
299  if os.path.exists(new_macro_filename):
300  os.remove(new_macro_filename)
301 
302  newmac = open(new_macro_filename, 'w')
303  horn_current_set = False
304  for s in oldmac.xreadlines():
305  if s.find("/LBNE/output/OutputNtpFileName")>=0:
306  newmac.write("/LBNE/output/OutputNtpFileName "+temp_dir+file_prefix+"\n")
307  elif s.find("/LBNE/output/OutputDk2NuFileName")>=0:
308  newmac.write("/LBNE/output/OutputDk2NuFileName "+temp_dir+file_prefix+"\n")
309  elif s.find("/LBNE/rndm/setRndmSeed")>=0:
310  newmac.write("/LBNE/rndm/setRndmSeed "+str(i)+"\n")
311  elif s.find("/LBNE/run/setRunID")>=0:
312  newmac.write("/LBNE/run/setRunID "+str(i)+"\n")
313  elif s.find("/LBNE/run/NEvents")>=0:
314  newmac.write("/LBNE/run/NEvents "+str(options.n_events)+"\n")
315  elif s.find("/LBNE/det/seHornCurrent")>=0:
316  splitline = s.split()
317  if options.mode=="antineutrino" and not splitline[1].strip().startswith("-"):
318  newmac.write("/LBNE/det/seHornCurrent "+"-"+splitline[1]+" \n")
319  elif options.mode=="neutrino" and splitline[1].startswith("-"):
320  newmac.write("/LBNE/det/seHornCurrent "+splitline[1][1:]+" \n")
321  else:
322  newmac.write(s)
323  horn_current_set = True
324  else:
325  newmac.write(s);
326 
327  if not horn_current_set:
328  print "ERROR: The macro "+macro_template+" does set the horn current; please add a line such as /LBNE/det/seHornCurrent 200 kA to your macro template"
329  sys.exit()
330 
331  newmac.close()
332 
333 # Write the script that will run on the grid
334 if 1>0:
335 
336  script_filename = output_wrapper_dir+os.path.basename(macro_template).replace(".mac",".sh")
337 
338  if os.path.exists(script_filename):
339  os.remove(script_filename)
340 
341 
342 
343  wrapper = open(script_filename, 'w')
344  on_grid = "true";
345  if(options.interactive):
346  on_grid = "false";
347  wrapper.write("source "+g4lbne_setup+" \n\n")
348 
349  else:
350  local_g4lbne_setup = "setups/"+os.path.basename(g4lbne_setup)
351  local_ppfx_setup = "ppfx/"+os.path.basename(ppfx_setup)
352  local_tar_path = "$_CONDOR_SCRATCH_DIR/"+os.path.basename(executable_file)
353  wrapper.write("source /cvmfs/fermilab.opensciencegrid.org/products/common/etc/setups \n\n")
354 
355  wrapper.write("setup ifdhc \n\n")
356  wrapper.write("ifdh cp "+ executable_file+" "+local_tar_path+" \n\n")
357  wrapper.write("tar -xvzf "+ local_tar_path+" \n\n")
358 
359  wrapper.write("source "+local_g4lbne_setup+" \n\n")
360 
361  if options.xtest:
362  wrapper.write('os.environ["IFDH_GRIDFTP_EXTRA"]="-st 10" \n\n') # waits only 10 seconds
363  wrapper.write('os.environ["IFDH_CP_MAXRETRIES"]="2" \n\n')
364 
365 
366  offset = options.first_job
367  wrapper.write("export run_number=$(($PROCESS+"+offset+")) \n")
368  wrapper.write("export padded_run_number=`printf \"%03g\" $(($PROCESS+"+offset+"))` \n")
369  wrapper.write("export padded_run_number5=`printf \"%05g\" $(($PROCESS+"+offset+"))` \n")
370  wrapper.write("\nenv\n\n")
371  new_macro_filename = output_macro_dir+os.path.basename(macro_template).replace(".mac","_${padded_run_number}.mac")
372  print output_macro_dir
373  #sys.exit()
374  local_macro_path = os.path.basename(new_macro_filename)
375 
376  local_g4lbne_executable = "g4lbnf"
377  local_ppfx_executable = "ppfx/bin/doReweight_dk2nu_dune"
378  local_ppfx_xml = "ppfx/scripts/inputs_default.xml"
379 
380  local_histomaker_macro = "ProductionScripts/makeFluxHistogramsL";
381 
382  if options.interactive:
383  wrapper.write(g4lbne_executable+" --physicslist "+physics_list+" "+new_macro_filename+'\n\n')
384  if options.ppfx_options:
385  dk2nu_output = file_prefix+"_${padded_run_number5}.dk2nu.root";
386  ppfx_ndhisto_output = "histos_"+file_prefix+"_LBNFND_ppfx_${padded_run_number5}.root";
387  wrapper.write("source "+ppfx_setup+"\n\n")
388  wrapper.write("echo $PWD") #need to figure out where i am usually
389  wrapper.write(ppfx_executable+" "+flux_dir+dk2nu_output+" "+ppfx_hadron_dir+ppfx_ndhisto_output+" "+ppfx_xml+"\n\n")
390  else:
391  wrapper.write("ifdh cp "+ new_macro_filename+" "+local_macro_path+" \n\n")
392  wrapper.write("if [ -f "+local_macro_path+" ];\n")
393  wrapper.write("then\n")
394  wrapper.write(" "+local_g4lbne_executable+" --physicslist "+physics_list+" "+local_macro_path+'\n')
395  wrapper.write("else\n")
396  wrapper.write(' echo "'+local_macro_path+' does not exit. Exiting."\n')
397  wrapper.write(" exit 1 \n")
398  wrapper.write("fi \n\n")
399 
400 
401 
402 
403 
404  # copy the output
405  ntuple_output = file_prefix+"_${padded_run_number}.root";
406  dk2nu_output = file_prefix+"_${padded_run_number5}.dk2nu.root";
407  ndhisto_output = "histos_"+file_prefix+"_${run_number}_LBNEND.root";
408  fdhisto_output = "histos_"+file_prefix+"_${run_number}_LBNEFD.root";
409  ndfmchisto_output = "histos_"+file_prefix+"_${run_number}_LBNEND_fastmc.root";
410  fdfmchisto_output = "histos_"+file_prefix+"_${run_number}_LBNEFD_fastmc.root";
411  ndglobeshisto_output = "histos_"+file_prefix+"_${run_number}_LBNEND_globes_flux.txt";
412  fdglobeshisto_output = "histos_"+file_prefix+"_${run_number}_LBNEFD_globes_flux.txt";
413  ppfx_ndhisto_output = "histos_"+file_prefix+"_LBNFND_ppfx_${padded_run_number5}.root";
414  ppfx_fdhisto_output = "histos_"+file_prefix+"_LBNFFD_ppfx_${padded_run_number5}.root";
415 
416  if not options.notuples:
417  wrapper.write("if [ -f "+temp_dir+ntuple_output+" ];\n")
418  wrapper.write("then\n")
419  wrapper.write(" ifdh cp "+ temp_dir+ntuple_output+" "+flux_dir+ntuple_output+"\n")
420  wrapper.write("fi \n")
421 
422  wrapper.write("if [ -f "+temp_dir+dk2nu_output+" ];\n")
423  wrapper.write("then\n")
424  wrapper.write(" ifdh cp "+ temp_dir+dk2nu_output+" "+flux_dir+dk2nu_output+"\n")
425  wrapper.write("fi \n")
426 
427 
428 
429  # make histograms
430  wrapper.write(local_histomaker_macro+' --user='+os.getenv("USER")+' --version='+version+' --macro='+options.macro+' --current='+str(options.mode)+' --location=LBNEND --physics_list='+physics_list+' --n_files=1 --start_index=${run_number} --pot_per_file='+str(options.n_events)+' --on_grid='+on_grid+'\n')
431  wrapper.write(local_histomaker_macro+' --user='+os.getenv("USER")+' --version='+version+' --macro='+options.macro+' --current='+str(options.mode)+' --location=LBNEFD --physics_list='+physics_list+' --n_files=1 --start_index=${run_number} --pot_per_file='+str(options.n_events)+' --on_grid='+on_grid+'\n')
432  if options.ppfx_options:
433  wrapper.write("source "+local_ppfx_setup)
434  wrapper.write(" "+local_ppfx_executable+" "+temp_dir+dk2nu_output+" "+temp_dir+ppfx_ndhisto_output+" "+local_ppfx_xml+"\n")
435  wrapper.write(" "+local_ppfx_executable+" "+temp_dir+dk2nu_output+" "+temp_dir+ppfx_fdhisto_output+" "+local_ppfx_xml+"\n")
436 
437 
438 
439  wrapper.write("ls -lrt $_CONDOR_SCRATCH_DIR\n")
440 
441  outfiles = temp_dir+ndhisto_output+" "+temp_dir+fdhisto_output+" "+temp_dir+ndfmchisto_output+" "+temp_dir+fdfmchisto_output+" "+temp_dir+ndglobeshisto_output+" "+temp_dir+fdglobeshisto_output+" "
442 
443  wrapper.write("if [ -f "+temp_dir+ndhisto_output+" ];\n")
444  wrapper.write("then\n")
445  wrapper.write(" ifdh cp -D "+ temp_dir+ndhisto_output+" "+flux_dir+"/histos/"+"\n")
446  wrapper.write("fi \n")
447 
448  wrapper.write("if [ -f "+temp_dir+fdhisto_output+" ];\n")
449  wrapper.write("then\n")
450  wrapper.write(" ifdh cp -D "+ temp_dir+fdhisto_output+" "+flux_dir+"/histos/"+"\n")
451  wrapper.write("fi \n")
452 
453  wrapper.write("if [ -f "+temp_dir+ndfmchisto_output+" ];\n")
454  wrapper.write("then\n")
455  wrapper.write(" ifdh cp -D "+ temp_dir+ndfmchisto_output+" "+flux_dir+"/histos/"+"\n")
456  wrapper.write("fi \n")
457 
458  wrapper.write("if [ -f "+temp_dir+fdfmchisto_output+" ];\n")
459  wrapper.write("then\n")
460  wrapper.write(" ifdh cp -D "+ temp_dir+fdfmchisto_output+" "+flux_dir+"/histos/"+"\n")
461  wrapper.write("fi \n")
462 
463  wrapper.write("if [ -f "+temp_dir+ndglobeshisto_output+" ];\n")
464  wrapper.write("then\n")
465  wrapper.write(" ifdh cp -D "+ temp_dir+ndglobeshisto_output+" "+flux_dir+"/histos/"+"\n")
466  wrapper.write("fi \n")
467 
468  wrapper.write("if [ -f "+temp_dir+fdglobeshisto_output+" ];\n")
469  wrapper.write("then\n")
470  wrapper.write(" ifdh cp -D "+ temp_dir+fdglobeshisto_output+" "+flux_dir+"/histos/"+"\n")
471  wrapper.write("fi \n")
472  if options.ppfx_options:
473  wrapper.write("if [ -f "+temp_dir+ppfx_ndhisto_output+" ];\n")
474  wrapper.write("then\n")
475  wrapper.write(" ifdh cp -D "+ temp_dir+ppfx_ndhisto_output+" "+ppfx_hadron_dir+"\n")
476  wrapper.write("fi \n")
477  wrapper.write("if [ -f "+temp_dir+ppfx_fdhisto_output+" ];\n")
478  wrapper.write("then\n")
479  wrapper.write(" ifdh cp -D "+temp_dir+ppfx_fdhisto_output+" "+ppfx_hadron_dir+"\n")
480  wrapper.write("fi\n")
481 
482  #wrapper.write("ifdh cp -D "+outfiles+" "+flux_dir+"/histos/"+"\n")
483  wrapper.write("echo 'ALL DONE'\n")
484  wrapper.close();
485 
486  os.chmod(script_filename,0777);
487 
488  # remove old files to prevent permissions conflicts
489  logfile = log_dir + ntuple_output.split("/")[-1].replace(".root",".log").replace("_${padded_run_number}","_\$PROCESS");
490  if os.path.exists(logfile):
491  os.remove(logfile)
492  if os.path.exists(ntuple_output):
493  os.remove(ntuple_output);
494  if os.path.exists(dk2nu_output):
495  os.remove(dk2nu_output);
496  if os.path.exists(ndhisto_output):
497  os.remove(ndhisto_output);
498  if os.path.exists(fdhisto_output):
499  os.remove(fdhisto_output);
500  if os.path.exists(ndfmchisto_output):
501  os.remove(ndfmchisto_output);
502 
503  if os.path.exists(fdfmchisto_output):
504  os.remove(fdfmchisto_output);
505  if os.path.exists(ndglobeshisto_output):
506  os.remove(ndglobeshisto_output);
507  if os.path.exists(fdglobeshisto_output):
508  os.remove(fdglobeshisto_output);
509 
510 
511 
512  print "logfile",logfile
513  # Submit the job
514  if options.interactive:
515  print "type "+script_filename+" to execute"
516  elif options.osg:
517 # os.system("jobsub_submit.py -N "+str(int(options.last_job)-int(options.first_job)+1)+" --resource-provides=usage_model=OFFSITE --OS=SL6 --disk=9000MB --site=SU-OG --group=dune -L "+logfile+" file:///"+script_filename);
518  os.system("jobsub_submit.py -N "+str(int(options.last_job)-int(options.first_job)+1)+" --resource-provides=usage_model=OFFSITE --OS=SL6 --disk=9000MB --site=Nebraska,Wisconsin,FNAL,MWT2,Clemson,Cornell --expected-lifetime 4h --group=dune -L "+logfile+" file:///"+script_filename);
519 # os.system("jobsub_submit.py --resource-provides=usage_model=OFFSITE --OS=SL6 --disk=9000MB --site=Nebraska,Caltech,Wisconsin,MWT2 --group=dune -L "+logfile+" file:///"+script_filename);
520 # os.system("jobsub_submit.py --resource-provides=usage_model=OFFSITE --OS=SL6 --disk=9000MB --site=FNAL --group=dune -L "+logfile+" file:///"+script_filename);
521  else:
522  jobsub_command = "jobsub_submit.py -N "+str(int(options.last_job)-int(options.first_job)+1)+" --resource-provides=usage_model=OPPORTUNISTIC --expected-lifetime 4h --OS=SL6 --group=dune -L "+logfile+" file://"+script_filename;
523  if options.xtest:
524  jobsub_command = "jobsub_submit.py -N "+str(int(options.last_job)-int(options.first_job)+1)+" --resource-provides=usage_model=OPPORTUNISTIC --expected-lifetime 1h --memory 500MB --OS=SL6 --group=dune -L "+logfile+" file://"+script_filename;
525  print jobsub_command
526  os.system(jobsub_command)
527 
528 
529  print "DONE"
530 
531 
int open(const char *, int)
Opens a file descriptor.
def remove_file(myfile)
Helper Functions.
Definition: submit_flux.py:22
if(!yymsg) yymsg
static QCString str