Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/lbc_lnk_generic.h90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/lbc_lnk_generic.h90	(revision 10316)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/lbc_lnk_generic.h90	(revision 10329)
@@ -78,10 +78,5 @@
       ! ------------------------------- !
       !
-      IF( PRESENT( cd_mpp ) ) THEN     !==  halos filled with inner values  ==!
-         !
-         ! only fill the overlap area and extra allows 
-         ! this is in mpp case. In this module, just do nothing
-         !
-      ELSE                             !==  standard close or cyclic treatment  ==!
+      IF( .NOT. PRESENT( cd_mpp ) ) THEN  !==  standard close or cyclic treatment  ==!
          !
          DO jf = 1, ipf                   ! number of arrays to be treated
Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/mpp_lnk_generic.h90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/mpp_lnk_generic.h90	(revision 10316)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/mpp_lnk_generic.h90	(revision 10329)
@@ -75,7 +75,4 @@
       IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
       !
-      ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,2), zt3sn(jpi,nn_hls,ipk,ipl,ipf,2),   &
-         &      zt3ew(jpj,nn_hls,ipk,ipl,ipf,2), zt3we(jpj,nn_hls,ipk,ipl,ipf,2)  )
-      !
       IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value
       ELSE                         ;   zland = 0._wp     ! zero by default
@@ -86,26 +83,5 @@
       ! ------------------------------- !
       !
-      IF( PRESENT( cd_mpp ) ) THEN     !==  halos filled with inner values  ==!
-         !
-         DO jf = 1, ipf                      ! number of arrays to be treated
-            !
-            DO jl = 1, ipl                   ! CAUTION: ptab is defined only between nld and nle
-               DO jk = 1, ipk
-                  DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
-                     ARRAY_IN(nldi  :nlei  ,jj,jk,jl,jf) = ARRAY_IN(nldi:nlei,nlej,jk,jl,jf)
-                     ARRAY_IN(1     :nldi-1,jj,jk,jl,jf) = ARRAY_IN(nldi     ,nlej,jk,jl,jf)
-                     ARRAY_IN(nlei+1:nlci  ,jj,jk,jl,jf) = ARRAY_IN(     nlei,nlej,jk,jl,jf)
-                  END DO
-                  DO ji = nlci+1, jpi                 ! added column(s) (full)
-                     ARRAY_IN(ji,nldj  :nlej  ,jk,jl,jf) = ARRAY_IN(nlei,nldj:nlej,jk,jl,jf)
-                     ARRAY_IN(ji,1     :nldj-1,jk,jl,jf) = ARRAY_IN(nlei,nldj     ,jk,jl,jf)
-                     ARRAY_IN(ji,nlej+1:jpj   ,jk,jl,jf) = ARRAY_IN(nlei,     nlej,jk,jl,jf)
-                  END DO
-               END DO
-            END DO
-            !
-         END DO
-         !
-      ELSE                              !==  standard close or cyclic treatment  ==!
+      IF( .NOT. PRESENT( cd_mpp ) ) THEN     !==  standard close or cyclic treatment  ==!
          !
          DO jf = 1, ipf                      ! number of arrays to be treated
@@ -136,6 +112,20 @@
       ! we play with the neigbours AND the row number because of the periodicity
       !
+      IF( ABS(nbondi) == 1 ) ALLOCATE( zt3ew(jpj,nn_hls,ipk,ipl,ipf,1), zt3we(jpj,nn_hls,ipk,ipl,ipf,1) )
+      IF(     nbondi  == 0 ) ALLOCATE( zt3ew(jpj,nn_hls,ipk,ipl,ipf,2), zt3we(jpj,nn_hls,ipk,ipl,ipf,2) )
+      !
       SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
-      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
+      CASE ( -1 )
+         iihom = nlci-nreci
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     zt3we(:,jh,jk,jl,jf,1) = ARRAY_IN(iihom +jh,:,jk,jl,jf)
+                  END DO
+               END DO
+            END DO
+         END DO
+      CASE ( 0 )
          iihom = nlci-nreci
          DO jf = 1, ipf
