Index: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lib_mpp.F90	(revision 14197)
+++ NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lib_mpp.F90	(revision 14644)
@@ -55,4 +55,7 @@
    USE dom_oce        ! ocean space and time domain
    USE in_out_manager ! I/O manager
+#if ! defined key_mpi_off
+   USE MPI
+#endif
 
    IMPLICIT NONE
@@ -73,5 +76,5 @@
    PUBLIC   mpp_bcast_nml
    PUBLIC   tic_tac
-#if ! defined key_mpp_mpi
+#if defined key_mpp_off
    PUBLIC MPI_wait
    PUBLIC MPI_Wtime
@@ -107,11 +110,16 @@
    END INTERFACE
 
+   TYPE, PUBLIC ::   PTR_4D_sp   !: array of 4D pointers (used in lbclnk and lbcnfd)
+      REAL(sp), DIMENSION (:,:,:,:), POINTER ::   pt4d
+   END TYPE PTR_4D_sp
+
+   TYPE, PUBLIC ::   PTR_4D_dp   !: array of 4D pointers (used in lbclnk and lbcnfd)
+      REAL(dp), DIMENSION (:,:,:,:), POINTER ::   pt4d
+   END TYPE PTR_4D_dp
+
    !! ========================= !!
    !!  MPI  variable definition !!
    !! ========================= !!
-#if   defined key_mpp_mpi
-!$AGRIF_DO_NOT_TREAT
-   INCLUDE 'mpif.h'
-!$AGRIF_END_DO_NOT_TREAT
+#if ! defined key_mpi_off
    LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .TRUE.    !: mpp flag
 #else
@@ -122,6 +130,4 @@
 #endif
 
-   INTEGER, PARAMETER         ::   nprocmax = 2**10   ! maximun dimension (required to be a power of 2)
-
    INTEGER, PUBLIC ::   mppsize        ! number of process
    INTEGER, PUBLIC ::   mpprank        ! process number  [ 0 - size-1 ]
@@ -132,14 +138,31 @@
    INTEGER :: MPI_SUMDD
 
+   ! Neighbourgs informations
+   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
+   INTEGER,    PARAMETER, PUBLIC ::   jpso = 3   !: SOuth
+   INTEGER,    PARAMETER, PUBLIC ::   jpno = 4   !: NOrth
+   INTEGER,    PARAMETER, PUBLIC ::   jpsw = 5   !: South-West
+   INTEGER,    PARAMETER, PUBLIC ::   jpse = 6   !: South-East
+   INTEGER,    PARAMETER, PUBLIC ::   jpnw = 7   !: North-West
+   INTEGER,    PARAMETER, PUBLIC ::   jpne = 8   !: North-East
+
+   LOGICAL, DIMENSION(8), PUBLIC ::   l_SelfPerio  !   should we explicitely take care of I/J periodicity
+   LOGICAL,               PUBLIC ::   l_IdoNFold
+
    ! variables used for zonal integration
-   INTEGER, PUBLIC ::   ncomm_znl       !: communicator made by the processors on the same zonal average
-   LOGICAL, PUBLIC ::   l_znl_root      !: True on the 'left'most processor on the same row
-   INTEGER         ::   ngrp_znl        !  group ID for the znl processors
-   INTEGER         ::   ndim_rank_znl   !  number of processors on the same zonal average
+   INTEGER, PUBLIC ::   ncomm_znl         !: communicator made by the processors on the same zonal average
+   LOGICAL, PUBLIC ::   l_znl_root        !: True on the 'left'most processor on the same row
+   INTEGER         ::   ngrp_znl          !: group ID for the znl processors
+   INTEGER         ::   ndim_rank_znl     !: number of processors on the same zonal average
    INTEGER, DIMENSION(:), ALLOCATABLE, SAVE ::   nrank_znl  ! dimension ndim_rank_znl, number of the procs into the same znl domain
 
    ! variables used for MPI3 neighbourhood collectives
