Index: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_fortran.F90
===================================================================
--- NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_fortran.F90	(revision 14286)
+++ NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_fortran.F90	(revision 14644)
@@ -169,5 +169,5 @@
       !
       DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
-         IF( MOD(mig(ji), 3) == MOD(nn_hls, 3) .AND.   &
+         IF( MOD(mig(ji), 3) == MOD(nn_hls, 3) .AND.   &              ! 1st bottom left corner always at (Nis0-1, Njs0-1)
            & MOD(mjg(jj), 3) == MOD(nn_hls, 3)         ) THEN         ! bottom left corner of a 3x3 box
             ji2 = MIN(mig(ji)+2, jpiglo) - nimpp + 1                  ! right position of the box
@@ -179,19 +179,21 @@
       END_2D
       CALL lbc_lnk( 'lib_fortran', p2d, 'T', 1.0_wp )
-      ! no need for 2nd exchange when nn_hls = 2
-      IF( nn_hls /= 2 ) THEN
-         IF( nbondi /= -1 ) THEN
-            IF( MOD(mig(    1), 3) == 1 )   p2d(    1,:) = p2d(    2,:)
-            IF( MOD(mig(    1), 3) == 2 )   p2d(    2,:) = p2d(    1,:)
-         ENDIF
-         IF( nbondi /=  1 ) THEN
+      ! no need for 2nd exchange when nn_hls > 1
+      IF( nn_hls == 1 ) THEN
+         IF( mpiRnei(nn_hls,jpwe) > -1 ) THEN   ! 1st column was changed during the previous call to lbc_lnk
+            IF( MOD(mig(    1), 3) == 1 )   &   ! 1st box start at i=1 -> column 1 to 3 correctly computed locally
+               p2d(    1,:) = p2d(    2,:)      ! previous lbc_lnk corrupted column 1 -> put it back using column 2 
+            IF( MOD(mig(    1), 3) == 2 )   &   ! 1st box start at i=3 -> column 1 and 2 correctly computed on west neighbourh
+               p2d(    2,:) = p2d(    1,:)      !  previous lbc_lnk fix column 1 -> copy it to column 2 
+         ENDIF
+         IF( mpiRnei(nn_hls,jpea) > -1 ) THEN
             IF( MOD(mig(jpi-2), 3) == 1 )   p2d(  jpi,:) = p2d(jpi-1,:)
             IF( MOD(mig(jpi-2), 3) == 0 )   p2d(jpi-1,:) = p2d(  jpi,:)
          ENDIF
-         IF( nbondj /= -1 ) THEN
+         IF( mpiRnei(nn_hls,jpso) > -1 ) THEN
             IF( MOD(mjg(    1), 3) == 1 )   p2d(:,    1) = p2d(:,    2)
             IF( MOD(mjg(    1), 3) == 2 )   p2d(:,    2) = p2d(:,    1)
          ENDIF
-         IF( nbondj /=  1 ) THEN
+         IF( mpiRnei(nn_hls,jpno) > -1 ) THEN
             IF( MOD(mjg(jpj-2), 3) == 1 )   p2d(:,  jpj) = p2d(:,jpj-1)
             IF( MOD(mjg(jpj-2), 3) == 0 )   p2d(:,jpj-1) = p2d(:,  jpj)
@@ -223,5 +225,5 @@
          !
          DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
-            IF( MOD(mig(ji), 3) == MOD(nn_hls, 3) .AND.   &
+            IF( MOD(mig(ji), 3) == MOD(nn_hls, 3) .AND.   &              ! 1st bottom left corner always at (Nis0-1, Njs0-1)
               & MOD(mjg(jj), 3) == MOD(nn_hls, 3)         ) THEN         ! bottom left corner of a 3x3 box
                ji2 = MIN(mig(ji)+2, jpiglo) - nimpp + 1                  ! right position of the box
@@ -234,19 +236,21 @@
       END DO
       CALL lbc_lnk( 'lib_fortran', p3d, 'T', 1.0_wp )
-      ! no need for 2nd exchange when nn_hls = 2
-      IF( nn_hls /= 2 ) THEN
-         IF( nbondi /= -1 ) THEN
-            IF( MOD(mig(    1), 3) == 1 )   p3d(    1,:,:) = p3d(    2,:,:)
-            IF( MOD(mig(    1), 3) == 2 )   p3d(    2,:,:) = p3d(    1,:,:)
-         ENDIF
-         IF( nbondi /=  1 ) THEN
+      ! no need for 2nd exchange when nn_hls > 1
+      IF( nn_hls == 1 ) THEN
+         IF( mpiRnei(nn_hls,jpwe) > -1 ) THEN    ! 1st column was changed during the previous call to lbc_lnk
+            IF( MOD(mig(    1), 3) == 1 )   &    ! 1st box start at i=1 -> column 1 to 3 correctly computed locally
+               p3d(    1,:,:) = p3d(    2,:,:)   ! previous lbc_lnk corrupted column 1 -> put it back using column 2 
+            IF( MOD(mig(    1), 3) == 2 )   &    ! 1st box start at i=3 -> column 1 and 2 correctly computed on west neighbourh
+               p3d(    2,:,:) = p3d(    1,:,:)   !  previous lbc_lnk fix column 1 -> copy it to column 2 
+         ENDIF
+         IF( mpiRnei(nn_hls,jpea) > -1 ) THEN
             IF( MOD(mig(jpi-2), 3) == 1 )   p3d(  jpi,:,:) = p3d(jpi-1,:,:)
             IF( MOD(mig(jpi-2), 3) == 0 )   p3d(jpi-1,:,:) = p3d(  jpi,:,:)
          ENDIF
-         IF( nbondj /= -1 ) THEN
+         IF( mpiRnei(nn_hls,jpso) > -1 ) THEN
             IF( MOD(mjg(    1), 3) == 1 )   p3d(:,    1,:) = p3d(:,    2,:)
             IF( MOD(mjg(    1), 3) == 2 )   p3d(:,    2,:) = p3d(:,    1,:)
          ENDIF
-         IF( nbondj /=  1 ) THEN
+         IF( mpiRnei(nn_hls,jpno) > -1 ) THEN
             IF( MOD(mjg(jpj-2), 3) == 1 )   p3d(:,  jpj,:) = p3d(:,jpj-1,:)
             IF( MOD(mjg(jpj-2), 3) == 0 )   p3d(:,jpj-1,:) = p3d(:,  jpj,:)
