Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/lbc_nfd_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/lbc_nfd_generic.h90	(revision 13173)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/lbc_nfd_generic.h90	(revision 13174)
@@ -6,4 +6,5 @@
 #      define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D),INTENT(inout)::ptab(f)
 #      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt2d(i,j)
+#      define J_SIZE(ptab)             SIZE(ptab(1)%pt2d,2)
 #      define K_SIZE(ptab)             1
 #      define L_SIZE(ptab)             1
@@ -12,4 +13,5 @@
 #      define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D),INTENT(inout)::ptab(f)
 #      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt3d(i,j,k)
+#      define J_SIZE(ptab)             SIZE(ptab(1)%pt3d,2)
 #      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
 #      define L_SIZE(ptab)             1
@@ -18,4 +20,5 @@
 #      define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D),INTENT(inout)::ptab(f)
 #      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt4d(i,j,k,l)
+#      define J_SIZE(ptab)             SIZE(ptab(1)%pt4d,2)
 #      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
 #      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
@@ -28,4 +31,5 @@
 #   if defined DIM_2d
 #      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
+#      define J_SIZE(ptab)          SIZE(ptab,2)
 #      define K_SIZE(ptab)          1
 #      define L_SIZE(ptab)          1
@@ -33,4 +37,5 @@
 #   if defined DIM_3d
 #      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
+#      define J_SIZE(ptab)          SIZE(ptab,2)
 #      define K_SIZE(ptab)          SIZE(ptab,3)
 #      define L_SIZE(ptab)          1
@@ -38,4 +43,5 @@
 #   if defined DIM_4d
 #      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
+#      define J_SIZE(ptab)          SIZE(ptab,2)
 #      define K_SIZE(ptab)          SIZE(ptab,3)
 #      define L_SIZE(ptab)          SIZE(ptab,4)
@@ -54,20 +60,13 @@
       REAL(wp)         , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
       !
-      INTEGER  ::    ji,  jj,  jk,  jl, jh,  jf   ! dummy loop indices
-      INTEGER  ::   ipi, ipj, ipk, ipl,     ipf   ! dimension of the input array
-      INTEGER  ::   ijt, iju, ipjm1
+      INTEGER  ::    ji,  jj,  jk,  jl,  jf   ! dummy loop indices
+      INTEGER  ::        ipj, ipk, ipl, ipf   ! dimension of the input array
+      INTEGER  ::   ii1, ii2, ij1, ij2
       !!----------------------------------------------------------------------
       !
-      ipk = K_SIZE(ptab)   ! 3rd dimension
+      ipj = J_SIZE(ptab)   ! 2nd dimension
+      ipk = K_SIZE(ptab)   ! 3rd    -
       ipl = L_SIZE(ptab)   ! 4th    -
       ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
-      !
-      !
-      SELECT CASE ( jpni )
-      CASE ( 1 )     ;   ipj = jpj        ! 1 proc only  along the i-direction
-      CASE DEFAULT   ;   ipj = 4          ! several proc along the i-direction
-      END SELECT
-      ipjm1 = ipj-1
-
       !
       DO jf = 1, ipf                      ! Loop on the number of arrays to be treated
@@ -79,40 +78,166 @@
             SELECT CASE ( NAT_IN(jf)  )
             CASE ( 'T' , 'W' )                         ! T-, W-point
