Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for ZM round 4 #345

Open
wants to merge 25 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b34d949
Merge remote-tracking branch 'upstream/development' into cam_sima_tes…
cacraigucar May 3, 2024
d221725
Change to get cam_sima_zm to compile
cacraigucar Jul 22, 2024
e4e6b38
Merge remote-tracking branch 'court/history_court' into cam_sima_testing
cacraigucar Jul 24, 2024
7e164e5
Remove nsteps from registry as now in there
cacraigucar Jul 24, 2024
b1afafd
Fix typo in metadata file
cacraigucar Aug 7, 2024
03890e8
Merge remote-tracking branch 'court/history_court' into cam_sima_testing
cacraigucar Aug 7, 2024
18a608f
Updates to aid in getting ZM running in CAM-SIMA
cacraigucar Aug 14, 2024
ee433ee
Merge remote-tracking branch 'court/history_court' into cam_sima_testing
cacraigucar Aug 23, 2024
3c63ad1
read in all constituents from file; not just build-time ones
Sep 20, 2024
28becd1
clarify variable name
Sep 20, 2024
75cdffb
fix bug from copied code
Sep 20, 2024
006f412
fix unit tests
Sep 20, 2024
6bfe67a
Update registry for ZM
cacraigucar Sep 23, 2024
dc7b04a
fix air composition standard names; add more water species to registry
Sep 25, 2024
3adb55e
Merge remote-tracking branch 'court/read-all-const' into cam_sima_tes…
cacraigucar Sep 25, 2024
c12b6cf
Merge remote-tracking branch 'court/read-all-const' into cam_sima_tes…
cacraigucar Sep 25, 2024
30656a2
fix missing line from merge conflict
cacraigucar Sep 27, 2024
b93ab05
Merge remote-tracking branch 'upstream/development' into cam_sima_tes…
cacraigucar Dec 9, 2024
77ba066
Merge remote-tracking branch 'upstream/development' into cam_sima_tes…
cacraigucar Dec 18, 2024
6040b85
Merge remote-tracking branch 'upstream/development' into cam_sima_tes…
cacraigucar Jan 3, 2025
85a1096
Update unit test sample files
cacraigucar Jan 3, 2025
c33eb21
Fix cloud_area_fraction conflict
cacraigucar Jan 6, 2025
3c5ac5e
Merge tag 'sima0_01_000' into cam_sima_testing
cacraigucar Jan 13, 2025
395fe91
Merge remote-tracking branch 'upstream/development' into cam_sima_tes…
cacraigucar Jan 16, 2025
b6c814d
Address reviewer comments
cacraigucar Jan 27, 2025
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
16 changes: 13 additions & 3 deletions cime_config/atm_in_paramgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,11 +1495,21 @@ 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"] #.strip()

#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

#If no value is set then move to the next variable:
#if val is None:
# continue
#End if

#Extract variable type:
Expand Down
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
2 changes: 1 addition & 1 deletion 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 = index_of_pressure_at_troposphere_cloud_top
units = index
type = integer
dimensions = ()
Expand Down
71 changes: 71 additions & 0 deletions src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -491,5 +491,76 @@
<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 -->
<!-- Note that no_deep_pbl defaults to false, but needs to be set to true for diag_TKE or UW schemes -->
<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="delt"
standard_name="half_timestep_for_physics"
units="s" type="real" kind="kind_phys">
</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"
Copy link
Member

Choose a reason for hiding this comment

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

Could I ask why the local name in SIMA is set to ql instead of icwmrdp as in the snapshot? I was not totally sure that icwmrdp corresponds exactly to ql since there is a icwmrsh which is the shallow convection equivalent, but I couldn't find a clear definition of the ql in the current CAM's state to be sure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The simple answer is that that is what the initial developer (whoever that was) used it in their code. Inside zm_convr_intr.F90 which resides in ESCOMP/CAM, there is a pbuf call call pbuf_get_field(pbuf, icwmrdp_idx, ql ). That links the two variable names together.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed as requested

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"
Copy link
Member

Choose a reason for hiding this comment

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

Same question about the choice of the local name dpdry here (which usually implies contiguous, non-gathered dry delta-p layer thickness?) It appears the CCPP standard names spreadsheet calls this fake_dpdry. Since this is convective gathered columns maybe the naming could be clear that this is related to convection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Again, this name is from the original developer and comes from ESCOMP/CAM zm_conv_intr.F90. The dpdry name is used both as a value which has meaning and a fake_dpdry. The time that dpdry has a value, it gets it from: dpdry(i,:) = state%pdeldry(ideep(i),:)/100._r8

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @cacraigucar. I don't think a change would need to be made in ESCOMP/CAM nor in the scheme to rename these in SIMA registry.

The "link" of these variables to CAM snapshots is through <ic_file_input_names>. The link to the CCPP schemes themselves is through the standard name.
I think the local_name here is only used for when these variables are USEd through the physics_types object.

To confirm this, I renamed ql and dpdry in src/data/registry.xml to icwmrdp and dpdry_ideep and built CAM-SIMA with ZM, and was able to get the same results as before the renaming - so I believe changing the local_name here won't affect anything else.

I am concerned that names that are too specific (in the case of ql/icwmrdp here, it is specific to deep convection: _due_to_deep_convection; for dpdry, it is for gathered columns: _for_deep_convection_for_gathered_convective_columns) are being given generic names (ql and dpdry) that otherwise have meanings outside of deep convection. The naming here (in the registry) applies across CAM-SIMA and not just within the ZM scheme, so I'd like to advocate for not using generic names but populating them with scheme-specific data.

Sorry for insisting on this, I'm happy to discuss further!

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jimmielin @cacraigucar

I lean towards @jimmielin 's approach here. These names are only used in the generated code in SIMA and the caps, so an update to atmospheric_physics wouldn't be necessary. And if there's a way to make them a little clearer so someone down the line doesn't think "hey, I need something called dpdry, i'll just use this standard name here in the registry", I think it'd be worth it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the two names as requested

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>
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.)
jimmielin marked this conversation as resolved.
Show resolved Hide resolved
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
Loading