domvvl.F90 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  1. MODULE domvvl
  2. !!======================================================================
  3. !! *** MODULE domvvl ***
  4. !! Ocean :
  5. !!======================================================================
  6. !! History : 2.0 ! 2006-06 (B. Levier, L. Marie) original code
  7. !! 3.1 ! 2009-02 (G. Madec, M. Leclair, R. Benshila) pure z* coordinate
  8. !! 3.3 ! 2011-10 (M. Leclair) totally rewrote domvvl:
  9. !! vvl option includes z_star and z_tilde coordinates
  10. !! 3.6 ! 2014-11 (P. Mathiot) add ice shelf capability
  11. !!----------------------------------------------------------------------
  12. !! 'key_vvl' variable volume
  13. !!----------------------------------------------------------------------
  14. !!----------------------------------------------------------------------
  15. !! dom_vvl_init : define initial vertical scale factors, depths and column thickness
  16. !! dom_vvl_sf_nxt : Compute next vertical scale factors
  17. !! dom_vvl_sf_swp : Swap vertical scale factors and update the vertical grid
  18. !! dom_vvl_interpol : Interpolate vertical scale factors from one grid point to another
  19. !! dom_vvl_rst : read/write restart file
  20. !! dom_vvl_ctl : Check the vvl options
  21. !! dom_vvl_orca_fix : Recompute some area-weighted interpolations of vertical scale factors
  22. !! : to account for manual changes to e[1,2][u,v] in some Straits
  23. !!----------------------------------------------------------------------
  24. !! * Modules used
  25. USE oce ! ocean dynamics and tracers
  26. USE dom_oce ! ocean space and time domain
  27. USE sbc_oce ! ocean surface boundary condition
  28. USE in_out_manager ! I/O manager
  29. USE iom ! I/O manager library
  30. USE restart ! ocean restart
  31. USE lib_mpp ! distributed memory computing library
  32. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  33. USE wrk_nemo ! Memory allocation
  34. USE timing ! Timing
  35. IMPLICIT NONE
  36. PRIVATE
  37. !! * Routine accessibility
  38. PUBLIC dom_vvl_init ! called by domain.F90
  39. PUBLIC dom_vvl_sf_nxt ! called by step.F90
  40. PUBLIC dom_vvl_sf_swp ! called by step.F90
  41. PUBLIC dom_vvl_interpol ! called by dynnxt.F90
  42. PRIVATE dom_vvl_orca_fix ! called by dom_vvl_interpol
  43. !!* Namelist nam_vvl
  44. LOGICAL , PUBLIC :: ln_vvl_zstar = .FALSE. ! zstar vertical coordinate
  45. LOGICAL , PUBLIC :: ln_vvl_ztilde = .FALSE. ! ztilde vertical coordinate
  46. LOGICAL , PUBLIC :: ln_vvl_layer = .FALSE. ! level vertical coordinate
  47. LOGICAL , PUBLIC :: ln_vvl_ztilde_as_zstar = .FALSE. ! ztilde vertical coordinate
  48. LOGICAL , PUBLIC :: ln_vvl_zstar_at_eqtor = .FALSE. ! ztilde vertical coordinate
  49. LOGICAL , PUBLIC :: ln_vvl_kepe = .FALSE. ! kinetic/potential energy transfer
  50. ! ! conservation: not used yet
  51. REAL(wp) :: rn_ahe3 ! thickness diffusion coefficient
  52. REAL(wp) :: rn_rst_e3t ! ztilde to zstar restoration timescale [days]
  53. REAL(wp) :: rn_lf_cutoff ! cutoff frequency for low-pass filter [days]
  54. REAL(wp) :: rn_zdef_max ! maximum fractional e3t deformation
  55. LOGICAL , PUBLIC :: ln_vvl_dbg = .FALSE. ! debug control prints
  56. !! * Module variables
  57. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: un_td, vn_td ! thickness diffusion transport
  58. REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: hdiv_lf ! low frequency part of hz divergence
  59. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: tilde_e3t_b, tilde_e3t_n ! baroclinic scale factors
  60. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: tilde_e3t_a, dtilde_e3t_a ! baroclinic scale factors
  61. REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:) :: frq_rst_e3t ! retoring period for scale factors
  62. REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:) :: frq_rst_hdv ! retoring period for low freq. divergence
  63. !! * Substitutions
  64. # include "domzgr_substitute.h90"
  65. # include "vectopt_loop_substitute.h90"
  66. !!----------------------------------------------------------------------
  67. !! NEMO/OPA 3.3 , NEMO-Consortium (2010)
  68. !! $Id: domvvl.F90 5506 2015-06-29 15:19:38Z clevy $
  69. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  70. !!----------------------------------------------------------------------
  71. CONTAINS
  72. INTEGER FUNCTION dom_vvl_alloc()
  73. !!----------------------------------------------------------------------
  74. !! *** FUNCTION dom_vvl_alloc ***
  75. !!----------------------------------------------------------------------
  76. IF( ln_vvl_zstar ) dom_vvl_alloc = 0
  77. IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
  78. ALLOCATE( tilde_e3t_b(jpi,jpj,jpk) , tilde_e3t_n(jpi,jpj,jpk) , tilde_e3t_a(jpi,jpj,jpk) , &
  79. & dtilde_e3t_a(jpi,jpj,jpk) , un_td (jpi,jpj,jpk) , vn_td (jpi,jpj,jpk) , &
  80. & STAT = dom_vvl_alloc )
  81. IF( lk_mpp ) CALL mpp_sum ( dom_vvl_alloc )
  82. IF( dom_vvl_alloc /= 0 ) CALL ctl_warn('dom_vvl_alloc: failed to allocate arrays')
  83. un_td = 0.0_wp
  84. vn_td = 0.0_wp
  85. ENDIF
  86. IF( ln_vvl_ztilde ) THEN
  87. ALLOCATE( frq_rst_e3t(jpi,jpj) , frq_rst_hdv(jpi,jpj) , hdiv_lf(jpi,jpj,jpk) , STAT= dom_vvl_alloc )
  88. IF( lk_mpp ) CALL mpp_sum ( dom_vvl_alloc )
  89. IF( dom_vvl_alloc /= 0 ) CALL ctl_warn('dom_vvl_alloc: failed to allocate arrays')
  90. ENDIF
  91. END FUNCTION dom_vvl_alloc
  92. SUBROUTINE dom_vvl_init
  93. !!----------------------------------------------------------------------
  94. !! *** ROUTINE dom_vvl_init ***
  95. !!
  96. !! ** Purpose : Initialization of all scale factors, depths
  97. !! and water column heights
  98. !!
  99. !! ** Method : - use restart file and/or initialize
  100. !! - interpolate scale factors
  101. !!
  102. !! ** Action : - fse3t_(n/b) and tilde_e3t_(n/b)
  103. !! - Regrid: fse3(u/v)_n
  104. !! fse3(u/v)_b
  105. !! fse3w_n
  106. !! fse3(u/v)w_b
  107. !! fse3(u/v)w_n
  108. !! fsdept_n, fsdepw_n and fsde3w_n
  109. !! - h(t/u/v)_0
  110. !! - frq_rst_e3t and frq_rst_hdv
  111. !!
  112. !! Reference : Leclair, M., and G. Madec, 2011, Ocean Modelling.
  113. !!----------------------------------------------------------------------
  114. USE phycst, ONLY : rpi, rsmall, rad
  115. !! * Local declarations
  116. INTEGER :: ji,jj,jk
  117. INTEGER :: ii0, ii1, ij0, ij1
  118. REAL(wp):: zcoef
  119. !!----------------------------------------------------------------------
  120. IF( nn_timing == 1 ) CALL timing_start('dom_vvl_init')
  121. IF(lwp) WRITE(numout,*)
  122. IF(lwp) WRITE(numout,*) 'dom_vvl_init : Variable volume activated'
  123. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
  124. ! choose vertical coordinate (z_star, z_tilde or layer)
  125. ! ==========================
  126. CALL dom_vvl_ctl
  127. ! Allocate module arrays
  128. ! ======================
  129. IF( dom_vvl_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'dom_vvl_init : unable to allocate arrays' )
  130. ! Read or initialize fse3t_(b/n), tilde_e3t_(b/n) and hdiv_lf (and e3t_a(jpk))
  131. ! ============================================================================
  132. CALL dom_vvl_rst( nit000, 'READ' )
  133. fse3t_a(:,:,jpk) = e3t_0(:,:,jpk)
  134. ! Reconstruction of all vertical scale factors at now and before time steps
  135. ! =============================================================================
  136. ! Horizontal scale factor interpolations
  137. ! --------------------------------------
  138. CALL dom_vvl_interpol( fse3t_b(:,:,:), fse3u_b(:,:,:), 'U' )
  139. CALL dom_vvl_interpol( fse3t_b(:,:,:), fse3v_b(:,:,:), 'V' )
  140. CALL dom_vvl_interpol( fse3t_n(:,:,:), fse3u_n(:,:,:), 'U' )
  141. CALL dom_vvl_interpol( fse3t_n(:,:,:), fse3v_n(:,:,:), 'V' )
  142. CALL dom_vvl_interpol( fse3u_n(:,:,:), fse3f_n(:,:,:), 'F' )
  143. ! Vertical scale factor interpolations
  144. ! ------------------------------------
  145. CALL dom_vvl_interpol( fse3t_n(:,:,:), fse3w_n (:,:,:), 'W' )
  146. CALL dom_vvl_interpol( fse3u_n(:,:,:), fse3uw_n(:,:,:), 'UW' )
  147. CALL dom_vvl_interpol( fse3v_n(:,:,:), fse3vw_n(:,:,:), 'VW' )
  148. CALL dom_vvl_interpol( fse3t_b(:,:,:), fse3w_b (:,:,:), 'W' )
  149. CALL dom_vvl_interpol( fse3u_b(:,:,:), fse3uw_b(:,:,:), 'UW' )
  150. CALL dom_vvl_interpol( fse3v_b(:,:,:), fse3vw_b(:,:,:), 'VW' )
  151. ! t- and w- points depth
  152. ! ----------------------
  153. ! set the isf depth as it is in the initial step
  154. fsdept_n(:,:,1) = 0.5_wp * fse3w_n(:,:,1)
  155. fsdepw_n(:,:,1) = 0.0_wp
  156. fsde3w_n(:,:,1) = fsdept_n(:,:,1) - sshn(:,:)
  157. fsdept_b(:,:,1) = 0.5_wp * fse3w_b(:,:,1)
  158. fsdepw_b(:,:,1) = 0.0_wp
  159. DO jk = 2, jpk
  160. DO jj = 1,jpj
  161. DO ji = 1,jpi
  162. ! zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk)) ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt
  163. ! 1 everywhere from mbkt to mikt + 1 or 1 (if no isf)
  164. ! 0.5 where jk = mikt
  165. zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk))
  166. fsdepw_n(ji,jj,jk) = fsdepw_n(ji,jj,jk-1) + fse3t_n(ji,jj,jk-1)
  167. fsdept_n(ji,jj,jk) = zcoef * ( fsdepw_n(ji,jj,jk ) + 0.5 * fse3w_n(ji,jj,jk)) &
  168. & + (1-zcoef) * ( fsdept_n(ji,jj,jk-1) + fse3w_n(ji,jj,jk))
  169. fsde3w_n(ji,jj,jk) = fsdept_n(ji,jj,jk) - sshn(ji,jj)
  170. fsdepw_b(ji,jj,jk) = fsdepw_b(ji,jj,jk-1) + fse3t_b(ji,jj,jk-1)
  171. fsdept_b(ji,jj,jk) = zcoef * ( fsdepw_b(ji,jj,jk ) + 0.5 * fse3w_b(ji,jj,jk)) &
  172. & + (1-zcoef) * ( fsdept_b(ji,jj,jk-1) + fse3w_b(ji,jj,jk))
  173. END DO
  174. END DO
  175. END DO
  176. ! Before depth and Inverse of the local depth of the water column at u- and v- points
  177. ! -----------------------------------------------------------------------------------
  178. hu_b(:,:) = 0.
  179. hv_b(:,:) = 0.
  180. DO jk = 1, jpkm1
  181. hu_b(:,:) = hu_b(:,:) + fse3u_b(:,:,jk) * umask(:,:,jk)
  182. hv_b(:,:) = hv_b(:,:) + fse3v_b(:,:,jk) * vmask(:,:,jk)
  183. END DO
  184. hur_b(:,:) = umask_i(:,:) / ( hu_b(:,:) + 1. - umask_i(:,:) )
  185. hvr_b(:,:) = vmask_i(:,:) / ( hv_b(:,:) + 1. - vmask_i(:,:) )
  186. ! Restoring frequencies for z_tilde coordinate
  187. ! ============================================
  188. IF( ln_vvl_ztilde ) THEN
  189. ! Values in days provided via the namelist; use rsmall to avoid possible division by zero errors with faulty settings
  190. frq_rst_e3t(:,:) = 2.0_wp * rpi / ( MAX( rn_rst_e3t , rsmall ) * 86400.0_wp )
  191. frq_rst_hdv(:,:) = 2.0_wp * rpi / ( MAX( rn_lf_cutoff, rsmall ) * 86400.0_wp )
  192. IF( ln_vvl_ztilde_as_zstar ) THEN
  193. ! Ignore namelist settings and use these next two to emulate z-star using z-tilde
  194. frq_rst_e3t(:,:) = 0.0_wp
  195. frq_rst_hdv(:,:) = 1.0_wp / rdt
  196. ENDIF
  197. IF ( ln_vvl_zstar_at_eqtor ) THEN
  198. DO jj = 1, jpj
  199. DO ji = 1, jpi
  200. IF( ABS(gphit(ji,jj)) >= 6.) THEN
  201. ! values outside the equatorial band and transition zone (ztilde)
  202. frq_rst_e3t(ji,jj) = 2.0_wp * rpi / ( MAX( rn_rst_e3t , rsmall ) * 86400.e0_wp )
  203. frq_rst_hdv(ji,jj) = 2.0_wp * rpi / ( MAX( rn_lf_cutoff, rsmall ) * 86400.e0_wp )
  204. ELSEIF( ABS(gphit(ji,jj)) <= 2.5) THEN
  205. ! values inside the equatorial band (ztilde as zstar)
  206. frq_rst_e3t(ji,jj) = 0.0_wp
  207. frq_rst_hdv(ji,jj) = 1.0_wp / rdt
  208. ELSE
  209. ! values in the transition band (linearly vary from ztilde to ztilde as zstar values)
  210. frq_rst_e3t(ji,jj) = 0.0_wp + (frq_rst_e3t(ji,jj)-0.0_wp)*0.5_wp &
  211. & * ( 1.0_wp - COS( rad*(ABS(gphit(ji,jj))-2.5_wp) &
  212. & * 180._wp / 3.5_wp ) )
  213. frq_rst_hdv(ji,jj) = (1.0_wp / rdt) &
  214. & + ( frq_rst_hdv(ji,jj)-(1.e0_wp / rdt) )*0.5_wp &
  215. & * ( 1._wp - COS( rad*(ABS(gphit(ji,jj))-2.5_wp) &
  216. & * 180._wp / 3.5_wp ) )
  217. ENDIF
  218. END DO
  219. END DO
  220. IF( cp_cfg == "orca" .AND. jp_cfg == 3 ) THEN
  221. ii0 = 103 ; ii1 = 111 ! Suppress ztilde in the Foxe Basin for ORCA2
  222. ij0 = 128 ; ij1 = 135 ;
  223. frq_rst_e3t( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.0_wp
  224. frq_rst_hdv( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0_wp / rdt
  225. ENDIF
  226. ENDIF
  227. ENDIF
  228. IF( nn_timing == 1 ) CALL timing_stop('dom_vvl_init')
  229. END SUBROUTINE dom_vvl_init
  230. SUBROUTINE dom_vvl_sf_nxt( kt, kcall )
  231. !!----------------------------------------------------------------------
  232. !! *** ROUTINE dom_vvl_sf_nxt ***
  233. !!
  234. !! ** Purpose : - compute the after scale factors used in tra_zdf, dynnxt,
  235. !! tranxt and dynspg routines
  236. !!
  237. !! ** Method : - z_star case: Repartition of ssh INCREMENT proportionnaly to the level thickness.
  238. !! - z_tilde_case: after scale factor increment =
  239. !! high frequency part of horizontal divergence
  240. !! + retsoring towards the background grid
  241. !! + thickness difusion
  242. !! Then repartition of ssh INCREMENT proportionnaly
  243. !! to the "baroclinic" level thickness.
  244. !!
  245. !! ** Action : - hdiv_lf : restoring towards full baroclinic divergence in z_tilde case
  246. !! - tilde_e3t_a: after increment of vertical scale factor
  247. !! in z_tilde case
  248. !! - fse3(t/u/v)_a
  249. !!
  250. !! Reference : Leclair, M., and Madec, G. 2011, Ocean Modelling.
  251. !!----------------------------------------------------------------------
  252. REAL(wp), POINTER, DIMENSION(:,:,:) :: ze3t
  253. REAL(wp), POINTER, DIMENSION(:,: ) :: zht, z_scale, zwu, zwv, zhdiv
  254. !! * Arguments
  255. INTEGER, INTENT( in ) :: kt ! time step
  256. INTEGER, INTENT( in ), OPTIONAL :: kcall ! optional argument indicating call sequence
  257. !! * Local declarations
  258. INTEGER :: ji, jj, jk ! dummy loop indices
  259. INTEGER , DIMENSION(3) :: ijk_max, ijk_min ! temporary integers
  260. REAL(wp) :: z2dt ! temporary scalars
  261. REAL(wp) :: z_tmin, z_tmax ! temporary scalars
  262. LOGICAL :: ll_do_bclinic ! temporary logical
  263. !!----------------------------------------------------------------------
  264. IF( nn_timing == 1 ) CALL timing_start('dom_vvl_sf_nxt')
  265. CALL wrk_alloc( jpi, jpj, zht, z_scale, zwu, zwv, zhdiv )
  266. CALL wrk_alloc( jpi, jpj, jpk, ze3t )
  267. IF(kt == nit000) THEN
  268. IF(lwp) WRITE(numout,*)
  269. IF(lwp) WRITE(numout,*) 'dom_vvl_sf_nxt : compute after scale factors'
  270. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'
  271. ENDIF
  272. ll_do_bclinic = .TRUE.
  273. IF( PRESENT(kcall) ) THEN
  274. IF ( kcall == 2 .AND. ln_vvl_ztilde ) ll_do_bclinic = .FALSE.
  275. ENDIF
  276. ! ******************************* !
  277. ! After acale factors at t-points !
  278. ! ******************************* !
  279. ! ! --------------------------------------------- !
  280. ! z_star coordinate and barotropic z-tilde part !
  281. ! ! --------------------------------------------- !
  282. z_scale(:,:) = ( ssha(:,:) - sshb(:,:) ) * ssmask(:,:) / ( ht_0(:,:) + sshn(:,:) + 1. - ssmask(:,:) )
  283. DO jk = 1, jpkm1
  284. ! formally this is the same as fse3t_a = e3t_0*(1+ssha/ht_0)
  285. fse3t_a(:,:,jk) = fse3t_b(:,:,jk) + fse3t_n(:,:,jk) * z_scale(:,:) * tmask(:,:,jk)
  286. END DO
  287. IF( ln_vvl_ztilde .OR. ln_vvl_layer .AND. ll_do_bclinic ) THEN ! z_tilde or layer coordinate !
  288. ! ! ------baroclinic part------ !
  289. ! I - initialization
  290. ! ==================
  291. ! 1 - barotropic divergence
  292. ! -------------------------
  293. zhdiv(:,:) = 0.
  294. zht(:,:) = 0.
  295. DO jk = 1, jpkm1
  296. zhdiv(:,:) = zhdiv(:,:) + fse3t_n(:,:,jk) * hdivn(:,:,jk)
  297. zht (:,:) = zht (:,:) + fse3t_n(:,:,jk) * tmask(:,:,jk)
  298. END DO
  299. zhdiv(:,:) = zhdiv(:,:) / ( zht(:,:) + 1. - tmask_i(:,:) )
  300. ! 2 - Low frequency baroclinic horizontal divergence (z-tilde case only)
  301. ! --------------------------------------------------
  302. IF( ln_vvl_ztilde ) THEN
  303. IF( kt .GT. nit000 ) THEN
  304. DO jk = 1, jpkm1
  305. hdiv_lf(:,:,jk) = hdiv_lf(:,:,jk) - rdt * frq_rst_hdv(:,:) &
  306. & * ( hdiv_lf(:,:,jk) - fse3t_n(:,:,jk) * ( hdivn(:,:,jk) - zhdiv(:,:) ) )
  307. END DO
  308. ENDIF
  309. END IF
  310. ! II - after z_tilde increments of vertical scale factors
  311. ! =======================================================
  312. tilde_e3t_a(:,:,:) = 0.0_wp ! tilde_e3t_a used to store tendency terms
  313. ! 1 - High frequency divergence term
  314. ! ----------------------------------
  315. IF( ln_vvl_ztilde ) THEN ! z_tilde case
  316. DO jk = 1, jpkm1
  317. tilde_e3t_a(:,:,jk) = tilde_e3t_a(:,:,jk) - ( fse3t_n(:,:,jk) * ( hdivn(:,:,jk) - zhdiv(:,:) ) - hdiv_lf(:,:,jk) )
  318. END DO
  319. ELSE ! layer case
  320. DO jk = 1, jpkm1
  321. tilde_e3t_a(:,:,jk) = tilde_e3t_a(:,:,jk) - fse3t_n(:,:,jk) * ( hdivn(:,:,jk) - zhdiv(:,:) ) * tmask(:,:,jk)
  322. END DO
  323. END IF
  324. ! 2 - Restoring term (z-tilde case only)
  325. ! ------------------
  326. IF( ln_vvl_ztilde ) THEN
  327. DO jk = 1, jpk
  328. tilde_e3t_a(:,:,jk) = tilde_e3t_a(:,:,jk) - frq_rst_e3t(:,:) * tilde_e3t_b(:,:,jk)
  329. END DO
  330. END IF
  331. ! 3 - Thickness diffusion term
  332. ! ----------------------------
  333. zwu(:,:) = 0.0_wp
  334. zwv(:,:) = 0.0_wp
  335. ! a - first derivative: diffusive fluxes
  336. DO jk = 1, jpkm1
  337. DO jj = 1, jpjm1
  338. DO ji = 1, fs_jpim1 ! vector opt.
  339. un_td(ji,jj,jk) = rn_ahe3 * umask(ji,jj,jk) * re2u_e1u(ji,jj) &
  340. & * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji+1,jj ,jk) )
  341. vn_td(ji,jj,jk) = rn_ahe3 * vmask(ji,jj,jk) * re1v_e2v(ji,jj) &
  342. & * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji ,jj+1,jk) )
  343. zwu(ji,jj) = zwu(ji,jj) + un_td(ji,jj,jk)
  344. zwv(ji,jj) = zwv(ji,jj) + vn_td(ji,jj,jk)
  345. END DO
  346. END DO
  347. END DO
  348. ! b - correction for last oceanic u-v points
  349. DO jj = 1, jpj
  350. DO ji = 1, jpi
  351. un_td(ji,jj,mbku(ji,jj)) = un_td(ji,jj,mbku(ji,jj)) - zwu(ji,jj)
  352. vn_td(ji,jj,mbkv(ji,jj)) = vn_td(ji,jj,mbkv(ji,jj)) - zwv(ji,jj)
  353. END DO
  354. END DO
  355. ! c - second derivative: divergence of diffusive fluxes
  356. DO jk = 1, jpkm1
  357. DO jj = 2, jpjm1
  358. DO ji = fs_2, fs_jpim1 ! vector opt.
  359. tilde_e3t_a(ji,jj,jk) = tilde_e3t_a(ji,jj,jk) + ( un_td(ji-1,jj ,jk) - un_td(ji,jj,jk) &
  360. & + vn_td(ji ,jj-1,jk) - vn_td(ji,jj,jk) &
  361. & ) * r1_e12t(ji,jj)
  362. END DO
  363. END DO
  364. END DO
  365. ! d - thickness diffusion transport: boundary conditions
  366. ! (stored for tracer advction and continuity equation)
  367. CALL lbc_lnk( un_td , 'U' , -1._wp)
  368. CALL lbc_lnk( vn_td , 'V' , -1._wp)
  369. ! 4 - Time stepping of baroclinic scale factors
  370. ! ---------------------------------------------
  371. ! Leapfrog time stepping
  372. ! ~~~~~~~~~~~~~~~~~~~~~~
  373. IF( neuler == 0 .AND. kt == nit000 ) THEN
  374. z2dt = rdt
  375. ELSE
  376. z2dt = 2.0_wp * rdt
  377. ENDIF
  378. CALL lbc_lnk( tilde_e3t_a(:,:,:), 'T', 1._wp )
  379. tilde_e3t_a(:,:,:) = tilde_e3t_b(:,:,:) + z2dt * tmask(:,:,:) * tilde_e3t_a(:,:,:)
  380. ! Maximum deformation control
  381. ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  382. ze3t(:,:,jpk) = 0.0_wp
  383. DO jk = 1, jpkm1
  384. ze3t(:,:,jk) = tilde_e3t_a(:,:,jk) / e3t_0(:,:,jk) * tmask(:,:,jk) * tmask_i(:,:)
  385. END DO
  386. z_tmax = MAXVAL( ze3t(:,:,:) )
  387. IF( lk_mpp ) CALL mpp_max( z_tmax ) ! max over the global domain
  388. z_tmin = MINVAL( ze3t(:,:,:) )
  389. IF( lk_mpp ) CALL mpp_min( z_tmin ) ! min over the global domain
  390. ! - ML - test: for the moment, stop simulation for too large e3_t variations
  391. IF( ( z_tmax .GT. rn_zdef_max ) .OR. ( z_tmin .LT. - rn_zdef_max ) ) THEN
  392. IF( lk_mpp ) THEN
  393. CALL mpp_maxloc( ze3t, tmask, z_tmax, ijk_max(1), ijk_max(2), ijk_max(3) )
  394. CALL mpp_minloc( ze3t, tmask, z_tmin, ijk_min(1), ijk_min(2), ijk_min(3) )
  395. ELSE
  396. ijk_max = MAXLOC( ze3t(:,:,:) )
  397. ijk_max(1) = ijk_max(1) + nimpp - 1
  398. ijk_max(2) = ijk_max(2) + njmpp - 1
  399. ijk_min = MINLOC( ze3t(:,:,:) )
  400. ijk_min(1) = ijk_min(1) + nimpp - 1
  401. ijk_min(2) = ijk_min(2) + njmpp - 1
  402. ENDIF
  403. IF (lwp) THEN
  404. WRITE(numout, *) 'MAX( tilde_e3t_a(:,:,:) / e3t_0(:,:,:) ) =', z_tmax
  405. WRITE(numout, *) 'at i, j, k=', ijk_max
  406. WRITE(numout, *) 'MIN( tilde_e3t_a(:,:,:) / e3t_0(:,:,:) ) =', z_tmin
  407. WRITE(numout, *) 'at i, j, k=', ijk_min
  408. CALL ctl_warn('MAX( ABS( tilde_e3t_a(:,:,:) ) / e3t_0(:,:,:) ) too high')
  409. ENDIF
  410. ENDIF
  411. ! - ML - end test
  412. ! - ML - Imposing these limits will cause a baroclinicity error which is corrected for below
  413. tilde_e3t_a(:,:,:) = MIN( tilde_e3t_a(:,:,:), rn_zdef_max * e3t_0(:,:,:) )
  414. tilde_e3t_a(:,:,:) = MAX( tilde_e3t_a(:,:,:), - rn_zdef_max * e3t_0(:,:,:) )
  415. !
  416. ! "tilda" change in the after scale factor
  417. ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  418. DO jk = 1, jpkm1
  419. dtilde_e3t_a(:,:,jk) = tilde_e3t_a(:,:,jk) - tilde_e3t_b(:,:,jk)
  420. END DO
  421. ! III - Barotropic repartition of the sea surface height over the baroclinic profile
  422. ! ==================================================================================
  423. ! add ( ssh increment + "baroclinicity error" ) proportionly to e3t(n)
  424. ! - ML - baroclinicity error should be better treated in the future
  425. ! i.e. locally and not spread over the water column.
  426. ! (keep in mind that the idea is to reduce Eulerian velocity as much as possible)
  427. zht(:,:) = 0.
  428. DO jk = 1, jpkm1
  429. zht(:,:) = zht(:,:) + tilde_e3t_a(:,:,jk) * tmask(:,:,jk)
  430. END DO
  431. z_scale(:,:) = - zht(:,:) / ( ht_0(:,:) + sshn(:,:) + 1. - ssmask(:,:) )
  432. DO jk = 1, jpkm1
  433. dtilde_e3t_a(:,:,jk) = dtilde_e3t_a(:,:,jk) + fse3t_n(:,:,jk) * z_scale(:,:) * tmask(:,:,jk)
  434. END DO
  435. ENDIF
  436. IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN ! z_tilde or layer coordinate !
  437. ! ! ---baroclinic part--------- !
  438. DO jk = 1, jpkm1
  439. fse3t_a(:,:,jk) = fse3t_a(:,:,jk) + dtilde_e3t_a(:,:,jk) * tmask(:,:,jk)
  440. END DO
  441. ENDIF
  442. IF( ln_vvl_dbg .AND. .NOT. ll_do_bclinic ) THEN ! - ML - test: control prints for debuging
  443. !
  444. IF( lwp ) WRITE(numout, *) 'kt =', kt
  445. IF ( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
  446. z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( zht(:,:) ) )
  447. IF( lk_mpp ) CALL mpp_max( z_tmax ) ! max over the global domain
  448. IF( lwp ) WRITE(numout, *) kt,' MAXVAL(abs(SUM(tilde_e3t_a))) =', z_tmax
  449. END IF
  450. !
  451. zht(:,:) = 0.0_wp
  452. DO jk = 1, jpkm1
  453. zht(:,:) = zht(:,:) + fse3t_n(:,:,jk) * tmask(:,:,jk)
  454. END DO
  455. z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + sshn(:,:) - zht(:,:) ) )
  456. IF( lk_mpp ) CALL mpp_max( z_tmax ) ! max over the global domain
  457. IF( lwp ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+sshn-SUM(fse3t_n))) =', z_tmax
  458. !
  459. zht(:,:) = 0.0_wp
  460. DO jk = 1, jpkm1
  461. zht(:,:) = zht(:,:) + fse3t_a(:,:,jk) * tmask(:,:,jk)
  462. END DO
  463. z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + ssha(:,:) - zht(:,:) ) )
  464. IF( lk_mpp ) CALL mpp_max( z_tmax ) ! max over the global domain
  465. IF( lwp ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+ssha-SUM(fse3t_a))) =', z_tmax
  466. !
  467. zht(:,:) = 0.0_wp
  468. DO jk = 1, jpkm1
  469. zht(:,:) = zht(:,:) + fse3t_b(:,:,jk) * tmask(:,:,jk)
  470. END DO
  471. z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + sshb(:,:) - zht(:,:) ) )
  472. IF( lk_mpp ) CALL mpp_max( z_tmax ) ! max over the global domain
  473. IF( lwp ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+sshb-SUM(fse3t_b))) =', z_tmax
  474. !
  475. z_tmax = MAXVAL( tmask(:,:,1) * ABS( sshb(:,:) ) )
  476. IF( lk_mpp ) CALL mpp_max( z_tmax ) ! max over the global domain
  477. IF( lwp ) WRITE(numout, *) kt,' MAXVAL(abs(sshb))) =', z_tmax
  478. !
  479. z_tmax = MAXVAL( tmask(:,:,1) * ABS( sshn(:,:) ) )
  480. IF( lk_mpp ) CALL mpp_max( z_tmax ) ! max over the global domain
  481. IF( lwp ) WRITE(numout, *) kt,' MAXVAL(abs(sshn))) =', z_tmax
  482. !
  483. z_tmax = MAXVAL( tmask(:,:,1) * ABS( ssha(:,:) ) )
  484. IF( lk_mpp ) CALL mpp_max( z_tmax ) ! max over the global domain
  485. IF( lwp ) WRITE(numout, *) kt,' MAXVAL(abs(ssha))) =', z_tmax
  486. END IF
  487. ! *********************************** !
  488. ! After scale factors at u- v- points !
  489. ! *********************************** !
  490. CALL dom_vvl_interpol( fse3t_a(:,:,:), fse3u_a(:,:,:), 'U' )
  491. CALL dom_vvl_interpol( fse3t_a(:,:,:), fse3v_a(:,:,:), 'V' )
  492. ! *********************************** !
  493. ! After depths at u- v points !
  494. ! *********************************** !
  495. hu_a(:,:) = 0._wp ! Ocean depth at U-points
  496. hv_a(:,:) = 0._wp ! Ocean depth at V-points
  497. DO jk = 1, jpkm1
  498. hu_a(:,:) = hu_a(:,:) + fse3u_a(:,:,jk) * umask(:,:,jk)
  499. hv_a(:,:) = hv_a(:,:) + fse3v_a(:,:,jk) * vmask(:,:,jk)
  500. END DO
  501. ! ! Inverse of the local depth
  502. hur_a(:,:) = 1._wp / ( hu_a(:,:) + 1._wp - umask_i(:,:) ) * umask_i(:,:)
  503. hvr_a(:,:) = 1._wp / ( hv_a(:,:) + 1._wp - vmask_i(:,:) ) * vmask_i(:,:)
  504. CALL wrk_dealloc( jpi, jpj, zht, z_scale, zwu, zwv, zhdiv )
  505. CALL wrk_dealloc( jpi, jpj, jpk, ze3t )
  506. IF( nn_timing == 1 ) CALL timing_stop('dom_vvl_sf_nxt')
  507. END SUBROUTINE dom_vvl_sf_nxt
  508. SUBROUTINE dom_vvl_sf_swp( kt )
  509. !!----------------------------------------------------------------------
  510. !! *** ROUTINE dom_vvl_sf_swp ***
  511. !!
  512. !! ** Purpose : compute time filter and swap of scale factors
  513. !! compute all depths and related variables for next time step
  514. !! write outputs and restart file
  515. !!
  516. !! ** Method : - swap of e3t with trick for volume/tracer conservation
  517. !! - reconstruct scale factor at other grid points (interpolate)
  518. !! - recompute depths and water height fields
  519. !!
  520. !! ** Action : - fse3t_(b/n), tilde_e3t_(b/n) and fse3(u/v)_n ready for next time step
  521. !! - Recompute:
  522. !! fse3(u/v)_b
  523. !! fse3w_n
  524. !! fse3(u/v)w_b
  525. !! fse3(u/v)w_n
  526. !! fsdept_n, fsdepw_n and fsde3w_n
  527. !! h(u/v) and h(u/v)r
  528. !!
  529. !! Reference : Leclair, M., and G. Madec, 2009, Ocean Modelling.
  530. !! Leclair, M., and G. Madec, 2011, Ocean Modelling.
  531. !!----------------------------------------------------------------------
  532. !! * Arguments
  533. INTEGER, INTENT( in ) :: kt ! time step
  534. !! * Local declarations
  535. INTEGER :: ji,jj,jk ! dummy loop indices
  536. REAL(wp) :: zcoef
  537. !!----------------------------------------------------------------------
  538. IF( nn_timing == 1 ) CALL timing_start('dom_vvl_sf_swp')
  539. !
  540. IF( kt == nit000 ) THEN
  541. IF(lwp) WRITE(numout,*)
  542. IF(lwp) WRITE(numout,*) 'dom_vvl_sf_swp : - time filter and swap of scale factors'
  543. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~ - interpolate scale factors and compute depths for next time step'
  544. ENDIF
  545. !
  546. ! Time filter and swap of scale factors
  547. ! =====================================
  548. ! - ML - fse3(t/u/v)_b are allready computed in dynnxt.
  549. IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
  550. IF( neuler == 0 .AND. kt == nit000 ) THEN
  551. tilde_e3t_b(:,:,:) = tilde_e3t_n(:,:,:)
  552. ELSE
  553. tilde_e3t_b(:,:,:) = tilde_e3t_n(:,:,:) &
  554. & + atfp * ( tilde_e3t_b(:,:,:) - 2.0_wp * tilde_e3t_n(:,:,:) + tilde_e3t_a(:,:,:) )
  555. ENDIF
  556. tilde_e3t_n(:,:,:) = tilde_e3t_a(:,:,:)
  557. ENDIF
  558. fsdept_b(:,:,:) = fsdept_n(:,:,:)
  559. fsdepw_b(:,:,:) = fsdepw_n(:,:,:)
  560. fse3t_n(:,:,:) = fse3t_a(:,:,:)
  561. fse3u_n(:,:,:) = fse3u_a(:,:,:)
  562. fse3v_n(:,:,:) = fse3v_a(:,:,:)
  563. ! Compute all missing vertical scale factor and depths
  564. ! ====================================================
  565. ! Horizontal scale factor interpolations
  566. ! --------------------------------------
  567. ! - ML - fse3u_b and fse3v_b are allready computed in dynnxt
  568. ! - JC - hu_b, hv_b, hur_b, hvr_b also
  569. CALL dom_vvl_interpol( fse3u_n(:,:,:), fse3f_n (:,:,:), 'F' )
  570. ! Vertical scale factor interpolations
  571. ! ------------------------------------
  572. CALL dom_vvl_interpol( fse3t_n(:,:,:), fse3w_n (:,:,:), 'W' )
  573. CALL dom_vvl_interpol( fse3u_n(:,:,:), fse3uw_n(:,:,:), 'UW' )
  574. CALL dom_vvl_interpol( fse3v_n(:,:,:), fse3vw_n(:,:,:), 'VW' )
  575. CALL dom_vvl_interpol( fse3t_b(:,:,:), fse3w_b (:,:,:), 'W' )
  576. CALL dom_vvl_interpol( fse3u_b(:,:,:), fse3uw_b(:,:,:), 'UW' )
  577. CALL dom_vvl_interpol( fse3v_b(:,:,:), fse3vw_b(:,:,:), 'VW' )
  578. ! t- and w- points depth
  579. ! ----------------------
  580. ! set the isf depth as it is in the initial step
  581. fsdept_n(:,:,1) = 0.5_wp * fse3w_n(:,:,1)
  582. fsdepw_n(:,:,1) = 0.0_wp
  583. fsde3w_n(:,:,1) = fsdept_n(:,:,1) - sshn(:,:)
  584. DO jk = 2, jpk
  585. DO jj = 1,jpj
  586. DO ji = 1,jpi
  587. ! zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk)) ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt
  588. ! 1 for jk = mikt
  589. zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk))
  590. fsdepw_n(ji,jj,jk) = fsdepw_n(ji,jj,jk-1) + fse3t_n(ji,jj,jk-1)
  591. fsdept_n(ji,jj,jk) = zcoef * ( fsdepw_n(ji,jj,jk ) + 0.5 * fse3w_n(ji,jj,jk)) &
  592. & + (1-zcoef) * ( fsdept_n(ji,jj,jk-1) + fse3w_n(ji,jj,jk))
  593. fsde3w_n(ji,jj,jk) = fsdept_n(ji,jj,jk) - sshn(ji,jj)
  594. END DO
  595. END DO
  596. END DO
  597. ! Local depth and Inverse of the local depth of the water column at u- and v- points
  598. ! ----------------------------------------------------------------------------------
  599. hu (:,:) = hu_a (:,:)
  600. hv (:,:) = hv_a (:,:)
  601. ! Inverse of the local depth
  602. hur(:,:) = hur_a(:,:)
  603. hvr(:,:) = hvr_a(:,:)
  604. ! Local depth of the water column at t- points
  605. ! --------------------------------------------
  606. ht(:,:) = 0.
  607. DO jk = 1, jpkm1
  608. ht(:,:) = ht(:,:) + fse3t_n(:,:,jk) * tmask(:,:,jk)
  609. END DO
  610. ! write restart file
  611. ! ==================
  612. IF( lrst_oce ) CALL dom_vvl_rst( kt, 'WRITE' )
  613. !
  614. IF( nn_timing == 1 ) CALL timing_stop('dom_vvl_sf_swp')
  615. END SUBROUTINE dom_vvl_sf_swp
  616. SUBROUTINE dom_vvl_interpol( pe3_in, pe3_out, pout )
  617. !!---------------------------------------------------------------------
  618. !! *** ROUTINE dom_vvl__interpol ***
  619. !!
  620. !! ** Purpose : interpolate scale factors from one grid point to another
  621. !!
  622. !! ** Method : e3_out = e3_0 + interpolation(e3_in - e3_0)
  623. !! - horizontal interpolation: grid cell surface averaging
  624. !! - vertical interpolation: simple averaging
  625. !!----------------------------------------------------------------------
  626. !! * Arguments
  627. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) :: pe3_in ! input e3 to be interpolated
  628. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) :: pe3_out ! output interpolated e3
  629. CHARACTER(LEN=*), INTENT( in ) :: pout ! grid point of out scale factors
  630. ! ! = 'U', 'V', 'W, 'F', 'UW' or 'VW'
  631. !! * Local declarations
  632. INTEGER :: ji, jj, jk ! dummy loop indices
  633. LOGICAL :: l_is_orca ! local logical
  634. !!----------------------------------------------------------------------
  635. IF( nn_timing == 1 ) CALL timing_start('dom_vvl_interpol')
  636. !
  637. l_is_orca = .FALSE.
  638. IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) l_is_orca = .TRUE. ! ORCA R2 configuration - will need to correct some locations
  639. SELECT CASE ( pout )
  640. ! ! ------------------------------------- !
  641. CASE( 'U' ) ! interpolation from T-point to U-point !
  642. ! ! ------------------------------------- !
  643. ! horizontal surface weighted interpolation
  644. DO jk = 1, jpk
  645. DO jj = 1, jpjm1
  646. DO ji = 1, fs_jpim1 ! vector opt.
  647. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * r1_e12u(ji,jj) &
  648. & * ( e12t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  649. & + e12t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) )
  650. END DO
  651. END DO
  652. END DO
  653. !
  654. IF( l_is_orca ) CALL dom_vvl_orca_fix( pe3_in, pe3_out, pout )
  655. ! boundary conditions
  656. CALL lbc_lnk( pe3_out(:,:,:), 'U', 1._wp )
  657. pe3_out(:,:,:) = pe3_out(:,:,:) + e3u_0(:,:,:)
  658. ! ! ------------------------------------- !
  659. CASE( 'V' ) ! interpolation from T-point to V-point !
  660. ! ! ------------------------------------- !
  661. ! horizontal surface weighted interpolation
  662. DO jk = 1, jpk
  663. DO jj = 1, jpjm1
  664. DO ji = 1, fs_jpim1 ! vector opt.
  665. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) * r1_e12v(ji,jj) &
  666. & * ( e12t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  667. & + e12t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) )
  668. END DO
  669. END DO
  670. END DO
  671. !
  672. IF( l_is_orca ) CALL dom_vvl_orca_fix( pe3_in, pe3_out, pout )
  673. ! boundary conditions
  674. CALL lbc_lnk( pe3_out(:,:,:), 'V', 1._wp )
  675. pe3_out(:,:,:) = pe3_out(:,:,:) + e3v_0(:,:,:)
  676. ! ! ------------------------------------- !
  677. CASE( 'F' ) ! interpolation from U-point to F-point !
  678. ! ! ------------------------------------- !
  679. ! horizontal surface weighted interpolation
  680. DO jk = 1, jpk
  681. DO jj = 1, jpjm1
  682. DO ji = 1, fs_jpim1 ! vector opt.
  683. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) * r1_e12f(ji,jj) &
  684. & * ( e12u(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3u_0(ji,jj ,jk) ) &
  685. & + e12u(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3u_0(ji,jj+1,jk) ) )
  686. END DO
  687. END DO
  688. END DO
  689. !
  690. IF( l_is_orca ) CALL dom_vvl_orca_fix( pe3_in, pe3_out, pout )
  691. ! boundary conditions
  692. CALL lbc_lnk( pe3_out(:,:,:), 'F', 1._wp )
  693. pe3_out(:,:,:) = pe3_out(:,:,:) + e3f_0(:,:,:)
  694. ! ! ------------------------------------- !
  695. CASE( 'W' ) ! interpolation from T-point to W-point !
  696. ! ! ------------------------------------- !
  697. ! vertical simple interpolation
  698. pe3_out(:,:,1) = e3w_0(:,:,1) + pe3_in(:,:,1) - e3t_0(:,:,1)
  699. ! - ML - The use of mask in this formaula enables the special treatment of the last w- point without indirect adressing
  700. DO jk = 2, jpk
  701. pe3_out(:,:,jk) = e3w_0(:,:,jk) + ( 1.0_wp - 0.5_wp * tmask(:,:,jk) ) * ( pe3_in(:,:,jk-1) - e3t_0(:,:,jk-1) ) &
  702. & + 0.5_wp * tmask(:,:,jk) * ( pe3_in(:,:,jk ) - e3t_0(:,:,jk ) )
  703. END DO
  704. ! ! -------------------------------------- !
  705. CASE( 'UW' ) ! interpolation from U-point to UW-point !
  706. ! ! -------------------------------------- !
  707. ! vertical simple interpolation
  708. pe3_out(:,:,1) = e3uw_0(:,:,1) + pe3_in(:,:,1) - e3u_0(:,:,1)
  709. ! - ML - The use of mask in this formaula enables the special treatment of the last w- point without indirect adressing
  710. DO jk = 2, jpk
  711. pe3_out(:,:,jk) = e3uw_0(:,:,jk) + ( 1.0_wp - 0.5_wp * umask(:,:,jk) ) * ( pe3_in(:,:,jk-1) - e3u_0(:,:,jk-1) ) &
  712. & + 0.5_wp * umask(:,:,jk) * ( pe3_in(:,:,jk ) - e3u_0(:,:,jk ) )
  713. END DO
  714. ! ! -------------------------------------- !
  715. CASE( 'VW' ) ! interpolation from V-point to VW-point !
  716. ! ! -------------------------------------- !
  717. ! vertical simple interpolation
  718. pe3_out(:,:,1) = e3vw_0(:,:,1) + pe3_in(:,:,1) - e3v_0(:,:,1)
  719. ! - ML - The use of mask in this formaula enables the special treatment of the last w- point without indirect adressing
  720. DO jk = 2, jpk
  721. pe3_out(:,:,jk) = e3vw_0(:,:,jk) + ( 1.0_wp - 0.5_wp * vmask(:,:,jk) ) * ( pe3_in(:,:,jk-1) - e3v_0(:,:,jk-1) ) &
  722. & + 0.5_wp * vmask(:,:,jk) * ( pe3_in(:,:,jk ) - e3v_0(:,:,jk ) )
  723. END DO
  724. END SELECT
  725. !
  726. IF( nn_timing == 1 ) CALL timing_stop('dom_vvl_interpol')
  727. END SUBROUTINE dom_vvl_interpol
  728. SUBROUTINE dom_vvl_rst( kt, cdrw )
  729. !!---------------------------------------------------------------------
  730. !! *** ROUTINE dom_vvl_rst ***
  731. !!
  732. !! ** Purpose : Read or write VVL file in restart file
  733. !!
  734. !! ** Method : use of IOM library
  735. !! if the restart does not contain vertical scale factors,
  736. !! they are set to the _0 values
  737. !! if the restart does not contain vertical scale factors increments (z_tilde),
  738. !! they are set to 0.
  739. !!----------------------------------------------------------------------
  740. !! * Arguments
  741. INTEGER , INTENT(in) :: kt ! ocean time-step
  742. CHARACTER(len=*), INTENT(in) :: cdrw ! "READ"/"WRITE" flag
  743. !! * Local declarations
  744. INTEGER :: jk
  745. INTEGER :: id1, id2, id3, id4, id5 ! local integers
  746. !!----------------------------------------------------------------------
  747. !
  748. IF( nn_timing == 1 ) CALL timing_start('dom_vvl_rst')
  749. IF( TRIM(cdrw) == 'READ' ) THEN ! Read/initialise
  750. ! ! ===============
  751. IF( ln_rstart ) THEN !* Read the restart file
  752. CALL rst_read_open ! open the restart file if necessary
  753. CALL iom_get( numror, jpdom_autoglo, 'sshn' , sshn )
  754. !
  755. id1 = iom_varid( numror, 'fse3t_b', ldstop = .FALSE. )
  756. id2 = iom_varid( numror, 'fse3t_n', ldstop = .FALSE. )
  757. id3 = iom_varid( numror, 'tilde_e3t_b', ldstop = .FALSE. )
  758. id4 = iom_varid( numror, 'tilde_e3t_n', ldstop = .FALSE. )
  759. id5 = iom_varid( numror, 'hdiv_lf', ldstop = .FALSE. )
  760. ! ! --------- !
  761. ! ! all cases !
  762. ! ! --------- !
  763. IF( MIN( id1, id2 ) > 0 ) THEN ! all required arrays exist
  764. CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) )
  765. CALL iom_get( numror, jpdom_autoglo, 'fse3t_n', fse3t_n(:,:,:) )
  766. ! needed to restart if land processor not computed
  767. IF(lwp) write(numout,*) 'dom_vvl_rst : fse3t_b and fse3t_n found in restart files'
  768. WHERE ( tmask(:,:,:) == 0.0_wp )
  769. fse3t_n(:,:,:) = e3t_0(:,:,:)
  770. fse3t_b(:,:,:) = e3t_0(:,:,:)
  771. END WHERE
  772. IF( neuler == 0 ) THEN
  773. fse3t_b(:,:,:) = fse3t_n(:,:,:)
  774. ENDIF
  775. ELSE IF( id1 > 0 ) THEN
  776. IF(lwp) write(numout,*) 'dom_vvl_rst WARNING : fse3t_n not found in restart files'
  777. IF(lwp) write(numout,*) 'fse3t_n set equal to fse3t_b.'
  778. IF(lwp) write(numout,*) 'neuler is forced to 0'
  779. CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) )
  780. fse3t_n(:,:,:) = fse3t_b(:,:,:)
  781. neuler = 0
  782. ELSE IF( id2 > 0 ) THEN
  783. IF(lwp) write(numout,*) 'dom_vvl_rst WARNING : fse3t_b not found in restart files'
  784. IF(lwp) write(numout,*) 'fse3t_b set equal to fse3t_n.'
  785. IF(lwp) write(numout,*) 'neuler is forced to 0'
  786. CALL iom_get( numror, jpdom_autoglo, 'fse3t_n', fse3t_n(:,:,:) )
  787. fse3t_b(:,:,:) = fse3t_n(:,:,:)
  788. neuler = 0
  789. ELSE
  790. IF(lwp) write(numout,*) 'dom_vvl_rst WARNING : fse3t_n not found in restart file'
  791. IF(lwp) write(numout,*) 'Compute scale factor from sshn'
  792. IF(lwp) write(numout,*) 'neuler is forced to 0'
  793. DO jk=1,jpk
  794. fse3t_n(:,:,jk) = e3t_0(:,:,jk) * ( ht_0(:,:) + sshn(:,:) ) &
  795. & / ( ht_0(:,:) + 1._wp - ssmask(:,:) ) * tmask(:,:,jk) &
  796. & + e3t_0(:,:,jk) * (1._wp -tmask(:,:,jk))
  797. END DO
  798. fse3t_b(:,:,:) = fse3t_n(:,:,:)
  799. neuler = 0
  800. ENDIF
  801. ! ! ----------- !
  802. IF( ln_vvl_zstar ) THEN ! z_star case !
  803. ! ! ----------- !
  804. IF( MIN( id3, id4 ) > 0 ) THEN
  805. CALL ctl_stop( 'dom_vvl_rst: z_star cannot restart from a z_tilde or layer run' )
  806. ENDIF
  807. ! ! ----------------------- !
  808. ELSE ! z_tilde and layer cases !
  809. ! ! ----------------------- !
  810. IF( MIN( id3, id4 ) > 0 ) THEN ! all required arrays exist
  811. CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
  812. CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
  813. ELSE ! one at least array is missing
  814. tilde_e3t_b(:,:,:) = 0.0_wp
  815. tilde_e3t_n(:,:,:) = 0.0_wp
  816. ENDIF
  817. ! ! ------------ !
  818. IF( ln_vvl_ztilde ) THEN ! z_tilde case !
  819. ! ! ------------ !
  820. IF( id5 > 0 ) THEN ! required array exists
  821. CALL iom_get( numror, jpdom_autoglo, 'hdiv_lf', hdiv_lf(:,:,:) )
  822. ELSE ! array is missing
  823. hdiv_lf(:,:,:) = 0.0_wp
  824. ENDIF
  825. ENDIF
  826. ENDIF
  827. !
  828. ELSE !* Initialize at "rest"
  829. fse3t_b(:,:,:) = e3t_0(:,:,:)
  830. fse3t_n(:,:,:) = e3t_0(:,:,:)
  831. sshn(:,:) = 0.0_wp
  832. IF( ln_vvl_ztilde .OR. ln_vvl_layer) THEN
  833. tilde_e3t_b(:,:,:) = 0.0_wp
  834. tilde_e3t_n(:,:,:) = 0.0_wp
  835. IF( ln_vvl_ztilde ) hdiv_lf(:,:,:) = 0.0_wp
  836. END IF
  837. ENDIF
  838. ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN ! Create restart file
  839. ! ! ===================
  840. IF(lwp) WRITE(numout,*) '---- dom_vvl_rst ----'
  841. ! ! --------- !
  842. ! ! all cases !
  843. ! ! --------- !
  844. CALL iom_rstput( kt, nitrst, numrow, 'fse3t_b', fse3t_b(:,:,:) )
  845. CALL iom_rstput( kt, nitrst, numrow, 'fse3t_n', fse3t_n(:,:,:) )
  846. ! ! ----------------------- !
  847. IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN ! z_tilde and layer cases !
  848. ! ! ----------------------- !
  849. CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
  850. CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
  851. END IF
  852. ! ! -------------!
  853. IF( ln_vvl_ztilde ) THEN ! z_tilde case !
  854. ! ! ------------ !
  855. CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:) )
  856. ENDIF
  857. ENDIF
  858. IF( nn_timing == 1 ) CALL timing_stop('dom_vvl_rst')
  859. END SUBROUTINE dom_vvl_rst
  860. SUBROUTINE dom_vvl_ctl
  861. !!---------------------------------------------------------------------
  862. !! *** ROUTINE dom_vvl_ctl ***
  863. !!
  864. !! ** Purpose : Control the consistency between namelist options
  865. !! for vertical coordinate
  866. !!----------------------------------------------------------------------
  867. INTEGER :: ioptio
  868. INTEGER :: ios
  869. NAMELIST/nam_vvl/ ln_vvl_zstar, ln_vvl_ztilde, ln_vvl_layer, ln_vvl_ztilde_as_zstar, &
  870. & ln_vvl_zstar_at_eqtor , rn_ahe3 , rn_rst_e3t , &
  871. & rn_lf_cutoff , rn_zdef_max , ln_vvl_dbg ! not yet implemented: ln_vvl_kepe
  872. !!----------------------------------------------------------------------
  873. REWIND( numnam_ref ) ! Namelist nam_vvl in reference namelist :
  874. READ ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
  875. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_vvl in reference namelist', lwp )
  876. REWIND( numnam_cfg ) ! Namelist nam_vvl in configuration namelist : Parameters of the run
  877. READ ( numnam_cfg, nam_vvl, IOSTAT = ios, ERR = 902 )
  878. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist', lwp )
  879. IF(lwm) WRITE ( numond, nam_vvl )
  880. IF(lwp) THEN ! Namelist print
  881. WRITE(numout,*)
  882. WRITE(numout,*) 'dom_vvl_ctl : choice/control of the variable vertical coordinate'
  883. WRITE(numout,*) '~~~~~~~~~~~'
  884. WRITE(numout,*) ' Namelist nam_vvl : chose a vertical coordinate'
  885. WRITE(numout,*) ' zstar ln_vvl_zstar = ', ln_vvl_zstar
  886. WRITE(numout,*) ' ztilde ln_vvl_ztilde = ', ln_vvl_ztilde
  887. WRITE(numout,*) ' layer ln_vvl_layer = ', ln_vvl_layer
  888. WRITE(numout,*) ' ztilde as zstar ln_vvl_ztilde_as_zstar = ', ln_vvl_ztilde_as_zstar
  889. WRITE(numout,*) ' ztilde near the equator ln_vvl_zstar_at_eqtor = ', ln_vvl_zstar_at_eqtor
  890. ! WRITE(numout,*) ' Namelist nam_vvl : chose kinetic-to-potential energy conservation'
  891. ! WRITE(numout,*) ' ln_vvl_kepe = ', ln_vvl_kepe
  892. WRITE(numout,*) ' Namelist nam_vvl : thickness diffusion coefficient'
  893. WRITE(numout,*) ' rn_ahe3 = ', rn_ahe3
  894. WRITE(numout,*) ' Namelist nam_vvl : maximum e3t deformation fractional change'
  895. WRITE(numout,*) ' rn_zdef_max = ', rn_zdef_max
  896. IF( ln_vvl_ztilde_as_zstar ) THEN
  897. WRITE(numout,*) ' ztilde running in zstar emulation mode; '
  898. WRITE(numout,*) ' ignoring namelist timescale parameters and using:'
  899. WRITE(numout,*) ' hard-wired : z-tilde to zstar restoration timescale (days)'
  900. WRITE(numout,*) ' rn_rst_e3t = 0.0'
  901. WRITE(numout,*) ' hard-wired : z-tilde cutoff frequency of low-pass filter (days)'
  902. WRITE(numout,*) ' rn_lf_cutoff = 1.0/rdt'
  903. ELSE
  904. WRITE(numout,*) ' Namelist nam_vvl : z-tilde to zstar restoration timescale (days)'
  905. WRITE(numout,*) ' rn_rst_e3t = ', rn_rst_e3t
  906. WRITE(numout,*) ' Namelist nam_vvl : z-tilde cutoff frequency of low-pass filter (days)'
  907. WRITE(numout,*) ' rn_lf_cutoff = ', rn_lf_cutoff
  908. ENDIF
  909. WRITE(numout,*) ' Namelist nam_vvl : debug prints'
  910. WRITE(numout,*) ' ln_vvl_dbg = ', ln_vvl_dbg
  911. ENDIF
  912. ioptio = 0 ! Parameter control
  913. IF( ln_vvl_ztilde_as_zstar ) ln_vvl_ztilde = .true.
  914. IF( ln_vvl_zstar ) ioptio = ioptio + 1
  915. IF( ln_vvl_ztilde ) ioptio = ioptio + 1
  916. IF( ln_vvl_layer ) ioptio = ioptio + 1
  917. IF( ioptio /= 1 ) CALL ctl_stop( 'Choose ONE vertical coordinate in namelist nam_vvl' )
  918. IF( .NOT. ln_vvl_zstar .AND. nn_isf .NE. 0) CALL ctl_stop( 'Only vvl_zstar has been tested with ice shelf cavity' )
  919. IF(lwp) THEN ! Print the choice
  920. WRITE(numout,*)
  921. IF( ln_vvl_zstar ) WRITE(numout,*) ' zstar vertical coordinate is used'
  922. IF( ln_vvl_ztilde ) WRITE(numout,*) ' ztilde vertical coordinate is used'
  923. IF( ln_vvl_layer ) WRITE(numout,*) ' layer vertical coordinate is used'
  924. IF( ln_vvl_ztilde_as_zstar ) WRITE(numout,*) ' to emulate a zstar coordinate'
  925. ! - ML - Option not developed yet
  926. ! IF( ln_vvl_kepe ) WRITE(numout,*) ' kinetic to potential energy transfer : option used'
  927. ! IF( .NOT. ln_vvl_kepe ) WRITE(numout,*) ' kinetic to potential energy transfer : option not used'
  928. ENDIF
  929. #if defined key_agrif
  930. IF (.NOT.Agrif_Root()) CALL ctl_stop( 'AGRIF not implemented with non-linear free surface (key_vvl)' )
  931. #endif
  932. END SUBROUTINE dom_vvl_ctl
  933. SUBROUTINE dom_vvl_orca_fix( pe3_in, pe3_out, pout )
  934. !!---------------------------------------------------------------------
  935. !! *** ROUTINE dom_vvl_orca_fix ***
  936. !!
  937. !! ** Purpose : Correct surface weighted, horizontally interpolated,
  938. !! scale factors at locations that have been individually
  939. !! modified in domhgr. Such modifications break the
  940. !! relationship between e12t and e1u*e2u etc.
  941. !! Recompute some scale factors ignoring the modified metric.
  942. !!----------------------------------------------------------------------
  943. !! * Arguments
  944. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) :: pe3_in ! input e3 to be interpolated
  945. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) :: pe3_out ! output interpolated e3
  946. CHARACTER(LEN=*), INTENT( in ) :: pout ! grid point of out scale factors
  947. ! ! = 'U', 'V', 'W, 'F', 'UW' or 'VW'
  948. !! * Local declarations
  949. INTEGER :: ji, jj, jk ! dummy loop indices
  950. INTEGER :: ij0, ij1, ii0, ii1 ! dummy loop indices
  951. INTEGER :: isrow ! index for ORCA1 starting row
  952. !! acc
  953. !! Hmm with the time splitting these "fixes" seem to do more harm than good. Temporarily disabled for
  954. !! the ORCA2 tests (by changing jp_cfg test from 2 to 3) pending further investigations
  955. !!
  956. ! ! =====================
  957. IF( cp_cfg == "orca" .AND. jp_cfg == 3 ) THEN ! ORCA R2 configuration
  958. ! ! =====================
  959. !! acc
  960. IF( nn_cla == 0 ) THEN
  961. !
  962. ii0 = 139 ; ii1 = 140 ! Gibraltar Strait (e2u was modified)
  963. ij0 = 102 ; ij1 = 102
  964. DO jk = 1, jpkm1
  965. DO jj = mj0(ij0), mj1(ij1)
  966. DO ji = mi0(ii0), mi1(ii1)
  967. SELECT CASE ( pout )
  968. CASE( 'U' )
  969. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  970. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  971. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  972. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  973. CASE( 'F' )
  974. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  975. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  976. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  977. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  978. END SELECT
  979. END DO
  980. END DO
  981. END DO
  982. !
  983. ii0 = 160 ; ii1 = 160 ! Bab el Mandeb (e2u and e1v were modified)
  984. ij0 = 88 ; ij1 = 88
  985. DO jk = 1, jpkm1
  986. DO jj = mj0(ij0), mj1(ij1)
  987. DO ji = mi0(ii0), mi1(ii1)
  988. SELECT CASE ( pout )
  989. CASE( 'U' )
  990. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  991. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  992. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  993. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  994. CASE( 'V' )
  995. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  996. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  997. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  998. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  999. CASE( 'F' )
  1000. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1001. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1002. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1003. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1004. END SELECT
  1005. END DO
  1006. END DO
  1007. END DO
  1008. ENDIF
  1009. ii0 = 145 ; ii1 = 146 ! Danish Straits (e2u was modified)
  1010. ij0 = 116 ; ij1 = 116
  1011. DO jk = 1, jpkm1
  1012. DO jj = mj0(ij0), mj1(ij1)
  1013. DO ji = mi0(ii0), mi1(ii1)
  1014. SELECT CASE ( pout )
  1015. CASE( 'U' )
  1016. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  1017. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  1018. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  1019. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  1020. CASE( 'F' )
  1021. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1022. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1023. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1024. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1025. END SELECT
  1026. END DO
  1027. END DO
  1028. END DO
  1029. ENDIF
  1030. !
  1031. ! ! =====================
  1032. IF( cp_cfg == "orca" .AND. jp_cfg == 1 ) THEN ! ORCA R1 configuration
  1033. ! ! =====================
  1034. ! This dirty section will be suppressed by simplification process:
  1035. ! all this will come back in input files
  1036. ! Currently these hard-wired indices relate to configuration with
  1037. ! extend grid (jpjglo=332)
  1038. ! which had a grid-size of 362x292.
  1039. isrow = 332 - jpjglo
  1040. !
  1041. ii0 = 282 ; ii1 = 283 ! Gibraltar Strait (e2u was modified)
  1042. ij0 = 241 - isrow ; ij1 = 241 - isrow
  1043. DO jk = 1, jpkm1
  1044. DO jj = mj0(ij0), mj1(ij1)
  1045. DO ji = mi0(ii0), mi1(ii1)
  1046. SELECT CASE ( pout )
  1047. CASE( 'U' )
  1048. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  1049. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  1050. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  1051. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  1052. CASE( 'F' )
  1053. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1054. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1055. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1056. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1057. END SELECT
  1058. END DO
  1059. END DO
  1060. END DO
  1061. !
  1062. ii0 = 314 ; ii1 = 315 ! Bhosporus Strait (e2u was modified)
  1063. ij0 = 248 - isrow ; ij1 = 248 - isrow
  1064. DO jk = 1, jpkm1
  1065. DO jj = mj0(ij0), mj1(ij1)
  1066. DO ji = mi0(ii0), mi1(ii1)
  1067. SELECT CASE ( pout )
  1068. CASE( 'U' )
  1069. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  1070. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  1071. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  1072. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  1073. CASE( 'F' )
  1074. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1075. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1076. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1077. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1078. END SELECT
  1079. END DO
  1080. END DO
  1081. END DO
  1082. !
  1083. ii0 = 44 ; ii1 = 44 ! Lombok Strait (e1v was modified)
  1084. ij0 = 164 - isrow ; ij1 = 165 - isrow
  1085. DO jk = 1, jpkm1
  1086. DO jj = mj0(ij0), mj1(ij1)
  1087. DO ji = mi0(ii0), mi1(ii1)
  1088. SELECT CASE ( pout )
  1089. CASE( 'V' )
  1090. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  1091. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  1092. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  1093. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  1094. END SELECT
  1095. END DO
  1096. END DO
  1097. END DO
  1098. !
  1099. ii0 = 48 ; ii1 = 48 ! Sumba Strait (e1v was modified) [closed from bathy_11 on]
  1100. ij0 = 164 - isrow ; ij1 = 165 - isrow
  1101. DO jk = 1, jpkm1
  1102. DO jj = mj0(ij0), mj1(ij1)
  1103. DO ji = mi0(ii0), mi1(ii1)
  1104. SELECT CASE ( pout )
  1105. CASE( 'V' )
  1106. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  1107. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  1108. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  1109. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  1110. END SELECT
  1111. END DO
  1112. END DO
  1113. END DO
  1114. !
  1115. ii0 = 53 ; ii1 = 53 ! Ombai Strait (e1v was modified)
  1116. ij0 = 164 - isrow ; ij1 = 165 - isrow
  1117. DO jk = 1, jpkm1
  1118. DO jj = mj0(ij0), mj1(ij1)
  1119. DO ji = mi0(ii0), mi1(ii1)
  1120. SELECT CASE ( pout )
  1121. CASE( 'V' )
  1122. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  1123. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  1124. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  1125. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  1126. END SELECT
  1127. END DO
  1128. END DO
  1129. END DO
  1130. !
  1131. ii0 = 56 ; ii1 = 56 ! Timor Passage (e1v was modified)
  1132. ij0 = 164 - isrow ; ij1 = 165 - isrow
  1133. DO jk = 1, jpkm1
  1134. DO jj = mj0(ij0), mj1(ij1)
  1135. DO ji = mi0(ii0), mi1(ii1)
  1136. SELECT CASE ( pout )
  1137. CASE( 'V' )
  1138. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  1139. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  1140. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  1141. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  1142. END SELECT
  1143. END DO
  1144. END DO
  1145. END DO
  1146. !
  1147. ii0 = 55 ; ii1 = 55 ! West Halmahera Strait (e1v was modified)
  1148. ij0 = 181 - isrow ; ij1 = 182 - isrow
  1149. DO jk = 1, jpkm1
  1150. DO jj = mj0(ij0), mj1(ij1)
  1151. DO ji = mi0(ii0), mi1(ii1)
  1152. SELECT CASE ( pout )
  1153. CASE( 'V' )
  1154. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  1155. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  1156. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  1157. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  1158. END SELECT
  1159. END DO
  1160. END DO
  1161. END DO
  1162. !
  1163. ii0 = 58 ; ii1 = 58 ! East Halmahera Strait (e1v was modified)
  1164. ij0 = 181 - isrow ; ij1 = 182 - isrow
  1165. DO jk = 1, jpkm1
  1166. DO jj = mj0(ij0), mj1(ij1)
  1167. DO ji = mi0(ii0), mi1(ii1)
  1168. SELECT CASE ( pout )
  1169. CASE( 'V' )
  1170. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  1171. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  1172. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  1173. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  1174. END SELECT
  1175. END DO
  1176. END DO
  1177. END DO
  1178. ENDIF
  1179. ! ! =====================
  1180. IF( cp_cfg == "orca" .AND. jp_cfg == 05 ) THEN ! ORCA R05 configuration
  1181. ! ! =====================
  1182. !
  1183. ii0 = 563 ; ii1 = 564 ! Gibraltar Strait (e2u was modified)
  1184. ij0 = 327 ; ij1 = 327
  1185. DO jk = 1, jpkm1
  1186. DO jj = mj0(ij0), mj1(ij1)
  1187. DO ji = mi0(ii0), mi1(ii1)
  1188. SELECT CASE ( pout )
  1189. CASE( 'U' )
  1190. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  1191. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  1192. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  1193. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  1194. CASE( 'F' )
  1195. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1196. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1197. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1198. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1199. END SELECT
  1200. END DO
  1201. END DO
  1202. END DO
  1203. !
  1204. ii0 = 627 ; ii1 = 628 ! Bosphorus Strait (e2u was modified)
  1205. ij0 = 343 ; ij1 = 343
  1206. DO jk = 1, jpkm1
  1207. DO jj = mj0(ij0), mj1(ij1)
  1208. DO ji = mi0(ii0), mi1(ii1)
  1209. SELECT CASE ( pout )
  1210. CASE( 'U' )
  1211. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  1212. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  1213. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  1214. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  1215. CASE( 'F' )
  1216. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1217. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1218. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1219. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1220. END SELECT
  1221. END DO
  1222. END DO
  1223. END DO
  1224. !
  1225. ii0 = 93 ; ii1 = 94 ! Sumba Strait (e2u was modified)
  1226. ij0 = 232 ; ij1 = 232
  1227. DO jk = 1, jpkm1
  1228. DO jj = mj0(ij0), mj1(ij1)
  1229. DO ji = mi0(ii0), mi1(ii1)
  1230. SELECT CASE ( pout )
  1231. CASE( 'U' )
  1232. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  1233. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  1234. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  1235. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  1236. CASE( 'F' )
  1237. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1238. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1239. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1240. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1241. END SELECT
  1242. END DO
  1243. END DO
  1244. END DO
  1245. !
  1246. ii0 = 103 ; ii1 = 103 ! Ombai Strait (e2u was modified)
  1247. ij0 = 232 ; ij1 = 232
  1248. DO jk = 1, jpkm1
  1249. DO jj = mj0(ij0), mj1(ij1)
  1250. DO ji = mi0(ii0), mi1(ii1)
  1251. SELECT CASE ( pout )
  1252. CASE( 'U' )
  1253. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  1254. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  1255. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  1256. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  1257. CASE( 'F' )
  1258. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1259. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1260. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1261. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1262. END SELECT
  1263. END DO
  1264. END DO
  1265. END DO
  1266. !
  1267. ii0 = 15 ; ii1 = 15 ! Palk Strait (e2u was modified)
  1268. ij0 = 270 ; ij1 = 270
  1269. DO jk = 1, jpkm1
  1270. DO jj = mj0(ij0), mj1(ij1)
  1271. DO ji = mi0(ii0), mi1(ii1)
  1272. SELECT CASE ( pout )
  1273. CASE( 'U' )
  1274. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) &
  1275. & * ( e1t(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3t_0(ji ,jj,jk) ) &
  1276. & + e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
  1277. & ) / e1u(ji,jj) + e3u_0(ji,jj,jk)
  1278. CASE( 'F' )
  1279. pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) &
  1280. & * ( e1u(ji ,jj) * ( pe3_in(ji ,jj,jk) - e3u_0(ji ,jj,jk) ) &
  1281. & + e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
  1282. & ) / e1f(ji,jj) + e3f_0(ji,jj,jk)
  1283. END SELECT
  1284. END DO
  1285. END DO
  1286. END DO
  1287. !
  1288. ii0 = 87 ; ii1 = 87 ! Lombok Strait (e1v was modified)
  1289. ij0 = 232 ; ij1 = 233
  1290. DO jk = 1, jpkm1
  1291. DO jj = mj0(ij0), mj1(ij1)
  1292. DO ji = mi0(ii0), mi1(ii1)
  1293. SELECT CASE ( pout )
  1294. CASE( 'V' )
  1295. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  1296. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  1297. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  1298. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  1299. END SELECT
  1300. END DO
  1301. END DO
  1302. END DO
  1303. !
  1304. ii0 = 662 ; ii1 = 662 ! Bab el Mandeb (e1v was modified)
  1305. ij0 = 276 ; ij1 = 276
  1306. DO jk = 1, jpkm1
  1307. DO jj = mj0(ij0), mj1(ij1)
  1308. DO ji = mi0(ii0), mi1(ii1)
  1309. SELECT CASE ( pout )
  1310. CASE( 'V' )
  1311. pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) &
  1312. & * ( e2t(ji,jj ) * ( pe3_in(ji,jj ,jk) - e3t_0(ji,jj ,jk) ) &
  1313. & + e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
  1314. & ) / e2v(ji,jj) + e3v_0(ji,jj,jk)
  1315. END SELECT
  1316. END DO
  1317. END DO
  1318. END DO
  1319. ENDIF
  1320. END SUBROUTINE dom_vvl_orca_fix
  1321. !!======================================================================
  1322. END MODULE domvvl