Skip to content
Snippets Groups Projects
Commit a77fec9c authored by Ingrid Luijkx's avatar Ingrid Luijkx
Browse files

Added option to start with restart file in the first cycle, instead of initco2 file.

parent 0a421b90
No related branches found
No related tags found
No related merge requests found
......@@ -132,6 +132,16 @@ class TM5ObservationOperator(ObservationOperator):
newrcfilename = os.path.join(self.tm_settings['rundir'], self.tm_settings['install.rc'])
#Use a TM5 restart file in the first cycle (instead of init file). Used now for the CO project.
if self.dacycle.has_key('da.obsoperator.restartfileinfirstcycle'):
restartfilename = self.dacycle['da.obsoperator.restartfileinfirstcycle']
sourcedir = self.dacycle['dir.exec']
targetdir = self.tm_settings[self.savedirkey]
create_dirs(targetdir)
sourcefile = os.path.join(sourcedir,restartfilename)
shutil.copy(sourcefile, sourcefile.replace(sourcedir, targetdir))
logging.debug('Copied TM5 restart file to TM5 restart directory for first cycle: %s'%sourcefile)
# Replace the rc filename for TM5 with the newly created one in the new run directory
......@@ -214,8 +224,12 @@ class TM5ObservationOperator(ObservationOperator):
new_items[self.istartkey] = self.restartvalue
logging.debug('Resetting TM5 to perform restart')
else:
new_items[self.istartkey] = self.coldstartvalue # if not, start TM5 'cold'
logging.debug('Resetting TM5 to perform cold start')
if not self.dacycle.has_key('da.obsoperator.restartfileinfirstcycle'):
new_items[self.istartkey] = self.coldstartvalue # if not, start TM5 'cold'
logging.debug('Resetting TM5 to perform cold start')
else:
new_items[self.istartkey] = self.restartvalue # If restart file is specified, start TM5 with initial restartfile
logging.debug('Resetting TM5 to start with restart file: %s'%self.dacycle['da.obsoperator.restartfileinfirstcycle'])
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
new_items[self.istartkey] = self.restartvalue
......@@ -361,8 +375,8 @@ class TM5ObservationOperator(ObservationOperator):
if not os.path.exists(obsfile):
msg = "The specified obs input file for the TM5 model to read from does not exist (%s), exiting..." % obsfile
logging.error(msg)
raise IOError, msg
if not self.dacycle.has_key('forward.savestate.dir'):
raise IOError, msg
for n in range(int(self.dacycle['da.optimizer.nmembers'])):
paramfile = 'parameters.%03d.nc' % n
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment