Index: branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 8882)
+++ branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 9012)
@@ -41,5 +41,4 @@
    !!   mynode        : indentify the processor unit
    !!   mpp_lnk       : interface (defined in lbclnk) for message passing of 2d or 3d arrays (mpp_lnk_2d, mpp_lnk_3d)
-   !!   mpp_lnk_e     : interface (defined in lbclnk) for message passing of 2d array with extra halo (mpp_lnk_2d_e)
    !!   mpp_lnk_icb   : interface for message passing of 2d arrays with extra halo for icebergs (mpp_lnk_2d_icb)
    !!   mpprecv       :
@@ -55,7 +54,5 @@
    !!   mppstop       :
    !!   mpp_ini_north : initialisation of north fold
-!!gm   !!   mpp_lbc_north : north fold processors gathering
-   !!   mpp_lbc_north_e : variant of mpp_lbc_north for extra outer halo
-   !!   mpp_lbc_north_icb : variant of mpp_lbc_north for extra outer halo with icebergs
+   !!   mpp_lbc_north_icb : alternative to mpp_nfd for extra outer halo with icebergs
    !!----------------------------------------------------------------------
    USE dom_oce        ! ocean space and time domain
@@ -75,5 +72,4 @@
    PUBLIC   mpp_lnk_2d      , mpp_lnk_3d      , mpp_lnk_4d
    PUBLIC   mpp_lnk_2d_ptr, mpp_lnk_3d_ptr, mpp_lnk_4d_ptr
-   PUBLIC   mpp_lnk_2d_e
    !
 !!gm  this should be useless
@@ -84,11 +80,9 @@
    PUBLIC   ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam
    PUBLIC   mynode, mppstop, mppsync, mpp_comm_free
-   PUBLIC   mpp_ini_north, mpp_lbc_north_e
-!!gm   PUBLIC   mpp_ini_north, mpp_lbc_north, mpp_lbc_north_e
-   PUBLIC   mpp_lbc_north_icb, mpp_lnk_2d_icb
+   PUBLIC   mpp_ini_north
+   PUBLIC   mpp_lnk_2d_icb
+   PUBLIC   mpp_lbc_north_icb
    PUBLIC   mpp_min, mpp_max, mpp_sum, mpp_minloc, mpp_maxloc
    PUBLIC   mpp_max_multiple
-!!gm   PUBLIC   mpp_lnk_2d_9 
-!!gm   PUBLIC   mpp_lnk_sum_3d, mpp_lnk_sum_2d
    PUBLIC   mppscatter, mppgather
    PUBLIC   mpp_ini_ice, mpp_ini_znl
@@ -112,7 +106,4 @@
          &             mppsum_realdd, mppsum_a_realdd
    END INTERFACE
-!!gm   INTERFACE mpp_lbc_north
-!!gm      MODULE PROCEDURE mpp_lbc_north_3d, mpp_lbc_north_2d
-!!gm   END INTERFACE
    INTERFACE mpp_minloc
       MODULE PROCEDURE mpp_minloc2d ,mpp_minloc3d
@@ -145,5 +136,5 @@
 
    ! variables used in case of sea-ice
-   INTEGER, PUBLIC ::   ncomm_ice       !: communicator made by the processors with sea-ice (public so that it can be freed in icethd)
+   INTEGER, PUBLIC ::   ncomm_ice       !: communicator made by the processors with sea-ice (public so that it can be freed in limthd)
    INTEGER         ::   ngrp_iworld     !  group ID for the world processors (for rheology)
    INTEGER         ::   ngrp_ice        !  group ID for the ice processors (for rheology)
@@ -454,9 +445,4 @@
 #     include "mpp_bdy_generic.h90"
 #     undef ROUTINE_BDY
-#     define MULTI
-#     define ROUTINE_BDY           mpp_lnk_bdy_2d_ptr
-#     include "mpp_bdy_generic.h90"
-#     undef ROUTINE_BDY
-#     undef MULTI
 #  undef DIM_2d
    !
@@ -467,9 +453,4 @@
 #     include "mpp_bdy_generic.h90"
 #     undef ROUTINE_BDY