-   INTEGER, PUBLIC :: mpi_nc_com                   ! MPI3 neighbourhood collectives communicator
-   INTEGER, PUBLIC :: mpi_nc_all_com               ! 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)
@@ -187,5 +210,11 @@
 
    LOGICAL, PUBLIC ::   ln_nnogather                !: namelist control of northfold comms
-   LOGICAL, PUBLIC ::   l_north_nogather = .FALSE.  !: internal control of northfold comms
+   INTEGER, PUBLIC ::   nn_comm                     !: namelist control of comms
+
+   INTEGER, PUBLIC, PARAMETER ::   jpfillnothing = 1
+   INTEGER, PUBLIC, PARAMETER ::   jpfillcst     = 2
+   INTEGER, PUBLIC, PARAMETER ::   jpfillcopy    = 3
+   INTEGER, PUBLIC, PARAMETER ::   jpfillperio   = 4
+   INTEGER, PUBLIC, PARAMETER ::   jpfillmpi     = 5
 
    !! * Substitutions
@@ -209,5 +238,5 @@
       LOGICAL ::   llmpi_init
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       CALL mpi_initialized ( llmpi_init, ierr )
@@ -265,5 +294,5 @@
       INTEGER , INTENT(in   ) ::   kdest      ! receive process number
       INTEGER , INTENT(in   ) ::   ktyp       ! tag of the message
-      INTEGER , INTENT(in   ) ::   md_req     ! argument for isend
+      INTEGER , INTENT(inout) ::   md_req     ! argument for isend
       !!
       INTEGER ::   iflag
@@ -271,5 +300,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF (wp == dp) THEN
          mpi_working_type = mpi_double_precision
@@ -294,10 +323,10 @@
       INTEGER , INTENT(in   ) ::   kdest      ! receive process number
       INTEGER , INTENT(in   ) ::   ktyp       ! tag of the message
-      INTEGER , INTENT(in   ) ::   md_req     ! argument for isend
+      INTEGER , INTENT(inout) ::   md_req     ! argument for isend
       !!
       INTEGER ::   iflag
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_isend( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_oce, md_req, iflag )
 #endif
@@ -317,10 +346,10 @@
       INTEGER , INTENT(in   ) ::   kdest      ! receive process number
       INTEGER , INTENT(in   ) ::   ktyp       ! tag of the message
-      INTEGER , INTENT(in   ) ::   md_req     ! argument for isend
+      INTEGER , INTENT(inout) ::   md_req     ! argument for isend
       !!
       INTEGER ::   iflag
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_isend( pmess, kbytes, mpi_real, kdest , ktyp, mpi_comm_oce, md_req, iflag )
 #endif
@@ -347,5 +376,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ! If a specific process number has been passed to the receive call,
       ! use that one. Default is to use mpi_any_source
@@ -380,5 +409,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ! If a specific process number has been passed to the receive call,
       ! use that one. Default is to use mpi_any_source
@@ -409,5 +438,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ! If a specific process number has been passed to the receive call,
       ! use that one. Default is to use mpi_any_source
@@ -437,5 +466,5 @@
       !
       itaille = jpi * jpj
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_gather( ptab, itaille, mpi_double_precision, pio, itaille     ,   &
          &                            mpi_double_precision, kp , mpi_comm_oce, ierror )
@@ -464,5 +493,5 @@
       itaille = jpi * jpj
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_scatter( pio, itaille, mpi_double_precision, ptab, itaille     ,   &
          &                            mpi_double_precision, kp  , mpi_comm_oce, ierror )
@@ -493,5 +522,5 @@
       COMPLEX(dp), ALLOCATABLE, DIMENSION(:) ::   ytmp
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ilocalcomm = mpi_comm_oce
       IF( PRESENT(kcom) )   ilocalcomm = kcom
@@ -568,5 +597,5 @@
       !!----------------------------------------------------------------------
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       if( wp == dp ) then
          MPI_TYPE = MPI_DOUBLE_PRECISION