@@ -149,6 +139,16 @@
             END DO
          END DO
-      END SELECT
-      !
+      CASE ( 1 )
+         iihom = nlci-nreci
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     zt3ew(:,jh,jk,jl,jf,1) = ARRAY_IN(nn_hls+jh,:,jk,jl,jf)
+                  END DO
+               END DO
+            END DO
+         END DO
+      END SELECT
       !                           ! Migrations
       imigr = nn_hls * jpj * ipk * ipl * ipf      
@@ -159,5 +159,5 @@
       CASE ( -1 )
          CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req1 )
-         CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
+         CALL mpprecv( 1, zt3ew(1,1,1,1,1,1), imigr, noea )
          IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err)
       CASE ( 0 )
@@ -170,10 +170,9 @@
       CASE ( 1 )
          CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
-         CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
+         CALL mpprecv( 2, zt3we(1,1,1,1,1,1), imigr, nowe )
          IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
       END SELECT
       !
       IF( ln_timing ) CALL tic_tac(.FALSE.)
-      !
       !
       !                           ! Write Dirichlet lateral conditions
@@ -186,5 +185,5 @@
                DO jk = 1, ipk
                   DO jh = 1, nn_hls
-                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
+                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,1)
                   END DO
                END DO
@@ -207,10 +206,12 @@
                DO jk = 1, ipk
                   DO jh = 1, nn_hls
-                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         END DO
-      END SELECT
+                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,1)
+                  END DO
+               END DO
+            END DO
+         END DO
+      END SELECT
+      !
+      IF( nbondi /= 2 ) DEALLOCATE( zt3ew, zt3we )
 
       ! 3. North and south directions
@@ -218,5 +219,20 @@
       ! always closed : we play only with the neigbours
       !
-      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+      IF( ABS(nbondj) == 1 ) ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,1), zt3sn(jpi,nn_hls,ipk,ipl,ipf,1) )
+      IF(     nbondj  == 0 ) ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,2), zt3sn(jpi,nn_hls,ipk,ipl,ipf,2) )
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         ijhom = nlcj-nrecj
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     zt3sn(:,jh,jk,jl,jf,1) = ARRAY_IN(:,ijhom +jh,jk,jl,jf)
+                  END DO
+               END DO
+            END DO
+         END DO
+      CASE ( 0 )
          ijhom = nlcj-nrecj
          DO jf = 1, ipf
@@ -230,5 +246,16 @@
             END DO
          END DO
-      ENDIF
+      CASE ( 1 )
+         ijhom = nlcj-nrecj
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     zt3ns(:,jh,jk,jl,jf,1) = ARRAY_IN(:,nn_hls+jh,jk,jl,jf)
+                  END DO
+               END DO
+            END DO
+         END DO
+      END SELECT
       !
       !                           ! Migrations
@@ -240,5 +267,5 @@
       CASE ( -1 )
          CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req1 )
-         CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
+         CALL mpprecv( 3, zt3ns(1,1,1,1,1,1), imigr, nono )
          IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err )
       CASE ( 0 )
@@ -251,5 +278,5 @@
       CASE ( 1 )
          CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
-         CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
+         CALL mpprecv( 4, zt3sn(1,1,1,1,1,1), imigr, noso )
          IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
       END SELECT
@@ -265,5 +292,5 @@
                DO jk = 1, ipk
                   DO jh = 1, nn_hls
-                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
+                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,1)
                   END DO
                END DO
@@ -286,10 +313,12 @@
                DO jk = 1, ipk
                   DO jh = 1, nn_hls
-                     ARRAY_IN(:,jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         END DO
-      END SELECT
+                     ARRAY_IN(:,jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,1)
+                  END DO
+               END DO
+            END DO
+         END DO
+      END SELECT
+      !
+      IF( nbondj /= 2 ) DEALLOCATE( zt3ns, zt3sn )
 
       ! 4. north fold treatment
@@ -305,6 +334,4 @@
       ENDIF
       !
-      DEALLOCATE( zt3ns, zt3sn, zt3ew, zt3we )
-      !
    END SUBROUTINE ROUTINE_LNK
 
