#! /usr/bin/env python3 # ----------------------------------------------- # help # ----------------------------------------------- """ NAME submit_tm5_step_all DESCRIPTION Script to call init, run, and done in sequence. This is to roll up the preprocessing ("init"), run, and postprocessing ("done") into one single batch job, suitable for queue submission. We use this at NOAA for situations in which the queue wait time for three separate jobs in a given step becomes too great a fraction of the total step execution time. Using this feature will require "all" job definitions in places where you define variables for "init", etc. For us, this is in pycasso-queue-qsub-noaa-jet.rc. You also need to set job.steps to "all", without "init", "run", or "done". This, for us, is in pycasso-tm5-expert-noaa-jet.rc. REVISION HISTORY 26 Aug 2011, Andy Jacobson (NOAA): Code here was adapted from Arjo's submit_tm5_tools.py """ # ----------------------------------------------- # external # ----------------------------------------------- # standard modules: import sys import os import shutil import fnmatch import optparse import logging import datetime import subprocess # ----------------------------------------------- # logging # ----------------------------------------------- # setup messages: logging.basicConfig( format='%(lineno)-4s:%(filename)-30s [%(levelname)-8s] %(message)s', level=logging.INFO, stream=sys.stdout ) # ----------------------------------------------- # default values # ----------------------------------------------- # location of auxilary scripts: bindir_default = os.curdir # ----------------------------------------------- # arguments # ----------------------------------------------- # set text for 'usage' help line: usage = "%prog [--bindir=]" # initialise the option parser: parser = optparse.OptionParser(usage=usage) # define options: parser.add_option( "--bindir", help="location of auxilary scripts (%s)" % bindir_default, dest="bindir", action="store", default=bindir_default ) # now parse the actual arguments; # return an object 'opts' with fields 'verbose' etc, # and the unnamed arguments in the list 'args' : opts,args = parser.parse_args() # only one argument ... if len(args) != 1 : if opts.verbose : logging.error( 'single argument command should be specified, found : %i' % len(args) ) parser.print_usage() sys.exit(1) #endif # extract ... rcfile = args[0] # ----------------------------------------------- # toolboxes # ----------------------------------------------- # location of scripts: bindir = opts.bindir # prepend locations of python modules to search path: sys.path.insert( 0, bindir ) # local modules: import rc import go from submit_tm5_tools import Command_Line # ----------------------------------------------- # begin # ----------------------------------------------- # info ... logging.info( 'start' ) # read settings: rcf = rc.RcFile( rcfile ) for step in ('init','run','done') : # call to acutal script: if step == 'run' : # get command line: exe = os.path.join( os.curdir, rcf.get('job.step.%s.exe' % step) ) args = rcfile indb = rcf.get('submit.debugger','bool') cmndline = Command_Line( rcf, exe, args, indb ) #