Skip to content

Commit

Permalink
fixed problems with order dependence of compset attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariana Vertenstein committed Jul 10, 2016
1 parent ad26223 commit d55ba8f
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 23 deletions.
12 changes: 6 additions & 6 deletions driver_cpl/driver/seq_diag_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ subroutine seq_diag_ocn_mct( ocn, xao_o, frac_o, do_o2x, do_x2o, do_xao)
real(r8) :: da,di,do,dl ! area of a grid cell
logical,save :: first_time = .true.
logical,save :: flds_wiso_ocn = .false.
logical,save :: model ! valid values are 'acme' or 'cesm'
character(len=4), save :: model ! valid values are 'acme' or 'cesm'

!----- formats -----
character(*),parameter :: subName = '(seq_diag_ocn_mct) '
Expand Down Expand Up @@ -1528,7 +1528,7 @@ subroutine seq_diag_ice_mct( ice, frac_i, do_i2x, do_x2i)
logical,save :: first_time = .true.
logical,save :: flds_wiso_ice = .false.
logical,save :: flds_wiso_ice_x2i = .false.
logical,save :: model ! valid values are 'acme' or 'cesm'
character(len=4),save :: model ! valid values are 'acme' or 'cesm'

!----- formats -----
character(*),parameter :: subName = '(seq_diag_ice_mct) '
Expand Down Expand Up @@ -1621,11 +1621,11 @@ subroutine seq_diag_ice_mct( ice, frac_i, do_i2x, do_x2i)
index_x2i_Faxa_lwdn = mct_aVect_indexRA(x2i_i,'Faxa_lwdn')
index_x2i_Faxa_rain = mct_aVect_indexRA(x2i_i,'Faxa_rain')
index_x2i_Faxa_snow = mct_aVect_indexRA(x2i_i,'Faxa_snow')
index_x2i_Fioo_frazil = mct_aVect_indexRA(x2i_i,'Fioo_frazil')
index_o2x_Fioo_q = mct_aVect_indexRA(o2x_o,'Fioo_q') !cesm
if (index_o2x_Fioo_frazil /= 0) then
index_x2i_Fioo_frazil = mct_aVect_indexRA(x2i_i,'Fioo_frazil') !acme
index_x2i_Fioo_q = mct_aVect_indexRA(x2i_i,'Fioo_q') !cesm
if (index_x2i_Fioo_frazil /= 0) then
model = 'acme'
else if (index_o2x_Fioo_q /= 0) then
else if (index_x2i_Fioo_q /= 0) then
model = 'cesm'
end if
index_x2i_Fixx_rofi = mct_aVect_indexRA(x2i_i,'Fixx_rofi')
Expand Down
118 changes: 101 additions & 17 deletions utils/python/CIME/XML/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def get_grid_info(self, name, compset):
"""
Find the matching grid node
"""
node = self.get_node("grids")
version = None
if "version" in node.attrib:
version = node.get("version")


nodes = self.get_nodes("grid")
gridinfo = {}
atmnlev = None
Expand All @@ -40,11 +46,14 @@ def get_grid_info(self, name, compset):
lndnlev = levmatch.group(3)
name = levmatch.group(1)+levmatch.group(2)+levmatch.group(4)


# first search for all grids that have a compset match - if one is found then return
for node in nodes:
if "compset" in node.attrib:
attrib = node.get("compset")
#--------------------------------------------------------------------
# version 1.0 schema (did not have a version in grids)
#--------------------------------------------------------------------
if version is None:
# first search for all grids that have a compset match - if one is found then return
for node in nodes:
if "compset" in node.attrib:
attrib = node.get("compset")
compset_match = re.search(attrib,compset)
if compset_match is not None:
alias = self.get_value("alias", root=node)
Expand All @@ -60,21 +69,96 @@ def get_grid_info(self, name, compset):
gridinfo["GRID"] = lname
return gridinfo

