Index: /NEMO/releases/r4.0/r4.0-HEAD/src/ICE/icedyn_adv_pra.F90
===================================================================
--- /NEMO/releases/r4.0/r4.0-HEAD/src/ICE/icedyn_adv_pra.F90	(revision 13553)
+++ /NEMO/releases/r4.0/r4.0-HEAD/src/ICE/icedyn_adv_pra.F90	(revision 13554)
@@ -362,4 +362,5 @@
       !! 
       INTEGER  ::   ji, jj, jl, jcat                     ! dummy loop indices
+      INTEGER  ::   jjmin, jjmax                         ! dummy loop indices
       REAL(wp) ::   zs1max, zslpmax, ztemp               ! local scalars
       REAL(wp) ::   zs1new, zalf , zalfq , zbt           !   -      -
@@ -369,4 +370,9 @@
       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
+      jjmin = 2     - NINT(pcrh)   ! 1   or 2
+      jjmax = jpjm1 + NINT(pcrh)   ! jpj or jpj-1
       !
       jcat = SIZE( ps0 , 3 )   ! size of input arrays
@@ -375,5 +381,6 @@
          !
          ! Limitation of moments.                                           
-         DO jj = 2, jpjm1
+         DO jj = jjmin, jjmax
+            
             DO ji = 1, jpi
                !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
@@ -383,6 +390,5 @@
                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) )  )
+               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
 
@@ -393,10 +399,7 @@
                psyy(ji,jj,jl) = psyy(ji,jj,jl) * rswitch
                psxy(ji,jj,jl) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj,jl) ) ) * rswitch
-            END DO
-         END DO
-
-         !  Calculate fluxes and moments between boxes i<-->i+1              
-         DO jj = 2, jpjm1                      !  Flux from i to i+1 WHEN u GT 0 
-            DO ji = 1, jpi
+
+               !  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)
@@ -413,5 +416,5 @@
                zfyy(ji,jj)  =  zalf  *   psyy(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)
@@ -422,8 +425,7 @@
                psxy(ji,jj,jl)  =  zalf1q * psxy(ji,jj,jl)
             END DO
-         END DO
-
-         DO jj = 2, jpjm1                      !  Flux from i+1 to i when u LT 0.
+
             DO ji = 1, fs_jpim1
+               !                                !  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
@@ -443,11 +445,9 @@
                zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *    psyy(ji+1,jj,jl)
             END DO
-         END DO
-
-         DO jj = 2, jpjm1                     !  Readjust moments remaining in the box. 
-            DO ji = fs_2, fs_jpim1
+
+            DO ji = fs_2, fs_jpim1 
                zbt  =       zbet(ji-1,jj)
                zbt1 = 1.0 - zbet(ji-1,jj)
-               !
+               !                                !  Readjust moments remaining in the box.
                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) )
@@ -457,10 +457,7 @@
                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 DO
-         END DO
-
-         !   Put the temporary moments into appropriate neighboring boxes.    
-         DO jj = 2, jpjm1                     !   Flux from i to i+1 IF u GT 0.
-            DO ji = fs_2, fs_jpim1
+
+               !   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)
@@ -480,9 +477,6 @@
                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 DO
-         END DO
-
-         DO jj = 2, jpjm1                      !  Flux from i+1 to i IF u LT 0.
-            DO ji = fs_2, fs_jpim1
+
+               !                                !  Flux from i+1 to i IF u LT 0.
                zbt  =       zbet(ji,jj)
                zbt1 = 1.0 - zbet(ji,jj)
@@ -502,4 +496,5 @@
                psyy(ji,jj,jl) = zbt * psyy(ji,jj,jl) + zbt1 * ( psyy(ji,jj,jl) + zfyy(ji,jj) )
             END DO
+            
          END DO
 
@@ -507,7 +502,9 @@
 
       !-- Lateral boundary conditions
-      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm(:,:,1:jcat) , 'T',  1., ps0 , 'T',  1.   &
-         &                                , psx             , 'T', -1., psy , 'T', -1.   &   ! caution gradient ==> the sign changes
-         &                                , psxx            , 'T',  1., psyy, 'T',  1. , psxy, 'T',  1. )
+      IF( NINT( pcrh ) == 0 ) THEN   ! adv_x is called after adv_y
+         CALL lbc_lnk_multi( 'icedyn_adv_pra', psm(:,:,1:jcat) , 'T',  1., ps0 , 'T',  1.   &
+            &                                , psx             , 'T', -1., psy , 'T', -1.   &   ! caution gradient ==> the sign changes
+            &                                , psxx            , 'T',  1., psyy, 'T',  1. , psxy, 'T',  1. )
+      ENDIF
       !
    END SUBROUTINE adv_x
