dynvor.F90 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. MODULE dynvor
  2. !!======================================================================
  3. !! *** MODULE dynvor ***
  4. !! Ocean dynamics: Update the momentum trend with the relative and
  5. !! planetary vorticity trends
  6. !!======================================================================
  7. !! History : OPA ! 1989-12 (P. Andrich) vor_ens: Original code
  8. !! 5.0 ! 1991-11 (G. Madec) vor_ene, vor_mix: Original code
  9. !! 6.0 ! 1996-01 (G. Madec) s-coord, suppress work arrays
  10. !! NEMO 0.5 ! 2002-08 (G. Madec) F90: Free form and module
  11. !! 1.0 ! 2004-02 (G. Madec) vor_een: Original code
  12. !! - ! 2003-08 (G. Madec) add vor_ctl
  13. !! - ! 2005-11 (G. Madec) add dyn_vor (new step architecture)
  14. !! 2.0 ! 2006-11 (G. Madec) flux form advection: add metric term
  15. !! 3.2 ! 2009-04 (R. Benshila) vvl: correction of een scheme
  16. !! 3.3 ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase
  17. !! 3.7 ! 2014-04 (G. Madec) trend simplification: suppress jpdyn_trd_dat vorticity
  18. !!----------------------------------------------------------------------
  19. !!----------------------------------------------------------------------
  20. !! dyn_vor : Update the momentum trend with the vorticity trend
  21. !! vor_ens : enstrophy conserving scheme (ln_dynvor_ens=T)
  22. !! vor_ene : energy conserving scheme (ln_dynvor_ene=T)
  23. !! vor_mix : mixed enstrophy/energy conserving (ln_dynvor_mix=T)
  24. !! vor_een : energy and enstrophy conserving (ln_dynvor_een=T)
  25. !! dyn_vor_init : set and control of the different vorticity option
  26. !!----------------------------------------------------------------------
  27. USE oce ! ocean dynamics and tracers
  28. USE dom_oce ! ocean space and time domain
  29. USE dommsk ! ocean mask
  30. USE dynadv ! momentum advection (use ln_dynadv_vec value)
  31. USE trd_oce ! trends: ocean variables
  32. USE trddyn ! trend manager: dynamics
  33. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  34. USE prtctl ! Print control
  35. USE in_out_manager ! I/O manager
  36. USE lib_mpp ! MPP library
  37. USE wrk_nemo ! Memory Allocation
  38. USE timing ! Timing
  39. IMPLICIT NONE
  40. PRIVATE
  41. PUBLIC dyn_vor ! routine called by step.F90
  42. PUBLIC dyn_vor_init ! routine called by opa.F90
  43. ! !!* Namelist namdyn_vor: vorticity term
  44. LOGICAL, PUBLIC :: ln_dynvor_ene !: energy conserving scheme
  45. LOGICAL, PUBLIC :: ln_dynvor_ens !: enstrophy conserving scheme
  46. LOGICAL, PUBLIC :: ln_dynvor_mix !: mixed scheme
  47. LOGICAL, PUBLIC :: ln_dynvor_een !: energy and enstrophy conserving scheme
  48. LOGICAL, PUBLIC :: ln_dynvor_een_old !: energy and enstrophy conserving scheme (original formulation)
  49. INTEGER :: nvor = 0 ! type of vorticity trend used
  50. INTEGER :: ncor = 1 ! coriolis
  51. INTEGER :: nrvm = 2 ! =2 relative vorticity ; =3 metric term
  52. INTEGER :: ntot = 4 ! =4 total vorticity (relative + planetary) ; =5 coriolis + metric term
  53. !! * Substitutions
  54. # include "domzgr_substitute.h90"
  55. # include "vectopt_loop_substitute.h90"
  56. !!----------------------------------------------------------------------
  57. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  58. !! $Id: dynvor.F90 4990 2014-12-15 16:42:49Z timgraham $
  59. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  60. !!----------------------------------------------------------------------
  61. CONTAINS
  62. SUBROUTINE dyn_vor( kt )
  63. !!----------------------------------------------------------------------
  64. !!
  65. !! ** Purpose : compute the lateral ocean tracer physics.
  66. !!
  67. !! ** Action : - Update (ua,va) with the now vorticity term trend
  68. !! - save the trends in (ztrdu,ztrdv) in 2 parts (relative
  69. !! and planetary vorticity trends) and send them to trd_dyn
  70. !! for futher diagnostics (l_trddyn=T)
  71. !!----------------------------------------------------------------------
  72. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  73. !
  74. REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdu, ztrdv
  75. !!----------------------------------------------------------------------
  76. !
  77. IF( nn_timing == 1 ) CALL timing_start('dyn_vor')
  78. !
  79. IF( l_trddyn ) CALL wrk_alloc( jpi,jpj,jpk, ztrdu, ztrdv )
  80. !
  81. ! ! vorticity term
  82. SELECT CASE ( nvor ) ! compute the vorticity trend and add it to the general trend
  83. !
  84. CASE ( -1 ) ! esopa: test all possibility with control print
  85. CALL vor_ene( kt, ntot, ua, va )
  86. CALL prt_ctl( tab3d_1=ua, clinfo1=' vor0 - Ua: ', mask1=umask, &
  87. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  88. CALL vor_ens( kt, ntot, ua, va )
  89. CALL prt_ctl( tab3d_1=ua, clinfo1=' vor1 - Ua: ', mask1=umask, &
  90. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  91. CALL vor_mix( kt )
  92. CALL prt_ctl( tab3d_1=ua, clinfo1=' vor2 - Ua: ', mask1=umask, &
  93. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  94. CALL vor_een( kt, ntot, ua, va )
  95. CALL prt_ctl( tab3d_1=ua, clinfo1=' vor3 - Ua: ', mask1=umask, &
  96. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  97. !
  98. CASE ( 0 ) ! energy conserving scheme
  99. IF( l_trddyn ) THEN
  100. ztrdu(:,:,:) = ua(:,:,:)
  101. ztrdv(:,:,:) = va(:,:,:)
  102. CALL vor_ene( kt, nrvm, ua, va ) ! relative vorticity or metric trend
  103. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  104. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  105. CALL trd_dyn( ztrdu, ztrdv, jpdyn_rvo, kt )
  106. ztrdu(:,:,:) = ua(:,:,:)
  107. ztrdv(:,:,:) = va(:,:,:)
  108. CALL vor_ene( kt, ncor, ua, va ) ! planetary vorticity trend
  109. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  110. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  111. CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
  112. ELSE
  113. CALL vor_ene( kt, ntot, ua, va ) ! total vorticity
  114. ENDIF
  115. !
  116. CASE ( 1 ) ! enstrophy conserving scheme
  117. IF( l_trddyn ) THEN
  118. ztrdu(:,:,:) = ua(:,:,:)
  119. ztrdv(:,:,:) = va(:,:,:)
  120. CALL vor_ens( kt, nrvm, ua, va ) ! relative vorticity or metric trend
  121. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  122. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  123. CALL trd_dyn( ztrdu, ztrdv, jpdyn_rvo, kt )
  124. ztrdu(:,:,:) = ua(:,:,:)
  125. ztrdv(:,:,:) = va(:,:,:)
  126. CALL vor_ens( kt, ncor, ua, va ) ! planetary vorticity trend
  127. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  128. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  129. CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
  130. ELSE
  131. CALL vor_ens( kt, ntot, ua, va ) ! total vorticity
  132. ENDIF
  133. !
  134. CASE ( 2 ) ! mixed ene-ens scheme
  135. IF( l_trddyn ) THEN
  136. ztrdu(:,:,:) = ua(:,:,:)
  137. ztrdv(:,:,:) = va(:,:,:)
  138. CALL vor_ens( kt, nrvm, ua, va ) ! relative vorticity or metric trend (ens)
  139. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  140. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  141. CALL trd_dyn( ztrdu, ztrdv, jpdyn_rvo, kt )
  142. ztrdu(:,:,:) = ua(:,:,:)
  143. ztrdv(:,:,:) = va(:,:,:)
  144. CALL vor_ene( kt, ncor, ua, va ) ! planetary vorticity trend (ene)
  145. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  146. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  147. CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
  148. ELSE
  149. CALL vor_mix( kt ) ! total vorticity (mix=ens-ene)
  150. ENDIF
  151. !
  152. CASE ( 3 ) ! energy and enstrophy conserving scheme
  153. IF( l_trddyn ) THEN
  154. ztrdu(:,:,:) = ua(:,:,:)
  155. ztrdv(:,:,:) = va(:,:,:)
  156. CALL vor_een( kt, nrvm, ua, va ) ! relative vorticity or metric trend
  157. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  158. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  159. CALL trd_dyn( ztrdu, ztrdv, jpdyn_rvo, kt )
  160. ztrdu(:,:,:) = ua(:,:,:)
  161. ztrdv(:,:,:) = va(:,:,:)
  162. CALL vor_een( kt, ncor, ua, va ) ! planetary vorticity trend
  163. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  164. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  165. CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
  166. ELSE
  167. ! CALL vor_een( kt, ntot, ua, va ) ! total vorticity
  168. CALL vor_een( kt, nrvm, ua, va ) ! Do not use the above compact form
  169. CALL vor_een( kt, ncor, ua, va ) ! in order to preserve reproducibility
  170. ENDIF
  171. !
  172. END SELECT
  173. !
  174. ! ! print sum trends (used for debugging)
  175. IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' vor - Ua: ', mask1=umask, &
  176. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  177. !
  178. IF( l_trddyn ) CALL wrk_dealloc( jpi,jpj,jpk, ztrdu, ztrdv )
  179. !
  180. IF( nn_timing == 1 ) CALL timing_stop('dyn_vor')
  181. !
  182. END SUBROUTINE dyn_vor
  183. SUBROUTINE vor_ene( kt, kvor, pua, pva )
  184. !!----------------------------------------------------------------------
  185. !! *** ROUTINE vor_ene ***
  186. !!
  187. !! ** Purpose : Compute the now total vorticity trend and add it to
  188. !! the general trend of the momentum equation.
  189. !!
  190. !! ** Method : Trend evaluated using now fields (centered in time)
  191. !! and the Sadourny (1975) flux form formulation : conserves the
  192. !! horizontal kinetic energy.
  193. !! The trend of the vorticity term is given by:
  194. !! * s-coordinate (ln_sco=T), the e3. are inside the derivatives:
  195. !! voru = 1/e1u mj-1[ (rotn+f)/e3f mi(e1v*e3v vn) ]
  196. !! vorv = 1/e2v mi-1[ (rotn+f)/e3f mj(e2u*e3u un) ]
  197. !! * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
  198. !! voru = 1/e1u mj-1[ (rotn+f) mi(e1v vn) ]
  199. !! vorv = 1/e2v mi-1[ (rotn+f) mj(e2u un) ]
  200. !! Add this trend to the general momentum trend (ua,va):
  201. !! (ua,va) = (ua,va) + ( voru , vorv )
  202. !!
  203. !! ** Action : - Update (ua,va) with the now vorticity term trend
  204. !!
  205. !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
  206. !!----------------------------------------------------------------------
  207. !
  208. INTEGER , INTENT(in ) :: kt ! ocean time-step index
  209. INTEGER , INTENT(in ) :: kvor ! =ncor (planetary) ; =ntot (total) ;
  210. ! ! =nrvm (relative vorticity or metric)
  211. REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: pua ! total u-trend
  212. REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: pva ! total v-trend
  213. !
  214. INTEGER :: ji, jj, jk ! dummy loop indices
  215. REAL(wp) :: zx1, zy1, zfact2, zx2, zy2 ! local scalars
  216. REAL(wp), POINTER, DIMENSION(:,:) :: zwx, zwy, zwz
  217. !!----------------------------------------------------------------------
  218. !
  219. IF( nn_timing == 1 ) CALL timing_start('vor_ene')
  220. !
  221. CALL wrk_alloc( jpi, jpj, zwx, zwy, zwz )
  222. !
  223. IF( kt == nit000 ) THEN
  224. IF(lwp) WRITE(numout,*)
  225. IF(lwp) WRITE(numout,*) 'dyn:vor_ene : vorticity term: energy conserving scheme'
  226. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
  227. ENDIF
  228. zfact2 = 0.5 * 0.5 ! Local constant initialization
  229. !CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz )
  230. ! ! ===============
  231. DO jk = 1, jpkm1 ! Horizontal slab
  232. ! ! ===============
  233. !
  234. ! Potential vorticity and horizontal fluxes
  235. ! -----------------------------------------
  236. SELECT CASE( kvor ) ! vorticity considered
  237. CASE ( 1 ) ; zwz(:,:) = ff(:,:) ! planetary vorticity (Coriolis)
  238. CASE ( 2 ) ; zwz(:,:) = rotn(:,:,jk) ! relative vorticity
  239. CASE ( 3 ) ! metric term
  240. DO jj = 1, jpjm1
  241. DO ji = 1, fs_jpim1 ! vector opt.
  242. zwz(ji,jj) = ( ( vn(ji+1,jj ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj ) - e2v(ji,jj) ) &
  243. & - ( un(ji ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji ,jj+1) - e1u(ji,jj) ) ) &
  244. & * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )
  245. END DO
  246. END DO
  247. CASE ( 4 ) ; zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) ) ! total (relative + planetary vorticity)
  248. CASE ( 5 ) ! total (coriolis + metric)
  249. DO jj = 1, jpjm1
  250. DO ji = 1, fs_jpim1 ! vector opt.
  251. zwz(ji,jj) = ( ff (ji,jj) &
  252. & + ( ( vn(ji+1,jj ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj ) - e2v(ji,jj) ) &
  253. & - ( un(ji ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji ,jj+1) - e1u(ji,jj) ) ) &
  254. & * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) ) &
  255. & )
  256. END DO
  257. END DO
  258. END SELECT
  259. IF( ln_sco ) THEN
  260. zwz(:,:) = zwz(:,:) / fse3f(:,:,jk)
  261. zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
  262. zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
  263. ELSE
  264. zwx(:,:) = e2u(:,:) * un(:,:,jk)
  265. zwy(:,:) = e1v(:,:) * vn(:,:,jk)
  266. ENDIF
  267. ! Compute and add the vorticity term trend
  268. ! ----------------------------------------
  269. DO jj = 2, jpjm1
  270. DO ji = fs_2, fs_jpim1 ! vector opt.
  271. zy1 = zwy(ji,jj-1) + zwy(ji+1,jj-1)
  272. zy2 = zwy(ji,jj ) + zwy(ji+1,jj )
  273. zx1 = zwx(ji-1,jj) + zwx(ji-1,jj+1)
  274. zx2 = zwx(ji ,jj) + zwx(ji ,jj+1)
  275. pua(ji,jj,jk) = pua(ji,jj,jk) + zfact2 / e1u(ji,jj) * ( zwz(ji ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
  276. pva(ji,jj,jk) = pva(ji,jj,jk) - zfact2 / e2v(ji,jj) * ( zwz(ji-1,jj ) * zx1 + zwz(ji,jj) * zx2 )
  277. END DO
  278. END DO
  279. ! ! ===============
  280. END DO ! End of slab
  281. ! ! ===============
  282. CALL wrk_dealloc( jpi, jpj, zwx, zwy, zwz )
  283. !
  284. IF( nn_timing == 1 ) CALL timing_stop('vor_ene')
  285. !
  286. END SUBROUTINE vor_ene
  287. SUBROUTINE vor_mix( kt )
  288. !!----------------------------------------------------------------------
  289. !! *** ROUTINE vor_mix ***
  290. !!
  291. !! ** Purpose : Compute the now total vorticity trend and add it to
  292. !! the general trend of the momentum equation.
  293. !!
  294. !! ** Method : Trend evaluated using now fields (centered in time)
  295. !! Mixte formulation : conserves the potential enstrophy of a hori-
  296. !! zontally non-divergent flow for (rotzu x uh), the relative vor-
  297. !! ticity term and the horizontal kinetic energy for (f x uh), the
  298. !! coriolis term. the now trend of the vorticity term is given by:
  299. !! * s-coordinate (ln_sco=T), the e3. are inside the derivatives:
  300. !! voru = 1/e1u mj-1(rotn/e3f) mj-1[ mi(e1v*e3v vn) ]
  301. !! +1/e1u mj-1[ f/e3f mi(e1v*e3v vn) ]
  302. !! vorv = 1/e2v mi-1(rotn/e3f) mi-1[ mj(e2u*e3u un) ]
  303. !! +1/e2v mi-1[ f/e3f mj(e2u*e3u un) ]
  304. !! * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
  305. !! voru = 1/e1u mj-1(rotn) mj-1[ mi(e1v vn) ]
  306. !! +1/e1u mj-1[ f mi(e1v vn) ]
  307. !! vorv = 1/e2v mi-1(rotn) mi-1[ mj(e2u un) ]
  308. !! +1/e2v mi-1[ f mj(e2u un) ]
  309. !! Add this now trend to the general momentum trend (ua,va):
  310. !! (ua,va) = (ua,va) + ( voru , vorv )
  311. !!
  312. !! ** Action : - Update (ua,va) arrays with the now vorticity term trend
  313. !!
  314. !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
  315. !!----------------------------------------------------------------------
  316. !
  317. INTEGER, INTENT(in) :: kt ! ocean timestep index
  318. !
  319. INTEGER :: ji, jj, jk ! dummy loop indices
  320. REAL(wp) :: zfact1, zua, zcua, zx1, zy1 ! local scalars
  321. REAL(wp) :: zfact2, zva, zcva, zx2, zy2 ! - -
  322. REAL(wp), POINTER, DIMENSION(:,:) :: zwx, zwy, zwz, zww
  323. !!----------------------------------------------------------------------
  324. !
  325. IF( nn_timing == 1 ) CALL timing_start('vor_mix')
  326. !
  327. CALL wrk_alloc( jpi, jpj, zwx, zwy, zwz, zww )
  328. !
  329. IF( kt == nit000 ) THEN
  330. IF(lwp) WRITE(numout,*)
  331. IF(lwp) WRITE(numout,*) 'dyn:vor_mix : vorticity term: mixed energy/enstrophy conserving scheme'
  332. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
  333. ENDIF
  334. zfact1 = 0.5 * 0.25 ! Local constant initialization
  335. zfact2 = 0.5 * 0.5
  336. !CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz, zww )
  337. ! ! ===============
  338. DO jk = 1, jpkm1 ! Horizontal slab
  339. ! ! ===============
  340. !
  341. ! Relative and planetary potential vorticity and horizontal fluxes
  342. ! ----------------------------------------------------------------
  343. IF( ln_sco ) THEN
  344. IF( ln_dynadv_vec ) THEN
  345. zww(:,:) = rotn(:,:,jk) / fse3f(:,:,jk)
  346. ELSE
  347. DO jj = 1, jpjm1
  348. DO ji = 1, fs_jpim1 ! vector opt.
  349. zww(ji,jj) = ( ( vn(ji+1,jj ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj ) - e2v(ji,jj) ) &
  350. & - ( un(ji ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji ,jj+1) - e1u(ji,jj) ) ) &
  351. & * 0.5 / ( e1f(ji,jj) * e2f (ji,jj) * fse3f(ji,jj,jk) )
  352. END DO
  353. END DO
  354. ENDIF
  355. zwz(:,:) = ff (:,:) / fse3f(:,:,jk)
  356. zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
  357. zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
  358. ELSE
  359. IF( ln_dynadv_vec ) THEN
  360. zww(:,:) = rotn(:,:,jk)
  361. ELSE
  362. DO jj = 1, jpjm1
  363. DO ji = 1, fs_jpim1 ! vector opt.
  364. zww(ji,jj) = ( ( vn(ji+1,jj ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj ) - e2v(ji,jj) ) &
  365. & - ( un(ji ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji ,jj+1) - e1u(ji,jj) ) ) &
  366. & * 0.5 / ( e1f(ji,jj) * e2f (ji,jj) )
  367. END DO
  368. END DO
  369. ENDIF
  370. zwz(:,:) = ff (:,:)
  371. zwx(:,:) = e2u(:,:) * un(:,:,jk)
  372. zwy(:,:) = e1v(:,:) * vn(:,:,jk)
  373. ENDIF
  374. ! Compute and add the vorticity term trend
  375. ! ----------------------------------------
  376. DO jj = 2, jpjm1
  377. DO ji = fs_2, fs_jpim1 ! vector opt.
  378. zy1 = ( zwy(ji,jj-1) + zwy(ji+1,jj-1) ) / e1u(ji,jj)
  379. zy2 = ( zwy(ji,jj ) + zwy(ji+1,jj ) ) / e1u(ji,jj)
  380. zx1 = ( zwx(ji-1,jj) + zwx(ji-1,jj+1) ) / e2v(ji,jj)
  381. zx2 = ( zwx(ji ,jj) + zwx(ji ,jj+1) ) / e2v(ji,jj)
  382. ! enstrophy conserving formulation for relative vorticity term
  383. zua = zfact1 * ( zww(ji ,jj-1) + zww(ji,jj) ) * ( zy1 + zy2 )
  384. zva =-zfact1 * ( zww(ji-1,jj ) + zww(ji,jj) ) * ( zx1 + zx2 )
  385. ! energy conserving formulation for planetary vorticity term
  386. zcua = zfact2 * ( zwz(ji ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
  387. zcva =-zfact2 * ( zwz(ji-1,jj ) * zx1 + zwz(ji,jj) * zx2 )
  388. ! mixed vorticity trend added to the momentum trends
  389. ua(ji,jj,jk) = ua(ji,jj,jk) + zcua + zua
  390. va(ji,jj,jk) = va(ji,jj,jk) + zcva + zva
  391. END DO
  392. END DO
  393. ! ! ===============
  394. END DO ! End of slab
  395. ! ! ===============
  396. CALL wrk_dealloc( jpi, jpj, zwx, zwy, zwz, zww )
  397. !
  398. IF( nn_timing == 1 ) CALL timing_stop('vor_mix')
  399. !
  400. END SUBROUTINE vor_mix
  401. SUBROUTINE vor_ens( kt, kvor, pua, pva )
  402. !!----------------------------------------------------------------------
  403. !! *** ROUTINE vor_ens ***
  404. !!
  405. !! ** Purpose : Compute the now total vorticity trend and add it to
  406. !! the general trend of the momentum equation.
  407. !!
  408. !! ** Method : Trend evaluated using now fields (centered in time)
  409. !! and the Sadourny (1975) flux FORM formulation : conserves the
  410. !! potential enstrophy of a horizontally non-divergent flow. the
  411. !! trend of the vorticity term is given by:
  412. !! * s-coordinate (ln_sco=T), the e3. are inside the derivative:
  413. !! voru = 1/e1u mj-1[ (rotn+f)/e3f ] mj-1[ mi(e1v*e3v vn) ]
  414. !! vorv = 1/e2v mi-1[ (rotn+f)/e3f ] mi-1[ mj(e2u*e3u un) ]
  415. !! * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
  416. !! voru = 1/e1u mj-1[ rotn+f ] mj-1[ mi(e1v vn) ]
  417. !! vorv = 1/e2v mi-1[ rotn+f ] mi-1[ mj(e2u un) ]
  418. !! Add this trend to the general momentum trend (ua,va):
  419. !! (ua,va) = (ua,va) + ( voru , vorv )
  420. !!
  421. !! ** Action : - Update (ua,va) arrays with the now vorticity term trend
  422. !!
  423. !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
  424. !!----------------------------------------------------------------------
  425. !
  426. INTEGER , INTENT(in ) :: kt ! ocean time-step index
  427. INTEGER , INTENT(in ) :: kvor ! =ncor (planetary) ; =ntot (total) ;
  428. ! ! =nrvm (relative vorticity or metric)
  429. REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: pua ! total u-trend
  430. REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: pva ! total v-trend
  431. !
  432. INTEGER :: ji, jj, jk ! dummy loop indices
  433. REAL(wp) :: zfact1, zuav, zvau ! temporary scalars
  434. REAL(wp), POINTER, DIMENSION(:,:) :: zwx, zwy, zwz, zww
  435. !!----------------------------------------------------------------------
  436. !
  437. IF( nn_timing == 1 ) CALL timing_start('vor_ens')
  438. !
  439. CALL wrk_alloc( jpi, jpj, zwx, zwy, zwz )
  440. !
  441. IF( kt == nit000 ) THEN
  442. IF(lwp) WRITE(numout,*)
  443. IF(lwp) WRITE(numout,*) 'dyn:vor_ens : vorticity term: enstrophy conserving scheme'
  444. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
  445. ENDIF
  446. zfact1 = 0.5 * 0.25 ! Local constant initialization
  447. !CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz )
  448. ! ! ===============
  449. DO jk = 1, jpkm1 ! Horizontal slab
  450. ! ! ===============
  451. !
  452. ! Potential vorticity and horizontal fluxes
  453. ! -----------------------------------------
  454. SELECT CASE( kvor ) ! vorticity considered
  455. CASE ( 1 ) ; zwz(:,:) = ff(:,:) ! planetary vorticity (Coriolis)
  456. CASE ( 2 ) ; zwz(:,:) = rotn(:,:,jk) ! relative vorticity
  457. CASE ( 3 ) ! metric term
  458. DO jj = 1, jpjm1
  459. DO ji = 1, fs_jpim1 ! vector opt.
  460. zwz(ji,jj) = ( ( vn(ji+1,jj ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj ) - e2v(ji,jj) ) &
  461. & - ( un(ji ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji ,jj+1) - e1u(ji,jj) ) ) &
  462. & * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )
  463. END DO
  464. END DO
  465. CASE ( 4 ) ; zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) ) ! total (relative + planetary vorticity)
  466. CASE ( 5 ) ! total (coriolis + metric)
  467. DO jj = 1, jpjm1
  468. DO ji = 1, fs_jpim1 ! vector opt.
  469. zwz(ji,jj) = ( ff (ji,jj) &
  470. & + ( ( vn(ji+1,jj ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj ) - e2v(ji,jj) ) &
  471. & - ( un(ji ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji ,jj+1) - e1u(ji,jj) ) ) &
  472. & * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) ) &
  473. & )
  474. END DO
  475. END DO
  476. END SELECT
  477. !
  478. IF( ln_sco ) THEN
  479. DO jj = 1, jpj ! caution: don't use (:,:) for this loop
  480. DO ji = 1, jpi ! it causes optimization problems on NEC in auto-tasking
  481. zwz(ji,jj) = zwz(ji,jj) / fse3f(ji,jj,jk)
  482. zwx(ji,jj) = e2u(ji,jj) * fse3u(ji,jj,jk) * un(ji,jj,jk)
  483. zwy(ji,jj) = e1v(ji,jj) * fse3v(ji,jj,jk) * vn(ji,jj,jk)
  484. END DO
  485. END DO
  486. ELSE
  487. DO jj = 1, jpj ! caution: don't use (:,:) for this loop
  488. DO ji = 1, jpi ! it causes optimization problems on NEC in auto-tasking
  489. zwx(ji,jj) = e2u(ji,jj) * un(ji,jj,jk)
  490. zwy(ji,jj) = e1v(ji,jj) * vn(ji,jj,jk)
  491. END DO
  492. END DO
  493. ENDIF
  494. !
  495. ! Compute and add the vorticity term trend
  496. ! ----------------------------------------
  497. DO jj = 2, jpjm1
  498. DO ji = fs_2, fs_jpim1 ! vector opt.
  499. zuav = zfact1 / e1u(ji,jj) * ( zwy(ji ,jj-1) + zwy(ji+1,jj-1) &
  500. & + zwy(ji ,jj ) + zwy(ji+1,jj ) )
  501. zvau =-zfact1 / e2v(ji,jj) * ( zwx(ji-1,jj ) + zwx(ji-1,jj+1) &
  502. & + zwx(ji ,jj ) + zwx(ji ,jj+1) )
  503. pua(ji,jj,jk) = pua(ji,jj,jk) + zuav * ( zwz(ji ,jj-1) + zwz(ji,jj) )
  504. pva(ji,jj,jk) = pva(ji,jj,jk) + zvau * ( zwz(ji-1,jj ) + zwz(ji,jj) )
  505. END DO
  506. END DO
  507. ! ! ===============
  508. END DO ! End of slab
  509. ! ! ===============
  510. CALL wrk_dealloc( jpi, jpj, zwx, zwy, zwz )
  511. !
  512. IF( nn_timing == 1 ) CALL timing_stop('vor_ens')
  513. !
  514. END SUBROUTINE vor_ens
  515. SUBROUTINE vor_een( kt, kvor, pua, pva )
  516. !!----------------------------------------------------------------------
  517. !! *** ROUTINE vor_een ***
  518. !!
  519. !! ** Purpose : Compute the now total vorticity trend and add it to
  520. !! the general trend of the momentum equation.
  521. !!
  522. !! ** Method : Trend evaluated using now fields (centered in time)
  523. !! and the Arakawa and Lamb (1980) flux form formulation : conserves
  524. !! both the horizontal kinetic energy and the potential enstrophy
  525. !! when horizontal divergence is zero (see the NEMO documentation)
  526. !! Add this trend to the general momentum trend (ua,va).
  527. !!
  528. !! ** Action : - Update (ua,va) with the now vorticity term trend
  529. !!
  530. !! References : Arakawa and Lamb 1980, Mon. Wea. Rev., 109, 18-36
  531. !!----------------------------------------------------------------------
  532. !
  533. INTEGER , INTENT(in ) :: kt ! ocean time-step index
  534. INTEGER , INTENT(in ) :: kvor ! =ncor (planetary) ; =ntot (total) ;
  535. ! ! =nrvm (relative vorticity or metric)
  536. REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: pua ! total u-trend
  537. REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: pva ! total v-trend
  538. !!
  539. INTEGER :: ji, jj, jk ! dummy loop indices
  540. INTEGER :: ierr ! local integer
  541. REAL(wp) :: zfac12, zua, zva ! local scalars
  542. REAL(wp) :: zmsk, ze3 ! local scalars
  543. ! ! 3D workspace
  544. REAL(wp), POINTER , DIMENSION(:,: ) :: zwx, zwy, zwz
  545. REAL(wp), POINTER , DIMENSION(:,: ) :: ztnw, ztne, ztsw, ztse
  546. #if defined key_vvl
  547. REAL(wp), POINTER , DIMENSION(:,:,:) :: ze3f ! 3D workspace (lk_vvl=T)
  548. #else
  549. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), SAVE :: ze3f ! lk_vvl=F, ze3f=1/e3f saved one for all
  550. #endif
  551. !!----------------------------------------------------------------------
  552. !
  553. IF( nn_timing == 1 ) CALL timing_start('vor_een')
  554. !
  555. CALL wrk_alloc( jpi, jpj, zwx , zwy , zwz )
  556. CALL wrk_alloc( jpi, jpj, ztnw, ztne, ztsw, ztse )
  557. #if defined key_vvl
  558. CALL wrk_alloc( jpi, jpj, jpk, ze3f )
  559. #endif
  560. !
  561. IF( kt == nit000 ) THEN
  562. IF(lwp) WRITE(numout,*)
  563. IF(lwp) WRITE(numout,*) 'dyn:vor_een : vorticity term: energy and enstrophy conserving scheme'
  564. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
  565. #if ! defined key_vvl
  566. IF( .NOT.ALLOCATED(ze3f) ) THEN
  567. ALLOCATE( ze3f(jpi,jpj,jpk) , STAT=ierr )
  568. IF( lk_mpp ) CALL mpp_sum ( ierr )
  569. IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'dyn:vor_een : unable to allocate arrays' )
  570. ENDIF
  571. ze3f(:,:,:) = 0._wp
  572. #endif
  573. ENDIF
  574. IF( kt == nit000 .OR. lk_vvl ) THEN ! reciprocal of e3 at F-point (masked averaging of e3t over ocean points)
  575. IF( ln_dynvor_een_old ) THEN ! original formulation
  576. DO jk = 1, jpk
  577. DO jj = 1, jpjm1
  578. DO ji = 1, fs_jpim1
  579. ze3 = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk) &
  580. & + fse3t(ji,jj ,jk)*tmask(ji,jj ,jk) + fse3t(ji+1,jj ,jk)*tmask(ji+1,jj ,jk) )
  581. IF ( ze3 /= 0._wp ) THEN ; ze3f(ji,jj,jk) = 4.0_wp / ze3
  582. ELSE ; ze3f(ji,jj,jk) = 0.0_wp
  583. ENDIF
  584. END DO
  585. END DO
  586. END DO
  587. ELSE ! new formulation from NEMO 3.6
  588. DO jk = 1, jpk
  589. DO jj = 1, jpjm1
  590. DO ji = 1, fs_jpim1
  591. ze3 = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk) &
  592. & + fse3t(ji,jj ,jk)*tmask(ji,jj ,jk) + fse3t(ji+1,jj ,jk)*tmask(ji+1,jj ,jk) )
  593. zmsk = ( tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk) &
  594. & + tmask(ji,jj ,jk) + tmask(ji+1,jj ,jk) )
  595. IF ( ze3 /= 0._wp ) THEN ; ze3f(ji,jj,jk) = zmsk / ze3
  596. ELSE ; ze3f(ji,jj,jk) = 0.0_wp
  597. ENDIF
  598. END DO
  599. END DO
  600. END DO
  601. ENDIF
  602. CALL lbc_lnk( ze3f, 'F', 1. )
  603. ENDIF
  604. zfac12 = 1._wp / 12._wp ! Local constant initialization
  605. !CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz, ztnw, ztne, ztsw, ztse )
  606. ! ! ===============
  607. DO jk = 1, jpkm1 ! Horizontal slab
  608. ! ! ===============
  609. ! Potential vorticity and horizontal fluxes
  610. ! -----------------------------------------
  611. SELECT CASE( kvor ) ! vorticity considered
  612. CASE ( 1 ) ! planetary vorticity (Coriolis)
  613. zwz(:,:) = ff(:,:) * ze3f(:,:,jk)
  614. CASE ( 2 ) ! relative vorticity
  615. zwz(:,:) = rotn(:,:,jk) * ze3f(:,:,jk)
  616. CASE ( 3 ) ! metric term
  617. DO jj = 1, jpjm1
  618. DO ji = 1, fs_jpim1 ! vector opt.
  619. zwz(ji,jj) = ( ( vn(ji+1,jj ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj ) - e2v(ji,jj) ) &
  620. & - ( un(ji ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji ,jj+1) - e1u(ji,jj) ) ) &
  621. & * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) ) * ze3f(ji,jj,jk)
  622. END DO
  623. END DO
  624. CALL lbc_lnk( zwz, 'F', 1. )
  625. CASE ( 4 ) ! total (relative + planetary vorticity)
  626. zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) ) * ze3f(:,:,jk)
  627. CASE ( 5 ) ! total (coriolis + metric)
  628. DO jj = 1, jpjm1
  629. DO ji = 1, fs_jpim1 ! vector opt.
  630. zwz(ji,jj) = ( ff (ji,jj) &
  631. & + ( ( vn(ji+1,jj ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj ) - e2v(ji,jj) ) &
  632. & - ( un(ji ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji ,jj+1) - e1u(ji,jj) ) ) &
  633. & * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) ) &
  634. & ) * ze3f(ji,jj,jk)
  635. END DO
  636. END DO
  637. CALL lbc_lnk( zwz, 'F', 1. )
  638. END SELECT
  639. zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
  640. zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
  641. ! Compute and add the vorticity term trend
  642. ! ----------------------------------------
  643. jj = 2
  644. ztne(1,:) = 0 ; ztnw(1,:) = 0 ; ztse(1,:) = 0 ; ztsw(1,:) = 0
  645. DO ji = 2, jpi
  646. ztne(ji,jj) = zwz(ji-1,jj ) + zwz(ji ,jj ) + zwz(ji ,jj-1)
  647. ztnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj ) + zwz(ji ,jj )
  648. ztse(ji,jj) = zwz(ji ,jj ) + zwz(ji ,jj-1) + zwz(ji-1,jj-1)
  649. ztsw(ji,jj) = zwz(ji ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj )
  650. END DO
  651. DO jj = 3, jpj
  652. DO ji = fs_2, jpi ! vector opt. ok because we start at jj = 3
  653. ztne(ji,jj) = zwz(ji-1,jj ) + zwz(ji ,jj ) + zwz(ji ,jj-1)
  654. ztnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj ) + zwz(ji ,jj )
  655. ztse(ji,jj) = zwz(ji ,jj ) + zwz(ji ,jj-1) + zwz(ji-1,jj-1)
  656. ztsw(ji,jj) = zwz(ji ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj )
  657. END DO
  658. END DO
  659. DO jj = 2, jpjm1
  660. DO ji = fs_2, fs_jpim1 ! vector opt.
  661. zua = + zfac12 / e1u(ji,jj) * ( ztne(ji,jj ) * zwy(ji ,jj ) + ztnw(ji+1,jj) * zwy(ji+1,jj ) &
  662. & + ztse(ji,jj ) * zwy(ji ,jj-1) + ztsw(ji+1,jj) * zwy(ji+1,jj-1) )
  663. zva = - zfac12 / e2v(ji,jj) * ( ztsw(ji,jj+1) * zwx(ji-1,jj+1) + ztse(ji,jj+1) * zwx(ji ,jj+1) &
  664. & + ztnw(ji,jj ) * zwx(ji-1,jj ) + ztne(ji,jj ) * zwx(ji ,jj ) )
  665. pua(ji,jj,jk) = pua(ji,jj,jk) + zua
  666. pva(ji,jj,jk) = pva(ji,jj,jk) + zva
  667. END DO
  668. END DO
  669. ! ! ===============
  670. END DO ! End of slab
  671. ! ! ===============
  672. CALL wrk_dealloc( jpi, jpj, zwx , zwy , zwz )
  673. CALL wrk_dealloc( jpi, jpj, ztnw, ztne, ztsw, ztse )
  674. #if defined key_vvl
  675. CALL wrk_dealloc( jpi, jpj, jpk, ze3f )
  676. #endif
  677. !
  678. IF( nn_timing == 1 ) CALL timing_stop('vor_een')
  679. !
  680. END SUBROUTINE vor_een
  681. SUBROUTINE dyn_vor_init
  682. !!---------------------------------------------------------------------
  683. !! *** ROUTINE dyn_vor_init ***
  684. !!
  685. !! ** Purpose : Control the consistency between cpp options for
  686. !! tracer advection schemes
  687. !!----------------------------------------------------------------------
  688. INTEGER :: ioptio ! local integer
  689. INTEGER :: ji, jj, jk ! dummy loop indices
  690. INTEGER :: ios ! Local integer output status for namelist read
  691. !!
  692. NAMELIST/namdyn_vor/ ln_dynvor_ens, ln_dynvor_ene, ln_dynvor_mix, ln_dynvor_een, ln_dynvor_een_old
  693. !!----------------------------------------------------------------------
  694. REWIND( numnam_ref ) ! Namelist namdyn_vor in reference namelist : Vorticity scheme options
  695. READ ( numnam_ref, namdyn_vor, IOSTAT = ios, ERR = 901)
  696. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_vor in reference namelist', lwp )
  697. REWIND( numnam_cfg ) ! Namelist namdyn_vor in configuration namelist : Vorticity scheme options
  698. READ ( numnam_cfg, namdyn_vor, IOSTAT = ios, ERR = 902 )
  699. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_vor in configuration namelist', lwp )
  700. IF(lwm) WRITE ( numond, namdyn_vor )
  701. IF(lwp) THEN ! Namelist print
  702. WRITE(numout,*)
  703. WRITE(numout,*) 'dyn_vor_init : vorticity term : read namelist and control the consistency'
  704. WRITE(numout,*) '~~~~~~~~~~~~'
  705. WRITE(numout,*) ' Namelist namdyn_vor : choice of the vorticity term scheme'
  706. WRITE(numout,*) ' energy conserving scheme ln_dynvor_ene = ', ln_dynvor_ene
  707. WRITE(numout,*) ' enstrophy conserving scheme ln_dynvor_ens = ', ln_dynvor_ens
  708. WRITE(numout,*) ' mixed enstrophy/energy conserving scheme ln_dynvor_mix = ', ln_dynvor_mix
  709. WRITE(numout,*) ' enstrophy and energy conserving scheme ln_dynvor_een = ', ln_dynvor_een
  710. WRITE(numout,*) ' enstrophy and energy conserving scheme (old) ln_dynvor_een_old= ', ln_dynvor_een_old
  711. ENDIF
  712. ! If energy, enstrophy or mixed advection of momentum in vector form change the value for masks
  713. ! at angles with three ocean points and one land point
  714. IF( ln_vorlat .AND. ( ln_dynvor_ene .OR. ln_dynvor_ens .OR. ln_dynvor_mix ) ) THEN
  715. DO jk = 1, jpk
  716. DO jj = 2, jpjm1
  717. DO ji = 2, jpim1
  718. IF( tmask(ji,jj,jk)+tmask(ji+1,jj,jk)+tmask(ji,jj+1,jk)+tmask(ji+1,jj+1,jk) == 3._wp ) &
  719. fmask(ji,jj,jk) = 1._wp
  720. END DO
  721. END DO
  722. END DO
  723. !
  724. CALL lbc_lnk( fmask, 'F', 1._wp ) ! Lateral boundary conditions on fmask
  725. !
  726. ENDIF
  727. ioptio = 0 ! Control of vorticity scheme options
  728. IF( ln_dynvor_ene ) ioptio = ioptio + 1
  729. IF( ln_dynvor_ens ) ioptio = ioptio + 1
  730. IF( ln_dynvor_mix ) ioptio = ioptio + 1
  731. IF( ln_dynvor_een ) ioptio = ioptio + 1
  732. IF( ln_dynvor_een_old ) ioptio = ioptio + 1
  733. IF( lk_esopa ) ioptio = 1
  734. IF( ioptio /= 1 ) CALL ctl_stop( ' use ONE and ONLY one vorticity scheme' )
  735. ! ! Set nvor (type of scheme for vorticity)
  736. IF( ln_dynvor_ene ) nvor = 0
  737. IF( ln_dynvor_ens ) nvor = 1
  738. IF( ln_dynvor_mix ) nvor = 2
  739. IF( ln_dynvor_een .or. ln_dynvor_een_old ) nvor = 3
  740. IF( lk_esopa ) nvor = -1
  741. ! ! Set ncor, nrvm, ntot (type of vorticity)
  742. IF(lwp) WRITE(numout,*)
  743. ncor = 1
  744. IF( ln_dynadv_vec ) THEN
  745. IF(lwp) WRITE(numout,*) ' Vector form advection : vorticity = Coriolis + relative vorticity'
  746. nrvm = 2
  747. ntot = 4
  748. ELSE
  749. IF(lwp) WRITE(numout,*) ' Flux form advection : vorticity = Coriolis + metric term'
  750. nrvm = 3
  751. ntot = 5
  752. ENDIF
  753. IF(lwp) THEN ! Print the choice
  754. WRITE(numout,*)
  755. IF( nvor == 0 ) WRITE(numout,*) ' vorticity scheme : energy conserving scheme'
  756. IF( nvor == 1 ) WRITE(numout,*) ' vorticity scheme : enstrophy conserving scheme'
  757. IF( nvor == 2 ) WRITE(numout,*) ' vorticity scheme : mixed enstrophy/energy conserving scheme'
  758. IF( nvor == 3 ) WRITE(numout,*) ' vorticity scheme : energy and enstrophy conserving scheme'
  759. IF( nvor == -1 ) WRITE(numout,*) ' esopa test: use all lateral physics options'
  760. ENDIF
  761. !
  762. END SUBROUTINE dyn_vor_init
  763. !!==============================================================================
  764. END MODULE dynvor