-               DO ji = 2, jpiglo
-                  ijt = jpiglo-ji+2
-                  ARRAY_IN(ji,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2,:,:,jf)
-               END DO
-               ARRAY_IN(1,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(3,ipj-2,:,:,jf)
-               DO ji = jpiglo/2+1, jpiglo
-                  ijt = jpiglo-ji+2
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipjm1,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
+               	  DO jj = 1, nn_hls
+               	     ij1 = ipj            - jj + 1       ! ends at: ipj - nn_hls + 1
+                     ij2 = ipj - 2*nn_hls + jj - 1       ! ends at: ipj - 2*nn_hls + nn_hls - 1 = ipj - nn_hls - 1
+                     !
+                     DO ji = 1, nn_hls            ! first nn_hls points
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 2 - ji          ! ends at: 2*nn_hls + 2 - nn_hls = nn_hls + 2
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, 1                 ! point nn_hls+1
+                        ii1 = nn_hls + ji
+                        ii2 = ii1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from nn_hls+2 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = 2 + nn_hls      + ji - 1   ! ends at: 2 + nn_hls + jpiglo - 2*nn_hls - 1 - 1 = jpiglo - nn_hls
+                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls - 1 ) + 1 = nn_hls + 2
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, 1                 ! point jpiglo - nn_hls + 1
+                        ii1 = jpiglo - nn_hls + ji
+                        ii2 =          nn_hls + ji
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls-1          ! last nn_hls-1 points
+                        ii1 = jpiglo - nn_hls + 1 + ji   ! ends at: jpiglo - nn_hls + 1 + nn_hls - 1 = jpiglo
+                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls + 1 = jpiglo - 2*nn_hls + 2
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                  END DO
+                  !
+                  ! line number ipj-nn_hls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - nn_hls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2-1        ! points from jpiglo/2+2 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = jpiglo/2 + ji + 1          ! ends at: jpiglo/2 + (jpiglo/2 - nn_hls - 1) + 1 = jpiglo - nn_hls
+                        ii2 = jpiglo/2 - ji + 1          ! ends at: jpiglo/2 - (jpiglo/2 - nn_hls - 1) + 1 = nn_hls + 2
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! first nn_hls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points jpiglo-2nn_hls+1 to jpiglo-nn_hls  
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 2 - ji          ! ends at: 2*nn_hls + 2 - nn_hls = nn_hls + 2
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     !                            ! points jpiglo - nn_hls + 1 to jpiglo : have been / will done by e-w periodicity 
+                  END DO
+                  !
+               END DO; END DO
             CASE ( 'U' )                               ! U-point
-               DO ji = 1, jpiglo-1
-                  iju = jpiglo-ji+1
-                  ARRAY_IN(ji,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2,:,:,jf)
-               END DO
-               ARRAY_IN(   1  ,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(    2   ,ipj-2,:,:,jf)
-               ARRAY_IN(jpiglo,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-1,ipj-2,:,:,jf) 
-               DO ji = jpiglo/2, jpiglo-1
-                  iju = jpiglo-ji+1
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipjm1,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
+               	  DO jj = 1, nn_hls
+               	     ij1 = ipj            - jj + 1       ! ends at: ipj - nn_hls + 1
+                     ij2 = ipj - 2*nn_hls + jj - 1       ! ends at: ipj - 2*nn_hls + nn_hls - 1 = ipj - nn_hls - 1
+                     !
+                     DO ji = 1, nn_hls            ! first nn_hls points
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from nn_hls to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = nn_hls          + ji       ! ends at: nn_hls + jpiglo - 2*nn_hls = jpiglo - nn_hls
+                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls ) + 1 = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! last nn_hls points
+                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
+                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls = jpiglo - 2*nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                  END DO
+                  !
+                  ! line number ipj-nn_hls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - nn_hls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2          ! points from jpiglo/2+1 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = jpiglo/2 + ji              ! ends at: jpiglo/2 + (jpiglo/2 - nn_hls) = jpiglo - nn_hls
+                        ii2 = jpiglo/2 - ji + 1          ! ends at: jpiglo/2 - (jpiglo/2 - nn_hls) + 1 = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! first nn_hls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points jpiglo-2nn_hls+1 to jpiglo-nn_hls  
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     !                            ! points jpiglo - nn_hls + 1 to jpiglo : have been / will done by e-w periodicity 
+                  END DO
+                  !
+               END DO; END DO
             CASE ( 'V' )                               ! V-point
