Skip to content
Snippets Groups Projects
Commit d9f52d13 authored by lkugler's avatar lkugler
Browse files

prints

parent a13e8801
No related branches found
No related tags found
No related merge requests found
......@@ -12,9 +12,6 @@ import importlib
from dartwrf.utils import script_to_str
from config.cfg import exp
def dict_to_py(d, outfile):
with open(outfile, 'w') as f:
txt = '# this file is autogenerated \nobs_kind_nrs = {'
......@@ -23,30 +20,7 @@ def dict_to_py(d, outfile):
txt += '}'
f.write(txt)
class WorkFlows(object):
def __init__(self, exp_config='cfg.py', server_config='server.py'):
"""Set up the experiment folder in `archivedir`.
Args:
exp (str): Path to exp config file
config (str): Path to the cluster config file
"""
# in WorkFlows, we load the config from the git cloned folder
# in all other dartwrf scripts, load the config from cluster.scripts_rundir
# exp = __import__('config/'+exp_config)
self.cluster = importlib.import_module('config.'+server_config.strip('.py')).cluster
# Set paths and backup scripts
self.cluster.log_dir = self.cluster.archivedir+'/logs/'
print('logging to', self.cluster.log_dir)
if self.cluster.use_slurm:
self.cluster.slurm_scripts_dir = self.cluster.archivedir+'/slurm-scripts/'
print('scripts, which are submitted to SLURM:', self.cluster.slurm_scripts_dir)
# copy obs kind def to config, we will read a table from there
# file needs to exist within package so sphinx can read it
def obskind_read():
def _obskind_read():
"""Read dictionary of observation types + ID numbers ("kind")
from DART f90 script
"""
......@@ -73,7 +47,34 @@ class WorkFlows(object):
obskind_nrs[kind_str] = kind_nr
return obskind_nrs
dict_to_py(obskind_read(), self.cluster.scriptsdir+'/../config/obskind.py')
class WorkFlows(object):
def __init__(self, exp_config='cfg.py', server_config='server.py'):
"""Set up the experiment folder in `archivedir`.
Args:
exp (str): Path to exp config file
config (str): Path to the cluster config file
Note:
in WorkFlows, we load the config from the git cloned folder
in all other dartwrf scripts, load the config from cluster.scripts_rundir
"""
print('------ start exp from ', exp_config, ' and ', server_config, ' ------')
# exp = __import__('config/'+exp_config)
# load python config file
self.cluster = importlib.import_module('config.'+server_config.strip('.py')).cluster
# Set paths and backup scripts
self.cluster.log_dir = self.cluster.archivedir+'/logs/'
print('logging to', self.cluster.log_dir)
if self.cluster.use_slurm:
self.cluster.slurm_scripts_dir = self.cluster.archivedir+'/slurm-scripts/'
print('SLURM scripts will be in', self.cluster.slurm_scripts_dir)
# copy obs kind def to config, we will read a table from there
# file needs to exist within package so sphinx can read it
dict_to_py(_obskind_read(), self.cluster.scriptsdir+'/../config/obskind.py')
# Copy scripts to self.cluster.archivedir folder
os.makedirs(self.cluster.archivedir, exist_ok=True)
......@@ -93,6 +94,8 @@ class WorkFlows(object):
# probably not needed
# shutil.copy('config/'+server_config, 'config/cluster.py') # whatever server, the config name is always the same!
print('------ dartwrf experiment initialized ------')
print('--------------------------------------------')
def prepare_WRFrundir(self, init_time):
"""Create WRF/run directories and wrfinput files
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment