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

Complete Zhang McFarlane conversion to CCPP #186

Merged
merged 57 commits into from
Jan 24, 2025

Conversation

cacraigucar
Copy link
Collaborator

@cacraigucar cacraigucar commented Dec 24, 2024

Originator(s): Cheryl Craig

Tag: atmos_phys0_08_000

Summary (include the keyword ['closes', 'fixes', 'resolves'] and issue number):
Add ccpp'ized ZM - closes #66

Describe any changes made to the namelist:
A schemes/zhang_mcfarlane/zm_convr_namelist.xml
- namelist template for ZM

List all files eliminated and why: N/A

List all files added and what they do:
A schemes/cloud_fraction/cloud_fraction_fice.F90
A schemes/cloud_fraction/cloud_fraction_fice.meta
- Bring in the cloud_fraction_fice portion of the cloud_fraction CAM code and CCPP'ize it

A schemes/sima_diagnostics/zm_diagnostics.F90
A schemes/sima_diagnostics/zm_diagnostics.meta
- Add the main ZM diagnostics

A schemes/sima_diagnostics/zm_convr_tendency_diagnostics.F90
A schemes/sima_diagnostics/zm_convr_tendency_diagnostics.meta
A schemes/sima_diagnostics/zm_evap_tendency_diagnostics.F90
A schemes/sima_diagnostics/zm_evap_tendency_diagnostics.meta
A schemes/sima_diagnostics/zm_momtran_tendency_diagnostics.F90
A schemes/sima_diagnostics/zm_momtran_tendency_diagnostics.meta
A schemes/sima_diagnostics/zm_tendency_diagnostics.F90
A schemes/sima_diagnostics/zm_tendency_diagnostics.meta
- Add ZM tendency diagnostics for each ZM component

A schemes/utilities/to_be_ccppized_temporary.F90
A schemes/utilities/to_be_ccppized_temporary.meta
- Add a temporary routine to house init methods which aren't being run with to_be_ccppized code.
- Add a call to wv_sat_init

A schemes/zhang_mcfarlane/set_deep_conv_fluxes_to_general.F90
A schemes/zhang_mcfarlane/set_deep_conv_fluxes_to_general.meta
A schemes/zhang_mcfarlane/set_general_conv_fluxes_to_deep.F90
A schemes/zhang_mcfarlane/set_general_conv_fluxes_to_deep.meta
- Add interstitials to move variables back and forth from the ZM deep variables to general variables for the ZM routine which is used in shallow convection as well

A test/test_suites/suite_zhang_mcfarlane.xml
- Suite to test ZM

A to_be_ccppized/error_messages.F90
A to_be_ccppized/namelist_utils.F90
A to_be_ccppized/wv_sat_methods.F90
A to_be_ccppized/wv_saturation.F90
- Add methods which ZM requires, but are not being CCPP-ized at this point in time

List all existing files that have been modified, and describe the changes:
(Helpful git command: git diff --name-status development...<your_branch_name>)
M doc/ChangeLog
M doc/NamesNotInDictionary.txt
- updated with ZM names

M schemes/zhang_mcfarlane/zm_conv_convtran.F90
M schemes/zhang_mcfarlane/zm_conv_convtran.meta
M schemes/zhang_mcfarlane/zm_conv_evap.F90
M schemes/zhang_mcfarlane/zm_conv_evap.meta
M schemes/zhang_mcfarlane/zm_conv_momtran.F90
M schemes/zhang_mcfarlane/zm_conv_momtran.meta
M schemes/zhang_mcfarlane/zm_convr.F90
M schemes/zhang_mcfarlane/zm_convr.meta
- Further refinements needed to CCPP'ize ZM

M suites/suite_cam7.xml
- Add ZM routines to CAM7

List any test failures:

Is this a science-changing update? New physics package, algorithm change, tuning changes, etc?
- CCPP'ized ZM which was a package which already existed in CAM

cacraigucar and others added 30 commits May 17, 2024 11:52
Pull ZM 0.5 timestep removal into main
Remove 0.5*timestop logic from all to zm

