Index: NEMO/trunk/src/ICE/icedyn_adv_pra.F90
===================================================================
--- NEMO/trunk/src/ICE/icedyn_adv_pra.F90	(revision 13612)
+++ NEMO/trunk/src/ICE/icedyn_adv_pra.F90	(revision 13613)
@@ -288,6 +288,33 @@
                   CALL adv_x( zdt , zudy , 0._wp , zarea , z0vl , sxvl , sxxvl , syvl , syyvl , sxyvl ) 
                ENDIF
-           ENDIF
-            !
+            ENDIF
+            !
+         ENDIF
+         
+         ! --- Lateral boundary conditions --- !
+         !     caution: for gradients (sx and sy) the sign changes
+         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0ice , 'T', 1._wp, sxice , 'T', -1._wp, syice , 'T', -1._wp  & ! ice volume
+            &                                , sxxice, 'T', 1._wp, syyice, 'T',  1._wp, sxyice, 'T',  1._wp  &
+            &                                , z0snw , 'T', 1._wp, sxsn  , 'T', -1._wp, sysn  , 'T', -1._wp  & ! snw volume
+            &                                , sxxsn , 'T', 1._wp, syysn , 'T',  1._wp, sxysn , 'T',  1._wp  )
+         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0smi , 'T', 1._wp, sxsal , 'T', -1._wp, sysal , 'T', -1._wp  & ! ice salinity
+            &                                , sxxsal, 'T', 1._wp, syysal, 'T',  1._wp, sxysal, 'T',  1._wp  &
+            &                                , z0ai  , 'T', 1._wp, sxa   , 'T', -1._wp, sya   , 'T', -1._wp  & ! ice concentration
+            &                                , sxxa  , 'T', 1._wp, syya  , 'T',  1._wp, sxya  , 'T',  1._wp  )
+         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0oi  , 'T', 1._wp, sxage , 'T', -1._wp, syage , 'T', -1._wp  & ! ice age
+            &                                , sxxage, 'T', 1._wp, syyage, 'T',  1._wp, sxyage, 'T',  1._wp  )
+         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0es  , 'T', 1._wp, sxc0  , 'T', -1._wp, syc0  , 'T', -1._wp  & ! snw enthalpy
+            &                                , sxxc0 , 'T', 1._wp, syyc0 , 'T',  1._wp, sxyc0 , 'T',  1._wp  ) 
+         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0ei  , 'T', 1._wp, sxe   , 'T', -1._wp, sye   , 'T', -1._wp  & ! ice enthalpy
+            &                                , sxxe  , 'T', 1._wp, syye  , 'T',  1._wp, sxye  , 'T',  1._wp  )
+         IF ( ln_pnd_LEV ) THEN
+            CALL lbc_lnk_multi( 'icedyn_adv_pra', z0ap , 'T', 1._wp, sxap , 'T', -1._wp, syap , 'T', -1._wp  & ! melt pond fraction
+               &                                , sxxap, 'T', 1._wp, syyap, 'T',  1._wp, sxyap, 'T',  1._wp  &
+               &                                , z0vp , 'T', 1._wp, sxvp , 'T', -1._wp, syvp , 'T', -1._wp  & ! melt pond volume
+               &                                , sxxvp, 'T', 1._wp, syyvp, 'T',  1._wp, sxyvp, 'T',  1._wp  ) 
+            IF ( ln_pnd_lids ) THEN
+               CALL lbc_lnk_multi( 'icedyn_adv_pra', z0vl ,'T', 1._wp, sxvl ,'T', -1._wp, syvl ,'T', -1._wp  & ! melt pond lid volume
+                  &                                , sxxvl,'T', 1._wp, syyvl,'T',  1._wp, sxyvl,'T',  1._wp  ) 
+            ENDIF
          ENDIF
 
@@ -368,4 +395,5 @@
       !! 
       INTEGER  ::   ji, jj, jl, jcat                     ! dummy loop indices
+      INTEGER  ::   jj0                                  ! dummy loop indices
       REAL(wp) ::   zs1max, zslpmax, ztemp               ! local scalars
       REAL(wp) ::   zs1new, zalf , zalfq , zbt           !   -      -
@@ -375,4 +403,8 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   zalg, zalg1, zalg1q         !  -      -
       !-----------------------------------------------------------------------
+      ! in order to avoid lbc_lnk (communications):
+      !    jj loop must be 1:jpj   if adv_x is called first
+      !                and 2:jpj-1 if adv_x is called second
+      jj0 = NINT(pcrh)
       !
       jcat = SIZE( ps0 , 3 )   ! size of input arrays
@@ -381,128 +413,126 @@
          !
          ! Limitation of moments.                                           
