dynldf_iso.F90 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. MODULE dynldf_iso
  2. !!======================================================================
  3. !! *** MODULE dynldf_iso ***
  4. !! Ocean dynamics: lateral viscosity trend
  5. !!======================================================================
  6. !! History : OPA ! 97-07 (G. Madec) Original code
  7. !! NEMO 1.0 ! 2002-08 (G. Madec) F90: Free form and module
  8. !! - ! 2004-08 (C. Talandier) New trends organization
  9. !! 2.0 ! 2005-11 (G. Madec) s-coordinate: horizontal diffusion
  10. !!----------------------------------------------------------------------
  11. #if defined key_ldfslp || defined key_esopa
  12. !!----------------------------------------------------------------------
  13. !! 'key_ldfslp' slopes of the direction of mixing
  14. !!----------------------------------------------------------------------
  15. !! dyn_ldf_iso : update the momentum trend with the horizontal part
  16. !! of the lateral diffusion using isopycnal or horizon-
  17. !! tal s-coordinate laplacian operator.
  18. !!----------------------------------------------------------------------
  19. USE oce ! ocean dynamics and tracers
  20. USE dom_oce ! ocean space and time domain
  21. USE ldfdyn_oce ! ocean dynamics lateral physics
  22. USE ldftra_oce ! ocean tracer lateral physics
  23. USE zdf_oce ! ocean vertical physics
  24. USE ldfslp ! iso-neutral slopes
  25. !
  26. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  27. USE in_out_manager ! I/O manager
  28. USE lib_mpp ! MPP library
  29. USE prtctl ! Print control
  30. USE wrk_nemo ! Memory Allocation
  31. USE timing ! Timing
  32. IMPLICIT NONE
  33. PRIVATE
  34. PUBLIC dyn_ldf_iso ! called by step.F90
  35. PUBLIC dyn_ldf_iso_alloc ! called by nemogcm.F90
  36. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: zfuw, zdiu, zdju, zdj1u ! 2D workspace (dyn_ldf_iso)
  37. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: zfvw, zdiv, zdjv, zdj1v ! - -
  38. !! * Substitutions
  39. # include "domzgr_substitute.h90"
  40. # include "ldfdyn_substitute.h90"
  41. # include "vectopt_loop_substitute.h90"
  42. !!----------------------------------------------------------------------
  43. !! NEMO/OPA 3.3 , NEMO Consortium (2011)
  44. !! $Id: dynldf_iso.F90 4990 2014-12-15 16:42:49Z timgraham $
  45. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  46. !!----------------------------------------------------------------------
  47. CONTAINS
  48. INTEGER FUNCTION dyn_ldf_iso_alloc()
  49. !!----------------------------------------------------------------------
  50. !! *** ROUTINE dyn_ldf_iso_alloc ***
  51. !!----------------------------------------------------------------------
  52. ALLOCATE( zfuw(jpi,jpk) , zdiu(jpi,jpk) , zdju(jpi,jpk) , zdj1u(jpi,jpk) , &
  53. & zfvw(jpi,jpk) , zdiv(jpi,jpk) , zdjv(jpi,jpk) , zdj1v(jpi,jpk) , STAT=dyn_ldf_iso_alloc )
  54. !
  55. IF( dyn_ldf_iso_alloc /= 0 ) CALL ctl_warn('dyn_ldf_iso_alloc: array allocate failed.')
  56. END FUNCTION dyn_ldf_iso_alloc
  57. SUBROUTINE dyn_ldf_iso( kt )
  58. !!----------------------------------------------------------------------
  59. !! *** ROUTINE dyn_ldf_iso ***
  60. !!
  61. !! ** Purpose : Compute the before trend of the rotated laplacian
  62. !! operator of lateral momentum diffusion except the diagonal
  63. !! vertical term that will be computed in dynzdf module. Add it
  64. !! to the general trend of momentum equation.
  65. !!
  66. !! ** Method :
  67. !! The momentum lateral diffusive trend is provided by a 2nd
  68. !! order operator rotated along neutral or geopotential surfaces
  69. !! (in s-coordinates).
  70. !! It is computed using before fields (forward in time) and isopyc-
  71. !! nal or geopotential slopes computed in routine ldfslp.
  72. !! Here, u and v components are considered as 2 independent scalar
  73. !! fields. Therefore, the property of splitting divergent and rota-
  74. !! tional part of the flow of the standard, z-coordinate laplacian
  75. !! momentum diffusion is lost.
  76. !! horizontal fluxes associated with the rotated lateral mixing:
  77. !! u-component:
  78. !! ziut = ( ahmt + ahmb0 ) e2t * e3t / e1t di[ ub ]
  79. !! - ahmt e2t * mi-1(uslp) dk[ mi(mk(ub)) ]
  80. !! zjuf = ( ahmf + ahmb0 ) e1f * e3f / e2f dj[ ub ]
  81. !! - ahmf e1f * mi(vslp) dk[ mj(mk(ub)) ]
  82. !! v-component:
  83. !! zivf = ( ahmf + ahmb0 ) e2t * e3t / e1t di[ vb ]
  84. !! - ahmf e2t * mj(uslp) dk[ mi(mk(vb)) ]
  85. !! zjvt = ( ahmt + ahmb0 ) e1f * e3f / e2f dj[ ub ]
  86. !! - ahmt e1f * mj-1(vslp) dk[ mj(mk(vb)) ]
  87. !! take the horizontal divergence of the fluxes:
  88. !! diffu = 1/(e1u*e2u*e3u) { di [ ziut ] + dj-1[ zjuf ] }
  89. !! diffv = 1/(e1v*e2v*e3v) { di-1[ zivf ] + dj [ zjvt ] }
  90. !! Add this trend to the general trend (ua,va):
  91. !! ua = ua + diffu
  92. !! CAUTION: here the isopycnal part is with a coeff. of aht. This
  93. !! should be modified for applications others than orca_r2 (!!bug)
  94. !!
  95. !! ** Action :
  96. !! Update (ua,va) arrays with the before geopotential biharmonic
  97. !! mixing trend.
  98. !! Update (avmu,avmv) to accompt for the diagonal vertical component
  99. !! of the rotated operator in dynzdf module
  100. !!----------------------------------------------------------------------
  101. !
  102. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  103. !
  104. INTEGER :: ji, jj, jk ! dummy loop indices
  105. REAL(wp) :: zabe1, zabe2, zcof1, zcof2 ! local scalars
  106. REAL(wp) :: zmskt, zmskf, zbu, zbv, zuah, zvah ! - -
  107. REAL(wp) :: zcoef0, zcoef3, zcoef4, zmkt, zmkf ! - -
  108. REAL(wp) :: zuav, zvav, zuwslpi, zuwslpj, zvwslpi, zvwslpj ! - -
  109. !
  110. REAL(wp), POINTER, DIMENSION(:,:) :: ziut, zjuf, zjvt, zivf, zdku, zdk1u, zdkv, zdk1v
  111. !!----------------------------------------------------------------------
  112. !
  113. IF( nn_timing == 1 ) CALL timing_start('dyn_ldf_iso')
  114. !
  115. CALL wrk_alloc( jpi, jpj, ziut, zjuf, zjvt, zivf, zdku, zdk1u, zdkv, zdk1v )
  116. !
  117. IF( kt == nit000 ) THEN
  118. IF(lwp) WRITE(numout,*)
  119. IF(lwp) WRITE(numout,*) 'dyn_ldf_iso : iso-neutral laplacian diffusive operator or '
  120. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate horizontal diffusive operator'
  121. ! ! allocate dyn_ldf_bilap arrays
  122. IF( dyn_ldf_iso_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_ldf_iso: failed to allocate arrays')
  123. ENDIF
  124. ! s-coordinate: Iso-level diffusion on tracer, but geopotential level diffusion on momentum
  125. IF( ln_dynldf_hor .AND. ln_traldf_iso ) THEN
  126. !
  127. DO jk = 1, jpk ! set the slopes of iso-level
  128. DO jj = 2, jpjm1
  129. DO ji = 2, jpim1
  130. uslp (ji,jj,jk) = -1./e1u(ji,jj) * ( fsdept_b(ji+1,jj,jk) - fsdept_b(ji ,jj ,jk) ) * umask(ji,jj,jk)
  131. vslp (ji,jj,jk) = -1./e2v(ji,jj) * ( fsdept_b(ji,jj+1,jk) - fsdept_b(ji ,jj ,jk) ) * vmask(ji,jj,jk)
  132. wslpi(ji,jj,jk) = -1./e1t(ji,jj) * ( fsdepw_b(ji+1,jj,jk) - fsdepw_b(ji-1,jj,jk) ) * tmask(ji,jj,jk) * 0.5
  133. wslpj(ji,jj,jk) = -1./e2t(ji,jj) * ( fsdepw_b(ji,jj+1,jk) - fsdepw_b(ji,jj-1,jk) ) * tmask(ji,jj,jk) * 0.5
  134. END DO
  135. END DO
  136. END DO
  137. ! Lateral boundary conditions on the slopes
  138. CALL lbc_lnk( uslp , 'U', -1. ) ; CALL lbc_lnk( vslp , 'V', -1. )
  139. CALL lbc_lnk( wslpi, 'W', -1. ) ; CALL lbc_lnk( wslpj, 'W', -1. )
  140. !!bug
  141. IF( kt == nit000 ) then
  142. IF(lwp) WRITE(numout,*) ' max slop: u', SQRT( MAXVAL(uslp*uslp)), ' v ', SQRT(MAXVAL(vslp)), &
  143. & ' wi', sqrt(MAXVAL(wslpi)) , ' wj', sqrt(MAXVAL(wslpj))
  144. endif
  145. !!end
  146. ENDIF
  147. ! ! ===============
  148. DO jk = 1, jpkm1 ! Horizontal slab
  149. ! ! ===============
  150. ! Vertical u- and v-shears at level jk and jk+1
  151. ! ---------------------------------------------
  152. ! surface boundary condition: zdku(jk=1)=zdku(jk=2)
  153. ! zdkv(jk=1)=zdkv(jk=2)
  154. zdk1u(:,:) = ( ub(:,:,jk) -ub(:,:,jk+1) ) * umask(:,:,jk+1)
  155. zdk1v(:,:) = ( vb(:,:,jk) -vb(:,:,jk+1) ) * vmask(:,:,jk+1)
  156. IF( jk == 1 ) THEN
  157. zdku(:,:) = zdk1u(:,:)
  158. zdkv(:,:) = zdk1v(:,:)
  159. ELSE
  160. zdku(:,:) = ( ub(:,:,jk-1) - ub(:,:,jk) ) * umask(:,:,jk)
  161. zdkv(:,:) = ( vb(:,:,jk-1) - vb(:,:,jk) ) * vmask(:,:,jk)
  162. ENDIF
  163. ! -----f-----
  164. ! Horizontal fluxes on U |
  165. ! --------------------=== t u t
  166. ! |
  167. ! i-flux at t-point -----f-----
  168. IF( ln_zps ) THEN ! z-coordinate - partial steps : min(e3u)
  169. DO jj = 2, jpjm1
  170. DO ji = fs_2, jpi ! vector opt.
  171. zabe1 = (fsahmt(ji,jj,jk)+ahmb0) * e2t(ji,jj) * MIN( fse3u(ji,jj,jk), fse3u(ji-1,jj,jk) ) / e1t(ji,jj)
  172. zmskt = 1./MAX( umask(ji-1,jj,jk )+umask(ji,jj,jk+1) &
  173. & + umask(ji-1,jj,jk+1)+umask(ji,jj,jk ), 1. )
  174. zcof1 = - aht0 * e2t(ji,jj) * zmskt * 0.5 * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
  175. ziut(ji,jj) = ( zabe1 * ( ub(ji,jj,jk) - ub(ji-1,jj,jk) ) &
  176. & + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj) &
  177. & +zdk1u(ji,jj) + zdku (ji-1,jj) ) ) * tmask(ji,jj,jk)
  178. END DO
  179. END DO
  180. ELSE ! other coordinate system (zco or sco) : e3t
  181. DO jj = 2, jpjm1
  182. DO ji = fs_2, jpi ! vector opt.
  183. zabe1 = (fsahmt(ji,jj,jk)+ahmb0) * e2t(ji,jj) * fse3t(ji,jj,jk) / e1t(ji,jj)
  184. zmskt = 1./MAX( umask(ji-1,jj,jk )+umask(ji,jj,jk+1) &
  185. & + umask(ji-1,jj,jk+1)+umask(ji,jj,jk ), 1. )
  186. zcof1 = - aht0 * e2t(ji,jj) * zmskt * 0.5 * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
  187. ziut(ji,jj) = ( zabe1 * ( ub(ji,jj,jk) - ub(ji-1,jj,jk) ) &
  188. & + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj) &
  189. & +zdk1u(ji,jj) + zdku (ji-1,jj) ) ) * tmask(ji,jj,jk)
  190. END DO
  191. END DO
  192. ENDIF
  193. ! j-flux at f-point
  194. DO jj = 1, jpjm1
  195. DO ji = 1, fs_jpim1 ! vector opt.
  196. zabe2 = ( fsahmf(ji,jj,jk) + ahmb0 ) * e1f(ji,jj) * fse3f(ji,jj,jk) / e2f(ji,jj)
  197. zmskf = 1./MAX( umask(ji,jj+1,jk )+umask(ji,jj,jk+1) &
  198. & + umask(ji,jj+1,jk+1)+umask(ji,jj,jk ), 1. )
  199. zcof2 = - aht0 * e1f(ji,jj) * zmskf * 0.5 * ( vslp(ji+1,jj,jk) + vslp(ji,jj,jk) )
  200. zjuf(ji,jj) = ( zabe2 * ( ub(ji,jj+1,jk) - ub(ji,jj,jk) ) &
  201. & + zcof2 * ( zdku (ji,jj+1) + zdk1u(ji,jj) &
  202. & +zdk1u(ji,jj+1) + zdku (ji,jj) ) ) * fmask(ji,jj,jk)
  203. END DO
  204. END DO
  205. ! | t |
  206. ! Horizontal fluxes on V | |
  207. ! --------------------=== f---v---f
  208. ! | |
  209. ! i-flux at f-point | t |
  210. DO jj = 2, jpjm1
  211. DO ji = 1, fs_jpim1 ! vector opt.
  212. zabe1 = ( fsahmf(ji,jj,jk) + ahmb0 ) * e2f(ji,jj) * fse3f(ji,jj,jk) / e1f(ji,jj)
  213. zmskf = 1./MAX( vmask(ji+1,jj,jk )+vmask(ji,jj,jk+1) &
  214. & + vmask(ji+1,jj,jk+1)+vmask(ji,jj,jk ), 1. )
  215. zcof1 = - aht0 * e2f(ji,jj) * zmskf * 0.5 * ( uslp(ji,jj+1,jk) + uslp(ji,jj,jk) )
  216. zivf(ji,jj) = ( zabe1 * ( vb(ji+1,jj,jk) - vb(ji,jj,jk) ) &
  217. & + zcof1 * ( zdkv (ji,jj) + zdk1v(ji+1,jj) &
  218. & +zdk1v(ji,jj) + zdkv (ji+1,jj) ) ) * fmask(ji,jj,jk)
  219. END DO
  220. END DO
  221. ! j-flux at t-point
  222. IF( ln_zps ) THEN ! z-coordinate - partial steps : min(e3u)
  223. DO jj = 2, jpj
  224. DO ji = 1, fs_jpim1 ! vector opt.
  225. zabe2 = (fsahmt(ji,jj,jk)+ahmb0) * e1t(ji,jj) * MIN( fse3v(ji,jj,jk), fse3v(ji,jj-1,jk) ) / e2t(ji,jj)
  226. zmskt = 1./MAX( vmask(ji,jj-1,jk )+vmask(ji,jj,jk+1) &
  227. & + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk ), 1. )
  228. zcof2 = - aht0 * e1t(ji,jj) * zmskt * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
  229. zjvt(ji,jj) = ( zabe2 * ( vb(ji,jj,jk) - vb(ji,jj-1,jk) ) &
  230. & + zcof2 * ( zdkv (ji,jj-1) + zdk1v(ji,jj) &
  231. & +zdk1v(ji,jj-1) + zdkv (ji,jj) ) ) * tmask(ji,jj,jk)
  232. END DO
  233. END DO
  234. ELSE ! other coordinate system (zco or sco) : e3t
  235. DO jj = 2, jpj
  236. DO ji = 1, fs_jpim1 ! vector opt.
  237. zabe2 = (fsahmt(ji,jj,jk)+ahmb0) * e1t(ji,jj) * fse3t(ji,jj,jk) / e2t(ji,jj)
  238. zmskt = 1./MAX( vmask(ji,jj-1,jk )+vmask(ji,jj,jk+1) &
  239. & + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk ), 1. )
  240. zcof2 = - aht0 * e1t(ji,jj) * zmskt * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
  241. zjvt(ji,jj) = ( zabe2 * ( vb(ji,jj,jk) - vb(ji,jj-1,jk) ) &
  242. & + zcof2 * ( zdkv (ji,jj-1) + zdk1v(ji,jj) &
  243. & +zdk1v(ji,jj-1) + zdkv (ji,jj) ) ) * tmask(ji,jj,jk)
  244. END DO
  245. END DO
  246. ENDIF
  247. ! Second derivative (divergence) and add to the general trend
  248. ! -----------------------------------------------------------
  249. DO jj = 2, jpjm1
  250. DO ji = 2, jpim1 !! Question vectop possible??? !!bug
  251. ! volume elements
  252. zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
  253. zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
  254. ! horizontal component of isopycnal momentum diffusive trends
  255. zuah =( ziut (ji+1,jj) - ziut (ji,jj ) + &
  256. & zjuf (ji ,jj) - zjuf (ji,jj-1) ) / zbu
  257. zvah =( zivf (ji,jj ) - zivf (ji-1,jj) + &
  258. & zjvt (ji,jj+1) - zjvt (ji,jj ) ) / zbv
  259. ! add the trends to the general trends
  260. ua (ji,jj,jk) = ua (ji,jj,jk) + zuah
  261. va (ji,jj,jk) = va (ji,jj,jk) + zvah
  262. END DO
  263. END DO
  264. ! ! ===============
  265. END DO ! End of slab
  266. ! ! ===============
  267. ! print sum trends (used for debugging)
  268. IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' ldfh - Ua: ', mask1=umask, &
  269. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  270. ! ! ===============
  271. DO jj = 2, jpjm1 ! Vertical slab
  272. ! ! ===============
  273. ! I. vertical trends associated with the lateral mixing
  274. ! =====================================================
  275. ! (excluding the vertical flux proportional to dk[t]
  276. ! I.1 horizontal momentum gradient
  277. ! --------------------------------
  278. DO jk = 1, jpk
  279. DO ji = 2, jpi
  280. ! i-gradient of u at jj
  281. zdiu (ji,jk) = tmask(ji,jj ,jk) * ( ub(ji,jj ,jk) - ub(ji-1,jj ,jk) )
  282. ! j-gradient of u and v at jj
  283. zdju (ji,jk) = fmask(ji,jj ,jk) * ( ub(ji,jj+1,jk) - ub(ji ,jj ,jk) )
  284. zdjv (ji,jk) = tmask(ji,jj ,jk) * ( vb(ji,jj ,jk) - vb(ji ,jj-1,jk) )
  285. ! j-gradient of u and v at jj+1
  286. zdj1u(ji,jk) = fmask(ji,jj-1,jk) * ( ub(ji,jj ,jk) - ub(ji ,jj-1,jk) )
  287. zdj1v(ji,jk) = tmask(ji,jj+1,jk) * ( vb(ji,jj+1,jk) - vb(ji ,jj ,jk) )
  288. END DO
  289. END DO
  290. DO jk = 1, jpk
  291. DO ji = 1, jpim1
  292. ! i-gradient of v at jj
  293. zdiv (ji,jk) = fmask(ji,jj ,jk) * ( vb(ji+1,jj,jk) - vb(ji ,jj ,jk) )
  294. END DO
  295. END DO
  296. ! I.2 Vertical fluxes
  297. ! -------------------
  298. ! Surface and bottom vertical fluxes set to zero
  299. DO ji = 1, jpi
  300. zfuw(ji, 1 ) = 0.e0
  301. zfvw(ji, 1 ) = 0.e0
  302. zfuw(ji,jpk) = 0.e0
  303. zfvw(ji,jpk) = 0.e0
  304. END DO
  305. ! interior (2=<jk=<jpk-1) on U field
  306. DO jk = 2, jpkm1
  307. DO ji = 2, jpim1
  308. zcoef0= 0.5 * aht0 * umask(ji,jj,jk)
  309. zuwslpi = zcoef0 * ( wslpi(ji+1,jj,jk) + wslpi(ji,jj,jk) )
  310. zuwslpj = zcoef0 * ( wslpj(ji+1,jj,jk) + wslpj(ji,jj,jk) )
  311. zmkt = 1./MAX( tmask(ji,jj,jk-1)+tmask(ji+1,jj,jk-1) &
  312. + tmask(ji,jj,jk )+tmask(ji+1,jj,jk ), 1. )
  313. zmkf = 1./MAX( fmask(ji,jj-1,jk-1)+fmask(ji,jj,jk-1) &
  314. + fmask(ji,jj-1,jk )+fmask(ji,jj,jk ), 1. )
  315. zcoef3 = - e2u(ji,jj) * zmkt * zuwslpi
  316. zcoef4 = - e1u(ji,jj) * zmkf * zuwslpj
  317. ! vertical flux on u field
  318. zfuw(ji,jk) = zcoef3 * ( zdiu (ji,jk-1) + zdiu (ji+1,jk-1) &
  319. +zdiu (ji,jk ) + zdiu (ji+1,jk ) ) &
  320. + zcoef4 * ( zdj1u(ji,jk-1) + zdju (ji ,jk-1) &
  321. +zdj1u(ji,jk ) + zdju (ji ,jk ) )
  322. ! update avmu (add isopycnal vertical coefficient to avmu)
  323. ! Caution: zcoef0 include aht0, so divided by aht0 to obtain slp^2 * aht0
  324. avmu(ji,jj,jk) = avmu(ji,jj,jk) + ( zuwslpi * zuwslpi + zuwslpj * zuwslpj ) / aht0
  325. END DO
  326. END DO
  327. ! interior (2=<jk=<jpk-1) on V field
  328. DO jk = 2, jpkm1
  329. DO ji = 2, jpim1
  330. zcoef0= 0.5 * aht0 * vmask(ji,jj,jk)
  331. zvwslpi = zcoef0 * ( wslpi(ji,jj+1,jk) + wslpi(ji,jj,jk) )
  332. zvwslpj = zcoef0 * ( wslpj(ji,jj+1,jk) + wslpj(ji,jj,jk) )
  333. zmkf = 1./MAX( fmask(ji-1,jj,jk-1)+fmask(ji,jj,jk-1) &
  334. + fmask(ji-1,jj,jk )+fmask(ji,jj,jk ), 1. )
  335. zmkt = 1./MAX( tmask(ji,jj,jk-1)+tmask(ji,jj+1,jk-1) &
  336. + tmask(ji,jj,jk )+tmask(ji,jj+1,jk ), 1. )
  337. zcoef3 = - e2v(ji,jj) * zmkf * zvwslpi
  338. zcoef4 = - e1v(ji,jj) * zmkt * zvwslpj
  339. ! vertical flux on v field
  340. zfvw(ji,jk) = zcoef3 * ( zdiv (ji,jk-1) + zdiv (ji-1,jk-1) &
  341. +zdiv (ji,jk ) + zdiv (ji-1,jk ) ) &
  342. + zcoef4 * ( zdjv (ji,jk-1) + zdj1v(ji ,jk-1) &
  343. +zdjv (ji,jk ) + zdj1v(ji ,jk ) )
  344. ! update avmv (add isopycnal vertical coefficient to avmv)
  345. ! Caution: zcoef0 include aht0, so divided by aht0 to obtain slp^2 * aht0
  346. avmv(ji,jj,jk) = avmv(ji,jj,jk) + ( zvwslpi * zvwslpi + zvwslpj * zvwslpj ) / aht0
  347. END DO
  348. END DO
  349. ! I.3 Divergence of vertical fluxes added to the general tracer trend
  350. ! -------------------------------------------------------------------
  351. DO jk = 1, jpkm1
  352. DO ji = 2, jpim1
  353. ! volume elements
  354. zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
  355. zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
  356. ! part of the k-component of isopycnal momentum diffusive trends
  357. zuav = ( zfuw(ji,jk) - zfuw(ji,jk+1) ) / zbu
  358. zvav = ( zfvw(ji,jk) - zfvw(ji,jk+1) ) / zbv
  359. ! add the trends to the general trends
  360. ua(ji,jj,jk) = ua(ji,jj,jk) + zuav
  361. va(ji,jj,jk) = va(ji,jj,jk) + zvav
  362. END DO
  363. END DO
  364. ! ! ===============
  365. END DO ! End of slab
  366. ! ! ===============
  367. CALL wrk_dealloc( jpi, jpj, ziut, zjuf, zjvt, zivf, zdku, zdk1u, zdkv, zdk1v )
  368. !
  369. IF( nn_timing == 1 ) CALL timing_stop('dyn_ldf_iso')
  370. !
  371. END SUBROUTINE dyn_ldf_iso
  372. # else
  373. !!----------------------------------------------------------------------
  374. !! Dummy module NO rotation of mixing tensor
  375. !!----------------------------------------------------------------------
  376. CONTAINS
  377. SUBROUTINE dyn_ldf_iso( kt ) ! Empty routine
  378. INTEGER, INTENT(in) :: kt
  379. WRITE(*,*) 'dyn_ldf_iso: You should not have seen this print! error?', kt
  380. END SUBROUTINE dyn_ldf_iso
  381. #endif
  382. !!======================================================================
  383. END MODULE dynldf_iso