-               DO ji = 2, jpiglo
-                  ijt = jpiglo-ji+2
-                  ARRAY_IN(ji,ipj-1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2,:,:,jf)
-                  ARRAY_IN(ji,ipj  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-3,:,:,jf)
-               END DO
-               ARRAY_IN(1,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(3,ipj-3,:,:,jf) 
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last nn_hls+1 lines (from ipj to ipj-nn_hls) : full
+               	  DO jj = 1, nn_hls+1
+               	     ij1 = ipj            - jj + 1       ! ends at: ipj - ( nn_hls + 1 ) + 1 = ipj - nn_hls
+                     ij2 = ipj - 2*nn_hls + jj - 2       ! ends at: ipj - 2*nn_hls + nn_hls + 1 - 2 = ipj - nn_hls - 1
+                     !
+                     DO ji = 1, nn_hls            ! first nn_hls points
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 2 - ji          ! ends at: 2*nn_hls + 2 - nn_hls = nn_hls + 2
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, 1                 ! point nn_hls+1
+                        ii1 = nn_hls + ji
+                        ii2 = ii1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from nn_hls+2 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = 2 + nn_hls      + ji - 1   ! ends at: 2 + nn_hls + jpiglo - 2*nn_hls - 1 - 1 = jpiglo - nn_hls
+                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls - 1 ) + 1 = nn_hls + 2
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, 1                 ! point jpiglo - nn_hls + 1
+                        ii1 = jpiglo - nn_hls + ji
+                        ii2 =          nn_hls + ji
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls-1          ! last nn_hls-1 points
+                        ii1 = jpiglo - nn_hls + 1 + ji   ! ends at: jpiglo - nn_hls + 1 + nn_hls - 1 = jpiglo
+                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls + 1 = jpiglo - 2*nn_hls + 2
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                  END DO
+                  !
+               END DO; END DO
             CASE ( 'F' )                               ! F-point
-               DO ji = 1, jpiglo-1
-                  iju = jpiglo-ji+1
-                  ARRAY_IN(ji,ipj-1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2,:,:,jf)
-                  ARRAY_IN(ji,ipj  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-3,:,:,jf)
-               END DO
-               ARRAY_IN(   1  ,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(    2   ,ipj-3,:,:,jf)
-               ARRAY_IN(jpiglo,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-1,ipj-3,:,:,jf) 
-            END SELECT
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last nn_hls+1 lines (from ipj to ipj-nn_hls) : full
+               	  DO jj = 1, nn_hls+1
+               	     ij1 = ipj            - jj + 1       ! ends at: ipj - ( nn_hls + 1 ) + 1 = ipj - nn_hls
+                     ij2 = ipj - 2*nn_hls + jj - 2       ! ends at: ipj - 2*nn_hls + nn_hls + 1 - 2 = ipj - nn_hls - 1
+                     !
+                     DO ji = 1, nn_hls            ! first nn_hls points
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from nn_hls to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = nn_hls          + ji       ! ends at: nn_hls + jpiglo - 2*nn_hls = jpiglo - nn_hls
+                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls ) + 1 = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! last nn_hls points
+                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
+                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls = jpiglo - 2*nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                  END DO
+                  !
+               END DO; END DO
+            END SELECT   ! NAT_IN(jf)
             !
          CASE ( 5 , 6 )                        ! *  North fold  F-point pivot
@@ -120,48 +245,193 @@
             SELECT CASE ( NAT_IN(jf)  )
             CASE ( 'T' , 'W' )                         ! T-, W-point
