Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Courtney Peverley committed Aug 28, 2023
2 parents 48041d8 + 2e53d9e commit dc0402a
Show file tree
Hide file tree
Showing 11 changed files with 336 additions and 105 deletions.
2 changes: 1 addition & 1 deletion scripts/constituents.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ConstituentVarDict(VarDictionary):
allocation and support for these variables.
"""

__const_prop_array_name = "ccpp_constituent_array"
__const_prop_array_name = "ccpp_constituents"
__const_prop_init_name = "ccpp_constituents_initialized"
__const_prop_init_consts = "ccpp_create_constituent_array"
__constituent_type = "suite"
Expand Down
4 changes: 2 additions & 2 deletions scripts/host_cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def add_constituent_vars(cap, host_model, suite_list, run_env):
to create the dictionary.
"""
# First create a MetadataTable for the constituents DDT
stdname_layer = "ccpp_num_constituents"
stdname_layer = "number_of_ccpp_constituents"
horiz_dim = "horizontal_dimension"
vert_layer_dim = "vertical_layer_dimension"
vert_interface_dim = "vertical_interface_dimension"
Expand All @@ -232,7 +232,7 @@ def add_constituent_vars(cap, host_model, suite_list, run_env):
f" standard_name = {stdname_layer}",
" units = count", " dimensions = ()", " type = integer",
f"[ {array_layer} ]",
" standard_name = ccpp_constituent_array",
" standard_name = ccpp_constituents",
" units = none",
f" dimensions = ({horiz_dim}, {vert_layer_dim}, {stdname_layer})",
" type = real", " kind = kind_phys"]
Expand Down
142 changes: 125 additions & 17 deletions src/ccpp_constituent_prop_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module ccpp_constituent_prop_mod
character(len=:), private, allocatable :: vert_dim
integer, private :: const_ind = int_unassigned
logical, private :: advected = .false.
logical, private :: thermo_active = .false.
! While the quantities below can be derived from the standard name,
! this implementation avoids string searching in parameterizations
! const_type distinguishes mass, volume, and number conc. mixing ratios
Expand All @@ -61,6 +62,7 @@ module ccpp_constituent_prop_mod
procedure :: vertical_dimension => ccp_get_vertical_dimension
procedure :: const_index => ccp_const_index
procedure :: is_advected => ccp_is_advected
procedure :: is_thermo_active => ccp_is_thermo_active
procedure :: equivalent => ccp_is_equivalent
procedure :: is_mass_mixing_ratio => ccp_is_mass_mixing_ratio
procedure :: is_volume_mixing_ratio => ccp_is_volume_mixing_ratio
Expand All @@ -76,9 +78,10 @@ module ccpp_constituent_prop_mod
procedure :: copyConstituent
generic :: assignment(=) => copyConstituent
! Methods that change state (XXgoldyXX: make private?)
procedure :: instantiate => ccp_instantiate
procedure :: deallocate => ccp_deallocate
procedure :: set_const_index => ccp_set_const_index
procedure :: instantiate => ccp_instantiate
procedure :: deallocate => ccp_deallocate
procedure :: set_const_index => ccp_set_const_index
procedure :: set_thermo_active => ccp_set_thermo_active
end type ccpp_constituent_properties_t

!! \section arg_table_ccpp_constituent_prop_ptr_t
Expand All @@ -96,6 +99,7 @@ module ccpp_constituent_prop_mod
procedure :: vertical_dimension => ccpt_get_vertical_dimension
procedure :: const_index => ccpt_const_index
procedure :: is_advected => ccpt_is_advected
procedure :: is_thermo_active => ccpt_is_thermo_active
procedure :: is_mass_mixing_ratio => ccpt_is_mass_mixing_ratio
procedure :: is_volume_mixing_ratio => ccpt_is_volume_mixing_ratio
procedure :: is_number_concentration => ccpt_is_number_concentration
Expand All @@ -109,8 +113,9 @@ module ccpp_constituent_prop_mod
! ccpt_set: Set the internal pointer
procedure :: set => ccpt_set
! Methods that change state (XXgoldyXX: make private?)
procedure :: deallocate => ccpt_deallocate
procedure :: set_const_index => ccpt_set_const_index
procedure :: deallocate => ccpt_deallocate
procedure :: set_const_index => ccpt_set_const_index
procedure :: set_thermo_active => ccpt_set_thermo_active
end type ccpp_constituent_prop_ptr_t

!! \section arg_table_ccpp_model_constituents_t
Expand Down Expand Up @@ -596,6 +601,45 @@ end subroutine ccp_set_const_index

!#######################################################################

subroutine ccp_set_thermo_active(this, thermo_flag, errcode, errmsg)
! Set whether this constituent is thermodynamically active, which
! means that certain physics schemes will use this constitutent
! when calculating thermodynamic quantities (e.g. enthalpy).

! Dummy arguments
class(ccpp_constituent_properties_t), intent(inout) :: this
logical, intent(in) :: thermo_flag
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg

