Skip to content

Commit dca5736

Browse files
Add comments for adding additonal CVMix components and clean module
1 parent c6327d6 commit dca5736

File tree

1 file changed

+22
-61
lines changed

1 file changed

+22
-61
lines changed

src/parameterizations/vertical/MOM_set_diffusivity.F90

Lines changed: 22 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,6 @@ module MOM_set_diffusivity
22

33
! This file is part of MOM6. See LICENSE.md for the license.
44

5-
!********+*********+*********+*********+*********+*********+*********+**
6-
!* *
7-
!* By Robert Hallberg, September 1997 - June 2007 *
8-
!* *
9-
!* This file contains the subroutines that sets the diapycnal *
10-
!* diffusivity, perhaps adding up pieces that are calculated in other *
11-
!* files and passed in via the vertvisc type argument. *
12-
!* *
13-
!* A small fragment of the grid is shown below: *
14-
!* *
15-
!* j+1 x ^ x ^ x At x: q *
16-
!* j+1 > o > o > At ^: v *
17-
!* j x ^ x ^ x At >: u *
18-
!* j > o > o > At o: h, buoy, ustar, T, S, Kd, ea, eb, etc. *
19-
!* j-1 x ^ x ^ x *
20-
!* i-1 i i+1 At x & ^: *
21-
!* i i+1 At > & o: *
22-
!* *
23-
!* The boundaries always run through q grid points (x). *
24-
!* *
25-
!********+*********+*********+*********+*********+*********+*********+**
26-
275
use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end
286
use MOM_cpu_clock, only : CLOCK_MODULE_DRIVER, CLOCK_MODULE, CLOCK_ROUTINE
297
use MOM_diag_mediator, only : diag_ctrl, time_type
@@ -41,12 +19,11 @@ module MOM_set_diffusivity
4119
use MOM_intrinsic_functions, only : invcosh
4220
use MOM_io, only : slasher, vardesc, var_desc, MOM_read_data
4321
use MOM_kappa_shear, only : calculate_kappa_shear, kappa_shear_init, Kappa_shear_CS
44-
use MOM_cvmix_shear, only : calculate_cvmix_shear, cvmix_shear_init, cvmix_shear_CS
22+
use MOM_cvmix_shear, only : calculate_cvmix_shear, cvmix_shear_init, cvmix_shear_cs
4523
use MOM_string_functions, only : uppercase
4624
use MOM_thickness_diffuse, only : vert_fill_TS
4725
use MOM_variables, only : thermo_var_ptrs, vertvisc_type, p3d
48-
use MOM_verticalGrid, only : verticalGrid_type
49-
26+
use MOM_verticalGrid, only : verticalGrid_type
5027
use user_change_diffusivity, only : user_change_diff, user_change_diff_init
5128
use user_change_diffusivity, only : user_change_diff_end, user_change_diff_CS
5229

@@ -244,11 +221,9 @@ module MOM_set_diffusivity
244221
logical :: user_change_diff ! If true, call user-defined code to change diffusivity.
245222
logical :: useKappaShear ! If true, use the kappa_shear module to find the
246223
! shear-driven diapycnal diffusivity.
247-
248-
logical :: useCVmix ! If true, use one of the CVMix modules to find
224+
logical :: use_cvmix_shear ! If true, use one of the CVMix modules to find
249225
! shear-driven diapycnal diffusivity.
250-
251-
logical :: double_diffusion ! If true, enable double-diffusive mixing.
226+
logical :: double_diffusion ! If true, enable double-diffusive mixing.
252227
logical :: simple_TKE_to_Kd ! If true, uses a simple estimate of Kd/TKE that
253228
! does not rely on a layer-formulation.
254229
real :: Max_Rrho_salt_fingers ! max density ratio for salt fingering
@@ -266,7 +241,7 @@ module MOM_set_diffusivity
266241
type(user_change_diff_CS), pointer :: user_change_diff_CSp => NULL()
267242
type(diag_to_Z_CS), pointer :: diag_to_Z_CSp => NULL()
268243
type(Kappa_shear_CS), pointer :: kappaShear_CSp => NULL()
269-
type(CVMix_shear_CS), pointer :: CVMix_Shear_CSp => NULL()
244+
type(cvmix_shear_cs), pointer :: cvmix_shear_csp => NULL()
270245
type(int_tide_CS), pointer :: int_tide_CSp => NULL()
271246

272247
integer :: id_TKE_itidal = -1
@@ -380,22 +355,7 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, &
380355
optional, intent(out) :: Kd_int !< Diapycnal diffusivity at each interface
381356
!! (m2/sec).
382357