-               DO ji = 1, jpiglo
-                  ijt = jpiglo-ji+1
-                  ARRAY_IN(ji,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-1,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! first: line number ipj-nn_hls : 3 points
+               	  DO jj = 1, 1
+                     ij1 = ipj - nn_hls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, 1            ! points from jpiglo/2+1
+                        ii1 = jpiglo/2 + ji
+                        ii2 = jpiglo/2 - ji + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) =              ARRAY_IN(ii2,ij2,jk,jl,jf)   ! Warning: pb with sign...
+                     END DO
+                     DO ji = 1, 1            ! points jpiglo - nn_hls
+                        ii1 = jpiglo - nn_hls + ji - 1
+                        ii2 =          nn_hls + ji
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) =              ARRAY_IN(ii2,ij2,jk,jl,jf)   ! Warning: pb with sign...
+                     END DO
+                     DO ji = 1, 1            ! point nn_hls: redo it just in case (if e-w periodocity already done)
+                        !                    ! as we just changed point jpiglo - nn_hls
+                        ii1 = nn_hls + ji - 1
+                        ii2 = nn_hls + ji
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) =              ARRAY_IN(ii2,ij2,jk,jl,jf)   ! Warning: pb with sign...
+                     END DO
+                  END DO
+                  !
+                  ! Second: last nn_hls lines (from ipj to ipj-nn_hls+1) : full
+               	  DO jj = 1, nn_hls
+               	     ij1 = ipj + 1        - jj           ! ends at: ipj + 1 - nn_hls
+                     ij2 = ipj - 2*nn_hls + jj           ! ends at: ipj - 2*nn_hls + nn_hls = ipj - nn_hls
+                     !
+                     DO ji = 1, nn_hls            ! first nn_hls points
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from nn_hls to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = nn_hls          + ji       ! ends at: nn_hls + jpiglo - 2*nn_hls = jpiglo - nn_hls
+                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls ) + 1 = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! last nn_hls points
+                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
+                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls = jpiglo - 2*nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                  END DO
+                  !
+               END DO; END DO
             CASE ( 'U' )                               ! U-point
-               DO ji = 1, jpiglo-1
-                  iju = jpiglo-ji
-                  ARRAY_IN(ji,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-1,:,:,jf)
-               END DO
-               ARRAY_IN(jpiglo,ipj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(jpiglo-2,ipj-1,:,:,jf)
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
+               	  DO jj = 1, nn_hls
+               	     ij1 = ipj + 1        - jj           ! ends at: ipj + 1 - nn_hls
+                     ij2 = ipj - 2*nn_hls + jj           ! ends at: ipj - 2*nn_hls + nn_hls = ipj - nn_hls
+                     !
+                     DO ji = 1, nn_hls-1          ! first nn_hls-1 points
+                        ii1 =            ji              ! ends at: nn_hls-1
+                        ii2 = 2*nn_hls - ji              ! ends at: 2*nn_hls - ( nn_hls - 1 ) = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, 1                 ! point nn_hls
+                        ii1 = nn_hls + ji - 1
+                        ii2 = jpiglo - ii1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from nn_hls+1 to jpiglo - nn_hls - 1  (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 =          nn_hls + ji       ! ends at: nn_hls + ( jpiglo - 2*nn_hls - 1 ) = jpiglo - nn_hls - 1
+                        ii2 = jpiglo - nn_hls - ji       ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls - 1 ) = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, 1                 ! point jpiglo - nn_hls
+                        ii1 = jpiglo - nn_hls + ji - 1
+                        ii2 = ii1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! last nn_hls points
+                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
+                        ii2 = jpiglo - nn_hls - ji       ! ends at: jpiglo - nn_hls - nn_hls = jpiglo - 2*nn_hls
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                  END DO
+                  !
+               END DO; END DO
             CASE ( 'V' )                               ! V-point
-               DO ji = 1, jpiglo
-                  ijt = jpiglo-ji+1
-                  ARRAY_IN(ji,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2,:,:,jf)
-               END DO
-               DO ji = jpiglo/2+1, jpiglo
-                  ijt = jpiglo-ji+1
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipjm1,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
+               	  DO jj = 1, nn_hls
+               	     ij1 = ipj            - jj + 1       ! ends at: ipj - nn_hls + 1
+                     ij2 = ipj - 2*nn_hls + jj - 1       ! ends at: ipj - 2*nn_hls + nn_hls - 1 = ipj - nn_hls - 1
+                     !
+                     DO ji = 1, nn_hls            ! first nn_hls points
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from nn_hls to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = nn_hls          + ji       ! ends at: nn_hls + jpiglo - 2*nn_hls = jpiglo - nn_hls
+                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls ) + 1 = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! last nn_hls points
+                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
+                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls = jpiglo - 2*nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                  END DO   
+                  !
+                  ! line number ipj-nn_hls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - nn_hls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2          ! points from jpiglo/2+1 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = jpiglo/2 + ji              ! ends at: jpiglo/2 + (jpiglo/2 - nn_hls) = jpiglo - nn_hls
+                        ii2 = jpiglo/2 - ji + 1          ! ends at: jpiglo/2 - (jpiglo/2 - nn_hls) + 1 = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! first nn_hls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points jpiglo-2nn_hls+1 to jpiglo-nn_hls  
+                        ii1 =                ji          ! ends at: nn_hls
+                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     !                            ! points jpiglo - nn_hls + 1 to jpiglo : have been / will done by e-w periodicity 
+                  END DO
+                  !
+               END DO; END DO
             CASE ( 'F' )                               ! F-point