-         DO_2D( 0, 0, 1, 1 )
-            !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
-            psm (ji,jj,jl) = MAX( pcrh * e1e2t(ji,jj) + ( 1.0 - pcrh ) * psm(ji,jj,jl) , epsi20 )
-            !
-            zslpmax = MAX( 0._wp, ps0(ji,jj,jl) )
-            zs1max  = 1.5 * zslpmax
-            zs1new  = MIN( zs1max, MAX( -zs1max, psx(ji,jj,jl) ) )
-            zs2new  = MIN(  2.0 * zslpmax - 0.3334 * ABS( zs1new ),      &
-               &            MAX( ABS( zs1new ) - zslpmax, psxx(ji,jj,jl) )  )
-            rswitch = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zslpmax) ) ) * tmask(ji,jj,1)   ! Case of empty boxes & Apply mask
-
-            ps0 (ji,jj,jl) = zslpmax  
-            psx (ji,jj,jl) = zs1new         * rswitch
-            psxx(ji,jj,jl) = zs2new         * rswitch
-            psy (ji,jj,jl) = psy (ji,jj,jl) * rswitch
-            psyy(ji,jj,jl) = psyy(ji,jj,jl) * rswitch
-            psxy(ji,jj,jl) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj,jl) ) ) * rswitch
-         END_2D
-
-         !  Calculate fluxes and moments between boxes i<-->i+1              
-         DO_2D( 0, 0, 1, 1 )                   !  Flux from i to i+1 WHEN u GT 0
-            zbet(ji,jj)  =  MAX( 0._wp, SIGN( 1._wp, put(ji,jj) ) )
-            zalf         =  MAX( 0._wp, put(ji,jj) ) * pdt / psm(ji,jj,jl)
-            zalfq        =  zalf * zalf
-            zalf1        =  1.0 - zalf
-            zalf1q       =  zalf1 * zalf1
-            !
-            zfm (ji,jj)  =  zalf  *   psm (ji,jj,jl)
-            zf0 (ji,jj)  =  zalf  * ( ps0 (ji,jj,jl) + zalf1 * ( psx(ji,jj,jl) + (zalf1 - zalf) * psxx(ji,jj,jl) ) )
-            zfx (ji,jj)  =  zalfq * ( psx (ji,jj,jl) + 3.0 * zalf1 * psxx(ji,jj,jl) )
-            zfxx(ji,jj)  =  zalf  *   psxx(ji,jj,jl) * zalfq
-            zfy (ji,jj)  =  zalf  * ( psy (ji,jj,jl) + zalf1 * psxy(ji,jj,jl) )
-            zfxy(ji,jj)  =  zalfq *   psxy(ji,jj,jl)
-            zfyy(ji,jj)  =  zalf  *   psyy(ji,jj,jl)
-
-            !  Readjust moments remaining in the box.
-            psm (ji,jj,jl)  =  psm (ji,jj,jl) - zfm(ji,jj)
-            ps0 (ji,jj,jl)  =  ps0 (ji,jj,jl) - zf0(ji,jj)
-            psx (ji,jj,jl)  =  zalf1q * ( psx(ji,jj,jl) - 3.0 * zalf * psxx(ji,jj,jl) )
-            psxx(ji,jj,jl)  =  zalf1  * zalf1q * psxx(ji,jj,jl)
-            psy (ji,jj,jl)  =  psy (ji,jj,jl) - zfy(ji,jj)
-            psyy(ji,jj,jl)  =  psyy(ji,jj,jl) - zfyy(ji,jj)
-            psxy(ji,jj,jl)  =  zalf1q * psxy(ji,jj,jl)
-         END_2D
-
-         DO_2D( 0, 0, 1, 0 )                   !  Flux from i+1 to i when u LT 0.
-            zalf          = MAX( 0._wp, -put(ji,jj) ) * pdt / psm(ji+1,jj,jl) 
-            zalg  (ji,jj) = zalf
-            zalfq         = zalf * zalf
-            zalf1         = 1.0 - zalf
-            zalg1 (ji,jj) = zalf1
-            zalf1q        = zalf1 * zalf1
-            zalg1q(ji,jj) = zalf1q
-            !
-            zfm   (ji,jj) = zfm (ji,jj) + zalf  *    psm (ji+1,jj,jl)
-            zf0   (ji,jj) = zf0 (ji,jj) + zalf  * (  ps0 (ji+1,jj,jl) &
-               &                                   - zalf1 * ( psx(ji+1,jj,jl) - (zalf1 - zalf ) * psxx(ji+1,jj,jl) ) )
-            zfx   (ji,jj) = zfx (ji,jj) + zalfq * (  psx (ji+1,jj,jl) - 3.0 * zalf1 * psxx(ji+1,jj,jl) )
-            zfxx  (ji,jj) = zfxx(ji,jj) + zalf  *    psxx(ji+1,jj,jl) * zalfq
-            zfy   (ji,jj) = zfy (ji,jj) + zalf  * (  psy (ji+1,jj,jl) - zalf1 * psxy(ji+1,jj,jl) )
-            zfxy  (ji,jj) = zfxy(ji,jj) + zalfq *    psxy(ji+1,jj,jl)
-            zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *    psyy(ji+1,jj,jl)
-         END_2D
-
-         DO_2D( 0, 0, 0, 0 )                   !  Readjust moments remaining in the box.
-            zbt  =       zbet(ji-1,jj)
-            zbt1 = 1.0 - zbet(ji-1,jj)
-            !
-            psm (ji,jj,jl) = zbt * psm(ji,jj,jl) + zbt1 * ( psm(ji,jj,jl) - zfm(ji-1,jj) )
-            ps0 (ji,jj,jl) = zbt * ps0(ji,jj,jl) + zbt1 * ( ps0(ji,jj,jl) - zf0(ji-1,jj) )
-            psx (ji,jj,jl) = zalg1q(ji-1,jj) * ( psx(ji,jj,jl) + 3.0 * zalg(ji-1,jj) * psxx(ji,jj,jl) )
-            psxx(ji,jj,jl) = zalg1 (ji-1,jj) * zalg1q(ji-1,jj) * psxx(ji,jj,jl)
-            psy (ji,jj,jl) = zbt * psy (ji,jj,jl) + zbt1 * ( psy (ji,jj,jl) - zfy (ji-1,jj) )
-            psyy(ji,jj,jl) = zbt * psyy(ji,jj,jl) + zbt1 * ( psyy(ji,jj,jl) - zfyy(ji-1,jj) )
-            psxy(ji,jj,jl) = zalg1q(ji-1,jj) * psxy(ji,jj,jl)
-         END_2D
-
-         !   Put the temporary moments into appropriate neighboring boxes.    
-         DO_2D( 0, 0, 0, 0 )                   !   Flux from i to i+1 IF u GT 0.
-            zbt  =       zbet(ji-1,jj)
-            zbt1 = 1.0 - zbet(ji-1,jj)
-            psm(ji,jj,jl) = zbt * ( psm(ji,jj,jl) + zfm(ji-1,jj) ) + zbt1 * psm(ji,jj,jl)
-            zalf          = zbt * zfm(ji-1,jj) / psm(ji,jj,jl)
-            zalf1         = 1.0 - zalf
-            ztemp         = zalf * ps0(ji,jj,jl) - zalf1 * zf0(ji-1,jj)
-            !
-            ps0 (ji,jj,jl) =  zbt  * ( ps0(ji,jj,jl) + zf0(ji-1,jj) ) + zbt1 * ps0(ji,jj,jl)
-            psx (ji,jj,jl) =  zbt  * ( zalf * zfx(ji-1,jj) + zalf1 * psx(ji,jj,jl) + 3.0 * ztemp ) + zbt1 * psx(ji,jj,jl)
-            psxx(ji,jj,jl) =  zbt  * ( zalf * zalf * zfxx(ji-1,jj) + zalf1 * zalf1 * psxx(ji,jj,jl)                             &
-               &                     + 5.0 * ( zalf * zalf1 * ( psx (ji,jj,jl) - zfx(ji-1,jj) ) - ( zalf1 - zalf ) * ztemp )  ) &
-               &            + zbt1 * psxx(ji,jj,jl)
-            psxy(ji,jj,jl) =  zbt  * ( zalf * zfxy(ji-1,jj) + zalf1 * psxy(ji,jj,jl)             &
-               &                     + 3.0 * (- zalf1*zfy(ji-1,jj)  + zalf * psy(ji,jj,jl) ) )   &
-               &            + zbt1 * psxy(ji,jj,jl)
-            psy (ji,jj,jl) =  zbt  * ( psy (ji,jj,jl) + zfy (ji-1,jj) ) + zbt1 * psy (ji,jj,jl)
-            psyy(ji,jj,jl) =  zbt  * ( psyy(ji,jj,jl) + zfyy(ji-1,jj) ) + zbt1 * psyy(ji,jj,jl)
-         END_2D
-
-         DO_2D( 0, 0, 0, 0 )                   !  Flux from i+1 to i IF u LT 0.
-            zbt  =       zbet(ji,jj)
-            zbt1 = 1.0 - zbet(ji,jj)
-            psm(ji,jj,jl) = zbt * psm(ji,jj,jl) + zbt1 * ( psm(ji,jj,jl) + zfm(ji,jj) )
-            zalf          = zbt1 * zfm(ji,jj) / psm(ji,jj,jl)
-            zalf1         = 1.0 - zalf
-            ztemp         = - zalf * ps0(ji,jj,jl) + zalf1 * zf0(ji,jj)
-            !
-            ps0 (ji,jj,jl) = zbt * ps0 (ji,jj,jl) + zbt1 * ( ps0(ji,jj,jl) + zf0(ji,jj) )
-            psx (ji,jj,jl) = zbt * psx (ji,jj,jl) + zbt1 * ( zalf * zfx(ji,jj) + zalf1 * psx(ji,jj,jl) + 3.0 * ztemp )
-            psxx(ji,jj,jl) = zbt * psxx(ji,jj,jl) + zbt1 * ( zalf * zalf * zfxx(ji,jj) + zalf1 * zalf1 * psxx(ji,jj,jl) &
-               &                                           + 5.0 * ( zalf * zalf1 * ( - psx(ji,jj,jl) + zfx(ji,jj) )    &
-               &                                           + ( zalf1 - zalf ) * ztemp ) )
-            psxy(ji,jj,jl) = zbt * psxy(ji,jj,jl) + zbt1 * ( zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj,jl)  &
-               &                                           + 3.0 * ( zalf1 * zfy(ji,jj) - zalf * psy(ji,jj,jl) ) )
-            psy (ji,jj,jl) = zbt * psy (ji,jj,jl) + zbt1 * ( psy (ji,jj,jl) + zfy (ji,jj) )
-            psyy(ji,jj,jl) = zbt * psyy(ji,jj,jl) + zbt1 * ( psyy(ji,jj,jl) + zfyy(ji,jj) )
-         END_2D
-
+         DO jj = Njs0 - jj0, Nje0 + jj0
+            
+            DO ji = Nis0 - 1, Nie0 + 1
+
+               !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
+               psm (ji,jj,jl) = MAX( pcrh * e1e2t(ji,jj) + ( 1.0 - pcrh ) * psm(ji,jj,jl) , epsi20 )
+               !
+               zslpmax = MAX( 0._wp, ps0(ji,jj,jl) )
+               zs1max  = 1.5 * zslpmax
+               zs1new  = MIN( zs1max, MAX( -zs1max, psx(ji,jj,jl) ) )
+               zs2new  = MIN( 2.0 * zslpmax - 0.3334 * ABS( zs1new ), MAX( ABS( zs1new ) - zslpmax, psxx(ji,jj,jl) ) )
+               rswitch = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zslpmax) ) ) * tmask(ji,jj,1)   ! Case of empty boxes & Apply mask
+               
+               ps0 (ji,jj,jl) = zslpmax  
+               psx (ji,jj,jl) = zs1new         * rswitch
+               psxx(ji,jj,jl) = zs2new         * rswitch
+               psy (ji,jj,jl) = psy (ji,jj,jl) * rswitch
+               psyy(ji,jj,jl) = psyy(ji,jj,jl) * rswitch
+               psxy(ji,jj,jl) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj,jl) ) ) * rswitch
+               
+               !  Calculate fluxes and moments between boxes i<-->i+1              
+               !                                !  Flux from i to i+1 WHEN u GT 0 
+               zbet(ji,jj)  =  MAX( 0._wp, SIGN( 1._wp, put(ji,jj) ) )
+               zalf         =  MAX( 0._wp, put(ji,jj) ) * pdt / psm(ji,jj,jl)
+               zalfq        =  zalf * zalf
+               zalf1        =  1.0 - zalf
+               zalf1q       =  zalf1 * zalf1
+               !
+               zfm (ji,jj)  =  zalf  *   psm (ji,jj,jl)
+               zf0 (ji,jj)  =  zalf  * ( ps0 (ji,jj,jl) + zalf1 * ( psx(ji,jj,jl) + (zalf1 - zalf) * psxx(ji,jj,jl) ) )
+               zfx (ji,jj)  =  zalfq * ( psx (ji,jj,jl) + 3.0 * zalf1 * psxx(ji,jj,jl) )
+               zfxx(ji,jj)  =  zalf  *   psxx(ji,jj,jl) * zalfq
+               zfy (ji,jj)  =  zalf  * ( psy (ji,jj,jl) + zalf1 * psxy(ji,jj,jl) )
+               zfxy(ji,jj)  =  zalfq *   psxy(ji,jj,jl)
+               zfyy(ji,jj)  =  zalf  *   psyy(ji,jj,jl)
+               
+               !                                !  Readjust moments remaining in the box.
+               psm (ji,jj,jl)  =  psm (ji,jj,jl) - zfm(ji,jj)
+               ps0 (ji,jj,jl)  =  ps0 (ji,jj,jl) - zf0(ji,jj)
+               psx (ji,jj,jl)  =  zalf1q * ( psx(ji,jj,jl) - 3.0 * zalf * psxx(ji,jj,jl) )
+               psxx(ji,jj,jl)  =  zalf1  * zalf1q * psxx(ji,jj,jl)
+               psy (ji,jj,jl)  =  psy (ji,jj,jl) - zfy(ji,jj)
+               psyy(ji,jj,jl)  =  psyy(ji,jj,jl) - zfyy(ji,jj)
+               psxy(ji,jj,jl)  =  zalf1q * psxy(ji,jj,jl)
+            END DO
+            
+            DO ji = Nis0 - 1, Nie0
+               !                                !  Flux from i+1 to i when u LT 0.
+               zalf          = MAX( 0._wp, -put(ji,jj) ) * pdt / psm(ji+1,jj,jl) 
+               zalg  (ji,jj) = zalf
+               zalfq         = zalf * zalf
+               zalf1         = 1.0 - zalf
+               zalg1 (ji,jj) = zalf1
+               zalf1q        = zalf1 * zalf1
+               zalg1q(ji,jj) = zalf1q
+               !
+               zfm   (ji,jj) = zfm (ji,jj) + zalf  *    psm (ji+1,jj,jl)
+               zf0   (ji,jj) = zf0 (ji,jj) + zalf  * (  ps0 (ji+1,jj,jl) &
+                  &                                   - zalf1 * ( psx(ji+1,jj,jl) - (zalf1 - zalf ) * psxx(ji+1,jj,jl) ) )
+               zfx   (ji,jj) = zfx (ji,jj) + zalfq * (  psx (ji+1,jj,jl) - 3.0 * zalf1 * psxx(ji+1,jj,jl) )
+               zfxx  (ji,jj) = zfxx(ji,jj) + zalf  *    psxx(ji+1,jj,jl) * zalfq
+               zfy   (ji,jj) = zfy (ji,jj) + zalf  * (  psy (ji+1,jj,jl) - zalf1 * psxy(ji+1,jj,jl) )
+               zfxy  (ji,jj) = zfxy(ji,jj) + zalfq *    psxy(ji+1,jj,jl)
+               zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *    psyy(ji+1,jj,jl)
+            END DO
+
+            DO ji = Nis0, Nie0
+               !                                !  Readjust moments remaining in the box.
+               zbt  =       zbet(ji-1,jj)
+               zbt1 = 1.0 - zbet(ji-1,jj)
+               !
+               psm (ji,jj,jl) = zbt * psm(ji,jj,jl) + zbt1 * ( psm(ji,jj,jl) - zfm(ji-1,jj) )
+               ps0 (ji,jj,jl) = zbt * ps0(ji,jj,jl) + zbt1 * ( ps0(ji,jj,jl) - zf0(ji-1,jj) )
+               psx (ji,jj,jl) = zalg1q(ji-1,jj) * ( psx(ji,jj,jl) + 3.0 * zalg(ji-1,jj) * psxx(ji,jj,jl) )
+               psxx(ji,jj,jl) = zalg1 (ji-1,jj) * zalg1q(ji-1,jj) * psxx(ji,jj,jl)
+               psy (ji,jj,jl) = zbt * psy (ji,jj,jl) + zbt1 * ( psy (ji,jj,jl) - zfy (ji-1,jj) )
+               psyy(ji,jj,jl) = zbt * psyy(ji,jj,jl) + zbt1 * ( psyy(ji,jj,jl) - zfyy(ji-1,jj) )
+               psxy(ji,jj,jl) = zalg1q(ji-1,jj) * psxy(ji,jj,jl)
+               
+               !   Put the temporary moments into appropriate neighboring boxes.    
+               !                                !   Flux from i to i+1 IF u GT 0.
+               zbt  =       zbet(ji-1,jj)
+               zbt1 = 1.0 - zbet(ji-1,jj)
+               psm(ji,jj,jl) = zbt * ( psm(ji,jj,jl) + zfm(ji-1,jj) ) + zbt1 * psm(ji,jj,jl)
+               zalf          = zbt * zfm(ji-1,jj) / psm(ji,jj,jl)
+               zalf1         = 1.0 - zalf
+               ztemp         = zalf * ps0(ji,jj,jl) - zalf1 * zf0(ji-1,jj)
+               !
+               ps0 (ji,jj,jl) =  zbt  * ( ps0(ji,jj,jl) + zf0(ji-1,jj) ) + zbt1 * ps0(ji,jj,jl)
+               psx (ji,jj,jl) =  zbt  * ( zalf * zfx(ji-1,jj) + zalf1 * psx(ji,jj,jl) + 3.0 * ztemp ) + zbt1 * psx(ji,jj,jl)
+               psxx(ji,jj,jl) =  zbt  * ( zalf * zalf * zfxx(ji-1,jj) + zalf1 * zalf1 * psxx(ji,jj,jl)                             &
+                  &                     + 5.0 * ( zalf * zalf1 * ( psx (ji,jj,jl) - zfx(ji-1,jj) ) - ( zalf1 - zalf ) * ztemp )  ) &
+                  &            + zbt1 * psxx(ji,jj,jl)
+               psxy(ji,jj,jl) =  zbt  * ( zalf * zfxy(ji-1,jj) + zalf1 * psxy(ji,jj,jl)             &
+                  &                     + 3.0 * (- zalf1*zfy(ji-1,jj)  + zalf * psy(ji,jj,jl) ) )   &
+                  &            + zbt1 * psxy(ji,jj,jl)
+               psy (ji,jj,jl) =  zbt  * ( psy (ji,jj,jl) + zfy (ji-1,jj) ) + zbt1 * psy (ji,jj,jl)
+               psyy(ji,jj,jl) =  zbt  * ( psyy(ji,jj,jl) + zfyy(ji-1,jj) ) + zbt1 * psyy(ji,jj,jl)
+               
+               !                                !  Flux from i+1 to i IF u LT 0.
+               zbt  =       zbet(ji,jj)
+               zbt1 = 1.0 - zbet(ji,jj)
+               psm(ji,jj,jl) = zbt * psm(ji,jj,jl) + zbt1 * ( psm(ji,jj,jl) + zfm(ji,jj) )
+               zalf          = zbt1 * zfm(ji,jj) / psm(ji,jj,jl)
+               zalf1         = 1.0 - zalf
+               ztemp         = - zalf * ps0(ji,jj,jl) + zalf1 * zf0(ji,jj)
+               !
+               ps0 (ji,jj,jl) = zbt * ps0 (ji,jj,jl) + zbt1 * ( ps0(ji,jj,jl) + zf0(ji,jj) )
+               psx (ji,jj,jl) = zbt * psx (ji,jj,jl) + zbt1 * ( zalf * zfx(ji,jj) + zalf1 * psx(ji,jj,jl) + 3.0 * ztemp )
+               psxx(ji,jj,jl) = zbt * psxx(ji,jj,jl) + zbt1 * ( zalf * zalf * zfxx(ji,jj) + zalf1 * zalf1 * psxx(ji,jj,jl) &
+                  &                                           + 5.0 * ( zalf * zalf1 * ( - psx(ji,jj,jl) + zfx(ji,jj) )    &
+                  &                                           + ( zalf1 - zalf ) * ztemp ) )
+               psxy(ji,jj,jl) = zbt * psxy(ji,jj,jl) + zbt1 * ( zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj,jl)  &
+                  &                                           + 3.0 * ( zalf1 * zfy(ji,jj) - zalf * psy(ji,jj,jl) ) )
+               psy (ji,jj,jl) = zbt * psy (ji,jj,jl) + zbt1 * ( psy (ji,jj,jl) + zfy (ji,jj) )
+               psyy(ji,jj,jl) = zbt * psyy(ji,jj,jl) + zbt1 * ( psyy(ji,jj,jl) + zfyy(ji,jj) )
+            END DO
+            !
+         END DO
+         !
       END DO
