Skip to content

Commit

Permalink
Adding option to smooth Ri using a 1-2-1 filter
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-marques committed Apr 10, 2018
1 parent 86e7074 commit 99ca9a7
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions src/parameterizations/vertical/MOM_cvmix_shear.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ module MOM_cvmix_shear
!> Control structure including parameters for CVMix interior shear schemes.
type, public :: cvmix_shear_cs
logical :: use_LMD94, use_PP81 !< Flags for various schemes
logical :: smooth_ri !< If true, smooth Ri using a 1-2-1 filter
real :: Ri_zero !< LMD94 critical Richardson number
real :: Nu_zero !< LMD94 maximum interior diffusivity
real :: KPP_exp !<
real :: KPP_exp !< Exponent of unitless factor of diff.
!! for KPP internal shear mixing scheme.
real, allocatable, dimension(:,:,:) :: N2 !< Squared Brunt-Vaisala frequency (1/s2)
real, allocatable, dimension(:,:,:) :: S2 !< Squared shear frequency (1/s2)
real, allocatable, dimension(:,:,:) :: ri_grad !< Gradient Richardson number
Expand All @@ -52,22 +54,22 @@ module MOM_cvmix_shear
!> Subroutine for calculating (internal) vertical diffusivities/viscosities
subroutine calculate_cvmix_shear(u_H, v_H, h, tv, kd, &
kv, G, GV, CS )
type(ocean_grid_type), intent(in) :: G !< Grid structure.
type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure.
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_(G)), intent(in) :: u_H !< Initial zonal velocity on T points, in m s-1.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: v_H !< Initial meridional velocity on T points, in m s-1.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h !< Layer thickness, in 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 !< The vertical diffusivity at each interface
!! (not layer!) in m2 s-1.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)+1), intent(out) :: kv !< The vertical viscosity at each interface
!! (not layer!) in m2 s-1.
type(cvmix_shear_cs), pointer :: CS !< The control structure returned by a previous call to
!! CVMix_shear_init.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h !< Layer thickness, in 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 !< The vertical diffusivity at each interface
!! (not layer!) in m2 s-1.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)+1), intent(out) :: kv !< The vertical viscosity at each interface
!! (not layer!) in m2 s-1.
type(cvmix_shear_cs), pointer :: CS !< The control structure returned by a previous call to
!! CVMix_shear_init.
! Local variables
integer :: i, j, k, kk, km1
real :: gorho
real :: pref, DU, DV, DRHO, DZ, N2, S2
real :: GoRho
real :: pref, DU, DV, DRHO, DZ, N2, S2, dummy
real, dimension(2*(G%ke)) :: pres_1d, temp_1d, salt_1d, rho_1d
real, dimension(G%ke+1) :: Ri_Grad !< Gradient Richardson number

Expand Down Expand Up @@ -120,10 +122,21 @@ subroutine calculate_cvmix_shear(u_H, v_H, h, tv, kd, &
! fill 3d arrays, if user asks for diagsnostics
if (CS%id_N2 > 0) CS%N2(i,j,k) = N2
if (CS%id_S2 > 0) CS%S2(i,j,k) = S2
if (CS%id_ri_grad > 0) CS%ri_grad(i,j,k) = Ri_Grad(k)

enddo

! vertically smooth Ri with 1-2-1 weighting
if (CS%smooth_ri) then
dummy = 0.25 * Ri_grad(1)
Ri_grad(G%ke+1) = Ri_grad(G%ke)
do k = 1, G%ke
Ri_Grad(k) = dummy + 0.5 * Ri_Grad(k) + 0.25 * Ri_grad(k+1)
dummy = 0.25 * Ri_grad(k)
enddo
endif

if (CS%id_ri_grad > 0) CS%ri_grad(i,j,:) = Ri_Grad(:)

! Call to CVMix wrapper for computing interior mixing coefficients.
call cvmix_coeffs_shear(Mdiff_out=kv(i,j,:), &
Tdiff_out=kd(i,j,:), &
Expand Down Expand Up @@ -209,6 +222,10 @@ logical function cvmix_shear_init(Time, G, GV, param_file, diag, CS)
"Exponent of unitless factor of diffusivities,"// &
" for KPP internal shear mixing scheme." &
,units="nondim", default=3.0)
call get_param(param_file, mdl, "SMOOTH_RI", CS%smooth_ri, &
"If true, vertically smooth the Richardson"// &
"number by applying a 1-2-1 filter once.", &
default = .false.)
call cvmix_init_shear(mix_scheme=CS%mix_scheme, &
KPP_nu_zero=CS%Nu_Zero, &
KPP_Ri_zero=CS%Ri_zero, &
Expand Down

0 comments on commit 99ca9a7

Please sign in to comment.