Skip to content

Commit 79b2b4f

Browse files
committed
merge main
2 parents 634610c + 41072c1 commit 79b2b4f

File tree

16 files changed

+170
-49
lines changed

16 files changed

+170
-49
lines changed

cime_config/testdefs/testlist_cam.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
<option name="comment">Test for Hack shallow convection scheme</option>
6262
</options>
6363
</test>
64+
<test compset="FPHYStest" grid="ne3pg3_ne3pg3_mg37" name="SMS_Ln2" testmods="cam/outfrq_dme_adjust_derecho">
65+
<machines>
66+
<machine name="derecho" compiler="gnu" category="aux_sima"/>
67+
</machines>
68+
<options>
69+
<option name="wallclock">00:10:00</option>
70+
<option name="comment">Test for dme_adjust scheme</option>
71+
</options>
72+
</test>
73+
6474

6575
<!-- Derecho dycore tests -->
6676
<test compset="FKESSLER" grid="mpasa480_mpasa480" name="SMS_Ln9" testmods="cam/outfrq_kessler_mpas_derecho">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./xmlchange CAM_CONFIG_OPTS="--dyn none --physics-suites dme_adjust"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ncdata='/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_dme_adjust_snapshot_derecho_gnu_before_c20250416.nc'
2+
ncdata_check='/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_dme_adjust_snapshot_derecho_gnu_after_c20250416.nc'
3+
debug_output=0
4+
pver=32
5+
hist_add_inst_fields;h2: Q,PS
6+
hist_output_frequency;h2: nsteps
7+
hist_write_nstep0;h2: .true.

src/data/generate_registry_data.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class VarBase:
141141
__pointer_type_str = "pointer"
142142