-               DO ji = 1, jpiglo-1
-                  iju = jpiglo-ji
-                  ARRAY_IN(ji,ipj  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2,:,:,jf)
-               END DO
-               ARRAY_IN(jpiglo,ipj,:,:,jf) = SGN_IN(jf)   * ARRAY_IN(jpiglo-2,ipj-2,:,:,jf)
-               DO ji = jpiglo/2+1, jpiglo-1
-                  iju = jpiglo-ji
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipjm1,:,:,jf)
-               END DO
-            END SELECT
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
+               	  DO jj = 1, nn_hls
+               	     ij1 = ipj            - jj + 1       ! ends at: ipj - nn_hls + 1
+                     ij2 = ipj - 2*nn_hls + jj - 1       ! ends at: ipj - 2*nn_hls + nn_hls - 1 = ipj - nn_hls - 1
+                     !
+                     DO ji = 1, nn_hls-1          ! first nn_hls-1 points
+                        ii1 =            ji              ! ends at: nn_hls-1
+                        ii2 = 2*nn_hls - ji              ! ends at: 2*nn_hls - ( nn_hls - 1 ) = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, 1                 ! point nn_hls
+                        ii1 = nn_hls + ji - 1
+                        ii2 = jpiglo - ii1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from nn_hls+1 to jpiglo - nn_hls - 1  (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 =          nn_hls + ji       ! ends at: nn_hls + ( jpiglo - 2*nn_hls - 1 ) = jpiglo - nn_hls - 1
+                        ii2 = jpiglo - nn_hls - ji       ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls - 1 ) = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, 1                 ! point jpiglo - nn_hls
+                        ii1 = jpiglo - nn_hls + ji - 1
+                        ii2 = ii1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls            ! last nn_hls points
+                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
+                        ii2 = jpiglo - nn_hls - ji       ! ends at: jpiglo - nn_hls - nn_hls = jpiglo - 2*nn_hls
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                  END DO   
+                  !
+                  ! line number ipj-nn_hls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - nn_hls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2-1        ! points from jpiglo/2+1 to jpiglo - nn_hls-1  (note: Ni0glo = jpiglo - 2*nn_hls)
+                        ii1 = jpiglo/2 + ji              ! ends at: jpiglo/2 + (jpiglo/2 - nn_hls) = jpiglo - nn_hls
+                        ii2 = jpiglo/2 - ji              ! ends at: jpiglo/2 - (jpiglo/2 - nn_hls - 1 ) = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     DO ji = 1, nn_hls-1          ! first nn_hls-1 points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points jpiglo-2nn_hls+1 to jpiglo-nn_hl-1  
+                        ii1 =            ji              ! ends at: nn_hls
+                        ii2 = 2*nn_hls - ji              ! ends at: 2*nn_hls - ( nn_hls - 1 ) = nn_hls + 1
+                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
+                     END DO
+                     !                            ! points jpiglo - nn_hls + 1 to jpiglo : have been / will done by e-w periodicity 
+                  END DO
+                  !
+               END DO; END DO
+            END SELECT   ! NAT_IN(jf)
             !
