Skip to content

Commit

Permalink
Updates for ZM round 4 (#345)
Browse files Browse the repository at this point in the history
Tag name (required for release branches): sima0_02_000zh
Originator(s): cacraig, peverley, nusbaume

Description (include the issue title, and the keyword ['closes',
'fixes', 'resolves'] followed by the issue number):
- No issue made
- Adds mods from various developers to get ZM to work properly in
CAM-SIMA

Describe any changes made to build system: N/A

Describe any changes made to the namelist: N/A

List any changes to the defaults for the input datasets (e.g. boundary
datasets): N/A

List all files eliminated and why: N/A

List all files added and what they do: N/A
A
cime_config/testdefs/testmods_dirs/cam/outfrq_zm_derecho/shell_commands
A cime_config/testdefs/testmods_dirs/cam/outfrq_zm_derecho/user_nl_cam
             - setup ZM regression test
             
A       src/physics/utils/ppgrid.F90
            - temporary file to use for backwards compatibility with CAM

List all existing files that have been modified, and describe the
changes:
(Helpful git command: `git diff --name-status
development...<your_branch_name>`)
M       .gitmodules
             - update to get atmospheric_physics changes for ZM
            
M       cime_config/atm_in_paramgen.py
             - exit if namelist entry does not have a value
             
M       cime_config/testdefs/testlist_cam.xml
             - add test for ZM
             
M       src/data/physconst.meta
M       src/data/ref_pres.meta
             - updated CCPP standard names
             
M       src/data/registry.xml
             - add entries required for ZM
            
M       src/physics/ncar_ccpp
             - updated submodule
             
M       src/physics/utils/musica_ccpp_dependencies.F90
M       src/physics/utils/musica_ccpp_dependencies.meta
             - remove cloud_area_fraction 
            
M       src/physics/utils/phys_comp.F90
             - Add new dimension: number_of_ccpp_constituents
             
M       src/utils/time_manager.F90
             - add current_timestep_number as "mark_as_initialized"
            
M       test/unit/python/test_atm_in_paramgen.py
             - @nusbaume added unit test for new python code

If there are new failures (compared to the
`test/existing-test-failures.txt` file),
have them OK'd by the gatekeeper, note them here, and add them to the
file.
If there are baseline differences, include the test and the reason for
the
diff. What is the nature of the change? Roundoff?

derecho/intel/aux_sima:
    - Added ZM test

derecho/gnu/aux_sima:
    - All pass

If this changes climate describe any run(s) done to evaluate the new
climate in enough detail that it(they) could be reproduced:

CAM-SIMA date used for the baseline comparison tests if different than
latest:
  • Loading branch information
cacraigucar authored Feb 13, 2025
2 parents 74b935d + 0da9024 commit c6de6d7
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[submodule "ncar-physics"]
path = src/physics/ncar_ccpp
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = 74e905b7a0ee5b2d2bfc3e3dd942eb9963398373
fxtag = atmos_phys0_08_000
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
[submodule "ccs_config"]
Expand Down
11 changes: 8 additions & 3 deletions cime_config/atm_in_paramgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,11 +1495,16 @@ def write(self, output_path):
# Write all variables within that group (sorted alphabetically):
for var in sorted(self._data[nml_group], key=var_sort_key):
#Extract variable value(s):
val = self._data[nml_group][var]["values"].strip()
val = self._data[nml_group][var]["values"]

#If no value is set then move to the next variable:
#Raise error if no value found:
if val is None:
continue
emsg = f"Namelist entry '{var}' is missing a "
emsg += "valid/default 'value' element."
raise AtmInParamGenError(emsg)
else:
#If value found then strip white space:
val = val.strip()
#End if

#Extract variable type:
Expand Down
9 changes: 9 additions & 0 deletions cime_config/testdefs/testlist_cam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
<option name="comment">Test for Moist Held-Suarez (TJ2016) physics (physics_after_coupler group)</option>
</options>
</test>
<test compset="FPHYStest" grid="ne3pg3_ne3pg3_mg37" name="SMS_Ln2" testmods="cam/outfrq_zm_derecho">
<machines>
<machine name="derecho" compiler="gnu" category="aux_sima"/>
</machines>
<options>
<option name="wallclock">00:10:00</option>
<option name="comment">Test for Zhang McFarlane physics</option>
</options>
</test>

<!-- Derecho dycore tests -->
<test compset="FKESSLER" grid="mpasa480_mpasa480" name="SMS_Ln9" testmods="cam/outfrq_kessler_mpas_derecho">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./xmlchange CAM_CONFIG_OPTS="--dyn none --physics-suites zhang_mcfarlane"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ncdata='/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_ZM_snapshot_derecho_gnu_before_c20250116.nc'
ncdata_check='/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_ZM_snapshot_derecho_gnu_after_c20250116.nc'
debug_output=0
pver=32
zmconv_momcd=.7D0
zmconv_momcu=.7D0
zmconv_num_cin=1
hist_add_inst_fields;h1: ZMDT, ZMDQ, CAPE, FREQZM, CMFMC_DP, ZMMU, ZMMD, DLFZM, PCONVT, PCONVB, ZMFLXPRC, ZMFLXSNW
hist_add_inst_fields;h1: ZMNTPRPD, ZMNTSNPD, ZMEIHEAT, PRECCDZM, PRECZ
hist_add_inst_fields;h1: ZMUPGU, ZMUPGD, ZMVPGU, ZMVPGD, ZMICUU, ZMICUD, ZMICVU, ZMICVD
hist_add_inst_fields;h1: EVAPTZM, FZSNTZM, EVSNTZM, EVAPQZM
hist_add_inst_fields;h1: ZMMTU, ZMMTV, ZMMTT
hist_add_inst_fields;h1: ZMDLIQ, ZMDICE
hist_output_frequency;h1: 1*nstep
hist_precision;h1: REAL64
hist_max_frames;h1: 1
2 changes: 1 addition & 1 deletion src/data/physconst.meta
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
dimensions = ()
protected = True
[ cpliq ]
standard_name = specific_heat_of_liquid_water_at_20c
standard_name = specific_heat_of_liquid_water_at_constant_pressure
long_name = Specific heat of fresh H2O
units = J kg-1 K-1
type = real | kind = kind_phys
Expand Down
4 changes: 2 additions & 2 deletions src/data/ref_pres.meta
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
dimensions = ()
protected = True
[ trop_cloud_top_lev ]
standard_name = index_of_pressure_at_troposhere_cloud_top
standard_name = vertical_layer_index_of_troposphere_cloud_top
units = index
type = integer
dimensions = ()
Expand Down Expand Up @@ -65,7 +65,7 @@
dimensions = ()
protected = True
[ nbot_molec ]
standard_name = index_of_pressure_at_bottom_of_molecular_diffusion
standard_name = vertical_layer_index_at_bottom_of_molecular_diffusion
units = index
type = integer
dimensions = ()
Expand Down
66 changes: 66 additions & 0 deletions src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -491,5 +491,71 @@
<long_name>graupel mass mixing ratio with respect to moist air plus all airborne condensates</long_name>
<ic_file_input_names>GRAUQM cnst_GRAUQM</ic_file_input_names>
</variable>

<!-- cam_in Variables -->
<variable local_name="landfrac"
standard_name="land_area_fraction"
units="fraction" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension</dimensions>
<ic_file_input_names>landfrac cam_in_landfrac</ic_file_input_names>
</variable>

<!-- Zhang McFarlane (ZM) Variables -->
<variable local_name="pblh"
standard_name="atmosphere_boundary_layer_thickness"
units="m" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension</dimensions>
<ic_file_input_names>pblh pbuf_pblh</ic_file_input_names>
</variable>
<variable local_name="tpert"
standard_name="convective_temperature_perturbation_due_to_pbl_eddies"
units="K" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension</dimensions>
<ic_file_input_names>tpert pbuf_tpert</ic_file_input_names>
</variable>
<variable local_name="ql"
standard_name="in_cloud_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water_due_to_deep_convection"
units="kg kg-1" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
<ic_file_input_names>ICWMRDP pbuf_ICWMRDP</ic_file_input_names>
</variable>
<variable local_name="cldfrc"
standard_name="cloud_area_fraction"
units="fraction" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
<initial_value>0.7_kind_phys</initial_value>
<ic_file_input_names>CLD pbuf_CLD</ic_file_input_names>
</variable>
<variable local_name="domomtran"
standard_name="flag_for_momentum_transport_by_zhang_mcfarlane_deep_convection_scheme"
units="flag" type="logical"
access="protected" >
<initial_value>.true.</initial_value>
</variable>
<variable local_name="il1g"
standard_name="index_of_first_column_of_gathered_deep_convection_arrays"
units="index" type="integer"
access="protected" >
<initial_value>1</initial_value>
</variable>
<variable local_name="dpdry"
standard_name="air_pressure_thickness_of_dry_air_for_deep_convection_for_gathered_convective_columns"
units="hPa" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
</variable>
<variable local_name="fracis"
standard_name="fraction_of_water_insoluble_convectively_transported_species"
units="fraction" type="real" kind="kind_phys"
allocatable="allocatable"
access="protected" >
<dimensions>horizontal_dimension vertical_layer_dimension number_of_ccpp_constituents</dimensions>
<initial_value>1</initial_value>
</variable>
</file>
</registry>
2 changes: 1 addition & 1 deletion src/physics/ncar_ccpp
Submodule ncar_ccpp updated 56 files
+56 −0 doc/ChangeLog
+255 −174 doc/NamesNotInDictionary.txt
+89 −0 schemes/cloud_fraction/cloud_fraction_fice.F90
+49 −0 schemes/cloud_fraction/cloud_fraction_fice.meta
+20 −4 schemes/musica/micm/musica_ccpp_micm.F90
+84 −58 schemes/musica/musica_ccpp.F90
+1 −1 schemes/musica/musica_ccpp.meta
+323 −0 schemes/musica/musica_ccpp_species.F90
+201 −88 schemes/musica/tuvx/musica_ccpp_tuvx.F90
+103 −0 schemes/musica/tuvx/musica_ccpp_tuvx_aerosol_optics.F90
+145 −0 schemes/musica/tuvx/musica_ccpp_tuvx_gas_species.F90
+11 −1 schemes/musica/tuvx/musica_ccpp_tuvx_height_grid.F90
+219 −0 schemes/musica/tuvx/musica_ccpp_tuvx_load_species.F90
+1 −1 schemes/musica/tuvx/musica_ccpp_tuvx_surface_albedo.F90
+68 −0 schemes/sima_diagnostics/zm_convr_tendency_diagnostics.F90
+70 −0 schemes/sima_diagnostics/zm_convr_tendency_diagnostics.meta
+205 −0 schemes/sima_diagnostics/zm_diagnostics.F90
+207 −0 schemes/sima_diagnostics/zm_diagnostics.meta
+81 −0 schemes/sima_diagnostics/zm_evap_tendency_diagnostics.F90
+81 −0 schemes/sima_diagnostics/zm_evap_tendency_diagnostics.meta
+67 −0 schemes/sima_diagnostics/zm_momtran_tendency_diagnostics.F90
+75 −0 schemes/sima_diagnostics/zm_momtran_tendency_diagnostics.meta
+79 −0 schemes/sima_diagnostics/zm_tendency_diagnostics.F90
+69 −0 schemes/sima_diagnostics/zm_tendency_diagnostics.meta
+29 −0 schemes/utilities/to_be_ccppized_temporary.F90
+22 −0 schemes/utilities/to_be_ccppized_temporary.meta
+26 −0 schemes/zhang_mcfarlane/set_deep_conv_fluxes_to_general.F90
+31 −0 schemes/zhang_mcfarlane/set_deep_conv_fluxes_to_general.meta
+46 −0 schemes/zhang_mcfarlane/set_general_conv_fluxes_to_deep.F90
+103 −0 schemes/zhang_mcfarlane/set_general_conv_fluxes_to_deep.meta
+61 −8 schemes/zhang_mcfarlane/zm_conv_convtran.F90
+91 −29 schemes/zhang_mcfarlane/zm_conv_convtran.meta
+29 −50 schemes/zhang_mcfarlane/zm_conv_evap.F90
+84 −68 schemes/zhang_mcfarlane/zm_conv_evap.meta
+14 −9 schemes/zhang_mcfarlane/zm_conv_momtran.F90
+81 −66 schemes/zhang_mcfarlane/zm_conv_momtran.meta
+83 −163 schemes/zhang_mcfarlane/zm_convr.F90
+148 −144 schemes/zhang_mcfarlane/zm_convr.meta
+195 −0 schemes/zhang_mcfarlane/zm_convr_namelist.xml
+46 −0 suites/suite_cam7.xml
+2 −2 test/docker/Dockerfile.musica
+2 −2 test/docker/Dockerfile.musica.no_install
+34 −5 test/musica/CMakeLists.txt
+51 −26 test/musica/test_musica_api.F90
+217 −0 test/musica/test_musica_species.F90
+97 −0 test/musica/tuvx/CMakeLists.txt
+85 −0 test/musica/tuvx/test_tuvx_aerosol_optics.F90
+476 −0 test/musica/tuvx/test_tuvx_gas_species.F90
+10 −1 test/musica/tuvx/test_tuvx_height_grid.F90
+362 −0 test/musica/tuvx/test_tuvx_load_species.F90
+38 −0 test/test_suites/suite_zhang_mcfarlane.xml
+1 −1 to_be_ccppized/ccpp_tuvx_utils.F90
+151 −0 to_be_ccppized/error_messages.F90
+6 −0 to_be_ccppized/namelist_utils.F90
+759 −0 to_be_ccppized/wv_sat_methods.F90
+1,483 −0 to_be_ccppized/wv_saturation.F90
8 changes: 1 addition & 7 deletions src/physics/utils/musica_ccpp_dependencies.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module musica_ccpp_dependencies
real(kind_phys), allocatable, public, protected :: extraterrestrial_radiation_flux(:)
real(kind_phys), allocatable, public, protected :: surface_albedo(:)
real(kind_phys), allocatable, public, protected :: blackbody_temperature_at_surface(:)
real(kind_phys), allocatable, public, protected :: cloud_area_fraction(:,:)

! local parameters
character(len=*), parameter :: module_name = '(musica_ccpp_dependencies)'
Expand Down Expand Up @@ -77,14 +76,9 @@ subroutine musica_ccpp_dependencies_init(horizontal_dimension, &
call check_allocate(error_code, subroutine_name, &
'blackbody_temperature_at_surface(horizontal_dimension)', &
file=__FILE__, line=__LINE__)
allocate(cloud_area_fraction(horizontal_dimension, vertical_layer_dimension), stat=error_code)
call check_allocate(error_code, subroutine_name, &
'cloud_area_fraction(horizontal_dimension, vertical_layer_dimension)', &
file=__FILE__, line=__LINE__)

surface_albedo(:) = 0.1_kind_phys
blackbody_temperature_at_surface(:) = 292.3_kind_phys
cloud_area_fraction(:,:) = 0.7_kind_phys
extraterrestrial_radiation_flux(:) = 1.0e14_kind_phys
photolysis_wavelength_grid_interfaces = (/ &
120.0e-9_kind_phys, &
Expand Down Expand Up @@ -194,4 +188,4 @@ subroutine musica_ccpp_dependencies_init(horizontal_dimension, &

end subroutine musica_ccpp_dependencies_init

end module musica_ccpp_dependencies
end module musica_ccpp_dependencies
6 changes: 0 additions & 6 deletions src/physics/utils/musica_ccpp_dependencies.meta
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,3 @@
units = K
dimensions = (horizontal_dimension)
protected = True
[ cloud_area_fraction ]
standard_name = cloud_area_fraction
type = real | kind = kind_phys
units = fraction
dimensions = (horizontal_dimension,vertical_layer_dimension)
protected = True
3 changes: 2 additions & 1 deletion src/physics/utils/phys_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,13 @@ subroutine phys_init()
use cam_thermo_formula, only: cam_thermo_formula_init
use physics_types, only: allocate_physics_types_fields
use cam_ccpp_cap, only: cam_ccpp_physics_initialize
use cam_constituents, only: num_advected

call cam_thermo_init(columns_on_task, pver, pverp)
call cam_thermo_formula_init()

call allocate_physics_types_fields(columns_on_task, pver, pverp, &
set_init_val_in=.true., reallocate_in=.false.)
num_advected, set_init_val_in=.true., reallocate_in=.false.)
call cam_ccpp_physics_initialize(phys_suite_name)
if (errcode /= 0) then
call endrun('cam_ccpp_physics_initialize: '//trim(errmsg))
Expand Down
24 changes: 24 additions & 0 deletions src/physics/utils/ppgrid.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

module ppgrid

!-----------------------------------------------------------------------
!
! Purpose: USED ONLY FOR BACKWARDS COMPATIBILITY WITH CAM!!!!
! PLEASE DELETE ONCE NO LONGER NEEDED BY "to_be_ccppized"
! PHYSICS SCHEMES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Thanks!
!-----------------------------------------------------------------------

use physics_grid, only: pcols => columns_on_task
use vert_coord, only: pver => pver, pverp => pverp !WILL NEED TO CHANGE THESE NAMES TO
!SOMETHING ELSE IN CAM-SIMA!

implicit none
private
save

public pcols
public pver
public pverp

end module ppgrid
4 changes: 4 additions & 0 deletions src/utils/time_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ subroutine timemgr_init( &
ref_tod, stop_ymd, stop_tod, curr_ymd, curr_tod, &
perpetual_run, perpetual_ymd, initial_run)

use phys_vars_init_check, only: mark_as_initialized

! Initialize the time manager.

! Arguments
Expand Down Expand Up @@ -152,6 +154,8 @@ subroutine timemgr_init( &
call timemgr_print()
end if

call mark_as_initialized('current_timestep_number')

end subroutine timemgr_init

!===========================================================================
Expand Down
72 changes: 71 additions & 1 deletion test/unit/python/test_atm_in_paramgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
python test_atm_in_paramgen.py -v
which will currently run 23 tests, all of which should pass.
which will currently run 24 tests, all of which should pass.
"""

#----------------------------------------
Expand Down Expand Up @@ -279,6 +279,76 @@ def test_namelist_from_xml_using_multi_attrs(self):

#++++++++++++++++++++++++++++++++++++++++++++++++

def test_namelist_xml_bad_value_entry(self):

"""
Check that AtmInParamGen throws the correct
error message when an XML namelist file
has an entry with a non-valid value.
"""

# Create fake CIME case:
fcase = FakeCase()

# Create namelist attribute dictionary:
nml_attr_dict = {"bird" : "goose", "never_read" : "0"}

# Get XML file path to original sample file:
xml_base_fil = os.path.join(_SAMPLES_DIR, "test_simple_nml_def.xml")

# Open base XML file:
base_tree = ET.parse(xml_base_fil)
base_root = base_tree.getroot()

# Write new namelist entry with "bad" value:
bad_namelist_string = \
"""
<entry id="bad_default_entry">
<type>integer</type>
<category>more_testing</category>
<group>please_fail</group>
<desc>
Let's make sure we don't have
a good default value
Default: None!
</desc>
<values>
<value never_read="1">3</value>
<value never_read="1" feel_lucky="1">5</value>
</values>
</entry>
"""

bad_xml_entry = ET.fromstring(bad_namelist_string)

# Add new namelist entry back to original namelist XML tree:
base_root.append(bad_xml_entry)

# Write out new, temporary XML namelist file for testing:
xml_test_fil = os.path.join(_TMP_DIR, "test_bad_value_nml_def.xml")
base_tree.write(xml_test_fil, encoding="utf-8", xml_declaration=True)

# Create ParamGen object:
pg_test = AtmInParamGen.from_namelist_xml(xml_test_fil)

# Set all ParamGen namelist values:
pg_test.reduce_atm_in(fcase, nml_attr_dict)

# Set atm_in filename to write to (should never get to this point):
test_output = os.path.join(_TMP_DIR, "test_bad_xml_value_entry_in")

# Attempt to write namelist using ParamGen:
with self.assertRaises(AtmInParamGenError) as cerr:
pg_test.write(test_output)

# Check exception message
emsg = "Namelist entry 'bad_default_entry' is missing"
emsg += " a valid/default 'value' element."

self.assertEqual(emsg, str(cerr.exception))

#++++++++++++++++++++++++++++++++++++++++++++++++

def test_namelist_xml_missing_elems(self):

"""
Expand Down

0 comments on commit c6de6d7

Please sign in to comment.