Skip to content

Commit

Permalink
Raname variables Kd -> kd_lay; visc%Kv_slow - > kv
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-marques committed Apr 3, 2018
1 parent 648018e commit 1218973
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
31 changes: 14 additions & 17 deletions src/parameterizations/vertical/MOM_bkgnd_mixing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,17 @@ end subroutine sfc_bkgnd_mixing


!> Calculates the vertical background diffusivities/viscosities
subroutine calculate_bkgnd_mixing(h, tv, N2_lay, Kd, visc, j, G, GV, CS)
subroutine calculate_bkgnd_mixing(h, tv, N2_lay, kd_lay, kv, j, G, GV, CS)

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) :: h !< Layer thickness, in m or kg m-2.
type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamics structure.
real, dimension(SZI_(G),SZK_(G)), intent(in) :: N2_lay!< squared buoyancy frequency associated
!! with layers (1/s2)
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(inout) :: Kd !< Diapycnal diffusivity of each layer (m2/sec).
type(vertvisc_type), intent(inout) :: visc!< Structure containing vertical viscosities,
!! bottom boundary layer properies, and related
!! fields.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(inout) :: kd_lay!< Diapycnal diffusivity of each layer m2 s-1.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)+1), intent(out) :: kv !< The "slow" vertical viscosity at each interface
!! (not layer!) in m2 s-1.
integer, intent(in) :: j !< Meridional grid indice.
type(bkgnd_mixing_cs), pointer :: CS !< The control structure returned by
!! a previous call to bkgnd_mixing_init.
Expand Down Expand Up @@ -365,7 +364,7 @@ subroutine calculate_bkgnd_mixing(h, tv, N2_lay, Kd, visc, j, G, GV, CS)

! Update Kd
do k=1,nz
Kd(i,j,k) = Kd(i,j,k) + 0.5*(CS%kd_bkgnd(i,j,K) + CS%kd_bkgnd(i,j,K+1))
kd_lay(i,j,k) = kd_lay(i,j,k) + 0.5*(CS%kd_bkgnd(i,j,K) + CS%kd_bkgnd(i,j,K+1))
enddo
enddo ! i loop

Expand All @@ -378,7 +377,7 @@ subroutine calculate_bkgnd_mixing(h, tv, N2_lay, Kd, visc, j, G, GV, CS)
if (depth_c <= CS%Hmix) then ; CS%kd_bkgnd(i,j,k) = CS%Kdml
elseif (depth_c >= 2.0*CS%Hmix) then ; CS%kd_bkgnd(i,j,k) = CS%Kd_sfc(i,j)
else
Kd(i,j,k) = ((CS%Kd_sfc(i,j) - CS%Kdml) * I_Hmix) * depth_c + &
kd_lay(i,j,k) = ((CS%Kd_sfc(i,j) - CS%Kdml) * I_Hmix) * depth_c + &
(2.0*CS%Kdml - CS%Kd_sfc(i,j))
endif

Expand All @@ -391,13 +390,13 @@ subroutine calculate_bkgnd_mixing(h, tv, N2_lay, Kd, visc, j, G, GV, CS)
abs_sin = max(epsilon,abs(sin(G%geoLatT(i,j)*deg_to_rad)))
N_2Omega = max(abs_sin,sqrt(N2_lay(i,k))*I_2Omega)
N02_N2 = (CS%N0_2Omega/N_2Omega)**2
Kd(i,j,k) = max(CS%Kd_min, CS%Kd_sfc(i,j) * &
kd_lay(i,j,k) = max(CS%Kd_min, CS%Kd_sfc(i,j) * &
((abs_sin * invcosh(N_2Omega/abs_sin)) * I_x30)*N02_N2)
enddo ; enddo

else
do k=1,nz ; do i=is,ie
Kd(i,j,k) = CS%Kd_sfc(i,j)
kd_lay(i,j,k) = CS%Kd_sfc(i,j)
enddo ; enddo
endif

Expand All @@ -407,20 +406,18 @@ subroutine calculate_bkgnd_mixing(h, tv, N2_lay, Kd, visc, j, G, GV, CS)
CS%kd_bkgnd(i,j,1) = 0.0; CS%kv_bkgnd(i,j,1) = 0.0
CS%kd_bkgnd(i,j,nz+1) = 0.0; CS%kv_bkgnd(i,j,nz+1) = 0.0
do k=2,nz
CS%kd_bkgnd(i,j,k) = CS%kd_bkgnd(i,j,k) + 0.5*(Kd(i,j,K-1) + Kd(i,j,K))
CS%kd_bkgnd(i,j,k) = CS%kd_bkgnd(i,j,k) + 0.5*(kd_lay(i,j,K-1) + kd_lay(i,j,K))
CS%kv_bkgnd(i,j,k) = CS%kd_bkgnd(i,j,k) * CS%prandtl_bkgnd
enddo
enddo
endif

! Update visc%Kv_slow, if associated
if (associated(visc%Kv_slow)) then
do i=is,ie
do k=1,nz+1
visc%Kv_slow(i,j,k) = visc%Kv_slow(i,j,k) + CS%kv_bkgnd(i,j,k)
enddo
! Update kv
do i=is,ie
do k=1,nz+1
kv(i,j,k) = kv(i,j,k) + CS%kv_bkgnd(i,j,k)
enddo
endif
enddo

end subroutine calculate_bkgnd_mixing

Expand Down
8 changes: 1 addition & 7 deletions src/parameterizations/vertical/MOM_set_diffusivity.F90
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, &
endif

! add background mixing
call calculate_bkgnd_mixing(h, tv, N2_lay, Kd, visc, j, G, GV, CS%bkgnd_mixing_csp)
call calculate_bkgnd_mixing(h, tv, N2_lay, Kd, visc%Kv_slow, j, G, GV, CS%bkgnd_mixing_csp)

! GMM, the following will go into the MOM_cvmix_double_diffusion module
if (CS%double_diffusion) then
Expand Down Expand Up @@ -629,12 +629,6 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, &
if (CS%debug) then
call hchksum(Kd ,"Kd",G%HI,haloshift=0)

!!if (associated(CS%bkgnd_mixing_csp%kd_bkgnd)) &
!1 call hchksum(CS%bkgnd_mixing_csp%kd_bkgnd, "kd_bkgnd",G%HI,haloshift=0)

!!if (associated(CS%bkgnd_mixing_csp%kv_bkgnd)) &
!! call hchksum(CS%bkgnd_mixing_csp%kv_bkgnd, "kv_bkgnd",G%HI,haloshift=0)

if (CS%useKappaShear) call hchksum(visc%Kd_shear,"Turbulent Kd",G%HI,haloshift=0)

if (associated(visc%kv_bbl_u) .and. associated(visc%kv_bbl_v)) then
Expand Down

0 comments on commit 1218973

Please sign in to comment.