-
-      !-- Lateral boundary conditions
-      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm(:,:,1:jcat) , 'T',  1.0_wp, ps0 , 'T',  1.0_wp   &
-         &                                , psx             , 'T', -1.0_wp, psy , 'T', -1.0_wp   &   ! caution gradient ==> the sign changes
-         &                                , psxx            , 'T',  1.0_wp, psyy, 'T',  1.0_wp , psxy, 'T',  1.0_wp )
-      !
+      !      
    END SUBROUTINE adv_x
 
@@ -525,4 +555,5 @@
       !!
       INTEGER  ::   ji, jj, jl, jcat                     ! dummy loop indices
+      INTEGER  ::   ji0                                  ! dummy loop indices
       REAL(wp) ::   zs1max, zslpmax, ztemp               ! temporary scalars
       REAL(wp) ::   zs1new, zalf , zalfq , zbt           !    -         -
@@ -532,4 +563,8 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   zalg, zalg1, zalg1q     !  -      -
       !---------------------------------------------------------------------
+      ! in order to avoid lbc_lnk (communications):
+      !    ji loop must be 1:jpi   if adv_y is called first
+      !                and 2:jpi-1 if adv_y is called second
+      ji0 = NINT(pcrh)
       !
       jcat = SIZE( ps0 , 3 )   ! size of input arrays
