Skip to content

Commit

Permalink
Complete Zhang McFarlane conversion to CCPP (#186)
Browse files Browse the repository at this point in the history
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

---------

Co-authored-by: Jesse Nusbaumer <[email protected]>
Co-authored-by: Haipeng Lin <[email protected]>
Co-authored-by: mwaxmonsky <[email protected]>
  • Loading branch information
4 people authored Jan 24, 2025
1 parent e8a29b3 commit fb23338
Show file tree
Hide file tree
Showing 35 changed files with 4,977 additions and 711 deletions.
56 changes: 56 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@

===============================================================

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

This PR fixes the following NCAR/atmospheric_physics Github issues:
Add ccpp'ized ZM : https://github.com/ESCOMP/atmospheric_physics/issues/66

Code reviewed by:

List all existing files that have been added (A), modified (M), or deleted (D),
and describe the changes:
A schemes/cloud_fraction/cloud_fraction_fice.F90
A schemes/cloud_fraction/cloud_fraction_fice.meta
A schemes/sima_diagnostics/zm_convr_tendency_diagnostics.F90
A schemes/sima_diagnostics/zm_convr_tendency_diagnostics.meta
A schemes/sima_diagnostics/zm_diagnostics.F90
A schemes/sima_diagnostics/zm_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
A schemes/utilities/to_be_ccppized_temporary.F90
A schemes/utilities/to_be_ccppized_temporary.meta
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
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
A schemes/zhang_mcfarlane/zm_convr_namelist.xml
A suites/suite_zhang_mcfarlane.xml
M test/test_schemes/initialize_constituents.F90
A to_be_ccppized/error_messages.F90
A to_be_ccppized/namelist_utils.F90
A to_be_ccppized/units.F90
A to_be_ccppized/wv_sat_methods.F90
A to_be_ccppized/wv_saturation.F90

List and Describe any test failures:

Summarize any changes to answers:

===============================================================
===============================================================

Tag name: atmos_phys0_07_000
Expand Down
429 changes: 255 additions & 174 deletions doc/NamesNotInDictionary.txt

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions schemes/cloud_fraction/cloud_fraction_fice.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
module cloud_fraction_fice

use ccpp_kinds, only: kind_phys
implicit none

contains

!================================================================================================

!===============================================================================
!> \section arg_table_cloud_fraction_fice_run Argument Table
!! \htmlinclude cloud_fraction_fice_run.html
!!
subroutine cloud_fraction_fice_run(ncol, t, tmelt, top_lev, pver, fice, fsnow)
!
! Compute the fraction of the total cloud water which is in ice phase.
! The fraction depends on temperature only.
! This is the form that was used for radiation, the code came from cldefr originally
!
! Author: B. A. Boville Sept 10, 2002
! modified: PJR 3/13/03 (added fsnow to ascribe snow production for convection )
!-----------------------------------------------------------------------

! Arguments
integer, intent(in) :: ncol ! number of active columns (count)
real(kind_phys), intent(in) :: t(:,:) ! temperature (K)
real(kind_phys), intent(in) :: tmelt ! freezing point of water (K)
integer, intent(in) :: top_lev ! Vertical layer index for highest layer with tropopheric clouds (index)
integer, intent(in) :: pver ! Number of vertical layers (count)

real(kind_phys), intent(out) :: fice(:,:) ! Fractional ice content within cloud
real(kind_phys), intent(out) :: fsnow(:,:) ! Fractional snow content for convection

! Local variables
real(kind_phys) :: tmax_fice ! max temperature for cloud ice formation
real(kind_phys) :: tmin_fice ! min temperature for cloud ice formation
real(kind_phys) :: tmax_fsnow ! max temperature for transition to convective snow
real(kind_phys) :: tmin_fsnow ! min temperature for transition to convective snow

integer :: i,k ! loop indexes

!-----------------------------------------------------------------------

tmax_fice = tmelt - 10._kind_phys ! max temperature for cloud ice formation
tmin_fice = tmax_fice - 30._kind_phys ! min temperature for cloud ice formation
tmax_fsnow = tmelt ! max temperature for transition to convective snow
tmin_fsnow = tmelt - 5._kind_phys ! min temperature for transition to convective snow

fice(:,:top_lev-1) = 0._kind_phys
fsnow(:,:top_lev-1) = 0._kind_phys

! Define fractional amount of cloud that is ice
do k=top_lev,pver
do i=1,ncol

! If warmer than tmax then water phase
if (t(i,k) > tmax_fice) then
fice(i,k) = 0.0_kind_phys

! If colder than tmin then ice phase
else if (t(i,k) < tmin_fice) then
fice(i,k) = 1.0_kind_phys

! Otherwise mixed phase, with ice fraction decreasing linearly from tmin to tmax
else
fice(i,k) =(tmax_fice - t(i,k)) / (tmax_fice - tmin_fice)
end if

! snow fraction partitioning

! If warmer than tmax then water phase
if (t(i,k) > tmax_fsnow) then
fsnow(i,k) = 0.0_kind_phys

! If colder than tmin then ice phase
else if (t(i,k) < tmin_fsnow) then
fsnow(i,k) = 1.0_kind_phys

! Otherwise mixed phase, with ice fraction decreasing linearly from tmin to tmax
else
fsnow(i,k) =(tmax_fsnow - t(i,k)) / (tmax_fsnow - tmin_fsnow)
end if

end do
end do

end subroutine cloud_fraction_fice_run

end module cloud_fraction_fice
49 changes: 49 additions & 0 deletions schemes/cloud_fraction/cloud_fraction_fice.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[ccpp-table-properties]
name = cloud_fraction_fice
type = scheme

[ccpp-arg-table]
name = cloud_fraction_fice_run
type = scheme
[ ncol ]
standard_name = horizontal_loop_extent
units = count
type = integer
dimensions = ()
intent = in
[ t ]
standard_name = air_temperature
units = K
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
intent = in
[ tmelt ]
standard_name = freezing_point_of_water
units = K
type = real | kind = kind_phys
dimensions = ()
intent = in
[ top_lev ]
standard_name = vertical_layer_index_of_troposphere_cloud_top
units = index
type = integer
dimensions = ()
intent = in
[ pver ]
standard_name = vertical_layer_dimension
units = count
type = integer
dimensions = ()
intent = in
[ fice ]
standard_name = mass_fraction_of_ice_content_within_stratiform_cloud
units = fraction
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
intent = out
[ fsnow ]
standard_name = mass_fraction_of_snow_content_within_stratiform_cloud
units = fraction
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
intent = out
68 changes: 68 additions & 0 deletions schemes/sima_diagnostics/zm_convr_tendency_diagnostics.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module zm_convr_tendency_diagnostics
use ccpp_kinds, only: kind_phys

implicit none
private
save

public :: zm_convr_tendency_diagnostics_init ! init routine
public :: zm_convr_tendency_diagnostics_run ! main routine

CONTAINS

!> \section arg_table_zm_convr_tendency_diagnostics_init Argument Table
!! \htmlinclude zm_convr_tendency_diagnostics_init.html
subroutine zm_convr_tendency_diagnostics_init(errmsg, errflg)
use cam_history, only: history_add_field
use cam_history_support, only: horiz_only

character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg

! Local variables:

errmsg = ''
errflg = 0

call history_add_field ('ZMDT', 'T tendency - Zhang-McFarlane moist convection', 'lev', 'avg', 'K s-1')
call history_add_field ('ZMDQ', 'Q tendency - Zhang-McFarlane moist convection', 'lev', 'avg', 'kg kg-1 s-1')

end subroutine zm_convr_tendency_diagnostics_init

!> \section arg_table_zm_convr_tendency_diagnostics_run Argument Table
!! \htmlinclude zm_convr_tendency_diagnostics_run.html
subroutine zm_convr_tendency_diagnostics_run(ncol, pver, cpair, heat, qtnd, errmsg, errflg)

use cam_history, only: history_out_field

!------------------------------------------------
! Input / output parameters
!------------------------------------------------
integer, intent(in) :: ncol
integer, intent(in) :: pver

real(kind_phys), intent(in) :: cpair
real(kind_phys), intent(in) :: heat(:,:)
real(kind_phys), intent(in) :: qtnd(:,:)

! CCPP error handling variables
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg


real(kind_phys) :: ftem(ncol,pver)

errmsg = ''
errflg = 0

ftem(:,:) = 0._kind_phys

ftem(:ncol,:pver) = heat(:ncol,:pver)/cpair
call history_out_field('ZMDT ', ftem)
call history_out_field('ZMDQ ', qtnd)

end subroutine zm_convr_tendency_diagnostics_run

!=======================================================================

end module zm_convr_tendency_diagnostics
70 changes: 70 additions & 0 deletions schemes/sima_diagnostics/zm_convr_tendency_diagnostics.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[ccpp-table-properties]
name = zm_convr_tendency_diagnostics
type = scheme

[ccpp-arg-table]
name = zm_convr_tendency_diagnostics_init
type = scheme
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = none
type = character | kind = len=512
dimensions = ()
intent = out
[ errflg ]
standard_name = ccpp_error_code
long_name = Error flag for error handling in CCPP
units = 1
type = integer
dimensions = ()
intent = out

[ccpp-arg-table]
name = zm_convr_tendency_diagnostics_run
type = scheme
[ ncol ]
standard_name = horizontal_loop_extent
units = count
type = integer
dimensions = ()
intent = in
[ pver ]
standard_name = vertical_layer_dimension
units = count
type = integer
dimensions = ()
intent = in
[ cpair ]
standard_name = specific_heat_of_dry_air_at_constant_pressure
units = J kg-1 K-1
type = real | kind = kind_phys
dimensions = ()
intent = in
[ heat ]
standard_name = tendency_of_dry_air_enthalpy_at_constant_pressure
units = J kg-1 s-1
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
intent = in
[ qtnd ]
standard_name = tendency_of_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water
units = kg kg-1 s-1
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
intent = in
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = none
type = character | kind = len=512
dimensions = ()
intent = out
[ errflg ]
standard_name = ccpp_error_code
long_name = Error flag for error handling in CCPP
units = 1
type = integer
dimensions = ()
intent = out

Loading

0 comments on commit fb23338

Please sign in to comment.