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

Merge development into main for ZM #194

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
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
24 changes: 20 additions & 4 deletions schemes/musica/micm/musica_ccpp_micm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ module musica_ccpp_micm

!> Registers MICM constituent properties with the CCPP
subroutine micm_register(solver_type, number_of_grid_cells, constituent_props, &
errmsg, errcode)
micm_species, errmsg, errcode)
use ccpp_constituent_prop_mod, only: ccpp_constituent_properties_t
use musica_micm, only: Rosenbrock, RosenbrockStandardOrder
use musica_ccpp_species, only: musica_species_t
use musica_util, only: error_t
use iso_c_binding, only: c_int

integer(c_int), intent(in) :: solver_type
integer(c_int), intent(in) :: number_of_grid_cells
type(ccpp_constituent_properties_t), allocatable, intent(out) :: constituent_props(:)
type(musica_species_t), allocatable, intent(out) :: micm_species(:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errcode

Expand All @@ -36,6 +37,7 @@ subroutine micm_register(solver_type, number_of_grid_cells, constituent_props, &
real(kind=kind_phys) :: molar_mass
character(len=:), allocatable :: species_name
logical :: is_advected
integer :: number_of_species
integer :: i, species_index

if (associated( micm )) then
Expand All @@ -46,13 +48,20 @@ subroutine micm_register(solver_type, number_of_grid_cells, constituent_props, &
number_of_grid_cells, error)
if (has_error_occurred(error, errmsg, errcode)) return

allocate(constituent_props(micm%species_ordering%size()), stat=errcode)
number_of_species = micm%species_ordering%size()
allocate(constituent_props(number_of_species), stat=errcode)
if (errcode /= 0) then
errmsg = "[MUSICA Error] Failed to allocate memory for constituent properties."
return
end if

do i = 1, micm%species_ordering%size()
allocate(micm_species(number_of_species), stat=errcode)
if (errcode /= 0) then
errmsg = "[MUSICA Error] Failed to allocate memory for micm species."
return
end if

do i = 1, number_of_species
associate( map => micm%species_ordering )
species_name = map%name(i)
species_index = map%index(i)
Expand All @@ -78,6 +87,13 @@ subroutine micm_register(solver_type, number_of_grid_cells, constituent_props, &
errcode = errcode, &
errmsg = errmsg)
if (errcode /= 0) return

! Species are ordered to match the sequence of the MICM state array
micm_species(species_index) = musica_species_t( &
name = species_name, &
unit = 'kg kg-1', &
molar_mass = molar_mass, &
index_musica_species = species_index )
end associate ! map
end do
number_of_rate_parameters = micm%user_defined_reaction_rates%size()
Expand Down
Loading
Loading