!Set thermodynamically active flag for this constituent:
if (this%is_instantiated(errcode, errmsg)) then
this%thermo_active = thermo_flag
end if

end subroutine ccp_set_thermo_active

!#######################################################################

subroutine ccp_is_thermo_active(this, val_out, errcode, errmsg)

! Dummy arguments
class(ccpp_constituent_properties_t), intent(in) :: this
logical, intent(out) :: val_out
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg

!If instantiated then check if constituent is
!thermodynamically active, otherwise return false:
if (this%is_instantiated(errcode, errmsg)) then
val_out = this%thermo_active
else
val_out = .false.
end if
end subroutine ccp_is_thermo_active

!#######################################################################

subroutine ccp_is_advected(this, val_out, errcode, errmsg)

! Dummy arguments
Expand Down Expand Up @@ -628,7 +672,8 @@ subroutine ccp_is_equivalent(this, oconst, equiv, errcode, errmsg)
(trim(this%var_long_name) == trim(oconst%var_long_name)) .and. &
(trim(this%vert_dim) == trim(oconst%vert_dim)) .and. &
(this%advected .eqv. oconst%advected) .and. &
(this%const_default_value == oconst%const_default_value)
(this%const_default_value == oconst%const_default_value) .and. &
(this%thermo_active .eqv. oconst%thermo_active)
else
equiv = .false.
end if
Expand Down Expand Up @@ -1339,8 +1384,8 @@ end subroutine ccp_model_const_reset

!########################################################################

logical function ccp_model_const_is_match(this, index, advected) &
result(is_match)
logical function ccp_model_const_is_match(this, index, advected, &
thermo_active) result(is_match)
! Return .true. iff the constituent at <index> matches a pattern
! Each (optional) property which is present represents something
! which is required as part of a match.
Expand All @@ -1351,6 +1396,7 @@ logical function ccp_model_const_is_match(this, index, advected) &
class(ccpp_model_constituents_t), intent(in) :: this
integer, intent(in) :: index
logical, optional, intent(in) :: advected
logical, optional, intent(in) :: thermo_active
! Local variable
logical :: check

Expand All @@ -1363,11 +1409,20 @@ logical function ccp_model_const_is_match(this, index, advected) &
end if
end if

if (present(thermo_active)) then
call this%const_metadata(index)%is_thermo_active(check)
if (thermo_active .neqv. check) then
is_match = .false.
end if
end if


end function ccp_model_const_is_match

!########################################################################

subroutine ccp_model_const_num_match(this, nmatch, advected, errcode, errmsg)
subroutine ccp_model_const_num_match(this, nmatch, advected, thermo_active, &
errcode, errmsg)
! Query number of constituents matching pattern
! Each (optional) property which is present represents something
! which is required as part of a match.
Expand All @@ -1377,6 +1432,7 @@ subroutine ccp_model_const_num_match(this, nmatch, advected, errcode, errmsg)
class(ccpp_model_constituents_t), intent(in) :: this
integer, intent(out) :: nmatch
logical, optional, intent(in) :: advected
logical, optional, intent(in) :: thermo_active
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
! Local variables
Expand All @@ -1386,7 +1442,7 @@ subroutine ccp_model_const_num_match(this, nmatch, advected, errcode, errmsg)
nmatch = 0
if (this%const_props_locked(errcode=errcode, errmsg=errmsg, warn_func=subname)) then
do index = 1, SIZE(this%const_metadata)
if (this%is_match(index, advected=advected)) then
if (this%is_match(index, advected=advected, thermo_active=thermo_active)) then
nmatch = nmatch + 1
end if
end do
Expand Down Expand Up @@ -1452,7 +1508,7 @@ end subroutine ccp_model_const_metadata
!########################################################################