Register species from MICM
Replace original, locally-developed license with Apache 2.0 license.
Bring in development ESCOMP#108 (TUV-x) ESCOMP#112 (tropopause_find) to main
Bring in new directory structure from development
Copy link
Collaborator Author

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

I believe I have addressed all of @peverwhee's comments, but I may have missed one

schemes/zhang_mcfarlane/zm_convr.F90 Outdated Show resolved Hide resolved
schemes/zhang_mcfarlane/zm_conv_momtran.F90 Outdated Show resolved Hide resolved
schemes/zhang_mcfarlane/zm_conv_evap.F90 Outdated Show resolved Hide resolved
schemes/zhang_mcfarlane/zm_conv_evap.F90 Outdated Show resolved Hide resolved
schemes/sima_diagnostics/zm_diagnostics.F90 Outdated Show resolved Hide resolved
schemes/sima_diagnostics/zm_diagnostics.F90 Outdated Show resolved Hide resolved
schemes/zhang_mcfarlane/zm_conv_evap.meta Show resolved Hide resolved
Comment on lines 213 to 219

work2 = max(fsnow_conv(i,k), work1)
if (snowmlt(i).gt.0._kind_phys) work2 = 0._kind_phys
ntsnprd(i,k) = prdprec(i,k)*work2 - evpsnow(i) - snowmlt(i)
tend_s_snwprd (i,k) = prdprec(i,k)*work2*latice
ntsnprd(i,k) = prdprec_gen(i,k)*work2 - evpsnow(i) - snowmlt(i)
tend_s_snwprd (i,k) = prdprec_gen(i,k)*work2*latice
tend_s_snwevmlt(i,k) = - ( evpsnow(i) + snowmlt(i) )*latice
else
ntsnprd(i,k) = prdsnow(i,k) - min(flxsnow(i,k)*gravit/pdel(i,k), evpsnow(i)+snowmlt(i))
tend_s_snwprd (i,k) = prdsnow(i,k)*latice
tend_s_snwevmlt(i,k) = -min(flxsnow(i,k)*gravit/pdel(i,k), evpsnow(i)+snowmlt(i) )*latice
end if
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I asked Rich Neale about this, but he has not responded. Since this could fit under "code cleanup", I am inclined to leave it. Also, ZM may be having some science changes coming in, so we could bring that up when that PR comes along.