# if no matches were found for a possible compset match, then search for just a grid match with no
# compset attribute
for node in nodes:
if "compset" not in node.attrib:
# if no matches were found for a possible compset match, then search for just a grid match with no
# compset attribute
for node in nodes:
if "compset" not in node.attrib:
sname = self.get_value("sname", root=node)
alias = self.get_value("alias", root=node)
lname = self.get_value("lname", root=node)
if alias == name or lname == name or sname == name:
logger.debug("Found node compset match: %s and lname: %s" % (attrib, lname))
component_grids = self._get_component_grids(lname)
gridinfo.update(self._get_domains(component_grids))
gridinfo.update(self._get_gridmaps(component_grids, atmnlev, lndnlev))
gridinfo["GRID"] = lname
return gridinfo

#--------------------------------------------------------------------
# version 2.0 schema
#--------------------------------------------------------------------

if version is not None and version == "2.0":
print "DEBUG: name is ",name
for node in nodes:
sname = self.get_value("sname", root=node)
alias = self.get_value("alias", root=node)
lname = self.get_value("lname", root=node)
if alias == name or lname == name or sname == name:
logger.debug("Found node compset match: %s and lname: %s" % (attrib, lname))
component_grids = self._get_component_grids(lname)
gridinfo.update(self._get_domains(component_grids))
gridinfo.update(self._get_gridmaps(component_grids, atmnlev, lndnlev))
gridinfo["GRID"] = lname
return gridinfo
# if alias or sname match the input name then find the appropriate lname
if alias == name or sname == name:
lname_nodes = self.get_nodes("lname", root=node)

# first search for all lname nodes that have a compset match - if one is found then return
for lname_node in lname_nodes:
lname = lname_node.text
if "compset" in lname_node.attrib:
attrib = lname_node.get("compset")
compset_match = re.search(attrib, compset)
print "DEBUG: lname is lname"
print "DEBUG: attrib is ",attrib
if compset_match is not None:
print "DEBUG: Found node compset match: %s and lname: %s" % (attrib, lname)
logger.debug("Found node compset match: %s and lname: %s" % (attrib, lname))
component_grids = self._get_component_grids(lname)
domains = self._get_domains(component_grids)
gridmaps = self._get_gridmaps(component_grids, atmnlev, lndnlev)
gridinfo.update(domains)
gridinfo.update(gridmaps)
gridinfo["GRID"] = lname
return gridinfo

# if no matches were found for a possible compset
# match, then search for just an lname match with no compset attribute
for lname_node in lname_nodes:
if "compset" not in lname_node.attrib:
lname = self.get_value("lname", root=lname_node)
logger.debug("Found node compset match: %s and lname: %s" % (attrib, lname))
component_grids = self._get_component_grids(lname)
gridinfo.update(self._get_domains(component_grids))
gridinfo.update(self._get_gridmaps(component_grids, atmnlev, lndnlev))
gridinfo["GRID"] = lname
return gridinfo

# There is no consistency check of a grid longname is provided
# TODO: search for all lnames and find a match with either the compset or no compset
lname_nodes = self.get_nodes("lname")
for lname_node in lname_nodes:
lname = self.get_value("lname", root=lname_node)
if lname == name:
if "compset" in lname_node.attrib:
attrib = lname_node.get("compset")
compset_match = re.search(attrib, compset)
if compset_match is not None:
logger.debug("Found node compset match: %s and lname: %s" % (attrib, lname))
component_grids = self._get_component_grids(lname)
domains = self._get_domains(component_grids)
gridmaps = self._get_gridmaps(component_grids, atmnlev, lndnlev)
gridinfo.update(domains)
gridinfo.update(gridmaps)
gridinfo["GRID"] = lname
return gridinfo

# if no matches were found for a possible compset
# match, then search for just an lname match with no compset attribute
for lname_node in lname_nodes:
if "compset" not in lname_node.attrib:
lname = self.get_value("lname", root=lname_node)
logger.debug("Found node compset match: %s and lname: %s" % (attrib, lname))
component_grids = self._get_component_grids(lname)
gridinfo.update(self._get_domains(component_grids))
gridinfo.update(self._get_gridmaps(component_grids, atmnlev, lndnlev))
gridinfo["GRID"] = lname
return gridinfo

expect (False,
"grid '%s' is not supported, use manage_case to determine supported grids " %name)

Expand Down

0 comments on commit d55ba8f

Please sign in to comment.