383-
! Arguments:
384-
! (in) u - zonal velocity (m/s)
385-
! (in) v - meridional velocity (m/s)
386-
! (in) h - Layer thickness (m or kg/m2)
387-
! (in) tv - structure with pointers to thermodynamic fields
388-
! (in) fluxes - structure of surface fluxes that may be used
389-
! (in) visc - structure containing vertical viscosities, bottom boundary
390-
! layer properies, and related fields
391-
! (in) dt - time increment (sec)
392-
! (in) G - ocean grid structure
393-
! (in) GV - The ocean's vertical grid structure.
394-
! (in) CS - module control structure
395-
! (in) j - meridional index upon which to work
396-
! (out) Kd - diapycnal diffusivity of each layer (m2/sec)
397-
! (out,opt) Kd_int - diapycnal diffusivity at each interface (m2/sec)
398-
358+
! local variables
399359
real, dimension(SZI_(G)) :: &
400360
depth, & ! distance from surface of an interface (meter)
401361
N2_bot ! bottom squared buoyancy frequency (1/s2)
@@ -580,9 +540,9 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, &
580540
call hchksum(visc%TKE_turb, "after calc_KS visc%TKE_turb",G%HI)
581541
endif
582542
if (showCallTree) call callTree_waypoint("done with calculate_kappa_shear (set_diffusivity)")
583-
elseif (CS%useCVMix) then
543+
elseif (CS%use_cvmix_shear) then
584544
!NOTE{BGR}: this needs to be cleaned up. It works in 1D case, but has not been tested outside.
585-
call calculate_cvmix_shear(u_h, v_h, h, tv, visc%Kd_turb, visc%Kv_turb,G,GV,CS%CVMix_shear_CSp)
545+
call calculate_cvmix_shear(u_h, v_h, h, tv, visc%Kd_turb, visc%Kv_turb,G,GV,CS%cvmix_shear_csp)
586546
elseif (associated(visc%Kv_turb)) then
587547
visc%Kv_turb(:,:,:) = 0. ! needed if calculate_kappa_shear is not enabled
588548
endif
@@ -674,6 +634,10 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, &
674634
Kd(i,j,k) = max(CS%Kd_min, Kd_sfc(i,j) * &
675635
((abs_sin * invcosh(N_2Omega/abs_sin)) * I_x30)*N02_N2)
676636
enddo ; enddo
637+
! GMM, CVMix "internal" bg mixing can go here
638+
!elseif (CS%use_cvmix_internal??) then
639+
640+
677641
else
678642
do k=1,nz ; do i=is,ie
679643
Kd(i,j,k) = Kd_sfc(i,j)
@@ -708,7 +672,7 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, &
708672
endif
709673

710674
! Add the input turbulent diffusivity.
711-
if (CS%useKappaShear .or. CS%useCVMix) then
675+
if (CS%useKappaShear .or. CS%use_cvmix_shear) then
712676
if (present(Kd_int)) then
713677
do K=2,nz ; do i=is,ie
714678
Kd_int(i,j,K) = visc%Kd_turb(i,j,K) + 0.5*(Kd(i,j,k-1) + Kd(i,j,k))
@@ -834,6 +798,7 @@ subroutine set_diffusivity(u, v, h, u_h, v_h, tv, fluxes, optics, visc, dt, &
834798
T_f, S_f, dd%Kd_user)
835799
endif
836800

801+
! GMM, post diags...
837802
if (CS%id_Kd_layer > 0) call post_data(CS%id_Kd_layer, Kd, CS%diag)
838803

839804
num_z_diags = 0
@@ -2533,6 +2498,7 @@ subroutine set_density_ratios(h, tv, kb, G, GV, CS, j, ds_dsp1, rho_0)
25332498

25342499
end subroutine set_density_ratios
25352500

2501+
!> Initialized the set_diffusivity module
25362502
subroutine set_diffusivity_init(Time, G, GV, param_file, diag, CS, diag_to_Z_CSp, int_tide_CSp)
25372503
type(time_type), intent(in) :: Time
25382504
type(ocean_grid_type), intent(inout) :: G !< The ocean's grid structure.
@@ -2547,21 +2513,14 @@ subroutine set_diffusivity_init(Time, G, GV, param_file, diag, CS, diag_to_Z_CSp
25472513
type(int_tide_CS), pointer :: int_tide_CSp !< pointer to the internal tides control
25482514
!! structure (BDM)
25492515

2550-
! Arguments:
2551-
! (in) Time - current model time
2552-
! (in) G - ocean grid structure
2553-
! (in) GV - The ocean's vertical grid structure.
2554-
! (in) param_file - structure indicating open file to parse for params
2555-
! (in) diag - structure used to regulate diagnostic output
2556-
! (in/out) CS - pointer set to point to the module control structure
2557-
! (in) diag_to_Z_CSp - pointer to the Z-diagnostics control structure
2558-
! (in) int_tide_CSp - pointer to the internal tides control structure (BDM)
2559-
2516+
! local variables
25602517
real :: decay_length, utide, zbot, hamp
25612518
type(vardesc) :: vd
25622519
logical :: read_tideamp, ML_use_omega
2520+
25632521
! This include declares and sets the variable "version".
25642522
#include "version_variable.h"
2523+
25652524
character(len=40) :: mdl = "MOM_set_diffusivity" ! This module's name.
25662525
character(len=20) :: tmpstr
25672526
character(len=200) :: filename, tideamp_file, h2_file, Niku_TKE_input_file
@@ -3131,6 +3090,8 @@ subroutine set_diffusivity_init(Time, G, GV, param_file, diag, CS, diag_to_Z_CSp
31313090
endif
31323091
endif
31333092

3093+
3094+
! GMM, the following should be moved to the DD module
31343095
call get_param(param_file, mdl, "DOUBLE_DIFFUSION", CS%double_diffusion, &
31353096
"If true, increase diffusivitives for temperature or salt \n"//&
31363097
"based on double-diffusive paramaterization from MOM4/KPP.", &
@@ -3181,9 +3142,9 @@ subroutine set_diffusivity_init(Time, G, GV, param_file, diag, CS, diag_to_Z_CSp
31813142
CS%useKappaShear = kappa_shear_init(Time, G, GV, param_file, CS%diag, CS%kappaShear_CSp)
31823143
if (CS%useKappaShear) &
31833144
id_clock_kappaShear = cpu_clock_id('(Ocean kappa_shear)', grain=CLOCK_MODULE)
3184-
CS%useCVMix = CVMix_shear_init(Time, G, GV, param_file, CS%diag, CS%CVMix_shear_CSp)
3185-
31863145

3146+
! CVMix shear-driven mixing
3147+
CS%use_cvmix_shear = cvmix_shear_init(Time, G, GV, param_file, CS%diag, CS%cvmix_shear_csp)
31873148

31883149
end subroutine set_diffusivity_init
31893150

0 commit comments

Comments
 (0)