@@ -192,7 +176,7 @@ subroutine zm_conv_evap_run(ncol, pver, pverp, &
evplimit = min(evplimit, flxprec(i,k) * gravit / pdel(i,k))

! Total evaporation cannot exceed input precipitation
evplimit = min(evplimit, (prec(i) - evpvint(i)) * gravit / pdel(i,k))
evplimit = min(evplimit, (prec_gen(i) - evpvint(i)) * gravit / pdel(i,k))

evpprec(i) = min(evplimit, evpprec(i))
if( .not.old_snow ) then
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See response on other old_snow comment

@cacraigucar cacraigucar requested a review from peverwhee January 14, 2025 23:26
schemes/zhang_mcfarlane/zm_conv_convtran.meta Outdated Show resolved Hide resolved
Comment on lines 213 to 219

work2 = max(fsnow_conv(i,k), work1)
if (snowmlt(i).gt.0._kind_phys) work2 = 0._kind_phys
ntsnprd(i,k) = prdprec(i,k)*work2 - evpsnow(i) - snowmlt(i)
tend_s_snwprd (i,k) = prdprec(i,k)*work2*latice
ntsnprd(i,k) = prdprec_gen(i,k)*work2 - evpsnow(i) - snowmlt(i)
tend_s_snwprd (i,k) = prdprec_gen(i,k)*work2*latice
tend_s_snwevmlt(i,k) = - ( evpsnow(i) + snowmlt(i) )*latice
else
ntsnprd(i,k) = prdsnow(i,k) - min(flxsnow(i,k)*gravit/pdel(i,k), evpsnow(i)+snowmlt(i))
tend_s_snwprd (i,k) = prdsnow(i,k)*latice
tend_s_snwevmlt(i,k) = -min(flxsnow(i,k)*gravit/pdel(i,k), evpsnow(i)+snowmlt(i) )*latice
end if
Copy link
Collaborator

@peverwhee peverwhee Jan 16, 2025

Choose a reason for hiding this comment

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

ok! I guess I'd like to be sure we haven't lost functionality in CAM with this PR? since there used to be a way to make old_snow=.false. (by passing in prdsnow)

Copy link
Collaborator

@peverwhee peverwhee left a comment

Choose a reason for hiding this comment

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

a couple lingering things

schemes/zhang_mcfarlane/zm_convr.meta Show resolved Hide resolved
schemes/sima_diagnostics/zm_diagnostics.meta Outdated Show resolved Hide resolved
@cacraigucar cacraigucar requested a review from peverwhee January 17, 2025 19:44
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Great work @cacraigucar! I do have some change requests, but hopefully they are all minor (and of course please let me know if you have any concerns with anything I suggested). Thanks!

schemes/cloud_fraction/cloud_fraction_fice.F90 Outdated Show resolved Hide resolved
schemes/cloud_fraction/cloud_fraction_fice.meta Outdated Show resolved Hide resolved
schemes/sima_diagnostics/zm_convr_tendency_diagnostics.F90 Outdated Show resolved Hide resolved
schemes/sima_diagnostics/zm_diagnostics.F90 Show resolved Hide resolved
to_be_ccppized/units.F90 Outdated Show resolved Hide resolved
to_be_ccppized/wv_saturation.F90 Outdated Show resolved Hide resolved
suites/suite_zhang_mcfarlane.xml Outdated Show resolved Hide resolved
<scheme>qneg</scheme>
<scheme>geopotential_temp</scheme>
<scheme>zm_diagnostics</scheme>

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 we need to add another set of check_energy calls after the ZM block here:

Suggested change
<!-- Check that energy and water changes match the boundary fluxes -->
<scheme>check_energy_scaling</scheme>
<scheme>check_energy_chng</scheme>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

Copy link
Member

@jimmielin jimmielin Jan 22, 2025

Choose a reason for hiding this comment

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

Thanks @nusbaume, also wanted to add that before running the ZM scheme, the following should be called to zero the inputs to check_energy_chng:

<scheme>check_energy_zero_fluxes</scheme>

Some inputs need to be provided to check_energy_chng to actually check the energy changes match the boundary fluxes.

Based on physpkg.F90 calls to check_energy_chng after convect_deep_tend:

    ! Check energy integrals, including "reserved liquid"
    flx_cnd(:ncol) = prec_dp(:ncol) + rliq(:ncol)
    snow_dp(:ncol) = snow_dp(:ncol) + rice(:ncol)
    call check_energy_cam_chng(state, tend, "convect_deep", nstep, ztodt, zero, flx_cnd, snow_dp, zero)
    snow_dp(:ncol) = snow_dp(:ncol) - rice(:ncol)

the following inputs need to be provided (as an output from the ZM scheme):

  • scheme_name = "convect_deep"
  • net_liquid_and_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column ("flx_cnd" in check_energy_chng) = prec_dp(:ncol) + rliq(:ncol)
  • net_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column ("flx_ice" in check_energy_chng; I don't like how the above code is recycling snow_dp there simply for calling check_energy_cam_chng) = snow_dp(:ncol) + rice(:ncol)

I realized I have to make the same changes for the shallow convection. Here is how I added these fluxes for my scheme: jimmielin@8c9b103

It looks like snow_dp comes from zm_conv_evap, so that needs to be provided in the interstitial that renames general to deep. But in the case of ZM, rice has to be added on top of it. Maybe pass net_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column into both the scheme that computes rice then add snow_dp on top of it in the interstitial.

Or if this is too much work feel free to open an issue? I can add this since I made check_energy_chng so I am the person to blame 😃

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jimmielin - can we open this as a new issue? I have converted ZM, and we can make convect_deep with its additional features a new PR? I'm literally on my last edits and I want to avoid feature creep (and missing deadlines)

Copy link
Member

Choose a reason for hiding this comment

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

@cacraigucar agreed, I am happy to defer this to the future - I can work on this as an example of how check_energy_chng is called as I didn't have a good example to work with when I converted it.

Added issue #192

Copy link
Collaborator

Choose a reason for hiding this comment

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

This all sounds like a good plan to me! I'm keeping this open so we can find it if need be, but feel free to consider it "resolved" for this PR. Thanks!

Originator(s): cacraig
Date: Dec 24, 2024
One-line Summary: Complete Zhang McFarlane conversion to CCPP
Github PR URL:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just adding a reminder to finish the ChangeLog or add the same info to the PR description before merging.

Copy link
Collaborator Author

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

@nusbaume - Let me know what you think about the few areas where I made some compromises and have questions for you.

schemes/cloud_fraction/cloud_fraction_fice.F90 Outdated Show resolved Hide resolved
schemes/sima_diagnostics/zm_convr_tendency_diagnostics.F90 Outdated Show resolved Hide resolved
schemes/sima_diagnostics/zm_convr_tendency_diagnostics.F90 Outdated Show resolved Hide resolved
schemes/sima_diagnostics/zm_diagnostics.F90 Outdated Show resolved Hide resolved
schemes/cloud_fraction/cloud_fraction_fice.meta Outdated Show resolved Hide resolved
<scheme>qneg</scheme>
<scheme>geopotential_temp</scheme>
<scheme>zm_diagnostics</scheme>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

suites/suite_zhang_mcfarlane.xml Outdated Show resolved Hide resolved
<scheme>qneg</scheme>
<scheme>geopotential_temp</scheme>
<scheme>zm_diagnostics</scheme>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jimmielin - can we open this as a new issue? I have converted ZM, and we can make convect_deep with its additional features a new PR? I'm literally on my last edits and I want to avoid feature creep (and missing deadlines)

to_be_ccppized/units.F90 Outdated Show resolved Hide resolved
Copy link
Collaborator

@peverwhee peverwhee left a comment

Choose a reason for hiding this comment

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

thanks @cacraigucar !

schemes/zhang_mcfarlane/zm_conv_evap.F90 Outdated Show resolved Hide resolved
to_be_ccppized/units.F90 Outdated Show resolved Hide resolved
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Getting much closer! Just some missed changes from the previous review along with one comment change request. Thanks!

Copy link
Collaborator Author

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

I'd forgotten to push my last set of changes last night... sigh. Could you please resolve the issues that were in that push, so I can see what is left? Also, I am still looking into the to_be_ccppized_temporary

schemes/zhang_mcfarlane/zm_conv_evap.F90 Outdated Show resolved Hide resolved
@cacraigucar cacraigucar requested a review from nusbaume January 23, 2025 17:22
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Almost there! Just two missed requests from earlier.

schemes/zhang_mcfarlane/zm_conv_evap.F90 Show resolved Hide resolved
schemes/sima_diagnostics/zm_diagnostics.F90 Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

Next try - there are still some unresolved conversations, but they are for things I remember doing, so I think they are in there.

@@ -0,0 +1,29 @@
module to_be_ccppized_temporary
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, it turns out that it is at the top of both the suite_zhang_mcfarlane.xml as well as the top of the ZM section in the CAM7 suite. So it is being tested - I just missed seeing it in my scanning of the files.

schemes/sima_diagnostics/zm_diagnostics.F90 Outdated Show resolved Hide resolved
schemes/zhang_mcfarlane/zm_conv_evap.F90 Show resolved Hide resolved
@cacraigucar cacraigucar requested a review from nusbaume January 23, 2025 18:44
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Looks great to me now, thanks @cacraigucar!

@cacraigucar cacraigucar merged commit fb23338 into ESCOMP:development Jan 24, 2025
3 checks passed
cacraigucar added a commit that referenced this pull request Jan 27, 2025
Tag: atmos_phys0_08_000

Use new constituent tendency updater in cam7 SDF #188 
MUSICA TUVX scheme: create aerosol radiator, set_aerosol_optics_values
#182
Set gas-species profiles in TUV-x and map indices between constituents
and MICM #184
Complete Zhang McFarlane conversion to CCPP #186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ccpp'ized ZM
5 participants