Skip to content

Commit

Permalink
+Standardize input salinity units as "ppt"
Browse files Browse the repository at this point in the history
  Standardized the syntax for the units of salinities that are read via
get_param calls to be uniformly 'units="ppt"' or similar units for derivatives
with salinity.  The only exceptions are places where practical salinity is used
specifically, which occurs for several arguments in the MOM_EOS code.  All
answers are bitwise identical, but there are changes to a number of
MOM_parameter_doc files.
  • Loading branch information
Hallberg-NOAA authored and adcroft committed Dec 15, 2023
1 parent 7d334f8 commit 4e8fbe1
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 116 deletions.
2 changes: 1 addition & 1 deletion config_src/drivers/FMS_cap/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, wind_stagger)
endif
call get_param(param_file, mdl, "SPEAR_DTFREEZE_DS", CS%SPEAR_dTf_dS, &
"The derivative of the freezing temperature with salinity.", &
units="deg C PSU-1", default=-0.054, scale=US%degC_to_C*US%S_to_ppt, &
units="degC ppt-1", default=-0.054, scale=US%degC_to_C*US%S_to_ppt, &
do_not_log=.not.CS%trestore_SPEAR_ECDA)
call get_param(param_file, mdl, "RESTORE_FLUX_RHO", CS%rho_restore, &
"The density that is used to convert piston velocities into salt or heat "//&
Expand Down
8 changes: 4 additions & 4 deletions config_src/drivers/solo_driver/MOM_surface_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1907,19 +1907,19 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, tracer_flow_C
call get_param(param_file, mdl, "SST_NORTH", CS%T_north, &
"With buoy_config linear, the sea surface temperature "//&
"at the northern end of the domain toward which to "//&
"to restore.", units="deg C", default=0.0, scale=US%degC_to_C)
"to restore.", units="degC", default=0.0, scale=US%degC_to_C)
call get_param(param_file, mdl, "SST_SOUTH", CS%T_south, &
"With buoy_config linear, the sea surface temperature "//&
"at the southern end of the domain toward which to "//&
"to restore.", units="deg C", default=0.0, scale=US%degC_to_C)
"to restore.", units="degC", default=0.0, scale=US%degC_to_C)
call get_param(param_file, mdl, "SSS_NORTH", CS%S_north, &
"With buoy_config linear, the sea surface salinity "//&
"at the northern end of the domain toward which to "//&
"to restore.", units="PSU", default=35.0, scale=US%ppt_to_S)
"to restore.", units="ppt", default=35.0, scale=US%ppt_to_S)
call get_param(param_file, mdl, "SSS_SOUTH", CS%S_south, &
"With buoy_config linear, the sea surface salinity "//&
"at the southern end of the domain toward which to "//&
"to restore.", units="PSU", default=35.0, scale=US%ppt_to_S)
"to restore.", units="ppt", default=35.0, scale=US%ppt_to_S)
endif
call get_param(param_file, mdl, "RESTORE_FLUX_RHO", CS%rho_restore, &
"The density that is used to convert piston velocities into salt or heat "//&
Expand Down
30 changes: 15 additions & 15 deletions src/equation_of_state/MOM_EOS.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1517,8 +1517,8 @@ subroutine EOS_init(param_file, EOS, US)
"temperature.", units="kg m-3 K-1", default=-0.2)
call get_param(param_file, mdl, "DRHO_DS", EOS%dRho_dS, &
"When EQN_OF_STATE="//trim(EOS_LINEAR_STRING)//", "//&
"this is the partial derivative of density with "//&
"salinity.", units="kg m-3 PSU-1", default=0.8)
"this is the partial derivative of density with salinity.", &
units="kg m-3 ppt-1", default=0.8)
call EOS_manual_init(EOS, form_of_EOS=EOS_LINEAR, Rho_T0_S0=EOS%Rho_T0_S0, dRho_dT=EOS%dRho_dT, dRho_dS=EOS%dRho_dS)
endif
if (EOS%form_of_EOS == EOS_WRIGHT) then
Expand Down Expand Up @@ -1563,17 +1563,17 @@ subroutine EOS_init(param_file, EOS, US)
call get_param(param_file, mdl, "TFREEZE_S0_P0",EOS%TFr_S0_P0, &
"When TFREEZE_FORM="//trim(TFREEZE_LINEAR_STRING)//", "//&
"this is the freezing potential temperature at "//&
"S=0, P=0.", units="deg C", default=0.0)
"S=0, P=0.", units="degC", default=0.0)
call get_param(param_file, mdl, "DTFREEZE_DS",EOS%dTFr_dS, &
"When TFREEZE_FORM="//trim(TFREEZE_LINEAR_STRING)//", "//&
"this is the derivative of the freezing potential "//&
"temperature with salinity.", &
units="deg C PSU-1", default=-0.054)
units="degC ppt-1", default=-0.054)
call get_param(param_file, mdl, "DTFREEZE_DP",EOS%dTFr_dP, &
"When TFREEZE_FORM="//trim(TFREEZE_LINEAR_STRING)//", "//&
"this is the derivative of the freezing potential "//&
"temperature with pressure.", &
units="deg C Pa-1", default=0.0)
units="degC Pa-1", default=0.0)
endif

