Index: /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_oce_interp.F90
===================================================================
--- /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_oce_interp.F90	(revision 14640)
+++ /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_oce_interp.F90	(revision 14641)
@@ -44,5 +44,5 @@
    PUBLIC   interptsn, interpsshn, interpavm
    PUBLIC   interpunb, interpvnb , interpub2b, interpvb2b
-   PUBLIC   interpe3t, interpglamt, interpgphit
+   PUBLIC   interpglamt, interpgphit
    PUBLIC   interpht0, interpmbkt, interpe3t0_vremap
    PUBLIC   agrif_istate_oce, agrif_istate_ssh   ! called by icestate.F90 and domvvl.F90
@@ -1535,37 +1535,4 @@
 
 
-   SUBROUTINE interpe3t( ptab, i1, i2, j1, j2, k1, k2, before )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE interpe3t  ***
-      !!----------------------------------------------------------------------  
-      INTEGER                              , INTENT(in   ) :: i1, i2, j1, j2, k1, k2
-      REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: ptab
-      LOGICAL                              , INTENT(in   ) :: before
-      !
-      INTEGER :: ji, jj, jk
-      !!----------------------------------------------------------------------  
-      !    
-      IF( before ) THEN
-         ptab(i1:i2,j1:j2,k1:k2) = tmask(i1:i2,j1:j2,k1:k2) * e3t_0(i1:i2,j1:j2,k1:k2)
-      ELSE
-         !
-         DO jk = k1, k2
-            DO jj = j1, j2
-               DO ji = i1, i2
-                  IF( ABS( ptab(ji,jj,jk) - tmask(ji,jj,jk) * e3t_0(ji,jj,jk) ) > 1.D-2) THEN
-                     WRITE(numout,*) ' Agrif error for e3t_0: parent , child, i, j, k ',  & 
-                     &                 ptab(ji,jj,jk), tmask(ji,jj,jk) * e3t_0(ji,jj,jk), &
-                     &                 mig0(ji), mjg0(jj), jk
-                     kindic_agr = kindic_agr + 1
-                  ENDIF
-               END DO
-            END DO
-         END DO
-         !
-      ENDIF
-      ! 
-   END SUBROUTINE interpe3t
-
-
    SUBROUTINE interpe3t0_vremap( ptab, i1, i2, j1, j2, k1, k2, before )
       !!----------------------------------------------------------------------
@@ -1793,5 +1760,5 @@
       INTEGER, INTENT(inout) ::   iindic
       !!
-      INTEGER :: ji, jj
+      INTEGER :: ji, jj, jk
       INTEGER  :: istart, iend, jstart, jend, ispon
       !!----------------------------------------------------------------------  
@@ -1801,14 +1768,24 @@
       IF(lk_west) THEN
          ispon  = nn_sponge_len * Agrif_irhox()
-         istart = nn_hls + 2                                  ! halo + land + 1
+         istart = nn_hls + 1                                  ! halo + land + 1
          iend   = nn_hls + 1 + nbghostcells + ispon           ! halo + land + nbghostcells + sponge
