Skip to content

Commit

Permalink
Document units of about 250 EOS variables
Browse files Browse the repository at this point in the history
  Added or amended comments to document the units of about 250 variables in 6
files in the src/equation_of_state directories.  Also revised comments to make
it clear that the MOM6 code for the UNESCO equation of state is based on the
Jackett and MacDougall (1995) refit to the UNESCO equation of state (which uses
potential temperature as a state variable) as opposed to the original UNESCO
equation of state, as documented in an appendix to Gill (1982) (which uses
in-situ temperature as a state variable).  Also corrected a handful of spelling
errors in comments.  Only comments are changed, and all answers are bitwise
identical.
  • Loading branch information
Hallberg-NOAA authored and marshallward committed Feb 3, 2023
1 parent 454c5c6 commit cab1e84
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 208 deletions.
8 changes: 4 additions & 4 deletions src/equation_of_state/MOM_EOS.F90
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ subroutine calculate_stanley_density_1d(T, S, pressure, Tvar, TScov, Svar, rho,
real :: rho_scale ! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]
real :: T2_scale ! A factor to convert temperature variance to units of degC2 [degC2 C-2 ~> 1]
real :: S2_scale ! A factor to convert salinity variance to units of ppt2 [ppt2 S-2 ~> 1]
real :: TS_scale ! A factor to convert temperture-salinity covariance to units of
real :: TS_scale ! A factor to convert temperature-salinity covariance to units of
! degC ppt [degC ppt C-1 S-1 ~> 1]
real :: rho_reference ! rho_ref converted to [kg m-3]
real, dimension(size(rho)) :: pres ! Pressure converted to [Pa]
Expand Down Expand Up @@ -1023,7 +1023,7 @@ subroutine calculate_density_second_derivs_1d(T, S, pressure, drho_dS_dS, drho_d

end subroutine calculate_density_second_derivs_1d

!> Calls the appropriate subroutine to calculate density second derivatives for scalar nputs.
!> Calls the appropriate subroutine to calculate density second derivatives for scalar inputs.
subroutine calculate_density_second_derivs_scalar(T, S, pressure, drho_dS_dS, drho_dS_dT, drho_dT_dT, &
drho_dS_dP, drho_dT_dP, EOS, scale)
real, intent(in) :: T !< Potential temperature referenced to the surface [C ~> degC]
Expand Down Expand Up @@ -1266,7 +1266,7 @@ subroutine calculate_compress_scalar(T, S, pressure, rho, drho_dp, EOS)
type(EOS_type), intent(in) :: EOS !< Equation of state structure

! Local variables
! These arrays use the same units as their counterparts in calcluate_compress_1d.
! These arrays use the same units as their counterparts in calculate_compress_1d.
real, dimension(1) :: pa ! Pressure in a size-1 1d array [R L2 T-2 ~> Pa]
real, dimension(1) :: Ta ! Temperature in a size-1 1d array [C ~> degC]
real, dimension(1) :: Sa ! Salinity in a size-1 1d array [S ~> ppt]
Expand Down Expand Up @@ -1734,7 +1734,7 @@ subroutine abs_saln_to_prac_saln(S, prSaln, EOS, dom, scale)

! Local variables
real, dimension(size(S)) :: Sa ! Salinity converted to [ppt]
real :: S_scale ! A factor to convert practical salnity 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 ppt-1 ~> 1]
integer :: i, is, ie

if (present(dom)) then
Expand Down
29 changes: 19 additions & 10 deletions src/equation_of_state/MOM_EOS_NEMO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module MOM_EOS_NEMO
module procedure calculate_density_derivs_scalar_nemo, calculate_density_derivs_array_nemo
end interface calculate_density_derivs_nemo

real, parameter :: Pa2db = 1.e-4 !< Conversion factor between Pa and dbar
real, parameter :: Pa2db = 1.e-4 !< Conversion factor between Pa and dbar [Pa dbar-1]
!>@{ Parameters in the NEMO equation of state
real, parameter :: rdeltaS = 32.
real, parameter :: r1_S0 = 0.875/35.16504
Expand Down Expand Up @@ -184,8 +184,10 @@ subroutine calculate_density_scalar_nemo(T, S, pressure, rho, rho_ref)
real, intent(out) :: rho !< In situ density [kg m-3].
real, optional, intent(in) :: rho_ref !< A reference density [kg m-3].

real, dimension(1) :: T0, S0, pressure0
real, dimension(1) :: rho0
real, dimension(1) :: T0 ! A 1-d array with a copy of the conservative temperature [degC]
real, dimension(1) :: S0 ! A 1-d array with a copy of the absolute salinity [g kg-1]
real, dimension(1) :: pressure0 ! A 1-d array with a copy of the pressure [Pa]
real, dimension(1) :: rho0 ! A 1-d array with a copy of the density [kg m-3]

T0(1) = T
S0(1) = S
Expand Down Expand Up @@ -345,8 +347,13 @@ subroutine calculate_density_derivs_scalar_nemo(T, S, pressure, drho_dt, drho_ds
real, intent(out) :: drho_dS !< The partial derivative of density with salinity,
!! in [kg m-3 ppt-1].
! Local variables
real, dimension(1) :: T0, S0, pressure0
real, dimension(1) :: drdt0, drds0
real, dimension(1) :: T0 ! A 1-d array with a copy of the conservative temperature [degC]
real, dimension(1) :: S0 ! A 1-d array with a copy of the absolute salinity [g kg-1]
real, dimension(1) :: pressure0 ! A 1-d array with a copy of the pressure [Pa]
real, dimension(1) :: drdt0 ! A 1-d array with a copy of the derivative of density
! with potential temperature [kg m-3 degC-1]
real, dimension(1) :: drds0 ! A 1-d array with a copy of the derivative of density
! with salinity [kg m-3 ppt-1]

T0(1) = T
S0(1) = S
Expand All @@ -358,12 +365,12 @@ subroutine calculate_density_derivs_scalar_nemo(T, S, pressure, drho_dt, drho_ds
end subroutine calculate_density_derivs_scalar_nemo

!> Compute the in situ density of sea water (rho in [kg m-3]) and the compressibility
!! (drho/dp = C_sound^-2, stored as drho_dp [s2 m-2]) from absolute salinity
!! (sal in g/kg), conservative temperature (T [degC]), and pressure [Pa], using the expressions
!! (drho/dp = C_sound^-2, stored as drho_dp [s2 m-2]) from absolute salinity (sal [g kg-1]),
!! conservative temperature (T [degC]), and pressure [Pa], using the expressions
!! derived for use with NEMO.
subroutine calculate_compress_nemo(T, S, pressure, rho, drho_dp, start, npts)
real, intent(in), dimension(:) :: T !< Conservative temperature [degC].
real, intent(in), dimension(:) :: S !< Absolute salinity [g/kg].
real, intent(in), dimension(:) :: S !< Absolute salinity [g kg-1].
real, intent(in), dimension(:) :: pressure !< pressure [Pa].
real, intent(out), dimension(:) :: rho !< In situ density [kg m-3].
real, intent(out), dimension(:) :: drho_dp !< The partial derivative of density with pressure
Expand All @@ -373,7 +380,9 @@ subroutine calculate_compress_nemo(T, S, pressure, rho, drho_dp, start, npts)
integer, intent(in) :: npts !< The number of values to calculate.

! Local variables
real :: zs,zt,zp
real :: zs ! Absolute salinity [g kg-1]
real :: zt ! Conservative temperature [degC]
real :: zp ! Pressure converted to decibars [dbar]
integer :: j

call calculate_density_array_nemo(T, S, pressure, rho, start, npts)
Expand All @@ -384,7 +393,7 @@ subroutine calculate_compress_nemo(T, S, pressure, rho, drho_dp, start, npts)
do j=start,start+npts-1
!Conversions
zs = S(j) !gsw_sr_from_sp(S(j)) !Convert practical salinity to absolute salinity
zt = T(j) !gsw_ct_from_pt(S(j),T(j)) !Convert potantial temp to conservative temp
zt = T(j) !gsw_ct_from_pt(S(j),T(j)) !Convert potential temp to conservative temp
zp = pressure(j)* Pa2db !Convert pressure from Pascal to decibar
call gsw_rho_first_derivatives(zs,zt,zp, drho_dp=drho_dp(j))
enddo
Expand Down
Loading

0 comments on commit cab1e84

Please sign in to comment.