Index: /NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_interp.F90
===================================================================
--- /NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_interp.F90	(revision 13497)
+++ /NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_interp.F90	(revision 13498)
@@ -1589,6 +1589,6 @@
       IF(lk_west) THEN
          ispon  = nn_sponge_len * Agrif_irhox()
-         istart = nn_hls + 2                                 ! halo + land + 1
-         iend   = nn_hls + 1 + nbghostcells + ispon          ! halo + land + nbghostcells + sponge
+         istart = nn_hls + 2                                  ! halo + land + 1
+         iend   = nn_hls + 1 + nbghostcells + ispon           ! halo + land + nbghostcells + sponge
          jstart = nn_hls + 2
          jend   = jpjglo - nn_hls - 1
@@ -1611,8 +1611,8 @@
       IF(lk_east) THEN
          ispon  = nn_sponge_len * Agrif_irhox() 
-         istart = jpiglo - ( nn_hls + nbghostcells + ispon ) ! halo + land + nbghostcells + sponge - 1
-         iend   = jpiglo - ( nn_hls + 1 )                    ! halo + land + 1                     - 1
+         istart = jpiglo - ( nn_hls + nbghostcells + ispon )  ! halo + land + nbghostcells + sponge - 1
+         iend   = jpiglo - ( nn_hls + 1 )                     ! halo + land + 1                     - 1
          jstart = nn_hls + 2
-         jend   = jpjglo - nn_hls - 1
+         jend   = jpjglo - nn_hls - 1 
          DO ji = mi0(istart), mi1(iend)
             DO jj = mj0(jstart), mj1(jend)
@@ -1623,5 +1623,5 @@
             END DO
          END DO
