Skip to content

Commit

Permalink
Document core and linear EOS variable units
Browse files Browse the repository at this point in the history
  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.
  • Loading branch information
Hallberg-NOAA committed Jan 29, 2024
1 parent 17f1c40 commit 038ca2a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/core/MOM_check_scaling.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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(:)
Expand Down
25 changes: 14 additions & 11 deletions src/core/MOM_forcing_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
5 changes: 4 additions & 1 deletion src/core/MOM_isopycnal_slopes.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
16 changes: 11 additions & 5 deletions src/core/MOM_verticalGrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/equation_of_state/MOM_EOS_linear.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 038ca2a

Please sign in to comment.