-         jstart = nn_hls + 2
-         jend   = jpjglo - nn_hls - 1
+         jstart = nn_hls + 1 
+         jend   = jpjglo - nn_hls 
          DO ji = mi0(istart), mi1(iend)
             DO jj = mj0(jstart), mj1(jend)
                IF ( ABS(ht0_parent(ji,jj)-ht_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3t0_parent(ji,jj,jk)-e3t_0(ji,jj,jk))*tmask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
             DO jj = mj0(jstart), mj1(jend-1)
                IF ( ABS(hv0_parent(ji,jj)-hv_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3v0_parent(ji,jj,jk)-e3v_0(ji,jj,jk))*vmask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
          END DO
@@ -1816,4 +1793,9 @@
             DO jj = mj0(jstart), mj1(jend)
                IF ( ABS(hu0_parent(ji,jj)-hu_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3u0_parent(ji,jj,jk)-e3u_0(ji,jj,jk))*umask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
          END DO
@@ -1824,18 +1806,33 @@
          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
-         jstart = nn_hls + 2
-         jend   = jpjglo - nn_hls - 1 
+         iend   = jpiglo - nn_hls                             ! halo + land + 1                     - 1
+         jstart = nn_hls + 1 
+         jend   = jpjglo - nn_hls 
          DO ji = mi0(istart), mi1(iend)
             DO jj = mj0(jstart), mj1(jend)
                IF ( ABS(ht0_parent(ji,jj)-ht_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3t0_parent(ji,jj,jk)-e3t_0(ji,jj,jk))*tmask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
             DO jj = mj0(jstart), mj1(jend-1)
                IF ( ABS(hv0_parent(ji,jj)-hv_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
-            END DO
-         END DO
-         DO ji = mi0(istart+1), mi1(iend-1)
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3v0_parent(ji,jj,jk)-e3v_0(ji,jj,jk))*vmask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
+            END DO
+         END DO
+         DO ji = mi0(istart), 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
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3u0_parent(ji,jj,jk)-e3u_0(ji,jj,jk))*umask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
          END DO
@@ -1844,15 +1841,25 @@
       ! --- South --- !
       IF(lk_south) THEN
-         ispon  = nn_sponge_len * Agrif_irhoy() 
-         jstart = nn_hls + 2                                 ! halo + land + 1
+         ispon  = nn_sponge_len * Agrif_irhoy()  
+         jstart = nn_hls + 1                                 ! halo + land + 1
          jend   = nn_hls + 1 + nbghostcells + ispon          ! halo + land + nbghostcells + sponge
-         istart = nn_hls + 2
-         iend   = jpiglo - nn_hls - 1
+         istart = nn_hls + 1 
+         iend   = jpiglo - nn_hls 
          DO jj = mj0(jstart), mj1(jend)
             DO ji = mi0(istart), mi1(iend)
                IF ( ABS(ht0_parent(ji,jj)-ht_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3t0_parent(ji,jj,jk)-e3t_0(ji,jj,jk))*tmask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
             DO ji = mi0(istart), mi1(iend-1)
                IF ( ABS(hu0_parent(ji,jj)-hu_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3u0_parent(ji,jj,jk)-e3u_0(ji,jj,jk))*umask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
          END DO
@@ -1860,4 +1867,9 @@
             DO ji = mi0(istart), mi1(iend)
                IF ( ABS(hv0_parent(ji,jj)-hv_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3v0_parent(ji,jj,jk)-e3v_0(ji,jj,jk))*vmask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
          END DO
@@ -1868,18 +1880,33 @@
          ispon  = nn_sponge_len * Agrif_irhoy() 
          jstart = jpjglo - ( nn_hls + nbghostcells + ispon)  ! halo + land + nbghostcells +sponge - 1
-         jend   = jpjglo - ( nn_hls + 1 )                    ! halo + land + 1            - 1
-         istart = nn_hls + 2
-         iend   = jpiglo - nn_hls - 1
+         jend   = jpjglo - nn_hls                            ! halo + land + 1            - 1
+         istart = nn_hls + 1 
+         iend   = jpiglo - nn_hls 
          DO jj = mj0(jstart), mj1(jend)
             DO ji = mi0(istart), mi1(iend)
                IF ( ABS(ht0_parent(ji,jj)-ht_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3t0_parent(ji,jj,jk)-e3t_0(ji,jj,jk))*tmask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
             DO ji = mi0(istart), mi1(iend-1)
                IF ( ABS(hu0_parent(ji,jj)-hu_0(ji,jj)) > 1.e-3 ) iindic = iindic + 1
-            END DO
-         END DO
-         DO jj = mj0(jstart+1), mj1(jend-1)
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3u0_parent(ji,jj,jk)-e3u_0(ji,jj,jk))*umask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
+            END DO
+         END DO
+         DO jj = mj0(jstart), 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
+               IF ( .NOT.ln_vert_remap) THEN
+                  DO jk = 1, jpkm1
+                     IF ( ABS(e3v0_parent(ji,jj,jk)-e3v_0(ji,jj,jk))*vmask(ji,jj,jk) > 1.e-3 ) iindic = iindic + 1
+                  END DO 
+               ENDIF
             END DO
          END DO
Index: /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_oce_update.F90
===================================================================
--- /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_oce_update.F90	(revision 14640)
+++ /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_oce_update.F90	(revision 14641)
@@ -1284,5 +1284,6 @@
       !!----------------------------------------------------------------------
       ! 
-      IF (( .NOT.ln_agrif_2way ).OR.(.NOT.ln_chk_bathy).OR.(Agrif_Root())) RETURN
+      IF (( .NOT.ln_agrif_2way ).OR.(.NOT.ln_chk_bathy) & 
+      & .OR.(.NOT.ln_vert_remap).OR.(Agrif_Root())) RETURN
       !
       Agrif_UseSpecialValueInUpdate = .FALSE.
Index: /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_user.F90
===================================================================
--- /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_user.F90	(revision 14640)
+++ /NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/NST/agrif_user.F90	(revision 14641)
@@ -120,13 +120,12 @@
        ! 3. Location of interpolation
       !-----------------------------
-!      CALL Agrif_Set_bc(  e3t_id, (/-nn_sponge_len*imaxrho,ind1-1/) )  
-! JC: check near the boundary only until matching in sponge has been sorted out:
-      CALL Agrif_Set_bc(    e3t_id, (/0,ind1-1/) )  
+      CALL Agrif_Set_bc(  e3t_id, (/-nn_sponge_len*imaxrho-2,ind1-1/) )  
 
       ! extend the interpolation zone by 1 more point than necessary:
       ! RB check here
-      CALL Agrif_Set_bc( e3t0_interp_id, (/-nn_sponge_len*imaxrho-2,ind1/) )
-      CALL Agrif_Set_bc(        mbkt_id, (/-nn_sponge_len*imaxrho-2,ind1/) )
-      CALL Agrif_Set_bc(         ht0_id, (/-nn_sponge_len*imaxrho-2,ind1/) )
+      CALL Agrif_Set_bc( e3t0_interp_id, (/-nn_sponge_len*imaxrho-2,ind1-1/) )
+      CALL Agrif_Set_bc(        mbkt_id, (/-nn_sponge_len*imaxrho-2,ind1-1/) )
+      CALL Agrif_Set_bc(         ht0_id, (/-nn_sponge_len*imaxrho-2,ind1-1/) )
+
       CALL Agrif_Set_bc(       tsini_id, (/0,ind1-1/) ) ! if west,  rhox=3 and nbghost=3: columns 2 to 4
       CALL Agrif_Set_bc(        uini_id, (/0,ind1-1/) ) 
@@ -222,35 +221,32 @@
       !
       ! Build "intermediate" parent vertical grid on child domain
-      IF ( ln_vert_remap ) THEN
-
-         jpk_parent = Agrif_parent( jpk )
-         ALLOCATE(e3t0_parent(jpi,jpj,jpk_parent), &
-            &     e3u0_parent(jpi,jpj,jpk_parent), &
-            &     e3v0_parent(jpi,jpj,jpk_parent), STAT = ierr) 
-         IF( ierr  > 0 )   CALL ctl_warn('Agrif_Init_Domain: allocation of arrays failed')
+      jpk_parent = Agrif_parent( jpk )
+      ALLOCATE(e3t0_parent(jpi,jpj,jpk_parent), &
+         &     e3u0_parent(jpi,jpj,jpk_parent), &
+         &     e3v0_parent(jpi,jpj,jpk_parent), STAT = ierr) 
+      IF( ierr  > 0 )   CALL ctl_warn('Agrif_Init_Domain: allocation of arrays failed')
        
-         ! Retrieve expected parent scale factors on child grid:
-         Agrif_UseSpecialValue = .FALSE.
-         e3t0_parent(:,:,:) = 0._wp
-         CALL Agrif_Init_Variable(e3t0_interp_id, procname=interpe3t0_vremap)
-         !
-         ! Deduce scale factors at U and V points:
-         DO_3D( 0, 0, 0, 0, 1, jpk_parent )
-            e3u0_parent(ji,jj,jk) = 0.5_wp * (e3t0_parent(ji,jj,jk) + e3t0_parent(ji+1,jj  ,jk))
-            e3v0_parent(ji,jj,jk) = 0.5_wp * (e3t0_parent(ji,jj,jk) + e3t0_parent(ji  ,jj+1,jk))
-         END_3D
-
-         ! Assume a step at the bottom except if (pure) s-coordinates
-         IF ( .NOT.Agrif_Parent(ln_sco) ) THEN 
-            DO_2D( 1, 0, 1, 0 )
-               jk = mbku_parent(ji,jj)
-               e3u0_parent(ji,jj,jk) = MIN(e3t0_parent(ji,jj,jk), e3t0_parent(ji+1,jj  ,jk))
-               jk = mbkv_parent(ji,jj)
-               e3v0_parent(ji,jj,jk) = MIN(e3t0_parent(ji,jj,jk), e3t0_parent(ji  ,jj+1,jk))
-            END_2D
-         ENDIF
-
-         CALL lbc_lnk( 'Agrif_Init_Domain', e3u0_parent, 'U', 1.0_wp, e3v0_parent, 'V', 1.0_wp )
-      ENDIF
+      ! Retrieve expected parent scale factors on child grid:
+      Agrif_UseSpecialValue = .FALSE.
+      e3t0_parent(:,:,:) = 0._wp
+      CALL Agrif_Init_Variable(e3t0_interp_id, procname=interpe3t0_vremap)
+      !
+      ! Deduce scale factors at U and V points:
+      DO_3D( 0, 0, 0, 0, 1, jpk_parent )
+         e3u0_parent(ji,jj,jk) = 0.5_wp * (e3t0_parent(ji,jj,jk) + e3t0_parent(ji+1,jj  ,jk))
+         e3v0_parent(ji,jj,jk) = 0.5_wp * (e3t0_parent(ji,jj,jk) + e3t0_parent(ji  ,jj+1,jk))
+      END_3D
+
+      ! Assume a step at the bottom except if (pure) s-coordinates
+      IF ( .NOT.Agrif_Parent(ln_sco) ) THEN 
+         DO_2D( 1, 0, 1, 0 )
+            jk = mbku_parent(ji,jj)
+            e3u0_parent(ji,jj,jk) = MIN(e3t0_parent(ji,jj,jk), e3t0_parent(ji+1,jj  ,jk))
+            jk = mbkv_parent(ji,jj)
+            e3v0_parent(ji,jj,jk) = MIN(e3t0_parent(ji,jj,jk), e3t0_parent(ji  ,jj+1,jk))
+         END_2D
+      ENDIF
+
+      CALL lbc_lnk( 'Agrif_Init_Domain', e3u0_parent, 'U', 1.0_wp, e3v0_parent, 'V', 1.0_wp )
 
       ! check if masks and bathymetries match
@@ -262,15 +258,6 @@
          !
          kindic_agr = 0
-         IF( .NOT. ln_vert_remap ) THEN
-            !
-            ! check if tmask and vertical scale factors agree with parent in sponge area:
-            CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t)
-            !
-         ELSE
-            !
-            ! In case of vertical interpolation, check only that total depths agree between child and parent:
-                  
-            CALL Agrif_check_bat( kindic_agr )           
-         ENDIF
+         !         
+         CALL Agrif_check_bat( kindic_agr )           
          !
          CALL mpp_sum( 'agrif_InitValues_Domain', kindic_agr )
@@ -287,4 +274,6 @@
       WHERE (ssmask(:,:)  == 0._wp) mbkt_parent(:,:) = 0
       !
+      IF ( .NOT.ln_vert_remap ) DEALLOCATE(e3t0_parent, e3u0_parent, e3v0_parent)
+
    END SUBROUTINE Agrif_Init_Domain
 
