Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cime_config/testdefs/testlist_cam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</machines>
<options>
<option name="wallclock">00:10:00</option>
<option name="comment">Test for Zhang McFarlane physics</option>
<option name="comment">Test for Zhang McFarlane deep convection scheme</option>
</options>
</test>
<test compset="FPHYStest" grid="ne3pg3_ne3pg3_mg37" name="SMS_Ln2" testmods="cam/outfrq_hack_shallow_derecho">
Expand All @@ -70,7 +70,15 @@
<option name="comment">Test for dme_adjust scheme</option>
</options>
</test>

<test compset="FPHYStest" grid="ne3pg3_ne3pg3_mg37" name="SMS_Ln2" testmods="cam/outfrq_rk_stratiform_derecho">
<machines>
<machine name="derecho" compiler="gnu" category="aux_sima"/>
</machines>
<options>
<option name="wallclock">00:10:00</option>
<option name="comment">Test for Rasch-Kristjansson microphysics scheme</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 rasch_kristjansson"
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
! these are QPC4 snapshots and require custom physical constant definitions.
ncdata = '/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_rasch_kristjansson_rk_stratiform_snapshot_derecho_gnu_before_c20250328.nc'
ncdata_check = '/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_rasch_kristjansson_rk_stratiform_snapshot_derecho_gnu_after_c20250328.nc'

Comment on lines +3 to +4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently realized that when possible we should have the model exit (and thus induce a test failure) whenever the snapshot file comparison finds significant differences. I believe this can be done for this test by adding the following namelist setting to this file:

ncdata_check_err = .true.

Of course if that ends up not working for this particular test please let me know!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nusbaume! Sadly I can't enable this option because it'll abort the model even with round-off differences. Right now the physics check data has round-off level differences against the snapshot

 ********** Physics Check Data Results **********

 TIMESTEP:            1

 Variable                                          # Diffs  Max Diff   Max Diff loc (rank, col, lev)
 --------                                          -------  --------   -----------------------------
 air_temperature                                       127  0.22E-15   (19,3,22)
 geopotential_height_wrt_surface                       152  0.38E-15   (14,20,19)
 geopotential_height_wrt_surface_at_interface          150  0.42E-15   (10,4,25)
 tendency_of_air_temperature_due_to_model_physics      171  0.10E-14   (19,11,24)
cloud_liquid_water_mixing_ratio_wrt_moist_air_and_condensed_water
                                                      2212  0.85E-15   (7,13,23)
cloud_ice_mixing_ratio_wrt_moist_air_and_condensed_water
                                                      2076  0.76E-15   (7,6,24)
water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water
                                                       131  0.22E-15   (12,4,26)

 ********** End Physics Check Data Results **********

It will run for all the time slices in the snapshot to completion with comparable round-off differences but the model will abort on timestep 1 if ncdata_check_err = .true.

 ERROR: Difference(s) found during ncdata check at /glade/derecho/scratch/hplin/aux_sima_gnu_20250516111902/SMS_Ln2.ne3pg3_ne3pg3_mg37.FPHYStest.derecho_gnu.cam-outfrq_rk_stratiform_derecho.GC.aux_sima_gnu_20250516111902/bld/atm/obj/phys_init/physics_inputs.F90:1056

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jimmielin, what happens if you add the following namelist option as well:

min_difference = 1e-15

It looks like by default any difference counts as a "failure", but I think with this option only differences greater than the min_difference value will count (which based off the print out should be none of them).

Of course if you don't have time for this then no worries! Just thought it might be worth it if it is easy to test. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nusbaume that is useful to know! Will test when Derecho is back up!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding my +1 for this feature

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nusbaume and @cacraigucar! I had to relax the constraint to min_difference = 2e-15 since this will trip 1e-15

 tendency_of_air_temperature_due_to_model_physics      171  0.10E-14   (19,11,24)

However if I enable min_difference the log output will change; it seems like if a difference is < min_difference, it'll be ignored by the log output as well:

 ********** Physics Check Data Results **********

 TIMESTEP:            2

 No differences found!

 ********** End Physics Check Data Results **********

I'm not sure if we want to "see" the differences in the logs, even if they are smaller than the min_difference. I think I would prefer to since it'll help distinguish between a truly bit-for-bit vs. a ~1e-15 difference due to differences in how SIMA and CAM do things. Please let me know which way you'd prefer!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I too would like to see roundoff differences even if we allow them to "pass" the test. Perhaps we should bring this up as a discussion topic on Monday?