@@ -538,5 +573,5 @@
          !
          ! Limitation of moments.
-         DO_2D( 1, 1, 0, 0 )
+         DO_2D( 1, 1, ji0, ji0 )
             !  Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
             psm(ji,jj,jl) = MAX(  pcrh * e1e2t(ji,jj) + ( 1.0 - pcrh ) * psm(ji,jj,jl) , epsi20  )
@@ -545,6 +580,5 @@
             zs1max  = 1.5 * zslpmax
             zs1new  = MIN( zs1max, MAX( -zs1max, psy(ji,jj,jl) ) )
-            zs2new  = MIN(  ( 2.0 * zslpmax - 0.3334 * ABS( zs1new ) ),   &
-               &             MAX( ABS( zs1new )-zslpmax, psyy(ji,jj,jl) )  )
+            zs2new  = MIN( ( 2.0 * zslpmax - 0.3334 * ABS( zs1new ) ), MAX( ABS( zs1new )-zslpmax, psyy(ji,jj,jl) ) )
             rswitch = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zslpmax) ) ) * tmask(ji,jj,1)   ! Case of empty boxes & Apply mask
             !
@@ -555,8 +589,7 @@
             psyy(ji,jj,jl) = zs2new         * rswitch
             psxy(ji,jj,jl) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj,jl) ) ) * rswitch
