Skip to content

Commit

Permalink
Replace 'molec_weight' with 'molar_mass', as it is likely a more accu…
Browse files Browse the repository at this point in the history
…rate term.
  • Loading branch information
nusbaume committed Jan 12, 2024
1 parent 7f3e7da commit 76fb682
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
58 changes: 29 additions & 29 deletions src/ccpp_constituent_prop_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ module ccpp_constituent_prop_mod
integer, private :: const_water = int_unassigned
! minimum_mr is the minimum allowed value (default zero)
real(kind_phys), private :: min_val = 0.0_kind_phys
! molar_mass is the molecular weight of the constituent (kg mol-1)
real(kind_phys), private :: molar_mass = kphys_unassigned
! molar_mass_val is the molar mass of the constituent (kg mol-1)
real(kind_phys), private :: molar_mass_val = kphys_unassigned
! default_value is the default value that the constituent array will be
! initialized to
real(kind_phys), private :: const_default_value = kphys_unassigned
Expand All @@ -73,7 +73,7 @@ module ccpp_constituent_prop_mod
procedure :: is_moist => ccp_is_moist
procedure :: is_wet => ccp_is_wet
procedure :: minimum => ccp_min_val
procedure :: molec_weight => ccp_molec_weight
procedure :: molar_mass => ccp_molar_mass
procedure :: default_value => ccp_default_value
procedure :: has_default => ccp_has_default
! Copy method (be sure to update this anytime fields are added)
Expand All @@ -86,7 +86,7 @@ module ccpp_constituent_prop_mod
procedure :: set_thermo_active => ccp_set_thermo_active
procedure :: set_water_species => ccp_set_water_species
procedure :: set_minimum => ccp_set_min_val
procedure :: set_molec_weight => ccp_set_molec_weight
procedure :: set_molar_mass => ccp_set_molar_mass
end type ccpp_constituent_properties_t

!! \section arg_table_ccpp_constituent_prop_ptr_t
Expand All @@ -113,18 +113,18 @@ module ccpp_constituent_prop_mod
procedure :: is_moist => ccpt_is_moist
procedure :: is_wet => ccpt_is_wet
procedure :: minimum => ccpt_min_val
procedure :: molec_weight => ccpt_molec_weight
procedure :: molar_mass => ccpt_molar_mass
procedure :: default_value => ccpt_default_value
procedure :: has_default => ccpt_has_default
! ccpt_set: Set the internal pointer
procedure :: set => ccpt_set
procedure :: set => ccpt_set
! Methods that change state (XXgoldyXX: make private?)
procedure :: deallocate => ccpt_deallocate
procedure :: set_const_index => ccpt_set_const_index
procedure :: set_thermo_active => ccpt_set_thermo_active
procedure :: set_water_species => ccpt_set_water_species
procedure :: set_minimum => ccpt_set_min_val
procedure :: set_molec_weight => ccpt_set_molec_weight
procedure :: set_molar_mass => ccpt_set_molar_mass
end type ccpp_constituent_prop_ptr_t

!! \section arg_table_ccpp_model_constituents_t
Expand Down Expand Up @@ -219,7 +219,7 @@ subroutine copyConstituent(outConst, inConst)
outConst%const_water = inConst%const_water
outConst%min_val = inConst%min_val
outConst%const_default_value = inConst%const_default_value
outConst%molar_mass = inConst%molar_mass
outConst%molar_mass_val = inConst%molar_mass_val
outConst%thermo_active = inConst%thermo_active
outConst%water_species = inConst%water_species
end subroutine copyConstituent
Expand Down Expand Up @@ -379,7 +379,7 @@ end function ccp_is_instantiated
!#######################################################################

subroutine ccp_instantiate(this, std_name, long_name, units, vertical_dim, &
advected, default_value, min_value, molec_weight, errcode, errmsg)
advected, default_value, min_value, molar_mass, errcode, errmsg)
! Initialize all fields in <this>

