Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/BDY/bdyini.F90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/BDY/bdyini.F90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/BDY/bdyini.F90	(revision 14363)
@@ -573,21 +573,21 @@
                ! check if point has to be sent     to   a neighbour
                ! W neighbour and on the inner left  side
-               IF( ii == 2     .AND. mpinei(jpwe) > -1 )   lsend_bdy(ib_bdy,igrd,jpwe,ir) = .TRUE.
+               IF( ii == 2     .AND. mpiSnei(nn_hls,jpwe) > -1 )   lsend_bdy(ib_bdy,igrd,jpwe,ir) = .TRUE.
                ! E neighbour and on the inner right side
-               IF( ii == jpi-1 .AND. mpinei(jpea) > -1 )   lsend_bdy(ib_bdy,igrd,jpea,ir) = .TRUE.
+               IF( ii == jpi-1 .AND. mpiSnei(nn_hls,jpea) > -1 )   lsend_bdy(ib_bdy,igrd,jpea,ir) = .TRUE.
                ! S neighbour and on the inner down side
-               IF( ij == 2     .AND. mpinei(jpso) > -1 )   lsend_bdy(ib_bdy,igrd,jpso,ir) = .TRUE.
+               IF( ij == 2     .AND. mpiSnei(nn_hls,jpso) > -1 )   lsend_bdy(ib_bdy,igrd,jpso,ir) = .TRUE.
                ! N neighbour and on the inner up   side
-               IF( ij == jpj-1 .AND. mpinei(jpno) > -1 )   lsend_bdy(ib_bdy,igrd,jpno,ir) = .TRUE.
+               IF( ij == jpj-1 .AND. mpiSnei(nn_hls,jpno) > -1 )   lsend_bdy(ib_bdy,igrd,jpno,ir) = .TRUE.
                !
                ! check if point has to be received from a neighbour
                ! W neighbour and on the outter left  side
-               IF( ii == 1     .AND. mpinei(jpwe) > -1 )   lrecv_bdy(ib_bdy,igrd,jpwe,ir) = .TRUE.
+               IF( ii == 1     .AND. mpiRnei(nn_hls,jpwe) > -1 )   lrecv_bdy(ib_bdy,igrd,jpwe,ir) = .TRUE.
                ! E neighbour and on the outter right side
-               IF( ii == jpi   .AND. mpinei(jpea) > -1 )   lrecv_bdy(ib_bdy,igrd,jpea,ir) = .TRUE.
+               IF( ii == jpi   .AND. mpiRnei(nn_hls,jpea) > -1 )   lrecv_bdy(ib_bdy,igrd,jpea,ir) = .TRUE.
                ! S neighbour and on the outter down side
-               IF( ij == 1     .AND. mpinei(jpso) > -1 )   lrecv_bdy(ib_bdy,igrd,jpso,ir) = .TRUE.
+               IF( ij == 1     .AND. mpiRnei(nn_hls,jpso) > -1 )   lrecv_bdy(ib_bdy,igrd,jpso,ir) = .TRUE.
                ! N neighbour and on the outter up   side
-               IF( ij == jpj   .AND. mpinei(jpno) > -1 )   lrecv_bdy(ib_bdy,igrd,jpno,ir) = .TRUE.
+               IF( ij == jpj   .AND. mpiRnei(nn_hls,jpno) > -1 )   lrecv_bdy(ib_bdy,igrd,jpno,ir) = .TRUE.
                !
             END DO
@@ -746,10 +746,10 @@
                ! :     |  x:o    |    neighbour limited by ... would need o    |    o:x  |     :
                ! :.....|_._:_____|   (1) W neighbour         E neighbour (2)   |_____:_._|.....:
-               IF( ii==2     .AND. mpinei(jpwe) > -1 .AND. &
+               IF( ii==2     .AND. mpiSnei(nn_hls,jpwe) > -1 .AND. &
                   & ( iibi==3     .OR. ii1==3     .OR. ii2==3     .OR. ii3==3    ) )   lsend_bdyint(ib_bdy,igrd,jpwe,ir) = .TRUE.
-               IF( ii==jpi-1 .AND. mpinei(jpea) > -1 .AND. &
+               IF( ii==jpi-1 .AND. mpiSnei(nn_hls,jpea) > -1 .AND. &
                   & ( iibi==jpi-2 .OR. ii1==jpi-2 .OR. ii2==jpi-2 .OR. ii3==jpi-2) )   lsend_bdyint(ib_bdy,igrd,jpea,ir) = .TRUE.
-               IF( ii==2     .AND. mpinei(jpwe) > -1             .AND. iibe==3     )   lsend_bdyext(ib_bdy,igrd,jpwe,ir) = .TRUE.
-               IF( ii==jpi-1 .AND. mpinei(jpea) > -1             .AND. iibe==jpi-2 )   lsend_bdyext(ib_bdy,igrd,jpea,ir) = .TRUE.
+               IF( ii==2     .AND. mpiSnei(nn_hls,jpwe) > -1 .AND. iibe==3     )   lsend_bdyext(ib_bdy,igrd,jpwe,ir) = .TRUE.
+               IF( ii==jpi-1 .AND. mpiSnei(nn_hls,jpea) > -1 .AND. iibe==jpi-2 )   lsend_bdyext(ib_bdy,igrd,jpea,ir) = .TRUE.
                !
                ! search neighbour in the north/south direction   
@@ -766,10 +766,10 @@
                !   |  |¨¨¨¨x¨¨¨¨|   neighbour limited by ... would need o     |  |....x....|
                !      :_________:  (3) S neighbour          N neighbour (4)   v  |    o    |   
-               IF( ij==2     .AND. mpinei(jpso) > -1 .AND. &
+               IF( ij==2     .AND. mpiSnei(nn_hls,jpso) > -1 .AND. &
                   & ( ijbi==3     .OR. ij1==3     .OR. ij2==3     .OR. ij3==3    ) )   lsend_bdyint(ib_bdy,igrd,jpso,ir) = .TRUE.
-               IF( ij==jpj-1 .AND. mpinei(jpno) > -1 .AND. &
+               IF( ij==jpj-1 .AND. mpiSnei(nn_hls,jpno) > -1 .AND. &
                   & ( ijbi==jpj-2 .OR. ij1==jpj-2 .OR. ij2==jpj-2 .OR. ij3==jpj-2) )   lsend_bdyint(ib_bdy,igrd,jpno,ir) = .TRUE.
-               IF( ij==2     .AND. mpinei(jpso) > -1             .AND. ijbe==3     )   lsend_bdyext(ib_bdy,igrd,jpso,ir) = .TRUE.
-               IF( ij==jpj-1 .AND. mpinei(jpno) > -1             .AND. ijbe==jpj-2 )   lsend_bdyext(ib_bdy,igrd,jpno,ir) = .TRUE.
+               IF( ij==2     .AND. mpiSnei(nn_hls,jpso) > -1 .AND. ijbe==3     )   lsend_bdyext(ib_bdy,igrd,jpso,ir) = .TRUE.
+               IF( ij==jpj-1 .AND. mpiSnei(nn_hls,jpno) > -1 .AND. ijbe==jpj-2 )   lsend_bdyext(ib_bdy,igrd,jpno,ir) = .TRUE.
             END DO
          END DO
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_call_generic.h90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_call_generic.h90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_call_generic.h90	(revision 14363)
@@ -24,5 +24,5 @@
       &                   , pt9 , cdna9 , psgn9 , pt10, cdna10, psgn10, pt11, cdna11, psgn11, pt12, cdna12, psgn12  &
       &                   , pt13, cdna13, psgn13, pt14, cdna14, psgn14, pt15, cdna15, psgn15, pt16, cdna16, psgn16  &
-      &                   , kfillmode, pfillval, lsend, lrecv, ncsten )
+      &                   , kfillmode, pfillval, khls, lsend, lrecv, ncsten )
       !!---------------------------------------------------------------------
       CHARACTER(len=*)     ,                   INTENT(in   ) ::   cdname  ! name of the calling subroutine
@@ -38,4 +38,5 @@
       INTEGER              , OPTIONAL        , INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
       REAL(PRECISION)      , OPTIONAL        , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER              , OPTIONAL        , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
       LOGICAL, DIMENSION(4), OPTIONAL        , INTENT(in   ) ::   lsend, lrecv   ! indicate how communications are to be carried out
       LOGICAL              , OPTIONAL        , INTENT(in   ) ::   ncsten
@@ -70,7 +71,7 @@
       !     
       IF( nn_comm == 1 ) THEN 
-         CALL lbc_lnk_pt2pt(   cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, lsend, lrecv )
+         CALL lbc_lnk_pt2pt(   cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, khls, lsend, lrecv )
       ELSE
-         CALL lbc_lnk_neicoll( cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, lsend, lrecv, ncsten )
+         CALL lbc_lnk_neicoll( cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, khls, lsend, lrecv, ncsten )
       ENDIF
       !
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_neicoll_generic.h90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_neicoll_generic.h90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_neicoll_generic.h90	(revision 14363)
@@ -1,4 +1,4 @@
 
-   SUBROUTINE lbc_lnk_neicoll_/**/PRECISION( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv, ncsten )
+   SUBROUTINE lbc_lnk_neicoll_/**/PRECISION( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, khls, lsend, lrecv, ncsten )
       CHARACTER(len=*)              , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
@@ -8,9 +8,10 @@
       INTEGER ,             OPTIONAL, INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
       REAL(PRECISION),      OPTIONAL, INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER ,             OPTIONAL, INTENT(in   ) ::   khls        ! halo size, default = nn_hls
       LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in   ) ::   lsend, lrecv  ! communication with other 4 proc
       LOGICAL,              OPTIONAL, INTENT(in   ) ::   ncsten      ! 5-point or 9-point stencil
       !
-      INTEGER  ::   ji, jj, jk, jl, jf, jn      ! dummy loop indices
-      INTEGER  ::   ipk, ipl, ipf                                     ! dimension of the input array
+      INTEGER  ::    ji,  jj,  jk , jl,  jf, jn      ! dummy loop indices
+      INTEGER  ::   ipi, ipj, ipk, ipl, ipf          ! dimension of the input array
       INTEGER  ::   ip0i, ip1i, im0i, im1i
       INTEGER  ::   ip0j, ip1j, im0j, im1j
@@ -18,10 +19,10 @@
       INTEGER  ::   iszs, iszr
       INTEGER  ::   ierr
-      INTEGER  ::   idx
+      INTEGER  ::   ihls, idx
       INTEGER  ::   impi_nc
       INTEGER  ::   ifill_nfd
       INTEGER, DIMENSION(4)  ::   iwewe, issnn
-      INTEGER, DIMENSION(8)  ::   isizei, ishtsi, ishtri, ishtpi
-      INTEGER, DIMENSION(8)  ::   isizej, ishtsj, ishtrj, ishtpj
+      INTEGER, DIMENSION(8)  ::   isizei, ishtSi, ishtRi, ishtPi
+      INTEGER, DIMENSION(8)  ::   isizej, ishtSj, ishtRj, ishtPj
       INTEGER, DIMENSION(8)  ::   ifill, iszall
       INTEGER, DIMENSION(:), ALLOCATABLE  ::   icounts, icountr    ! number of elements to be sent/received
@@ -38,4 +39,6 @@
       ! ----------------------------------------- !
       !
+      ipi = SIZE(ptab(1)%pt4d,1)
+      ipj = SIZE(ptab(1)%pt4d,2)
       ipk = SIZE(ptab(1)%pt4d,3)
       ipl = SIZE(ptab(1)%pt4d,4)
@@ -46,9 +49,24 @@
       ! take care of optional parameters
       !
-      llncall = .TRUE. 
+      ihls = nn_hls       ! default definition
+      IF( PRESENT( khls ) )   ihls = khls
+      IF( ihls > n_hlsmax ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), '  is calling lbc_lnk with khls > n_hlsmax : ', khls, '>', n_hlsmax
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      IF( ipi /= Ni_0+2*ihls ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along i: ', ipi, ihls, Ni_0
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      IF( ipj /= Nj_0+2*ihls ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along j:', ipj, ihls , Nj_0
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      !
+      llncall = .TRUE.    ! default definition
       IF( PRESENT(ncsten) ) llncall = ncsten
       !
-      impi_nc = mpi_nc_com4
-      IF(llncall)   impi_nc = mpi_nc_com8
+      impi_nc = mpi_nc_com4(ihls)
+      IF(llncall)   impi_nc = mpi_nc_com8(ihls)
       !
       zland = 0._wp                                     ! land filling value: zero by default
@@ -60,10 +78,11 @@
 !!$         ---> llsend(:) = lsend(:)   ;   llrecv(:) = lrecv(:) ???
       ELSE IF( PRESENT(lsend) .OR.  PRESENT(lrecv) ) THEN
-         WRITE(ctmp1,*) ' Routine ', cdname, '  is calling lbc_lnk with only one of the two arguments lsend or lrecv'
+         WRITE(ctmp1,*) TRIM(cdname), '  is calling lbc_lnk with only one of the two arguments lsend or lrecv'
          CALL ctl_stop( 'STOP', ctmp1 )
       ELSE                                                  ! default neighbours
-         llsend(:) = mpinei(:) >= 0
+         llsend(:) = mpiSnei(ihls,:) >= 0
          IF( .NOT. llncall )   llsend(5:8) = .FALSE.        ! exclude corners
-         llrecv(:) = llsend(:)
+         llrecv(:) = mpiRnei(ihls,:) >= 0
+         IF( .NOT. llncall )   llrecv(5:8) = .FALSE.        ! exclude corners
       END IF
       !
@@ -92,25 +111,27 @@
       ! or used for periodocity (p). The localization is defined as "the bottom left corner - 1" in i and j directions.
       ! This is a shift that will be applied later in the do loops to pick-up the appropriate part of the array
-      !                    !                       ________________________
-      ip0i =          0    !          im0j = inner |__|________________|__|
-      ip1i =      nn_hls   !   im1j = inner - halo |  |__|__________|__|  |
-      im1i = Nie0-nn_hls   !                       |  |  |          |  |  |
-      im0i = Nie0          !                       |  |  |          |  |  |
-      ip0j =          0    !                       |  |  |          |  |  |
-      ip1j =      nn_hls   !                       |  |__|__________|__|  |
-      im1j = Nje0-nn_hls   !           ip1j = halo |__|__|__________|__|__|
-      im0j = Nje0          !              ip0j = 0 |__|________________|__|
-      !                    !                    ip0i ip1i        im1i im0i
+      !
+      ! all definitions bellow do not refer to N[ij][se]0 so we can use it with any local value of ihls
+      !                   !                       ________________________
+      ip0i =          0   !          im0j = inner |__|________________|__|
+      ip1i =       ihls   !   im1j = inner - halo |  |__|__________|__|  |
+      im1i = ipi-2*ihls   !                       |  |  |          |  |  |
+      im0i = ipi - ihls   !                       |  |  |          |  |  |
+      ip0j =          0   !                       |  |  |          |  |  |
+      ip1j =       ihls   !                       |  |__|__________|__|  |
+      im1j = ipj-2*ihls   !           ip1j = halo |__|__|__________|__|__|
+      im0j = ipj - ihls   !              ip0j = 0 |__|________________|__|
+      !                   !                    ip0i ip1i        im1i im0i
       !
       iwewe(:) = (/ jpwe,jpea,jpwe,jpea /)   ;   issnn(:) = (/ jpso,jpso,jpno,jpno /)
-      !     sides:       west    east   south   north      ;       corners: so-we, so-ea, no-we, no-ea
-      isizei(1:4) = (/ nn_hls, nn_hls,   Ni_0,   Ni_0 /)   ;   isizei(5:8) = nn_hls            ! i- count
-      isizej(1:4) = (/   Nj_0,   Nj_0, nn_hls, nn_hls /)   ;   isizej(5:8) = nn_hls            ! j- count
-      ishtsi(1:4) = (/   ip1i,   im1i,   ip1i,   ip1i /)   ;   ishtsi(5:8) = ishtsi( iwewe )   ! i- shift send data
-      ishtsj(1:4) = (/   ip1j,   ip1j,   ip1j,   im1j /)   ;   ishtsj(5:8) = ishtsj( issnn )   ! j- shift send data
-      ishtri(1:4) = (/   ip0i,   im0i,   ip1i,   ip1i /)   ;   ishtri(5:8) = ishtri( iwewe )   ! i- shift received data location
-      ishtrj(1:4) = (/   ip1j,   ip1j,   ip0j,   im0j /)   ;   ishtrj(5:8) = ishtrj( issnn )   ! j- shift received data location
-      ishtpi(1:4) = (/   im1i,   ip1i,   ip1i,   ip1i /)   ;   ishtpi(5:8) = ishtpi( iwewe )   ! i- shift data used for periodicity
-      ishtpj(1:4) = (/   ip1j,   ip1j,   im1j,   ip1j /)   ;   ishtpj(5:8) = ishtpj( issnn )   ! j- shift data used for periodicity
+      !     sides:     west  east south north      ;   corners: so-we, so-ea, no-we, no-ea
+      isizei(1:4) = (/ ihls, ihls, Ni_0, Ni_0 /)   ;   isizei(5:8) = ihls              ! i- count
+      isizej(1:4) = (/ Nj_0, Nj_0, ihls, ihls /)   ;   isizej(5:8) = ihls              ! j- count
+      ishtSi(1:4) = (/ ip1i, im1i, ip1i, ip1i /)   ;   ishtSi(5:8) = ishtSi( iwewe )   ! i- shift send data
+      ishtSj(1:4) = (/ ip1j, ip1j, ip1j, im1j /)   ;   ishtSj(5:8) = ishtSj( issnn )   ! j- shift send data
+      ishtRi(1:4) = (/ ip0i, im0i, ip1i, ip1i /)   ;   ishtRi(5:8) = ishtRi( iwewe )   ! i- shift received data location
+      ishtRj(1:4) = (/ ip1j, ip1j, ip0j, im0j /)   ;   ishtRj(5:8) = ishtRj( issnn )   ! j- shift received data location
+      ishtPi(1:4) = (/ im1i, ip1i, ip1i, ip1i /)   ;   ishtPi(5:8) = ishtPi( iwewe )   ! i- shift data used for periodicity
+      ishtPj(1:4) = (/ ip1j, ip1j, im1j, ip1j /)   ;   ishtPj(5:8) = ishtPj( issnn )   ! j- shift data used for periodicity
       !
       ! -------------------------------- !
@@ -140,6 +161,6 @@
       DO jn = 1, 8
          IF( llsend(jn) ) THEN
-            ishti = ishtsi(jn)
-            ishtj = ishtsj(jn)
+            ishti = ishtSi(jn)
+            ishtj = ishtSj(jn)
             DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
                zsnd(idx) = ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl)
@@ -163,6 +184,6 @@
       idx = 1
       DO jn = 1, 8
-         ishti = ishtri(jn)
-         ishtj = ishtrj(jn)
+         ishti = ishtRi(jn)
+         ishtj = ishtRj(jn)
          SELECT CASE ( ifill(jn) )
          CASE ( jpfillnothing )               ! no filling 
@@ -173,12 +194,12 @@
             END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
          CASE ( jpfillperio )                 ! use periodicity
-            ishti2 = ishtpi(jn)
-            ishtj2 = ishtpj(jn)
+            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)
                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)