143143
def __init__(self, elem_node, local_name, dimensions, known_types,
144-
type_default, units_default="", kind_default='',
144+
type_default, units_default="", kind_default='', dycore='',
145145
protected=False, index_name='', local_index_name='',
146146
local_index_name_str='', alloc_default='none',
147147
tstep_init_default=False):
@@ -154,6 +154,7 @@ def __init__(self, elem_node, local_name, dimensions, known_types,
154154
self.__standard_name = elem_node.get('standard_name')
155155
self.__long_name = ''
156156
self.__initial_value = ''
157+
self.__initial_value_match = 0
157158
self.__initial_val_vars = set()
158159
self.__ic_names = None
159160
self.__elements = []
@@ -183,7 +184,30 @@ def __init__(self, elem_node, local_name, dimensions, known_types,
183184
if attrib.tag == 'long_name':
184185
self.__long_name = attrib.text
185186
elif attrib.tag == 'initial_value':
186-
self.__initial_value = attrib.text
187+
# Figure out if we should use this initial_value
188+
# If the number of matching attributes is greater than the
189+
# default or a previous match, pick this one
190+
matches = 0
191+
if not attrib.keys():
192+
self.__initial_value = attrib.text
193+
# end if (no attributes, this is the default)
194+
for att in attrib.keys():
195+
# Check each attribute (for now, this is only the dycore)
196+
if att == 'dyn':
197+
dycore_list = attrib.get('dyn').lower().split(',')
198+
if dycore in dycore_list:
199+
matches += 1
200+
# end if (dycore matches)
201+
# end if (check the dycore)
202+
# end for
203+
if matches == self.__initial_value_match and matches != 0:
204+
emsg = f"Unclear which initial_value to use for {local_name}. There are at least two configurations with {matches} matching attributes"
205+
raise CCPPError(emsg)
206+
elif matches > self.__initial_value_match:
207+
# Use this initial_value (for now)
208+
self.__initial_value_match = matches
209+
self.__initial_value = attrib.text
210+
# end if (number of matches)
187211
elif attrib.tag == 'ic_file_input_names':
188212
#Separate out string into list:
189213
self.__ic_names = [x.strip() for x in attrib.text.split(' ') if x]
@@ -488,16 +512,16 @@ class Variable(VarBase):
488512
###############################################################################
489513
# pylint: disable=too-many-instance-attributes
490514
"""Registry variable
491-
>>> Variable(ET.fromstring('<variable kind="kind_phys" local_name="u" standard_name="east_wind" type="real" units="m s-1"><dimensions>ccpp_constant_one:horizontal_dimension:two</dimensions></variable>'), TypeRegistry(), VarDict("foo", "module", None), None) #doctest: +IGNORE_EXCEPTION_DETAIL
515+
>>> Variable(ET.fromstring('<variable kind="kind_phys" local_name="u" standard_name="east_wind" type="real" units="m s-1"><dimensions>ccpp_constant_one:horizontal_dimension:two</dimensions></variable>'), TypeRegistry(), VarDict("foo", "module", None), 'se', None) #doctest: +IGNORE_EXCEPTION_DETAIL
492516
Traceback (most recent call last):
493517
CCPPError: Illegal dimension string, ccpp_constant_one:horizontal_dimension:two, in u, step not allowed.
494-
>>> Variable(ET.fromstring('<variable kind="kind_phys" local_name="u" standard_name="east_wind" type="real" units="m s-1"><dims>horizontal_dimension</dims></variable>'), TypeRegistry(), VarDict("foo", "module", None), None) #doctest: +IGNORE_EXCEPTION_DETAIL
518+
>>> Variable(ET.fromstring('<variable kind="kind_phys" local_name="u" standard_name="east_wind" type="real" units="m s-1"><dims>horizontal_dimension</dims></variable>'), TypeRegistry(), VarDict("foo", "module", None), 'se', None) #doctest: +IGNORE_EXCEPTION_DETAIL
495519
Traceback (most recent call last):
496520
CCPPError: Unknown Variable content, dims
497-
>>> Variable(ET.fromstring('<variable kkind="kind_phys" local_name="u" standard_name="east_wind" type="real" units="m s-1"></variable>'), TypeRegistry(), VarDict("foo", "module", None), None) #doctest: +IGNORE_EXCEPTION_DETAIL
521+
>>> Variable(ET.fromstring('<variable kkind="kind_phys" local_name="u" standard_name="east_wind" type="real" units="m s-1"></variable>'), TypeRegistry(), VarDict("foo", "module", None), 'se', None) #doctest: +IGNORE_EXCEPTION_DETAIL
498522
Traceback (most recent call last):
499523
CCPPError: Bad variable attribute, 'kkind', for 'u'
500-
>>> Variable(ET.fromstring('<variable kind="kind_phys" local_name="u" standard_name="east_wind" type="real" units="m s-1" allocatable="target"><dimensions>horizontal_dimension vertical_dimension</dimensions></variable>'), TypeRegistry(), VarDict("foo", "module", None), None) #doctest: +IGNORE_EXCEPTION_DETAIL
524+
>>> Variable(ET.fromstring('<variable kind="kind_phys" local_name="u" standard_name="east_wind" type="real" units="m s-1" allocatable="target"><dimensions>horizontal_dimension vertical_dimension</dimensions></variable>'), TypeRegistry(), VarDict("foo", "module", None), 'se', None) #doctest: +IGNORE_EXCEPTION_DETAIL
501525
Traceback (most recent call last):
502526
CCPPError: Dimension, 'vertical_dimension', not found for 'u'
503527
"""
@@ -511,7 +535,7 @@ class Variable(VarBase):
511535
"phys_timestep_init_zero", "standard_name",
512536
"type", "units", "version"]
513537

514-
def __init__(self, var_node, known_types, vdict, logger):
538+
def __init__(self, var_node, known_types, vdict, dycore, logger):
515539
# pylint: disable=too-many-locals
516540
"""Initialize a Variable from registry XML"""
517541
local_name = var_node.get('local_name')
@@ -588,7 +612,7 @@ def __init__(self, var_node, known_types, vdict, logger):
588612
# Initialize the base class
589613
super().__init__(var_node, local_name,
590614
my_dimensions, known_types, ttype,
591-
protected=protected)
615+
dycore=dycore, protected=protected)
592616

