zdftmx.F90 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. MODULE zdftmx
  2. !!========================================================================
  3. !! *** MODULE zdftmx ***
  4. !! Ocean physics: vertical tidal mixing coefficient
  5. !!========================================================================
  6. !! History : 1.0 ! 2004-04 (L. Bessieres, G. Madec) Original code
  7. !! - ! 2006-08 (A. Koch-Larrouy) Indonesian strait
  8. !! 3.3 ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase
  9. !!----------------------------------------------------------------------
  10. #if defined key_zdftmx || defined key_esopa
  11. !!----------------------------------------------------------------------
  12. !! 'key_zdftmx' Tidal vertical mixing
  13. !!----------------------------------------------------------------------
  14. !! zdf_tmx : global momentum & tracer Kz with tidal induced Kz
  15. !! tmx_itf : Indonesian momentum & tracer Kz with tidal induced Kz
  16. !!----------------------------------------------------------------------
  17. USE oce ! ocean dynamics and tracers variables
  18. USE dom_oce ! ocean space and time domain variables
  19. USE zdf_oce ! ocean vertical physics variables
  20. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  21. USE eosbn2 ! ocean equation of state
  22. USE phycst ! physical constants
  23. USE prtctl ! Print control
  24. USE in_out_manager ! I/O manager
  25. USE iom ! I/O Manager
  26. USE lib_mpp ! MPP library
  27. USE wrk_nemo ! work arrays
  28. USE timing ! Timing
  29. USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
  30. IMPLICIT NONE
  31. PRIVATE
  32. PUBLIC zdf_tmx ! called in step module
  33. PUBLIC zdf_tmx_init ! called in opa module
  34. PUBLIC zdf_tmx_alloc ! called in nemogcm module
  35. LOGICAL, PUBLIC, PARAMETER :: lk_zdftmx = .TRUE. !: tidal mixing flag
  36. ! !!* Namelist namzdf_tmx : tidal mixing *
  37. REAL(wp) :: rn_htmx ! vertical decay scale for turbulence (meters)
  38. REAL(wp) :: rn_n2min ! threshold of the Brunt-Vaisala frequency (s-1)
  39. REAL(wp) :: rn_tfe ! tidal dissipation efficiency (St Laurent et al. 2002)
  40. REAL(wp) :: rn_me ! mixing efficiency (Osborn 1980)
  41. LOGICAL :: ln_tmx_itf ! Indonesian Through Flow (ITF): Koch-Larrouy et al. (2007) parameterization
  42. REAL(wp) :: rn_tfe_itf ! ITF tidal dissipation efficiency (St Laurent et al. 2002)
  43. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: en_tmx ! energy available for tidal mixing (W/m2)
  44. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: mask_itf ! mask to use over Indonesian area
  45. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: az_tmx ! coefficient used to evaluate the tidal induced Kz
  46. !! * Substitutions
  47. # include "domzgr_substitute.h90"
  48. # include "vectopt_loop_substitute.h90"
  49. !!----------------------------------------------------------------------
  50. !! NEMO/OPA 4.0 , NEMO Consortium (2011)
  51. !! $Id: zdftmx.F90 4990 2014-12-15 16:42:49Z timgraham $
  52. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  53. !!----------------------------------------------------------------------
  54. CONTAINS
  55. INTEGER FUNCTION zdf_tmx_alloc()
  56. !!----------------------------------------------------------------------
  57. !! *** FUNCTION zdf_tmx_alloc ***
  58. !!----------------------------------------------------------------------
  59. ALLOCATE(en_tmx(jpi,jpj), mask_itf(jpi,jpj), az_tmx(jpi,jpj,jpk), STAT=zdf_tmx_alloc )
  60. !
  61. IF( lk_mpp ) CALL mpp_sum ( zdf_tmx_alloc )
  62. IF( zdf_tmx_alloc /= 0 ) CALL ctl_warn('zdf_tmx_alloc: failed to allocate arrays')
  63. END FUNCTION zdf_tmx_alloc
  64. SUBROUTINE zdf_tmx( kt )
  65. !!----------------------------------------------------------------------
  66. !! *** ROUTINE zdf_tmx ***
  67. !!
  68. !! ** Purpose : add to the vertical mixing coefficients the effect of
  69. !! tidal mixing (Simmons et al 2004).
  70. !!
  71. !! ** Method : - tidal-induced vertical mixing is given by:
  72. !! Kz_tides = az_tmx / max( rn_n2min, N^2 )
  73. !! where az_tmx is a coefficient that specified the 3D space
  74. !! distribution of the faction of tidal energy taht is used
  75. !! for mixing. Its expression is set in zdf_tmx_init routine,
  76. !! following Simmons et al. 2004.
  77. !! NB: a specific bounding procedure is performed on av_tide
  78. !! so that the input tidal energy is actually almost used. The
  79. !! basic maximum value is 60 cm2/s, but values of 300 cm2/s
  80. !! can be reached in area where bottom stratification is too
  81. !! weak.
  82. !!
  83. !! - update av_tide in the Indonesian Through Flow area
  84. !! following Koch-Larrouy et al. (2007) parameterisation
  85. !! (see tmx_itf routine).
  86. !!
  87. !! - update the model vertical eddy viscosity and diffusivity:
  88. !! avt = avt + av_tides
  89. !! avm = avm + av_tides
  90. !! avmu = avmu + mi(av_tides)
  91. !! avmv = avmv + mj(av_tides)
  92. !!
  93. !! ** Action : avt, avm, avmu, avmv increased by tidal mixing
  94. !!
  95. !! References : Simmons et al. 2004, Ocean Modelling, 6, 3-4, 245-263.
  96. !! Koch-Larrouy et al. 2007, GRL.
  97. !!----------------------------------------------------------------------
  98. USE oce, zav_tide => ua ! use ua as workspace
  99. !!
  100. INTEGER, INTENT(in) :: kt ! ocean time-step
  101. !!
  102. INTEGER :: ji, jj, jk ! dummy loop indices
  103. REAL(wp) :: ztpc ! scalar workspace
  104. REAL(wp), POINTER, DIMENSION(:,:) :: zkz
  105. !!----------------------------------------------------------------------
  106. !
  107. IF( nn_timing == 1 ) CALL timing_start('zdf_tmx')
  108. !
  109. CALL wrk_alloc( jpi,jpj, zkz )
  110. ! ! ----------------------- !
  111. ! ! Standard tidal mixing ! (compute zav_tide)
  112. ! ! ----------------------- !
  113. ! !* First estimation (with n2 bound by rn_n2min) bounded by 60 cm2/s
  114. zav_tide(:,:,:) = MIN( 60.e-4, az_tmx(:,:,:) / MAX( rn_n2min, rn2(:,:,:) ) )
  115. zkz(:,:) = 0.e0 !* Associated potential energy consummed over the whole water column
  116. DO jk = 2, jpkm1
  117. zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zav_tide(:,:,jk) * wmask(:,:,jk)
  118. END DO
  119. DO jj = 1, jpj !* Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
  120. DO ji = 1, jpi
  121. IF( zkz(ji,jj) /= 0.e0 ) zkz(ji,jj) = en_tmx(ji,jj) / zkz(ji,jj)
  122. END DO
  123. END DO
  124. DO jk = 2, jpkm1 !* Mutiply by zkz to recover en_tmx, BUT bound by 30/6 ==> zav_tide bound by 300 cm2/s
  125. DO jj = 1, jpj !* Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
  126. DO ji = 1, jpi
  127. zav_tide(ji,jj,jk) = zav_tide(ji,jj,jk) * MIN( zkz(ji,jj), 30./6. ) * wmask(ji,jj,jk) !kz max = 300 cm2/s
  128. END DO
  129. END DO
  130. END DO
  131. IF( kt == nit000 ) THEN !* check at first time-step: diagnose the energy consumed by zav_tide
  132. ztpc = 0.e0
  133. DO jk= 1, jpk
  134. DO jj= 1, jpj
  135. DO ji= 1, jpi
  136. ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) &
  137. & * MAX( 0.e0, rn2(ji,jj,jk) ) * zav_tide(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
  138. END DO
  139. END DO
  140. END DO
  141. ztpc= rau0 / ( rn_tfe * rn_me ) * ztpc
  142. IF(lwp) WRITE(numout,*)
  143. IF(lwp) WRITE(numout,*) ' N Total power consumption by av_tide : ztpc = ', ztpc * 1.e-12 ,'TW'
  144. ENDIF
  145. ! ! ----------------------- !
  146. ! ! ITF tidal mixing ! (update zav_tide)
  147. ! ! ----------------------- !
  148. IF( ln_tmx_itf ) CALL tmx_itf( kt, zav_tide )
  149. ! ! ----------------------- !
  150. ! ! Update mixing coefs !
  151. ! ! ----------------------- !
  152. DO jk = 2, jpkm1 !* update momentum & tracer diffusivity with tidal mixing
  153. DO jj = 1, jpj !* Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
  154. DO ji = 1, jpi
  155. avt(ji,jj,jk) = avt(ji,jj,jk) + zav_tide(ji,jj,jk) * wmask(ji,jj,jk)
  156. avm(ji,jj,jk) = avm(ji,jj,jk) + zav_tide(ji,jj,jk) * wmask(ji,jj,jk)
  157. END DO
  158. END DO
  159. END DO
  160. DO jk = 2, jpkm1 !* update momentum & tracer diffusivity with tidal mixing
  161. DO jj = 2, jpjm1
  162. DO ji = fs_2, fs_jpim1 ! vector opt.
  163. avmu(ji,jj,jk) = avmu(ji,jj,jk) + 0.5 * ( zav_tide(ji,jj,jk) + zav_tide(ji+1,jj ,jk) ) * wumask(ji,jj,jk)
  164. avmv(ji,jj,jk) = avmv(ji,jj,jk) + 0.5 * ( zav_tide(ji,jj,jk) + zav_tide(ji ,jj+1,jk) ) * wvmask(ji,jj,jk)
  165. END DO
  166. END DO
  167. END DO
  168. CALL lbc_lnk( avmu, 'U', 1. ) ; CALL lbc_lnk( avmv, 'V', 1. ) ! lateral boundary condition
  169. ! !* output tidal mixing coefficient
  170. CALL iom_put( "av_tide", zav_tide )
  171. IF(ln_ctl) CALL prt_ctl(tab3d_1=zav_tide , clinfo1=' tmx - av_tide: ', tab3d_2=avt, clinfo2=' avt: ', ovlap=1, kdim=jpk)
  172. !
  173. CALL wrk_dealloc( jpi,jpj, zkz )
  174. !
  175. IF( nn_timing == 1 ) CALL timing_stop('zdf_tmx')
  176. !
  177. END SUBROUTINE zdf_tmx
  178. SUBROUTINE tmx_itf( kt, pav )
  179. !!----------------------------------------------------------------------
  180. !! *** ROUTINE tmx_itf ***
  181. !!
  182. !! ** Purpose : modify the vertical eddy diffusivity coefficients
  183. !! (pav) in the Indonesian Through Flow area (ITF).
  184. !!
  185. !! ** Method : - Following Koch-Larrouy et al. (2007), in the ITF defined
  186. !! by msk_itf (read in a file, see tmx_init), the tidal
  187. !! mixing coefficient is computed with :
  188. !! * q=1 (i.e. all the tidal energy remains trapped in
  189. !! the area and thus is used for mixing)
  190. !! * the vertical distribution of the tifal energy is a
  191. !! proportional to N above the thermocline (d(N^2)/dz > 0)
  192. !! and to N^2 below the thermocline (d(N^2)/dz < 0)
  193. !!
  194. !! ** Action : av_tide updated in the ITF area (msk_itf)
  195. !!
  196. !! References : Koch-Larrouy et al. 2007, GRL
  197. !!----------------------------------------------------------------------
  198. INTEGER , INTENT(in ) :: kt ! ocean time-step
  199. REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: pav ! Tidal mixing coef.
  200. !!
  201. INTEGER :: ji, jj, jk ! dummy loop indices
  202. REAL(wp) :: zcoef, ztpc ! temporary scalar
  203. REAL(wp), DIMENSION(:,:) , POINTER :: zkz ! 2D workspace
  204. REAL(wp), DIMENSION(:,:) , POINTER :: zsum1 , zsum2 , zsum ! - -
  205. REAL(wp), DIMENSION(:,:,:), POINTER :: zempba_3d_1, zempba_3d_2 ! 3D workspace
  206. REAL(wp), DIMENSION(:,:,:), POINTER :: zempba_3d , zdn2dz ! - -
  207. REAL(wp), DIMENSION(:,:,:), POINTER :: zavt_itf ! - -
  208. !!----------------------------------------------------------------------
  209. !
  210. IF( nn_timing == 1 ) CALL timing_start('tmx_itf')
  211. !
  212. CALL wrk_alloc( jpi,jpj, zkz, zsum1 , zsum2 , zsum )
  213. CALL wrk_alloc( jpi,jpj,jpk, zempba_3d_1, zempba_3d_2, zempba_3d, zdn2dz, zavt_itf )
  214. ! ! compute the form function using N2 at each time step
  215. zdn2dz (:,:,jpk) = 0.e0
  216. zempba_3d_1(:,:,jpk) = 0.e0
  217. zempba_3d_2(:,:,jpk) = 0.e0
  218. DO jk = 1, jpkm1
  219. zdn2dz (:,:,jk) = rn2(:,:,jk) - rn2(:,:,jk+1) ! Vertical profile of dN2/dz
  220. !CDIR NOVERRCHK
  221. zempba_3d_1(:,:,jk) = SQRT( MAX( 0.e0, rn2(:,:,jk) ) ) ! - - of N
  222. zempba_3d_2(:,:,jk) = MAX( 0.e0, rn2(:,:,jk) ) ! - - of N^2
  223. END DO
  224. !
  225. zsum (:,:) = 0.e0
  226. zsum1(:,:) = 0.e0
  227. zsum2(:,:) = 0.e0
  228. DO jk= 2, jpk
  229. zsum1(:,:) = zsum1(:,:) + zempba_3d_1(:,:,jk) * fse3w(:,:,jk) * tmask(:,:,jk) * tmask(:,:,jk-1)
  230. zsum2(:,:) = zsum2(:,:) + zempba_3d_2(:,:,jk) * fse3w(:,:,jk) * tmask(:,:,jk) * tmask(:,:,jk-1)
  231. END DO
  232. DO jj = 1, jpj
  233. DO ji = 1, jpi
  234. IF( zsum1(ji,jj) /= 0.e0 ) zsum1(ji,jj) = 1.e0 / zsum1(ji,jj)
  235. IF( zsum2(ji,jj) /= 0.e0 ) zsum2(ji,jj) = 1.e0 / zsum2(ji,jj)
  236. END DO
  237. END DO
  238. DO jk= 1, jpk
  239. DO jj = 1, jpj
  240. DO ji = 1, jpi
  241. zcoef = 0.5 - SIGN( 0.5, zdn2dz(ji,jj,jk) ) ! =0 if dN2/dz > 0, =1 otherwise
  242. ztpc = zempba_3d_1(ji,jj,jk) * zsum1(ji,jj) * zcoef &
  243. & + zempba_3d_2(ji,jj,jk) * zsum2(ji,jj) * ( 1. - zcoef )
  244. !
  245. zempba_3d(ji,jj,jk) = ztpc
  246. zsum (ji,jj) = zsum(ji,jj) + ztpc * fse3w(ji,jj,jk)
  247. END DO
  248. END DO
  249. END DO
  250. DO jj = 1, jpj
  251. DO ji = 1, jpi
  252. IF( zsum(ji,jj) > 0.e0 ) zsum(ji,jj) = 1.e0 / zsum(ji,jj)
  253. END DO
  254. END DO
  255. ! ! first estimation bounded by 10 cm2/s (with n2 bounded by rn_n2min)
  256. zcoef = rn_tfe_itf / ( rn_tfe * rau0 )
  257. DO jk = 1, jpk
  258. zavt_itf(:,:,jk) = MIN( 10.e-4, zcoef * en_tmx(:,:) * zsum(:,:) * zempba_3d(:,:,jk) &
  259. & / MAX( rn_n2min, rn2(:,:,jk) ) * tmask(:,:,jk) )
  260. END DO
  261. zkz(:,:) = 0.e0 ! Associated potential energy consummed over the whole water column
  262. DO jk = 2, jpkm1
  263. zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zavt_itf(:,:,jk) * tmask(:,:,jk) * tmask(:,:,jk-1)
  264. END DO
  265. DO jj = 1, jpj ! Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
  266. DO ji = 1, jpi
  267. IF( zkz(ji,jj) /= 0.e0 ) zkz(ji,jj) = en_tmx(ji,jj) * rn_tfe_itf / rn_tfe / zkz(ji,jj)
  268. END DO
  269. END DO
  270. DO jk = 2, jpkm1 ! Mutiply by zkz to recover en_tmx, BUT bound by 30/6 ==> zavt_itf bound by 300 cm2/s
  271. zavt_itf(:,:,jk) = zavt_itf(:,:,jk) * MIN( zkz(:,:), 120./10. ) * tmask(:,:,jk) * tmask(:,:,jk-1) ! kz max = 120 cm2/s
  272. END DO
  273. IF( kt == nit000 ) THEN ! diagnose the nergy consumed by zavt_itf
  274. ztpc = 0.e0
  275. DO jk= 1, jpk
  276. DO jj= 1, jpj
  277. DO ji= 1, jpi
  278. ztpc = ztpc + e1t(ji,jj) * e2t(ji,jj) * fse3w(ji,jj,jk) * MAX( 0.e0, rn2(ji,jj,jk) ) &
  279. & * zavt_itf(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
  280. END DO
  281. END DO
  282. END DO
  283. ztpc= rau0 * ztpc / ( rn_me * rn_tfe_itf )
  284. IF(lwp) WRITE(numout,*) ' N Total power consumption by zavt_itf: ztpc = ', ztpc * 1.e-12 ,'TW'
  285. ENDIF
  286. ! ! Update pav with the ITF mixing coefficient
  287. DO jk = 2, jpkm1
  288. pav(:,:,jk) = pav (:,:,jk) * ( 1.e0 - mask_itf(:,:) ) &
  289. & + zavt_itf(:,:,jk) * mask_itf(:,:)
  290. END DO
  291. !
  292. CALL wrk_dealloc( jpi,jpj, zkz, zsum1 , zsum2 , zsum )
  293. CALL wrk_dealloc( jpi,jpj,jpk, zempba_3d_1, zempba_3d_2, zempba_3d, zdn2dz, zavt_itf )
  294. !
  295. IF( nn_timing == 1 ) CALL timing_stop('tmx_itf')
  296. !
  297. END SUBROUTINE tmx_itf
  298. SUBROUTINE zdf_tmx_init
  299. !!----------------------------------------------------------------------
  300. !! *** ROUTINE zdf_tmx_init ***
  301. !!
  302. !! ** Purpose : Initialization of the vertical tidal mixing, Reading
  303. !! of M2 and K1 tidal energy in nc files
  304. !!
  305. !! ** Method : - Read the namtmx namelist and check the parameters
  306. !!
  307. !! - Read the input data in NetCDF files :
  308. !! M2 and K1 tidal energy. The total tidal energy, en_tmx,
  309. !! is the sum of M2, K1 and S2 energy where S2 is assumed
  310. !! to be: S2=(1/2)^2 * M2
  311. !! mask_itf, a mask array that determine where substituing
  312. !! the standard Simmons et al. (2005) formulation with the
  313. !! one of Koch_Larrouy et al. (2007).
  314. !!
  315. !! - Compute az_tmx, a 3D coefficient that allows to compute
  316. !! the standard tidal-induced vertical mixing as follows:
  317. !! Kz_tides = az_tmx / max( rn_n2min, N^2 )
  318. !! with az_tmx a bottom intensified coefficient is given by:
  319. !! az_tmx(z) = en_tmx / ( rau0 * rn_htmx ) * EXP( -(H-z)/rn_htmx )
  320. !! / ( 1. - EXP( - H /rn_htmx ) )
  321. !! where rn_htmx the characteristic length scale of the bottom
  322. !! intensification, en_tmx the tidal energy, and H the ocean depth
  323. !!
  324. !! ** input : - Namlist namtmx
  325. !! - NetCDF file : M2_ORCA2.nc, K1_ORCA2.nc, and mask_itf.nc
  326. !!
  327. !! ** Action : - Increase by 1 the nstop flag is setting problem encounter
  328. !! - defined az_tmx used to compute tidal-induced mixing
  329. !!
  330. !! References : Simmons et al. 2004, Ocean Modelling, 6, 3-4, 245-263.
  331. !! Koch-Larrouy et al. 2007, GRL.
  332. !!----------------------------------------------------------------------
  333. USE oce , zav_tide => ua ! ua used as workspace
  334. !!
  335. INTEGER :: ji, jj, jk ! dummy loop indices
  336. INTEGER :: inum ! local integer
  337. INTEGER :: ios
  338. REAL(wp) :: ztpc, ze_z ! local scalars
  339. REAL(wp), DIMENSION(:,:) , POINTER :: zem2, zek1 ! read M2 and K1 tidal energy
  340. REAL(wp), DIMENSION(:,:) , POINTER :: zkz ! total M2, K1 and S2 tidal energy
  341. REAL(wp), DIMENSION(:,:) , POINTER :: zfact ! used for vertical structure function
  342. REAL(wp), DIMENSION(:,:) , POINTER :: zhdep ! Ocean depth
  343. REAL(wp), DIMENSION(:,:,:), POINTER :: zpc ! power consumption
  344. !!
  345. NAMELIST/namzdf_tmx/ rn_htmx, rn_n2min, rn_tfe, rn_me, ln_tmx_itf, rn_tfe_itf
  346. !!----------------------------------------------------------------------
  347. !
  348. IF( nn_timing == 1 ) CALL timing_start('zdf_tmx_init')
  349. !
  350. CALL wrk_alloc( jpi,jpj, zem2, zek1, zkz, zfact, zhdep )
  351. CALL wrk_alloc( jpi,jpj,jpk, zpc )
  352. REWIND( numnam_ref ) ! Namelist namzdf_tmx in reference namelist : Tidal Mixing
  353. READ ( numnam_ref, namzdf_tmx, IOSTAT = ios, ERR = 901)
  354. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_tmx in reference namelist', lwp )
  355. REWIND( numnam_cfg ) ! Namelist namzdf_tmx in configuration namelist : Tidal Mixing
  356. READ ( numnam_cfg, namzdf_tmx, IOSTAT = ios, ERR = 902 )
  357. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_tmx in configuration namelist', lwp )
  358. IF(lwm) WRITE ( numond, namzdf_tmx )
  359. IF(lwp) THEN ! Control print
  360. WRITE(numout,*)
  361. WRITE(numout,*) 'zdf_tmx_init : tidal mixing'
  362. WRITE(numout,*) '~~~~~~~~~~~~'
  363. WRITE(numout,*) ' Namelist namzdf_tmx : set tidal mixing parameters'
  364. WRITE(numout,*) ' Vertical decay scale for turbulence = ', rn_htmx
  365. WRITE(numout,*) ' Brunt-Vaisala frequency threshold = ', rn_n2min
  366. WRITE(numout,*) ' Tidal dissipation efficiency = ', rn_tfe
  367. WRITE(numout,*) ' Mixing efficiency = ', rn_me
  368. WRITE(numout,*) ' ITF specific parameterisation = ', ln_tmx_itf
  369. WRITE(numout,*) ' ITF tidal dissipation efficiency = ', rn_tfe_itf
  370. ENDIF
  371. ! ! allocate tmx arrays
  372. IF( zdf_tmx_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'zdf_tmx_init : unable to allocate tmx arrays' )
  373. IF( ln_tmx_itf ) THEN ! read the Indonesian Through Flow mask
  374. CALL iom_open('mask_itf',inum)
  375. CALL iom_get (inum, jpdom_data, 'tmaskitf',mask_itf,1) !
  376. CALL iom_close(inum)
  377. ENDIF
  378. ! read M2 tidal energy flux : W/m2 ( zem2 < 0 )
  379. CALL iom_open('M2rowdrg',inum)
  380. CALL iom_get (inum, jpdom_data, 'field',zem2,1) !
  381. CALL iom_close(inum)
  382. ! read K1 tidal energy flux : W/m2 ( zek1 < 0 )
  383. CALL iom_open('K1rowdrg',inum)
  384. CALL iom_get (inum, jpdom_data, 'field',zek1,1) !
  385. CALL iom_close(inum)
  386. ! Total tidal energy ( M2, S2 and K1 with S2=(1/2)^2 * M2 )
  387. ! only the energy available for mixing is taken into account,
  388. ! (mixing efficiency tidal dissipation efficiency)
  389. en_tmx(:,:) = - rn_tfe * rn_me * ( zem2(:,:) * 1.25 + zek1(:,:) ) * ssmask(:,:)
  390. !============
  391. !TG: Bug for VVL? Should this section be moved out of _init and be updated at every timestep?
  392. ! Vertical structure (az_tmx)
  393. DO jj = 1, jpj ! part independent of the level
  394. DO ji = 1, jpi
  395. zhdep(ji,jj) = gdepw_0(ji,jj,mbkt(ji,jj)+1) ! depth of the ocean
  396. zfact(ji,jj) = rau0 * rn_htmx * ( 1. - EXP( -zhdep(ji,jj) / rn_htmx ) )
  397. IF( zfact(ji,jj) /= 0 ) zfact(ji,jj) = en_tmx(ji,jj) / zfact(ji,jj)
  398. END DO
  399. END DO
  400. DO jk= 1, jpk ! complete with the level-dependent part
  401. DO jj = 1, jpj
  402. DO ji = 1, jpi
  403. az_tmx(ji,jj,jk) = zfact(ji,jj) * EXP( -( zhdep(ji,jj)-gdepw_0(ji,jj,jk) ) / rn_htmx ) * tmask(ji,jj,jk)
  404. END DO
  405. END DO
  406. END DO
  407. !===========
  408. IF( nprint == 1 .AND. lwp ) THEN
  409. ! Control print
  410. ! Total power consumption due to vertical mixing
  411. ! zpc = rau0 * 1/rn_me * rn2 * zav_tide
  412. zav_tide(:,:,:) = 0.e0
  413. DO jk = 2, jpkm1
  414. zav_tide(:,:,jk) = az_tmx(:,:,jk) / MAX( rn_n2min, rn2(:,:,jk) )
  415. END DO
  416. ztpc = 0.e0
  417. zpc(:,:,:) = MAX(rn_n2min,rn2(:,:,:)) * zav_tide(:,:,:)
  418. DO jk= 2, jpkm1
  419. DO jj = 1, jpj
  420. DO ji = 1, jpi
  421. ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) * zpc(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
  422. END DO
  423. END DO
  424. END DO
  425. ztpc= rau0 * 1/(rn_tfe * rn_me) * ztpc
  426. WRITE(numout,*)
  427. WRITE(numout,*) ' Total power consumption of the tidally driven part of Kz : ztpc = ', ztpc * 1.e-12 ,'TW'
  428. ! control print 2
  429. zav_tide(:,:,:) = MIN( zav_tide(:,:,:), 60.e-4 )
  430. zkz(:,:) = 0.e0
  431. DO jk = 2, jpkm1
  432. DO jj = 1, jpj
  433. DO ji = 1, jpi
  434. zkz(ji,jj) = zkz(ji,jj) + fse3w(ji,jj,jk) * MAX(0.e0, rn2(ji,jj,jk)) * rau0 * zav_tide(ji,jj,jk) * wmask(ji,jj,jk)
  435. END DO
  436. END DO
  437. END DO
  438. ! Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz
  439. DO jj = 1, jpj
  440. DO ji = 1, jpi
  441. IF( zkz(ji,jj) /= 0.e0 ) THEN
  442. zkz(ji,jj) = en_tmx(ji,jj) / zkz(ji,jj)
  443. ENDIF
  444. END DO
  445. END DO
  446. ztpc = 1.e50
  447. DO jj = 1, jpj
  448. DO ji = 1, jpi
  449. IF( zkz(ji,jj) /= 0.e0 ) THEN
  450. ztpc = Min( zkz(ji,jj), ztpc)
  451. ENDIF
  452. END DO
  453. END DO
  454. WRITE(numout,*) ' Min de zkz ', ztpc, ' Max = ', maxval(zkz(:,:) )
  455. DO jk = 2, jpkm1
  456. DO jj = 1, jpj
  457. DO ji = 1, jpi
  458. zav_tide(ji,jj,jk) = zav_tide(ji,jj,jk) * MIN( zkz(ji,jj), 30./6. ) * wmask(ji,jj,jk) !kz max = 300 cm2/s
  459. END DO
  460. END DO
  461. END DO
  462. ztpc = 0.e0
  463. zpc(:,:,:) = Max(0.e0,rn2(:,:,:)) * zav_tide(:,:,:)
  464. DO jk= 1, jpk
  465. DO jj = 1, jpj
  466. DO ji = 1, jpi
  467. ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) * zpc(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
  468. END DO
  469. END DO
  470. END DO
  471. ztpc= rau0 * 1/(rn_tfe * rn_me) * ztpc
  472. WRITE(numout,*) ' 2 Total power consumption of the tidally driven part of Kz : ztpc = ', ztpc * 1.e-12 ,'TW'
  473. DO jk = 1, jpk
  474. ze_z = SUM( e1t(:,:) * e2t(:,:) * zav_tide(:,:,jk) * tmask_i(:,:) ) &
  475. & / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * wmask (:,:,jk) * tmask_i(:,:) ) )
  476. ztpc = 1.E50
  477. DO jj = 1, jpj
  478. DO ji = 1, jpi
  479. IF( zav_tide(ji,jj,jk) /= 0.e0 ) ztpc =Min( ztpc, zav_tide(ji,jj,jk) )
  480. END DO
  481. END DO
  482. WRITE(numout,*) ' N2 min - jk= ', jk,' ', ze_z * 1.e4,' cm2/s min= ',ztpc*1.e4, &
  483. & 'max= ', MAXVAL(zav_tide(:,:,jk) )*1.e4, ' cm2/s'
  484. END DO
  485. WRITE(numout,*) ' e_tide : ', SUM( e1t*e2t*en_tmx ) / ( rn_tfe * rn_me ) * 1.e-12, 'TW'
  486. WRITE(numout,*)
  487. WRITE(numout,*) ' Initial profile of tidal vertical mixing'
  488. DO jk = 1, jpk
  489. DO jj = 1,jpj
  490. DO ji = 1,jpi
  491. zkz(ji,jj) = az_tmx(ji,jj,jk) /MAX( rn_n2min, rn2(ji,jj,jk) )
  492. END DO
  493. END DO
  494. ze_z = SUM( e1t(:,:) * e2t(:,:) * zkz(:,:) * tmask_i(:,:) ) &
  495. & / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * wmask (:,:,jk) * tmask_i(:,:) ) )
  496. WRITE(numout,*) ' jk= ', jk,' ', ze_z * 1.e4,' cm2/s'
  497. END DO
  498. DO jk = 1, jpk
  499. zkz(:,:) = az_tmx(:,:,jk) /rn_n2min
  500. ze_z = SUM( e1t(:,:) * e2t(:,:) * zkz(:,:) * tmask_i(:,:) ) &
  501. & / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * wmask (:,:,jk) * tmask_i(:,:) ) )
  502. WRITE(numout,*)
  503. WRITE(numout,*) ' N2 min - jk= ', jk,' ', ze_z * 1.e4,' cm2/s min= ',MINVAL(zkz)*1.e4, &
  504. & 'max= ', MAXVAL(zkz)*1.e4, ' cm2/s'
  505. END DO
  506. !
  507. ENDIF
  508. !
  509. CALL wrk_dealloc( jpi,jpj, zem2, zek1, zkz, zfact, zhdep )
  510. CALL wrk_dealloc( jpi,jpj,jpk, zpc )
  511. !
  512. IF( nn_timing == 1 ) CALL timing_stop('zdf_tmx_init')
  513. !
  514. END SUBROUTINE zdf_tmx_init
  515. #elif defined key_zdftmx_new
  516. !!----------------------------------------------------------------------
  517. !! 'key_zdftmx_new' Internal wave-driven vertical mixing
  518. !!----------------------------------------------------------------------
  519. !! zdf_tmx : global momentum & tracer Kz with wave induced Kz
  520. !! zdf_tmx_init : global momentum & tracer Kz with wave induced Kz
  521. !!----------------------------------------------------------------------
  522. USE oce ! ocean dynamics and tracers variables
  523. USE dom_oce ! ocean space and time domain variables
  524. USE zdf_oce ! ocean vertical physics variables
  525. USE zdfddm ! ocean vertical physics: double diffusive mixing
  526. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  527. USE eosbn2 ! ocean equation of state
  528. USE phycst ! physical constants
  529. USE prtctl ! Print control
  530. USE in_out_manager ! I/O manager
  531. USE iom ! I/O Manager
  532. USE lib_mpp ! MPP library
  533. USE wrk_nemo ! work arrays
  534. USE timing ! Timing
  535. USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
  536. IMPLICIT NONE
  537. PRIVATE
  538. PUBLIC zdf_tmx ! called in step module
  539. PUBLIC zdf_tmx_init ! called in nemogcm module
  540. PUBLIC zdf_tmx_alloc ! called in nemogcm module
  541. LOGICAL, PUBLIC, PARAMETER :: lk_zdftmx = .TRUE. !: wave-driven mixing flag
  542. ! !!* Namelist namzdf_tmx : internal wave-driven mixing *
  543. INTEGER :: nn_zpyc ! pycnocline-intensified mixing energy proportional to N (=1) or N^2 (=2)
  544. LOGICAL :: ln_mevar ! variable (=T) or constant (=F) mixing efficiency
  545. LOGICAL :: ln_tsdiff ! account for differential T/S wave-driven mixing (=T) or not (=F)
  546. REAL(wp) :: r1_6 = 1._wp / 6._wp
  547. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: ebot_tmx ! power available from high-mode wave breaking (W/m2)
  548. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: epyc_tmx ! power available from low-mode, pycnocline-intensified wave breaking (W/m2)
  549. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: ecri_tmx ! power available from low-mode, critical slope wave breaking (W/m2)
  550. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: hbot_tmx ! WKB decay scale for high-mode energy dissipation (m)
  551. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: hcri_tmx ! decay scale for low-mode critical slope dissipation (m)
  552. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: emix_tmx ! local energy density available for mixing (W/kg)
  553. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: bflx_tmx ! buoyancy flux Kz * N^2 (W/kg)
  554. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: pcmap_tmx ! vertically integrated buoyancy flux (W/m2)
  555. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: zav_ratio ! S/T diffusivity ratio (only for ln_tsdiff=T)
  556. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: zav_wave ! Internal wave-induced diffusivity
  557. !! * Substitutions
  558. # include "zdfddm_substitute.h90"
  559. # include "domzgr_substitute.h90"
  560. # include "vectopt_loop_substitute.h90"
  561. !!----------------------------------------------------------------------
  562. !! NEMO/OPA 4.0 , NEMO Consortium (2016)
  563. !! $Id$
  564. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  565. !!----------------------------------------------------------------------
  566. CONTAINS
  567. INTEGER FUNCTION zdf_tmx_alloc()
  568. !!----------------------------------------------------------------------
  569. !! *** FUNCTION zdf_tmx_alloc ***
  570. !!----------------------------------------------------------------------
  571. ALLOCATE( ebot_tmx(jpi,jpj), epyc_tmx(jpi,jpj), ecri_tmx(jpi,jpj) , &
  572. & hbot_tmx(jpi,jpj), hcri_tmx(jpi,jpj), emix_tmx(jpi,jpj,jpk), &
  573. & bflx_tmx(jpi,jpj,jpk), pcmap_tmx(jpi,jpj), zav_ratio(jpi,jpj,jpk), &
  574. & zav_wave(jpi,jpj,jpk), STAT=zdf_tmx_alloc )
  575. !
  576. IF( lk_mpp ) CALL mpp_sum ( zdf_tmx_alloc )
  577. IF( zdf_tmx_alloc /= 0 ) CALL ctl_warn('zdf_tmx_alloc: failed to allocate arrays')
  578. END FUNCTION zdf_tmx_alloc
  579. SUBROUTINE zdf_tmx( kt )
  580. !!----------------------------------------------------------------------
  581. !! *** ROUTINE zdf_tmx ***
  582. !!
  583. !! ** Purpose : add to the vertical mixing coefficients the effect of
  584. !! breaking internal waves.
  585. !!
  586. !! ** Method : - internal wave-driven vertical mixing is given by:
  587. !! Kz_wave = min( 100 cm2/s, f( Reb = emix_tmx /( Nu * N^2 ) )
  588. !! where emix_tmx is the 3D space distribution of the wave-breaking
  589. !! energy and Nu the molecular kinematic viscosity.
  590. !! The function f(Reb) is linear (constant mixing efficiency)
  591. !! if the namelist parameter ln_mevar = F and nonlinear if ln_mevar = T.
  592. !!
  593. !! - Compute emix_tmx, the 3D power density that allows to compute
  594. !! Reb and therefrom the wave-induced vertical diffusivity.
  595. !! This is divided into three components:
  596. !! 1. Bottom-intensified low-mode dissipation at critical slopes
  597. !! emix_tmx(z) = ( ecri_tmx / rau0 ) * EXP( -(H-z)/hcri_tmx )
  598. !! / ( 1. - EXP( - H/hcri_tmx ) ) * hcri_tmx
  599. !! where hcri_tmx is the characteristic length scale of the bottom
  600. !! intensification, ecri_tmx a map of available power, and H the ocean depth.
  601. !! 2. Pycnocline-intensified low-mode dissipation
  602. !! emix_tmx(z) = ( epyc_tmx / rau0 ) * ( sqrt(rn2(z))^nn_zpyc )
  603. !! / SUM( sqrt(rn2(z))^nn_zpyc * e3w(z) )
  604. !! where epyc_tmx is a map of available power, and nn_zpyc
  605. !! is the chosen stratification-dependence of the internal wave
  606. !! energy dissipation.
  607. !! 3. WKB-height dependent high mode dissipation
  608. !! emix_tmx(z) = ( ebot_tmx / rau0 ) * rn2(z) * EXP(-z_wkb(z)/hbot_tmx)
  609. !! / SUM( rn2(z) * EXP(-z_wkb(z)/hbot_tmx) * e3w(z) )
  610. !! where hbot_tmx is the characteristic length scale of the WKB bottom
  611. !! intensification, ebot_tmx is a map of available power, and z_wkb is the
  612. !! WKB-stretched height above bottom defined as
  613. !! z_wkb(z) = H * SUM( sqrt(rn2(z'>=z)) * e3w(z'>=z) )
  614. !! / SUM( sqrt(rn2(z')) * e3w(z') )
  615. !!
  616. !! - update the model vertical eddy viscosity and diffusivity:
  617. !! avt = avt + av_wave
  618. !! avm = avm + av_wave
  619. !! avmu = avmu + mi(av_wave)
  620. !! avmv = avmv + mj(av_wave)
  621. !!
  622. !! - if namelist parameter ln_tsdiff = T, account for differential mixing:
  623. !! avs = avt + av_wave * diffusivity_ratio(Reb)
  624. !!
  625. !! ** Action : - Define emix_tmx used to compute internal wave-induced mixing
  626. !! - avt, avs, avm, avmu, avmv increased by internal wave-driven mixing
  627. !!
  628. !! References : de Lavergne et al. 2015, JPO; 2016, in prep.
  629. !!----------------------------------------------------------------------
  630. INTEGER, INTENT(in) :: kt ! ocean time-step
  631. !
  632. INTEGER :: ji, jj, jk ! dummy loop indices
  633. REAL(wp) :: ztpc ! scalar workspace
  634. REAL(wp), DIMENSION(:,:) , POINTER :: zfact ! Used for vertical structure
  635. REAL(wp), DIMENSION(:,:) , POINTER :: zhdep ! Ocean depth
  636. REAL(wp), DIMENSION(:,:,:), POINTER :: zwkb ! WKB-stretched height above bottom
  637. REAL(wp), DIMENSION(:,:,:), POINTER :: zweight ! Weight for high mode vertical distribution
  638. REAL(wp), DIMENSION(:,:,:), POINTER :: znu_t ! Molecular kinematic viscosity (T grid)
  639. REAL(wp), DIMENSION(:,:,:), POINTER :: znu_w ! Molecular kinematic viscosity (W grid)
  640. REAL(wp), DIMENSION(:,:,:), POINTER :: zReb ! Turbulence intensity parameter
  641. !!----------------------------------------------------------------------
  642. !
  643. IF( nn_timing == 1 ) CALL timing_start('zdf_tmx')
  644. !
  645. CALL wrk_alloc( jpi,jpj, zfact, zhdep )
  646. CALL wrk_alloc( jpi,jpj,jpk, zwkb, zweight, znu_t, znu_w, zReb )
  647. ! ! ----------------------------- !
  648. ! ! Internal wave-driven mixing ! (compute zav_wave)
  649. ! ! ----------------------------- !
  650. !
  651. ! !* Critical slope mixing: distribute energy over the time-varying ocean depth,
  652. ! using an exponential decay from the seafloor.
  653. DO jj = 1, jpj ! part independent of the level
  654. DO ji = 1, jpi
  655. zhdep(ji,jj) = fsdepw(ji,jj,mbkt(ji,jj)+1) ! depth of the ocean
  656. zfact(ji,jj) = rau0 * ( 1._wp - EXP( -zhdep(ji,jj) / hcri_tmx(ji,jj) ) )
  657. IF( zfact(ji,jj) /= 0 ) zfact(ji,jj) = ecri_tmx(ji,jj) / zfact(ji,jj)
  658. END DO
  659. END DO
  660. DO jk = 2, jpkm1 ! complete with the level-dependent part
  661. emix_tmx(:,:,jk) = zfact(:,:) * ( EXP( ( fsde3w(:,:,jk ) - zhdep(:,:) ) / hcri_tmx(:,:) ) &
  662. & - EXP( ( fsde3w(:,:,jk-1) - zhdep(:,:) ) / hcri_tmx(:,:) ) ) * wmask(:,:,jk) &
  663. & / ( fsde3w(:,:,jk) - fsde3w(:,:,jk-1) )
  664. END DO
  665. ! !* Pycnocline-intensified mixing: distribute energy over the time-varying
  666. ! !* ocean depth as proportional to sqrt(rn2)^nn_zpyc
  667. SELECT CASE ( nn_zpyc )
  668. CASE ( 1 ) ! Dissipation scales as N (recommended)
  669. zfact(:,:) = 0._wp
  670. DO jk = 2, jpkm1 ! part independent of the level
  671. zfact(:,:) = zfact(:,:) + fse3w(:,:,jk) * SQRT( MAX( 0._wp, rn2(:,:,jk) ) ) * wmask(:,:,jk)
  672. END DO
  673. DO jj = 1, jpj
  674. DO ji = 1, jpi
  675. IF( zfact(ji,jj) /= 0 ) zfact(ji,jj) = epyc_tmx(ji,jj) / ( rau0 * zfact(ji,jj) )
  676. END DO
  677. END DO
  678. DO jk = 2, jpkm1 ! complete with the level-dependent part
  679. emix_tmx(:,:,jk) = emix_tmx(:,:,jk) + zfact(:,:) * SQRT( MAX( 0._wp, rn2(:,:,jk) ) ) * wmask(:,:,jk)
  680. END DO
  681. CASE ( 2 ) ! Dissipation scales as N^2
  682. zfact(:,:) = 0._wp
  683. DO jk = 2, jpkm1 ! part independent of the level
  684. zfact(:,:) = zfact(:,:) + fse3w(:,:,jk) * MAX( 0._wp, rn2(:,:,jk) ) * wmask(:,:,jk)
  685. END DO
  686. DO jj= 1, jpj
  687. DO ji = 1, jpi
  688. IF( zfact(ji,jj) /= 0 ) zfact(ji,jj) = epyc_tmx(ji,jj) / ( rau0 * zfact(ji,jj) )
  689. END DO
  690. END DO
  691. DO jk = 2, jpkm1 ! complete with the level-dependent part
  692. emix_tmx(:,:,jk) = emix_tmx(:,:,jk) + zfact(:,:) * MAX( 0._wp, rn2(:,:,jk) ) * wmask(:,:,jk)
  693. END DO
  694. END SELECT
  695. ! !* WKB-height dependent mixing: distribute energy over the time-varying
  696. ! !* ocean depth as proportional to rn2 * exp(-z_wkb/rn_hbot)
  697. zwkb(:,:,:) = 0._wp
  698. zfact(:,:) = 0._wp
  699. DO jk = 2, jpkm1
  700. zfact(:,:) = zfact(:,:) + fse3w(:,:,jk) * SQRT( MAX( 0._wp, rn2(:,:,jk) ) ) * wmask(:,:,jk)
  701. zwkb(:,:,jk) = zfact(:,:)
  702. END DO
  703. DO jk = 2, jpkm1
  704. DO jj = 1, jpj
  705. DO ji = 1, jpi
  706. IF( zfact(ji,jj) /= 0 ) zwkb(ji,jj,jk) = zhdep(ji,jj) * ( zfact(ji,jj) - zwkb(ji,jj,jk) ) &
  707. & * tmask(ji,jj,jk) / zfact(ji,jj)
  708. END DO
  709. END DO
  710. END DO
  711. zwkb(:,:,1) = zhdep(:,:) * tmask(:,:,1)
  712. zweight(:,:,:) = 0._wp
  713. DO jk = 2, jpkm1
  714. zweight(:,:,jk) = MAX( 0._wp, rn2(:,:,jk) ) * hbot_tmx(:,:) * wmask(:,:,jk) &
  715. & * ( EXP( -zwkb(:,:,jk) / hbot_tmx(:,:) ) - EXP( -zwkb(:,:,jk-1) / hbot_tmx(:,:) ) )
  716. END DO
  717. zfact(:,:) = 0._wp
  718. DO jk = 2, jpkm1 ! part independent of the level
  719. zfact(:,:) = zfact(:,:) + zweight(:,:,jk)
  720. END DO
  721. DO jj = 1, jpj
  722. DO ji = 1, jpi
  723. IF( zfact(ji,jj) /= 0 ) zfact(ji,jj) = ebot_tmx(ji,jj) / ( rau0 * zfact(ji,jj) )
  724. END DO
  725. END DO
  726. DO jk = 2, jpkm1 ! complete with the level-dependent part
  727. emix_tmx(:,:,jk) = emix_tmx(:,:,jk) + zweight(:,:,jk) * zfact(:,:) * wmask(:,:,jk) &
  728. & / ( fsde3w(:,:,jk) - fsde3w(:,:,jk-1) )
  729. END DO
  730. ! Calculate molecular kinematic viscosity
  731. znu_t(:,:,:) = 1.e-4_wp * ( 17.91_wp - 0.53810_wp * tsn(:,:,:,jp_tem) + 0.00694_wp * tsn(:,:,:,jp_tem) * tsn(:,:,:,jp_tem) &
  732. & + 0.02305_wp * tsn(:,:,:,jp_sal) ) * tmask(:,:,:) * r1_rau0
  733. DO jk = 2, jpkm1
  734. znu_w(:,:,jk) = 0.5_wp * ( znu_t(:,:,jk-1) + znu_t(:,:,jk) ) * wmask(:,:,jk)
  735. END DO
  736. ! Calculate turbulence intensity parameter Reb
  737. DO jk = 2, jpkm1
  738. zReb(:,:,jk) = emix_tmx(:,:,jk) / MAX( 1.e-20_wp, znu_w(:,:,jk) * rn2(:,:,jk) )
  739. END DO
  740. ! Define internal wave-induced diffusivity
  741. DO jk = 2, jpkm1
  742. zav_wave(:,:,jk) = znu_w(:,:,jk) * zReb(:,:,jk) * r1_6 ! This corresponds to a constant mixing efficiency of 1/6
  743. END DO
  744. IF( ln_mevar ) THEN ! Variable mixing efficiency case : modify zav_wave in the
  745. DO jk = 2, jpkm1 ! energetic (Reb > 480) and buoyancy-controlled (Reb <10.224 ) regimes
  746. DO jj = 1, jpj
  747. DO ji = 1, jpi
  748. IF( zReb(ji,jj,jk) > 480.00_wp ) THEN
  749. zav_wave(ji,jj,jk) = 3.6515_wp * znu_w(ji,jj,jk) * SQRT( zReb(ji,jj,jk) )
  750. ELSEIF( zReb(ji,jj,jk) < 10.224_wp ) THEN
  751. zav_wave(ji,jj,jk) = 0.052125_wp * znu_w(ji,jj,jk) * zReb(ji,jj,jk) * SQRT( zReb(ji,jj,jk) )
  752. ENDIF
  753. END DO
  754. END DO
  755. END DO
  756. ENDIF
  757. DO jk = 2, jpkm1 ! Bound diffusivity by molecular value and 100 cm2/s
  758. zav_wave(:,:,jk) = MIN( MAX( 1.4e-7_wp, zav_wave(:,:,jk) ), 1.e-2_wp ) * wmask(:,:,jk)
  759. END DO
  760. IF( kt == nit000 ) THEN !* Control print at first time-step: diagnose the energy consumed by zav_wave
  761. ztpc = 0._wp
  762. DO jk = 2, jpkm1
  763. DO jj = 1, jpj
  764. DO ji = 1, jpi
  765. ztpc = ztpc + fse3w(ji,jj,jk) * e1e2t(ji,jj) &
  766. & * MAX( 0._wp, rn2(ji,jj,jk) ) * zav_wave(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
  767. END DO
  768. END DO
  769. END DO
  770. IF( lk_mpp ) CALL mpp_sum( ztpc )
  771. ztpc = rau0 * ztpc ! Global integral of rauo * Kz * N^2 = power contributing to mixing
  772. IF(lwp) THEN
  773. WRITE(numout,*)
  774. WRITE(numout,*) 'zdf_tmx : Internal wave-driven mixing (tmx)'
  775. WRITE(numout,*) '~~~~~~~ '
  776. WRITE(numout,*)
  777. WRITE(numout,*) ' Total power consumption by av_wave: ztpc = ', ztpc * 1.e-12_wp, 'TW'
  778. ENDIF
  779. ENDIF
  780. ! ! ----------------------- !
  781. ! ! Update mixing coefs !
  782. ! ! ----------------------- !
  783. !
  784. IF( ln_tsdiff ) THEN !* Option for differential mixing of salinity and temperature
  785. DO jk = 2, jpkm1 ! Calculate S/T diffusivity ratio as a function of Reb
  786. DO jj = 1, jpj
  787. DO ji = 1, jpi
  788. zav_ratio(ji,jj,jk) = ( 0.505_wp + 0.495_wp * &
  789. & TANH( 0.92_wp * ( LOG10( MAX( 1.e-20_wp, zReb(ji,jj,jk) * 5._wp * r1_6 ) ) - 0.60_wp ) ) &
  790. & ) * wmask(ji,jj,jk)
  791. END DO
  792. END DO
  793. END DO
  794. CALL iom_put( "av_ratio", zav_ratio )
  795. DO jk = 2, jpkm1 !* update momentum & tracer diffusivity with wave-driven mixing
  796. fsavs(:,:,jk) = avt(:,:,jk) + zav_wave(:,:,jk) * zav_ratio(:,:,jk)
  797. avt (:,:,jk) = avt(:,:,jk) + zav_wave(:,:,jk)
  798. avm (:,:,jk) = avm(:,:,jk) + zav_wave(:,:,jk)
  799. END DO
  800. !
  801. ELSE !* update momentum & tracer diffusivity with wave-driven mixing
  802. DO jk = 2, jpkm1
  803. fsavs(:,:,jk) = avt(:,:,jk) + zav_wave(:,:,jk)
  804. avt (:,:,jk) = avt(:,:,jk) + zav_wave(:,:,jk)
  805. avm (:,:,jk) = avm(:,:,jk) + zav_wave(:,:,jk)
  806. END DO
  807. ENDIF
  808. DO jk = 2, jpkm1 !* update momentum diffusivity at wu and wv points
  809. DO jj = 2, jpjm1
  810. DO ji = fs_2, fs_jpim1 ! vector opt.
  811. avmu(ji,jj,jk) = avmu(ji,jj,jk) + 0.5_wp * ( zav_wave(ji,jj,jk) + zav_wave(ji+1,jj ,jk) ) * wumask(ji,jj,jk)
  812. avmv(ji,jj,jk) = avmv(ji,jj,jk) + 0.5_wp * ( zav_wave(ji,jj,jk) + zav_wave(ji ,jj+1,jk) ) * wvmask(ji,jj,jk)
  813. END DO
  814. END DO
  815. END DO
  816. CALL lbc_lnk( avmu, 'U', 1. ) ; CALL lbc_lnk( avmv, 'V', 1. ) ! lateral boundary condition
  817. ! !* output internal wave-driven mixing coefficient
  818. CALL iom_put( "av_wave", zav_wave )
  819. !* output useful diagnostics: N^2, Kz * N^2 (bflx_tmx),
  820. ! vertical integral of rau0 * Kz * N^2 (pcmap_tmx), energy density (emix_tmx)
  821. IF( iom_use("bflx_tmx") .OR. iom_use("pcmap_tmx") ) THEN
  822. bflx_tmx(:,:,:) = MAX( 0._wp, rn2(:,:,:) ) * zav_wave(:,:,:)
  823. pcmap_tmx(:,:) = 0._wp
  824. DO jk = 2, jpkm1
  825. pcmap_tmx(:,:) = pcmap_tmx(:,:) + fse3w(:,:,jk) * bflx_tmx(:,:,jk) * wmask(:,:,jk)
  826. END DO
  827. pcmap_tmx(:,:) = rau0 * pcmap_tmx(:,:)
  828. CALL iom_put( "bflx_tmx", bflx_tmx )
  829. CALL iom_put( "pcmap_tmx", pcmap_tmx )
  830. ENDIF
  831. CALL iom_put( "bn2", rn2 )
  832. CALL iom_put( "emix_tmx", emix_tmx )
  833. CALL wrk_dealloc( jpi,jpj, zfact, zhdep )
  834. CALL wrk_dealloc( jpi,jpj,jpk, zwkb, zweight, znu_t, znu_w, zReb )
  835. IF(ln_ctl) CALL prt_ctl(tab3d_1=zav_wave , clinfo1=' tmx - av_wave: ', tab3d_2=avt, clinfo2=' avt: ', ovlap=1, kdim=jpk)
  836. !
  837. IF( nn_timing == 1 ) CALL timing_stop('zdf_tmx')
  838. !
  839. END SUBROUTINE zdf_tmx
  840. SUBROUTINE zdf_tmx_init
  841. !!----------------------------------------------------------------------
  842. !! *** ROUTINE zdf_tmx_init ***
  843. !!
  844. !! ** Purpose : Initialization of the wave-driven vertical mixing, reading
  845. !! of input power maps and decay length scales in netcdf files.
  846. !!
  847. !! ** Method : - Read the namzdf_tmx namelist and check the parameters
  848. !!
  849. !! - Read the input data in NetCDF files :
  850. !! power available from high-mode wave breaking (mixing_power_bot.nc)
  851. !! power available from pycnocline-intensified wave-breaking (mixing_power_pyc.nc)
  852. !! power available from critical slope wave-breaking (mixing_power_cri.nc)
  853. !! WKB decay scale for high-mode wave-breaking (decay_scale_bot.nc)
  854. !! decay scale for critical slope wave-breaking (decay_scale_cri.nc)
  855. !!
  856. !! ** input : - Namlist namzdf_tmx
  857. !! - NetCDF files : mixing_power_bot.nc, mixing_power_pyc.nc, mixing_power_cri.nc,
  858. !! decay_scale_bot.nc decay_scale_cri.nc
  859. !!
  860. !! ** Action : - Increase by 1 the nstop flag is setting problem encounter
  861. !! - Define ebot_tmx, epyc_tmx, ecri_tmx, hbot_tmx, hcri_tmx
  862. !!
  863. !! References : de Lavergne et al. 2015, JPO; 2016, in prep.
  864. !!
  865. !!----------------------------------------------------------------------
  866. INTEGER :: ji, jj, jk ! dummy loop indices
  867. INTEGER :: inum ! local integer
  868. INTEGER :: ios
  869. REAL(wp) :: zbot, zpyc, zcri ! local scalars
  870. !!
  871. NAMELIST/namzdf_tmx_new/ nn_zpyc, ln_mevar, ln_tsdiff
  872. !!----------------------------------------------------------------------
  873. !
  874. IF( nn_timing == 1 ) CALL timing_start('zdf_tmx_init')
  875. !
  876. REWIND( numnam_ref ) ! Namelist namzdf_tmx in reference namelist : Wave-driven mixing
  877. READ ( numnam_ref, namzdf_tmx_new, IOSTAT = ios, ERR = 901)
  878. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_tmx in reference namelist', lwp )
  879. !
  880. REWIND( numnam_cfg ) ! Namelist namzdf_tmx in configuration namelist : Wave-driven mixing
  881. READ ( numnam_cfg, namzdf_tmx_new, IOSTAT = ios, ERR = 902 )
  882. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_tmx in configuration namelist', lwp )
  883. IF(lwm) WRITE ( numond, namzdf_tmx_new )
  884. !
  885. IF(lwp) THEN ! Control print
  886. WRITE(numout,*)
  887. WRITE(numout,*) 'zdf_tmx_init : internal wave-driven mixing'
  888. WRITE(numout,*) '~~~~~~~~~~~~'
  889. WRITE(numout,*) ' Namelist namzdf_tmx_new : set wave-driven mixing parameters'
  890. WRITE(numout,*) ' Pycnocline-intensified diss. scales as N (=1) or N^2 (=2) = ', nn_zpyc
  891. WRITE(numout,*) ' Variable (T) or constant (F) mixing efficiency = ', ln_mevar
  892. WRITE(numout,*) ' Differential internal wave-driven mixing (T) or not (F) = ', ln_tsdiff
  893. ENDIF
  894. ! The new wave-driven mixing parameterization elevates avt and avm in the interior, and
  895. ! ensures that avt remains larger than its molecular value (=1.4e-7). Therefore, avtb should
  896. ! be set here to a very small value, and avmb to its (uniform) molecular value (=1.4e-6).
  897. avmb(:) = 1.4e-6_wp ! viscous molecular value
  898. avtb(:) = 1.e-10_wp ! very small diffusive minimum (background avt is specified in zdf_tmx)
  899. avtb_2d(:,:) = 1.e0_wp ! uniform
  900. IF(lwp) THEN ! Control print
  901. WRITE(numout,*)
  902. WRITE(numout,*) ' Force the background value applied to avm & avt in TKE to be everywhere ', &
  903. & 'the viscous molecular value & a very small diffusive value, resp.'
  904. ENDIF
  905. IF( .NOT.lk_zdfddm ) CALL ctl_stop( 'STOP', 'zdf_tmx_init_new : key_zdftmx_new requires key_zdfddm' )
  906. ! ! allocate tmx arrays
  907. IF( zdf_tmx_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'zdf_tmx_init : unable to allocate tmx arrays' )
  908. !
  909. ! ! read necessary fields
  910. CALL iom_open('mixing_power_bot',inum) ! energy flux for high-mode wave breaking [W/m2]
  911. CALL iom_get (inum, jpdom_data, 'field', ebot_tmx, 1 )
  912. CALL iom_close(inum)
  913. !
  914. CALL iom_open('mixing_power_pyc',inum) ! energy flux for pynocline-intensified wave breaking [W/m2]
  915. CALL iom_get (inum, jpdom_data, 'field', epyc_tmx, 1 )
  916. CALL iom_close(inum)
  917. !
  918. CALL iom_open('mixing_power_cri',inum) ! energy flux for critical slope wave breaking [W/m2]
  919. CALL iom_get (inum, jpdom_data, 'field', ecri_tmx, 1 )
  920. CALL iom_close(inum)
  921. !
  922. CALL iom_open('decay_scale_bot',inum) ! spatially variable decay scale for high-mode wave breaking [m]
  923. CALL iom_get (inum, jpdom_data, 'field', hbot_tmx, 1 )
  924. CALL iom_close(inum)
  925. !
  926. CALL iom_open('decay_scale_cri',inum) ! spatially variable decay scale for critical slope wave breaking [m]
  927. CALL iom_get (inum, jpdom_data, 'field', hcri_tmx, 1 )
  928. CALL iom_close(inum)
  929. ebot_tmx(:,:) = ebot_tmx(:,:) * ssmask(:,:)
  930. epyc_tmx(:,:) = epyc_tmx(:,:) * ssmask(:,:)
  931. ecri_tmx(:,:) = ecri_tmx(:,:) * ssmask(:,:)
  932. ! Set once for all to zero the first and last vertical levels of appropriate variables
  933. emix_tmx (:,:, 1 ) = 0._wp
  934. emix_tmx (:,:,jpk) = 0._wp
  935. zav_ratio(:,:, 1 ) = 0._wp
  936. zav_ratio(:,:,jpk) = 0._wp
  937. zav_wave (:,:, 1 ) = 0._wp
  938. zav_wave (:,:,jpk) = 0._wp
  939. zbot = glob_sum( e1e2t(:,:) * ebot_tmx(:,:) )
  940. zpyc = glob_sum( e1e2t(:,:) * epyc_tmx(:,:) )
  941. zcri = glob_sum( e1e2t(:,:) * ecri_tmx(:,:) )
  942. IF(lwp) THEN
  943. WRITE(numout,*) ' High-mode wave-breaking energy: ', zbot * 1.e-12_wp, 'TW'
  944. WRITE(numout,*) ' Pycnocline-intensifed wave-breaking energy: ', zpyc * 1.e-12_wp, 'TW'
  945. WRITE(numout,*) ' Critical slope wave-breaking energy: ', zcri * 1.e-12_wp, 'TW'
  946. ENDIF
  947. !
  948. IF( nn_timing == 1 ) CALL timing_stop('zdf_tmx_init')
  949. !
  950. END SUBROUTINE zdf_tmx_init
  951. #else
  952. !!----------------------------------------------------------------------
  953. !! Default option Dummy module NO Tidal MiXing
  954. !!----------------------------------------------------------------------
  955. LOGICAL, PUBLIC, PARAMETER :: lk_zdftmx = .FALSE. !: tidal mixing flag
  956. CONTAINS
  957. SUBROUTINE zdf_tmx_init ! Dummy routine
  958. WRITE(*,*) 'zdf_tmx: You should not have seen this print! error?'
  959. END SUBROUTINE zdf_tmx_init
  960. SUBROUTINE zdf_tmx( kt ) ! Dummy routine
  961. WRITE(*,*) 'zdf_tmx: You should not have seen this print! error?', kt
  962. END SUBROUTINE zdf_tmx
  963. #endif
  964. !!======================================================================
  965. END MODULE zdftmx