+            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)
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
@@ -196,8 +217,8 @@
       DO jn = 5, 8
          IF( .NOT. l_SelfPerio(jn) .AND. l_SelfPerio(jpwe)  ) THEN   ! no bi-perio but ew-perio: corners indirect definition
-            ishti  = ishtri(jn)
-            ishtj  = ishtrj(jn)
-            ishti2 = ishtpi(jn)   ! use i- shift periodicity
-            ishtj2 = ishtrj(jn)   ! use j- shift recv location: use ew-perio -> ok as filling of the south and north halos now done
+            ishti  = ishtRi(jn)
+            ishtj  = ishtRj(jn)
+            ishti2 = ishtPi(jn)   ! use i- shift periodicity
+            ishtj2 = ishtRj(jn)   ! use j- shift recv location: use ew-perio -> ok as filling of the south and north halos now done
             DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
@@ -205,8 +226,8 @@
          ENDIF
          IF( .NOT. l_SelfPerio(jn) .AND. l_SelfPerio(jpso)  ) THEN   ! no bi-perio but ns-perio: corners indirect definition
-            ishti  = ishtri(jn)
-            ishtj  = ishtrj(jn)
-            ishti2 = ishtri(jn)   ! use i- shift recv location: use ns-perio -> ok as filling of the west and east halos now done
-            ishtj2 = ishtpj(jn)   ! use j- shift periodicity
+            ishti  = ishtRi(jn)
+            ishtj  = ishtRj(jn)
+            ishti2 = ishtRi(jn)   ! use i- shift recv location: use ns-perio -> ok as filling of the west and east halos now done
+            ishtj2 = ishtPj(jn)   ! use j- shift periodicity
             DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
@@ -220,6 +241,6 @@
       !
       IF( ll_IdoNFold ) THEN
-         IF( jpni == 1 )  THEN   ;   CALL lbc_nfd( ptab, cd_nat, psgn                  , ipf )   ! self NFold
-         ELSE                    ;   CALL mpp_nfd( ptab, cd_nat, psgn, ifill_nfd, zland, ipf )   ! mpi  NFold
+         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
          ENDIF
       ENDIF
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_pt2pt_generic.h90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_pt2pt_generic.h90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_pt2pt_generic.h90	(revision 14363)
@@ -1,4 +1,4 @@
 
-   SUBROUTINE lbc_lnk_pt2pt_/**/PRECISION( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv )
+   SUBROUTINE lbc_lnk_pt2pt_/**/PRECISION( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, khls, lsend, lrecv )
       CHARACTER(len=*)              , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
@@ -8,16 +8,17 @@
       INTEGER ,             OPTIONAL, INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
       REAL(PRECISION),      OPTIONAL, INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER ,             OPTIONAL, INTENT(in   ) ::   khls        ! halo size, default = nn_hls
       LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in   ) ::   lsend, lrecv  ! communication with other 4 proc
       !
-      INTEGER  ::   ji, jj, jk, jl, jf, jn      ! dummy loop indices
-      INTEGER  ::   ipk, ipl, ipf      ! dimension of the input array
+      INTEGER  ::     ji,   jj,  jk,  jl,  jf, jn     ! dummy loop indices
+      INTEGER  ::    ipi,  ipj, ipk, ipl, ipf         ! dimension of the input array
       INTEGER  ::   ip0i, ip1i, im0i, im1i
       INTEGER  ::   ip0j, ip1j, im0j, im1j
       INTEGER  ::   ishti, ishtj, ishti2, ishtj2
       INTEGER  ::   ifill_nfd, icomm, ierr
-      INTEGER  ::   idxs, idxr
-      INTEGER, DIMENSION(4)  ::   isizei, ishtsi, ishtri, ishtpi
-      INTEGER, DIMENSION(4)  ::   isizej, ishtsj, ishtrj, ishtpj
-      INTEGER, DIMENSION(4)  ::   ifill, iszall, ishts, ishtr
+      INTEGER  ::   ihls, idxs, idxr
+      INTEGER, DIMENSION(4)  ::   isizei, ishtSi, ishtRi, ishtPi
+      INTEGER, DIMENSION(4)  ::   isizej, ishtSj, ishtRj, ishtPj
+      INTEGER, DIMENSION(4)  ::   ifill, iszall, ishtS, ishtR
       INTEGER, DIMENSION(4)  ::   ireq  ! mpi_request id
       REAL(PRECISION) ::   zland
@@ -31,4 +32,6 @@
       ! ----------------------------------------- !
       !
+      ipi = SIZE(ptab(1)%pt4d,1)
+      ipj = SIZE(ptab(1)%pt4d,2)
       ipk = SIZE(ptab(1)%pt4d,3)
       ipl = SIZE(ptab(1)%pt4d,4)
