Index: NEMO/branches/2021/dev_r14383_PISCES_NEWDEV_PISCO/src/OCE/LBC/lbc_lnk_neicoll_generic.h90
===================================================================
--- NEMO/branches/2021/dev_r14383_PISCES_NEWDEV_PISCO/src/OCE/LBC/lbc_lnk_neicoll_generic.h90	(revision 14448)
+++ NEMO/branches/2021/dev_r14383_PISCES_NEWDEV_PISCO/src/OCE/LBC/lbc_lnk_neicoll_generic.h90	(revision 15127)
@@ -26,4 +26,5 @@
       INTEGER, DIMENSION(8)  ::   isizej, ishtSj, ishtRj, ishtPj
       INTEGER, DIMENSION(8)  ::   ifill, iszall
+      INTEGER, DIMENSION(8)  ::   jnf
       INTEGER, DIMENSION(:), ALLOCATABLE  ::   iScnt, iRcnt    ! number of elements to be sent/received
       INTEGER, DIMENSION(:), ALLOCATABLE  ::   iSdpl, iRdpl    ! displacement in halos arrays
@@ -31,5 +32,4 @@
       REAL(PRECISION) ::   zland
       LOGICAL  ::   ll4only                                    ! default: 8 neighbourgs
-      LOGICAL  ::   ll_IdoNFold
       !!----------------------------------------------------------------------
       !
@@ -101,6 +101,5 @@
       END DO
       ! north fold treatment
-      ll_IdoNFold = l_IdoNFold .AND. ifill(jpno) /= jpfillnothing
-      IF( ll_IdoNFold ) THEN
+      IF( l_IdoNFold ) THEN
          ifill_nfd = ifill(jpno)             ! if we are here, this means llrecv(jpno) = .false. and l_SelfPerio(jpno) = .false.
          ifill( (/jpno/) ) = jpfillnothing   ! we do north fold -> do nothing for northern halo
@@ -192,28 +191,43 @@
       !
       idx = 1
+      ! MPI3 bug fix when domain decomposition has 2 columns/rows
+      IF (jpni .eq. 2) THEN
+         IF (jpnj .eq. 2) THEN
+            jnf(1:8) = (/ 2, 1, 4, 3, 8, 7, 6, 5 /)
+         ELSE
+            jnf(1:8) = (/ 2, 1, 3, 4, 6, 5, 8, 7 /)
+         ENDIF
+      ELSE
+         IF (jpnj .eq. 2) THEN
+            jnf(1:8) = (/ 1, 2, 4, 3, 7, 8, 5, 6 /)
+         ELSE
+            jnf(1:8) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
+         ENDIF
+      ENDIF
+
       DO jn = 1, 8
-         ishti = ishtRi(jn)
-         ishtj = ishtRj(jn)
-         SELECT CASE ( ifill(jn) )
+         ishti = ishtRi(jnf(jn))
+         ishtj = ishtRj(jnf(jn))
+         SELECT CASE ( ifill(jnf(jn)) )
          CASE ( jpfillnothing )               ! no filling 
          CASE ( jpfillmpi   )                 ! fill with data received by MPI
-            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jnf(jn))  ;  DO ji = 1,isizei(jnf(jn))
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = BUFFRCV(idx)
                idx = idx + 1
             END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
          CASE ( jpfillperio )                 ! use periodicity
-            ishti2 = ishtPi(jn)
-            ishtj2 = ishtPj(jn)
-            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+            ishti2 = ishtPi(jnf(jn))
+            ishtj2 = ishtPj(jnf(jn))
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jnf(jn))  ;  DO ji = 1,isizei(jnf(jn))
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
             END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
          CASE ( jpfillcopy  )                 ! filling with inner domain values
-            ishti2 = ishtSi(jn)
-            ishtj2 = ishtSj(jn)
-            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+            ishti2 = ishtSi(jnf(jn))
+            ishtj2 = ishtSj(jnf(jn))
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jnf(jn))  ;  DO ji = 1,isizei(jnf(jn))
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
             END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
          CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jnf(jn))  ;  DO ji = 1,isizei(jnf(jn))
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = zland
             END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
@@ -251,5 +265,5 @@
       ! ------------------------------- !
       !
-      IF( ll_IdoNFold ) THEN
+      IF( l_IdoNFold ) THEN
          IF( jpni == 1 )  THEN   ;   CALL lbc_nfd( ptab, cd_nat, psgn                  , ihls, ipf )   ! self NFold
          ELSE                    ;   CALL mpp_nfd( ptab, cd_nat, psgn, ifill_nfd, zland, ihls, ipf )   ! mpi  NFold
