dynzdf_imp.F90 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. MODULE dynzdf_imp
  2. !!======================================================================
  3. !! *** MODULE dynzdf_imp ***
  4. !! Ocean dynamics: vertical component(s) of the momentum mixing trend
  5. !!======================================================================
  6. !! History : OPA ! 1990-10 (B. Blanke) Original code
  7. !! 8.0 ! 1997-05 (G. Madec) vertical component of isopycnal
  8. !! NEMO 0.5 ! 2002-08 (G. Madec) F90: Free form and module
  9. !! 3.3 ! 2010-04 (M. Leclair, G. Madec) Forcing averaged over 2 time steps
  10. !! 3.4 ! 2012-01 (H. Liu) Semi-implicit bottom friction
  11. !!----------------------------------------------------------------------
  12. !!----------------------------------------------------------------------
  13. !! dyn_zdf_imp : update the momentum trend with the vertical diffusion using a implicit time-stepping
  14. !!----------------------------------------------------------------------
  15. USE oce ! ocean dynamics and tracers
  16. USE dom_oce ! ocean space and time domain
  17. USE domvvl ! variable volume
  18. USE sbc_oce ! surface boundary condition: ocean
  19. USE zdf_oce ! ocean vertical physics
  20. USE phycst ! physical constants
  21. USE dynadv ! dynamics: vector invariant versus flux form
  22. USE dynspg_oce, ONLY: lk_dynspg_ts
  23. USE zdfbfr ! Bottom friction setup
  24. !
  25. USE in_out_manager ! I/O manager
  26. USE iom ! I/O library
  27. USE lib_mpp ! MPP library
  28. USE wrk_nemo ! Memory Allocation
  29. USE timing ! Timing
  30. IMPLICIT NONE
  31. PRIVATE
  32. PUBLIC dyn_zdf_imp ! called by step.F90
  33. REAL(wp) :: r_vvl ! variable volume indicator, =1 if lk_vvl=T, =0 otherwise
  34. !! * Substitutions
  35. # include "domzgr_substitute.h90"
  36. # include "vectopt_loop_substitute.h90"
  37. !!----------------------------------------------------------------------
  38. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  39. !! $Id: dynzdf_imp.F90 4990 2014-12-15 16:42:49Z timgraham $
  40. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  41. !!----------------------------------------------------------------------
  42. CONTAINS
  43. SUBROUTINE dyn_zdf_imp( kt, p2dt )
  44. !!----------------------------------------------------------------------
  45. !! *** ROUTINE dyn_zdf_imp ***
  46. !!
  47. !! ** Purpose : Compute the trend due to the vert. momentum diffusion
  48. !! and the surface forcing, and add it to the general trend of
  49. !! the momentum equations.
  50. !!
  51. !! ** Method : The vertical momentum mixing trend is given by :
  52. !! dz( avmu dz(u) ) = 1/e3u dk+1( avmu/e3uw dk(ua) )
  53. !! backward time stepping
  54. !! Surface boundary conditions: wind stress input (averaged over kt-1/2 & kt+1/2)
  55. !! Bottom boundary conditions : bottom stress (cf zdfbfr.F)
  56. !! Add this trend to the general trend ua :
  57. !! ua = ua + dz( avmu dz(u) )
  58. !!
  59. !! ** Action : - Update (ua,va) arrays with the after vertical diffusive mixing trend.
  60. !!---------------------------------------------------------------------
  61. INTEGER , INTENT(in) :: kt ! ocean time-step index
  62. REAL(wp), INTENT(in) :: p2dt ! vertical profile of tracer time-step
  63. !!
  64. INTEGER :: ji, jj, jk ! dummy loop indices
  65. INTEGER :: ikbu, ikbv ! local integers
  66. REAL(wp) :: z1_p2dt, zcoef, zzwi, zzws, zrhs ! local scalars
  67. REAL(wp) :: ze3ua, ze3va, zzz
  68. REAL(wp), POINTER, DIMENSION(:,:) :: z2d
  69. REAL(wp), POINTER, DIMENSION(:,:,:) :: zwi, zwd, zws
  70. REAL(wp), POINTER, DIMENSION(:,:,:) :: z3d
  71. !!----------------------------------------------------------------------
  72. !
  73. IF( nn_timing == 1 ) CALL timing_start('dyn_zdf_imp')
  74. !
  75. CALL wrk_alloc( jpi,jpj,jpk, zwi, zwd, zws )
  76. !
  77. IF( kt == nit000 ) THEN
  78. IF(lwp) WRITE(numout,*)
  79. IF(lwp) WRITE(numout,*) 'dyn_zdf_imp : vertical momentum diffusion implicit operator'
  80. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
  81. !
  82. IF( lk_vvl ) THEN ; r_vvl = 1._wp ! Variable volume indicator
  83. ELSE ; r_vvl = 0._wp
  84. ENDIF
  85. ENDIF
  86. ! 0. Local constant initialization
  87. ! --------------------------------
  88. z1_p2dt = 1._wp / p2dt ! inverse of the timestep
  89. ! 1. Apply semi-implicit bottom friction
  90. ! --------------------------------------
  91. ! Only needed for semi-implicit bottom friction setup. The explicit
  92. ! bottom friction has been included in "u(v)a" which act as the R.H.S
  93. ! column vector of the tri-diagonal matrix equation
  94. !
  95. IF( ln_bfrimp ) THEN
  96. DO jj = 2, jpjm1
  97. DO ji = 2, jpim1
  98. ikbu = mbku(ji,jj) ! ocean bottom level at u- and v-points
  99. ikbv = mbkv(ji,jj) ! (deepest ocean u- and v-points)
  100. avmu(ji,jj,ikbu+1) = -bfrua(ji,jj) * fse3uw(ji,jj,ikbu+1)
  101. avmv(ji,jj,ikbv+1) = -bfrva(ji,jj) * fse3vw(ji,jj,ikbv+1)
  102. END DO
  103. END DO
  104. IF ( ln_isfcav ) THEN
  105. DO jj = 2, jpjm1
  106. DO ji = 2, jpim1
  107. ikbu = miku(ji,jj) ! ocean top level at u- and v-points
  108. ikbv = mikv(ji,jj) ! (first wet ocean u- and v-points)
  109. IF (ikbu .GE. 2) avmu(ji,jj,ikbu) = -tfrua(ji,jj) * fse3uw(ji,jj,ikbu)
  110. IF (ikbv .GE. 2) avmv(ji,jj,ikbv) = -tfrva(ji,jj) * fse3vw(ji,jj,ikbv)
  111. END DO
  112. END DO
  113. END IF
  114. ENDIF
  115. #if defined key_dynspg_ts
  116. IF( ln_dynadv_vec .OR. .NOT. lk_vvl ) THEN ! applied on velocity
  117. DO jk = 1, jpkm1
  118. ua(:,:,jk) = ( ub(:,:,jk) + p2dt * ua(:,:,jk) ) * umask(:,:,jk)
  119. va(:,:,jk) = ( vb(:,:,jk) + p2dt * va(:,:,jk) ) * vmask(:,:,jk)
  120. END DO
  121. ELSE ! applied on thickness weighted velocity
  122. DO jk = 1, jpkm1
  123. ua(:,:,jk) = ( ub(:,:,jk) * fse3u_b(:,:,jk) &
  124. & + p2dt * ua(:,:,jk) * fse3u_n(:,:,jk) ) &
  125. & / fse3u_a(:,:,jk) * umask(:,:,jk)
  126. va(:,:,jk) = ( vb(:,:,jk) * fse3v_b(:,:,jk) &
  127. & + p2dt * va(:,:,jk) * fse3v_n(:,:,jk) ) &
  128. & / fse3v_a(:,:,jk) * vmask(:,:,jk)
  129. END DO
  130. ENDIF
  131. IF ( ln_bfrimp .AND.lk_dynspg_ts ) THEN
  132. ! remove barotropic velocities:
  133. DO jk = 1, jpkm1
  134. ua(:,:,jk) = (ua(:,:,jk) - ua_b(:,:)) * umask(:,:,jk)
  135. va(:,:,jk) = (va(:,:,jk) - va_b(:,:)) * vmask(:,:,jk)
  136. END DO
  137. ! Add bottom/top stress due to barotropic component only:
  138. DO jj = 2, jpjm1
  139. DO ji = fs_2, fs_jpim1 ! vector opt.
  140. ikbu = mbku(ji,jj) ! ocean bottom level at u- and v-points
  141. ikbv = mbkv(ji,jj) ! (deepest ocean u- and v-points)
  142. ze3ua = ( 1._wp - r_vvl ) * fse3u_n(ji,jj,ikbu) + r_vvl * fse3u_a(ji,jj,ikbu)
  143. ze3va = ( 1._wp - r_vvl ) * fse3v_n(ji,jj,ikbv) + r_vvl * fse3v_a(ji,jj,ikbv)
  144. ua(ji,jj,ikbu) = ua(ji,jj,ikbu) + p2dt * bfrua(ji,jj) * ua_b(ji,jj) / ze3ua
  145. va(ji,jj,ikbv) = va(ji,jj,ikbv) + p2dt * bfrva(ji,jj) * va_b(ji,jj) / ze3va
  146. END DO
  147. END DO
  148. IF ( ln_isfcav ) THEN
  149. DO jj = 2, jpjm1
  150. DO ji = fs_2, fs_jpim1 ! vector opt.
  151. ikbu = miku(ji,jj) ! top ocean level at u- and v-points
  152. ikbv = mikv(ji,jj) ! (first wet ocean u- and v-points)
  153. ze3ua = ( 1._wp - r_vvl ) * fse3u_n(ji,jj,ikbu) + r_vvl * fse3u_a(ji,jj,ikbu)
  154. ze3va = ( 1._wp - r_vvl ) * fse3v_n(ji,jj,ikbv) + r_vvl * fse3v_a(ji,jj,ikbv)
  155. ua(ji,jj,ikbu) = ua(ji,jj,ikbu) + p2dt * tfrua(ji,jj) * ua_b(ji,jj) / ze3ua
  156. va(ji,jj,ikbv) = va(ji,jj,ikbv) + p2dt * tfrva(ji,jj) * va_b(ji,jj) / ze3va
  157. END DO
  158. END DO
  159. END IF
  160. ENDIF
  161. #endif
  162. ! 2. Vertical diffusion on u
  163. ! ---------------------------
  164. ! Matrix and second member construction
  165. ! bottom boundary condition: both zwi and zws must be masked as avmu can take
  166. ! non zero value at the ocean bottom depending on the bottom friction used.
  167. !
  168. DO jk = 1, jpkm1 ! Matrix
  169. DO jj = 2, jpjm1
  170. DO ji = fs_2, fs_jpim1 ! vector opt.
  171. ze3ua = ( 1._wp - r_vvl ) * fse3u_n(ji,jj,jk) + r_vvl * fse3u_a(ji,jj,jk) ! after scale factor at T-point
  172. zcoef = - p2dt / ze3ua
  173. zzwi = zcoef * avmu (ji,jj,jk ) / fse3uw(ji,jj,jk )
  174. zwi(ji,jj,jk) = zzwi * wumask(ji,jj,jk )
  175. zzws = zcoef * avmu (ji,jj,jk+1) / fse3uw(ji,jj,jk+1)
  176. zws(ji,jj,jk) = zzws * wumask(ji,jj,jk+1)
  177. zwd(ji,jj,jk) = 1._wp - zzwi - zzws
  178. END DO
  179. END DO
  180. END DO
  181. DO jj = 2, jpjm1 ! Surface boundary conditions
  182. DO ji = fs_2, fs_jpim1 ! vector opt.
  183. zwi(ji,jj,1) = 0._wp
  184. zwd(ji,jj,1) = 1._wp - zws(ji,jj,1)
  185. END DO
  186. END DO
  187. ! Matrix inversion starting from the first level
  188. !-----------------------------------------------------------------------
  189. ! solve m.x = y where m is a tri diagonal matrix ( jpk*jpk )
  190. !
  191. ! ( zwd1 zws1 0 0 0 )( zwx1 ) ( zwy1 )
  192. ! ( zwi2 zwd2 zws2 0 0 )( zwx2 ) ( zwy2 )
  193. ! ( 0 zwi3 zwd3 zws3 0 )( zwx3 )=( zwy3 )
  194. ! ( ... )( ... ) ( ... )
  195. ! ( 0 0 0 zwik zwdk )( zwxk ) ( zwyk )
  196. !
  197. ! m is decomposed in the product of an upper and a lower triangular matrix
  198. ! The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
  199. ! The solution (the after velocity) is in ua
  200. !-----------------------------------------------------------------------
  201. !
  202. !== First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1 (increasing k) ==
  203. DO jk = 2, jpkm1
  204. DO jj = 2, jpjm1
  205. DO ji = fs_2, fs_jpim1 ! vector opt.
  206. zwd(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwd(ji,jj,jk-1)
  207. END DO
  208. END DO
  209. END DO
  210. !
  211. DO jj = 2, jpjm1 !== second recurrence: SOLk = RHSk - Lk / Dk-1 Lk-1 ==
  212. DO ji = fs_2, fs_jpim1 ! vector opt.
  213. #if defined key_dynspg_ts
  214. ze3ua = ( 1._wp - r_vvl ) * fse3u_n(ji,jj,1) + r_vvl * fse3u_a(ji,jj,1)
  215. ua(ji,jj,1) = ua(ji,jj,1) + p2dt * 0.5_wp * ( utau_b(ji,jj) + utau(ji,jj) ) &
  216. & / ( ze3ua * rau0 ) * umask(ji,jj,1)
  217. #else
  218. ua(ji,jj,1) = ub(ji,jj,1) &
  219. & + p2dt *(ua(ji,jj,1) + 0.5_wp * ( utau_b(ji,jj) + utau(ji,jj) ) &
  220. & / ( fse3u(ji,jj,1) * rau0 ) * umask(ji,jj,1) )
  221. #endif
  222. END DO
  223. END DO
  224. DO jk = 2, jpkm1
  225. DO jj = 2, jpjm1
  226. DO ji = fs_2, fs_jpim1
  227. #if defined key_dynspg_ts
  228. zrhs = ua(ji,jj,jk) ! zrhs=right hand side
  229. #else
  230. zrhs = ub(ji,jj,jk) + p2dt * ua(ji,jj,jk)
  231. #endif
  232. ua(ji,jj,jk) = zrhs - zwi(ji,jj,jk) / zwd(ji,jj,jk-1) * ua(ji,jj,jk-1)
  233. END DO
  234. END DO
  235. END DO
  236. !
  237. DO jj = 2, jpjm1 !== thrid recurrence : SOLk = ( Lk - Uk * Ek+1 ) / Dk ==
  238. DO ji = fs_2, fs_jpim1 ! vector opt.
  239. ua(ji,jj,jpkm1) = ua(ji,jj,jpkm1) / zwd(ji,jj,jpkm1)
  240. END DO
  241. END DO
  242. DO jk = jpk-2, 1, -1
  243. DO jj = 2, jpjm1
  244. DO ji = fs_2, fs_jpim1
  245. ua(ji,jj,jk) = ( ua(ji,jj,jk) - zws(ji,jj,jk) * ua(ji,jj,jk+1) ) / zwd(ji,jj,jk)
  246. END DO
  247. END DO
  248. END DO
  249. ! 3. Vertical diffusion on v
  250. ! ---------------------------
  251. ! Matrix and second member construction
  252. ! bottom boundary condition: both zwi and zws must be masked as avmv can take
  253. ! non zero value at the ocean bottom depending on the bottom friction used
  254. !
  255. DO jk = 1, jpkm1 ! Matrix
  256. DO jj = 2, jpjm1
  257. DO ji = fs_2, fs_jpim1 ! vector opt.
  258. ze3va = ( 1._wp - r_vvl ) * fse3v_n(ji,jj,jk) + r_vvl * fse3v_a(ji,jj,jk) ! after scale factor at T-point
  259. zcoef = - p2dt / ze3va
  260. zzwi = zcoef * avmv (ji,jj,jk ) / fse3vw(ji,jj,jk )
  261. zwi(ji,jj,jk) = zzwi * wvmask(ji,jj,jk)
  262. zzws = zcoef * avmv (ji,jj,jk+1) / fse3vw(ji,jj,jk+1)
  263. zws(ji,jj,jk) = zzws * wvmask(ji,jj,jk+1)
  264. zwd(ji,jj,jk) = 1._wp - zzwi - zzws
  265. END DO
  266. END DO
  267. END DO
  268. DO jj = 2, jpjm1 ! Surface boundary conditions
  269. DO ji = fs_2, fs_jpim1 ! vector opt.
  270. zwi(ji,jj,1) = 0._wp
  271. zwd(ji,jj,1) = 1._wp - zws(ji,jj,1)
  272. END DO
  273. END DO
  274. ! Matrix inversion
  275. !-----------------------------------------------------------------------
  276. ! solve m.x = y where m is a tri diagonal matrix ( jpk*jpk )
  277. !
  278. ! ( zwd1 zws1 0 0 0 )( zwx1 ) ( zwy1 )
  279. ! ( zwi2 zwd2 zws2 0 0 )( zwx2 ) ( zwy2 )
  280. ! ( 0 zwi3 zwd3 zws3 0 )( zwx3 )=( zwy3 )
  281. ! ( ... )( ... ) ( ... )
  282. ! ( 0 0 0 zwik zwdk )( zwxk ) ( zwyk )
  283. !
  284. ! m is decomposed in the product of an upper and lower triangular matrix
  285. ! The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
  286. ! The solution (after velocity) is in 2d array va
  287. !-----------------------------------------------------------------------
  288. !
  289. !== First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1 (increasing k) ==
  290. DO jk = 2, jpkm1
  291. DO jj = 2, jpjm1
  292. DO ji = fs_2, fs_jpim1 ! vector opt.
  293. zwd(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwd(ji,jj,jk-1)
  294. END DO
  295. END DO
  296. END DO
  297. !
  298. DO jj = 2, jpjm1 !== second recurrence: SOLk = RHSk - Lk / Dk-1 Lk-1 ==
  299. DO ji = fs_2, fs_jpim1 ! vector opt.
  300. #if defined key_dynspg_ts
  301. ze3va = ( 1._wp - r_vvl ) * fse3v_n(ji,jj,1) + r_vvl * fse3v_a(ji,jj,1)
  302. va(ji,jj,1) = va(ji,jj,1) + p2dt * 0.5_wp * ( vtau_b(ji,jj) + vtau(ji,jj) ) &
  303. & / ( ze3va * rau0 )
  304. #else
  305. va(ji,jj,1) = vb(ji,jj,1) &
  306. & + p2dt *(va(ji,jj,1) + 0.5_wp * ( vtau_b(ji,jj) + vtau(ji,jj) ) &
  307. & / ( fse3v(ji,jj,1) * rau0 ) )
  308. #endif
  309. END DO
  310. END DO
  311. DO jk = 2, jpkm1
  312. DO jj = 2, jpjm1
  313. DO ji = fs_2, fs_jpim1 ! vector opt.
  314. #if defined key_dynspg_ts
  315. zrhs = va(ji,jj,jk) ! zrhs=right hand side
  316. #else
  317. zrhs = vb(ji,jj,jk) + p2dt * va(ji,jj,jk)
  318. #endif
  319. va(ji,jj,jk) = zrhs - zwi(ji,jj,jk) / zwd(ji,jj,jk-1) * va(ji,jj,jk-1)
  320. END DO
  321. END DO
  322. END DO
  323. !
  324. DO jj = 2, jpjm1 !== third recurrence : SOLk = ( Lk - Uk * SOLk+1 ) / Dk ==
  325. DO ji = fs_2, fs_jpim1 ! vector opt.
  326. va(ji,jj,jpkm1) = va(ji,jj,jpkm1) / zwd(ji,jj,jpkm1)
  327. END DO
  328. END DO
  329. DO jk = jpk-2, 1, -1
  330. DO jj = 2, jpjm1
  331. DO ji = fs_2, fs_jpim1
  332. va(ji,jj,jk) = ( va(ji,jj,jk) - zws(ji,jj,jk) * va(ji,jj,jk+1) ) / zwd(ji,jj,jk)
  333. END DO
  334. END DO
  335. END DO
  336. IF( iom_use( 'dispkevfo' ) ) THEN ! ocean kinetic energy dissipation per unit area
  337. ! ! due to v friction (v=vertical)
  338. ! ! see NEMO_book appendix C, §C.8 (N.B. here averaged at t-points)
  339. ! ! Note that formally, in a Leap-Frog environment, the shear**2 should be the product of
  340. ! ! now by before shears, i.e. the source term of TKE (local positivity is not ensured).
  341. CALL wrk_alloc(jpi, jpj, z2d )
  342. CALL wrk_alloc(jpi, jpj, jpk, z3d )
  343. z2d(:,:) = 0._wp
  344. z3d(:,:,:) = ua(:,:,:) ; CALL lbc_lnk( z3d,'U', -1. )
  345. DO jk = 2, jpkm1
  346. DO jj = 2, jpjm1
  347. DO ji = fs_2, fs_jpim1 ! vector opt.
  348. z2d(ji,jj) = z2d(ji,jj) + ( &
  349. & avmu(ji ,jj,jk) * ( z3d(ji ,jj,jk-1) - z3d(ji ,jj,jk) )**2 / fse3uw(ji ,jj,jk) * wumask(ji ,jj,jk) &
  350. & + avmu(ji-1,jj,jk) * ( z3d(ji-1,jj,jk-1) - z3d(ji-1,jj,jk) )**2 / fse3uw(ji-1,jj,jk) * wumask(ji-1,jj,jk) &
  351. & )
  352. END DO
  353. END DO
  354. END DO
  355. z3d(:,:,:) = va(:,:,:) ; CALL lbc_lnk( z3d,'V', -1. )
  356. DO jk = 2, jpkm1
  357. DO jj = 2, jpjm1
  358. DO ji = fs_2, fs_jpim1 ! vector opt.
  359. z2d(ji,jj) = z2d(ji,jj) + ( &
  360. & avmv(ji,jj ,jk) * ( z3d(ji,jj ,jk-1) - z3d(ji,jj ,jk) )**2 / fse3vw(ji,jj ,jk) * wvmask(ji,jj ,jk) &
  361. & + avmv(ji,jj-1,jk) * ( z3d(ji,jj-1,jk-1) - z3d(ji,jj-1,jk) )**2 / fse3vw(ji,jj-1,jk) * wvmask(ji,jj-1,jk) &
  362. & )
  363. END DO
  364. END DO
  365. END DO
  366. zzz= - 0.5_wp* rau0 ! caution sign minus here
  367. z2d(:,:) = zzz * z2d(:,:)
  368. CALL lbc_lnk( z2d,'T', 1. )
  369. CALL iom_put( 'dispkevfo', z2d )
  370. !
  371. CALL wrk_dealloc(jpi, jpj, z2d )
  372. CALL wrk_dealloc(jpi, jpj, jpk, z3d )
  373. ENDIF
  374. #if ! defined key_dynspg_ts
  375. !!gm this can be removed if tranxt is changed like in the trunk so that implicit outcome with
  376. !!gm the after velocity, not a trend
  377. ! Normalization to obtain the general momentum trend ua
  378. DO jk = 1, jpkm1
  379. DO jj = 2, jpjm1
  380. DO ji = fs_2, fs_jpim1 ! vector opt.
  381. ua(ji,jj,jk) = ( ua(ji,jj,jk) - ub(ji,jj,jk) ) * z1_p2dt
  382. va(ji,jj,jk) = ( va(ji,jj,jk) - vb(ji,jj,jk) ) * z1_p2dt
  383. END DO
  384. END DO
  385. END DO
  386. #endif
  387. ! J. Chanut: Lines below are useless ?
  388. !! restore bottom layer avmu(v)
  389. IF( ln_bfrimp ) THEN
  390. DO jj = 2, jpjm1
  391. DO ji = 2, jpim1
  392. ikbu = mbku(ji,jj) ! ocean bottom level at u- and v-points
  393. ikbv = mbkv(ji,jj) ! (deepest ocean u- and v-points)
  394. avmu(ji,jj,ikbu+1) = 0.e0
  395. avmv(ji,jj,ikbv+1) = 0.e0
  396. END DO
  397. END DO
  398. IF (ln_isfcav) THEN
  399. DO jj = 2, jpjm1
  400. DO ji = 2, jpim1
  401. ikbu = miku(ji,jj) ! ocean top level at u- and v-points
  402. ikbv = mikv(ji,jj) ! (first wet ocean u- and v-points)
  403. IF (ikbu > 1) avmu(ji,jj,ikbu) = 0.e0
  404. IF (ikbv > 1) avmv(ji,jj,ikbv) = 0.e0
  405. END DO
  406. END DO
  407. END IF
  408. ENDIF
  409. !
  410. CALL wrk_dealloc( jpi,jpj,jpk, zwi, zwd, zws)
  411. !
  412. !
  413. IF( nn_timing == 1 ) CALL timing_stop('dyn_zdf_imp')
  414. !
  415. END SUBROUTINE dyn_zdf_imp
  416. !!==============================================================================
  417. END MODULE dynzdf_imp