@@ -38,4 +41,19 @@
       !
       ! take care of optional parameters
+      !
+      ihls = nn_hls   ! default definition
+      IF( PRESENT( khls ) )   ihls = khls
+      IF( ihls > n_hlsmax ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with khls > n_hlsmax : ', khls, '>', n_hlsmax
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      IF( ipi /= Ni_0+2*ihls ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along i: ', ipi, ihls, Ni_0
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      IF( ipj /= Nj_0+2*ihls ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along j:', ipj, ihls , Nj_0
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
       !
       zland = 0._wp                                     ! land filling value: zero by default
@@ -46,9 +64,9 @@
          llsend(1:4) = lsend(1:4)   ;   llrecv(1:4) = lrecv(1:4)
       ELSE IF( PRESENT(lsend) .OR.  PRESENT(lrecv) ) THEN
-         WRITE(ctmp1,*) ' Routine ', cdname, '  is calling lbc_lnk with only one of the two arguments lsend or lrecv'
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with only one of the two arguments lsend or lrecv'
          CALL ctl_stop( 'STOP', ctmp1 )
       ELSE                                                  ! default neighbours
-         llsend(1:4) = mpinei(1:4) >= 0
-         llrecv(:) = llsend(:)
+         llsend(:) = mpiSnei(ihls,1:4) >= 0
+         llrecv(:) = mpiRnei(ihls,1:4) >= 0
       END IF
       !
@@ -72,24 +90,26 @@
       ! or used for periodocity (p). The localization is defined as "the bottom left corner - 1" in i and j directions.
       ! This is a shift that will be applied later in the do loops to pick-up the appropriate part of the array
-      !                    !                       ________________________
-      ip0i =          0    !          im0j = inner |__|__|__________|__|__|
-      ip1i =      nn_hls   !   im1j = inner - halo |__|__|__________|__|__|
-      im1i = Nie0-nn_hls   !                       |  |  |          |  |  |
-      im0i = Nie0          !                       |  |  |          |  |  |
-      ip0j =          0    !                       |  |  |          |  |  |
-      ip1j =      nn_hls   !                       |__|__|__________|__|__|
-      im1j = Nje0-nn_hls   !           ip1j = halo |__|__|__________|__|__|
-      im0j = Nje0          !              ip0j = 0 |__|__|__________|__|__|
-      !                    !                    ip0i ip1i        im1i im0i
-      !
-      !     sides:       west    east   south   north
-      isizei(1:4) = (/ nn_hls, nn_hls,    jpi,    jpi /)   ! i- count
-      isizej(1:4) = (/    jpj,    jpj, nn_hls, nn_hls /)   ! j- count
-      ishtsi(1:4) = (/   ip1i,   im1i,   ip0i,   ip0i /)   ! i- shift send data
-      ishtsj(1:4) = (/   ip0j,   ip0j,   ip1j,   im1j /)   ! j- shift send data
-      ishtri(1:4) = (/   ip0i,   im0i,   ip0i,   ip0i /)   ! i- shift received data location
-      ishtrj(1:4) = (/   ip0j,   ip0j,   ip0j,   im0j /)   ! j- shift received data location
-      ishtpi(1:4) = (/   im1i,   ip1i,   ip0i,   ip0i /)   ! i- shift data used for periodicity
-      ishtpj(1:4) = (/   ip0j,   ip0j,   im1j,   ip1j /)   ! j- shift data used for periodicity
+      !
+      ! all definitions bellow do not refer to N[ij][se]0 so we can use it with any local value of ihls
+      !                   !                       ________________________
+      ip0i =          0   !          im0j = inner |__|__|__________|__|__|
+      ip1i =       ihls   !   im1j = inner - halo |__|__|__________|__|__|
+      im1i = ipi-2*ihls   !                       |  |  |          |  |  |
+      im0i = ipi - ihls   !                       |  |  |          |  |  |
+      ip0j =          0   !                       |  |  |          |  |  |
+      ip1j =       ihls   !                       |__|__|__________|__|__|
+      im1j = ipj-2*ihls   !           ip1j = halo |__|__|__________|__|__|
+      im0j = ipj - ihls   !              ip0j = 0 |__|__|__________|__|__|
+      !                   !                    ip0i ip1i        im1i im0i
+      !
+      !     sides:     west  east south north
+      isizei(1:4) = (/ ihls, ihls,  ipi,  ipi /)   ! i- count
+      isizej(1:4) = (/  ipj,  ipj, ihls, ihls /)   ! j- count
+      ishtSi(1:4) = (/ ip1i, im1i, ip0i, ip0i /)   ! i- shift send data
+      ishtSj(1:4) = (/ ip0j, ip0j, ip1j, im1j /)   ! j- shift send data
+      ishtRi(1:4) = (/ ip0i, im0i, ip0i, ip0i /)   ! i- shift received data location
+      ishtRj(1:4) = (/ ip0j, ip0j, ip0j, im0j /)   ! j- shift received data location
+      ishtPi(1:4) = (/ im1i, ip1i, ip0i, ip0i /)   ! i- shift data used for periodicity
+      ishtPj(1:4) = (/ ip0j, ip0j, im1j, ip1j /)   ! j- shift data used for periodicity
       !
       ! -------------------------------- !
@@ -99,11 +119,11 @@
       ireq(:) = MPI_REQUEST_NULL
       iszall(:) = isizei(:) * isizej(:) * ipk * ipl * ipf
-      ishts(1) = 0
+      ishtS(1) = 0
       DO jn = 2,4
-         ishts(jn) = ishts(jn-1) + iszall(jn-1) * COUNT( (/llsend(jn-1)/) )   ! with _alltoallv: in units of sendtype
-      END DO
-      ishtr(1) = 0
+         ishtS(jn) = ishtS(jn-1) + iszall(jn-1) * COUNT( (/llsend(jn-1)/) )   ! with _alltoallv: in units of sendtype
+      END DO
+      ishtR(1) = 0
       DO jn = 2,4
-         ishtr(jn) = ishtr(jn-1) + iszall(jn-1) * COUNT( (/llrecv(jn-1)/) )   ! with _alltoallv: in units of sendtype
+         ishtR(jn) = ishtR(jn-1) + iszall(jn-1) * COUNT( (/llrecv(jn-1)/) )   ! with _alltoallv: in units of sendtype
       END DO
 
@@ -119,6 +139,6 @@
       DO jn = 1, 2
          IF( llsend(jn) ) THEN
-            ishti = ishtsi(jn)
-            ishtj = ishtsj(jn)
+            ishti = ishtSi(jn)
+            ishtj = ishtSj(jn)
             DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
                zsnd(idxs) = ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl)
@@ -134,12 +154,12 @@
       ! non-blocking send of the western/eastern side using local temporary arrays
       jn = jpwe
-      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishts(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 1, icomm, ireq(jn), ierr )
+      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), 1, icomm, ireq(jn), ierr )
       jn = jpea
-      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishts(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 2, icomm, ireq(jn), ierr )
+      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), 2, icomm, ireq(jn), ierr )
       ! blocking receive of the western/eastern halo in local temporary arrays
       jn = jpwe
-      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtr(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 2, icomm, MPI_STATUS_IGNORE, ierr )
+      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), 2, icomm, MPI_STATUS_IGNORE, ierr )
       jn = jpea
-      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtr(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 1, icomm, MPI_STATUS_IGNORE, ierr )
+      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), 1, icomm, MPI_STATUS_IGNORE, ierr )
       !
       IF( ln_timing ) CALL tic_tac(.FALSE.)
@@ -152,6 +172,6 @@
       idxr = 1
       DO jn = 1, 2
-         ishti = ishtri(jn)
-         ishtj = ishtrj(jn)
+         ishti = ishtRi(jn)
+         ishtj = ishtRj(jn)
          SELECT CASE ( ifill(jn) )
          CASE ( jpfillnothing )               ! no filling 
@@ -162,12 +182,12 @@
             END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
          CASE ( jpfillperio )                 ! use periodicity
-            ishti2 = ishtpi(jn)
-            ishtj2 = ishtpj(jn)
+            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)
                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)
+            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)
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
@@ -187,6 +207,6 @@
       !
       IF( ll_IdoNFold ) THEN
-         IF( jpni == 1 )  THEN   ;   CALL lbc_nfd( ptab, cd_nat, psgn                  , ipf )   ! self NFold
-         ELSE                    ;   CALL mpp_nfd( ptab, cd_nat, psgn, ifill_nfd, zland, ipf )   ! mpi  NFold
+         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
          ENDIF
       ENDIF
@@ -198,6 +218,6 @@
       DO jn = 3, 4
          IF( llsend(jn) ) THEN
-            ishti = ishtsi(jn)
-            ishtj = ishtsj(jn)
+            ishti = ishtSi(jn)
+            ishtj = ishtSj(jn)
             DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
                zsnd(idxs) = ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl)
@@ -212,12 +232,12 @@
       ! non-blocking send of the western/eastern side using local temporary arrays
       jn = jpso
-      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishts(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 3, icomm, ireq(jn), ierr )
+      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), 3, icomm, ireq(jn), ierr )
       jn = jpno
-      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishts(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 4, icomm, ireq(jn), ierr )
+      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), 4, icomm, ireq(jn), ierr )
       ! blocking receive of the western/eastern halo in local temporary arrays
       jn = jpso
-      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtr(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 4, icomm, MPI_STATUS_IGNORE, ierr )
+      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), 4, icomm, MPI_STATUS_IGNORE, ierr )
       jn = jpno
-      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtr(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 3, icomm, MPI_STATUS_IGNORE, ierr )
+      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), 3, icomm, MPI_STATUS_IGNORE, ierr )
       !
       IF( ln_timing ) CALL tic_tac(.FALSE.)
@@ -229,6 +249,6 @@
       !
       DO jn = 3, 4
-         ishti = ishtri(jn)
-         ishtj = ishtrj(jn)
+         ishti = ishtRi(jn)
+         ishtj = ishtRj(jn)
          SELECT CASE ( ifill(jn) )
          CASE ( jpfillnothing )               ! no filling 
@@ -239,12 +259,12 @@
             END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
          CASE ( jpfillperio )                 ! use periodicity
-            ishti2 = ishtpi(jn)
-            ishtj2 = ishtpj(jn)
+            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)
                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)
+            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)
                ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_nfd_generic.h90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_nfd_generic.h90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_nfd_generic.h90	(revision 14363)
@@ -1,18 +1,25 @@
 
-   SUBROUTINE lbc_nfd_/**/PRECISION( ptab, cd_nat, psgn, kfld )
+   SUBROUTINE lbc_nfd_/**/PRECISION( ptab, cd_nat, psgn, khls, kfld )
       TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
       CHARACTER(len=1), DIMENSION(:), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
       REAL(PRECISION),  DIMENSION(:), INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER                       , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
       INTEGER                       , INTENT(in   ) ::   kfld        ! number of pt3d arrays
       !
       INTEGER  ::    ji,  jj,  jk,  jl,  jf   ! dummy loop indices
-      INTEGER  ::        ipj, ipk, ipl, ipf   ! dimension of the input array
+      INTEGER  ::   ipi, ipj, ipk, ipl, ipf   ! dimension of the input array
       INTEGER  ::   ii1, ii2, ij1, ij2
       !!----------------------------------------------------------------------
       !
+      ipi = SIZE(ptab(1)%pt4d,1)
       ipj = SIZE(ptab(1)%pt4d,2)
       ipk = SIZE(ptab(1)%pt4d,3)
       ipl = SIZE(ptab(1)%pt4d,4)
       ipf = kfld
+      !
+      IF( ipi /= Ni0glo+2*khls ) THEN
+         WRITE(ctmp1,*) 'lbc_nfd input array does not match khls', ipi, khls, Ni0glo
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
       !
       DO jf = 1, ipf                      ! Loop on the number of arrays to be treated
@@ -24,53 +31,53 @@
                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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     DO ji = 1, 1                 ! point nn_hls+1