-         END_2D
  
-         !  Calculate fluxes and moments between boxes j<-->j+1              
-         DO_2D( 1, 1, 0, 0 )                   !  Flux from j to j+1 WHEN v GT 0
+            !  Calculate fluxes and moments between boxes j<-->j+1              
+            !                                !  Flux from j to j+1 WHEN v GT 0   
             zbet(ji,jj)  =  MAX( 0._wp, SIGN( 1._wp, pvt(ji,jj) ) )
             zalf         =  MAX( 0._wp, pvt(ji,jj) ) * pdt / psm(ji,jj,jl)
@@ -573,5 +606,5 @@
             zfxx(ji,jj)  =  zalf  * psxx(ji,jj,jl)
             !
-            !  Readjust moments remaining in the box.
+            !                                !  Readjust moments remaining in the box.
             psm (ji,jj,jl)  =  psm (ji,jj,jl) - zfm(ji,jj)
             ps0 (ji,jj,jl)  =  ps0 (ji,jj,jl) - zf0(ji,jj)
@@ -583,5 +616,6 @@
          END_2D
          !
-         DO_2D( 1, 0, 0, 0 )                   !  Flux from j+1 to j when v LT 0.
+         DO_2D( 1, 0, ji0, ji0 )
+            !                                !  Flux from j+1 to j when v LT 0.
             zalf          = MAX( 0._wp, -pvt(ji,jj) ) * pdt / psm(ji,jj+1,jl) 
             zalg  (ji,jj) = zalf