-         DO ji = mi0(istart), mi1(iend-1)
+         DO ji = mi0(istart+1), mi1(iend-1)
             DO jj = mj0(jstart), mj1(jend)
                IF ( ABS(hu0_parent(ji,jj)-hu_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
@@ -1667,5 +1667,5 @@
             END DO
          END DO
-         DO jj = mj0(jstart), mj1(jend-1)
+         DO jj = mj0(jstart+1), mj1(jend-1)
             DO ji = mi0(istart), mi1(iend)
                IF ( ABS(hv0_parent(ji,jj)-hv_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
Index: /NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_sponge.F90
===================================================================
--- /NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_sponge.F90	(revision 13497)
+++ /NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_sponge.F90	(revision 13498)
@@ -113,6 +113,4 @@
       REAL(wp) ::   z1_ispongearea, z1_jspongearea
       REAL(wp), DIMENSION(jpi,jpj) :: ztabramp
-      REAL(wp), DIMENSION(jpi,jpj) :: ztabrampu
-      REAL(wp), DIMENSION(jpi,jpj) :: ztabrampv
       !!----------------------------------------------------------------------
       !
@@ -123,5 +121,5 @@
       !|            |           |           |           |
       !fine :     t u t u t u t u t u t u t u t u t u t u t
-      !sponge val:0   0   0   1  5/6 4/6 3/6 2/6 1/6  0   0
+      !sponge val:0 1   1   1   1  5/6 4/6 3/6 2/6 1/6  0 
       !           |   ghost     | <-- sponge area  -- > |
       !           |   points    |                       |
@@ -130,11 +128,11 @@
 #if defined SPONGE || defined SPONGE_TOP
       IF (( .NOT. spongedoneT ).OR.( .NOT. spongedoneU )) THEN
-         ! Define ramp from boundaries towards domain interior at T-points
+         ! Define ramp from boundaries towards domain interior at F-points
          ! Store it in ztabramp
 
          ispongearea    = nn_sponge_len * Agrif_irhox()
-         z1_ispongearea = 1._wp / REAL( ispongearea, wp )
+         z1_ispongearea = 1._wp / REAL( MAX(ispongearea,1), wp )
          jspongearea    = nn_sponge_len * Agrif_irhoy()
-         z1_jspongearea = 1._wp / REAL( jspongearea, wp )
+         z1_jspongearea = 1._wp / REAL( MAX(jspongearea,1), wp )
          
          ztabramp(:,:) = 0._wp
@@ -162,6 +160,6 @@
          ENDIF
          IF( lk_east ) THEN                             ! --- East --- !
-            ind1 = jpiglo - ( nn_hls + nbghostcells ) - ispongearea
-            ind2 = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+            ind1 = jpiglo - ( nn_hls + nbghostcells ) - ispongearea - 1
+            ind2 = jpiglo - ( nn_hls + nbghostcells ) - 1    ! halo + land + nbghostcells - 1
             DO ji = mi0(ind1), mi1(ind2)
                DO jj = 1, jpj
@@ -170,6 +168,6 @@
             END DO
             ! ghost cells:
-            ind1 = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-            ind2 = jpiglo
+            ind1 = jpiglo - ( nn_hls + nbghostcells ) - 1    ! halo + land + nbghostcells - 1
+            ind2 = jpiglo - 1
             DO ji = mi0(ind1), mi1(ind2)
                DO jj = 1, jpj
@@ -179,5 +177,5 @@
          ENDIF      
          IF( lk_south ) THEN                            ! --- South --- !
-            ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+            ind1 = nn_hls + 1 + nbghostcells                 ! halo + land + nbghostcells
             ind2 = nn_hls + 1 + nbghostcells + jspongearea 
             DO jj = mj0(ind1), mj1(ind2) 
@@ -188,5 +186,5 @@
             ! ghost cells:
             ind1 = 1
-            ind2 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+            ind2 = nn_hls + 1 + nbghostcells                 ! halo + land + nbghostcells
             DO jj = mj0(ind1), mj1(ind2) 
                DO ji = 1, jpi
@@ -196,6 +194,6 @@
          ENDIF
          IF( lk_north ) THEN                            ! --- North --- !
-            ind1 = jpjglo - ( nn_hls + nbghostcells ) - jspongearea
-            ind2 = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+            ind1 = jpjglo - ( nn_hls + nbghostcells ) - jspongearea - 1
+            ind2 = jpjglo - ( nn_hls + nbghostcells ) - 1    ! halo + land + nbghostcells - 1
             DO jj = mj0(ind1), mj1(ind2)
                DO ji = 1, jpi
@@ -220,6 +218,6 @@
          fspv(:,:) = 0._wp
          DO_2D( 0, 0, 0, 0 )
-            fspu(ji,jj) = 0.5_wp * ( ztabramp(ji,jj) + ztabramp(ji+1,jj  ) ) * ssumask(ji,jj)
-            fspv(ji,jj) = 0.5_wp * ( ztabramp(ji,jj) + ztabramp(ji  ,jj+1) ) * ssvmask(ji,jj)
+            fspu(ji,jj) = 0.5_wp * ( ztabramp(ji,jj) + ztabramp(ji,jj-1) ) * ssumask(ji,jj)
+            fspv(ji,jj) = 0.5_wp * ( ztabramp(ji,jj) + ztabramp(ji-1,jj) ) * ssvmask(ji,jj)
          END_2D
       ENDIF
@@ -230,8 +228,7 @@
          fspf(:,:) = 0._wp
          DO_2D( 0, 0, 0, 0 )
-            fspt(ji,jj) = ztabramp(ji,jj) * ssmask(ji,jj)
-            fspf(ji,jj) = 0.25_wp * ( ztabramp(ji  ,jj  ) + ztabramp(ji  ,jj+1)   &
-                                  &  +ztabramp(ji+1,jj+1) + ztabramp(ji+1,jj  ) ) &
-                                  &  * ssvmask(ji,jj) * ssvmask(ji,jj+1)
+            fspt(ji,jj) = 0.25_wp * ( ztabramp(ji  ,jj  ) + ztabramp(ji-1,jj  ) &
+                                  &  +ztabramp(ji  ,jj-1) + ztabramp(ji-1,jj-1) ) * ssmask(ji,jj)
+            fspf(ji,jj) = ztabramp(ji,jj) * ssvmask(ji,jj) * ssvmask(ji,jj+1)
          END_2D
       ENDIF
@@ -250,28 +247,10 @@
          spongedoneU = .TRUE.
       ENDIF
-
+      !
       ! Remove vertical interpolation where not needed:
-      DO_2D( 0, 0, 0, 0 )
-         IF ((fspu(ji-1,jj)==0._wp).AND.(fspu(ji,jj)==0._wp).AND. &
-         &   (fspv(ji,jj-1)==0._wp).AND.(fspv(ji,jj)==0._wp)) mbkt_parent(ji,jj) = 0
-!
-         IF ((fspt(ji+1,jj)==0._wp).AND.(fspt(ji,jj)==0._wp).AND. &
-         &   (fspf(ji,jj-1)==0._wp).AND.(fspf(ji,jj)==0._wp)) mbku_parent(ji,jj) = 0
-!
-         IF ((fspt(ji,jj+1)==0._wp).AND.(fspt(ji,jj)==0._wp).AND. &
-         &   (fspf(ji-1,jj)==0._wp).AND.(fspf(ji,jj)==0._wp)) mbkv_parent(ji,jj) = 0
-!
-         IF ( ssmask(ji,jj) == 0._wp) mbkt_parent(ji,jj) = 0
-         IF (ssumask(ji,jj) == 0._wp) mbku_parent(ji,jj) = 0
-         IF (ssvmask(ji,jj) == 0._wp) mbkv_parent(ji,jj) = 0
-      END_2D
-      !
-      ztabramp (:,:) = REAL( mbkt_parent(:,:), wp )
-      ztabrampu(:,:) = REAL( mbku_parent(:,:), wp )
-      ztabrampv(:,:) = REAL( mbkv_parent(:,:), wp )
-      CALL lbc_lnk_multi( 'Agrif_Sponge', ztabramp, 'T', 1._wp, ztabrampu, 'U', 1._wp, ztabrampv, 'V', 1._wp )
-      mbkt_parent(:,:) = NINT( ztabramp (:,:) )
-      mbku_parent(:,:) = NINT( ztabrampu(:,:) )
-      mbkv_parent(:,:) = NINT( ztabrampv(:,:) )
+      ! (A null value in mbkx arrays does the job)
+      WHERE (fspu(:,:) == 0._wp) mbku_parent(:,:) = 0
+      WHERE (fspv(:,:) == 0._wp) mbkv_parent(:,:) = 0
+      WHERE (fspt(:,:) == 0._wp) mbkt_parent(:,:) = 0
       !
 #endif
@@ -406,5 +385,5 @@
                DO jj = j1,j2
                   DO ji = i1,i2-1
-                     zabe1 = rn_sponge_tra * r1_Dt * fspu(ji,jj) * umask(ji,jj,jk) * e1e2u(ji,jj) * e3u(ji,jj,jk,Kmm_a)
+                     zabe1 = fspu(ji,jj) * rn_sponge_tra * r1_Dt * umask(ji,jj,jk) * e1e2u(ji,jj) * e3u(ji,jj,jk,Kmm_a)
                      ztu(ji,jj,jk) = zabe1 * ( tsbdiff(ji+1,jj  ,jk,jn) - tsbdiff(ji,jj,jk,jn) ) 
                   END DO
@@ -413,5 +392,5 @@
                DO ji = i1,i2
                   DO jj = j1,j2-1
-                     zabe2 = rn_sponge_tra * r1_Dt * fspv(ji,jj) * vmask(ji,jj,jk) * e1e2v(ji,jj) * e3v(ji,jj,jk,Kmm_a)
+                     zabe2 = fspv(ji,jj) * rn_sponge_tra * r1_Dt * vmask(ji,jj,jk) * e1e2v(ji,jj) * e3v(ji,jj,jk,Kmm_a)
                      ztv(ji,jj,jk) = zabe2 * ( tsbdiff(ji  ,jj+1,jk,jn) - tsbdiff(ji,jj,jk,jn) )
                   END DO