Copy link
Collaborator

@peverwhee peverwhee Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to chat about it on monday. I don't think it'd be a big lift to still include the diffs, but I lean towards keeping it the way it is because:

  1. I'm not sure who will be looking at the test output for a PASS
  2. I like that the current implementation allows for cleaner/clearer depictions of actual answer changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now added!

! qpc4
pver = 26
user_defined_cpwv = 1.846e3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the value specified in namelist_definition_physconst.xml being overriden? I would suggest that the baseline which gets stored from this tests depend on the settings in that structure. That way if the field gets changed, then the test will have a baseline difference indicating that this routine has been impacted. I've not checked the other values below, but I believe that all of them specified in physconst should not be listed (changed or unchanged)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snapshots are taken from a CAM4 aquaplanet compset (QPC4) and aquaplanet simulations have a specific set of physical constants overriding the defaults. ref. CAM/bld/namelist_files/use_cases/aquaplanet_cam4.xml

<!-- Revised physics constants for ape experiments -->
<sday                     >86164.10063718943</sday>
<rearth                   >6.37100e6</rearth>
<gravit                   >9.79764</gravit>
<mwdry                    >28.96623324623746</mwdry>
<mwh2o                    >18.01618112892741</mwh2o>
<cpwv                     >1.846e3</cpwv>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cacraigucar, I've added an issue to create this test in the near future! #397

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentionally not resolving this so #397 can more easily see this discussion

user_defined_gravit = 9.79764
user_defined_mwdry = 28.96623324623746
user_defined_mwh2o = 18.01618112892741
user_defined_rearth = 6.37100e6
user_defined_sday = 86164.10063718943

! rk
cldfrc_dp1 = 0.10D0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there are a number of these fields which should be specified via a namelist.xml file. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snapshots are taken from a CAM4 aquaplanet configuration; the cldfrc scheme tuning parameter defaults in namelist_defaults_cam.xml is different for the "default" and "CAM4" configurations; the FPHYStest compset has no way of conveying this information in SIMA (tagging @nusbaume to be sure!) since the physics suite is a test SDF so it has to be overridden here:

<cldfrc_dp1                                                           > 0.14D0 </cldfrc_dp1>
<cldfrc_dp1             phys="cam5"                                   > 0.10D0 </cldfrc_dp1>
<cldfrc_dp1             phys="cam6"                                   > 0.10D0 </cldfrc_dp1>
<cldfrc_dp1             phys="cam7"                                   > 0.10D0 </cldfrc_dp1>
<cldfrc_dp1 dyn="fv"    phys="cam4"                                   > 0.10D0 </cldfrc_dp1>
<cldfrc_dp1 dyn="se"    phys="cam4"                                   > 0.10D0 </cldfrc_dp1>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we need two tests

  1. A test which compares directly with CAM and uses these custom settings
  2. A test which does not use the custom settings, but is used to maintain BFB testing of RK over future commits, using the values supplied by CAM-SIMA.

I believe there also needs to be a namelist.xml file, doesn't there to support the reading of RK namelist variables (and this would be needed by test 2).

I would suggest that this also would be a good discussion topic for Monday's hackathon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an issue for this in the near future: #397

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentionally not resolving this so #397 can more easily see this discussion

cldfrc_dp2 = 500.0D0
cldfrc_freeze_dry = .true.
cldfrc_ice = .false.
cldfrc_icecrit = 0.95D0
cldfrc_iceopt = 1
cldfrc_premib = 750.0D2
cldfrc_premit = 75000.0D0
cldfrc_rhminh = 0.800D0
cldfrc_rhminl = 0.910D0
cldfrc_rhminl_adj_land = 0.100D0
cldfrc_sh1 = 0.04D0
cldfrc_sh2 = 500.0D0

! sima only:
cldfrc_inversion_cld_off = .false.

cldsed_ice_stokes_fac = 1.0D0

rk_strat_conke = 5.0e-6
rk_strat_icritc = 18.0e-6
rk_strat_icritw = 2.0e-4
rk_strat_r3lcrit = 10.0e-6
! sima only:
rk_strat_polstrat_dorhmin = .false.