@@ -602,6 +636,6 @@
          END_2D
 
-         !  Readjust moments remaining in the box. 
-         DO_2D( 0, 0, 0, 0 )
+         DO_2D( 0, 0, ji0, ji0 )
+            !                                !  Readjust moments remaining in the box.
             zbt  =         zbet(ji,jj-1)
             zbt1 = ( 1.0 - zbet(ji,jj-1) )
@@ -614,8 +648,7 @@
             psxx(ji,jj,jl) = zbt * psxx(ji,jj,jl) + zbt1 * ( psxx(ji,jj,jl) - zfxx(ji,jj-1) )
             psxy(ji,jj,jl) = zalg1q(ji,jj-1) * psxy(ji,jj,jl)
-         END_2D
-
-         !   Put the temporary moments into appropriate neighboring boxes.    
-         DO_2D( 0, 0, 0, 0 )                   !  Flux from j to j+1 IF v GT 0.
+
+            !   Put the temporary moments into appropriate neighboring boxes.    
+            !                                !   Flux from j to j+1 IF v GT 0.
             zbt  =       zbet(ji,jj-1)
             zbt1 = 1.0 - zbet(ji,jj-1)
@@ -636,7 +669,6 @@
             psx (ji,jj,jl) =   zbt * ( psx (ji,jj,jl) + zfx (ji,jj-1) ) + zbt1 * psx (ji,jj,jl)
             psxx(ji,jj,jl) =   zbt * ( psxx(ji,jj,jl) + zfxx(ji,jj-1) ) + zbt1 * psxx(ji,jj,jl)