-                        ii1 = nn_hls + ji
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - khls + 1
+                     ij2 = ipj - 2*khls + jj - 1         ! ends at: ipj - 2*khls + khls - 1 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 2 - ji            ! ends at: 2*khls + 2 - khls = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point khls+1
+                        ii1 = khls + ji
                         ii2 = ii1
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     DO ji = 1, 1                 ! point jpiglo - nn_hls + 1
-                        ii1 = jpiglo - nn_hls + ji
-                        ii2 =          nn_hls + ji
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     !                            ! last nn_hls-1 points: have been / will done by e-w periodicity 
+                     DO ji = 1, Ni0glo - 1        ! points from khls+2 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =   2 + khls + ji - 1        ! ends at: 2 + khls + ipi - 2*khls - 1 - 1 = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls - 1 ) + 1 = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point ipi - khls + 1
+                        ii1 = ipi - khls + ji
+                        ii2 =          khls + ji
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls-1            ! last khls-1 points
+                        ii1 = ipi - khls + 1 + ji        ! ends at: ipi - khls + 1 + khls - 1 = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls + 1 = ipi - 2*khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO
+                  !
+                  ! line number ipj-khls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2-1        ! points from ipi/2+2 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 = ipi/2 + ji + 1             ! ends at: ipi/2 + (ipi/2 - khls - 1) + 1 = ipi - khls
+                        ii2 = ipi/2 - ji + 1             ! ends at: ipi/2 - (ipi/2 - khls - 1) + 1 = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! first khls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points ipi-2khls+1 to ipi-khls  
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 2 - ji            ! ends at: 2*khls + 2 - khls = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     !                            ! last khls-1 points: have been / will done by e-w periodicity 
                   END DO
                   !
@@ -79,43 +86,43 @@
                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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     !                            ! last nn_hls-1 points: have been / will done by e-w periodicity 
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - khls + 1
+                     ij2 = ipj - 2*khls + jj - 1         ! ends at: ipj - 2*khls + khls - 1 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from khls to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ipi - 2*khls = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls ) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls = ipi - 2*khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO
+                  !
+                  ! line number ipj-khls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2          ! points from ipi/2+1 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 = ipi/2 + ji                 ! ends at: ipi/2 + (ipi/2 - khls) = ipi - khls
+                        ii2 = ipi/2 - ji + 1             ! ends at: ipi/2 - (ipi/2 - khls) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! first khls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points ipi-2khls+1 to ipi-khls  
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     !                            ! last khls-1 points: have been / will done by e-w periodicity 
                   END DO
                   !
@@ -124,32 +131,32 @@
                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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     DO ji = 1, 1                 ! point nn_hls+1
-                        ii1 = nn_hls + ji
+                  ! last khls+1 lines (from ipj to ipj-khls) : full
+               	  DO jj = 1, khls+1
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - ( khls + 1 ) + 1 = ipj - khls
+                     ij2 = ipj - 2*khls + jj - 2         ! ends at: ipj - 2*khls + khls + 1 - 2 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 2 - ji            ! ends at: 2*khls + 2 - khls = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point khls+1
+                        ii1 = khls + ji
                         ii2 = ii1
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     DO ji = 1, 1                 ! point jpiglo - nn_hls + 1
-                        ii1 = jpiglo - nn_hls + ji
-                        ii2 =          nn_hls + ji
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
+                     DO ji = 1, Ni0glo - 1        ! points from khls+2 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =   2 + khls + ji - 1        ! ends at: 2 + khls + ipi - 2*khls - 1 - 1 = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls - 1 ) + 1 = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point ipi - khls + 1
+                        ii1 = ipi - khls + ji
+                        ii2 =          khls + ji
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls-1            ! last khls-1 points
+                        ii1 = ipi - khls + 1 + ji        ! ends at: ipi - khls + 1 + khls - 1 = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls + 1 = ipi - 2*khls + 2
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      END DO
@@ -160,22 +167,22 @@
                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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
+                  ! last khls+1 lines (from ipj to ipj-khls) : full
+               	  DO jj = 1, khls+1
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - ( khls + 1 ) + 1 = ipj - khls
+                     ij2 = ipj - 2*khls + jj - 2         ! ends at: ipj - 2*khls + khls + 1 - 2 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from khls to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ipi - 2*khls = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls ) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls = ipi - 2*khls + 1
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      END DO
@@ -193,45 +200,45 @@
                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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =              ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! Warning: pb with sign...
-                     END DO
-                     DO ji = 1, 1            ! points jpiglo - nn_hls
-                        ii1 = jpiglo - nn_hls + ji - 1
-                        ii2 =          nn_hls + ji
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =              ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! 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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =              ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! 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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
+                  ! first: line number ipj-khls : 3 points
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, 1                 ! points from ipi/2+1
+                        ii1 = ipi/2 + ji
+                        ii2 = ipi/2 - ji + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =            ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! Warning: pb with sign...
+                     END DO
+                     DO ji = 1, 1                 ! points ipi - khls
+                        ii1 = ipi - khls + ji - 1
+                        ii2 =          khls + ji
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =            ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! Warning: pb with sign...
+                     END DO
+                     DO ji = 1, 1                 ! point khls: redo it just in case (if e-w periodocity already done)
+                        !                         ! as we just changed point ipi - khls
+                        ii1 = khls + ji - 1
+                        ii2 = khls + ji
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =            ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! Warning: pb with sign...
+                     END DO
+                  END DO
+                  !
+                  ! Second: last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj + 1      - jj             ! ends at: ipj + 1 - khls
+                     ij2 = ipj - 2*khls + jj             ! ends at: ipj - 2*khls + khls = ipj - khls
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from khls to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ipi - 2*khls = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls ) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls = ipi - 2*khls + 1
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      END DO
@@ -242,32 +249,32 @@
                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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     DO ji = 1, 1                 ! point nn_hls