-         CASE DEFAULT                           ! *  closed : the code probably never go through
-            !
-            SELECT CASE ( NAT_IN(jf) )
-            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
-               ARRAY_IN(:, 1 ,:,:,jf) = 0._wp
-               ARRAY_IN(:,ipj,:,:,jf) = 0._wp
-            CASE ( 'F' )                               ! F-point
-               ARRAY_IN(:,ipj,:,:,jf) = 0._wp
-            END SELECT
-            !
-         END SELECT     !  npolj
+         END SELECT   ! npolj
          !
-      END DO
+      END DO   ! ipf
       !
    END SUBROUTINE ROUTINE_NFD
@@ -171,4 +441,5 @@
 #undef NAT_IN
 #undef SGN_IN
+#undef J_SIZE
 #undef K_SIZE
 #undef L_SIZE
Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/mppini.F90
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/mppini.F90	(revision 13173)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/mppini.F90	(revision 13174)
@@ -176,4 +176,5 @@
 902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nammpp in configuration namelist' )   
       !
+      nn_hls = MAX(1, nn_hls)   ! nn_hls must be > 0
       IF(lwp) THEN
             WRITE(numout,*) '   Namelist nammpp'
@@ -1282,22 +1283,20 @@
       !!----------------------------------------------------------------------
       !
-      IF(     nn_hls == 1 ) THEN          !* halo size of 1
-         !
-         Nis0 =   2     ;   Nis1 =   1     ;   Nis1nxt2 = Nis0   ;   Nis2 = Nis1
-         Njs0 =   2     ;   Njs1 =   1     ;   Njs1nxt2 = Njs0   ;   Njs2 = Njs1
-         !                                   
-         Nie0 = jpi-1   ;   Nie1 = jpi     ;   Nie1nxt2 = Nie0   ;   Nie2 = Nie1
-         Nje0 = jpj-1   ;   Nje1 = jpj     ;   Nje1nxt2 = Nje0   ;   Nje2 = Nje1
-         !
-      ELSEIF( nn_hls == 2 ) THEN          !* halo size of 2
-         !
-         Nis0 =   3     ;   Nis1 =   2     ;   Nis1nxt2 = Nis1   ;   Nis2 =   1
-         Njs0 =   3     ;   Njs1 =   2     ;   Njs1nxt2 = Njs1   ;   Njs2 =   1
-         !                                                              
-         Nie0 = jpi-2   ;   Nie1 = jpi-1   ;   Nie1nxt2 = Nie1   ;   Nie2 = jpi
-         Nje0 = jpj-2   ;   Nje1 = jpj-1   ;   Nje1nxt2 = Nje1   ;   Nje2 = jpj
-         !
-      ELSE                                !* unexpected halo size
-         CALL ctl_stop( 'STOP', 'ini_mpp:  wrong value of halo size : nn_hls= 1 or 2 only !')
+      Nis0 =   1+nn_hls   ;   Nis1 = Nis0-1   ;   Nis2 = MAX(  1, Nis0-2)
+      Njs0 =   1+nn_hls   ;   Njs1 = Njs0-1   ;   Njs2 = MAX(  1, Njs0-2)  
+      !                                                 
+      Nie0 = jpi-nn_hls   ;   Nie1 = Nie0+1   ;   Nie2 = MIN(jpi, Nie0+2)
+      Nje0 = jpj-nn_hls   ;   Nje1 = Nje0+1   ;   Nje2 = MIN(jpj, Nje0+2)
+      !
+      IF( nn_hls == 1 ) THEN          !* halo size of 1
+         !
+         Nis1nxt2 = Nis0   ;   Njs1nxt2 = Njs0
+         Nie1nxt2 = Nie0   ;   Nje1nxt2 = Nje0
+         !
+      ELSE                            !* larger halo size... 
+         !
+         Nis1nxt2 = Nis1   ;   Njs1nxt2 = Njs1
+         Nie1nxt2 = Nie1   ;   Nje1nxt2 = Nje1
+         !
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca025_like
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca025_like	(revision 13173)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca025_like	(revision 13174)
@@ -19,5 +19,4 @@
    nn_ksize   =   75       ! total number of point in k-direction
    nn_perio   =   4        ! periodicity