-         END_2D
-
-         DO_2D( 0, 0, 0, 0 )                   !  Flux from j+1 to j IF v LT 0.
+
+            !                                !  Flux from j+1 to j IF v LT 0.
             zbt  =       zbet(ji,jj)
             zbt1 = 1.0 - zbet(ji,jj)
@@ -656,11 +688,6 @@
             psxx(ji,jj,jl) = zbt * psxx(ji,jj,jl) + zbt1 * ( psxx(ji,jj,jl) + zfxx(ji,jj) )
          END_2D
-
+         !
       END DO
-
-      !-- Lateral boundary conditions
-      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm(:,:,1:jcat) , 'T',  1.0_wp, ps0 , 'T',  1.0_wp   &
-         &                                , psx             , 'T', -1.0_wp, psy , 'T', -1.0_wp   &   ! caution gradient ==> the sign changes
-         &                                , psxx            , 'T',  1.0_wp, psyy, 'T',  1.0_wp , psxy, 'T',  1.0_wp )
       !
    END SUBROUTINE adv_y
@@ -890,30 +917,30 @@
             !
             !                                                        ! ice thickness
-            CALL iom_get( numrir, jpdom_auto, 'sxice' , sxice  )
-            CALL iom_get( numrir, jpdom_auto, 'syice' , syice  )
+            CALL iom_get( numrir, jpdom_auto, 'sxice' , sxice , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'syice' , syice , psgn = -1._wp )
             CALL iom_get( numrir, jpdom_auto, 'sxxice', sxxice )
             CALL iom_get( numrir, jpdom_auto, 'syyice', syyice )
             CALL iom_get( numrir, jpdom_auto, 'sxyice', sxyice )
             !                                                        ! snow thickness