! Dummy arguments
Expand All @@ -391,7 +391,7 @@ subroutine ccp_instantiate(this, std_name, long_name, units, vertical_dim, &
logical, optional, intent(in) :: advected
real(kind_phys), optional, intent(in) :: default_value
real(kind_phys), optional, intent(in) :: min_value
real(kind_phys), optional, intent(in) :: molec_weight
real(kind_phys), optional, intent(in) :: molar_mass
integer, intent(out) :: errcode
character(len=*), intent(out) :: errmsg

Expand Down Expand Up @@ -419,8 +419,8 @@ subroutine ccp_instantiate(this, std_name, long_name, units, vertical_dim, &
if (present(min_value)) then
this%min_val = min_value
end if
if (present(molec_weight)) then
this%molar_mass = molec_weight
if (present(molar_mass)) then
this%molar_mass_val = molar_mass
end if
end if
if (errcode == 0) then
Expand Down Expand Up @@ -733,7 +733,7 @@ subroutine ccp_is_equivalent(this, oconst, equiv, errcode, errmsg)
(this%advected .eqv. oconst%advected) .and. &
(this%const_default_value == oconst%const_default_value) .and. &
(this%min_val == oconst%min_val) .and. &
(this%molar_mass == oconst%molar_mass) .and. &
(this%molar_mass_val == oconst%molar_mass_val) .and. &
(this%thermo_active .eqv. oconst%thermo_active) .and. &
(this%water_species .eqv. oconst%water_species)
else
Expand Down Expand Up @@ -887,7 +887,7 @@ end subroutine ccp_set_min_val

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

subroutine ccp_molec_weight(this, val_out, errcode, errmsg)
subroutine ccp_molar_mass(this, val_out, errcode, errmsg)

! Dummy arguments
class(ccpp_constituent_properties_t), intent(in) :: this
Expand All @@ -896,28 +896,28 @@ subroutine ccp_molec_weight(this, val_out, errcode, errmsg)
character(len=*), intent(out) :: errmsg

if (this%is_instantiated(errcode, errmsg)) then
val_out = this%molar_mass
val_out = this%molar_mass_val
else
val_out = kphys_unassigned
end if

end subroutine ccp_molec_weight
end subroutine ccp_molar_mass

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

subroutine ccp_set_molec_weight(this, molec_weight, errcode, errmsg)
subroutine ccp_set_molar_mass(this, molar_mass, errcode, errmsg)

! Dummy arguments
class(ccpp_constituent_properties_t), intent(inout) :: this
real(kind_phys), intent(in) :: molec_weight
real(kind_phys), intent(in) :: molar_mass
integer, intent(out) :: errcode
character(len=*), intent(out) :: errmsg

if (this%is_instantiated(errcode, errmsg)) then
this%molar_mass = molec_weight
this%molar_mass_val = molar_mass
end if

end subroutine ccp_set_molec_weight
end subroutine ccp_set_molar_mass

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

Expand Down Expand Up @@ -2251,46 +2251,46 @@ end subroutine ccpt_set_min_val

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

subroutine ccpt_molec_weight(this, val_out, errcode, errmsg)
subroutine ccpt_molar_mass(this, val_out, errcode, errmsg)

! Dummy arguments
class(ccpp_constituent_prop_ptr_t), intent(in) :: this
real(kind_phys), intent(out) :: val_out
integer, intent(out) :: errcode
character(len=*), intent(out) :: errmsg
! Local variable
character(len=*), parameter :: subname = 'ccpt_molec_weight'
character(len=*), parameter :: subname = 'ccpt_molar_mass'

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

end subroutine ccpt_molec_weight
end subroutine ccpt_molar_mass

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

subroutine ccpt_set_molec_weight(this, molec_weight, errcode, errmsg)
subroutine ccpt_set_molar_mass(this, molar_mass, errcode, errmsg)

! Dummy arguments
class(ccpp_constituent_prop_ptr_t), intent(inout) :: this
real(kind_phys), intent(in) :: molec_weight
real(kind_phys), intent(in) :: molar_mass
integer, intent(out) :: errcode
character(len=*), intent(out) :: errmsg
! Local variable
character(len=*), parameter :: subname = 'ccpt_set_molec_weight'
character(len=*), parameter :: subname = 'ccpt_set_molar_mass'

if (associated(this%prop)) then
call this%prop%set_molec_weight(molec_weight, errcode, errmsg)
call this%prop%set_molar_mass(molar_mass, errcode, errmsg)
else
call set_errvars(1, subname//": invalid constituent pointer", &
errcode=errcode, errmsg=errmsg)
end if

end subroutine ccpt_set_molec_weight
end subroutine ccpt_set_molar_mass

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

Expand Down
12 changes: 6 additions & 6 deletions test/advection_test/test_host.F90
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ subroutine test_host(retval, test_suites)
call host_constituents(1)%instantiate(std_name="specific_humidity", &
long_name="Specific humidity", units="kg kg-1", &
vertical_dim="vertical_layer_dimension", advected=.true., &
min_value=1000._kind_phys, molec_weight=2000._kind_phys, &
min_value=1000._kind_phys, molar_mass=2000._kind_phys, &
errcode=errflg, errmsg=errmsg)
call check_errflg(subname//'.initialize', errflg, errmsg, errflg_final)
if (errflg == 0) then
Expand Down Expand Up @@ -543,7 +543,7 @@ subroutine test_host(retval, test_suites)

!Check that a constituent instantiated with a specified molecular
!weight actually contains that molecular weight property value:
call const_props(index)%molec_weight(check_value, errflg, errmsg)
call const_props(index)%molar_mass(check_value, errflg, errmsg)
if (errflg /= 0) then
write(6, '(a,i0,a,a,i0,/,a)') "ERROR: Error, ", errflg, " trying ", &
"to get molecular weight for specific humidity index = ", &
Expand All @@ -552,7 +552,7 @@ subroutine test_host(retval, test_suites)
end if
if (errflg == 0) then
if (check_value /= 2000._kind_phys) then !Should be 2000
write(6, *) "ERROR: 'molec_weight' should give a value of 2000 ", &
write(6, *) "ERROR: 'molar_mass' should give a value of 2000 ", &
"for specific humidity, as was set during instantiation."
errflg_final = -1 !Notify test script that a failure occured
end if
Expand All @@ -563,7 +563,7 @@ subroutine test_host(retval, test_suites)

!Check that setting a constituent's molecular weight works
!as expected:
call const_props(index_ice)%set_molec_weight(1._kind_phys, errflg, &
call const_props(index_ice)%set_molar_mass(1._kind_phys, errflg, &
errmsg)
if (errflg /= 0) then
write(6, '(a,i0,a,a,i0,/,a)') "ERROR: Error, ", errflg, " trying ", &
Expand All @@ -572,7 +572,7 @@ subroutine test_host(retval, test_suites)
errflg_final = -1 !Notify test script that a failure occurred
end if
if (errflg == 0) then
call const_props(index_ice)%molec_weight(check_value, errflg, errmsg)
call const_props(index_ice)%molar_mass(check_value, errflg, errmsg)
if (errflg /= 0) then
write(6, '(a,i0,a,i0,/,a)') "ERROR: Error, ", errflg, &
" trying to get molecular weight for cld_ice index = ", &
Expand All @@ -582,7 +582,7 @@ subroutine test_host(retval, test_suites)
end if
if (errflg == 0) then
if (check_value /= 1._kind_phys) then !Should be equal to one
write(6, *) "ERROR: 'set_molec_weight' did not set constituent", &
write(6, *) "ERROR: 'set_molar_mass' did not set constituent", &
" molecular weight value correctly."
errflg_final = -1 !Notify test script that a failure occurred
end if
Expand Down

0 comments on commit 76fb682

Please sign in to comment.