if ((EOS%form_of_EOS == EOS_TEOS10 .or. EOS%form_of_EOS == EOS_ROQUET_RHO .or. &
Expand Down Expand Up @@ -1694,7 +1694,7 @@ subroutine convert_temp_salt_for_TEOS10(T, S, HI, kd, mask_z, EOS)
type(EOS_type), intent(in) :: EOS !< Equation of state structure

real, parameter :: Sref_Sprac = (35.16504/35.0) ! The TEOS 10 conversion factor to go from
! practical salinity to reference salinity [nondim]
! practical salinity to reference salinity [PSU ppt-1]
integer :: i, j, k

if ((EOS%form_of_EOS /= EOS_TEOS10) .and. (EOS%form_of_EOS /= EOS_ROQUET_RHO) .and. &
Expand Down Expand Up @@ -1808,20 +1808,20 @@ end subroutine pot_temp_to_cons_temp
!! temperature uses this same scaling, but this can be replaced by the factor given by scale.
subroutine abs_saln_to_prac_saln(S, prSaln, EOS, dom, scale)
real, dimension(:), intent(in) :: S !< Absolute salinity [S ~> ppt]
real, dimension(:), intent(inout) :: prSaln !< Practical salinity [S ~> ppt]
real, dimension(:), intent(inout) :: prSaln !< Practical salinity [S ~> PSU]
type(EOS_type), intent(in) :: EOS !< Equation of state structure
integer, dimension(2), optional, intent(in) :: dom !< The domain of indices to work on, taking
!! into account that arrays start at 1.
real, optional, intent(in) :: scale !< A multiplicative factor by which to scale the output
!! practical in place of with scaling stored
!! practical salinities in place of with scaling stored
!! in EOS. A value of 1.0 returns salinities in [PSU],
!! while the default is equivalent to EOS%ppt_to_S.

! Local variables
real, dimension(size(S)) :: Sa ! Salinity converted to [ppt]
real :: S_scale ! A factor to convert practical salinity from ppt to the desired units [S ppt-1 ~> 1]
real :: S_scale ! A factor to convert practical salinity from ppt to the desired units [S PSU-1 ~> 1]
real, parameter :: Sprac_Sref = (35.0/35.16504) ! The TEOS 10 conversion factor to go from
! reference salinity to practical salinity [nondim]
! reference salinity to practical salinity [PSU ppt-1]
integer :: i, is, ie

if (present(dom)) then
Expand All @@ -1848,21 +1848,21 @@ end subroutine abs_saln_to_prac_saln
!! use the dimensionally rescaling as specified within the EOS type. The output potential
!! temperature uses this same scaling, but this can be replaced by the factor given by scale.
subroutine prac_saln_to_abs_saln(S, absSaln, EOS, dom, scale)
real, dimension(:), intent(in) :: S !< Practical salinity [S ~> ppt]
real, dimension(:), intent(in) :: S !< Practical salinity [S ~> PSU]
real, dimension(:), intent(inout) :: absSaln !< Absolute salinity [S ~> ppt]
type(EOS_type), intent(in) :: EOS !< Equation of state structure
integer, dimension(2), optional, intent(in) :: dom !< The domain of indices to work on, taking
!! into account that arrays start at 1.
real, optional, intent(in) :: scale !< A multiplicative factor by which to scale the output
!! practical in place of with scaling stored
!! in EOS. A value of 1.0 returns salinities in [PSU],
!! absolute salnities in place of with scaling stored
!! in EOS. A value of 1.0 returns salinities in [ppt],
!! while the default is equivalent to EOS%ppt_to_S.

! Local variables
real, dimension(size(S)) :: Sp ! Salinity converted to [ppt]
real :: S_scale ! A factor to convert practical salinity from ppt to the desired units [S ppt-1 ~> 1]
real :: S_scale ! A factor to convert absolute salinity from ppt to the desired units [S ppt-1 ~> 1]
real, parameter :: Sref_Sprac = (35.16504/35.0) ! The TEOS 10 conversion factor to go from
! practical salinity to reference salinity [nondim]
! practical salinity to reference salinity [PSU ppt-1]
integer :: i, is, ie

if (present(dom)) then
Expand Down
44 changes: 20 additions & 24 deletions src/equation_of_state/MOM_EOS_linear.F90
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module MOM_EOS_linear
real elemental function density_elem_linear(this, T, S, pressure)
class(linear_EOS), intent(in) :: this !< This EOS
real, intent(in) :: T !< Potential temperature relative to the surface [degC]
real, intent(in) :: S !< Salinity [PSU]
real, intent(in) :: S !< Salinity [ppt]
real, intent(in) :: pressure !< Pressure [Pa]

density_elem_linear = this%Rho_T0_S0 + this%dRho_dT*T + this%dRho_dS*S
Expand All @@ -73,7 +73,7 @@ end function density_elem_linear
real elemental function density_anomaly_elem_linear(this, T, S, pressure, rho_ref)
class(linear_EOS), intent(in) :: this !< This EOS
real, intent(in) :: T !< Potential temperature relative to the surface [degC]
real, intent(in) :: S !< Salinity [PSU]
real, intent(in) :: S !< Salinity [ppt]
real, intent(in) :: pressure !< Pressure [Pa]
real, intent(in) :: rho_ref !< A reference density [kg m-3]

Expand All @@ -87,9 +87,8 @@ end function density_anomaly_elem_linear
!! scalar and array inputs.
real elemental function spec_vol_elem_linear(this, T, S, pressure)
class(linear_EOS), intent(in) :: this !< This EOS
real, intent(in) :: T !< potential temperature relative to the surface
!! [degC].
real, intent(in) :: S !< Salinity [PSU].
real, intent(in) :: T !< Potential temperature relative to the surface [degC].
real, intent(in) :: S !< Salinity [ppt].
real, intent(in) :: pressure !< Pressure [Pa].

spec_vol_elem_linear = 1.0 / ( this%Rho_T0_S0 + (this%dRho_dT*T + this%dRho_dS*S))
Expand All @@ -102,9 +101,8 @@ end function spec_vol_elem_linear
!! scalar and array inputs.
real elemental function spec_vol_anomaly_elem_linear(this, T, S, pressure, spv_ref)
class(linear_EOS), intent(in) :: this !< This EOS
real, intent(in) :: T !< potential temperature relative to the surface
!! [degC].
real, intent(in) :: S !< Salinity [PSU].
real, intent(in) :: T !< Potential temperature relative to the surface [degC].
real, intent(in) :: S !< Salinity [ppt].
real, intent(in) :: pressure !< Pressure [Pa].
real, intent(in) :: spv_ref !< A reference specific volume [m3 kg-1].

Expand All @@ -118,9 +116,8 @@ end function spec_vol_anomaly_elem_linear
!! with potential temperature and salinity.
elemental subroutine calculate_density_derivs_elem_linear(this,T, S, pressure, dRho_dT, dRho_dS)
class(linear_EOS), intent(in) :: this !< This EOS
real, intent(in) :: T !< Potential temperature relative to the surface
!! [degC].
real, intent(in) :: S !< Salinity [PSU].
real, intent(in) :: T !< Potential temperature relative to the surface [degC].
real, intent(in) :: S !< Salinity [ppt].
real, intent(in) :: pressure !< Pressure [Pa].
real, intent(out) :: drho_dT !< The partial derivative of density with
!! potential temperature [kg m-3 degC-1].
Expand All @@ -138,16 +135,16 @@ elemental subroutine calculate_density_second_derivs_elem_linear(this, T, S, pre
drho_dS_dS, drho_dS_dT, drho_dT_dT, drho_dS_dP, drho_dT_dP)
class(linear_EOS), intent(in) :: this !< This EOS
real, intent(in) :: T !< Potential temperature relative to the surface [degC].
real, intent(in) :: S !< Salinity [PSU].
real, intent(in) :: S !< Salinity [ppt].
real, intent(in) :: pressure !< pressure [Pa].
real, intent(inout) :: drho_dS_dS !< The second derivative of density with
!! salinity [kg m-3 PSU-2].
!! salinity [kg m-3 ppt-2].
real, intent(inout) :: drho_dS_dT !< The second derivative of density with
!! temperature and salinity [kg m-3 ppt-1 degC-1].
real, intent(inout) :: drho_dT_dT !< The second derivative of density with
!! temperature [kg m-3 degC-2].
real, intent(inout) :: drho_dS_dP !< The second derivative of density with
!! salinity and pressure [kg m-3 PSU-1 Pa-1].
!! salinity and pressure [kg m-3 ppt-1 Pa-1].
real, intent(inout) :: drho_dT_dP !< The second derivative of density with
!! temperature and pressure [kg m-3 degC-1 Pa-1].

Expand All @@ -163,10 +160,10 @@ end subroutine calculate_density_second_derivs_elem_linear
elemental subroutine calculate_specvol_derivs_elem_linear(this, T, S, pressure, dSV_dT, dSV_dS)
class(linear_EOS), intent(in) :: this !< This EOS
real, intent(in) :: T !< Potential temperature [degC]
real, intent(in) :: S !< Salinity [PSU]
real, intent(in) :: S !< Salinity [ppt]
real, intent(in) :: pressure !< pressure [Pa]
real, intent(inout) :: dSV_dS !< The partial derivative of specific volume with
!! salinity [m3 kg-1 PSU-1]
!! salinity [m3 kg-1 ppt-1]
real, intent(inout) :: dSV_dT !< The partial derivative of specific volume with
!! potential temperature [m3 kg-1 degC-1]
! Local variables
Expand All @@ -184,9 +181,8 @@ end subroutine calculate_specvol_derivs_elem_linear
!! salinity, potential temperature, and pressure.
elemental subroutine calculate_compress_elem_linear(this, T, S, pressure, rho, drho_dp)
class(linear_EOS), intent(in) :: this !< This EOS
real, intent(in) :: T !< Potential temperature relative to the surface
!! [degC].
real, intent(in) :: S !< Salinity [PSU].
real, intent(in) :: T !< Potential temperature relative to the surface [degC].
real, intent(in) :: S !< Salinity [ppt].
real, intent(in) :: pressure !< pressure [Pa].
real, intent(out) :: rho !< In situ density [kg m-3].
real, intent(out) :: drho_dp !< The partial derivative of density with pressure
Expand All @@ -201,7 +197,7 @@ end subroutine calculate_compress_elem_linear
!> Calculates the layer average specific volumes.
subroutine avg_spec_vol_linear(T, S, p_t, dp, SpV_avg, start, npts, Rho_T0_S0, dRho_dT, dRho_dS)
real, dimension(:), intent(in) :: T !< Potential temperature [degC]
real, dimension(:), intent(in) :: S !< Salinity [PSU]
real, dimension(:), intent(in) :: S !< Salinity [ppt]
real, dimension(:), intent(in) :: p_t !< Pressure at the top of the layer [Pa]
real, dimension(:), intent(in) :: dp !< Pressure change in the layer [Pa]
real, dimension(:), intent(inout) :: SpV_avg !< The vertical average specific volume
Expand Down Expand Up @@ -268,7 +264,7 @@ subroutine int_density_dz_linear(T, S, z_t, z_b, rho_ref, rho_0_pres, G_e, HI, &
intent(in) :: T !< Potential temperature relative to the surface
!! [C ~> degC].
real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
intent(in) :: S !< Salinity [S ~> PSU].
intent(in) :: S !< Salinity [S ~> ppt].
real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
intent(in) :: z_t !< Height at the top of the layer in depth units [Z ~> m].
real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
Expand Down Expand Up @@ -439,7 +435,7 @@ subroutine int_spec_vol_dp_linear(T, S, p_t, p_b, alpha_ref, HI, Rho_T0_S0, &
intent(in) :: T !< Potential temperature relative to the surface
!! [C ~> degC].
real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
intent(in) :: S !< Salinity [S ~> PSU].
intent(in) :: S !< Salinity [S ~> ppt].
real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
intent(in) :: p_t !< Pressure at the top of the layer [R L2 T-2 ~> Pa]
real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
Expand Down Expand Up @@ -614,7 +610,7 @@ end subroutine int_spec_vol_dp_linear
subroutine calculate_density_array_linear(this, T, S, pressure, rho, start, npts, rho_ref)
class(linear_EOS), intent(in) :: this !< This EOS
real, dimension(:), intent(in) :: T !< Potential temperature relative to the surface [degC]
real, dimension(:), intent(in) :: S !< Salinity [PSU]
real, dimension(:), intent(in) :: S !< Salinity [ppt]
real, dimension(:), intent(in) :: pressure !< Pressure [Pa]
real, dimension(:), intent(out) :: rho !< In situ density [kg m-3]
integer, intent(in) :: start !< The starting index for calculations
Expand All @@ -640,7 +636,7 @@ end subroutine calculate_density_array_linear
subroutine calculate_spec_vol_array_linear(this, T, S, pressure, specvol, start, npts, spv_ref)
class(linear_EOS), intent(in) :: this !< This EOS
real, dimension(:), intent(in) :: T !< Potential temperature relative to the surface [degC]
real, dimension(:), intent(in) :: S !< Salinity [PSU]
real, dimension(:), intent(in) :: S !< Salinity [ppt]
real, dimension(:), intent(in) :: pressure !< Pressure [Pa]
real, dimension(:), intent(out) :: specvol !< In situ specific volume [m3 kg-1]
integer, intent(in) :: start !< The starting index for calculations
Expand Down
Loading

0 comments on commit 4e8fbe1

Please sign in to comment.