593617
for attrib in var_node:
594618
# Second pass, only process array elements
@@ -1090,7 +1114,7 @@ def __init__(self, ddt_node, known_types, var_dict, dycore):
10901114
varname = attrib.text
10911115
include_var = True
10921116
attrib_dycores = [x.strip().lower() for x in
1093-
attrib.get('dycore', default="").split(',')
1117+
attrib.get('dyn', default="").split(',')
10941118
if x]
10951119
if attrib_dycores and (dycore not in attrib_dycores):
10961120
include_var = False
@@ -1226,6 +1250,7 @@ def __init__(self, file_node, known_types, dycore,
12261250
self.__use_statements = []
12271251
self.__generate_code = gen_code
12281252
self.__file_path = file_path
1253+
self.__dycore = dycore
12291254
for obj in file_node:
12301255
if obj.tag in ['variable', 'array']:
12311256
self.add_variable(obj, logger)
@@ -1252,7 +1277,7 @@ def add_variable(self, var_node, logger):
12521277
"""Create a Variable from <var_node> and add to this File's
12531278
variable dictionary"""
12541279
newvar = Variable(var_node, self.__known_types, self.__var_dict,
1255-
logger)
1280+
self.__dycore, logger)
12561281
self.__var_dict.add_variable(newvar)
12571282

12581283
def add_ddt(self, newddt, logger=None):

src/data/ref_pres.F90

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,11 @@ subroutine ref_pres_readnl(nlfile)
9494
end if
9595
end if
9696

97-
if (npes > 1) then
98-
! Broadcast namelist variables
99-
call mpi_bcast(trop_cloud_top_press, 1, mpi_real8, masterprocid, mpicom, ierr)
100-
call mpi_bcast(clim_modal_aero_top_press, 1, mpi_real8, masterprocid, mpicom, ierr)
101-
call mpi_bcast(do_molec_press, 1, mpi_real8, masterprocid, mpicom, ierr)
102-
call mpi_bcast(molec_diff_bot_press, 1, mpi_real8, masterprocid, mpicom, ierr)
103-
endif
97+
! Broadcast namelist variables
98+
call mpi_bcast(trop_cloud_top_press, 1, mpi_real8, masterprocid, mpicom, ierr)
99+
call mpi_bcast(clim_modal_aero_top_press, 1, mpi_real8, masterprocid, mpicom, ierr)
100+
call mpi_bcast(do_molec_press, 1, mpi_real8, masterprocid, mpicom, ierr)
101+
call mpi_bcast(molec_diff_bot_press, 1, mpi_real8, masterprocid, mpicom, ierr)
104102

105103
end subroutine ref_pres_readnl
106104

src/data/registry.xml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
units="flag" type="logical">
350350
<long_name>flag indicating if dynamical core energy is not consistent with CAM physics and to perform adjustment of temperature and temperature tendency</long_name>
351351
<initial_value>.false.</initial_value>
352-
<initial_value dycore="SE,MPAS">.true.</initial_value>
352+
<initial_value dyn="SE,MPAS">.true.</initial_value>
353353
</variable>
354354
<!-- Timestep properties -->
355355
<variable local_name="is_first_timestep"
@@ -392,7 +392,7 @@
392392
standard_name="dycore_calculates_geopotential_using_logarithms"
393393
units="flag" type="logical" access="protected">
394394
<initial_value>.false.</initial_value>
395-
<initial_value dycore="SE,FV">.true.</initial_value>
395+
<initial_value dyn="SE,FV">.true.</initial_value>
396396
</variable>
397397
<ddt type="physics_state">
398398
<data>air_temperature</data>
@@ -697,5 +697,34 @@
697697
<dimensions>horizontal_dimension vertical_layer_dimension number_of_ccpp_constituents</dimensions>
698698
<initial_value>1</initial_value>
699699
</variable>
700+
701+
<!-- dme_adjust Variables -->
702+
<variable local_name="qini"
703+
standard_name="water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water_before_physics"
704+
units="kg kg-1" type="real" kind="kind_phys"
705+
allocatable="allocatable">
706+
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
707+
<ic_file_input_names>QINI pbuf_QINI</ic_file_input_names>
708+
</variable>
709+
<variable local_name="liqini"
710+
standard_name="total_liquid_water_mixing_ratio_wrt_moist_air_and_condensed_water_before_physics"
711+
units="kg kg-1" type="real" kind="kind_phys"
712+
allocatable="allocatable">
713+
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
714+
<ic_file_input_names>TOTLIQINI pbuf_TOTLIQINI</ic_file_input_names>
715+
</variable>
716+
<variable local_name="iceini"
717+
standard_name="total_ice_water_mixing_ratio_wrt_moist_air_and_condensed_water_before_physics"
718+
units="kg kg-1" type="real" kind="kind_phys"
719+
allocatable="allocatable">
720+
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
721+
<ic_file_input_names>TOTICEINI pbuf_TOTICEINI</ic_file_input_names>
722+
</variable>
723+
<variable local_name="is_moist_dycore"
724+
standard_name="is_moist_basis_dycore"
725+
units="flag" type="logical" access="protected">
726+
<initial_value>.true.</initial_value>
727+
<initial_value dyn="SE,MPAS"> .false. </initial_value>
728+
</variable>
700729
</file>
701730
</registry>

