Skip to content

Commit

Permalink
black and clarified tod reference
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaganKing committed Aug 21, 2024
1 parent 5f6d496 commit 0f5819f
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ def buildnml(case, caseroot, compname):
clm_phys = case.get_value("CLM_PHYSICS_VERSION")

config_cache_text = _config_cache_template.format(clm_phys=clm_phys)
config_cache_path = os.path.join(caseroot, "Buildconf", compname + "conf", "config_cache.xml")
config_cache_path = os.path.join(
caseroot, "Buildconf", compname + "conf", "config_cache.xml"
)
with open(config_cache_path, "w") as config_cache_file:
config_cache_file.write(config_cache_text)

Expand Down Expand Up @@ -291,13 +293,17 @@ def buildnml(case, caseroot, compname):
if (yr_start != None) and (yr_end != None):
nyr = yr_end - yr_start + 1
if (yr_end <= 0) or (yr_start <= 0):
logger.error("ERROR: Year start and end are both negative and should not be")
logger.error(
"ERROR: Year start and end are both negative and should not be"
)
clm_namelist_opts = "nyr_forcing={} {}".format(nyr, clm_namelist_opts)
else:
logger.warning(
"WARNING: It does not make sense to do a SASU spinup with a prognostic atmosphere model"
)
logger.warning(" as it expects regular atmosphere forcing that is cycled over")
logger.warning(
" as it expects regular atmosphere forcing that is cycled over"
)

infile = os.path.join(ctsmconf, "namelist")

Expand All @@ -311,7 +317,9 @@ def buildnml(case, caseroot, compname):
lndfrac_file = os.path.join(lnd_domain_path, lnd_domain_file)
lndfrac_setting = "-lnd_frac " + lndfrac_file

config_cache_file = os.path.join(caseroot, "Buildconf", compname + "conf", "config_cache.xml")
config_cache_file = os.path.join(
caseroot, "Buildconf", compname + "conf", "config_cache.xml"
)

# -----------------------------------------------------
# Clear out old data
Expand Down Expand Up @@ -351,21 +359,19 @@ def buildnml(case, caseroot, compname):
compnames = ["clm4", "clm5", "clm2"]
for comp in compnames:
if "PLUMBER2" in clm_usrdat_name:
clm_startfile = "%s.%s%s.r.%s-%s.nc" % (
run_refcase,
comp,
inst_string,
run_refdate,
start_tod,
)
# start_tod is supplied for PLUMBER cases
tod = start_tod
else:
clm_startfile = "%s.%s%s.r.%s-%s.nc" % (
run_refcase,
comp,
inst_string,
run_refdate,
run_reftod,
)
# run_reftod is supplied for other cases
tod = run_reftod

clm_startfile = "%s.%s%s.r.%s-%s.nc" % (
run_refcase,
comp,
inst_string,
run_refdate,
tod,
)
if os.path.exists(os.path.join(rundir, clm_startfile)):
break
else:
Expand All @@ -383,7 +389,9 @@ def buildnml(case, caseroot, compname):
break

if not os.path.exists(os.path.join(rundir, clm_startfile)):
logger.warning("WARNING: Could NOT find a start file named " + clm_startfile)
logger.warning(
"WARNING: Could NOT find a start file named " + clm_startfile
)
clm_icfile = "%s = '%s'" % (startfile_type, clm_startfile)
else:
clm_icfile = ""
Expand All @@ -394,7 +402,9 @@ def buildnml(case, caseroot, compname):
user_nl_file = os.path.join(caseroot, "user_nl_clm" + inst_string)
namelist_infile = os.path.join(ctsmconf, "namelist")

create_namelist_infile(case, user_nl_file, namelist_infile, "\n".join(infile_lines))
create_namelist_infile(
case, user_nl_file, namelist_infile, "\n".join(infile_lines)
)

cmd = os.path.join(lnd_root, "bld", "build-namelist")

Expand Down

0 comments on commit 0f5819f

Please sign in to comment.