Commit a0324966 authored by Peters, Wouter's avatar Peters, Wouter
Browse files

now using environment variable to decide on submission of next run

parent 54e93abc
......@@ -302,7 +302,6 @@ class CycleControl(dict):
strippedname = os.path.split(self['jobrcfilename'])[-1]
self['jobrcfilename'] = os.path.join(self['dir.exec'], strippedname)
self.read_random_seed(False)
self['da.resources.ncycle_in_job'] = self['da.resources.ncycles_per_job'] # force submission of next job after this
elif self['time.restart']:
logging.info("Restarting filter from previous step")
......@@ -310,15 +309,10 @@ class CycleControl(dict):
strippedname = os.path.split(self['jobrcfilename'])[-1]
self['jobrcfilename'] = os.path.join(self['dir.exec'], strippedname)
self.read_random_seed(False)
self['da.resources.ncycle_in_job'] = int(self['da.resources.ncycle_in_job'])+1
if int(self['da.resources.ncycle_in_job']) > int(self['da.resources.ncycles_per_job']):
self['da.resources.ncycle_in_job'] = 1 # reset counter if we just submitted this job
else: #assume that it is a fresh start, change this condition to more specific if crash recover added
logging.info("First time step in filter sequence")
self.setup_file_structure()
self['da.resources.ncycle_in_job'] = self['da.resources.ncycles_per_job'] # force submission of next job after this
# expand jobrcfilename to include exec dir from now on.
# First strip current leading path from filename
......@@ -533,20 +527,25 @@ class CycleControl(dict):
if '-t' in self.opts:
(self.opts).remove('-t')
ncycles = int(self['da.resources.ncycles_per_job'])
if not os.environ.has_key('icycle_in_job'):
logging.info('Environment variable icycle_in_job not found, resubmitting after this cycle')
os.environ['icycle_in_job'] = self['da.resources.ncycles_per_job'] # assume that if no cycle number is set, we should submit the next job by default
else:
logging.info('Environment variable icycle_in_job was found, processing cycle %s of %s in this job'%(os.environ['icycle_in_job'],self['da.resources.ncycles_per_job']) )
ncycles = int(self['da.resources.ncycles_per_job'])
for cycle in range(ncycles):
nextjobid = '%s'% ( (self['time.end']+cycle*self['cyclelength']).strftime('%Y%m%d'),)
nextrestartfilename = self['da.restart.fname'].replace(jobid,nextjobid)
nextlogfilename = logfile.replace(jobid,nextjobid)
template += 'python %s rc=%s %s >&%s\n' % (execcommand, nextrestartfilename, join(self.opts, ''), nextlogfilename)
template += '\nexport icycle_in_job=%d\npython %s rc=%s %s >&%s\n' % (cycle+1,execcommand, nextrestartfilename, join(self.opts, ''), nextlogfilename,)
# write and submit
self.daplatform.write_job(jobfile, template, jobid)
if 'da.resources.ncycles_per_job' in self:
do_submit = (int(self['da.resources.ncycle_in_job']) == int(self['da.resources.ncycles_per_job']))
do_submit = (int(os.environ['icycle_in_job']) >= int(self['da.resources.ncycles_per_job']))
else:
dosubmit = True
dosubmit = False
if do_submit:
jobid = self.daplatform.submit_job(jobfile, joblog=logfile)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment