From 038ca2a7a8329acd476f766c8af3227352eeeb89 Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Sun, 28 Jan 2024 21:21:55 -0500 Subject: [PATCH] Document core and linear EOS variable units Modified comments to document the units of 17 variables in 5 files in the core directory and another 5 variables in MOM_EOS_linear.F90. Only comments are changed and all answers are bitwise identical. --- src/core/MOM.F90 | 6 +++--- src/core/MOM_check_scaling.F90 | 2 +- src/core/MOM_forcing_type.F90 | 25 +++++++++++++----------- src/core/MOM_isopycnal_slopes.F90 | 5 ++++- src/core/MOM_verticalGrid.F90 | 16 ++++++++++----- src/equation_of_state/MOM_EOS_linear.F90 | 6 +++--- 6 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index 2800011ccf..1922e87926 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -263,7 +263,7 @@ module MOM type(MOM_stoch_eos_CS) :: stoch_eos_CS !< structure containing random pattern for stoch EOS logical :: alternate_first_direction !< If true, alternate whether the x- or y-direction !! updates occur first in directionally split parts of the calculation. - real :: first_dir_restart = -1.0 !< A real copy of G%first_direction for use in restart files + real :: first_dir_restart = -1.0 !< A real copy of G%first_direction for use in restart files [nondim] logical :: offline_tracer_mode = .false. !< If true, step_offline() is called instead of step_MOM(). !! This is intended for running MOM6 in offline tracer mode @@ -1205,7 +1205,7 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, & endif !OBC segment data update for some fields can be less frequent than others - if(associated(CS%OBC)) then + if (associated(CS%OBC)) then CS%OBC%update_OBC_seg_data = .false. if (CS%dt_obc_seg_period == 0.0) CS%OBC%update_OBC_seg_data = .true. if (CS%dt_obc_seg_period > 0.0) then @@ -2079,7 +2079,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, & real :: Hmix_z, Hmix_UV_z ! Temporary variables with averaging depths [Z ~> m] real :: HFrz_z ! Temporary variable with the melt potential depth [Z ~> m] - real :: default_val ! default value for a parameter + real :: default_val ! The default value for DTBT_RESET_PERIOD [s] logical :: write_geom_files ! If true, write out the grid geometry files. logical :: new_sim ! If true, this has been determined to be a new simulation logical :: use_geothermal ! If true, apply geothermal heating. diff --git a/src/core/MOM_check_scaling.F90 b/src/core/MOM_check_scaling.F90 index 1d7c27b6fd..2841514924 100644 --- a/src/core/MOM_check_scaling.F90 +++ b/src/core/MOM_check_scaling.F90 @@ -29,7 +29,7 @@ subroutine check_MOM6_scaling_factors(GV, US) ! Local variables integer, parameter :: ndims = 8 ! The number of rescalable dimensional factors. - real, dimension(ndims) :: scales ! An array of scaling factors for each of the basic units. + real, dimension(ndims) :: scales ! An array of scaling factors for each of the basic units [various]. integer, dimension(ndims) :: scale_pow2 ! The powers of 2 that give each element of scales. character(len=2), dimension(ndims) :: key integer, allocatable :: weights(:) diff --git a/src/core/MOM_forcing_type.F90 b/src/core/MOM_forcing_type.F90 index dcbf440292..b2ccdde71f 100644 --- a/src/core/MOM_forcing_type.F90 +++ b/src/core/MOM_forcing_type.F90 @@ -3492,7 +3492,7 @@ end subroutine get_mech_forcing_groups !> Allocates and zeroes-out array. subroutine myAlloc(array, is, ie, js, je, flag) - real, dimension(:,:), pointer :: array !< Array to be allocated + real, dimension(:,:), pointer :: array !< Array to be allocated [arbitrary] integer, intent(in) :: is !< Start i-index integer, intent(in) :: ie !< End i-index integer, intent(in) :: js !< Start j-index @@ -3970,11 +3970,12 @@ end subroutine homogenize_forcing subroutine homogenize_field_t(var, G, tmp_scale) type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure - real, dimension(SZI_(G),SZJ_(G)), intent(inout) :: var !< The variable to homogenize - real, optional, intent(in) :: tmp_scale !< A temporary rescaling factor for the - !! variable that is reversed in the return value + real, dimension(SZI_(G),SZJ_(G)), intent(inout) :: var !< The variable to homogenize [A ~> a] + real, optional, intent(in) :: tmp_scale !< A temporary rescaling factor for the + !! variable that is reversed in the + !! return value [a A-1 ~> 1] - real :: avg ! Global average of var, in the same units as var + real :: avg ! Global average of var, in the same units as var [A ~> a] integer :: i, j, is, ie, js, je is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec @@ -3987,11 +3988,12 @@ end subroutine homogenize_field_t subroutine homogenize_field_v(var, G, tmp_scale) type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure - real, dimension(SZI_(G),SZJB_(G)), intent(inout) :: var !< The variable to homogenize + real, dimension(SZI_(G),SZJB_(G)), intent(inout) :: var !< The variable to homogenize [A ~> a] real, optional, intent(in) :: tmp_scale !< A temporary rescaling factor for the - !! variable that is reversed in the return value + !! variable that is reversed in the + !! return value [a A-1 ~> 1] - real :: avg ! Global average of var, in the same units as var + real :: avg ! Global average of var, in the same units as var [A ~> a] integer :: i, j, is, ie, jsB, jeB is = G%isc ; ie = G%iec ; jsB = G%jscB ; jeB = G%jecB @@ -4004,11 +4006,12 @@ end subroutine homogenize_field_v subroutine homogenize_field_u(var, G, tmp_scale) type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure - real, dimension(SZI_(G),SZJB_(G)), intent(inout) :: var !< The variable to homogenize + real, dimension(SZI_(G),SZJB_(G)), intent(inout) :: var !< The variable to homogenize [A ~> a] real, optional, intent(in) :: tmp_scale !< A temporary rescaling factor for the - !! variable that is reversed in the return value + !! variable that is reversed in the + !! return value [a A-1 ~> 1] - real :: avg ! Global average of var, in the same units as var + real :: avg ! Global average of var, in the same units as var [A ~> a] integer :: i, j, isB, ieB, js, je isB = G%iscB ; ieB = G%iecB ; js = G%jsc ; je = G%jec diff --git a/src/core/MOM_isopycnal_slopes.F90 b/src/core/MOM_isopycnal_slopes.F90 index 5aa78cb87a..9defa597ab 100644 --- a/src/core/MOM_isopycnal_slopes.F90 +++ b/src/core/MOM_isopycnal_slopes.F90 @@ -70,7 +70,10 @@ subroutine calc_isoneutral_slopes(G, GV, US, h, e, tv, dt_kappa_smooth, use_stan ! in massless layers filled vertically by diffusion. real, dimension(SZI_(G), SZJ_(G),SZK_(GV)+1) :: & pres ! The pressure at an interface [R L2 T-2 ~> Pa]. - real, dimension(SZI_(G)) :: scrap ! An array to pass to calculate_density_second_derivs() that will be ingored. + real, dimension(SZI_(G)) :: scrap ! An array to pass to calculate_density_second_derivs() that is + ! set there but will be ignored, it is used simultaneously with four different + ! inconsistent units of [R S-1 C-1 ~> kg m-3 degC-1 ppt-1], [R S-2 ~> kg m-3 ppt-2], + ! [T2 S-1 L-2 ~> kg m-3 ppt-1 Pa-1] and [T2 C-1 L-2 ~> kg m-3 degC-1 Pa-1]. real, dimension(SZIB_(G)) :: & drho_dT_u, & ! The derivative of density with temperature at u points [R C-1 ~> kg m-3 degC-1]. drho_dS_u ! The derivative of density with salinity at u points [R S-1 ~> kg m-3 ppt-1]. diff --git a/src/core/MOM_verticalGrid.F90 b/src/core/MOM_verticalGrid.F90 index b0b9fa9fcd..b6cc97d943 100644 --- a/src/core/MOM_verticalGrid.F90 +++ b/src/core/MOM_verticalGrid.F90 @@ -35,8 +35,12 @@ module MOM_verticalGrid character(len=40) :: zAxisUnits !< The units that vertical coordinates are written in character(len=40) :: zAxisLongName !< Coordinate name to appear in files, !! e.g. "Target Potential Density" or "Height" - real, allocatable, dimension(:) :: sLayer !< Coordinate values of layer centers - real, allocatable, dimension(:) :: sInterface !< Coordinate values on interfaces + real, allocatable, dimension(:) :: sLayer !< Coordinate values of layer centers, in unscaled + !! units that depend on the vertical coordinate, such as [kg m-3] for an + !! isopycnal or some hybrid coordinates, [m] for a Z* coordinate, + !! or [nondim] for a sigma coordinate. + real, allocatable, dimension(:) :: sInterface !< Coordinate values on interfaces, in the same + !! unscale units as sLayer [various]. integer :: direction = 1 !< Direction defaults to 1, positive up. ! The following variables give information about the vertical grid. @@ -326,9 +330,11 @@ end function get_tr_flux_units !> This sets the coordinate data for the "layer mode" of the isopycnal model. subroutine setVerticalGridAxes( Rlay, GV, scale ) - type(verticalGrid_type), intent(inout) :: GV !< The container for vertical grid data - real, dimension(GV%ke), intent(in) :: Rlay !< The layer target density [R ~> kg m-3] - real, intent(in) :: scale !< A unit scaling factor for Rlay + type(verticalGrid_type), intent(inout) :: GV !< The container for vertical grid data + real, dimension(GV%ke), intent(in) :: Rlay !< The layer target density [R ~> kg m-3] + real, intent(in) :: scale !< A unit scaling factor for Rlay to convert + !! it into the units of sInterface, usually + !! [kg m-3 R-1 ~> 1] when used in layer mode. ! Local variables integer :: k, nk diff --git a/src/equation_of_state/MOM_EOS_linear.F90 b/src/equation_of_state/MOM_EOS_linear.F90 index db67040304..8984fbca88 100644 --- a/src/equation_of_state/MOM_EOS_linear.F90 +++ b/src/equation_of_state/MOM_EOS_linear.F90 @@ -167,7 +167,7 @@ elemental subroutine calculate_specvol_derivs_elem_linear(this, T, S, pressure, real, intent(inout) :: dSV_dT !< The partial derivative of specific volume with !! potential temperature [m3 kg-1 degC-1] ! Local variables - real :: I_rho2 + real :: I_rho2 ! The inverse of density squared [m6 kg-2] ! Sv = 1.0 / (Rho_T0_S0 + dRho_dT*T + dRho_dS*S) I_rho2 = 1.0 / (this%Rho_T0_S0 + (this%dRho_dT*T + this%dRho_dS*S))**2 @@ -317,7 +317,7 @@ subroutine int_density_dz_linear(T, S, z_t, z_b, rho_ref, rho_0_pres, G_e, HI, & real :: intz(5) ! The integrals of density with height at the ! 5 sub-column locations [R L2 T-2 ~> Pa] logical :: do_massWeight ! Indicates whether to do mass weighting. - real, parameter :: C1_6 = 1.0/6.0, C1_90 = 1.0/90.0 ! Rational constants. + real, parameter :: C1_6 = 1.0/6.0, C1_90 = 1.0/90.0 ! Rational constants [nondim]. integer :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, i, j, m ! These array bounds work for the indexing convention of the input arrays, but @@ -488,7 +488,7 @@ subroutine int_spec_vol_dp_linear(T, S, p_t, p_b, alpha_ref, HI, Rho_T0_S0, & real :: intp(5) ! The integrals of specific volume with pressure at the ! 5 sub-column locations [L2 T-2 ~> m2 s-2] logical :: do_massWeight ! Indicates whether to do mass weighting. - real, parameter :: C1_6 = 1.0/6.0, C1_90 = 1.0/90.0 ! Rational constants. + real, parameter :: C1_6 = 1.0/6.0, C1_90 = 1.0/90.0 ! Rational constants [nondim]. integer :: Isq, Ieq, Jsq, Jeq, ish, ieh, jsh, jeh, i, j, m, halo Isq = HI%IscB ; Ieq = HI%IecB ; Jsq = HI%JscB ; Jeq = HI%JecB