subroutine ccp_model_const_copy_in_3d(this, const_array, advected, &
errcode, errmsg)
thermo_active, errcode, errmsg)
! Gather constituent fields matching pattern
! Each (optional) property which is present represents something
! which is required as part of a match.
Expand All @@ -1462,6 +1518,7 @@ subroutine ccp_model_const_copy_in_3d(this, const_array, advected, &
class(ccpp_model_constituents_t), intent(in) :: this
real(kind_phys), intent(out) :: const_array(:,:,:)
logical, optional, intent(in) :: advected
logical, optional, intent(in) :: thermo_active
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
! Local variables
Expand All @@ -1478,7 +1535,8 @@ subroutine ccp_model_const_copy_in_3d(this, const_array, advected, &
max_cind = SIZE(const_array, 3)
num_levels = SIZE(const_array, 2)
do index = 1, SIZE(this%const_metadata)
if (this%is_match(index, advected=advected)) then
if (this%is_match(index, advected=advected, &
thermo_active=thermo_active)) then
! See if we have room for another constituent
cindex = cindex + 1
if (cindex > max_cind) then
Expand Down Expand Up @@ -1527,7 +1585,7 @@ end subroutine ccp_model_const_copy_in_3d
!########################################################################

subroutine ccp_model_const_copy_out_3d(this, const_array, advected, &
errcode, errmsg)
thermo_active, errcode, errmsg)
! Update constituent fields matching pattern
! Each (optional) property which is present represents something
! which is required as part of a match.
Expand All @@ -1537,6 +1595,7 @@ subroutine ccp_model_const_copy_out_3d(this, const_array, advected, &
class(ccpp_model_constituents_t), intent(inout) :: this
real(kind_phys), intent(in) :: const_array(:,:,:)
logical, optional, intent(in) :: advected
logical, optional, intent(in) :: thermo_active
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
! Local variables
Expand All @@ -1553,7 +1612,8 @@ subroutine ccp_model_const_copy_out_3d(this, const_array, advected, &
max_cind = SIZE(const_array, 3)
num_levels = SIZE(const_array, 2)
do index = 1, SIZE(this%const_metadata)
if (this%is_match(index, advected=advected)) then
if (this%is_match(index, advected=advected, &
thermo_active=thermo_active)) then
! See if we have room for another constituent
cindex = cindex + 1
if (cindex > max_cind) then
Expand Down Expand Up @@ -1828,6 +1888,28 @@ end subroutine ccpt_const_index

!#######################################################################

subroutine ccpt_is_thermo_active(this, val_out, errcode, errmsg)

! Dummy arguments
class(ccpp_constituent_prop_ptr_t), intent(in) :: this
logical, intent(out) :: val_out
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
! Local variable
character(len=*), parameter :: subname = 'ccpt_is_thermo_active'

if (associated(this%prop)) then
call this%prop%is_thermo_active(val_out, errcode, errmsg)
else
val_out = .false.
call set_errvars(1, subname//": invalid constituent pointer", &
errcode=errcode, errmsg=errmsg)
end if

end subroutine ccpt_is_thermo_active

!#######################################################################

subroutine ccpt_is_advected(this, val_out, errcode, errmsg)

! Dummy arguments
Expand Down Expand Up @@ -2123,9 +2205,9 @@ subroutine ccpt_set_const_index(this, index, errcode, errmsg)

! Dummy arguments
class(ccpp_constituent_prop_ptr_t), intent(inout) :: this
integer, intent(in) :: index
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
integer, intent(in) :: index
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
! Local variable
character(len=*), parameter :: subname = 'ccpt_set_const_index'

Expand All @@ -2146,4 +2228,30 @@ subroutine ccpt_set_const_index(this, index, errcode, errmsg)

end subroutine ccpt_set_const_index

!#######################################################################

subroutine ccpt_set_thermo_active(this, thermo_flag, errcode, errmsg)
! Set whether this constituent is thermodynamically active, which
! means that certain physics schemes will use this constitutent
! when calculating thermodynamic quantities (e.g. enthalpy).

! Dummy arguments
class(ccpp_constituent_prop_ptr_t), intent(inout) :: this
logical, intent(in) :: thermo_flag
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
! Local variable
character(len=*), parameter :: subname = 'ccpt_set_thermo_active'

if (associated(this%prop)) then
if (this%prop%is_instantiated(errcode, errmsg)) then
this%prop%thermo_active = thermo_flag
end if
else
call set_errvars(1, subname//": invalid constituent pointer", &
errcode=errcode, errmsg=errmsg)
end if

end subroutine ccpt_set_thermo_active

end module ccpp_constituent_prop_mod
16 changes: 8 additions & 8 deletions src/ccpp_constituent_prop_mod.meta
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
name = ccpp_model_constituents_t
type = ddt
[ num_layer_vars ]
standard_name = ccpp_num_constituents
standard_name = number_of_ccpp_constituents
long_name = Number of constituents managed by CCPP Framework
units = count
dimensions = ()
type = integer
[ num_advected_vars ]
standard_name = ccpp_num_advected_constituents
standard_name = number_of_ccpp_advected_constituents
long_name = Number of advected constituents managed by CCPP Framework
units = count
dimensions = ()
type = integer
[ vars_layer ]
standard_name = ccpp_constituent_array
standard_name = ccpp_constituents
long_name = Array of constituents managed by CCPP Framework
units = none
state_variable = true
dimensions = (horizontal_dimension, vertical_layer_dimension, ccpp_num_constituents)
dimensions = (horizontal_dimension, vertical_layer_dimension, number_of_ccpp_constituents)
type = real | kind = kind_phys
[ const_metadata ]
standard_name = ccpp_constituent_properties_array
standard_name = ccpp_constituent_properties
units = None
type = ccpp_constituent_prop_ptr_t
dimensions = (ccpp_num_constituents)
dimensions = (number_of_ccpp_constituents)
[ vars_minvalue ]
standard_name = ccpp_constituent_array_minimum_values
standard_name = ccpp_constituent_minimum_values
units = kg kg-1
type = real | kind = kind_phys
dimensions = (ccpp_num_constituents)
dimensions = (number_of_ccpp_constituents)
protected = True
Loading

0 comments on commit dc0402a

Please sign in to comment.