-            CALL iom_get( numrir, jpdom_auto, 'sxsn'  , sxsn   )
-            CALL iom_get( numrir, jpdom_auto, 'sysn'  , sysn   )
+            CALL iom_get( numrir, jpdom_auto, 'sxsn'  , sxsn  , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sysn'  , sysn  , psgn = -1._wp )
             CALL iom_get( numrir, jpdom_auto, 'sxxsn' , sxxsn  )
             CALL iom_get( numrir, jpdom_auto, 'syysn' , syysn  )
             CALL iom_get( numrir, jpdom_auto, 'sxysn' , sxysn  )
             !                                                        ! ice concentration
-            CALL iom_get( numrir, jpdom_auto, 'sxa'   , sxa    )
-            CALL iom_get( numrir, jpdom_auto, 'sya'   , sya    )
+            CALL iom_get( numrir, jpdom_auto, 'sxa'   , sxa   , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sya'   , sya   , psgn = -1._wp )
             CALL iom_get( numrir, jpdom_auto, 'sxxa'  , sxxa   )
             CALL iom_get( numrir, jpdom_auto, 'syya'  , syya   )
             CALL iom_get( numrir, jpdom_auto, 'sxya'  , sxya   )
             !                                                        ! ice salinity
-            CALL iom_get( numrir, jpdom_auto, 'sxsal' , sxsal  )
-            CALL iom_get( numrir, jpdom_auto, 'sysal' , sysal  )
+            CALL iom_get( numrir, jpdom_auto, 'sxsal' , sxsal , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sysal' , sysal , psgn = -1._wp )
             CALL iom_get( numrir, jpdom_auto, 'sxxsal', sxxsal )
             CALL iom_get( numrir, jpdom_auto, 'syysal', syysal )
             CALL iom_get( numrir, jpdom_auto, 'sxysal', sxysal )
             !                                                        ! ice age
-            CALL iom_get( numrir, jpdom_auto, 'sxage' , sxage  )
-            CALL iom_get( numrir, jpdom_auto, 'syage' , syage  )
+            CALL iom_get( numrir, jpdom_auto, 'sxage' , sxage , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'syage' , syage , psgn = -1._wp )
             CALL iom_get( numrir, jpdom_auto, 'sxxage', sxxage )
             CALL iom_get( numrir, jpdom_auto, 'syyage', syyage )
@@ -922,6 +949,6 @@
             DO jk = 1, nlay_s
                WRITE(zchar1,'(I2.2)') jk
-               znam = 'sxc0'//'_l'//zchar1  ;   CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sxc0 (:,:,jk,:) = z3d(:,:,:)
-               znam = 'syc0'//'_l'//zchar1  ;   CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   syc0 (:,:,jk,:) = z3d(:,:,:)
+               znam = 'sxc0'//'_l'//zchar1  ;   CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp )   ;   sxc0 (:,:,jk,:) = z3d(:,:,:)
+               znam = 'syc0'//'_l'//zchar1  ;   CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp )   ;   syc0 (:,:,jk,:) = z3d(:,:,:)
                znam = 'sxxc0'//'_l'//zchar1 ;   CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sxxc0(:,:,jk,:) = z3d(:,:,:)
                znam = 'syyc0'//'_l'//zchar1 ;   CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   syyc0(:,:,jk,:) = z3d(:,:,:)
@@ -931,6 +958,6 @@
             DO jk = 1, nlay_i
                WRITE(zchar1,'(I2.2)') jk
-               znam = 'sxe'//'_l'//zchar1   ;   CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sxe (:,:,jk,:) = z3d(:,:,:)
-               znam = 'sye'//'_l'//zchar1   ;   CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sye (:,:,jk,:) = z3d(:,:,:)
+               znam = 'sxe'//'_l'//zchar1   ;   CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp )   ;   sxe (:,:,jk,:) = z3d(:,:,:)
+               znam = 'sye'//'_l'//zchar1   ;   CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp )   ;   sye (:,:,jk,:) = z3d(:,:,:)
                znam = 'sxxe'//'_l'//zchar1  ;   CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sxxe(:,:,jk,:) = z3d(:,:,:)
                znam = 'syye'//'_l'//zchar1  ;   CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   syye(:,:,jk,:) = z3d(:,:,:)
@@ -940,12 +967,12 @@
             IF( ln_pnd_LEV ) THEN                                    ! melt pond fraction
                IF( iom_varid( numror, 'sxap', ldstop = .FALSE. ) > 0 ) THEN
-                  CALL iom_get( numrir, jpdom_auto, 'sxap' , sxap  )
-                  CALL iom_get( numrir, jpdom_auto, 'syap' , syap  )
+                  CALL iom_get( numrir, jpdom_auto, 'sxap' , sxap , psgn = -1._wp )
+                  CALL iom_get( numrir, jpdom_auto, 'syap' , syap , psgn = -1._wp )
                   CALL iom_get( numrir, jpdom_auto, 'sxxap', sxxap )
                   CALL iom_get( numrir, jpdom_auto, 'syyap', syyap )
                   CALL iom_get( numrir, jpdom_auto, 'sxyap', sxyap )
                   !                                                     ! melt pond volume
-                  CALL iom_get( numrir, jpdom_auto, 'sxvp' , sxvp  )
-                  CALL iom_get( numrir, jpdom_auto, 'syvp' , syvp  )
+                  CALL iom_get( numrir, jpdom_auto, 'sxvp' , sxvp , psgn = -1._wp )
+                  CALL iom_get( numrir, jpdom_auto, 'syvp' , syvp , psgn = -1._wp )
                   CALL iom_get( numrir, jpdom_auto, 'sxxvp', sxxvp )
                   CALL iom_get( numrir, jpdom_auto, 'syyvp', syyvp )
@@ -958,6 +985,6 @@
                IF ( ln_pnd_lids ) THEN                               ! melt pond lid volume
                   IF( iom_varid( numror, 'sxvl', ldstop = .FALSE. ) > 0 ) THEN
-                     CALL iom_get( numrir, jpdom_auto, 'sxvl' , sxvl  )
-                     CALL iom_get( numrir, jpdom_auto, 'syvl' , syvl  )
+                     CALL iom_get( numrir, jpdom_auto, 'sxvl' , sxvl , psgn = -1._wp )
+                     CALL iom_get( numrir, jpdom_auto, 'syvl' , syvl , psgn = -1._wp )
                      CALL iom_get( numrir, jpdom_auto, 'sxxvl', sxxvl )
                      CALL iom_get( numrir, jpdom_auto, 'syyvl', syyvl )