hist_output_frequency;h1: 1*nsteps
hist_max_frames;h1: 1
hist_add_inst_fields;h1:DQSED,DISED,DLSED,HSED,PRECSED,SNOWSED,RAINSED
hist_add_inst_fields;h1:SH_CLD,DP_CLD,CONCLD,AST
hist_add_inst_fields;h1:FICE,REPARTICE,REPARTLIQ,HREPART
hist_add_inst_fields;h1:FWAUT,FSAUT,FRACW,FSACW,FSACI,PCSNOW,CME,CMEICE,CMELIQ
hist_add_inst_fields;h1:ICE2PR,LIQ2PR,HPROGCLD,HEVAP,HMELT,HCME,HFREEZ
hist_add_inst_fields;h1:PRODPREC,EVAPPREC,EVAPSNOW,LS_FLXPRC,LS_FLXSNW,PRACWO,PSACWO,PSACIO
hist_add_inst_fields;h1:CLDLIQSTR,CLDICESTR,CLDLIQCON,CLDICECON
hist_add_inst_fields;h1:IWC,LWC,ICIMR,ICWMR,REI,REL
hist_precision;h1: REAL64
48 changes: 47 additions & 1 deletion src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,14 @@
<initial_value>0.0_kind_phys</initial_value>
<ic_file_input_names>landfrac cam_in_landfrac</ic_file_input_names>
</variable>
<variable local_name="ocnfrac"
standard_name="ocean_area_fraction"
units="fraction" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension</dimensions>
<initial_value>1.0_kind_phys</initial_value>
<ic_file_input_names>ocnfrac cam_in_ocnfrac</ic_file_input_names>
</variable>
<variable local_name="icefrac"
standard_name="sea_ice_area_fraction"
units="fraction" type="real" kind="kind_phys"
Expand All @@ -608,6 +616,15 @@
<initial_value>273.15_kind_phys</initial_value>
<ic_file_input_names>sst cam_in_sst</ic_file_input_names>
</variable>
<variable local_name="landm"
standard_name="smoothed_land_area_fraction"
units="fraction" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension</dimensions>
<!-- Note: In CAM, landm is read from the topo dataset (or if disabled, set to zero) -->
<initial_value>0.0_kind_phys</initial_value>
<ic_file_input_names>LANDM_COSLAT pbuf_LANDM</ic_file_input_names>
</variable>

<!-- Temporary initializations from snapshot -->
<!-- Note that no_deep_pbl defaults to false, but needs to be set to true for diag_TKE or UW schemes -->
Expand Down Expand Up @@ -647,14 +664,43 @@
<initial_value>.false.</initial_value>
</variable>
<variable local_name="shfrc"
standard_name="shallow_convective_cloud_area_fraction"
standard_name="shallow_convective_cloud_area_fraction_from_shallow_convection"
units="fraction" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
<!-- only used if use_shfrc is .true. -->
<initial_value>0.0_kind_phys</initial_value>
</variable>

<!-- rk_stratiform microphysics/macrophysics variables - need to be kept in physics state -->
<variable local_name="qcwat"
standard_name="water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water_on_previous_timestep"
units="kg kg-1" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
<!-- set to negative if not read from the snapshot. -->
<initial_value>-1.0_kind_phys</initial_value>
<ic_file_input_names>pbuf_QCWAT</ic_file_input_names>
</variable>
<variable local_name="tcwat"
standard_name="air_temperature_on_previous_timestep"
units="K" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
<!-- set to negative if not read from the snapshot. -->
<initial_value>-1.0_kind_phys</initial_value>
<ic_file_input_names>pbuf_TCWAT</ic_file_input_names>
</variable>
<variable local_name="lcwat"
standard_name="cloud_water_mixing_ratio_wrt_moist_air_and_condensed_water_on_previous_timestep"
units="kg kg-1" type="real" kind="kind_phys"
allocatable="allocatable">
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
<!-- set to negative if not read from the snapshot. -->
<initial_value>-1.0_kind_phys</initial_value>
<ic_file_input_names>pbuf_LCWAT</ic_file_input_names>
</variable>

<!-- Zhang McFarlane (ZM) Variables -->
<variable local_name="ql"
standard_name="in_cloud_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water_due_to_deep_convection"
Expand Down
2 changes: 1 addition & 1 deletion src/physics/ncar_ccpp
Submodule ncar_ccpp updated 112 files
Loading