@@ -640,5 +669,5 @@
       INTEGER ::   ierr
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
       ! test on ndelayid(kid) useless as mpi_wait return immediatly if the request handle is MPI_REQUEST_NULL
@@ -662,5 +691,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       call MPI_BCAST(kleng, 1, MPI_INT, 0, mpi_comm_oce, iflag)
       call MPI_BARRIER(mpi_comm_oce, iflag)
@@ -928,5 +957,5 @@
       !!-----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_barrier( mpi_comm_oce, ierror )
 #endif
@@ -944,12 +973,12 @@
       LOGICAL, OPTIONAL, INTENT(in) :: ld_abort    ! source process number
       LOGICAL ::   ll_abort
-      INTEGER ::   info
+      INTEGER ::   info, ierr
       !!----------------------------------------------------------------------
       ll_abort = .FALSE.
       IF( PRESENT(ld_abort) ) ll_abort = ld_abort
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF(ll_abort) THEN
-         CALL mpi_abort( MPI_COMM_WORLD )
+         CALL mpi_abort( MPI_COMM_WORLD, 123, info )
       ELSE
          CALL mppsync
@@ -964,10 +993,10 @@
    SUBROUTINE mpp_comm_free( kcom )
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kcom
+      INTEGER, INTENT(inout) ::   kcom
       !!
       INTEGER :: ierr
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL MPI_COMM_FREE(kcom, ierr)
 #endif
@@ -1001,8 +1030,8 @@
       INTEGER, ALLOCATABLE, DIMENSION(:) ::   kwork
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
-      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_world     : ', ngrp_world
-      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - mpi_comm_world : ', mpi_comm_world
-      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - mpi_comm_oce   : ', mpi_comm_oce
+#if ! defined key_mpi_off
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ngrp_world     : ', ngrp_world
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - mpi_comm_world : ', mpi_comm_world
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - mpi_comm_oce   : ', mpi_comm_oce
       !
       ALLOCATE( kwork(jpnij), STAT=ierr )
@@ -1015,5 +1044,5 @@
          !
          CALL MPI_ALLGATHER ( njmpp, 1, mpi_integer, kwork, 1, mpi_integer, mpi_comm_oce, ierr )
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - kwork pour njmpp : ', kwork
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - kwork pour njmpp : ', kwork
          !-$$        CALL flush(numout)
          !
@@ -1025,5 +1054,5 @@
             ENDIF
          END DO
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ndim_rank_znl : ', ndim_rank_znl
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ndim_rank_znl : ', ndim_rank_znl
          !-$$        CALL flush(numout)
          ! Allocate the right size to nrank_znl
@@ -1038,20 +1067,20 @@
             ENDIF
          END DO
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - nrank_znl : ', nrank_znl
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - nrank_znl : ', nrank_znl
          !-$$        CALL flush(numout)
 
          ! Create the opa group
          CALL MPI_COMM_GROUP(mpi_comm_oce,ngrp_opa,ierr)
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_opa : ', ngrp_opa
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ngrp_opa : ', ngrp_opa
          !-$$        CALL flush(numout)
 
          ! Create the znl group from the opa group
          CALL MPI_GROUP_INCL  ( ngrp_opa, ndim_rank_znl, nrank_znl, ngrp_znl, ierr )
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_znl ', ngrp_znl
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ngrp_znl ', ngrp_znl
          !-$$        CALL flush(numout)
 
          ! Create the znl communicator from the opa communicator, ie the pool of procs in the same row
          CALL MPI_COMM_CREATE ( mpi_comm_oce, ngrp_znl, ncomm_znl, ierr )
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ncomm_znl ', ncomm_znl
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ncomm_znl ', ncomm_znl
          !-$$        CALL flush(numout)
          !
@@ -1073,5 +1102,6 @@
    END SUBROUTINE mpp_ini_znl
 