-                        ii1 = nn_hls + ji - 1
-                        ii2 = jpiglo - ii1
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     DO ji = 1, 1                 ! point jpiglo - nn_hls
-                        ii1 = jpiglo - nn_hls + ji - 1
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj + 1      - jj             ! ends at: ipj + 1 - khls
+                     ij2 = ipj - 2*khls + jj             ! ends at: ipj - 2*khls + khls = ipj - khls
+                     !
+                     DO ji = 1, khls-1            ! first khls-1 points
+                        ii1 =          ji                ! ends at: khls-1
+                        ii2 = 2*khls - ji                ! ends at: 2*khls - ( khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point khls
+                        ii1 = khls + ji - 1
+                        ii2 = ipi - ii1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from khls+1 to ipi - khls - 1  (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ( ipi - 2*khls - 1 ) = ipi - khls - 1
+                        ii2 = ipi - khls - ji            ! ends at: ipi - khls - ( ipi - 2*khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point ipi - khls
+                        ii1 = ipi - khls + ji - 1
                         ii2 = ii1
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      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
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls - ji            ! ends at: ipi - khls - khls = ipi - 2*khls
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      END DO
@@ -278,43 +285,43 @@
                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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - khls + 1
+                     ij2 = ipj - 2*khls + jj - 1         ! ends at: ipj - 2*khls + khls - 1 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from khls to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji          ! ends at: khls + ipi - 2*khls = ipi - khls
+                        ii2 = ipi - khls - ji + 1      ! ends at: ipi - khls - ( ipi - 2*khls ) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls            ! last khls points
+                        ii1 = ipi - khls + ji          ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls + 1 - ji      ! ends at: ipi - khls + 1 - khls = ipi - 2*khls + 1
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     !                            ! last nn_hls points: have been / will done by e-w periodicity 
+                  ! line number ipj-khls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2          ! points from ipi/2+1 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 = ipi/2 + ji                 ! ends at: ipi/2 + (ipi/2 - khls) = ipi - khls
+                        ii2 = ipi/2 - ji + 1             ! ends at: ipi/2 - (ipi/2 - khls) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! first khls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points ipi-2khls+1 to ipi-khls  
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     !                            ! last khls points: have been / will done by e-w periodicity 
                   END DO
                   !
@@ -323,53 +330,53 @@
                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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     DO ji = 1, 1                 ! point nn_hls
-                        ii1 = nn_hls + ji - 1
-                        ii2 = jpiglo - ii1
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     DO ji = 1, 1                 ! point jpiglo - nn_hls
-                        ii1 = jpiglo - nn_hls + ji - 1
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - khls + 1
+                     ij2 = ipj - 2*khls + jj - 1         ! ends at: ipj - 2*khls + khls - 1 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls-1            ! first khls-1 points
+                        ii1 =          ji                ! ends at: khls-1
+                        ii2 = 2*khls - ji                ! ends at: 2*khls - ( khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point khls
+                        ii1 = khls + ji - 1
+                        ii2 = ipi - ii1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from khls+1 to ipi - khls - 1  (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ( ipi - 2*khls - 1 ) = ipi - khls - 1
+                        ii2 = ipi - khls - ji            ! ends at: ipi - khls - ( ipi - 2*khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point ipi - khls
+                        ii1 = ipi - khls + ji - 1
                         ii2 = ii1
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      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
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls - ji            ! ends at: ipi - khls - khls = ipi - 2*khls
                         ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
                      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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     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
-                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
-                     END DO
-                     !                            ! last nn_hls points: have been / will done by e-w periodicity 
+                  ! line number ipj-khls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2-1        ! points from ipi/2+1 to ipi - khls-1  (note: Ni0glo = ipi - 2*khls)
+                        ii1 = ipi/2 + ji                 ! ends at: ipi/2 + (ipi/2 - khls) = ipi - khls
+                        ii2 = ipi/2 - ji                 ! ends at: ipi/2 - (ipi/2 - khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls-1            ! first khls-1 points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points ipi-2khls+1 to ipi-nn_hl-1  
+                        ii1 =          ji                ! ends at: khls
+                        ii2 = 2*khls - ji                ! ends at: 2*khls - ( khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     !                            ! last khls points: have been / will done by e-w periodicity 
                   END DO
                   !
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_nfd_nogather_generic.h90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_nfd_nogather_generic.h90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_nfd_nogather_generic.h90	(revision 14363)
@@ -1,4 +1,4 @@
 
-   SUBROUTINE lbc_nfd_nogather_/**/PRECISION( ptab, ptab2, cd_nat, psgn )
+   SUBROUTINE lbc_nfd_nogather_/**/PRECISION( ptab, ptab2, cd_nat, psgn, khls )
       !!----------------------------------------------------------------------
       !!
@@ -11,4 +11,5 @@
       CHARACTER(len=1)                    , INTENT(in   ) ::   cd_nat      ! nature of array grid-points
       REAL(PRECISION)                     , INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER                             , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
       !
       INTEGER  ::    ji,  jj, jk,  jn,  jl, jh       ! dummy loop indices
@@ -29,9 +30,9 @@
          CASE ( 'T' , 'W' )                         ! T-, W-point
             IF ( nimpp /= 1 ) THEN  ;  startloop = 1 
-            ELSE                    ;  startloop = 1 + nn_hls
-            ENDIF
-            !
-            DO jl = 1, ipl; DO jk = 1, ipk
-               DO jj = 1, nn_hls
+            ELSE                    ;  startloop = 1 + khls
+            ENDIF
+            !
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
                   ijj = jpj -jj +1
                   DO ji = startloop, jpi
@@ -43,8 +44,8 @@
             IF( nimpp == 1 ) THEN
                DO jl = 1, ipl; DO jk = 1, ipk
-                  DO jj = 1, nn_hls
+                  DO jj = 1, khls
                      ijj = jpj -jj +1
-                     DO ii = 0, nn_hls-1
-                        ptab(ii+1,ijj,jk,jl) = psgn * ptab(2*nn_hls-ii+1,jpj-2*nn_hls+jj-1,jk,jl)
+                     DO ii = 0, khls-1
+                        ptab(ii+1,ijj,jk,jl) = psgn * ptab(2*khls-ii+1,jpj-2*khls+jj-1,jk,jl)
                      END DO
                   END DO
@@ -56,5 +57,5 @@
                   startloop = 1
                ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
-                  startloop = Ni0glo/2+2 - nimpp + nn_hls
+                  startloop = Ni0glo/2+2 - nimpp + khls
                ELSE
                   startloop = jpi + 1
@@ -67,7 +68,7 @@
                         ijta = jpiglo - jia + 2
                         IF( ijta >= startloop+nimpp-1 .AND. ijta < jia ) THEN
-                           ptab(ji,jpj-nn_hls,jk,jl) = psgn * ptab(ijta-nimpp+nn_hls,jpj-nn_hls,jk,jl)
+                           ptab(ji,jpj-khls,jk,jl) = psgn * ptab(ijta-nimpp+khls,jpj-khls,jk,jl)
                         ELSE
-                           ptab(ji,jpj-nn_hls,jk,jl) = psgn * ptab2(ijt,nn_hls+1,jk,jl)
+                           ptab(ji,jpj-khls,jk,jl) = psgn * ptab2(ijt,khls+1,jk,jl)
                         ENDIF
                      END DO
@@ -79,8 +80,8 @@
                endloop = jpi
             ELSE
-               endloop = jpi - nn_hls
-            ENDIF
-            DO jl = 1, ipl; DO jk = 1, ipk
-               DO jj = 1, nn_hls
+               endloop = jpi - khls
+            ENDIF
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
                   ijj = jpj -jj +1
                   DO ji = 1, endloop
@@ -91,16 +92,16 @@
             END DO; END DO
             IF (nimpp .eq. 1) THEN
-               DO jj = 1, nn_hls
-                  ijj = jpj -jj +1
-                  DO ii = 0, nn_hls-1
-                     ptab(ii+1,ijj,:,:) = psgn * ptab(2*nn_hls-ii,jpj-2*nn_hls+jj-1,:,:)
+               DO jj = 1, khls
+                  ijj = jpj -jj +1
+                  DO ii = 0, khls-1
+                     ptab(ii+1,ijj,:,:) = psgn * ptab(2*khls-ii,jpj-2*khls+jj-1,:,:)
                   END DO
                END DO
             ENDIF
             IF((nimpp + jpi - 1) .eq. jpiglo) THEN
-               DO jj = 1, nn_hls
-                  ijj = jpj -jj +1
-                  DO ii = 1, nn_hls
-                     ptab(jpi-ii+1,ijj,:,:) = psgn * ptab(jpi-2*nn_hls+ii,jpj-2*nn_hls+jj-1,:,:)
+               DO jj = 1, khls
+                  ijj = jpj -jj +1
+                  DO ii = 1, khls
+                     ptab(jpi-ii+1,ijj,:,:) = psgn * ptab(jpi-2*khls+ii,jpj-2*khls+jj-1,:,:)
                   END DO
                END DO
@@ -111,10 +112,10 @@
                   endloop = jpi
                ELSE
-                  endloop = jpi - nn_hls
+                  endloop = jpi - khls
                ENDIF
                IF( nimpp >= Ni0glo/2+1 ) THEN
-                  startloop = nn_hls
+                  startloop = khls
                ELSEIF( ( nimpp + jpi - 1 >= Ni0glo/2+1 ) .AND. ( nimpp < Ni0glo/2+1 ) ) THEN
-                  startloop = Ni0glo/2+1 - nimpp + nn_hls 
+                  startloop = Ni0glo/2+1 - nimpp + khls 
                ELSE
                   startloop = endloop + 1
@@ -127,7 +128,7 @@
                         ijua = jpiglo - jia + 1 
                         IF( ijua >= startloop+nimpp-1 .AND. ijua < jia ) THEN
-                           ptab(ji,jpj-nn_hls,jk,jl) = psgn * ptab(ijua-nimpp+1,jpj-nn_hls,jk,jl)
+                           ptab(ji,jpj-khls,jk,jl) = psgn * ptab(ijua-nimpp+1,jpj-khls,jk,jl)
                         ELSE
-                           ptab(ji,jpj-nn_hls,jk,jl) = psgn * ptab2(iju,nn_hls+1,jk,jl)
+                           ptab(ji,jpj-khls,jk,jl) = psgn * ptab2(iju,khls+1,jk,jl)
                         ENDIF
                      END DO
@@ -140,9 +141,9 @@
                startloop = 1 
             ELSE
-               startloop = 1 + nn_hls
-            ENDIF
-            IF ( .NOT. l_fast_exchanges ) THEN
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  DO jj = 2, nn_hls+1
+               startloop = 1 + khls
+            ENDIF
+            IF ( .NOT. l_fast_exchanges ) THEN
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO jj = 2, khls+1
                      ijj = jpj -jj +1
                      DO ji = startloop, jpi
@@ -160,8 +161,8 @@
             END DO; END DO
             IF (nimpp .eq. 1) THEN
-               DO jj = 1, nn_hls
+               DO jj = 1, khls
                   ijj = jpj-jj+1
-                  DO ii = 0, nn_hls-1
-                     ptab(ii+1,ijj,:,:) = psgn * ptab(2*nn_hls-ii+1,jpj-2*nn_hls+jj-1,:,:)
+                  DO ii = 0, khls-1
+                     ptab(ii+1,ijj,:,:) = psgn * ptab(2*khls-ii+1,jpj-2*khls+jj-1,:,:)
                   END DO
                END DO
@@ -171,9 +172,9 @@
                endloop = jpi
             ELSE
-               endloop = jpi - nn_hls
-            ENDIF
-            IF ( .NOT. l_fast_exchanges ) THEN
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  DO jj = 2, nn_hls+1
+               endloop = jpi - khls
+            ENDIF
+            IF ( .NOT. l_fast_exchanges ) THEN
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO jj = 2, khls+1
                      ijj = jpj -jj +1
                      DO ji = 1, endloop
@@ -191,12 +192,12 @@
             END DO; END DO
             IF (nimpp .eq. 1) THEN               
-               DO ii = 1, nn_hls
-                  ptab(ii,jpj,:,:) = psgn * ptab(2*nn_hls-ii,jpj-2*nn_hls-1,:,:)
+               DO ii = 1, khls
+                  ptab(ii,jpj,:,:) = psgn * ptab(2*khls-ii,jpj-2*khls-1,:,:)
                END DO
                IF ( .NOT. l_fast_exchanges ) THEN
-                  DO jj = 1, nn_hls
+                  DO jj = 1, khls
                      ijj = jpj -jj
-                     DO ii = 0, nn_hls-1
-                        ptab(ii+1,ijj,:,:) = psgn * ptab(2*nn_hls-ii,jpj-2*nn_hls+jj-1,:,:)
+                     DO ii = 0, khls-1
+                        ptab(ii+1,ijj,:,:) = psgn * ptab(2*khls-ii,jpj-2*khls+jj-1,:,:)
                      END DO
                   END DO
@@ -204,12 +205,12 @@
             ENDIF
             IF((nimpp + jpi - 1 ) .eq. jpiglo) THEN
-               DO ii = 1, nn_hls
-                  ptab(jpi-ii+1,jpj,:,:) = psgn * ptab(jpi-2*nn_hls+ii,jpj-2*nn_hls-1,:,:)
+               DO ii = 1, khls
+                  ptab(jpi-ii+1,jpj,:,:) = psgn * ptab(jpi-2*khls+ii,jpj-2*khls-1,:,:)
                END DO
                IF ( .NOT. l_fast_exchanges ) THEN
-                  DO jj = 1, nn_hls
+                  DO jj = 1, khls
                      ijj = jpj -jj
-                     DO ii = 1, nn_hls
-                        ptab(jpi-ii+1,ijj,:,:) = psgn * ptab(jpi-2*nn_hls+ii,jpj-2*nn_hls+jj-1,:,:)
+                     DO ii = 1, khls
+                        ptab(jpi-ii+1,ijj,:,:) = psgn * ptab(jpi-2*khls+ii,jpj-2*khls+jj-1,:,:)
                      END DO
                   END DO
@@ -226,5 +227,5 @@
          CASE ( 'T' , 'W' )                               ! T-, W-point
             DO jl = 1, ipl; DO jk = 1, ipk
-               DO jj = 1, nn_hls
+               DO jj = 1, khls
                   ijj = jpj-jj+1
                   DO ji = 1, jpi
@@ -239,8 +240,8 @@
                endloop = jpi
             ELSE
-               endloop = jpi - nn_hls
-            ENDIF
-            DO jl = 1, ipl; DO jk = 1, ipk
-               DO jj = 1, nn_hls
+               endloop = jpi - khls
+            ENDIF
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
                   ijj = jpj-jj+1
                   DO ji = 1, endloop
@@ -252,9 +253,9 @@
             IF(nimpp + jpi - 1 .eq. jpiglo) THEN
                DO jl = 1, ipl; DO jk = 1, ipk
-                  DO jj = 1, nn_hls
+                  DO jj = 1, khls
                      ijj = jpj-jj+1
-                     DO ii = 1, nn_hls
+                     DO ii = 1, khls
                         iij = jpi-ii+1
-                        ptab(iij,ijj,jk,jl) = psgn * ptab(jpi-2*nn_hls+ii-1,jpj-2*nn_hls+jj,jk,jl)
+                        ptab(iij,ijj,jk,jl) = psgn * ptab(jpi-2*khls+ii-1,jpj-2*khls+jj,jk,jl)
                      END DO
                   END DO
@@ -264,5 +265,5 @@
          CASE ( 'V' )                                     ! V-point
             DO jl = 1, ipl; DO jk = 1, ipk
-               DO jj = 1, nn_hls
+               DO jj = 1, khls
                   ijj = jpj -jj +1
                   DO ji = 1, jpi
@@ -277,5 +278,5 @@
                   startloop = 1
                ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
-                  startloop = Ni0glo/2+2 - nimpp + nn_hls
+                  startloop = Ni0glo/2+2 - nimpp + khls
                ELSE
                   startloop = jpi + 1
@@ -285,5 +286,5 @@
                      DO ji = startloop, jpi
                         ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
-                        ptab(ji,jpj-nn_hls,jk,jl) = psgn * ptab2(ijt,nn_hls+1,jk,jl)
+                        ptab(ji,jpj-khls,jk,jl) = psgn * ptab2(ijt,khls+1,jk,jl)
                      END DO
                   END DO; END DO
@@ -295,8 +296,8 @@
                endloop = jpi
             ELSE
-               endloop = jpi - nn_hls
-            ENDIF
-            DO jl = 1, ipl; DO jk = 1, ipk
-               DO jj = 1, nn_hls
+               endloop = jpi - khls
+            ENDIF
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
                   ijj = jpj -jj +1
                   DO ji = 1, endloop
@@ -308,9 +309,9 @@
             IF((nimpp + jpi - 1) .eq. jpiglo) THEN
                DO jl = 1, ipl; DO jk = 1, ipk
-                  DO jj = 1, nn_hls
+                  DO jj = 1, khls
                      ijj = jpj -jj +1
-                     DO ii = 1, nn_hls
+                     DO ii = 1, khls
                         iij = jpi -ii+1
-                        ptab(iij,ijj,jk,jl) = psgn * ptab(jpi-2*nn_hls+ii-1,jpj-2*nn_hls+jj-1,jk,jl)
+                        ptab(iij,ijj,jk,jl) = psgn * ptab(jpi-2*khls+ii-1,jpj-2*khls+jj-1,jk,jl)
                      END DO
                   END DO
@@ -322,10 +323,10 @@
                   endloop = jpi
                ELSE
-                  endloop = jpi - nn_hls
+                  endloop = jpi - khls
                ENDIF
                IF( nimpp >= Ni0glo/2+2 ) THEN
                   startloop = 1 
                ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
-                  startloop = Ni0glo/2+2 - nimpp + nn_hls
+                  startloop = Ni0glo/2+2 - nimpp + khls
                ELSE
                   startloop = endloop + 1
@@ -335,5 +336,5 @@
                      DO ji = startloop, endloop
                         iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 2
-                        ptab(ji,jpj-nn_hls,jk,jl) = psgn * ptab2(iju,nn_hls+1,jk,jl)
+                        ptab(ji,jpj-khls,jk,jl) = psgn * ptab2(iju,khls+1,jk,jl)
                      END DO
                   END DO; END DO
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lib_mpp.F90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lib_mpp.F90	(revision 14363)
@@ -139,5 +139,8 @@
 
    ! Neighbourgs informations
-   INTEGER, DIMENSION(8), PUBLIC ::   mpinei     !: 8-neighbourg MPI indexes (starting at 0, -1 if no neighbourg)
+   INTEGER,    PARAMETER, PUBLIC ::   n_hlsmax = 3
+   INTEGER, DIMENSION(         8), PUBLIC ::   mpinei      !: 8-neighbourg MPI indexes (starting at 0, -1 if no neighbourg)
+   INTEGER, DIMENSION(n_hlsmax,8), PUBLIC ::   mpiSnei     !: 8-neighbourg Send MPI indexes (starting at 0, -1 if no neighbourg)
+   INTEGER, DIMENSION(n_hlsmax,8), PUBLIC ::   mpiRnei     !: 8-neighbourg Recv MPI indexes (starting at 0, -1 if no neighbourg)
    INTEGER,    PARAMETER, PUBLIC ::   jpwe = 1   !: WEst
    INTEGER,    PARAMETER, PUBLIC ::   jpea = 2   !: EAst
@@ -160,6 +163,6 @@
 
    ! variables used for MPI3 neighbourhood collectives
-   INTEGER, PUBLIC ::   mpi_nc_com4       ! MPI3 neighbourhood collectives communicator
-   INTEGER, PUBLIC ::   mpi_nc_com8       ! MPI3 neighbourhood collectives communicator (with diagionals)
+   INTEGER, DIMENSION(n_hlsmax), PUBLIC ::   mpi_nc_com4       ! MPI3 neighbourhood collectives communicator
+   INTEGER, DIMENSION(n_hlsmax), PUBLIC ::   mpi_nc_com8       ! MPI3 neighbourhood collectives communicator (with diagionals)
 
    ! North fold condition in mpp_mpi with jpni > 1 (PUBLIC for TAM)
@@ -1100,5 +1103,5 @@
 
    
-   SUBROUTINE mpp_ini_nc
+   SUBROUTINE mpp_ini_nc( khls )
       !!----------------------------------------------------------------------
       !!               ***  routine mpp_ini_nc  ***
@@ -1114,25 +1117,31 @@
       !!         mpi_nc_com8 = MPI3 neighbourhood collectives communicator (with diagonals)
       !!----------------------------------------------------------------------
-      INTEGER, DIMENSION(:), ALLOCATABLE :: inei4, inei8
-      INTEGER :: icnt4, icnt8
-      INTEGER :: ierr
-      LOGICAL, PARAMETER :: ireord = .FALSE.
+      INTEGER,             INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      !
+      INTEGER, DIMENSION(:), ALLOCATABLE :: iSnei4, iRnei4, iSnei8, iRnei8
+      INTEGER                            :: iScnt4, iRcnt4, iScnt8, iRcnt8
+      INTEGER                            :: ierr
+      LOGICAL, PARAMETER                 :: ireord = .FALSE.
       !!----------------------------------------------------------------------
 #if ! defined key_mpi_off && ! defined key_mpi2
       
-      icnt4 = COUNT( mpinei(1:4) >= 0 )
-      icnt8 = COUNT( mpinei(1:8) >= 0 )
-
-      ALLOCATE( inei4(icnt4), inei8(icnt8) )   ! ok if icnt4 or icnt8 = 0
-
-      inei4 = PACK( mpinei(1:4), mask = mpinei(1:4) >= 0 )
-      inei8 = PACK( mpinei(1:8), mask = mpinei(1:8) >= 0 )
-
-      CALL MPI_Dist_graph_create_adjacent(mpi_comm_oce, icnt4, inei4, MPI_UNWEIGHTED,   &
-         &                                              icnt4, inei4, MPI_UNWEIGHTED, MPI_INFO_NULL, ireord, mpi_nc_com4, ierr)
-      CALL MPI_Dist_graph_create_adjacent(mpi_comm_oce, icnt8, inei8, MPI_UNWEIGHTED,   &
-         &                                              icnt8, inei8, MPI_UNWEIGHTED, MPI_INFO_NULL, ireord, mpi_nc_com8, ierr)
-
-      DEALLOCATE (inei4, inei8)
+      iScnt4 = COUNT( mpiSnei(khls,1:4) >= 0 )
+      iRcnt4 = COUNT( mpiRnei(khls,1:4) >= 0 )
+      iScnt8 = COUNT( mpiSnei(khls,1:8) >= 0 )
+      iRcnt8 = COUNT( mpiRnei(khls,1:8) >= 0 )
+
+      ALLOCATE( iSnei4(iScnt4), iRnei4(iRcnt4), iSnei8(iScnt8), iRnei8(iRcnt8) )   ! ok if icnt4 or icnt8 = 0
+
+      iSnei4 = PACK( mpiSnei(khls,1:4), mask = mpiSnei(khls,1:4) >= 0 )
+      iRnei4 = PACK( mpiRnei(khls,1:4), mask = mpiRnei(khls,1:4) >= 0 )
+      iSnei8 = PACK( mpiSnei(khls,1:8), mask = mpiSnei(khls,1:8) >= 0 )
+      iRnei8 = PACK( mpiRnei(khls,1:8), mask = mpiRnei(khls,1:8) >= 0 )
+
+      CALL MPI_Dist_graph_create_adjacent( mpi_comm_oce, iScnt4, iSnei4, MPI_UNWEIGHTED, iRcnt4, iRnei4, MPI_UNWEIGHTED,   &
+         &                                 MPI_INFO_NULL, ireord, mpi_nc_com4(khls), ierr )
+      CALL MPI_Dist_graph_create_adjacent( mpi_comm_oce, iScnt8, iSnei8, MPI_UNWEIGHTED, iRcnt8, iRnei8, MPI_UNWEIGHTED,   &
+         &                                 MPI_INFO_NULL, ireord, mpi_nc_com8(khls), ierr)
+
+      DEALLOCATE( iSnei4, iRnei4, iSnei8, iRnei8 )
 #endif
    END SUBROUTINE mpp_ini_nc
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/mpp_nfd_generic.h90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/mpp_nfd_generic.h90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/mpp_nfd_generic.h90	(revision 14363)
@@ -1,4 +1,4 @@
 
-   SUBROUTINE mpp_nfd_/**/PRECISION( ptab, cd_nat, psgn, kfillmode, pfillval, kfld )
+   SUBROUTINE mpp_nfd_/**/PRECISION( ptab, cd_nat, psgn, kfillmode, pfillval, khls, kfld )
       TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
       CHARACTER(len=1), DIMENSION(:), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
@@ -6,4 +6,5 @@
       INTEGER                       , INTENT(in   ) ::   kfillmode   ! filling method for halo over land 
       REAL(PRECISION)               , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER                       , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
       INTEGER                       , INTENT(in   ) ::   kfld        ! number of pt3d arrays
       !
@@ -64,8 +65,8 @@
          IF( ll_add_line ) THEN
             DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
-               ipj_s(jf) = nn_hls + COUNT( (/ c_NFtype == 'T' .OR. cd_nat(jf) == 'V' .OR. cd_nat(jf) == 'F' /) ) 
+               ipj_s(jf) = khls + COUNT( (/ c_NFtype == 'T' .OR. cd_nat(jf) == 'V' .OR. cd_nat(jf) == 'F' /) ) 
             END DO
          ELSE
-            ipj_s(:) = nn_hls
+            ipj_s(:) = khls
          ENDIF
          
@@ -94,5 +95,5 @@
                ij1 = ij1 + 1
                jj_b(jj,jf) = ij1
-               jj_s(jj,jf) = jpj - 2*nn_hls + jj - i012
+               jj_s(jj,jf) = jpj - 2*khls + jj - i012
             END DO
             !
@@ -137,9 +138,9 @@
             ipi   = nfjpi (ipni)
             !
-            IF( ipni ==   1  ) THEN   ;   iis0 =   1            ! domain  left side: as e-w comm already done -> from 1st column
-            ELSE                      ;   iis0 =   1 + nn_hls   ! default: -> from inner domain 
-            ENDIF
-            IF( ipni == jpni ) THEN   ;   iie0 = ipi            ! domain right side: as e-w comm already done -> until last column
-            ELSE                      ;   iie0 = ipi - nn_hls   ! default: -> until inner domain 
+            IF( ipni ==   1  ) THEN   ;   iis0 =   1          ! domain  left side: as e-w comm already done -> from 1st column
+            ELSE                      ;   iis0 =   1 + khls   ! default: -> from inner domain 
+            ENDIF
+            IF( ipni == jpni ) THEN   ;   iie0 = ipi          ! domain right side: as e-w comm already done -> until last column
+            ELSE                      ;   iie0 = ipi - khls   ! default: -> until inner domain 
             ENDIF
             impp = nfimpp(ipni) - nfimpp(isendto(1))
@@ -205,5 +206,5 @@
             ij1 = jj_b(       1 ,jf)
             ij2 = jj_b(ipj_s(jf),jf)
-            CALL lbc_nfd_nogather( ptab(jf)%pt4d(:,:,:,:), ztabr(:,ij1:ij2,:,:), cd_nat(jf), psgn(jf) )
+            CALL lbc_nfd_nogather( ptab(jf)%pt4d(:,:,:,:), ztabr(:,ij1:ij2,:,:), cd_nat(jf), psgn(jf), khls )
          END DO
          !
@@ -221,9 +222,9 @@
          !
          ! how many lines do we exchange at max? -> ipj    (no further optimizations in this case...)
-         ipj =      nn_hls + 2
+         ipj =      khls + 2
          ! how many lines do we     need at max? -> ipj2   (no further optimizations in this case...)
-         ipj2 = 2 * nn_hls + 2
-         !
-         i0max = jpimax - 2 * nn_hls
+         ipj2 = 2 * khls + 2
+         !
+         i0max = jpimax - 2 * khls
          ibuffsize = i0max * ipj * ipk * ipl * ipf
          ALLOCATE( znorthloc(i0max,ipj,ipk,ipl,ipf), znorthglo(i0max,ipj,ipk,ipl,ipf,ndim_rank_north) )
@@ -255,10 +256,10 @@
          END DO
          !
-         ! need to fill only the first ipj lines of ztabglo as lbc_nfd don't use the last nn_hls lines
+         ! need to fill only the first ipj lines of ztabglo as lbc_nfd don't use the last khls lines
          ijnr = 0
          DO jr = 1, jpni                                                        ! recover the global north array
             iproc = nfproc(jr)
             impp  = nfimpp(jr)
-            ipi   = nfjpi( jr) - 2 * nn_hls                       ! corresponds to Ni_0 but for subdomain iproc
+            ipi   = nfjpi( jr) - 2 * khls                       ! corresponds to Ni_0 but for subdomain iproc
             IF( iproc == -1 ) THEN   ! No neighbour (land proc that was suppressed)
               !
@@ -270,5 +271,5 @@
                         ij2 = jpj - ipj2 + jj                    ! the first ipj lines of the last ipj2 lines
                         DO ji = 1, ipi
-                           ii1 = impp + nn_hls + ji - 1          ! corresponds to mig(nn_hls + ji) but for subdomain iproc
+                           ii1 = impp + khls + ji - 1            ! corresponds to mig(khls + ji) but for subdomain iproc
                            ztabglo(jf)%pt4d(ii1,jj,jk,jl) = ptab(jf)%pt4d(Nis0,ij2,jk,jl) ! chose to take the 1st inner domain point
                         END DO
@@ -279,5 +280,5 @@
                      DO jj = 1, ipj
                         DO ji = 1, ipi
-                           ii1 = impp + nn_hls + ji - 1          ! corresponds to mig(nn_hls + ji) but for subdomain iproc
+                           ii1 = impp + khls + ji - 1            ! corresponds to mig(khls + ji) but for subdomain iproc
                            ztabglo(jf)%pt4d(ii1,jj,jk,jl) = pfillval
                         END DO
@@ -291,5 +292,5 @@
                   DO jj = 1, ipj
                      DO ji = 1, ipi
-                        ii1 = impp + nn_hls + ji - 1             ! corresponds to mig(nn_hls + ji) but for subdomain iproc
+                        ii1 = impp + khls + ji - 1               ! corresponds to mig(khls + ji) but for subdomain iproc
                         ztabglo(jf)%pt4d(ii1,jj,jk,jl) = znorthglo(ji,jj,jk,jl,jf,ijnr)
                      END DO
@@ -302,10 +303,10 @@
          !
          DO jf = 1, ipf
-            CALL lbc_nfd( ztabglo(jf:jf), cd_nat(jf:jf), psgn(jf:jf), 1 )   ! North fold boundary condition
+            CALL lbc_nfd( ztabglo(jf:jf), cd_nat(jf:jf), psgn(jf:jf), khls, 1 )   ! North fold boundary condition
             DO jl = 1, ipl   ;   DO jk = 1, ipk                  ! e-w periodicity
-               DO jj = 1, nn_hls + 1
-                  ij1 = ipj2 - (nn_hls + 1) + jj                 ! need only the last nn_hls + 1 lines until ipj2
-                  ztabglo(jf)%pt4d(              1:nn_hls,ij1,jk,jl) = ztabglo(jf)%pt4d(jpiglo-2*nn_hls+1:jpiglo-nn_hls,ij1,jk,jl)
-                  ztabglo(jf)%pt4d(jpiglo-nn_hls+1:jpiglo,ij1,jk,jl) = ztabglo(jf)%pt4d(         nn_hls+1:     2*nn_hls,ij1,jk,jl)
+               DO jj = 1, khls + 1
+                  ij1 = ipj2 - (khls + 1) + jj                   ! need only the last khls + 1 lines until ipj2
+                  ztabglo(jf)%pt4d(            1:  khls,ij1,jk,jl) = ztabglo(jf)%pt4d(jpiglo-2*khls+1:jpiglo-khls,ij1,jk,jl)
+                  ztabglo(jf)%pt4d(jpiglo-khls+1:jpiglo,ij1,jk,jl) = ztabglo(jf)%pt4d(         khls+1:     2*khls,ij1,jk,jl)
                END DO
             END DO   ;   END DO
@@ -313,7 +314,7 @@
          !
          DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk               ! Scatter back to ARRAY_IN
-            DO jj = 1, nn_hls + 1
-               ij1 = jpj  - (nn_hls + 1) + jj   ! last nn_hls + 1 lines until jpj
-               ij2 = ipj2 - (nn_hls + 1) + jj   ! last nn_hls + 1 lines until ipj2
+            DO jj = 1, khls + 1
+               ij1 = jpj  - (khls + 1) + jj   ! last khls + 1 lines until jpj
+               ij2 = ipj2 - (khls + 1) + jj   ! last khls + 1 lines until ipj2
                DO ji= 1, jpi
                   ii2 = mig(ji)
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/mppini.F90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/mppini.F90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/mppini.F90	(revision 14363)
@@ -121,5 +121,5 @@
       !!                    mpinei    : number of neighboring domains (starting at 0, -1 if no neighbourg)
       !!----------------------------------------------------------------------
-      INTEGER ::   ji, jj, jn, jp
+      INTEGER ::   ji, jj, jn, jp, jh
       INTEGER ::   ii, ij, ii2, ij2
       INTEGER ::   inijmin   ! number of oce subdomains
@@ -128,4 +128,5 @@
       INTEGER ::   ierr, ios
       INTEGER ::   inbi, inbj, iimax, ijmax, icnt1, icnt2
+      INTEGER, DIMENSION(16*n_hlsmax) :: ichanged
       INTEGER, ALLOCATABLE, DIMENSION(:    ) ::   iin, ijn
       INTEGER, ALLOCATABLE, DIMENSION(:,:  ) ::   iimppt, ijpi, ipproc
@@ -441,9 +442,14 @@
          WRITE(inum,'(a)') '  jpnij jpimax jpjmax    jpk jpiglo jpjglo ( local:   narea    jpi    jpj )'
          WRITE(inum,'(6i7,a,3i7,a)') jpnij,jpimax,jpjmax,jpk,jpiglo,jpjglo,' ( local: ',narea,jpi,jpj,' )'
-         WRITE(inum,'(a)') ' narea    ii    ij   jpi   jpj nimpp njmpp mpiwe mpiea mpiso mpino mpisw mpise mpinw mpine'
+         WRITE(inum,*) 
+         WRITE(inum,       *) '------------------------------------'
+         WRITE(inum,'(a,i2)') ' Mapping of the default neighnourgs '
+         WRITE(inum,       *) '------------------------------------'
+         WRITE(inum,*) 
+         WRITE(inum,'(a)') '  rank    ii    ij   jpi   jpj nimpp njmpp mpiwe mpiea mpiso mpino mpisw mpise mpinw mpine'
          DO jp = 1, jpnij
             ii = iin(jp)
             ij = ijn(jp)
-            WRITE(inum,'(15i6)')  jp, ii, ij, ijpi(ii,ij),  ijpj(ii,ij), iimppt(ii,ij), ijmppt(ii,ij), inei(:,ii,ij)
+            WRITE(inum,'(15i6)')  jp-1, ii, ij, ijpi(ii,ij), ijpj(ii,ij), iimppt(ii,ij), ijmppt(ii,ij), inei(:,ii,ij)
          END DO
       END IF
@@ -479,4 +485,8 @@
       ! set default neighbours
       mpinei(:) = impi(:,narea)
+      DO jh = 1, n_hlsmax
+         mpiSnei(jh,:) = impi(:,narea)   ! default definition
+         mpiRnei(jh,:) = impi(:,narea)
+      END DO
       !
       IF(lwp) THEN
@@ -489,5 +499,4 @@
          WRITE(numout,*) '      mpi nei no-we = ', mpinei(jpnw)  , '   mpi nei no-ea = ', mpinei(jpne)
       ENDIF
-      !
       !                          ! Prepare mpp north fold
       !
@@ -501,8 +510,8 @@
             WRITE(numout,*) '   ==>>>   North fold boundary prepared for jpni >1'
          ENDIF
-         IF (llwrtlay) THEN   ! additional prints in layout.dat
+         IF (llwrtlay) THEN      ! additional prints in layout.dat
             WRITE(inum,*)
             WRITE(inum,*)
-            WRITE(inum,*) 'number of subdomains located along the north fold : ', ndim_rank_north
+            WRITE(inum,*) 'Number of subdomains located along the north fold : ', ndim_rank_north
             WRITE(inum,*) 'Rank of the subdomains located along the north fold : ', ndim_rank_north
             DO jp = 1, ndim_rank_north, 5
@@ -521,7 +530,41 @@
       ENDIF
       !
-      CALL mpp_ini_nc        ! Initialize communicator for neighbourhood collective communications
-      !
-      CALL init_ioipsl       ! Prepare NetCDF output file (if necessary)
+      CALL mpp_ini_nc(nn_hls)    ! Initialize communicator for neighbourhood collective communications
+      DO jh = 1, n_hlsmax
+         mpi_nc_com4(jh) = mpi_nc_com4(nn_hls)   ! default definition
+         mpi_nc_com8(jh) = mpi_nc_com8(nn_hls)
+      END DO
+      !
+      CALL init_excl_landpt      ! exclude exchanges which contain only land points
+      !
+      ! Save processor layout changes in ascii file
+      DO jh = 1, n_hlsmax    ! different halo size
+         DO ji = 1, 8
+            ichanged(16*(jh-1)  +ji) = COUNT( mpinei(ji:ji) /= mpiSnei(jh,ji:ji) )
+            ichanged(16*(jh-1)+8+ji) = COUNT( mpinei(ji:ji) /= mpiRnei(jh,ji:ji) )
+         END DO
+      END DO
+      CALL mpp_sum( "mpp_init", ichanged )   ! must be called by all processes
+      IF (llwrtlay) THEN
+         WRITE(inum,*) 
+         WRITE(inum,       *) '----------------------------------------------------------------------'
+         WRITE(inum,'(a,i2)') ' Mapping of the neighnourgs once excluding comm with only land points '
+         WRITE(inum,       *) '----------------------------------------------------------------------'
+         DO jh = 1, n_hlsmax    ! different halo size
+            WRITE(inum,*) 
+            WRITE(inum,'(a,i2)') 'halo size: ', jh
+            WRITE(inum,       *) '---------'
+            WRITE(inum,'(a)') '  rank    ii    ij mpiwe mpiea mpiso mpino mpisw mpise mpinw mpine'
+            WRITE(inum,   '(11i6,a)')  narea-1, iin(narea), ijn(narea),   mpinei(:), ' <- Org'
+            WRITE(inum,'(18x,8i6,a,i1,a)')   mpiSnei(jh,:), ' <- Send ', COUNT( mpinei(:) /= mpiSnei(jh,:) ), ' modif'
+            WRITE(inum,'(18x,8i6,a,i1,a)')   mpiRnei(jh,:), ' <- Recv ', COUNT( mpinei(:) /= mpiRnei(jh,:) ), ' modif'
+            WRITE(inum,*) ' total changes among all mpi tasks:'
+            WRITE(inum,*) '       mpiwe mpiea mpiso mpino mpisw mpise mpinw mpine'
+            WRITE(inum,'(a,8i6)') ' Send: ', ichanged(jh*16-15:jh*16-8)
+            WRITE(inum,'(a,8i6)') ' Recv: ', ichanged(jh*16 -7:jh*16  )
+         END DO
+      END IF
+      !
+      CALL init_ioipsl           ! Prepare NetCDF output file (if necessary)
       !
       IF (llwrtlay) CLOSE(inum)
@@ -878,5 +921,5 @@
          !
          ALLOCATE( lloce(Ni0glo, ijsz) )                                     ! allocate the strip
-         CALL readbot_strip( ijstr, ijsz, lloce )
+         CALL read_mask( 1, ijstr, Ni0glo, ijsz, lloce )
          inboce = COUNT(lloce)                                               ! number of ocean point in the stripe
          DEALLOCATE(lloce)
@@ -948,9 +991,9 @@
             inry = iny - COUNT( (/ iarea == 1, iarea == inbj /) )      ! number of point to read in y-direction
             isty = 1 + COUNT( (/ iarea == 1 /) )                       ! read from the first or the second line?
-            CALL readbot_strip( ijmppt(1,iarea) - 2 + isty, inry, lloce(2:inx-1, isty:inry+isty-1) )   ! read the strip
+            CALL read_mask( 1, ijmppt(1,iarea) - 2 + isty, Ni0glo, inry, lloce(2:inx-1, isty:inry+isty-1) )   ! read the strip
             !
             IF( iarea == 1    ) THEN                                   ! the first line was not read
                IF( l_Jperio ) THEN                                     !   north-south periodocity
-                  CALL readbot_strip( Nj0glo, 1, lloce(2:inx-1, 1) )   !   read the last line -> first line of lloce
+                  CALL read_mask( 1, Nj0glo, Ni0glo, 1, lloce(2:inx-1, 1) )   !   read the last line -> first line of lloce
                ELSE
                   lloce(2:inx-1,  1) = .FALSE.                         !   closed boundary
@@ -959,5 +1002,5 @@
             IF( iarea == inbj ) THEN                                   ! the last line was not read
                IF( l_Jperio ) THEN                                     !   north-south periodocity
-                  CALL readbot_strip( 1, 1, lloce(2:inx-1,iny) )       !      read the first line -> last line of lloce
+                  CALL read_mask( 1, 1, Ni0glo, 1, lloce(2:inx-1,iny) )   !      read the first line -> last line of lloce
                ELSEIF( c_NFtype == 'T' ) THEN                          !   north-pole folding T-pivot, T-point
                   lloce(2,iny) = lloce(2,iny-2)                        !      here we have 1 halo (even if nn_hls>1)
@@ -1004,7 +1047,7 @@
 
 
-   SUBROUTINE readbot_strip( kjstr, kjcnt, ldoce )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE readbot_strip  ***
+   SUBROUTINE read_mask( kistr, kjstr, kicnt, kjcnt, ldoce )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE read_mask  ***
       !!
       !! ** Purpose : Read relevant bathymetric information in order to
@@ -1014,10 +1057,10 @@
       !! ** Method  : read stipe of size (Ni0glo,...)
       !!----------------------------------------------------------------------
-      INTEGER                         , INTENT(in   ) ::   kjstr       ! starting j position of the reading
-      INTEGER                         , INTENT(in   ) ::   kjcnt       ! number of lines to read
-      LOGICAL, DIMENSION(Ni0glo,kjcnt), INTENT(  out) ::   ldoce       ! ldoce(i,j) = .true. if the point (i,j) is ocean
-      !
-      INTEGER                           ::   inumsave                ! local logical unit
-      REAL(wp), DIMENSION(Ni0glo,kjcnt) ::   zbot, zbdy
+      INTEGER                        , INTENT(in   ) ::   kistr, kjstr   ! starting i and j position of the reading
+      INTEGER                        , INTENT(in   ) ::   kicnt, kjcnt   ! number of points to read in i and j directions
+      LOGICAL, DIMENSION(kicnt,kjcnt), INTENT(  out) ::   ldoce          ! ldoce(i,j) = .true. if the point (i,j) is ocean
+      !
+      INTEGER                          ::   inumsave                     ! local logical unit
+      REAL(wp), DIMENSION(kicnt,kjcnt) ::   zbot, zbdy
       !!----------------------------------------------------------------------
       !
@@ -1025,5 +1068,5 @@
       !
       IF( numbot /= -1 ) THEN
-         CALL iom_get( numbot, jpdom_unknown, 'bottom_level', zbot, kstart = (/1,kjstr/), kcount = (/Ni0glo, kjcnt/) )
+         CALL iom_get( numbot, jpdom_unknown, 'bottom_level', zbot, kstart = (/kistr,kjstr/), kcount = (/kicnt, kjcnt/) )
       ELSE
          zbot(:,:) = 1._wp                      ! put a non-null value
@@ -1031,12 +1074,12 @@
       !
       IF( numbdy /= -1 ) THEN                   ! Adjust with bdy_msk if it exists
-         CALL iom_get ( numbdy, jpdom_unknown,     'bdy_msk', zbdy, kstart = (/1,kjstr/), kcount = (/Ni0glo, kjcnt/) )
+         CALL iom_get ( numbdy, jpdom_unknown,     'bdy_msk', zbdy, kstart = (/kistr,kjstr/), kcount = (/kicnt, kjcnt/) )
          zbot(:,:) = zbot(:,:) * zbdy(:,:)
       ENDIF
       !
-      ldoce(:,:) = zbot(:,:) > 0._wp
+      ldoce(:,:) = NINT(zbot(:,:)) > 0
       numout = inumsave
       !
-   END SUBROUTINE readbot_strip
+   END SUBROUTINE read_mask
 
 
@@ -1092,4 +1135,85 @@
       !
    END SUBROUTINE mpp_getnum
+
+
+   SUBROUTINE init_excl_landpt
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE   ***
+      !!
+      !! ** Purpose : exclude exchanges which contain only land points
+      !!
+      !! ** Method  : if a send or receive buffer constains only land point we
+      !!              flag off the corresponding communication
+      !!              Warning: this selection depend on the halo size -> loop on halo size
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER ::   inumsave
+      INTEGER ::   jh
+      INTEGER ::   ipi, ipj
+      INTEGER ::   iiwe, iiea, iist, iisz 
+      INTEGER ::   ijso, ijno, ijst, ijsz 
+      LOGICAL ::   llsave
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   zmsk
+      LOGICAL , DIMENSION(Ni_0,Nj_0,1)      ::   lloce
+      !!----------------------------------------------------------------------
+      !
+      ! read the land-sea mask on the inner domain
+      CALL read_mask( nimpp, njmpp, Ni_0, Nj_0, lloce(:,:,1) )
+      !
+      ! Here we look only at communications excluding the NP folding.
+      ! As lbcnfd not validated if halo size /= nn_hls, we switch if off temporary...
+      llsave = l_IdoNFold
+      l_IdoNFold = .FALSE.
+      !
+      DO jh = 1, n_hlsmax    ! different halo size
+         !
+         ipi = Ni_0 + 2*jh   ! local domain size
+         ipj = Nj_0 + 2*jh
+         !
+         ALLOCATE( zmsk(ipi,ipj) )
+         zmsk(jh+1:jh+Ni_0,jh+1:jh+Nj_0) = REAL(COUNT(lloce, dim = 3), wp)   ! define inner domain -> need REAL to use lbclnk
+         CALL lbc_lnk('mppini', zmsk, 'T', 1._wp, khls = jh)                 ! fill halos
+         !        
+         iiwe = jh   ;   iiea = Ni_0   ! bottom-left corfer - 1 of the sent data
+         ijso = jh   ;   ijno = Nj_0
+         IF( nn_comm == 1 ) THEN 
+            iist =  0   ;   iisz = ipi
+            ijst =  0   ;   ijsz = ipj
+         ELSE
+            iist = jh   ;   iisz = Ni_0
+            ijst = jh   ;   ijsz = Nj_0
+         ENDIF
+IF( nn_comm == 1 ) THEN       ! SM: NOT WORKING FOR NEIGHBOURHOOD COLLECTIVE COMMUNICATIONS, I DON'T KNOW WHY... 
+         ! do not send if we send only land points
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijst+1:ijst+ijsz) )) == 0 )   mpiSnei(jh,jpwe) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijst+1:ijst+ijsz) )) == 0 )   mpiSnei(jh,jpea) = -1
+         IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijso+1:ijso+jh  ) )) == 0 )   mpiSnei(jh,jpso) = -1
+         IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijno+1:ijno+jh  ) )) == 0 )   mpiSnei(jh,jpno) = -1
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijso+1:ijso+jh  ) )) == 0 )   mpiSnei(jh,jpsw) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijso+1:ijso+jh  ) )) == 0 )   mpiSnei(jh,jpse) = -1
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijno+1:ijno+jh  ) )) == 0 )   mpiSnei(jh,jpnw) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijno+1:ijno+jh  ) )) == 0 )   mpiSnei(jh,jpne) = -1
+         !
+         iiwe = iiwe-jh   ;   iiea = iiea+jh   ! bottom-left corfer - 1 of the received data
+         ijso = ijso-jh   ;   ijno = ijno+jh
+         ! do not send if we send only land points
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijst+1:ijst+ijsz) )) == 0 )   mpiRnei(jh,jpwe) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijst+1:ijst+ijsz) )) == 0 )   mpiRnei(jh,jpea) = -1
+         IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijso+1:ijso+jh  ) )) == 0 )   mpiRnei(jh,jpso) = -1
+         IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijno+1:ijno+jh  ) )) == 0 )   mpiRnei(jh,jpno) = -1
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijso+1:ijso+jh  ) )) == 0 )   mpiRnei(jh,jpsw) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijso+1:ijso+jh  ) )) == 0 )   mpiRnei(jh,jpse) = -1
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijno+1:ijno+jh  ) )) == 0 )   mpiRnei(jh,jpnw) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijno+1:ijno+jh  ) )) == 0 )   mpiRnei(jh,jpne) = -1
+ENDIF
+         !
+         DEALLOCATE( zmsk )
+         !
+         CALL mpp_ini_nc(jh)    ! Initialize/Update communicator for neighbourhood collective communications
+         !
+      END DO
+      l_IdoNFold = llsave
+
+   END SUBROUTINE init_excl_landpt
 
 
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/SBC/sbcblk.F90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/SBC/sbcblk.F90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/SBC/sbcblk.F90	(revision 14363)
@@ -501,5 +501,6 @@
       !!----------------------------------------------------------------------
       REAL(wp), DIMENSION(jpi,jpj) ::   zssq, zcd_du, zsen, zlat, zevp