-#     define MULTI
-#     define ROUTINE_BDY           mpp_lnk_bdy_3d_ptr
-#     include "mpp_bdy_generic.h90"
-#     undef ROUTINE_BDY
-#     undef MULTI
 #  undef DIM_3d
    !
@@ -480,9 +461,4 @@
 !!#     include "mpp_bdy_generic.h90"
 !!#     undef ROUTINE_BDY
-!!#     define MULTI
-!!#     define ROUTINE_BDY           mpp_lnk_bdy_4d_ptr
-!!#     include "mpp_bdy_generic.h90"
-!!#     undef ROUTINE_BDY
-!!#     undef MULTI
 !!#  undef DIM_4d
 
@@ -492,7 +468,4 @@
    
    
-   !!    mpp_lnk_2d_e     utilisé dans ICB 
-
-
    !!    mpp_lnk_sum_2d et 3D   ====>>>>>>   à virer du code !!!!
    
@@ -500,187 +473,4 @@
    !!----------------------------------------------------------------------
 
-
-   SUBROUTINE mpp_lnk_2d_e( pt2d, cd_type, psgn, jpri, jprj )
-      !!----------------------------------------------------------------------
-      !!                  ***  routine mpp_lnk_2d_e  ***
-      !!
-      !! ** Purpose :   Message passing manadgement for 2d array (with halo)
-      !!
-      !! ** Method  :   Use mppsend and mpprecv function for passing mask
-      !!      between processors following neighboring subdomains.
-      !!            domain parameters
-      !!                    nlci   : first dimension of the local subdomain
-      !!                    nlcj   : second dimension of the local subdomain
-      !!                    jpri   : number of rows for extra outer halo
-      !!                    jprj   : number of columns for extra outer halo
-      !!                    nbondi : mark for "east-west local boundary"
-      !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors
-      !!                    nowe   : number for local neighboring processors
-      !!                    noso   : number for local neighboring processors
-      !!                    nono   : number for local neighboring processors
-      !!
-      !!----------------------------------------------------------------------
-      INTEGER                                             , INTENT(in   ) ::   jpri
-      INTEGER                                             , INTENT(in   ) ::   jprj
-      REAL(wp), DIMENSION(1-jpri:jpi+jpri,1-jprj:jpj+jprj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
-      CHARACTER(len=1)                                    , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
-      !                                                                                 ! = T , U , V , F , W and I points
-      REAL(wp)                                            , INTENT(in   ) ::   psgn     ! =-1 the sign change across the
-      !!                                                                                ! north boundary, =  1. otherwise
-      INTEGER  ::   jl   ! dummy loop indices
-      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers
-      INTEGER  ::   ipreci, iprecj             ! temporary integers
-      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
-      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
-      !!
-      REAL(wp), DIMENSION(1-jpri:jpi+jpri,jprecj+jprj,2) :: r2dns
-      REAL(wp), DIMENSION(1-jpri:jpi+jpri,jprecj+jprj,2) :: r2dsn
-      REAL(wp), DIMENSION(1-jprj:jpj+jprj,jpreci+jpri,2) :: r2dwe
-      REAL(wp), DIMENSION(1-jprj:jpj+jprj,jpreci+jpri,2) :: r2dew
-      !!----------------------------------------------------------------------
-
-      ipreci = jpreci + jpri      ! take into account outer extra 2D overlap area
-      iprecj = jprecj + jprj
-
-
-      ! 1. standard boundary treatment   (CAUTION: the order matters Here !!!! )
-      ! ------------------------------
-      !                                !== North-South boundaries
-      !                                      !* cyclic
-      IF( nbondj == 2 .AND. jperio == 7 ) THEN
-         pt2d(:, 1-jprj:  1     ) = pt2d ( :, jpjm1-jprj:jpjm1 )
-         pt2d(:, jpj   :jpj+jprj) = pt2d ( :, 2         :2+jprj)
-      ELSE                                   !* closed
-         IF( .NOT. cd_type == 'F' )   pt2d(:,  1-jprj   :  jprecj  ) = 0._wp     ! south except at F-point
-                                      pt2d(:,nlcj-jprecj+1:jpj+jprj) = 0._wp     ! north
-      ENDIF
-      !                                !== East-West boundaries
-      !                                      !* Cyclic east-west
-      IF( nbondi == 2 .AND. (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
-         pt2d(1-jpri:     1    ,:) = pt2d(jpim1-jpri:  jpim1 ,:)              ! east
-         pt2d(   jpi  :jpi+jpri,:) = pt2d(     2      :2+jpri,:)              ! west
-      ELSE                                   !* closed
-         IF( .NOT. cd_type == 'F' )   pt2d(  1-jpri   :jpreci    ,:) = 0._wp  ! south except at F-point
-                                      pt2d(nlci-jpreci+1:jpi+jpri,:) = 0._wp  ! north
-      ENDIF
-      !
-      ! north fold treatment
-      ! --------------------
-      IF( npolj /= 0 ) THEN
-         !
-         SELECT CASE ( jpni )
-!!gm ERROR        CASE ( 1 )     ;   CALL lbc_nfd        ( pt2d(1:jpi,1:jpj+jprj), cd_type, psgn, pr2dj=jprj )
-!!gm ERROR         CASE DEFAULT   ;   CALL mpp_lbc_north_e( pt2d                  , cd_type, psgn             )
-         END SELECT
-         !
-      ENDIF
-
-      ! 2. East and west directions exchange
-      ! ------------------------------------
-      ! we play with the neigbours AND the row number because of the periodicity
-      !
-      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
-      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
-         iihom = nlci-nreci-jpri
-         DO jl = 1, ipreci
-            r2dew(:,jl,1) = pt2d(jpreci+jl,:)
-            r2dwe(:,jl,1) = pt2d(iihom +jl,:)
-         END DO
-      END SELECT
-      !
-      !                           ! Migrations
-      imigr = ipreci * ( jpj + 2*jprj)
-      !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
-         CALL mppsend( 2, r2dwe(1-jprj,1,1), imigr, noea, ml_req1 )
-         CALL mpprecv( 1, r2dew(1-jprj,1,2), imigr, noea )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      CASE ( 0 )
-         CALL mppsend( 1, r2dew(1-jprj,1,1), imigr, nowe, ml_req1 )
-         CALL mppsend( 2, r2dwe(1-jprj,1,1), imigr, noea, ml_req2 )
-         CALL mpprecv( 1, r2dew(1-jprj,1,2), imigr, noea )
-         CALL mpprecv( 2, r2dwe(1-jprj,1,2), imigr, nowe )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
-      CASE ( 1 )
-         CALL mppsend( 1, r2dew(1-jprj,1,1), imigr, nowe, ml_req1 )
-         CALL mpprecv( 2, r2dwe(1-jprj,1,2), imigr, nowe )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      END SELECT
-      !
-      !                           ! Write Dirichlet lateral conditions
-      iihom = nlci - jpreci
-      !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
-         DO jl = 1, ipreci
-            pt2d(iihom+jl,:) = r2dew(:,jl,2)
-         END DO
-      CASE ( 0 )
-         DO jl = 1, ipreci
-            pt2d(jl-jpri,:) = r2dwe(:,jl,2)
-            pt2d( iihom+jl,:) = r2dew(:,jl,2)
-         END DO
-      CASE ( 1 )
-         DO jl = 1, ipreci
-            pt2d(jl-jpri,:) = r2dwe(:,jl,2)
-         END DO
-      END SELECT
-
-      ! 3. North and south directions
-      ! -----------------------------
-      ! always closed : we play only with the neigbours
-      !
-      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
-         ijhom = nlcj-nrecj-jprj
-         DO jl = 1, iprecj
-            r2dsn(:,jl,1) = pt2d(:,ijhom +jl)
-            r2dns(:,jl,1) = pt2d(:,jprecj+jl)
-         END DO
-      ENDIF
-      !
-      !                           ! Migrations
-      imigr = iprecj * ( jpi + 2*jpri )
-      !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         CALL mppsend( 4, r2dsn(1-jpri,1,1), imigr, nono, ml_req1 )
-         CALL mpprecv( 3, r2dns(1-jpri,1,2), imigr, nono )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      CASE ( 0 )
-         CALL mppsend( 3, r2dns(1-jpri,1,1), imigr, noso, ml_req1 )
-         CALL mppsend( 4, r2dsn(1-jpri,1,1), imigr, nono, ml_req2 )
-         CALL mpprecv( 3, r2dns(1-jpri,1,2), imigr, nono )
-         CALL mpprecv( 4, r2dsn(1-jpri,1,2), imigr, noso )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
-      CASE ( 1 )
-         CALL mppsend( 3, r2dns(1-jpri,1,1), imigr, noso, ml_req1 )
-         CALL mpprecv( 4, r2dsn(1-jpri,1,2), imigr, noso )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      END SELECT
-      !
-      !                           ! Write Dirichlet lateral conditions
-      ijhom = nlcj - jprecj
-      !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         DO jl = 1, iprecj
-            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
-         END DO
-      CASE ( 0 )
-         DO jl = 1, iprecj
-            pt2d(:,jl-jprj) = r2dsn(:,jl,2)
-            pt2d(:,ijhom+jl ) = r2dns(:,jl,2)
-         END DO
-      CASE ( 1 )
-         DO jl = 1, iprecj
-            pt2d(:,jl-jprj) = r2dsn(:,jl,2)
-         END DO
-      END SELECT
-      !
-   END SUBROUTINE mpp_lnk_2d_e
 
 
@@ -1458,78 +1248,4 @@
 
 
-   SUBROUTINE mpp_lbc_north_e( pt2d, cd_type, psgn)
-      !!---------------------------------------------------------------------
-      !!                   ***  routine mpp_lbc_north_2d  ***
-      !!
-      !! ** Purpose :   Ensure proper north fold horizontal bondary condition
-      !!              in mpp configuration in case of jpn1 > 1 and for 2d
-      !!              array with outer extra halo
-      !!
-      !! ** Method  :   North fold condition and mpp with more than one proc
-      !!              in i-direction require a specific treatment. We gather
-      !!              the 4+2*jpr2dj northern lines of the global domain on 1
-      !!              processor and apply lbc north-fold on this sub array.
-      !!              Then we scatter the north fold array back to the processors.
-      !!
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
-      CHARACTER(len=1)                                            , INTENT(in   ) ::   cd_type  ! nature of pt3d grid-points
-      REAL(wp)                                                    , INTENT(in   ) ::   psgn     ! sign used across the north fold
-      !
-      INTEGER ::   ji, jj, jr
-      INTEGER ::   ierr, itaille, ildi, ilei, iilb
-      INTEGER ::   ijpj, ij, iproc
-      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE  ::  ztab_e, znorthloc_e
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE  ::  znorthgloio_e
-      !!----------------------------------------------------------------------
-      !
-      ALLOCATE( ztab_e(jpiglo,4+2*jpr2dj), znorthloc_e(jpi,4+2*jpr2dj), znorthgloio_e(jpi,4+2*jpr2dj,jpni) )
-      !
-      ijpj=4
-      ztab_e(:,:) = 0._wp
-
-      ij = 0
-      ! put in znorthloc_e the last 4 jlines of pt2d
-      DO jj = nlcj - ijpj + 1 - jpr2dj, nlcj +jpr2dj
-         ij = ij + 1
-         DO ji = 1, jpi
-            znorthloc_e(ji,ij) = pt2d(ji,jj)
-         END DO
-      END DO
-      !
-      itaille = jpi * ( ijpj + 2 * jpr2dj )
-      CALL MPI_ALLGATHER( znorthloc_e(1,1)    , itaille, MPI_DOUBLE_PRECISION,    &
-         &                znorthgloio_e(1,1,1), itaille, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
-      !
-      DO jr = 1, ndim_rank_north            ! recover the global north array
-         iproc = nrank_north(jr) + 1
-         ildi  = nldit (iproc)
-         ilei  = nleit (iproc)
-         iilb  = nimppt(iproc)
-         DO jj = 1, ijpj+2*jpr2dj
-            DO ji = ildi, ilei
-               ztab_e(ji+iilb-1,jj) = znorthgloio_e(ji,jj,jr)
-            END DO
-         END DO
-      END DO
-
-      ! 2. North-Fold boundary conditions
-      ! ----------------------------------
-!!gm ERROR      CALL lbc_nfd( ztab_e(:,:), cd_type, psgn, pr2dj = jpr2dj )
-
-      ij = jpr2dj
-      !! Scatter back to pt2d
-      DO jj = nlcj - ijpj + 1 , nlcj +jpr2dj
-      ij  = ij +1
-         DO ji= 1, nlci
-            pt2d(ji,jj) = ztab_e(ji+nimpp-1,ij)
-         END DO
-      END DO
-      !
-      DEALLOCATE( ztab_e, znorthloc_e, znorthgloio_e )
-      !
-   END SUBROUTINE mpp_lbc_north_e
-
-
    SUBROUTINE mpi_init_opa( ldtxt, ksft, code )
       !!---------------------------------------------------------------------
@@ -1623,5 +1339,5 @@
 
 
-   SUBROUTINE mpp_lbc_north_icb( pt2d, cd_type, psgn, pr2dj)
+   SUBROUTINE mpp_lbc_north_icb( pt2d, cd_type, psgn, kextj)
       !!---------------------------------------------------------------------
       !!                   ***  routine mpp_lbc_north_icb  ***
@@ -1633,8 +1349,9 @@
       !! ** Method  :   North fold condition and mpp with more than one proc
       !!              in i-direction require a specific treatment. We gather
-      !!              the 4+2*jpr2dj northern lines of the global domain on 1
+      !!              the 4+kextj northern lines of the global domain on 1
       !!              processor and apply lbc north-fold on this sub array.
       !!              Then we scatter the north fold array back to the processors.
-      !!              This version accounts for an extra halo with icebergs.
+      !!              This routine accounts for an extra halo with icebergs
+      !!              and assumes ghost rows and columns have been suppressed.
       !!
       !!----------------------------------------------------------------------
@@ -1644,9 +1361,9 @@
       REAL(wp)                , INTENT(in   ) ::   psgn     ! = -1. the sign change across the
       !!                                                    ! north fold, =  1. otherwise
-      INTEGER, OPTIONAL       , INTENT(in   ) ::   pr2dj
+      INTEGER                 , INTENT(in   ) ::   kextj    ! Extra halo width at north fold
       !
       INTEGER ::   ji, jj, jr
       INTEGER ::   ierr, itaille, ildi, ilei, iilb
-      INTEGER ::   ijpj, ij, iproc, ipr2dj
+      INTEGER ::   ipj, ij, iproc
       !
       REAL(wp), DIMENSION(:,:)  , ALLOCATABLE  ::  ztab_e, znorthloc_e
@@ -1654,24 +1371,19 @@
       !!----------------------------------------------------------------------
       !
-      ijpj=4
-      IF( PRESENT(pr2dj) ) THEN           ! use of additional halos
-         ipr2dj = pr2dj
-      ELSE
-         ipr2dj = 0
-      ENDIF
-      ALLOCATE( ztab_e(jpiglo,4+2*ipr2dj), znorthloc_e(jpi,4+2*ipr2dj), znorthgloio_e(jpi,4+2*ipr2dj,jpni) )
-      !
-      ztab_e(:,:) = 0._wp
+      ipj=4
+      ALLOCATE( ztab_e(jpiglo,ipj+kextj), znorthloc_e(  jpimax,ipj+kextj), &
+     &                                    znorthgloio_e(jpimax,ipj+kextj,jpni) )
+      !
+      ztab_e(:,:)      = 0._wp
+      znorthloc_e(:,:) = 0._wp
       !
       ij = 0
-      ! put in znorthloc_e the last 4 jlines of pt2d
-      DO jj = nlcj - ijpj + 1 - ipr2dj, nlcj +ipr2dj
+      ! put the last ipj+kextj lines of pt2d into znorthloc_e 
+      DO jj = jpj - ipj + 1, jpj + kextj
          ij = ij + 1
-         DO ji = 1, jpi
-            znorthloc_e(ji,ij)=pt2d(ji,jj)
-         END DO
+         znorthloc_e(1:jpi,ij)=pt2d(1:jpi,jj)
       END DO
       !
-      itaille = jpi * ( ijpj + 2 * ipr2dj )
+      itaille = jpimax * ( ipj + kextj )
       CALL MPI_ALLGATHER( znorthloc_e(1,1)  , itaille, MPI_DOUBLE_PRECISION,    &
          &                znorthgloio_e(1,1,1), itaille, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
@@ -1682,5 +1394,5 @@
          ilei = nleit (iproc)
          iilb = nimppt(iproc)
-         DO jj = 1, ijpj+2*ipr2dj
+         DO jj = 1, ipj+kextj
             DO ji = ildi, ilei
                ztab_e(ji+iilb-1,jj) = znorthgloio_e(ji,jj,jr)
@@ -1691,11 +1403,11 @@
       ! 2. North-Fold boundary conditions
       ! ----------------------------------
-!!gm ERROR      CALL lbc_nfd( ztab_e(:,:), cd_type, psgn, pr2dj = ipr2dj )
-
-      ij = ipr2dj
+      CALL lbc_nfd( ztab_e(:,:), cd_type, psgn, kextj )
+
+      ij = 0
       !! Scatter back to pt2d
-      DO jj = nlcj - ijpj + 1 , nlcj +ipr2dj
+      DO jj = jpj - ipj + 1 , jpj + kextj
       ij  = ij +1
-         DO ji= 1, nlci
+         DO ji= 1, jpi
             pt2d(ji,jj) = ztab_e(ji+nimpp-1,ij)
          END DO
@@ -1707,17 +1419,19 @@
 
 
-   SUBROUTINE mpp_lnk_2d_icb( pt2d, cd_type, psgn, jpri, jprj )
+   SUBROUTINE mpp_lnk_2d_icb( pt2d, cd_type, psgn, kexti, kextj )
       !!----------------------------------------------------------------------
       !!                  ***  routine mpp_lnk_2d_icb  ***
       !!
-      !! ** Purpose :   Message passing manadgement for 2d array (with extra halo and icebergs)
+      !! ** Purpose :   Message passing management for 2d array (with extra halo for icebergs)
+      !!                This routine receives a (1-kexti:jpi+kexti,1-kexti:jpj+kextj)
+      !!                array (usually (0:jpi+1, 0:jpj+1)) from lbc_lnk_icb calls.
       !!
       !! ** Method  :   Use mppsend and mpprecv function for passing mask
       !!      between processors following neighboring subdomains.
       !!            domain parameters
-      !!                    nlci   : first dimension of the local subdomain
-      !!                    nlcj   : second dimension of the local subdomain
-      !!                    jpri   : number of rows for extra outer halo
-      !!                    jprj   : number of columns for extra outer halo
+      !!                    jpi    : first dimension of the local subdomain
+      !!                    jpj    : second dimension of the local subdomain
+      !!                    kexti  : number of columns for extra outer halo
+      !!                    kextj  : number of rows for extra outer halo
       !!                    nbondi : mark for "east-west local boundary"
       !!                    nbondj : mark for "north-south local boundary"
@@ -1727,9 +1441,9 @@
       !!                    nono   : number for local neighboring processors
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(1-jpri:jpi+jpri,1-jprj:jpj+jprj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
-      CHARACTER(len=1)                                    , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
-      REAL(wp)                                            , INTENT(in   ) ::   psgn     ! sign used across the north fold
-      INTEGER                                             , INTENT(in   ) ::   jpri
-      INTEGER                                             , INTENT(in   ) ::   jprj
+      REAL(wp), DIMENSION(1-kexti:jpi+kexti,1-kextj:jpj+kextj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
+      CHARACTER(len=1)                                        , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
+      REAL(wp)                                                , INTENT(in   ) ::   psgn     ! sign used across the north fold
+      INTEGER                                                 , INTENT(in   ) ::   kexti    ! extra i-halo width
+      INTEGER                                                 , INTENT(in   ) ::   kextj    ! extra j-halo width
       !
       INTEGER  ::   jl   ! dummy loop indices
@@ -1739,10 +1453,10 @@
       INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
       !!
-      REAL(wp), DIMENSION(1-jpri:jpi+jpri,jprecj+jprj,2) ::   r2dns, r2dsn
-      REAL(wp), DIMENSION(1-jprj:jpj+jprj,jpreci+jpri,2) ::   r2dwe, r2dew
-      !!----------------------------------------------------------------------
-
-      ipreci = jpreci + jpri      ! take into account outer extra 2D overlap area
-      iprecj = jprecj + jprj
+      REAL(wp), DIMENSION(1-kexti:jpi+kexti,nn_hls+kextj,2) ::   r2dns, r2dsn
+      REAL(wp), DIMENSION(1-kextj:jpj+kextj,nn_hls+kexti,2) ::   r2dwe, r2dew
+      !!----------------------------------------------------------------------
+
+      ipreci = nn_hls + kexti      ! take into account outer extra 2D overlap area
+      iprecj = nn_hls + kextj
 
 
@@ -1754,10 +1468,10 @@
       !                                           !* Cyclic east-west
       IF( nbondi == 2 .AND. (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
-         pt2d(1-jpri:     1    ,:) = pt2d(jpim1-jpri:  jpim1 ,:)       ! east
-         pt2d(   jpi  :jpi+jpri,:) = pt2d(     2      :2+jpri,:)       ! west
+         pt2d(1-kexti:     1    ,:) = pt2d(jpim1-kexti:  jpim1 ,:)       ! east
+         pt2d(   jpi  :jpi+kexti,:) = pt2d(     2      :2+kexti,:)       ! west
          !
       ELSE                                        !* closed
-         IF( .NOT. cd_type == 'F' )   pt2d(  1-jpri   :jpreci    ,:) = 0._wp    ! south except at F-point
-                                      pt2d(nlci-jpreci+1:jpi+jpri,:) = 0._wp    ! north
+         IF( .NOT. cd_type == 'F' )   pt2d(  1-kexti   :nn_hls    ,:) = 0._wp    ! south except at F-point
+                                      pt2d(jpi-nn_hls+1:jpi+kexti,:) = 0._wp    ! north
       ENDIF
       !
@@ -1768,6 +1482,6 @@
          !
          SELECT CASE ( jpni )
-!!gm ERROR         CASE ( 1 )     ;   CALL lbc_nfd        ( pt2d(1:jpi,1:jpj+jprj), cd_type, psgn, pr2dj=jprj )
-!!gm ERROR         CASE DEFAULT   ;   CALL mpp_lbc_north_icb( pt2d(1:jpi,1:jpj+jprj)  , cd_type, psgn , pr2dj=jprj  )
+                   CASE ( 1 )     ;   CALL lbc_nfd          ( pt2d(1:jpi,1:jpj+kextj), cd_type, psgn, kextj )
+                   CASE DEFAULT   ;   CALL mpp_lbc_north_icb( pt2d(1:jpi,1:jpj+kextj), cd_type, psgn, kextj )
          END SELECT
          !
@@ -1780,7 +1494,7 @@
       SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
       CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
-         iihom = nlci-nreci-jpri
+         iihom = jpi-nreci-kexti
          DO jl = 1, ipreci
-            r2dew(:,jl,1) = pt2d(jpreci+jl,:)
+            r2dew(:,jl,1) = pt2d(nn_hls+jl,:)
             r2dwe(:,jl,1) = pt2d(iihom +jl,:)
          END DO
@@ -1788,26 +1502,26 @@
       !
       !                           ! Migrations
-      imigr = ipreci * ( jpj + 2*jprj)
+      imigr = ipreci * ( jpj + 2*kextj )
       !
       SELECT CASE ( nbondi )
       CASE ( -1 )
-         CALL mppsend( 2, r2dwe(1-jprj,1,1), imigr, noea, ml_req1 )
-         CALL mpprecv( 1, r2dew(1-jprj,1,2), imigr, noea )
+         CALL mppsend( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, r2dew(1-kextj,1,2), imigr, noea )
          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
       CASE ( 0 )
-         CALL mppsend( 1, r2dew(1-jprj,1,1), imigr, nowe, ml_req1 )
-         CALL mppsend( 2, r2dwe(1-jprj,1,1), imigr, noea, ml_req2 )
-         CALL mpprecv( 1, r2dew(1-jprj,1,2), imigr, noea )
-         CALL mpprecv( 2, r2dwe(1-jprj,1,2), imigr, nowe )
+         CALL mppsend( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, r2dew(1-kextj,1,2), imigr, noea )
+         CALL mpprecv( 2, r2dwe(1-kextj,1,2), imigr, nowe )
          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
          IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
       CASE ( 1 )
-         CALL mppsend( 1, r2dew(1-jprj,1,1), imigr, nowe, ml_req1 )
-         CALL mpprecv( 2, r2dwe(1-jprj,1,2), imigr, nowe )
+         CALL mppsend( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, r2dwe(1-kextj,1,2), imigr, nowe )
          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
       END SELECT
       !
       !                           ! Write Dirichlet lateral conditions
-      iihom = nlci - jpreci
+      iihom = jpi - nn_hls
       !
       SELECT CASE ( nbondi )
@@ -1818,10 +1532,10 @@
       CASE ( 0 )
          DO jl = 1, ipreci
-            pt2d(jl-jpri,:) = r2dwe(:,jl,2)
-            pt2d( iihom+jl,:) = r2dew(:,jl,2)
+            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
+            pt2d(iihom+jl,:) = r2dew(:,jl,2)
          END DO
       CASE ( 1 )
          DO jl = 1, ipreci
-            pt2d(jl-jpri,:) = r2dwe(:,jl,2)
+            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
          END DO
       END SELECT
@@ -1833,34 +1547,34 @@
       !
       IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
-         ijhom = nlcj-nrecj-jprj
+         ijhom = jpj-nrecj-kextj
          DO jl = 1, iprecj
             r2dsn(:,jl,1) = pt2d(:,ijhom +jl)
-            r2dns(:,jl,1) = pt2d(:,jprecj+jl)
+            r2dns(:,jl,1) = pt2d(:,nn_hls+jl)
          END DO
       ENDIF
       !
       !                           ! Migrations
-      imigr = iprecj * ( jpi + 2*jpri )
+      imigr = iprecj * ( jpi + 2*kexti )
       !
       SELECT CASE ( nbondj )
       CASE ( -1 )
-         CALL mppsend( 4, r2dsn(1-jpri,1,1), imigr, nono, ml_req1 )
-         CALL mpprecv( 3, r2dns(1-jpri,1,2), imigr, nono )
+         CALL mppsend( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, r2dns(1-kexti,1,2), imigr, nono )
          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
       CASE ( 0 )
-         CALL mppsend( 3, r2dns(1-jpri,1,1), imigr, noso, ml_req1 )
-         CALL mppsend( 4, r2dsn(1-jpri,1,1), imigr, nono, ml_req2 )
-         CALL mpprecv( 3, r2dns(1-jpri,1,2), imigr, nono )
-         CALL mpprecv( 4, r2dsn(1-jpri,1,2), imigr, noso )
+         CALL mppsend( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, r2dns(1-kexti,1,2), imigr, nono )
+         CALL mpprecv( 4, r2dsn(1-kexti,1,2), imigr, noso )
          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
          IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
       CASE ( 1 )
-         CALL mppsend( 3, r2dns(1-jpri,1,1), imigr, noso, ml_req1 )
-         CALL mpprecv( 4, r2dsn(1-jpri,1,2), imigr, noso )
+         CALL mppsend( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, r2dsn(1-kexti,1,2), imigr, noso )
          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
       END SELECT
       !
       !                           ! Write Dirichlet lateral conditions
-      ijhom = nlcj - jprecj
+      ijhom = jpj - nn_hls
       !
       SELECT CASE ( nbondj )
@@ -1871,10 +1585,10 @@
       CASE ( 0 )
          DO jl = 1, iprecj
-            pt2d(:,jl-jprj) = r2dsn(:,jl,2)
-            pt2d(:,ijhom+jl ) = r2dns(:,jl,2)
+            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
+            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
          END DO
       CASE ( 1 )
          DO jl = 1, iprecj
-            pt2d(:,jl-jprj) = r2dsn(:,jl,2)
+            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
          END DO
       END SELECT