src/data/registry_v1_0.xsd

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
<xs:attribute name="access" type="access_type"/>
9898
<xs:attribute name="allocatable" type="allocation_type"/>
99-
<xs:attribute name="dycore" type="dycore_type"/>
99+
<xs:attribute name="dyn" type="dycore_type"/>
100100
<xs:attribute name="extends" type="fortran_id_type"/>
101101
<xs:attribute name="kind" type="fortran_id_type"/>
102102
<xs:attribute name="local_name" type="fortran_id_type"/>
@@ -130,7 +130,10 @@
130130
<xs:complexType name="initial_value">
131131
<xs:simpleContent>
132132
<xs:extension base="xs:string">
133-
<xs:attribute ref="dycore" use="optional" default=""/>
133+
<!--- If adding a new attribute, also modify generate_registry_data.py
134+
to check the attribute
135+
-->
136+
<xs:attribute ref="dyn" use="optional" default=""/>
134137
</xs:extension>
135138
</xs:simpleContent>
136139
</xs:complexType>
@@ -192,7 +195,7 @@
192195
<xs:complexType name="data_type">
193196
<xs:simpleContent>
194197
<xs:extension base="standard_name_type">
195-
<xs:attribute ref="dycore" use="optional" default=""/>
198+
<xs:attribute ref="dyn" use="optional" default=""/>
196199
</xs:extension>
197200
</xs:simpleContent>
198201
</xs:complexType>

src/dynamics/utils/vert_coord.F90

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ subroutine vert_coord_readnl(nlfile)
6767
end if
6868
end if
6969

70-
if (npes > 1) then
71-
! Broadcast namelist variables
72-
call mpi_bcast(pver, 1, mpi_integer, masterprocid, mpicom, ierr)
73-
endif
70+
! Broadcast namelist variables
71+
call mpi_bcast(pver, 1, mpi_integer, masterprocid, mpicom, ierr)
7472

7573
end subroutine vert_coord_readnl
7674

src/physics/utils/physics_grid.F90

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,12 @@ subroutine phys_grid_init(hdim1_d_in, hdim2_d_in, dycore_name_in, &
285285
file=__FILE__, line=__LINE__)
286286

287287
! We need a global minimum longitude and latitude
288-
if (npes > 1) then
289-
temp = lonmin
290-
call MPI_allreduce(temp, lonmin, 1, MPI_INTEGER, MPI_MIN, &
291-
mpicom, ierr)
292-
temp = latmin
293-
call MPI_allreduce(temp, latmin, 1, MPI_INTEGER, MPI_MIN, &
294-
mpicom, ierr)
295-
end if
288+
temp = lonmin
289+
call MPI_allreduce(temp, lonmin, 1, MPI_INTEGER, MPI_MIN, &
290+
mpicom, ierr)
291+
temp = latmin
292+
call MPI_allreduce(temp, latmin, 1, MPI_INTEGER, MPI_MIN, &
293+
mpicom, ierr)
296294
! Create lon coord map which only writes from one of each unique lon
297295
where(latvals == latmin)
298296
coord_map(:) = grid_map(3, :)

test/existing-test-failures.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
SMS_Ln9.ne5pg3_ne5pg3_mg37.FCAM7.derecho_intel.cam-outfrq_se_cslam_analy_ic (Overall: FAIL) details:
2-
SMS_Ln9.ne5pg3_ne5pg3_mg37.FCAM7.derecho_gnu.cam-outfrq_se_cslam_analy_ic (Overall: FAIL) details:
3-
- CAM7 suite will not work without a PBL scheme
4-
- CAM7 suite will not work with snapshot fields in registry.xml even if initial_value is defined (CAM-SIMA#359)
1+
All tests are currently passing

0 commit comments

Comments
 (0)