-   SUBROUTINE mpp_ini_nc
+   
+   SUBROUTINE mpp_ini_nc( khls )
       !!----------------------------------------------------------------------
       !!               ***  routine mpp_ini_nc  ***
@@ -1084,139 +1114,36 @@
       !
       !! ** output
-      !!         mpi_nc_com = MPI3 neighbourhood collectives communicator
-      !!         mpi_nc_all_com = MPI3 neighbourhood collectives communicator
-      !!                          (with diagonals)
-      !!
-      !!----------------------------------------------------------------------
-      INTEGER, DIMENSION(:), ALLOCATABLE :: ineigh, ineighalls, ineighallr
-      INTEGER :: ideg, idegalls, idegallr, icont, icont1
-      INTEGER :: ierr
-      LOGICAL, PARAMETER :: ireord = .FALSE.
-
-#if defined key_mpp_mpi
-
-      ideg = 0
-      idegalls = 0
-      idegallr = 0
-      icont = 0
-      icont1 = 0
-
-      IF (nbondi .eq. 1) THEN
-         ideg = ideg + 1
-      ELSEIF (nbondi .eq. -1) THEN
-         ideg = ideg + 1
-      ELSEIF (nbondi .eq. 0) THEN
-         ideg = ideg + 2
-      ENDIF
-
-      IF (nbondj .eq. 1) THEN
-         ideg = ideg + 1
-      ELSEIF (nbondj .eq. -1) THEN
-         ideg = ideg + 1
-      ELSEIF (nbondj .eq. 0) THEN
-         ideg = ideg + 2
-      ENDIF
-
-      idegalls = ideg
-      idegallr = ideg
-
-      IF (nones .ne. -1) idegalls = idegalls + 1
-      IF (nonws .ne. -1) idegalls = idegalls + 1
-      IF (noses .ne. -1) idegalls = idegalls + 1
-      IF (nosws .ne. -1) idegalls = idegalls + 1
-      IF (noner .ne. -1) idegallr = idegallr + 1
-      IF (nonwr .ne. -1) idegallr = idegallr + 1
-      IF (noser .ne. -1) idegallr = idegallr + 1
-      IF (noswr .ne. -1) idegallr = idegallr + 1
-
-      ALLOCATE(ineigh(ideg))
-      ALLOCATE(ineighalls(idegalls))
-      ALLOCATE(ineighallr(idegallr))
-
-      IF (nbondi .eq. 1) THEN
-         icont = icont + 1
-         ineigh(icont) = nowe
-         ineighalls(icont) = nowe
-         ineighallr(icont) = nowe
-      ELSEIF (nbondi .eq. -1) THEN
-         icont = icont + 1
-         ineigh(icont) = noea
-         ineighalls(icont) = noea
-         ineighallr(icont) = noea
-      ELSEIF (nbondi .eq. 0) THEN
-         icont = icont + 1
-         ineigh(icont) = nowe
-         ineighalls(icont) = nowe
-         ineighallr(icont) = nowe
-         icont = icont + 1
-         ineigh(icont) = noea
-         ineighalls(icont) = noea
-         ineighallr(icont) = noea
-      ENDIF
-
-      IF (nbondj .eq. 1) THEN
-         icont = icont + 1
-         ineigh(icont) = noso
-         ineighalls(icont) = noso
-         ineighallr(icont) = noso
-      ELSEIF (nbondj .eq. -1) THEN
-         icont = icont + 1
-         ineigh(icont) = nono
-         ineighalls(icont) = nono
-         ineighallr(icont) = nono
-      ELSEIF (nbondj .eq. 0) THEN
-         icont = icont + 1
-         ineigh(icont) = noso
-         ineighalls(icont) = noso
-         ineighallr(icont) = noso
-         icont = icont + 1
-         ineigh(icont) = nono
-         ineighalls(icont) = nono
-         ineighallr(icont) = nono
-      ENDIF
-
-      icont1 = icont
-      IF (nosws .ne. -1) THEN
-         icont = icont + 1
-         ineighalls(icont) = nosws
-      ENDIF
-      IF (noses .ne. -1) THEN
-         icont = icont + 1
-         ineighalls(icont) = noses
-      ENDIF
-      IF (nonws .ne. -1) THEN
-         icont = icont + 1
-         ineighalls(icont) = nonws
-      ENDIF
-      IF (nones .ne. -1) THEN
-         icont = icont + 1
-         ineighalls(icont) = nones
-      ENDIF
-      IF (noswr .ne. -1) THEN
-         icont1 = icont1 + 1
-         ineighallr(icont1) = noswr
-      ENDIF
-      IF (noser .ne. -1) THEN
-         icont1 = icont1 + 1
-         ineighallr(icont1) = noser
-      ENDIF
-      IF (nonwr .ne. -1) THEN
-         icont1 = icont1 + 1
-         ineighallr(icont1) = nonwr
-      ENDIF
-      IF (noner .ne. -1) THEN
-         icont1 = icont1 + 1
-         ineighallr(icont1) = noner
-      ENDIF
-
-      CALL MPI_Dist_graph_create_adjacent(mpi_comm_oce, ideg, ineigh, MPI_UNWEIGHTED, ideg, ineigh, MPI_UNWEIGHTED, MPI_INFO_NULL, ireord, mpi_nc_com, ierr)
-      CALL MPI_Dist_graph_create_adjacent(mpi_comm_oce, idegallr, ineighallr, MPI_UNWEIGHTED, idegalls, ineighalls, MPI_UNWEIGHTED, MPI_INFO_NULL, ireord, mpi_nc_all_com, ierr)
-
-      DEALLOCATE (ineigh)
-      DEALLOCATE (ineighalls)
-      DEALLOCATE (ineighallr)
+      !!         mpi_nc_com4 = MPI3 neighbourhood collectives communicator
+      !!         mpi_nc_com8 = MPI3 neighbourhood collectives communicator (with diagonals)
+      !!----------------------------------------------------------------------
+      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
+      
+      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
-
 
 
@@ -1234,5 +1161,4 @@
       !!
       !! ** output