@@ -531,4 +528,5 @@
       !!
       INTEGER  ::   ji, jj, jl, jcat                     ! dummy loop indices
+      INTEGER  ::   jimin, jimax                         ! dummy loop indices
       REAL(wp) ::   zs1max, zslpmax, ztemp               ! temporary scalars
       REAL(wp) ::   zs1new, zalf , zalfq , zbt           !    -         -
@@ -538,4 +536,9 @@
       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
+      jimin = 2     - NINT(pcrh)   ! 1   or 2
+      jimax = jpim1 + NINT(pcrh)   ! jpi or jpi-1
       !
       jcat = SIZE( ps0 , 3 )   ! size of input arrays
@@ -545,6 +548,6 @@
          ! Limitation of moments.
          DO jj = 1, jpj
-            DO ji = fs_2, fs_jpim1
-               !  Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
+            DO ji = jimin, jimax
+               !  Initialize volumes of boxes (=area if adv_y first called, =psm otherwise)
                psm(ji,jj,jl) = MAX(  pcrh * e1e2t(ji,jj) + ( 1.0 - pcrh ) * psm(ji,jj,jl) , epsi20  )
                !
@@ -552,6 +555,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
                !
@@ -562,10 +564,7 @@
                psyy(ji,jj,jl) = zs2new         * rswitch
                psxy(ji,jj,jl) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj,jl) ) ) * rswitch
-            END DO
-         END DO
  
-         !  Calculate fluxes and moments between boxes j<-->j+1              
-         DO jj = 1, jpj                     !  Flux from j to j+1 WHEN v GT 0   
-            DO ji = fs_2, fs_jpim1
+               !  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)
@@ -582,5 +581,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)
@@ -593,6 +592,7 @@
          END DO
          !
-         DO jj = 1, jpjm1                   !  Flux from j+1 to j when v LT 0.
-            DO ji = fs_2, fs_jpim1
+         DO jj = 1, jpjm1
+            DO ji = jimin, jimax
+               !                                !  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
@@ -614,7 +614,7 @@
          END DO
 
-         !  Readjust moments remaining in the box. 
          DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1
+            DO ji = jimin, jimax
+               !                                !  Readjust moments remaining in the box.
                zbt  =         zbet(ji,jj-1)
                zbt1 = ( 1.0 - zbet(ji,jj-1) )
@@ -627,10 +627,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 DO
-         END DO
-
-         !   Put the temporary moments into appropriate neighboring boxes.    
-         DO jj = 2, jpjm1                    !   Flux from j to j+1 IF v GT 0.
-            DO ji = fs_2, fs_jpim1
+
+               !   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)
@@ -651,9 +648,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 DO
-         END DO
-
-         DO jj = 2, jpjm1                      !  Flux from j+1 to j IF v LT 0.
-            DO ji = fs_2, fs_jpim1
+
+               !                                !  Flux from j+1 to j IF v LT 0.
                zbt  =       zbet(ji,jj)
                zbt1 = 1.0 - zbet(ji,jj)
@@ -678,7 +672,9 @@
 
       !-- Lateral boundary conditions
-      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm(:,:,1:jcat) , 'T',  1., ps0 , 'T',  1.   &
-         &                                , psx             , 'T', -1., psy , 'T', -1.   &   ! caution gradient ==> the sign changes
-         &                                , psxx            , 'T',  1., psyy, 'T',  1. , psxy, 'T',  1. )
+      IF( NINT( pcrh ) == 0 ) THEN   ! adv_y is called after adv_x
+         CALL lbc_lnk_multi( 'icedyn_adv_pra', psm(:,:,1:jcat) , 'T',  1., ps0 , 'T',  1.   &
+            &                                , psx             , 'T', -1., psy , 'T', -1.   &   ! caution gradient ==> the sign changes
+            &                                , psxx            , 'T',  1., psyy, 'T',  1. , psxy, 'T',  1. )
+      ENDIF
       !
    END SUBROUTINE adv_y
