This subroutine adds the effect of internal-tide-driven mixing to the layer diffusivities. The mechanisms considered are (1) local dissipation of internal waves generated by the barotropic flow ("itidal"), (2) local dissipation of internal waves generated by the propagating low modes (rays) of the internal tide ("lowmode"), and (3) local dissipation of internal lee waves. Will eventually need to add diffusivity due to other wave-breaking processes (e.g. Bottom friction, Froude-number-depending breaking, PSI, etc.).
939 type(ocean_grid_type),
intent(in) :: G
940 type(verticalGrid_type),
intent(in) :: GV
941 type(unit_scale_type),
intent(in) :: US
942 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
944 real,
dimension(SZI_(G)),
intent(in) :: N2_bot
946 real,
dimension(SZI_(G),SZK_(G)),
intent(in) :: N2_lay
948 integer,
intent(in) :: j
949 real,
dimension(SZI_(G),SZK_(G)),
intent(in) :: TKE_to_Kd
954 real,
dimension(SZI_(G),SZK_(G)),
intent(in) :: max_TKE
956 type(tidal_mixing_cs),
pointer :: CS
957 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
958 intent(inout) :: Kd_lay
959 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)+1), &
960 optional,
intent(inout) :: Kd_int
962 real,
intent(in) :: Kd_max
969 real,
dimension(SZI_(G)) :: &
990 tke_frac_top_lowmode, &
997 real :: TKE_itide_lay
999 real :: TKE_lowmode_lay
1006 real :: TKE_lowmode_tot
1008 logical :: use_Polzin, use_Simmons
1009 character(len=160) :: mesg
1010 integer :: i, k, is, ie, nz
1012 type(tidal_mixing_diags),
pointer :: dd => null()
1014 is = g%isc ; ie = g%iec ; nz = g%ke
1017 if (.not.(cs%Int_tide_dissipation .or. cs%Lee_wave_dissipation))
return
1019 do i=is,ie ; htot(i) = 0.0 ; inv_int(i) = 0.0 ; inv_int_lee(i) = 0.0 ; inv_int_low(i) = 0.0 ;
enddo
1020 do k=1,nz ;
do i=is,ie
1021 htot(i) = htot(i) + gv%H_to_Z*h(i,j,k)
1024 i_rho0 = 1.0/gv%Rho0
1026 use_polzin = ((cs%Int_tide_dissipation .and. (cs%int_tide_profile == polzin_09)) .or. &
1027 (cs%lee_wave_dissipation .and. (cs%lee_wave_profile == polzin_09)) .or. &
1028 (cs%Lowmode_itidal_dissipation .and. (cs%int_tide_profile == polzin_09)))
1029 use_simmons = ((cs%Int_tide_dissipation .and. (cs%int_tide_profile == stlaurent_02)) .or. &
1030 (cs%lee_wave_dissipation .and. (cs%lee_wave_profile == stlaurent_02)) .or. &
1031 (cs%Lowmode_itidal_dissipation .and. (cs%int_tide_profile == stlaurent_02)))
1035 if ( use_simmons )
then
1036 izeta = 1.0 / max(cs%Int_tide_decay_scale, gv%H_subroundoff*gv%H_to_Z)
1037 izeta_lee = 1.0 / max(cs%Int_tide_decay_scale*cs%Decay_scale_factor_lee, &
1038 gv%H_subroundoff*gv%H_to_Z)
1040 cs%Nb(i,j) = sqrt(n2_bot(i))
1041 if (
associated(dd%N2_bot)) dd%N2_bot(i,j) = n2_bot(i)
1042 if ( cs%Int_tide_dissipation )
then
1043 if (izeta*htot(i) > 1.0e-14)
then
1044 inv_int(i) = 1.0 / (1.0 - exp(-izeta*htot(i)))
1047 if ( cs%Lee_wave_dissipation )
then
1048 if (izeta_lee*htot(i) > 1.0e-14)
then
1049 inv_int_lee(i) = 1.0 / (1.0 - exp(-izeta_lee*htot(i)))
1052 if ( cs%Lowmode_itidal_dissipation)
then
1053 if (izeta*htot(i) > 1.0e-14)
then
1054 inv_int_low(i) = 1.0 / (1.0 - exp(-izeta*htot(i)))
1057 z_from_bot(i) = gv%H_to_Z*h(i,j,nz)
1062 if ( use_polzin )
then
1064 do i=is,ie ; n2_meanz(i) = 0.0 ;
enddo
1065 do k=1,nz ;
do i=is,ie
1066 n2_meanz(i) = n2_meanz(i) + n2_lay(i,k) * gv%H_to_Z * h(i,j,k)
1069 n2_meanz(i) = n2_meanz(i) / (htot(i) + gv%H_subroundoff*gv%H_to_Z)
1070 if (
associated(dd%N2_meanz)) dd%N2_meanz(i,j) = n2_meanz(i)
1074 do i=is,ie ; htot_wkb(i) = htot(i) ;
enddo
1082 cs%Nb(i,j) = sqrt(n2_bot(i))
1083 if (cs%answers_2018)
then
1084 if ((cs%tideamp(i,j) > 0.0) .and. &
1085 (cs%kappa_itides**2 * cs%h2(i,j) * cs%Nb(i,j)**3 > 1.0e-14*us%T_to_s**3) )
then
1086 z0_polzin(i) = cs%Polzin_decay_scale_factor * cs%Nu_Polzin * &
1087 cs%Nbotref_Polzin**2 * cs%tideamp(i,j) / &
1088 ( cs%kappa_itides**2 * cs%h2(i,j) * cs%Nb(i,j)**3 )
1089 if (z0_polzin(i) < cs%Polzin_min_decay_scale) &
1090 z0_polzin(i) = cs%Polzin_min_decay_scale
1091 if (n2_meanz(i) > 1.0e-14*us%T_to_s**2 )
then
1092 z0_polzin_scaled(i) = z0_polzin(i)*cs%Nb(i,j)**2 / n2_meanz(i)
1094 z0_polzin_scaled(i) = cs%Polzin_decay_scale_max_factor * htot(i)
1096 if (z0_polzin_scaled(i) > (cs%Polzin_decay_scale_max_factor * htot(i)) ) &
1097 z0_polzin_scaled(i) = cs%Polzin_decay_scale_max_factor * htot(i)
1099 z0_polzin(i) = cs%Polzin_decay_scale_max_factor * htot(i)
1100 z0_polzin_scaled(i) = cs%Polzin_decay_scale_max_factor * htot(i)
1103 z0ps_num = (cs%Polzin_decay_scale_factor * cs%Nu_Polzin * cs%Nbotref_Polzin**2) * cs%tideamp(i,j)
1104 z0ps_denom = ( cs%kappa_itides**2 * cs%h2(i,j) * cs%Nb(i,j) * n2_meanz(i) )
1105 if ((cs%tideamp(i,j) > 0.0) .and. &
1106 (z0ps_num < z0ps_denom * cs%Polzin_decay_scale_max_factor * htot(i)))
then
1107 z0_polzin_scaled(i) = z0ps_num / z0ps_denom
1109 if (abs(n2_meanz(i) * z0_polzin_scaled(i)) < &
1110 cs%Nb(i,j)**2 * (cs%Polzin_decay_scale_max_factor * htot(i)))
then
1111 z0_polzin(i) = z0_polzin_scaled(i) * (n2_meanz(i) / cs%Nb(i,j)**2)
1113 z0_polzin(i) = cs%Polzin_decay_scale_max_factor * htot(i)
1116 z0_polzin(i) = cs%Polzin_decay_scale_max_factor * htot(i)
1117 z0_polzin_scaled(i) = cs%Polzin_decay_scale_max_factor * htot(i)
1121 if (
associated(dd%Polzin_decay_scale)) &
1122 dd%Polzin_decay_scale(i,j) = z0_polzin(i)
1123 if (
associated(dd%Polzin_decay_scale_scaled)) &
1124 dd%Polzin_decay_scale_scaled(i,j) = z0_polzin_scaled(i)
1125 if (
associated(dd%N2_bot)) dd%N2_bot(i,j) = cs%Nb(i,j)*cs%Nb(i,j)
1127 if (cs%answers_2018)
then
1129 if ( cs%Int_tide_dissipation .and. (cs%int_tide_profile == polzin_09) )
then
1130 if (htot_wkb(i) > 1.0e-14*us%m_to_Z) &
1131 inv_int(i) = ( z0_polzin_scaled(i) / htot_wkb(i) ) + 1.0
1133 if ( cs%lee_wave_dissipation .and. (cs%lee_wave_profile == polzin_09) )
then
1134 if (htot_wkb(i) > 1.0e-14*us%m_to_Z) &
1135 inv_int_lee(i) = ( z0_polzin_scaled(i)*cs%Decay_scale_factor_lee / htot_wkb(i) ) + 1.0
1137 if ( cs%Lowmode_itidal_dissipation .and. (cs%int_tide_profile == polzin_09) )
then
1138 if (htot_wkb(i) > 1.0e-14*us%m_to_Z) &
1139 inv_int_low(i) = ( z0_polzin_scaled(i) / htot_wkb(i) ) + 1.0
1143 inv_int(i) = 0.0 ; inv_int_lee(i) = 0.0 ; inv_int_low(i) = 0.0
1144 if ( cs%Int_tide_dissipation .and. (cs%int_tide_profile == polzin_09) )
then
1145 if (z0_polzin_scaled(i) < 1.0e14 * htot_wkb(i)) &
1146 inv_int(i) = ( z0_polzin_scaled(i) / htot_wkb(i) ) + 1.0
1148 if ( cs%lee_wave_dissipation .and. (cs%lee_wave_profile == polzin_09) )
then
1149 if (z0_polzin_scaled(i) < 1.0e14 * htot_wkb(i)) &
1150 inv_int_lee(i) = ( z0_polzin_scaled(i)*cs%Decay_scale_factor_lee / htot_wkb(i) ) + 1.0
1152 if ( cs%Lowmode_itidal_dissipation .and. (cs%int_tide_profile == polzin_09) )
then
1153 if (z0_polzin_scaled(i) < 1.0e14 * htot_wkb(i)) &
1154 inv_int_low(i) = ( z0_polzin_scaled(i) / htot_wkb(i) ) + 1.0
1158 z_from_bot(i) = gv%H_to_Z*h(i,j,nz)
1160 if (cs%answers_2018)
then
1161 if (n2_meanz(i) > 1.0e-14*us%T_to_s**2 )
then
1162 z_from_bot_wkb(i) = gv%H_to_Z*h(i,j,nz) * n2_lay(i,nz) / n2_meanz(i)
1163 else ; z_from_bot_wkb(i) = 0 ;
endif
1165 if (gv%H_to_Z*h(i,j,nz) * n2_lay(i,nz) < n2_meanz(i) * (1.0e14 * htot_wkb(i)))
then
1166 z_from_bot_wkb(i) = gv%H_to_Z*h(i,j,nz) * n2_lay(i,nz) / n2_meanz(i)
1167 else ; z_from_bot_wkb(i) = 0 ;
endif
1176 tke_itidal_bot(i) = min(cs%TKE_itidal(i,j)*cs%Nb(i,j), cs%TKE_itide_max)
1177 if (
associated(dd%TKE_itidal_used)) &
1178 dd%TKE_itidal_used(i,j) = tke_itidal_bot(i)
1179 tke_itidal_bot(i) = (i_rho0 * cs%Mu_itides * cs%Gamma_itides) * tke_itidal_bot(i)
1181 tke_niku_bot(i) = 0.0
1182 if (cs%Lee_wave_dissipation)
then
1183 tke_niku_bot(i) = (i_rho0 * cs%Mu_itides * cs%Gamma_lee) * cs%TKE_Niku(i,j)
1186 tke_lowmode_tot = 0.0
1187 tke_lowmode_bot(i) = 0.0
1188 if (cs%Lowmode_itidal_dissipation)
then
1193 write (mesg,*)
"========", __file__, __line__
1194 call mom_error(fatal,trim(mesg)//
": this block not supported yet. (aa)")
1196 tke_lowmode_bot(i) = cs%Mu_itides * i_rho0 * tke_lowmode_tot
1199 tke_itidal_rem(i) = inv_int(i) * tke_itidal_bot(i)
1200 tke_niku_rem(i) = inv_int_lee(i) * tke_niku_bot(i)
1201 tke_lowmode_rem(i) = inv_int_low(i) * tke_lowmode_bot(i)
1203 if (
associated(dd%Fl_itidal)) dd%Fl_itidal(i,j,nz) = tke_itidal_rem(i)
1208 if ( use_simmons )
then
1209 do k=nz-1,2,-1 ;
do i=is,ie
1210 if (max_tke(i,k) <= 0.0) cycle
1211 z_from_bot(i) = z_from_bot(i) + gv%H_to_Z*h(i,j,k)
1214 tke_frac_top(i) = inv_int(i) * exp(-izeta * z_from_bot(i))
1215 tke_frac_top_lee(i) = inv_int_lee(i) * exp(-izeta_lee * z_from_bot(i))
1216 tke_frac_top_lowmode(i) = inv_int_low(i) * exp(-izeta * z_from_bot(i))
1220 tke_itide_lay = tke_itidal_rem(i) - tke_itidal_bot(i) * tke_frac_top(i)
1221 tke_niku_lay = tke_niku_rem(i) - tke_niku_bot(i) * tke_frac_top_lee(i)
1222 tke_lowmode_lay = tke_lowmode_rem(i) - tke_lowmode_bot(i)* tke_frac_top_lowmode(i)
1225 if (tke_itide_lay + tke_niku_lay + tke_lowmode_lay > (max_tke(i,k)))
then
1226 frac_used = (max_tke(i,k)) / (tke_itide_lay + tke_niku_lay + tke_lowmode_lay)
1227 tke_itide_lay = frac_used * tke_itide_lay
1228 tke_niku_lay = frac_used * tke_niku_lay
1229 tke_lowmode_lay = frac_used * tke_lowmode_lay
1233 tke_itidal_rem(i) = tke_itidal_rem(i) - tke_itide_lay
1234 tke_niku_rem(i) = tke_niku_rem(i) - tke_niku_lay
1235 tke_lowmode_rem(i) = tke_lowmode_rem(i) - tke_lowmode_lay
1238 kd_add = tke_to_kd(i,k) * (tke_itide_lay + tke_niku_lay + tke_lowmode_lay)
1240 if (kd_max >= 0.0) kd_add = min(kd_add, kd_max)
1241 kd_lay(i,j,k) = kd_lay(i,j,k) + kd_add
1243 if (
present(kd_int))
then
1244 kd_int(i,j,k) = kd_int(i,j,k) + 0.5 * kd_add
1245 kd_int(i,j,k+1) = kd_int(i,j,k+1) + 0.5 * kd_add
1249 if (
associated(dd%Kd_itidal))
then
1252 kd_add = tke_to_kd(i,k) * tke_itide_lay
1253 if (kd_max >= 0.0) kd_add = min(kd_add, kd_max)
1254 if (k>1) dd%Kd_itidal(i,j,k) = dd%Kd_itidal(i,j,k) + 0.5*kd_add
1255 if (k<nz) dd%Kd_itidal(i,j,k+1) = dd%Kd_itidal(i,j,k+1) + 0.5*kd_add
1257 if (
associated(dd%Kd_Itidal_work)) &
1258 dd%Kd_itidal_work(i,j,k) = gv%Rho0 * tke_itide_lay
1259 if (
associated(dd%Fl_itidal)) dd%Fl_itidal(i,j,k) = tke_itidal_rem(i)
1261 if (
associated(dd%Kd_Niku))
then
1264 kd_add = tke_to_kd(i,k) * tke_niku_lay
1265 if (kd_max >= 0.0) kd_add = min(kd_add, kd_max)
1266 if (k>1) dd%Kd_Niku(i,j,k) = dd%Kd_Niku(i,j,k) + 0.5*kd_add
1267 if (k<nz) dd%Kd_Niku(i,j,k+1) = dd%Kd_Niku(i,j,k+1) + 0.5*kd_add
1270 if (
associated(dd%Kd_Niku_work)) &
1271 dd%Kd_Niku_work(i,j,k) = gv%Rho0 * tke_niku_lay
1273 if (
associated(dd%Kd_lowmode))
then
1276 kd_add = tke_to_kd(i,k) * tke_lowmode_lay
1277 if (kd_max >= 0.0) kd_add = min(kd_add, kd_max)
1278 if (k>1) dd%Kd_lowmode(i,j,k) = dd%Kd_lowmode(i,j,k) + 0.5*kd_add
1279 if (k<nz) dd%Kd_lowmode(i,j,k+1) = dd%Kd_lowmode(i,j,k+1) + 0.5*kd_add
1281 if (
associated(dd%Kd_lowmode_work)) &
1282 dd%Kd_lowmode_work(i,j,k) = gv%Rho0 * tke_lowmode_lay
1283 if (
associated(dd%Fl_lowmode)) dd%Fl_lowmode(i,j,k) = tke_lowmode_rem(i)
1289 if ( use_polzin )
then
1290 do k=nz-1,2,-1 ;
do i=is,ie
1291 if (max_tke(i,k) <= 0.0) cycle
1292 z_from_bot(i) = z_from_bot(i) + gv%H_to_Z*h(i,j,k)
1293 if (n2_meanz(i) > 1.0e-14*us%T_to_s**2 )
then
1294 z_from_bot_wkb(i) = z_from_bot_wkb(i) &
1295 + gv%H_to_Z * h(i,j,k) * n2_lay(i,k) / n2_meanz(i)
1296 else ; z_from_bot_wkb(i) = 0 ;
endif
1299 tke_frac_top(i) = ( inv_int(i) * z0_polzin_scaled(i) ) / &
1300 ( z0_polzin_scaled(i) + z_from_bot_wkb(i) )
1301 z0_psl = z0_polzin_scaled(i)*cs%Decay_scale_factor_lee
1302 tke_frac_top_lee(i) = (inv_int_lee(i) * z0_psl) / (z0_psl + z_from_bot_wkb(i))
1303 tke_frac_top_lowmode(i) = ( inv_int_low(i) * z0_polzin_scaled(i) ) / &
1304 ( z0_polzin_scaled(i) + z_from_bot_wkb(i) )
1308 tke_itide_lay = tke_itidal_rem(i) - tke_itidal_bot(i) *tke_frac_top(i)
1309 tke_niku_lay = tke_niku_rem(i) - tke_niku_bot(i) * tke_frac_top_lee(i)
1310 tke_lowmode_lay = tke_lowmode_rem(i) - tke_lowmode_bot(i)*tke_frac_top_lowmode(i)
1313 if (tke_itide_lay + tke_niku_lay + tke_lowmode_lay > (max_tke(i,k)))
then
1314 frac_used = (max_tke(i,k)) / (tke_itide_lay + tke_niku_lay + tke_lowmode_lay)
1315 tke_itide_lay = frac_used * tke_itide_lay
1316 tke_niku_lay = frac_used * tke_niku_lay
1317 tke_lowmode_lay = frac_used * tke_lowmode_lay
1321 tke_itidal_rem(i) = tke_itidal_rem(i) - tke_itide_lay
1322 tke_niku_rem(i) = tke_niku_rem(i) - tke_niku_lay
1323 tke_lowmode_rem(i) = tke_lowmode_rem(i) - tke_lowmode_lay
1326 kd_add = tke_to_kd(i,k) * (tke_itide_lay + tke_niku_lay + tke_lowmode_lay)
1328 if (kd_max >= 0.0) kd_add = min(kd_add, kd_max)
1329 kd_lay(i,j,k) = kd_lay(i,j,k) + kd_add
1331 if (
present(kd_int))
then
1332 kd_int(i,j,k) = kd_int(i,j,k) + 0.5 * kd_add
1333 kd_int(i,j,k+1) = kd_int(i,j,k+1) + 0.5 * kd_add
1337 if (
associated(dd%Kd_itidal))
then
1340 kd_add = tke_to_kd(i,k) * tke_itide_lay
1341 if (kd_max >= 0.0) kd_add = min(kd_add, kd_max)
1342 if (k>1) dd%Kd_itidal(i,j,k) = dd%Kd_itidal(i,j,k) + 0.5*kd_add
1343 if (k<nz) dd%Kd_itidal(i,j,k+1) = dd%Kd_itidal(i,j,k+1) + 0.5*kd_add
1345 if (
associated(dd%Kd_Itidal_work)) &
1346 dd%Kd_itidal_work(i,j,k) = gv%Rho0 * tke_itide_lay
1347 if (
associated(dd%Fl_itidal)) dd%Fl_itidal(i,j,k) = tke_itidal_rem(i)
1349 if (
associated(dd%Kd_Niku))
then
1352 kd_add = tke_to_kd(i,k) * tke_niku_lay
1353 if (kd_max >= 0.0) kd_add = min(kd_add, kd_max)
1354 if (k>1) dd%Kd_Niku(i,j,k) = dd%Kd_Niku(i,j,k) + 0.5*kd_add
1355 if (k<nz) dd%Kd_Niku(i,j,k+1) = dd%Kd_Niku(i,j,k+1) + 0.5*kd_add
1358 if (
associated(dd%Kd_Niku_work)) dd%Kd_Niku_work(i,j,k) = gv%Rho0 * tke_niku_lay
1360 if (
associated(dd%Kd_lowmode))
then
1363 kd_add = tke_to_kd(i,k) * tke_lowmode_lay
1364 if (kd_max >= 0.0) kd_add = min(kd_add, kd_max)
1365 if (k>1) dd%Kd_lowmode(i,j,k) = dd%Kd_lowmode(i,j,k) + 0.5*kd_add
1366 if (k<nz) dd%Kd_lowmode(i,j,k+1) = dd%Kd_lowmode(i,j,k+1) + 0.5*kd_add
1368 if (
associated(dd%Kd_lowmode_work)) &
1369 dd%Kd_lowmode_work(i,j,k) = gv%Rho0 * tke_lowmode_lay
1370 if (
associated(dd%Fl_lowmode)) dd%Fl_lowmode(i,j,k) = tke_lowmode_rem(i)