Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+Cleanup MOM_set_diffusivity and MOM_geothermal #1228

Merged
merged 21 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
449d568
+Eliminated sfc_bkgnd_mixing
Hallberg-NOAA Oct 18, 2020
902f7a9
+Made Kd_lay arg to calculate_tidal_mixing optional
Hallberg-NOAA Oct 18, 2020
db4d3f0
White space cleanup in MOM_generic_tracer
Hallberg-NOAA Oct 18, 2020
8ef820e
+Remove 3-d diagnostic arrays in MOM_bkgnd_mixing
Hallberg-NOAA Oct 19, 2020
c007a13
+Move diagnostics out of MOM_CVMix_ddiff
Hallberg-NOAA Oct 19, 2020
8d1539e
+Made elements of tidal_mixing_CS private
Hallberg-NOAA Oct 19, 2020
f057821
+Made Kd_lay argument to set_diffusivity optional
Hallberg-NOAA Oct 20, 2020
741b9c7
+Work with 2-d slice of Kd_int in set_diffusivity
Hallberg-NOAA Oct 20, 2020
03c7433
Removed Kd_lay from diabatic_ALE routines
Hallberg-NOAA Oct 21, 2020
ca3a5a9
+Initialize tidal_mixing from set_diffusivity_init
Hallberg-NOAA Oct 21, 2020
986bfbd
Reuse auxiliary salinity array in set_diffusivity
Hallberg-NOAA Oct 21, 2020
c61232f
+Overloaded the interface to geothermal
Hallberg-NOAA Oct 21, 2020
c4e1455
Eliminated unused variables in diabatic_ALE
Hallberg-NOAA Oct 21, 2020
2968e4d
Refactored diagnostics in geothermal_in_place
Hallberg-NOAA Oct 21, 2020
fc806af
Reordering of code in calculate_bkgnd_mixing
Hallberg-NOAA Oct 21, 2020
5df0137
+Added the runtime parameter PRANDTL_EPBL
Hallberg-NOAA Oct 22, 2020
cd3ebe4
Merge branch 'dev/gfdl' into set_diffusivity_cleanup
Hallberg-NOAA Oct 22, 2020
94a8338
Fixed the diagnostic internal_heat_temp_tendency
Hallberg-NOAA Oct 22, 2020
a30e121
Reorder compute_ddiff_coeffs argument declarations
Hallberg-NOAA Oct 26, 2020
aea8755
+Changed overloaded interface to geothermal()
Hallberg-NOAA Oct 26, 2020
6a9506e
Merge branch 'dev/gfdl' into set_diffusivity_cleanup
Hallberg-NOAA Oct 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 27 additions & 50 deletions src/parameterizations/vertical/MOM_CVMix_ddiff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module MOM_CVMix_ddiff
public CVMix_ddiff_init, CVMix_ddiff_end, CVMix_ddiff_is_used, compute_ddiff_coeffs

!> Control structure including parameters for CVMix double diffusion.
type, public :: CVMix_ddiff_cs
type, public :: CVMix_ddiff_cs ; private

! Parameters
real :: strat_param_max !< maximum value for the stratification parameter [nondim]
Expand All @@ -40,17 +40,6 @@ module MOM_CVMix_ddiff
!! Caldwell 1976 ("MC76"; default) and Kelley 1988, 1990 ("K90")
logical :: debug !< If true, turn on debugging

! Daignostic handles and pointers
type(diag_ctrl), pointer :: diag => NULL() !< Pointer to diagnostics control structure
!>@{ Diagnostics handles
integer :: id_KT_extra = -1, id_KS_extra = -1, id_R_rho = -1
!>@}

! Diagnostics arrays
! real, allocatable, dimension(:,:,:) :: KT_extra !< Double diffusion diffusivity for temp [Z2 s-1 ~> m2 s-1]
! real, allocatable, dimension(:,:,:) :: KS_extra !< Double diffusion diffusivity for salt [Z2 s-1 ~> m2 s-1]
real, allocatable, dimension(:,:,:) :: R_rho !< Double-diffusion density ratio [nondim]

end type CVMix_ddiff_cs

character(len=40) :: mdl = "MOM_CVMix_ddiff" !< This module's name.
Expand Down Expand Up @@ -136,23 +125,6 @@ logical function CVMix_ddiff_init(Time, G, GV, US, param_file, diag, CS)

call closeParameterBlock(param_file)

! Register diagnostics
CS%diag => diag

CS%id_KT_extra = register_diag_field('ocean_model','KT_extra',diag%axesTi,Time, &
'Double-diffusive diffusivity for temperature', 'm2 s-1', conversion=US%Z2_T_to_m2_s)

CS%id_KS_extra = register_diag_field('ocean_model','KS_extra',diag%axesTi,Time, &
'Double-diffusive diffusivity for salinity', 'm2 s-1', conversion=US%Z2_T_to_m2_s)

CS%id_R_rho = register_diag_field('ocean_model','R_rho',diag%axesTi,Time, &
'Double-diffusion density ratio', 'nondim')

