Commit bc392c94 authored by karolina's avatar karolina
Browse files

removed checking for rc filetype, as it is always pycasso

parent 63b166f0
...@@ -63,26 +63,18 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -63,26 +63,18 @@ class TM5ObservationOperator(ObservationOperator):
""" """
def __init__(self, RcFileName, DaCycle=None): def __init__(self, filename):
""" The instance of an TMObservationOperator is application dependent """ """ The instance of an TMObservationOperator is application dependent """
self.Identifier = identifier # the identifier gives the model name self.Identifier = identifier # the identifier gives the model name
self.Version = version # the model version used self.Version = version # the model version used
self.RestartFileList = [] self.RestartFileList = []
self.OutputFileList = [] self.OutputFileList = []
self.RcFileType = 'None'
self.outputdir = None # Needed for opening the samples.nc files created self.outputdir = None # Needed for opening the samples.nc files created
self.load_rc(RcFileName) # load the specified rc-file self.load_rc(filename) # load the specified rc-file
self.validate_rc() # validate the contents self.validate_rc() # validate the contents
# The following code allows the object to be initialized with a DaCycle object already present. Otherwise, it can
# be added at a later moment.
if DaCycle != None:
self.DaCycle = DaCycle
else:
self.DaCycle = {}
logging.info('Observation Operator initialized: %s (%s)' % (self.Identifier, self.Version)) logging.info('Observation Operator initialized: %s (%s)' % (self.Identifier, self.Version))
def initialize(self, DaCycle): def initialize(self, DaCycle):
...@@ -101,7 +93,7 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -101,7 +93,7 @@ class TM5ObservationOperator(ObservationOperator):
# Create the TM5 run directory to hold a copy of the modified rc-file # Create the TM5 run directory to hold a copy of the modified rc-file
tm5compiledir = self.tm_settings[self.rundirkey] tm5compiledir = self.tm_settings['my.run.dir']
create_dirs(tm5compiledir) create_dirs(tm5compiledir)
rcfilename = os.path.join(tm5compiledir, 'tm5_setup_init.rc') rcfilename = os.path.join(tm5compiledir, 'tm5_setup_init.rc')
...@@ -125,7 +117,7 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -125,7 +117,7 @@ class TM5ObservationOperator(ObservationOperator):
logging.debug('Reloading the da.obsoperator.rc file for this DaCycle') logging.debug('Reloading the da.obsoperator.rc file for this DaCycle')
self.load_rc(self.DaCycle['da.obsoperator.rc']) #LU czy tutaj jest to kiedykolwiek zapisywane? chyba tak, jak zapisujemy daCycle... self.load_rc(self.DaCycle['da.obsoperator.rc'])
logging.debug('Note that the obsoperator is not recompiled if this is a recovery from a crash!!!') logging.debug('Note that the obsoperator is not recompiled if this is a recovery from a crash!!!')
...@@ -178,8 +170,8 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -178,8 +170,8 @@ class TM5ObservationOperator(ObservationOperator):
NewItems = { NewItems = {
'submit.options': DaPlatForm.give_blocking_flag(), 'submit.options': DaPlatForm.give_blocking_flag(),
self.timestartkey: self.DaCycle['time.sample.start'], 'timerange.start': self.DaCycle['time.sample.start'],
self.timefinalkey: self.DaCycle['time.sample.end'], 'timerange.end': self.DaCycle['time.sample.end'],
'jobstep.timerange.start': self.DaCycle['time.sample.start'], 'jobstep.timerange.start': self.DaCycle['time.sample.start'],
'jobstep.timerange.end': self.DaCycle['time.sample.end'], 'jobstep.timerange.end': self.DaCycle['time.sample.end'],
'jobstep.length': 'inf', 'jobstep.length': 'inf',
...@@ -190,10 +182,10 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -190,10 +182,10 @@ class TM5ObservationOperator(ObservationOperator):
} }
if self.DaCycle['time.restart']: # If this is a restart from a previous cycle, the TM5 model should do a restart if self.DaCycle['time.restart']: # If this is a restart from a previous cycle, the TM5 model should do a restart
NewItems[self.istartkey] = self.restartvalue NewItems['istart'] = self.restartvalue
logging.debug('Resetting TM5 to perform restart') logging.debug('Resetting TM5 to perform restart')
else: else:
NewItems[self.istartkey] = self.coldstartvalue # if not, start TM5 'cold' NewItems['istart'] = self.coldstartvalue # if not, start TM5 'cold'
logging.debug('Resetting TM5 to perform cold start') logging.debug('Resetting TM5 to perform cold start')
#LU to ponizej: po prostu jesli to jest inny lag niz pierwszy #LU to ponizej: po prostu jesli to jest inny lag niz pierwszy
#LU czyli: restart wtedy kiedy albo time.restart = true czyli w kazdym nastepnym cyklu, albo kiedy jest to nie pierwszy step w sample step. tylko wtedy to skad robimy restart sie rozni...czy nie , bo robimy po advance? #LU czyli: restart wtedy kiedy albo time.restart = true czyli w kazdym nastepnym cyklu, albo kiedy jest to nie pierwszy step w sample step. tylko wtedy to skad robimy restart sie rozni...czy nie , bo robimy po advance?
...@@ -201,7 +193,7 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -201,7 +193,7 @@ class TM5ObservationOperator(ObservationOperator):
#LU ale: nowy RC zapisywany jst przy koncu cyklu. czyli time. sample.window bedzie zawsze 0. #LU ale: nowy RC zapisywany jst przy koncu cyklu. czyli time. sample.window bedzie zawsze 0.
if self.DaCycle['time.sample.window'] != 0: # If this is a restart from a previous time step within the filter lag, the TM5 model should do a restart if self.DaCycle['time.sample.window'] != 0: # If this is a restart from a previous time step within the filter lag, the TM5 model should do a restart
NewItems[self.istartkey] = self.restartvalue NewItems['istart'] = self.restartvalue
logging.debug('Resetting TM5 to perform restart') logging.debug('Resetting TM5 to perform restart')
# If neither one is true, simply take the istart value from the tm5.rc file that was read # If neither one is true, simply take the istart value from the tm5.rc file that was read
...@@ -209,20 +201,16 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -209,20 +201,16 @@ class TM5ObservationOperator(ObservationOperator):
self.modify_rc(NewItems) self.modify_rc(NewItems)
self.write_rc(self.RcFileName) self.write_rc(self.RcFileName)
def load_rc(self, RcFileName):#LU tutaj bylo wczesniej rcfIletype. to znaczy ze pewnie zawsze bylo pycasso. bo wpp byloby blad. def load_rc(self, name):#LU tutaj bylo wczesniej rcfIletype. to znaczy ze pewnie zawsze bylo pycasso. bo wpp byloby blad.
""" """
This method loads a TM5 rc-file with settings for this simulation This method loads a TM5 rc-file with settings for this simulation
""" """
import da.tools.rcn as rc import da.tools.rcn as rc
self.rcfile = rc.RcFile(RcFileName) self.rcfile = rc.RcFile(name)
self.tm_settings = self.rcfile.values self.tm_settings = self.rcfile.values
self.RcFileName = RcFileName self.RcFileName = name
self.Tm5RcLoaded = True #LU to wyglada na zupelnie niepotrzebne
if 'my.source.dirs' in self.tm_settings.keys():
self.RcFileType = 'pycasso'
else:
self.RcFileType = 'pre-pycasso'
logging.debug('TM5 rc-file loaded successfully') logging.debug('TM5 rc-file loaded successfully')
def validate_rc(self): def validate_rc(self):
...@@ -230,40 +218,18 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -230,40 +218,18 @@ class TM5ObservationOperator(ObservationOperator):
Validate the contents of the tm_settings dictionary and add extra values. The required items for the TM5 rc-file Validate the contents of the tm_settings dictionary and add extra values. The required items for the TM5 rc-file
are specified in the tm5_tools module, as dictionary variable "needed_rc_items". are specified in the tm5_tools module, as dictionary variable "needed_rc_items".
""" """
self.restartvalue = 33
self.coldstartvalue = 9
if self.RcFileType == 'pycasso':
self.projectkey = 'my.project.dir'
self.rundirkey = 'my.run.dir'
self.outputdirkey = 'output.dir'
self.savedirkey = 'restart.write.dir'
self.timestartkey = 'timerange.start'
self.timefinalkey = 'timerange.end'
self.timelengthkey = 'jobstep.length'
self.istartkey = 'istart'
self.restartvalue = 33
self.coldstartvalue = 9
else:
self.projectkey = 'runid'
self.rundirkey = 'rundir'
self.outputdirkey = 'outputdir'
self.savedirkey = 'savedir'
self.timestartkey = 'time.start'
self.timefinalkey = 'time.final'
self.timelengthkey = 'time.break.nday'
self.istartkey = 'istart'
self.restartvalue = 3
self.coldstartvalue = 9
needed_rc_items = [ needed_rc_items = [
self.projectkey, 'my.project.dir',
self.rundirkey, 'my.run.dir',
self.outputdirkey, 'output.dir',
self.savedirkey, 'restart.write.dir',
self.timestartkey, 'timerange.start',
self.timefinalkey, 'timerange.end',
self.timelengthkey, 'jobstep.length',
self.istartkey 'istart'
] ]
for k, v in self.tm_settings.iteritems(): for k, v in self.tm_settings.iteritems():
...@@ -280,7 +246,6 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -280,7 +246,6 @@ class TM5ObservationOperator(ObservationOperator):
self.tm_settings[k] = to_datetime(v) self.tm_settings[k] = to_datetime(v)
for key in needed_rc_items: for key in needed_rc_items:
if not self.tm_settings.has_key(key): if not self.tm_settings.has_key(key):
msg = 'Missing a required value in rc-file : %s' % key msg = 'Missing a required value in rc-file : %s' % key
logging.error(msg) logging.error(msg)
...@@ -357,12 +322,10 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -357,12 +322,10 @@ class TM5ObservationOperator(ObservationOperator):
# Next, make sure there is an actual model version compiled and ready to execute # Next, make sure there is an actual model version compiled and ready to execute
targetdir = os.path.join(self.tm_settings[self.rundirkey]) targetdir = os.path.join(self.tm_settings['my.run.dir'])
if self.RcFileType == 'pycasso':
self.Tm5Executable = os.path.join(targetdir, self.tm_settings['my.basename'] + '.x') self.Tm5Executable = os.path.join(targetdir, self.tm_settings['my.basename'] + '.x')
else:
self.Tm5Executable = os.path.join(targetdir, 'tm5.x')
if not os.path.exists(self.Tm5Executable): if not os.path.exists(self.Tm5Executable):
logging.error("Required TM5 executable was not found %s" % self.Tm5Executable) logging.error("Required TM5 executable was not found %s" % self.Tm5Executable)
...@@ -386,8 +349,8 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -386,8 +349,8 @@ class TM5ObservationOperator(ObservationOperator):
# First get the restart data for TM5 from the current restart dir of the filter # First get the restart data for TM5 from the current restart dir of the filter
sourcedir = self.DaCycle['dir.restart'] sourcedir = self.DaCycle['dir.restart']
targetdir = self.tm_settings[self.savedirkey] targetdir = self.tm_settings['restart.write.dir']
self.outputdir = self.tm_settings[self.outputdirkey] #IV test self.outputdir = self.tm_settings['output.dir'] #IV test
for f in os.listdir(sourcedir): for f in os.listdir(sourcedir):
fpath = os.path.join(sourcedir, f) fpath = os.path.join(sourcedir, f)
...@@ -458,7 +421,7 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -458,7 +421,7 @@ class TM5ObservationOperator(ObservationOperator):
""" Method handles the case where a shell runs an MPI process that forks into N TM5 model instances """ """ Method handles the case where a shell runs an MPI process that forks into N TM5 model instances """
DaPlatForm = self.DaCycle.DaPlatForm DaPlatForm = self.DaCycle.DaPlatForm
targetdir = os.path.join(self.tm_settings[self.rundirkey]) targetdir = os.path.join(self.tm_settings['my.run.dir'])
if not os.path.exists(os.path.join(mpi_shell_location, mpi_shell_filename)): if not os.path.exists(os.path.join(mpi_shell_location, mpi_shell_filename)):
logging.error("Cannot find the mpi_shell wrapper needed for completion (%s) in (%s)" % (mpi_shell_filename, mpi_shell_location)) logging.error("Cannot find the mpi_shell wrapper needed for completion (%s) in (%s)" % (mpi_shell_filename, mpi_shell_location))
...@@ -513,7 +476,7 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -513,7 +476,7 @@ class TM5ObservationOperator(ObservationOperator):
""" Method handles the case where one TM5 model instance with N tracers does the sampling of all ensemble members""" """ Method handles the case where one TM5 model instance with N tracers does the sampling of all ensemble members"""
tm5submitdir = os.path.join(self.tm_settings[self.rundirkey]) tm5submitdir = os.path.join(self.tm_settings['my.run.dir'])
logging.info('tm5submitdir', tm5submitdir) logging.info('tm5submitdir', tm5submitdir)
# Go to executable directory and start the subprocess, using a new logfile # Go to executable directory and start the subprocess, using a new logfile
...@@ -558,8 +521,8 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -558,8 +521,8 @@ class TM5ObservationOperator(ObservationOperator):
Note 2: also adding the weekly mean flux output to the OutputFileList for later collection Note 2: also adding the weekly mean flux output to the OutputFileList for later collection
""" """
sourcedir = os.path.join(self.tm_settings[self.savedirkey]) sourcedir = os.path.join(self.tm_settings['restart.write.dir'])
filterlist = ['%s' % self.tm_settings[self.timefinalkey].strftime('%Y%m%d')] filterlist = ['%s' % self.tm_settings['timerange.end'].strftime('%Y%m%d')]
logging.debug("Creating a new list of TM5 restart data") logging.debug("Creating a new list of TM5 restart data")
logging.debug(" from directory: %s " % sourcedir) logging.debug(" from directory: %s " % sourcedir)
...@@ -591,7 +554,7 @@ class TM5ObservationOperator(ObservationOperator): ...@@ -591,7 +554,7 @@ class TM5ObservationOperator(ObservationOperator):
self.RestartFileList.append(fil) self.RestartFileList.append(fil)
logging.debug(" [added to restart list] .... %s " % fil) logging.debug(" [added to restart list] .... %s " % fil)
sourcedir = os.path.join(self.tm_settings[self.outputdirkey]) sourcedir = os.path.join(self.tm_settings['output.dir'])
sd_ed = self.DaCycle['time.sample.stamp'] sd_ed = self.DaCycle['time.sample.stamp']
filterlist = ['flask_output.%s' % sd_ed, 'flux1x1_%s' % sd_ed] filterlist = ['flask_output.%s' % sd_ed, 'flux1x1_%s' % sd_ed]
......
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