-      REAL(wp) :: ztmp
+      REAL(wp) :: ztst
+      LOGICAL  :: llerr
       !!----------------------------------------------------------------------
       !
@@ -512,18 +513,19 @@
          IF(lwp) WRITE(numout,*) ' === AGRIF => Sanity/consistence test on air humidity SKIPPED! :( ==='
 #else
-         ztmp = SUM(tmask(:,:,1)) ! number of ocean points on local proc domain
-         IF( ztmp > 8._wp ) THEN ! test only on proc domains with at least 8 ocean points!
-            ztmp = SUM(sf(jp_humi)%fnow(:,:,1)*tmask(:,:,1))/ztmp ! mean humidity over ocean on proc
+         ztst = SUM(tmask(:,:,1)) ! number of ocean points on local proc domain
+         IF( ztst > 8._wp ) THEN ! test only on proc domains with at least 8 ocean points!
+            ztst = SUM(sf(jp_humi)%fnow(:,:,1)*tmask(:,:,1))/ztst ! mean humidity over ocean on proc
+            llerr = .FALSE.
             SELECT CASE( nhumi )
             CASE( np_humi_sph ) ! specific humidity => expect: 0. <= something < 0.065 [kg/kg] (0.061 is saturation at 45degC !!!)
-               IF(  (ztmp < 0._wp) .OR. (ztmp > 0.065)  ) ztmp = -1._wp
+               IF( (ztst <   0._wp) .OR. (ztst > 0.065_wp) )   llerr = .TRUE.
             CASE( np_humi_dpt ) ! dew-point temperature => expect: 110. <= something < 320. [K]