-   nn_hls     =   2        ! halo dimension
 /
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca12_like
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca12_like	(revision 13173)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca12_like	(revision 13174)
@@ -19,5 +19,4 @@
    nn_ksize   =   75       ! total number of point in k-direction
    nn_perio   =   4        ! periodicity
-   nn_hls     =   2        ! halo dimension
 /
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca1_like
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca1_like	(revision 13173)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/EXPREF/namelist_cfg_orca1_like	(revision 13174)
@@ -19,5 +19,4 @@
    nn_ksize   =   75       ! total number of point in k-direction
    nn_perio   =   6        ! periodicity
-   nn_hls     =   2        ! halo dimension
 /
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/MY_SRC/usrdef_zgr.F90	(revision 13173)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/BENCH/MY_SRC/usrdef_zgr.F90	(revision 13174)
@@ -191,13 +191,22 @@
       !
       z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
-      IF( .NOT. (nbondj == 1 .OR. nbondj == 0 .OR. l_Jperio) )   &
-         z2d(mi0(  1 ):mi1(jpiglo),mj0(Njs0):mj1( Njs0 )) = 0._wp   ! line   number Njs0 at 0
-      IF( .NOT. (nbondi == 1 .OR. nbondi == 0 .OR. l_Iperio) )   & 
-         z2d(mi0(Nis0):mi1( Nis0 ),mj0(  1 ):mj1(jpjglo)) = 0._wp   ! column number Nis0 at 0
-      !
-      IF( jperio == 3 .OR. jperio ==4 ) THEN   ! add a small island in the upper corners to avoid model instabilities...
-         z2d(mi0(              1):mi1(Nis0+1),mj0(jpjglo-nn_hls-1):mj1(jpjglo)) = 0.
-         z2d(mi0(jpiglo-nn_hls-1):mi1(jpiglo),mj0(jpjglo-nn_hls-1):mj1(jpjglo)) = 0.
-      ENDIF
+      !
+      !
+      ! BENCH should work without these 2 small islands on the 2 poles of the folding...
+      !   -> Comment out these lines if instabilities are too large...
+      !
+      
+!!$      IF( jperio == 3 .OR. jperio == 4 ) THEN   ! add a small island in the upper corners to avoid model instabilities...
+!!$         z2d(mi0(       nn_hls):mi1(                  nn_hls+2 ),mj0(jpjglo-nn_hls-1):mj1(jpjglo-nn_hls+1)) = 0.
+!!$         z2d(mi0(jpiglo-nn_hls):mi1(MIN(jpiglo,jpiglo-nn_hls+2)),mj0(jpjglo-nn_hls-1):mj1(jpjglo-nn_hls+1)) = 0.
+!!$         z2d(mi0(jpiglo/2     ):mi1(           jpiglo/2     +2 ),mj0(jpjglo-nn_hls-1):mj1(jpjglo-nn_hls+1)) = 0.
+!!$      ENDIF
+!!$      !
+!!$      IF( jperio == 5 .OR. jperio == 6 ) THEN   ! add a small island in the upper corners to avoid model instabilities...
+!!$         z2d(mi0(       nn_hls):mi1(       nn_hls+1),mj0(jpjglo-nn_hls):mj1(jpjglo-nn_hls+1)) = 0.
+!!$         z2d(mi0(jpiglo-nn_hls):mi1(jpiglo-nn_hls+1),mj0(jpjglo-nn_hls):mj1(jpjglo-nn_hls+1)) = 0.
+!!$         z2d(mi0(jpiglo/2     ):mi1(jpiglo/2     +1),mj0(jpjglo-nn_hls):mj1(jpjglo-nn_hls+1)) = 0.
+!!$      ENDIF
+
       !
       CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