-      !!      njmppmax = njmpp for northern procs
       !!      ndim_rank_north = number of processors in the northern line
       !!      nrank_north (ndim_rank_north) = number  of the northern procs.
@@ -1248,6 +1174,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
-      njmppmax = MAXVAL( njmppt )
+#if ! defined key_mpi_off
       !
       ! Look for how many procs on the northern boundary
@@ -1330,5 +1255,5 @@
       INTEGER ::    ji,  jj,  jk,  jh, jf, jcount   ! dummy loop indices
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       ll_lbc = .FALSE.
@@ -1400,5 +1325,5 @@
          END DO
          IF ( crname_lbc(n_sequence_lbc) /= 'already counted' ) THEN
-            WRITE(numcom,'(A, I4, A, A)') ' - ', 1,' times by subroutine ', TRIM(crname_lbc(ncom_rec_max))
+            WRITE(numcom,'(A, I4, A, A)') ' - ', 1,' times by subroutine ', TRIM(crname_lbc(n_sequence_lbc))
          END IF
          WRITE(numcom,*) ' '
@@ -1451,5 +1376,5 @@
     REAL(dp),               SAVE :: tic_ct = 0._dp
     INTEGER :: ii
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
 
     IF( ncom_stp <= nit000 ) RETURN
@@ -1471,5 +1396,5 @@
    END SUBROUTINE tic_tac
 
-#if ! defined key_mpp_mpi
+#if defined key_mpi_off
    SUBROUTINE mpi_wait(request, status, ierror)
       INTEGER                            , INTENT(in   ) ::   request
@@ -1792,5 +1717,5 @@
          !write(*,'(32A)') cdnambuff
       ENDIF
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpp_bcast_nml( cdnambuff, itot )
 #endif