-               IF( (ztmp < 110._wp).OR.(ztmp > 320._wp) ) ztmp = -1._wp
+               IF( (ztst < 110._wp) .OR. (ztst >  320._wp) )   llerr = .TRUE.
             CASE( np_humi_rlh ) ! relative humidity => expect: 0. <= something < 100. [%]
-               IF(  (ztmp < 0._wp) .OR.(ztmp > 100._wp) ) ztmp = -1._wp
+               IF( (ztst <   0._wp) .OR. (ztst >  100._wp) )   llerr = .TRUE.
             END SELECT
-            IF(ztmp < 0._wp) THEN
-               IF (lwp) WRITE(numout,'("   Mean humidity value found on proc #",i6.6," is: ",f10.5)') narea, ztmp
-               CALL ctl_stop( 'STOP', 'Something is wrong with air humidity!!!', &
+            IF(llerr) THEN
+               WRITE(ctmp1,'("   Error on mean humidity value: ",f10.5)') ztst
+               CALL ctl_stop( 'STOP', ctmp1, 'Something is wrong with air humidity!!!', &
                   &   ' ==> check the unit in your input files'       , &
                   &   ' ==> check consistence of namelist choice: specific? relative? dew-point?', &
Index: NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/lib_fortran.F90
===================================================================
--- NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/lib_fortran.F90	(revision 14349)
+++ NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/lib_fortran.F90	(revision 14363)
@@ -232,5 +232,5 @@
       ! no need for 2nd exchange when nn_hls > 1
       IF( nn_hls == 1 ) THEN
-         IF( mpinei(jpwe) > -1 ) THEN   ! 1st column was changed beacuse of an MPI communication during the previous call to lbc_lnk
+         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 
@@ -238,13 +238,13 @@
                p2d(    2,:) = p2d(    1,:)      !  previous lbc_lnk fix column 1 -> copy it to column 2 
          ENDIF
-         IF( mpinei(jpea) > -1 ) THEN
+         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( mpinei(jpso) > -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( mpinei(jpno) > -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)
@@ -289,5 +289,5 @@
       ! no need for 2nd exchange when nn_hls > 1
       IF( nn_hls == 1 ) THEN
-         IF( mpinei(jpwe) > -1 ) THEN   ! 1st column was changed beacuse of an MPI communication during the previous call to lbc_lnk
+         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 
@@ -295,13 +295,13 @@
                p3d(    2,:,:) = p3d(    1,:,:)   !  previous lbc_lnk fix column 1 -> copy it to column 2 
          ENDIF
-         IF( mpinei(jpea) > -1 ) THEN
+         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( mpinei(jpso) > -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( mpinei(jpno) > -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,:)