if (CS%id_R_rho > 0) then
allocate(CS%R_rho( SZI_(G), SZJ_(G), SZK_(G)+1))
CS%R_rho(:,:,:) = 0.0
endif

call cvmix_init_ddiff(strat_param_max=CS%strat_param_max, &
kappa_ddiff_s=CS%kappa_ddiff_s, &
ddiff_exp1=CS%ddiff_exp1, &
Expand All @@ -167,22 +139,26 @@ end function CVMix_ddiff_init

!> Subroutine for computing vertical diffusion coefficients for the
!! double diffusion mixing parameterization.
subroutine compute_ddiff_coeffs(h, tv, G, GV, US, j, Kd_T, Kd_S, CS)

type(ocean_grid_type), intent(in) :: G !< Grid structure.
type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure.
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h !< Layer thickness [H ~> m or kg m-2].
type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamics structure.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)+1), intent(out) :: Kd_T !< Interface double diffusion diapycnal
!! diffusivity for temp [Z2 T-1 ~> m2 s-1].
real, dimension(SZI_(G),SZJ_(G),SZK_(G)+1), intent(out) :: Kd_S !< Interface double diffusion diapycnal
!! diffusivity for salt [Z2 T-1 ~> m2 s-1].
type(CVMix_ddiff_cs), pointer :: CS !< The control structure returned
!! by a previous call to CVMix_ddiff_init.
integer, intent(in) :: j !< Meridional grid indice.
subroutine compute_ddiff_coeffs(h, tv, G, GV, US, j, Kd_T, Kd_S, CS, R_rho)
Hallberg-NOAA marked this conversation as resolved.
Show resolved Hide resolved

type(ocean_grid_type), intent(in) :: G !< Grid structure.
type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure.
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h !< Layer thickness [H ~> m or kg m-2].
type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamics structure.
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
integer, intent(in) :: j !< Meridional grid index to work on.
! Kd_T and Kd_S are intent inout because only one j-row is set here, but they are essentially outputs.
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), intent(inout) :: Kd_T !< Interface double diffusion diapycnal
!! diffusivity for temp [Z2 T-1 ~> m2 s-1].
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), intent(inout) :: Kd_S !< Interface double diffusion diapycnal
!! diffusivity for salt [Z2 T-1 ~> m2 s-1].
type(CVMix_ddiff_cs), pointer :: CS !< The control structure returned
!! by a previous call to CVMix_ddiff_init.
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), &
optional, intent(inout) :: R_rho !< The density ratios at interfaces [nondim].

! Local variables
real, dimension(SZK_(G)) :: &
real, dimension(SZK_(GV)) :: &
cellHeight, & !< Height of cell centers [m]
dRho_dT, & !< partial derivatives of density wrt temp [R degC-1 ~> kg m-3 degC-1]
dRho_dS, & !< partial derivatives of density wrt saln [R ppt-1 ~> kg m-3 ppt-1]
Expand All @@ -193,11 +169,11 @@ subroutine compute_ddiff_coeffs(h, tv, G, GV, US, j, Kd_T, Kd_S, CS)
beta_dS, & !< beta*dS across interfaces [kg m-3]
dT, & !< temp. difference between adjacent layers [degC]
dS !< salt difference between adjacent layers [ppt]
real, dimension(SZK_(G)+1) :: &
real, dimension(SZK_(GV)+1) :: &
Kd1_T, & !< Diapycanal diffusivity of temperature [m2 s-1].
Kd1_S !< Diapycanal diffusivity of salinity [m2 s-1].

real, dimension(SZK_(G)+1) :: iFaceHeight !< Height of interfaces [m]
real, dimension(SZK_(GV)+1) :: iFaceHeight !< Height of interfaces [m]
integer :: kOBL !< level of OBL extent
real :: dh, hcorr
integer :: i, k
Expand Down Expand Up @@ -246,11 +222,12 @@ subroutine compute_ddiff_coeffs(h, tv, G, GV, US, j, Kd_T, Kd_S, CS)
beta_dS(k) = US%R_to_kg_m3*drho_dS(k) * dS(k)
enddo

if (CS%id_R_rho > 0.0) then
if (present(R_rho)) then
do k=1,G%ke
CS%R_rho(i,j,k) = alpha_dT(k)/beta_dS(k)
! avoid NaN's
if(CS%R_rho(i,j,k) /= CS%R_rho(i,j,k)) CS%R_rho(i,j,k) = 0.0
! Set R_rho using Adcroft's rule of reciprocals.
R_rho(i,j,k) = 0.0 ; if (abs(beta_dS(k)) > 0.0) R_rho(i,j,k) = alpha_dT(k) / beta_dS(k)
! avoid NaN's again for safety, perhaps unnecessarily.
if (R_rho(i,j,k) /= R_rho(i,j,k)) R_rho(i,j,k) = 0.0
enddo
endif

Expand Down
Loading