Index: /NEMO/branches/2019/dev_r11470_HPC_12_mpi3/src/OCE/LBC/mpp_nc_generic.h90
===================================================================
--- /NEMO/branches/2019/dev_r11470_HPC_12_mpi3/src/OCE/LBC/mpp_nc_generic.h90	(revision 11954)
+++ /NEMO/branches/2019/dev_r11470_HPC_12_mpi3/src/OCE/LBC/mpp_nc_generic.h90	(revision 11955)
@@ -183,68 +183,138 @@
       ! --------------------------------------------------- !
       !
-      ! 2.1 fill weastern halo
+      !!! Patch to solve MPI3 bug when we have only two processes columns
+      IF(jpni .eq. 2) THEN
+         ! ---------------------
+         ! 2.2 fill eastern halo
+         ! ---------------------
+         idx = 1
+         ishift = jpi - ihl                ! fill halo from ji = jpi-ihl+1 to jpi 
+         SELECT CASE ( ifill_ea )
+         CASE ( jpfillnothing )               ! no filling 
+         CASE ( jpfillmpi   )                 ! use data received by MPI 
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv(idx)   ! jpi - ihl + 1 -> jpi
+               idx = idx + 1
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         CASE ( jpfillperio )                 ! use east-weast periodicity
+            ishift2 = ihl
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         CASE ( jpfillcopy  )                 ! filling with inner domain values
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         CASE ( jpfillcst   )                 ! filling with constant value
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
+            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         END SELECT
+         ! ----------------------
+         ! 2.1 fill weastern halo
+         ! ----------------------
+         SELECT CASE ( ifill_we )
+         CASE ( jpfillnothing )               ! no filling 
+         CASE ( jpfillmpi   )                 ! use data received by MPI 
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)   ! 1 -> ihl
+               idx = idx + 1
+            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+         CASE ( jpfillperio )                 ! use east-weast periodicity
+            ishift2 = jpi - 2 * ihl
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
+            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         CASE ( jpfillcopy  )                 ! filling with inner domain values
+            DO jf = 1, ipf                               ! number of arrays to be treated
+               IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
+                  DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+                     ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ihl+1,jj,jk,jl,jf)
+                  END DO   ;   END DO   ;   END DO   ;   END DO
+               ENDIF
+            END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         CASE ( jpfillcst   )                 ! filling with constant value
+            DO jf = 1, ipf                               ! number of arrays to be treated
+               IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
+                  DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+                     ARRAY_IN(ji,jj,jk,jl,jf) = zland
+                  END DO;   END DO   ;   END DO   ;   END DO
+               ENDIF
+            END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         END SELECT
+
+      ELSE
+         ! ----------------------
+         ! 2.1 fill weastern halo
+         ! ----------------------
+         idx = 1
+         SELECT CASE ( ifill_we )
+         CASE ( jpfillnothing )               ! no filling 
+         CASE ( jpfillmpi   )                 ! use data received by MPI 
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)   ! 1 -> ihl
+               idx = idx + 1
+            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+         CASE ( jpfillperio )                 ! use east-weast periodicity
+            ishift2 = jpi - 2 * ihl
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
+            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         CASE ( jpfillcopy  )                 ! filling with inner domain values
+            DO jf = 1, ipf                               ! number of arrays to be treated
+               IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
+                  DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+                     ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ihl+1,jj,jk,jl,jf)
+                  END DO   ;   END DO   ;   END DO   ;   END DO
+               ENDIF
+            END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         CASE ( jpfillcst   )                 ! filling with constant value
+            DO jf = 1, ipf                               ! number of arrays to be treated
+               IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
+                  DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+                     ARRAY_IN(ji,jj,jk,jl,jf) = zland
+                  END DO;   END DO   ;   END DO   ;   END DO
+               ENDIF
+            END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         END SELECT
+         ! ---------------------
+         ! 2.2 fill eastern halo
+         ! ---------------------
+         ishift = jpi - ihl                ! fill halo from ji = jpi-ihl+1 to jpi 
+         SELECT CASE ( ifill_ea )
+         CASE ( jpfillnothing )               ! no filling 
+         CASE ( jpfillmpi   )                 ! use data received by MPI 
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv(idx)   ! jpi - ihl + 1 -> jpi
+               idx = idx + 1
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         CASE ( jpfillperio )                 ! use east-weast periodicity
+            ishift2 = ihl
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         CASE ( jpfillcopy  )                 ! filling with inner domain values
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         CASE ( jpfillcst   )                 ! filling with constant value
+            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
+               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
+            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+            idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
+         END SELECT
+      END IF
       ! ----------------------
-      idx = 1
-      SELECT CASE ( ifill_we )
-      CASE ( jpfillnothing )               ! no filling 
-      CASE ( jpfillmpi   )                 ! use data received by MPI 
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
-            ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)   ! 1 -> ihl
-            idx = idx + 1
-         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillperio )                 ! use east-weast periodicity
-         ishift2 = jpi - 2 * ihl
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
-            ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
-         idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
-      CASE ( jpfillcopy  )                 ! filling with inner domain values
-         DO jf = 1, ipf                               ! number of arrays to be treated
-            IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
-               DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
-                  ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ihl+1,jj,jk,jl,jf)
-               END DO   ;   END DO   ;   END DO   ;   END DO
-            ENDIF
-         END DO
-         idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
-      CASE ( jpfillcst   )                 ! filling with constant value
-         DO jf = 1, ipf                               ! number of arrays to be treated
-            IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
-               DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
-                  ARRAY_IN(ji,jj,jk,jl,jf) = zland
-               END DO;   END DO   ;   END DO   ;   END DO
-            ENDIF
-         END DO
-         idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
-      END SELECT
-      !
-      ! 2.2 fill eastern halo
-      ! ---------------------
-      ishift = jpi - ihl                ! fill halo from ji = jpi-ihl+1 to jpi 
-      SELECT CASE ( ifill_ea )
-      CASE ( jpfillnothing )               ! no filling 
-      CASE ( jpfillmpi   )                 ! use data received by MPI 
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
-            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv(idx)   ! jpi - ihl + 1 -> jpi
-            idx = idx + 1
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillperio )                 ! use east-weast periodicity
-         ishift2 = ihl
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
-            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
-      CASE ( jpfillcopy  )                 ! filling with inner domain values
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
-            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
-      CASE ( jpfillcst   )                 ! filling with constant value
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = ihl + 1, jpj - ihl   ;   DO ji = 1, ihl
-            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
-         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
-         idx = idx + (jpj-2*ihl)*ihl*ipk*ipl*ipf
-      END SELECT
-      !
       ! 2.3 fill southern halo
       ! ----------------------
@@ -281,5 +351,5 @@
          idx = idx + (jpi-2*ihl)*ihl*ipk*ipl*ipf
       END SELECT
-      !
+      ! ----------------------
       ! 2.4 fill northern halo
       ! ----------------------
