limadv_2.F90 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. MODULE limadv_2
  2. !!======================================================================
  3. !! *** MODULE limadv_2 ***
  4. !! LIM 2.0 sea-ice model : sea-ice advection
  5. !!======================================================================
  6. !! History : OPA ! 2000-01 (LIM) Original code
  7. !! ! 2001-05 (G. Madec, R. Hordoir) Doctor norm
  8. !! NEMO 1.0 ! 2003-10 (C. Ethe) F90, module
  9. !! - ! 2003-12 (R. Hordoir, G. Madec) mpp
  10. !! 3.2 ! 2009-06 (F. Dupont) correct a error in the North fold b. c.
  11. !!--------------------------------------------------------------------
  12. #if defined key_lim2
  13. !!----------------------------------------------------------------------
  14. !! 'key_lim2' LIM 2.0 sea-ice model
  15. !!----------------------------------------------------------------------
  16. !! lim_adv_x_2 : advection of sea ice on x axis
  17. !! lim_adv_y_2 : advection of sea ice on y axis
  18. !!----------------------------------------------------------------------
  19. USE dom_oce
  20. USE dom_ice_2
  21. USE ice_2
  22. USE lbclnk
  23. USE in_out_manager ! I/O manager
  24. USE lib_mpp ! MPP library
  25. USE wrk_nemo ! work arrays
  26. USE prtctl ! Print control
  27. USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
  28. IMPLICIT NONE
  29. PRIVATE
  30. PUBLIC lim_adv_x_2 ! called by lim_trp
  31. PUBLIC lim_adv_y_2 ! called by lim_trp
  32. REAL(wp) :: epsi20 = 1.e-20 ! constant values
  33. REAL(wp) :: rzero = 0.e0 ! - -
  34. REAL(wp) :: rone = 1.e0 ! - -
  35. !! * Substitutions
  36. # include "vectopt_loop_substitute.h90"
  37. !!----------------------------------------------------------------------
  38. !! NEMO/LIM2 3.3 , UCL - NEMO Consortium (2010)
  39. !! $Id: limadv_2.F90 3625 2012-11-21 13:19:18Z acc $
  40. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  41. !!----------------------------------------------------------------------
  42. CONTAINS
  43. SUBROUTINE lim_adv_x_2( pdf, put , pcrh, psm , ps0 , &
  44. & psx, psxx, psy , psyy, psxy )
  45. !!---------------------------------------------------------------------
  46. !! ** routine lim_adv_x_2 **
  47. !!
  48. !! ** purpose : Computes and adds the advection trend to sea-ice
  49. !! variable on i-axis
  50. !!
  51. !! ** method : Uses Prather second order scheme that advects tracers
  52. !! but also theirquadratic forms. The method preserves
  53. !! tracer structures by conserving second order moments.
  54. !!
  55. !! Reference: Prather, 1986, JGR, 91, D6. 6671-6681.
  56. !!--------------------------------------------------------------------
  57. REAL(wp) , INTENT(in ) :: pdf ! reduction factor for the time step
  58. REAL(wp) , INTENT(in ) :: pcrh ! call lim_adv_x then lim_adv_y (=1) or the opposite (=0)
  59. REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: put ! i-direction ice velocity at U-point [m/s]
  60. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: psm ! area
  61. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: ps0 ! field to be advected
  62. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: psx , psy ! 1st moments
  63. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: psxx, psyy, psxy ! 2nd moments
  64. !
  65. INTEGER :: ji, jj ! dummy loop indices
  66. REAL(wp) :: zs1max, zrdt, zslpmax, ztemp, zin0 ! temporary scalars
  67. REAL(wp) :: zs1new, zalf , zalfq , zbt ! - -
  68. REAL(wp) :: zs2new, zalf1, zalf1q, zbt1 ! - -
  69. REAL(wp), DIMENSION(:,:), POINTER :: zf0, zfx , zfy , zbet ! 2D workspace
  70. REAL(wp), DIMENSION(:,:), POINTER :: zfm, zfxx, zfyy, zfxy ! - -
  71. REAL(wp), DIMENSION(:,:), POINTER :: zalg, zalg1, zalg1q ! - -
  72. !---------------------------------------------------------------------
  73. CALL wrk_alloc( jpi, jpj, zf0 , zfx , zfy , zbet, zfm )
  74. CALL wrk_alloc( jpi, jpj, zfxx, zfyy, zfxy, zalg, zalg1, zalg1q )
  75. ! Limitation of moments.
  76. zrdt = rdt_ice * pdf ! If ice drift field is too fast, use an appropriate time step for advection.
  77. DO jj = 1, jpj
  78. DO ji = 1, jpi
  79. zslpmax = MAX( rzero, ps0(ji,jj) )
  80. zs1max = 1.5 * zslpmax
  81. zs1new = MIN( zs1max, MAX( -zs1max, psx(ji,jj) ) )
  82. zs2new = MIN( 2.0 * zslpmax - 0.3334 * ABS( zs1new ), &
  83. & MAX( ABS( zs1new ) - zslpmax, psxx(ji,jj) ) )
  84. zin0 = ( 1.0 - MAX( rzero, sign ( rone, -zslpmax) ) ) * tms(ji,jj) ! Case of empty boxes & Apply mask
  85. !
  86. ps0 (ji,jj) = zslpmax
  87. psx (ji,jj) = zs1new * zin0
  88. psxx(ji,jj) = zs2new * zin0
  89. psy (ji,jj) = psy (ji,jj) * zin0
  90. psyy(ji,jj) = psyy(ji,jj) * zin0
  91. psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * zin0
  92. END DO
  93. END DO
  94. ! Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
  95. psm (:,:) = MAX( pcrh * area(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
  96. ! Calculate fluxes and moments between boxes i<-->i+1
  97. DO jj = 1, jpj ! Flux from i to i+1 WHEN u GT 0
  98. DO ji = 1, jpi
  99. zbet(ji,jj) = MAX( rzero, SIGN( rone, put(ji,jj) ) )
  100. zalf = MAX( rzero, put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji,jj)
  101. zalfq = zalf * zalf
  102. zalf1 = 1.0 - zalf
  103. zalf1q = zalf1 * zalf1
  104. !
  105. zfm (ji,jj) = zalf * psm(ji,jj)
  106. zf0 (ji,jj) = zalf * ( ps0(ji,jj) + zalf1 * ( psx(ji,jj) + (zalf1 - zalf) * psxx(ji,jj) ) )
  107. zfx (ji,jj) = zalfq * ( psx(ji,jj) + 3.0 * zalf1 * psxx(ji,jj) )
  108. zfxx(ji,jj) = zalf * zalfq * psxx(ji,jj)
  109. zfy (ji,jj) = zalf * ( psy(ji,jj) + zalf1 * psxy(ji,jj) )
  110. zfxy(ji,jj) = zalfq * psxy(ji,jj)
  111. zfyy(ji,jj) = zalf * psyy(ji,jj)
  112. !
  113. ! Readjust moments remaining in the box.
  114. psm (ji,jj) = psm (ji,jj) - zfm(ji,jj)
  115. ps0 (ji,jj) = ps0 (ji,jj) - zf0(ji,jj)
  116. psx (ji,jj) = zalf1q * ( psx(ji,jj) - 3.0 * zalf * psxx(ji,jj) )
  117. psxx(ji,jj) = zalf1 * zalf1q * psxx(ji,jj)
  118. psy (ji,jj) = psy (ji,jj) - zfy(ji,jj)
  119. psyy(ji,jj) = psyy(ji,jj) - zfyy(ji,jj)
  120. psxy(ji,jj) = zalf1q * psxy(ji,jj)
  121. END DO
  122. END DO
  123. DO jj = 1, jpjm1 ! Flux from i+1 to i when u LT 0.
  124. DO ji = 1, fs_jpim1
  125. zalf = MAX( rzero, -put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji+1,jj)
  126. zalg (ji,jj) = zalf
  127. zalfq = zalf * zalf
  128. zalf1 = 1.0 - zalf
  129. zalg1 (ji,jj) = zalf1
  130. zalf1q = zalf1 * zalf1
  131. zalg1q(ji,jj) = zalf1q
  132. zfm (ji,jj) = zfm (ji,jj) + zalf * psm(ji+1,jj)
  133. zf0 (ji,jj) = zf0 (ji,jj) + zalf * ( ps0(ji+1,jj) - zalf1 * ( psx(ji+1,jj) - (zalf1 - zalf ) * psxx(ji+1,jj) ) )
  134. zfx (ji,jj) = zfx (ji,jj) + zalfq * ( psx(ji+1,jj) - 3.0 * zalf1 * psxx(ji+1,jj) )
  135. zfxx (ji,jj) = zfxx(ji,jj) + zalf * zalfq * psxx(ji+1,jj)
  136. zfy (ji,jj) = zfy (ji,jj) + zalf * ( psy(ji+1,jj) - zalf1 * psxy(ji+1,jj) )
  137. zfxy (ji,jj) = zfxy(ji,jj) + zalfq * psxy(ji+1,jj)
  138. zfyy (ji,jj) = zfyy(ji,jj) + zalf * psyy(ji+1,jj)
  139. END DO
  140. END DO
  141. DO jj = 2, jpjm1 ! Readjust moments remaining in the box.
  142. DO ji = fs_2, fs_jpim1
  143. zbt = zbet(ji-1,jj)
  144. zbt1 = 1.0 - zbet(ji-1,jj)
  145. psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji-1,jj) )
  146. ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji-1,jj) )
  147. psx (ji,jj) = zalg1q(ji-1,jj) * ( psx(ji,jj) + 3.0 * zalg(ji-1,jj) * psxx(ji,jj) )
  148. psxx(ji,jj) = zalg1 (ji-1,jj) * zalg1q(ji-1,jj) * psxx(ji,jj)
  149. psy (ji,jj) = zbt * psy (ji,jj) + zbt1 * ( psy (ji,jj) - zfy (ji-1,jj) )
  150. psyy(ji,jj) = zbt * psyy(ji,jj) + zbt1 * ( psyy(ji,jj) - zfyy(ji-1,jj) )
  151. psxy(ji,jj) = zalg1q(ji-1,jj) * psxy(ji,jj)
  152. END DO
  153. END DO
  154. ! Put the temporary moments into appropriate neighboring boxes.
  155. DO jj = 2, jpjm1 ! Flux from i to i+1 IF u GT 0.
  156. DO ji = fs_2, fs_jpim1
  157. zbt = zbet(ji-1,jj)
  158. zbt1 = 1.0 - zbet(ji-1,jj)
  159. psm(ji,jj) = zbt * ( psm(ji,jj) + zfm(ji-1,jj) ) + zbt1 * psm(ji,jj)
  160. zalf = zbt * zfm(ji-1,jj) / psm(ji,jj)
  161. zalf1 = 1.0 - zalf
  162. ztemp = zalf * ps0(ji,jj) - zalf1 * zf0(ji-1,jj)
  163. !
  164. ps0 (ji,jj) = zbt * (ps0(ji,jj) + zf0(ji-1,jj)) + zbt1 * ps0(ji,jj)
  165. psx (ji,jj) = zbt * ( zalf * zfx(ji-1,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp ) + zbt1 * psx(ji,jj)
  166. psxx(ji,jj) = zbt * ( zalf * zalf * zfxx(ji-1,jj) + zalf1 * zalf1 * psxx(ji,jj) &
  167. & + 5.0 * ( zalf * zalf1 * ( psx (ji,jj) - zfx(ji-1,jj) ) - ( zalf1 - zalf ) * ztemp ) ) &
  168. & + zbt1 * psxx(ji,jj)
  169. psxy(ji,jj) = zbt * ( zalf * zfxy(ji-1,jj) + zalf1 * psxy(ji,jj) &
  170. & + 3.0 * (- zalf1*zfy(ji-1,jj) + zalf * psy(ji,jj) ) ) &
  171. & + zbt1 * psxy(ji,jj)
  172. psy (ji,jj) = zbt * ( psy (ji,jj) + zfy (ji-1,jj) ) + zbt1 * psy (ji,jj)
  173. psyy(ji,jj) = zbt * ( psyy(ji,jj) + zfyy(ji-1,jj) ) + zbt1 * psyy(ji,jj)
  174. END DO
  175. END DO
  176. DO jj = 2, jpjm1 ! Flux from i+1 to i IF u LT 0.
  177. DO ji = fs_2, fs_jpim1
  178. zbt = zbet(ji,jj)
  179. zbt1 = 1.0 - zbet(ji,jj)
  180. psm(ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
  181. zalf = zbt1 * zfm(ji,jj) / psm(ji,jj)
  182. zalf1 = 1.0 - zalf
  183. ztemp = -zalf * ps0(ji,jj) + zalf1 * zf0(ji,jj)
  184. !
  185. ps0(ji,jj) = zbt * ps0 (ji,jj) + zbt1 * ( ps0(ji,jj) + zf0(ji,jj) )
  186. psx(ji,jj) = zbt * psx (ji,jj) + zbt1 * ( zalf * zfx(ji,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp )
  187. psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( zalf * zalf * zfxx(ji,jj) + zalf1 * zalf1 * psxx(ji,jj) &
  188. & + 5.0 *( zalf * zalf1 * ( - psx(ji,jj) + zfx(ji,jj) ) &
  189. & + ( zalf1 - zalf ) * ztemp ) )
  190. psxy(ji,jj) = zbt * psxy(ji,jj) + zbt1 * ( zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj) &
  191. & + 3.0 * ( zalf1 * zfy(ji,jj) - zalf * psy(ji,jj) ) )
  192. psy(ji,jj) = zbt * psy (ji,jj) + zbt1 * ( psy (ji,jj) + zfy (ji,jj) )
  193. psyy(ji,jj) = zbt * psyy(ji,jj) + zbt1 * ( psyy(ji,jj) + zfyy(ji,jj) )
  194. END DO
  195. END DO
  196. !-- Lateral boundary conditions
  197. CALL lbc_lnk( psm , 'T', 1. ) ; CALL lbc_lnk( ps0 , 'T', 1. )
  198. CALL lbc_lnk( psx , 'T', -1. ) ; CALL lbc_lnk( psy , 'T', -1. ) ! caution gradient ==> the sign changes
  199. CALL lbc_lnk( psxx, 'T', 1. ) ; CALL lbc_lnk( psyy, 'T', 1. )
  200. CALL lbc_lnk( psxy, 'T', 1. )
  201. IF(ln_ctl) THEN
  202. CALL prt_ctl(tab2d_1=psm , clinfo1=' lim_adv_x: psm :', tab2d_2=ps0 , clinfo2=' ps0 : ')
  203. CALL prt_ctl(tab2d_1=psx , clinfo1=' lim_adv_x: psx :', tab2d_2=psxx, clinfo2=' psxx : ')
  204. CALL prt_ctl(tab2d_1=psy , clinfo1=' lim_adv_x: psy :', tab2d_2=psyy, clinfo2=' psyy : ')
  205. CALL prt_ctl(tab2d_1=psxy , clinfo1=' lim_adv_x: psxy :')
  206. ENDIF
  207. !
  208. CALL wrk_dealloc( jpi, jpj, zf0 , zfx , zfy , zbet, zfm )
  209. CALL wrk_dealloc( jpi, jpj, zfxx, zfyy, zfxy, zalg, zalg1, zalg1q )
  210. !
  211. END SUBROUTINE lim_adv_x_2
  212. SUBROUTINE lim_adv_y_2( pdf, pvt , pcrh, psm , ps0 , &
  213. & psx, psxx, psy , psyy, psxy )
  214. !!---------------------------------------------------------------------
  215. !! ** routine lim_adv_y_2 **
  216. !!
  217. !! ** purpose : Computes and adds the advection trend to sea-ice
  218. !! variable on j-axis
  219. !!
  220. !! ** method : Uses Prather second order scheme that advects tracers
  221. !! but also their quadratic forms. The method preserves
  222. !! tracer structures by conserving second order moments.
  223. !!
  224. !! Reference: Prather, 1986, JGR, 91, D6. 6671-6681.
  225. !!---------------------------------------------------------------------
  226. REAL(wp) , INTENT(in ) :: pdf ! reduction factor for the time step
  227. REAL(wp) , INTENT(in ) :: pcrh ! call lim_adv_x then lim_adv_y (=1) or the opposite (=0)
  228. REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: pvt ! j-direction ice velocity at V-point [m/s]
  229. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: psm ! area
  230. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: ps0 ! field to be advected
  231. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: psx , psy ! 1st moments
  232. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: psxx, psyy, psxy ! 2nd moments
  233. !!
  234. INTEGER :: ji, jj ! dummy loop indices
  235. REAL(wp) :: zs1max, zrdt, zslpmax, ztemp, zin0 ! temporary scalars
  236. REAL(wp) :: zs1new, zalf , zalfq , zbt ! - -
  237. REAL(wp) :: zs2new, zalf1, zalf1q, zbt1 ! - -
  238. REAL(wp), DIMENSION(:,:), POINTER :: zf0, zfx , zfy , zbet ! 2D workspace
  239. REAL(wp), DIMENSION(:,:), POINTER :: zfm, zfxx, zfyy, zfxy ! - -
  240. REAL(wp), DIMENSION(:,:), POINTER :: zalg, zalg1, zalg1q ! - -
  241. !---------------------------------------------------------------------
  242. CALL wrk_alloc( jpi, jpj, zf0 , zfx , zfy , zbet, zfm )
  243. CALL wrk_alloc( jpi, jpj, zfxx, zfyy, zfxy, zalg, zalg1, zalg1q )
  244. ! Limitation of moments.
  245. zrdt = rdt_ice * pdf ! If ice drift field is too fast, use an appropriate time step for advection.
  246. DO jj = 1, jpj
  247. DO ji = 1, jpi
  248. zslpmax = MAX( rzero, ps0(ji,jj) )
  249. zs1max = 1.5 * zslpmax
  250. zs1new = MIN( zs1max, MAX( -zs1max, psy(ji,jj) ) )
  251. zs2new = MIN( ( 2.0 * zslpmax - 0.3334 * ABS( zs1new ) ), &
  252. & MAX( ABS( zs1new )-zslpmax, psyy(ji,jj) ) )
  253. zin0 = ( 1.0 - MAX( rzero, sign ( rone, -zslpmax) ) ) * tms(ji,jj) ! Case of empty boxes & Apply mask
  254. !
  255. ps0 (ji,jj) = zslpmax
  256. psx (ji,jj) = psx (ji,jj) * zin0
  257. psxx(ji,jj) = psxx(ji,jj) * zin0
  258. psy (ji,jj) = zs1new * zin0
  259. psyy(ji,jj) = zs2new * zin0
  260. psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * zin0
  261. END DO
  262. END DO
  263. ! Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
  264. psm(:,:) = MAX( pcrh * area(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
  265. ! Calculate fluxes and moments between boxes j<-->j+1
  266. DO jj = 1, jpj ! Flux from j to j+1 WHEN v GT 0
  267. DO ji = 1, jpi
  268. zbet(ji,jj) = MAX( rzero, SIGN( rone, pvt(ji,jj) ) )
  269. zalf = MAX( rzero, pvt(ji,jj) ) * zrdt * e1v(ji,jj) / psm(ji,jj)
  270. zalfq = zalf * zalf
  271. zalf1 = 1.0 - zalf
  272. zalf1q = zalf1 * zalf1
  273. zfm (ji,jj) = zalf * psm(ji,jj)
  274. zf0 (ji,jj) = zalf * ( ps0(ji,jj) + zalf1 * ( psy(ji,jj) + (zalf1-zalf) * psyy(ji,jj) ) )
  275. zfy (ji,jj) = zalfq *( psy(ji,jj) + 3.0*zalf1*psyy(ji,jj) )
  276. zfyy(ji,jj) = zalf * zalfq * psyy(ji,jj)
  277. zfx (ji,jj) = zalf * ( psx(ji,jj) + zalf1 * psxy(ji,jj) )
  278. zfxy(ji,jj) = zalfq * psxy(ji,jj)
  279. zfxx(ji,jj) = zalf * psxx(ji,jj)
  280. !
  281. ! Readjust moments remaining in the box.
  282. psm (ji,jj) = psm (ji,jj) - zfm(ji,jj)
  283. ps0 (ji,jj) = ps0 (ji,jj) - zf0(ji,jj)
  284. psy (ji,jj) = zalf1q * ( psy(ji,jj) -3.0 * zalf * psyy(ji,jj) )
  285. psyy(ji,jj) = zalf1 * zalf1q * psyy(ji,jj)
  286. psx (ji,jj) = psx (ji,jj) - zfx(ji,jj)
  287. psxx(ji,jj) = psxx(ji,jj) - zfxx(ji,jj)
  288. psxy(ji,jj) = zalf1q * psxy(ji,jj)
  289. END DO
  290. END DO
  291. !
  292. DO jj = 1, jpjm1 ! Flux from j+1 to j when v LT 0.
  293. DO ji = 1, jpi
  294. zalf = ( MAX(rzero, -pvt(ji,jj) ) * zrdt * e1v(ji,jj) ) / psm(ji,jj+1)
  295. zalg (ji,jj) = zalf
  296. zalfq = zalf * zalf
  297. zalf1 = 1.0 - zalf
  298. zalg1 (ji,jj) = zalf1
  299. zalf1q = zalf1 * zalf1
  300. zalg1q(ji,jj) = zalf1q
  301. zfm (ji,jj) = zfm (ji,jj) + zalf * psm(ji,jj+1)
  302. zf0 (ji,jj) = zf0 (ji,jj) + zalf * ( ps0(ji,jj+1) - zalf1 * (psy(ji,jj+1) - (zalf1 - zalf ) * psyy(ji,jj+1) ) )
  303. zfy (ji,jj) = zfy (ji,jj) + zalfq * ( psy(ji,jj+1) - 3.0 * zalf1 * psyy(ji,jj+1) )
  304. zfyy (ji,jj) = zfyy(ji,jj) + zalf * zalfq * psyy(ji,jj+1)
  305. zfx (ji,jj) = zfx (ji,jj) + zalf * ( psx(ji,jj+1) - zalf1 * psxy(ji,jj+1) )
  306. zfxy (ji,jj) = zfxy(ji,jj) + zalfq * psxy(ji,jj+1)
  307. zfxx (ji,jj) = zfxx(ji,jj) + zalf * psxx(ji,jj+1)
  308. END DO
  309. END DO
  310. ! Readjust moments remaining in the box.
  311. DO jj = 2, jpj
  312. DO ji = 1, jpi
  313. zbt = zbet(ji,jj-1)
  314. zbt1 = ( 1.0 - zbet(ji,jj-1) )
  315. !
  316. psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji,jj-1) )
  317. ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji,jj-1) )
  318. psy (ji,jj) = zalg1q(ji,jj-1) * ( psy(ji,jj) + 3.0 * zalg(ji,jj-1) * psyy(ji,jj) )
  319. psyy(ji,jj) = zalg1 (ji,jj-1) * zalg1q(ji,jj-1) * psyy(ji,jj)
  320. psx (ji,jj) = zbt * psx (ji,jj) + zbt1 * ( psx (ji,jj) - zfx (ji,jj-1) )
  321. psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) - zfxx(ji,jj-1) )
  322. psxy(ji,jj) = zalg1q(ji,jj-1) * psxy(ji,jj)
  323. END DO
  324. END DO
  325. ! Put the temporary moments into appropriate neighboring boxes.
  326. DO jj = 2, jpjm1 ! Flux from j to j+1 IF v GT 0.
  327. DO ji = 1, jpi
  328. zbt = zbet(ji,jj-1)
  329. zbt1 = ( 1.0 - zbet(ji,jj-1) )
  330. psm(ji,jj) = zbt * ( psm(ji,jj) + zfm(ji,jj-1) ) + zbt1 * psm(ji,jj)
  331. zalf = zbt * zfm(ji,jj-1) / psm(ji,jj)
  332. zalf1 = 1.0 - zalf
  333. ztemp = zalf * ps0(ji,jj) - zalf1 * zf0(ji,jj-1)
  334. !
  335. ps0(ji,jj) = zbt * (ps0(ji,jj) + zf0(ji,jj-1)) + zbt1 * ps0(ji,jj)
  336. psy(ji,jj) = zbt * ( zalf * zfy(ji,jj-1) + zalf1 * psy(ji,jj) + 3.0 * ztemp ) &
  337. & + zbt1 * psy(ji,jj)
  338. psyy(ji,jj) = zbt * ( zalf * zalf * zfyy(ji,jj-1) + zalf1 * zalf1 * psyy(ji,jj) &
  339. & + 5.0 * ( zalf * zalf1 * ( psy(ji,jj) - zfy(ji,jj-1) ) - ( zalf1 - zalf ) * ztemp ) ) &
  340. & + zbt1 * psyy(ji,jj)
  341. psxy(ji,jj) = zbt * ( zalf * zfxy(ji,jj-1) + zalf1 * psxy(ji,jj) &
  342. & + 3.0 * (- zalf1 * zfx(ji,jj-1) + zalf * psx(ji,jj) ) ) &
  343. & + zbt1 * psxy(ji,jj)
  344. psx (ji,jj) = zbt * ( psx (ji,jj) + zfx (ji,jj-1) ) + zbt1 * psx (ji,jj)
  345. psxx(ji,jj) = zbt * ( psxx(ji,jj) + zfxx(ji,jj-1) ) + zbt1 * psxx(ji,jj)
  346. END DO
  347. END DO
  348. !
  349. DO jj = 2, jpjm1 ! Flux from j+1 to j IF v LT 0.
  350. DO ji = 1, jpi
  351. zbt = zbet(ji,jj)
  352. zbt1 = ( 1.0 - zbet(ji,jj) )
  353. psm(ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
  354. zalf = zbt1 * zfm(ji,jj) / psm(ji,jj)
  355. zalf1 = 1.0 - zalf
  356. ztemp = -zalf * ps0(ji,jj) + zalf1 * zf0(ji,jj)
  357. ps0(ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) + zf0(ji,jj) )
  358. psy(ji,jj) = zbt * psy(ji,jj) &
  359. & + zbt1 * ( zalf*zfy(ji,jj) + zalf1 * psy(ji,jj) + 3.0 * ztemp )
  360. psyy(ji,jj) = zbt * psyy(ji,jj) &
  361. & + zbt1 * ( zalf * zalf * zfyy(ji,jj) + zalf1 * zalf1 * psyy(ji,jj) &
  362. & + 5.0 *( zalf *zalf1 *( -psy(ji,jj) + zfy(ji,jj) ) + ( zalf1 - zalf ) * ztemp ) )
  363. psxy(ji,jj) = zbt * psxy(ji,jj) &
  364. & + zbt1 * ( zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj) &
  365. & + 3.0 * ( zalf1 * zfx(ji,jj) - zalf * psx(ji,jj) ) )
  366. psx(ji,jj) = zbt * psx (ji,jj) + zbt1 * ( psx (ji,jj) + zfx (ji,jj) )
  367. psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) + zfxx(ji,jj) )
  368. END DO
  369. END DO
  370. !-- Lateral boundary conditions
  371. CALL lbc_lnk( psm , 'T', 1. ) ; CALL lbc_lnk( ps0 , 'T', 1. )
  372. CALL lbc_lnk( psx , 'T', -1. ) ; CALL lbc_lnk( psy , 'T', -1. ) ! caution gradient ==> the sign changes
  373. CALL lbc_lnk( psxx, 'T', 1. ) ; CALL lbc_lnk( psyy, 'T', 1. )
  374. CALL lbc_lnk( psxy, 'T', 1. )
  375. IF(ln_ctl) THEN
  376. CALL prt_ctl(tab2d_1=psm , clinfo1=' lim_adv_y: psm :', tab2d_2=ps0 , clinfo2=' ps0 : ')
  377. CALL prt_ctl(tab2d_1=psx , clinfo1=' lim_adv_y: psx :', tab2d_2=psxx, clinfo2=' psxx : ')
  378. CALL prt_ctl(tab2d_1=psy , clinfo1=' lim_adv_y: psy :', tab2d_2=psyy, clinfo2=' psyy : ')
  379. CALL prt_ctl(tab2d_1=psxy , clinfo1=' lim_adv_y: psxy :')
  380. ENDIF
  381. !
  382. CALL wrk_dealloc( jpi, jpj, zf0 , zfx , zfy , zbet, zfm )
  383. CALL wrk_dealloc( jpi, jpj, zfxx, zfyy, zfxy, zalg, zalg1, zalg1q )
  384. !
  385. END SUBROUTINE lim_adv_y_2
  386. #else
  387. !!----------------------------------------------------------------------
  388. !! Default option Dummy module NO LIM 2.0 sea-ice model
  389. !!----------------------------------------------------------------------
  390. #endif
  391. !!======================================================================
  392. END MODULE limadv_2