Skip to content

Commit

Permalink
+Add runtime parameters for sloshing_initialization
Browse files Browse the repository at this point in the history
  Added the new runtime parameters INITIAL_SSS and SLOSHING_T_PERT to specify the
previously hard-coded dimensional parameters in the sloshing_initialization
module.  Also added comments documenting the purpose and units of the internal
real variables in sloshing_initialization.F90.  There is also a new comment
questioning whether the temperature perturbations are being applied correctly,
but for now the code reproduces the previous answers.  By default all answers
are bitwise identical, but there are new entries in the MOM_parameter_doc.all
files for the sloshing test cases.
  • Loading branch information
Hallberg-NOAA committed Dec 23, 2022
1 parent dd7c787 commit 5831dc6
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions src/user/sloshing_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ module sloshing_initialization
subroutine sloshing_initialize_topography( D, G, param_file, max_depth )
type(dyn_horgrid_type), intent(in) :: G !< The dynamic horizontal grid type
real, dimension(G%isd:G%ied,G%jsd:G%jed), &
intent(out) :: D !< Ocean bottom depth in the units of depth_max
intent(out) :: D !< Ocean bottom depth [Z ~> m]
type(param_file_type), intent(in) :: param_file !< Parameter file structure
real, intent(in) :: max_depth !< Maximum ocean depth in arbitrary units
real, intent(in) :: max_depth !< Maximum ocean depth [Z ~> m]

