Index: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lnk_icb_generic.h90
===================================================================
--- NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lnk_icb_generic.h90	(revision 14197)
+++ NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lnk_icb_generic.h90	(revision 14644)
@@ -24,17 +24,12 @@
       !!                    jpi    : first dimension of the local subdomain
       !!                    jpj    : second dimension of the local subdomain
+      !!                    mpinei : number of neighboring domains (starting at 0, -1 if no neighbourg)
       !!                    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"
-      !!                    noea   : number for local neighboring processors
-      !!                    nowe   : number for local neighboring processors
-      !!                    noso   : number for local neighboring processors
-      !!                    nono   : number for local neighboring processors
       !!----------------------------------------------------------------------
       CHARACTER(len=*)                                        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       REAL(PRECISION), 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
+      REAL(PRECISION)                                         , 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
@@ -90,5 +85,5 @@
       ! north fold treatment
       ! -----------------------
-      IF( npolj /= 0 ) THEN
+      IF( l_IdoNFold ) THEN
          !
          SELECT CASE ( jpni )
@@ -103,6 +98,5 @@
       ! 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)
+      IF( mpinei(jpwe) >= 0 .OR. mpinei(jpea) >= 0 ) THEN   ! Read Dirichlet lateral conditions: all exept 2 (i.e. close case)
          iihom = jpi - (2 * nn_hls) -kexti
          DO jl = 1, ipreci
@@ -110,5 +104,5 @@
             r2dwe(:,jl,1) = pt2d(iihom +jl,:)
          END DO
-      END SELECT
+      ENDIF
       !
       !                           ! Migrations
@@ -120,21 +114,10 @@
       IF( ln_timing ) CALL tic_tac(.TRUE.)
       !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
-         CALL SENDROUTINE( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req1 )
-         CALL RECVROUTINE( 1, r2dew(1-kextj,1,2), imigr, noea )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      CASE ( 0 )
-         CALL SENDROUTINE( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
-         CALL SENDROUTINE( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req2 )
-         CALL RECVROUTINE( 1, r2dew(1-kextj,1,2), imigr, noea )
-         CALL RECVROUTINE( 2, r2dwe(1-kextj,1,2), imigr, nowe )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-         CALL mpi_wait(ml_req2,ml_stat,ml_err)
-      CASE ( 1 )
-         CALL SENDROUTINE( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
-         CALL RECVROUTINE( 2, r2dwe(1-kextj,1,2), imigr, nowe )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      END SELECT
+      IF( mpinei(jpwe) >= 0  )   CALL SENDROUTINE( 1, r2dew(1-kextj,1,1), imigr, mpinei(jpwe), ml_req1 )
+      IF( mpinei(jpea) >= 0  )   CALL SENDROUTINE( 2, r2dwe(1-kextj,1,1), imigr, mpinei(jpea), ml_req2 )
+      IF( mpinei(jpwe) >= 0  )   CALL RECVROUTINE( 2, r2dwe(1-kextj,1,2), imigr, mpinei(jpwe) )
+      IF( mpinei(jpea) >= 0  )   CALL RECVROUTINE( 1, r2dew(1-kextj,1,2), imigr, mpinei(jpea) )
+      IF( mpinei(jpwe) >= 0  )   CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      IF( mpinei(jpea) >= 0  )   CALL mpi_wait(ml_req2,ml_stat,ml_err)
       !
       IF( ln_timing ) CALL tic_tac(.FALSE.)
@@ -142,21 +125,14 @@
       !                           ! Write Dirichlet lateral conditions
       iihom = jpi - nn_hls
-      !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
+      IF( mpinei(jpwe) >= 0  ) THEN
+         DO jl = 1, ipreci
+            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
+         END DO
+      ENDIF
+      IF( mpinei(jpea) >= 0  ) THEN
          DO jl = 1, ipreci
             pt2d(iihom+jl,:) = r2dew(:,jl,2)
          END DO
-      CASE ( 0 )
-         DO jl = 1, ipreci
-            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
-            pt2d(iihom+jl,:) = r2dew(:,jl,2)
-         END DO
-      CASE ( 1 )
-         DO jl = 1, ipreci
-            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
-         END DO
-      END SELECT
-
+      ENDIF
 
       ! 3. North and south directions
@@ -164,5 +140,5 @@
       ! always closed : we play only with the neigbours
       !
-      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+      IF( mpinei(jpso) >= 0 .OR. mpinei(jpno) >= 0 ) THEN   ! Read Dirichlet lateral conditions: all exept 2 (i.e. close case)
          ijhom = jpj - (2 * nn_hls) - kextj
          DO jl = 1, iprecj
@@ -177,21 +153,10 @@
       IF( ln_timing ) CALL tic_tac(.TRUE.)
       !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         CALL SENDROUTINE( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req1 )
-         CALL RECVROUTINE( 3, r2dns(1-kexti,1,2), imigr, nono )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      CASE ( 0 )
-         CALL SENDROUTINE( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
-         CALL SENDROUTINE( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req2 )
-         CALL RECVROUTINE( 3, r2dns(1-kexti,1,2), imigr, nono )
-         CALL RECVROUTINE( 4, r2dsn(1-kexti,1,2), imigr, noso )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-         CALL mpi_wait(ml_req2,ml_stat,ml_err)
-      CASE ( 1 )
-         CALL SENDROUTINE( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
-         CALL RECVROUTINE( 4, r2dsn(1-kexti,1,2), imigr, noso )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      END SELECT
+      IF( mpinei(jpso) >= 0  )   CALL SENDROUTINE( 3, r2dns(1-kexti,1,1), imigr, mpinei(jpso), ml_req1 )
+      IF( mpinei(jpno) >= 0  )   CALL SENDROUTINE( 4, r2dsn(1-kexti,1,1), imigr, mpinei(jpno), ml_req2 )
+      IF( mpinei(jpso) >= 0  )   CALL RECVROUTINE( 4, r2dsn(1-kexti,1,2), imigr, mpinei(jpso) )
+      IF( mpinei(jpno) >= 0  )   CALL RECVROUTINE( 3, r2dns(1-kexti,1,2), imigr, mpinei(jpno) )
+      IF( mpinei(jpso) >= 0  )   CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      IF( mpinei(jpno) >= 0  )   CALL mpi_wait(ml_req2,ml_stat,ml_err)
       !
       IF( ln_timing ) CALL tic_tac(.FALSE.)
@@ -200,19 +165,14 @@
       ijhom = jpj - nn_hls
       !
-      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-kextj) = r2dsn(:,jl,2)
-            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
-         END DO
-      CASE ( 1 )
+      IF( mpinei(jpso) >= 0  ) THEN
          DO jl = 1, iprecj
             pt2d(:,jl-kextj) = r2dsn(:,jl,2)
          END DO
-      END SELECT
+      ENDIF
+       IF( mpinei(jpno) >= 0  ) THEN
+        DO jl = 1, iprecj
+            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
+         END DO
+      ENDIF
       !
    END SUBROUTINE ROUTINE_LNK
