Skip to content

Commit

Permalink
cesm.runconfig no longer removes MED->XXX for non-prognostic componen…
Browse files Browse the repository at this point in the history
…ts - this will be done on the component end
  • Loading branch information
mvertens committed Jul 19, 2017
1 parent 74eb54b commit 655e675
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 48 deletions.
25 changes: 3 additions & 22 deletions scripts/lib/CIME/namelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,21 +1136,18 @@ def write(self, out_file, groups=None, append=False, format_='nml', sorted_group
with open(out_file, flag) as file_obj:
if format_ == 'nuopc':
self._write_nuopc(file_obj, groups, sorted_groups=sorted_groups,
skip_comps=skip_comps, prognostic_comps=prognostic_comps,
atm_cpl_dt=atm_cpl_dt, ocn_cpl_dt=ocn_cpl_dt)
skip_comps=skip_comps, atm_cpl_dt=atm_cpl_dt, ocn_cpl_dt=ocn_cpl_dt)
else:
self._write(file_obj, groups, format_, sorted_groups=sorted_groups)
else:
logger.debug("Writing namelist to file object")
if format_ == 'nuopc':
self._write_noupc(out_file, groups, sorted_groups=sorted_groups,
skip_comps=skip_comps, prognostic_comps=prognostic_comps,
atm_cpl_dt=atm_cpl_dt, ocn_cpl_dt=ocn_cpl_dt)
skip_comps=skip_comps, atm_cpl_dt=atm_cpl_dt, ocn_cpl_dt=ocn_cpl_dt)
else:
self._write(out_file, groups, format_, sorted_groups=sorted_groups)

def _write_nuopc(self, out_file, groups, sorted_groups, skip_comps, prognostic_comps,
atm_cpl_dt, ocn_cpl_dt):
def _write_nuopc(self, out_file, groups, sorted_groups, skip_comps, atm_cpl_dt, ocn_cpl_dt):
"""Unwrapped version of `write` assuming that a file object is input."""

if groups is None:
Expand Down Expand Up @@ -1225,22 +1222,6 @@ def _write_nuopc(self, out_file, groups, sorted_groups, skip_comps, prognostic_c
if skip_comp.lower().strip() in run_entry:
print_entry = False
logger.info("Writing nuopc_runseq, skipping {}".format(run_entry))
if print_entry:
med_to_comp_regex = re.compile(r"MED.*-\> *([A-Z]+)")
match = med_to_comp_regex.search(run_entry)
if match:
target_comp = match.group(1)
for prognostic_comp in prognostic_comps:
if not prognostic_comp in target_comp:
print_entry = False
logger.info("Writing nuopc_runseq, skipping {}".format(run_entry))
med_to_comp_regex = re.compile(r"MED.*prep.+")
match = med_to_comp_regex.search(run_entry)
if match:
for prognostic_comp in prognostic_comps:
if not prognostic_comp.lower().strip() in run_entry:
print_entry = False
logger.info("Writing nuopc_runseq, skipping {}".format(run_entry))
if print_entry:
if "@atm_cpl_dt" in run_entry:
run_entry = run_entry.replace("atm_cpl_dt",atm_cpl_dt)
Expand Down
5 changes: 2 additions & 3 deletions scripts/lib/CIME/nmlgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,11 @@ def write_modelio_file(self, filename):
self._namelist.write(filename, groups=["modelio", "pio_inparm"], format_="nml")

def write_nuopc_config_file(self, filename, data_list_path=None,
skip_comps=None, prognostic_comps=None, atm_cpl_dt=None, ocn_cpl_dt=None):
skip_comps=None, atm_cpl_dt=None, ocn_cpl_dt=None):
self._definition.validate(self._namelist)
groups = self._namelist.get_group_names()
self._namelist.write(filename, groups=groups, format_='nuopc', sorted_groups=False,
skip_comps=skip_comps, prognostic_comps=prognostic_comps,
atm_cpl_dt=atm_cpl_dt, ocn_cpl_dt=ocn_cpl_dt)
skip_comps=skip_comps, atm_cpl_dt=atm_cpl_dt, ocn_cpl_dt=ocn_cpl_dt)
if data_list_path is not None:
# append to input_data_list file
with open(data_list_path, "a") as input_data_list:
Expand Down
24 changes: 1 addition & 23 deletions src/drivers/nuopc/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
xcpl_types = [ 'x' + x for x in comp_types]
data_types = [ 'd' + x for x in comp_types]

prognostic_types = {"cam":"COMP_ATM", "clm":"COMP_LND", "cice":"COMP_ICE",
"pop":"COMP_OCN", "mom":"COMP_OCN", "rtm":"COMP_ROF",
"mosart":"COMP_ROF", "cism":"COMP_GLC", "ww":"COMP_WAV"}

# Determine components that are not present
skip_comps = []
for item in comp_types:
Expand All @@ -203,24 +199,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
if case.get_value(item.upper() + "_NX") == "0" and case.get_value(item.upper() + "_NY") == "0":
skip_comps.append(item.upper)

# Determine if prognostic components
prognostic_comps = []
for key,value in prognostic_types.iteritems():
if case.get_value(value) == key:
prognostic_comps.append(value)

# Determine prognostic data component configurations
if case.get_value("COMP_ICE") == "dice":
if case.get_value("DICE_MODE") != "null":
prognostic_comps.append("ICE")
if case.get_value("COMP_OCN") == "docn":
if case.get_value("DOCN_MODE") == "interannual":
prognostic_comps.append("OCN")
if case.get_value("DOCN_MODE") == "som" or case.get_value("DOCN_MODE") == "som_aquap":
prognostic_comps.append("OCN")

logger.info("Writing nuopc_runseq will skip components {}".format(skip_comps))
logger.info("Writing nuopc_runseq will only use prognostic components {}".format(prognostic_comps))

#TODO: how would the current data model namelist force_prognostic_true be used - and actually how is it unsed now?
#TODO: how are we going to handle ocnrof_prognostic setting?
Expand All @@ -229,8 +208,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
ocn_cpl_dt = nmlgen.get_value('ocn_cpl_dt')
nuopc_config_file = os.path.join(confdir, "cesm.runconfig")
nmlgen.write_nuopc_config_file(nuopc_config_file, data_list_path=data_list_path,
skip_comps=skip_comps, prognostic_comps=prognostic_comps,
atm_cpl_dt=atm_cpl_dt, ocn_cpl_dt=ocn_cpl_dt)
skip_comps=skip_comps, atm_cpl_dt=atm_cpl_dt, ocn_cpl_dt=ocn_cpl_dt)

#--------------------------------
# (4) Write drv_flds_in
Expand Down

0 comments on commit 655e675

Please sign in to comment.