Commit 5727ebc9 authored by Peters, Wouter's avatar Peters, Wouter
Browse files

minor changes to make it work using the settings taken from the da.rc file

parent fb54246f
......@@ -243,6 +243,40 @@ class TM5():
os.chdir(cwd)
def SaveData(self):
""" Write the TM5 recovery data for the next cycle """
sourcedir = os.path.join(self.tm_settings['outputdir'])
targetdir = os.path.join(self.tm_settings['savedir'])
filter = ['save_%s'%self.tm_settings['time.final'].strftime('%Y%m%d')]
msg = "Performing a full backup of TM5 save data" ; logging.debug(msg)
msg = " from directory: %s " % sourcedir ; logging.debug(msg)
msg = " to directory: %s " % targetdir ; logging.debug(msg)
msg = " with filter: %s " % filter ; logging.debug(msg)
for file in os.listdir(sourcedir):
file = os.path.join(sourcedir,file)
if os.path.isdir(file): # skip dirs
skip = True
elif filter == []: # copy all
skip= False
else: # check filter
skip = True # default skip
for f in filter:
if f in file:
skip = False # unless in filter
break
if skip:
msg = " [skip] .... %s " % file ; logging.debug(msg)
continue
msg = " [copy] .... %s " % file ; logging.debug(msg)
dummy = shutil.copy(file,file.replace(sourcedir,targetdir) )
################### End Class TM5 ###################
......@@ -303,40 +337,6 @@ def PrepareExe(rc_da_shell):
return Tm5Model
def WriteSaveData(rc_da_shell):
""" Write the TM5 recovery data for the next DA cycle """
sourcedir = os.path.join(rc_da_shell['dir.output'])
targetdir = os.path.join(rc_da_shell['dir.save'])
filter = ['save_%s'%rc_da_shell['enddate'].strftime('%Y%m%d')]
msg = "Performing a full backup of TM5 save data" ; logging.debug(msg)
msg = " from directory: %s " % sourcedir ; logging.debug(msg)
msg = " to directory: %s " % targetdir ; logging.debug(msg)
msg = " with filter: %s " % filter ; logging.debug(msg)
for file in os.listdir(sourcedir):
file = os.path.join(sourcedir,file)
if os.path.isdir(file): # skip dirs
skip = True
elif filter == []: # copy all
skip= False
else: # check filter
skip = True # default skip
for f in filter:
if f in file:
skip = False # unless in filter
break
if skip:
msg = " [skip] .... %s " % file ; logging.debug(msg)
continue
msg = " [copy] .... %s " % file ; logging.debug(msg)
dummy = shutil.copy(file,file.replace(sourcedir,targetdir) )
if __name__ == "__main__":
......@@ -344,21 +344,24 @@ if __name__ == "__main__":
import sys
import logging
#tm=TM5('/Users/peters/Modeling/TM5/tutorial.rc')
#tm.WriteRc()
#tm.WriteRunRc()
#tm.Run()
tm=TM5('/Users/peters/Modeling/TM5/ct_new.rc')
tm.WriteRc()
tm.WriteRunRc()
tm.Run()
tm.SaveData()
sys.exit(0)
#sys.exit(0)
#dasrc=rc.read('da.rc')
dasrc=rc.read('da.rc')
#dasrc['dir.save']=os.path.join(dasrc['dir.da_run'],'save')
#dasrc['dir.output']=os.path.join(dasrc['dir.da_run'],'output')
#dasrc['dir.exec']=os.path.join(dasrc['dir.da_run'],'exec')
dasrc['dir.save']=os.path.join(dasrc['dir.da_run'],'save')
dasrc['dir.output']=os.path.join(dasrc['dir.da_run'],'output')
dasrc['dir.exec']=os.path.join(dasrc['dir.da_run'],'exec')
#tm = PrepareExe(dasrc)
#tm.Run()
#tm.SaveData()
tm = PrepareExe(dasrc)
tm.Run()
......
......@@ -323,11 +323,11 @@ def RunForecastModel(rc_da_shell):
# Prepare everything needed to run the forward model
rc_fcmodel = model.PrepareExe(rc_da_shell)
executable = model.PrepareExe(rc_da_shell)
# Run the forward model
status = model.StartExe(rc_da_shell,rc_fcmodel)
executable.Run()
########################################### RETURN CONTROL TO DA SHELL #########################################
......
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