! Local variables
integer :: i, j
Expand Down Expand Up @@ -60,23 +60,22 @@ subroutine sloshing_initialize_thickness ( h, depth_tot, G, GV, US, param_file,
intent(out) :: h !< The thickness that is being initialized [H ~> m or kg m-2].
real, dimension(SZI_(G),SZJ_(G)), &
intent(in) :: depth_tot !< The nominal total depth of the ocean [Z ~> m]
type(param_file_type), intent(in) :: param_file !< A structure indicating the open file
!! to parse for model parameter values.
logical, intent(in) :: just_read !< If true, this call will
!! only read parameters without changing h.
type(param_file_type), intent(in) :: param_file !< A structure to parse for model parameter values.
logical, intent(in) :: just_read !< If true, this call will only read
!! parameters without changing h.

! Local variables
real :: displ(SZK_(GV)+1) ! The interface displacement [Z ~> m].
real :: z_unif(SZK_(GV)+1) ! Fractional uniform interface heights [nondim].
real :: z_inter(SZK_(GV)+1) ! Interface heights [Z ~> m]
real :: a0 ! The displacement amplitude [Z ~> m].
real :: weight_z ! A (misused?) depth-space weighting, in inconsistent units.
real :: x1, y1, x2, y2 ! Dimensonless parameters.
real :: x, t ! Dimensionless depth coordinates?
real :: weight_z ! A depth-space weighting [nondim].
real :: x1, y1, x2, y2 ! Dimensonless parameters specifying the depth profile [nondim]
real :: x, t ! Dimensionless depth coordinates scales [nondim]
logical :: use_IC_bug ! If true, set the initial conditions retaining an old bug.
! This include declares and sets the variable "version".
# include "version_variable.h"
character(len=40) :: mdl = "sloshing_initialization" !< This module's name.

integer :: i, j, k, is, ie, js, je, nz

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke
Expand Down Expand Up @@ -133,7 +132,7 @@ subroutine sloshing_initialize_thickness ( h, depth_tot, G, GV, US, param_file,

x = G%geoLonT(i,j) / G%len_lon
if (use_IC_bug) then
displ(k) = a0 * cos(acos(-1.0)*x) + weight_z * US%m_to_Z
displ(k) = a0 * cos(acos(-1.0)*x) + weight_z * US%m_to_Z ! There is a flag to fix this bug.
else
displ(k) = a0 * cos(acos(-1.0)*x) * weight_z
endif
Expand Down Expand Up @@ -176,29 +175,28 @@ end subroutine sloshing_initialize_thickness
!! Note that the linear distribution is set up with respect to the layer
!! number, not the physical position).
subroutine sloshing_initialize_temperature_salinity ( T, S, h, G, GV, US, param_file, just_read)
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure.
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure.
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(out) :: T !< Potential temperature [C ~> degC].
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(out) :: S !< Salinity [S ~> ppt].
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h !< Layer thickness [H ~> m or kg m-2].
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(out) :: T !< Potential temperature [C ~> degC].
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(out) :: S !< Salinity [S ~> ppt].
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h !< Layer thickness [H ~> m or kg m-2].
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(param_file_type), intent(in) :: param_file !< A structure indicating the
!! open file to parse for model
!! parameter values.
logical, intent(in) :: just_read !< If true, this call will
!! only read parameters without changing T & S.
type(param_file_type), intent(in) :: param_file !< A structure to parse
!! for model parameter values.
logical, intent(in) :: just_read !< If true, this call will only read
!! parameters without changing T & S.

! Local variables
real :: delta_T ! Temperature difference between layers [C ~> degC]
real :: S_ref, T_ref ! Reference salinity [S ~> ppt] and temperature [C ~> degC] within surface layer
real :: S_range, T_range ! Range of salinities [S ~> ppt] and temperatures [C ~> degC] over the vertical
real :: S_surf ! Initial surface salinity [S ~> ppt]
real :: T_pert ! A perturbed temperature [C ~> degC]
integer :: kdelta ! Half the number of layers with the temperature perturbation
real :: deltah ! Thickness of each layer [Z ~> m]
real :: xi0, xi1 ! Fractional vertical positions [nondim]
character(len=40) :: mdl = "sloshing_initialization" ! This module's name.
integer :: i, j, k, is, ie, js, je, nz
real :: delta_T
real :: S_ref, T_ref; ! Reference salinity [S ~> ppt] and temperature [C ~> degC] within
! surface layer
real :: S_range, T_range; ! Range of [S ~> ppt] and temperatures [C ~> degC] over the
! vertical
integer :: kdelta
real :: deltah
real :: xi0, xi1
character(len=40) :: mdl = "initialize_temp_salt_linear" ! This subroutine's
! name.

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke

Expand All @@ -208,10 +206,15 @@ subroutine sloshing_initialize_temperature_salinity ( T, S, h, G, GV, US, param_
units='degC', scale=US%degC_to_C, fail_if_missing=.not.just_read, do_not_log=just_read)

! The default is to assume an increase by 2 ppt for the salinity and a uniform temperature.
call get_param(param_file, mdl,"S_RANGE",S_range,'Initial salinity range.', &
call get_param(param_file, mdl, "S_RANGE", S_range, 'Initial salinity range.', &
units='1e-3', default=2.0, scale=US%ppt_to_S, do_not_log=just_read)
call get_param(param_file, mdl,"T_RANGE",T_range,'Initial temperature range', &
call get_param(param_file, mdl, "T_RANGE", T_range, 'Initial temperature range', &
units='degC', default=0.0, scale=US%degC_to_C, do_not_log=just_read)
call get_param(param_file, mdl, "INITIAL_SSS", S_surf, "Initial surface salinity", &
units="1e-3", default=34.0, scale=US%ppt_to_S, do_not_log=just_read)
call get_param(param_file, mdl, "SLOSHING_T_PERT", T_pert, &
'A mid-column temperature perturbation in the sloshing test case', &
units='degC', default=1.0, scale=US%degC_to_C, do_not_log=just_read)

if (just_read) return ! All run-time parameters have been read, so return.

Expand All @@ -228,7 +231,7 @@ subroutine sloshing_initialize_temperature_salinity ( T, S, h, G, GV, US, param_
xi0 = 0.0
do k = 1,nz
xi1 = xi0 + deltah / G%max_depth ! = xi0 + 1.0 / real(nz)
S(i,j,k) = 34.0*US%ppt_to_S + 0.5 * S_range * (xi0 + xi1)
S(i,j,k) = S_surf + 0.5 * S_range * (xi0 + xi1)
xi0 = xi1
enddo
enddo ; enddo
Expand All @@ -241,7 +244,8 @@ subroutine sloshing_initialize_temperature_salinity ( T, S, h, G, GV, US, param_
T(:,:,k) = T(:,:,k-1) + delta_T
enddo
kdelta = 2
T(:,:,GV%ke/2 - (kdelta-1):GV%ke/2 + kdelta) = 1.0*US%degC_to_C
! Perhaps the following lines should instead assign T() = T_pert + T_ref
T(:,:,GV%ke/2 - (kdelta-1):GV%ke/2 + kdelta) = T_pert

end subroutine sloshing_initialize_temperature_salinity

Expand Down

0 comments on commit 5831dc6

Please sign in to comment.