limadv.F90 23 KB

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