Skip to content
Snippets Groups Projects
Commit 9fbe70f4 authored by Peters, Wouter's avatar Peters, Wouter
Browse files

latest implementation of new TM5 run mode

parent d270e779
Branches
No related tags found
No related merge requests found
......@@ -50,6 +50,15 @@ class PlatForm(object):
return self.Version
def ReturnBlockingFlag(self):
return ""
def ReturnQueueType(self):
return "foreground"
def GetJobTemplate(self,joboptions={},block=False):
"""
Returns the job template for a given computing system, and fill it with options from the dictionary provided as argument.
......
......@@ -22,6 +22,14 @@ class MaunaloaPlatForm(PlatForm):
self.Identifier = 'WU maunaloa' # the identifier gives the platform name
self.Version = '1.0' # the platform version used
def ReturnBlockingFlag(self):
return ""
def ReturnQueueType(self):
return "foreground"
def GetJobTemplate(self,joboptions={},block=False):
"""
Returns the job template for a given computing system, and fill it with options from the dictionary provided as argument.
......
......@@ -135,6 +135,7 @@ class TM5ObservationOperator(ObservationOperator):
"""
import subprocess
from string import join
DaPlatForm = self.DaCycle.DaPlatForm
try:
os.chdir(self.DaCycle['da.obsoperator.home'])
......@@ -147,7 +148,7 @@ class TM5ObservationOperator(ObservationOperator):
os.chdir(tm5_dir)
cmd = ['python','setup_tm5','-q',self.RcFileName]
cmd = ['python','setup_tm5','--%s'%DaPlatForm.ReturnQueueType(),self.RcFileName]
msg = 'Starting the external TM5 setup script' ; logging.info(msg)
msg = 'using command ... %s'% join(cmd) ; logging.info(msg)
......@@ -180,6 +181,8 @@ class TM5ObservationOperator(ObservationOperator):
"""
from da.tools.general import CreateLinks
DaPlatForm = self.DaCycle.DaPlatForm
# First reload the original tm5.rc file to get unmodified settings
dummy = self.LoadRc(self.RcFileName) # load the specified rc-file
......@@ -189,6 +192,7 @@ class TM5ObservationOperator(ObservationOperator):
# Write a modified TM5 model rc-file in which run/break times are defined by our da system
NewItems = {
'submit.options' : DaPlatForm.ReturnBlockingFlag() ,
self.timestartkey : self.DaCycle['time.sample.start'] ,
self.timefinalkey : self.DaCycle['time.sample.end'] ,
'jobstep.timerange.start' : self.DaCycle['time.sample.start'] ,
......@@ -566,15 +570,16 @@ class TM5ObservationOperator(ObservationOperator):
""" Method handles the case where one TM5 model instance with N tracers does the sampling of all ensemble members"""
from string import join
import datetime
import subprocess
import os
DaPlatForm = self.DaCycle.DaPlatForm
targetdir = os.path.join(self.tm_settings[self.rundirkey])
tm5submitdir = os.path.join(self.tm_settings[self.rundirkey])
# Go to executable directory and start the subprocess, using a new logfile
dummy = os.chdir(targetdir)
msg = 'Changing directory to %s ' % targetdir ;logging.debug(msg)
dummy = os.chdir(tm5submitdir)
msg = 'Changing directory to %s ' % tm5submitdir ;logging.debug(msg)
# Remove the tm5.ok file from a previous run, placed back only if a successful TM5 run is executed
......@@ -592,25 +597,9 @@ class TM5ObservationOperator(ObservationOperator):
# An option would need to be added to force a re-compile of the TM5 code, for debugging purposes.
# file ID and names
jobid = 'tm5'
jobfile = os.path.join(targetdir,'jb.%s.jb'%jobid)
logfile = jobfile.replace('.jb','.log')
nthreads = int(self.DaCycle['da.obsoperator.threads'])
jobparams = {'jobname':'tm5',
'jobnodes':'ncomp %d'%int(nthreads),
'jobtime':'00:30:00',
'joblog':os.path.join(self.DaCycle['dir.jobs'])
}
template = DaPlatForm.GetJobTemplate(jobparams,block=True)
template += 'cd %s\n'%targetdir
template += '%s -np %d %s tm5.rc\n'%(self.tm_settings['mpirun.command'],int(nthreads),self.Tm5Executable,)
dummy = DaPlatForm.WriteJob(jobfile,template,jobid)
submitcommand = self.tm_settings['submit.command']
msg = 'Submitting job at %s'%datetime.datetime.now() ; logging.info(msg)
code = DaPlatForm.SubmitJob(jobfile,block=True)
code = subprocess.call(submitcommand.split())
msg = 'Resuming job at %s'%datetime.datetime.now() ; logging.info(msg)
if not os.path.exists(okfile):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment