Skip to content

Commit

Permalink
Merge pull request #4615 from jedwards4b/feature/long_grid_name
Browse files Browse the repository at this point in the history
Feature/long grid name
  • Loading branch information
jedwards4b authored Apr 24, 2024
2 parents 05635e7 + 3edf752 commit 591f4e5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CIME/SystemTests/eri.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def _get_rest_date(archive_root):

def _helper(dout_sr, refdate, refsec, rundir):
rest_path = os.path.join(dout_sr, "rest", "{}-{}".format(refdate, refsec))

if not os.path.exists(rundir):
os.makedirs(rundir)
for item in glob.glob("{}/*{}*".format(rest_path, refdate)):
dst = os.path.join(rundir, os.path.basename(item))
if not os.path.exists(rundir):
Expand Down
45 changes: 30 additions & 15 deletions CIME/XML/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
# data.
GRID_SEP = ":"

# elements of a valid grid long name
grid_prefix = {
"atm": "a%",
"lnd": "l%",
"ocnice": "oi%",
"rof": "r%",
"wav": "w%",
"glc": "g%",
"mask": "m%",
"iac": "z%",
}


class Grids(GenericXML):
def __init__(self, infile=None, files=None, comp_interface=None):
Expand Down Expand Up @@ -77,7 +89,11 @@ def get_grid_info(self, name, compset, driver):
name = levmatch.group(1) + levmatch.group(2) + levmatch.group(4)

# determine component_grids dictionary and grid longname
lname = self._read_config_grids(name, compset, atmnlev, lndnlev)
if self._valid_lname(name):
lname = name
else:
lname = self._read_config_grids(name, compset, atmnlev, lndnlev)

gridinfo["GRID"] = lname
component_grids = _ComponentGrids(lname)

Expand All @@ -94,6 +110,17 @@ def get_grid_info(self, name, compset, driver):

return gridinfo

def _valid_lname(self, name):
"""
check if the grid long name is valid
"""
valid = True
for comp in self._comp_gridnames:
if not (grid_prefix[comp] in name):
valid = False
break
return valid

def _read_config_grids(self, name, compset, atmnlev, lndnlev):
"""
read config_grids.xml with version 2.0 schema
Expand Down Expand Up @@ -186,24 +213,12 @@ def _read_config_grids(self, name, compset, atmnlev, lndnlev):
else:
model_grid["mask"] = model_grid["ocnice"]

# determine component grids and associated required domains and gridmaps
# TODO: this should be in XML, not here
prefix = {
"atm": "a%",
"lnd": "l%",
"ocnice": "oi%",
"rof": "r%",
"wav": "w%",
"glc": "g%",
"mask": "m%",
"iac": "z%",
}
lname = ""
for component_gridname in self._comp_gridnames:
if lname:
lname = lname + "_" + prefix[component_gridname]
lname = lname + "_" + grid_prefix[component_gridname]
else:
lname = prefix[component_gridname]
lname = grid_prefix[component_gridname]
if model_grid[component_gridname] is not None:
lname += model_grid[component_gridname]
if component_gridname == "atm" and atmnlev is not None:
Expand Down

0 comments on commit 591f4e5

Please sign in to comment.