Index: NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_update.F90
===================================================================
--- NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_update.F90	(revision 13313)
+++ NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/NST/agrif_oce_update.F90	(revision 13337)
@@ -50,13 +50,7 @@
       IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update tracers  from grid Number',Agrif_Fixed()
 
-#if defined key_vertical
-! Effect of this has to be carrefully checked 
-! depending on what the nesting tools ensure for
-! volume conservation:
-      Agrif_UseSpecialValueInUpdate = .FALSE.
-#else
-      Agrif_UseSpecialValueInUpdate = .TRUE.
-#endif
+      Agrif_UseSpecialValueInUpdate = .NOT.l_vremap
       Agrif_SpecialValueFineGrid    = 0._wp
+      l_vremap                      = ln_vremap
       ! 
 # if ! defined DECAL_FEEDBACK
@@ -71,4 +65,5 @@
       !
       Agrif_UseSpecialValueInUpdate = .FALSE.
+      l_vremap                      = .FALSE.
       !
       !
@@ -86,7 +81,7 @@
       Agrif_UseSpecialValueInUpdate = .FALSE.
       Agrif_SpecialValueFineGrid    = 0._wp
-
-      use_sign_north = .TRUE.
-      sign_north     = -1._wp
+      l_vremap                      = ln_vremap
+      use_sign_north                = .TRUE.
+      sign_north                    = -1._wp
 
       !     
@@ -133,4 +128,5 @@
       !
       use_sign_north = .FALSE.
+      ln_vremap = .FALSE.
       !
    END SUBROUTINE Agrif_Update_Dyn
@@ -291,5 +287,4 @@
    END SUBROUTINE dom_vvl_update_UVF
 
-#if defined key_vertical
 
    SUBROUTINE updateTS( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before )
@@ -311,84 +306,124 @@
       !
       IF (before) THEN
-!jc_alt
-!         AGRIF_SpecialValue = -999._wp
-         DO jn = n1,n2-1
+         IF ( l_vremap ) THEN
+            DO jn = n1,n2-1
+               DO jk=k1,k2
+                  DO jj=j1,j2
+                     DO ji=i1,i2
+                        tabres(ji,jj,jk,jn) = ts(ji,jj,jk,jn,Kmm_a) * e3t(ji,jj,jk,Kmm_a)
+                     END DO
+                  END DO
+               END DO
+            END DO
             DO jk=k1,k2
                DO jj=j1,j2
                   DO ji=i1,i2
-!jc_alt
-!                     tabres(ji,jj,jk,jn) = (ts(ji,jj,jk,jn,Kmm_a) * e3t(ji,jj,jk,Kmm_a) ) &
-!                                         &  * tmask(ji,jj,jk) + (tmask(ji,jj,jk)-1._wp) * 999._wp
-                     tabres(ji,jj,jk,jn) = ts(ji,jj,jk,jn,Kmm_a) * e3t(ji,jj,jk,Kmm_a)
+                     tabres(ji,jj,jk,n2) = tmask(ji,jj,jk) * e3t(ji,jj,jk,Kmm_a)
                   END DO
                END DO
             END DO
-         END DO
-         DO jk=k1,k2
+         ELSE
+            DO jn = 1,jpts
+               DO jk=k1,k2
+                  DO jj=j1,j2
+                     DO ji=i1,i2
+                        tabres(ji,jj,jk,jn) = ts(ji,jj,jk,jn,Kmm_a)  * e3t(ji,jj,jk,Kmm_a) / e3t_0(ji,jj,jk)
+                     END DO
+                  END DO
+               END DO
+            END DO
+
+         ENDIF
+      ELSE
+         IF ( l_vremap ) THEN
+            tabres_child(:,:,:,:) = 0._wp
+            AGRIF_SpecialValue = 0._wp
             DO jj=j1,j2
                DO ji=i1,i2
-!jc_alt
-!                  tabres(ji,jj,jk,n2) =      tmask(ji,jj,jk) * e3t(ji,jj,jk,Kmm_a) &
-!                                      &   + (tmask(ji,jj,jk) - 1._wp) * 999._wp
-                  tabres(ji,jj,jk,n2) = tmask(ji,jj,jk) * e3t(ji,jj,jk,Kmm_a)
-               END DO
-            END DO
-         END DO
-      ELSE
-         tabres_child(:,:,:,:) = 0._wp
-         AGRIF_SpecialValue = 0._wp
-         DO jj=j1,j2
-            DO ji=i1,i2
-               N_in = 0
-               DO jk=k1,k2 !k2 = jpk of child grid
-! jc_alt
-!                  IF (tabres(ji,jj,jk,n2) < -900._wp  ) EXIT
-                  IF (tabres(ji,jj,jk,n2) == 0._wp  ) EXIT
-                  N_in = N_in + 1
-                  tabin(jk,:) = tabres(ji,jj,jk,n1:n2-1)/tabres(ji,jj,jk,n2)
-                  h_in(N_in) = tabres(ji,jj,jk,n2)
+                  N_in = 0
+                  DO jk=k1,k2 !k2 = jpk of child grid
+                     IF (tabres(ji,jj,jk,n2) == 0._wp  ) EXIT
+                     N_in = N_in + 1
+                     tabin(jk,:) = tabres(ji,jj,jk,n1:n2-1)/tabres(ji,jj,jk,n2)
+                     h_in(N_in) = tabres(ji,jj,jk,n2)
+                  ENDDO
+                  N_out = 0
+                  DO jk=1,jpk ! jpk of parent grid
+                     IF (tmask(ji,jj,jk) == 0 ) EXIT ! TODO: Will not work with ISF
+                     N_out = N_out + 1
+                     h_out(N_out) = e3t(ji,jj,jk,Kmm_a) 
+                  ENDDO
+                  IF (N_in*N_out > 0) THEN !Remove this?
+                     CALL reconstructandremap(tabin(1:N_in,1:jpts),h_in(1:N_in),tabres_child(ji,jj,1:N_out,1:jpts),h_out(1:N_out),N_in,N_out,jpts)
+                  ENDIF
                ENDDO
-               N_out = 0
-               DO jk=1,jpk ! jpk of parent grid
-                  IF (tmask(ji,jj,jk) == 0 ) EXIT ! TODO: Will not work with ISF
-                  N_out = N_out + 1
-                  h_out(N_out) = e3t(ji,jj,jk,Kmm_a) 
-               ENDDO
-               IF (N_in*N_out > 0) THEN !Remove this?
-                  CALL reconstructandremap(tabin(1:N_in,1:jpts),h_in(1:N_in),tabres_child(ji,jj,1:N_out,1:jpts),h_out(1:N_out),N_in,N_out,jpts)
-               ENDIF
             ENDDO
-         ENDDO
-
-         IF (.NOT.(lk_agrif_fstep.AND.(l_1st_euler))) THEN
-            ! Add asselin part
+
+            IF (.NOT.(lk_agrif_fstep.AND.(l_1st_euler))) THEN
+               ! Add asselin part
+               DO jn = 1,jpts
+                  DO jk = 1, jpkm1
+                     DO jj = j1, j2
+                        DO ji = i1, i2
+                           IF( tabres_child(ji,jj,jk,jn) /= 0._wp ) THEN
+                              ztb  = ts(ji,jj,jk,jn,Kbb_a) * e3t(ji,jj,jk,Kbb_a) ! fse3t_b prior update should be used
+                              ztnu = tabres_child(ji,jj,jk,jn) * e3t(ji,jj,jk,Kmm_a)
+                              ztno = ts(ji,jj,jk,jn,Kmm_a) * e3t(ji,jj,jk,Krhs_a)
+                              ts(ji,jj,jk,jn,Kbb_a) = ( ztb + rn_atfp * ( ztnu - ztno) )  & 
+                                        &        * tmask(ji,jj,jk) / e3t(ji,jj,jk,Kbb_a)
+                           ENDIF
+                        END DO
+                     END DO
+                  END DO
+               END DO
+            ENDIF
             DO jn = 1,jpts
                DO jk = 1, jpkm1
                   DO jj = j1, j2
                      DO ji = i1, i2
-                        IF( tabres_child(ji,jj,jk,jn) /= 0._wp ) THEN
-                           ztb  = ts(ji,jj,jk,jn,Kbb_a) * e3t(ji,jj,jk,Kbb_a) ! fse3t_b prior update should be used
-                           ztnu = tabres_child(ji,jj,jk,jn) * e3t(ji,jj,jk,Kmm_a)
-                           ztno = ts(ji,jj,jk,jn,Kmm_a) * e3t(ji,jj,jk,Krhs_a)
-                           ts(ji,jj,jk,jn,Kbb_a) = ( ztb + rn_atfp * ( ztnu - ztno) )  & 
-                                     &        * tmask(ji,jj,jk) / e3t(ji,jj,jk,Kbb_a)
-                        ENDIF
+                        IF( tabres_child(ji,jj,jk,jn) /= 0._wp ) THEN 
+                           ts(ji,jj,jk,jn,Kmm_a) = tabres_child(ji,jj,jk,jn)
+                        END IF
                      END DO
                   END DO
                END DO
             END DO
-         ENDIF
-         DO jn = 1,jpts
-            DO jk = 1, jpkm1
-               DO jj = j1, j2
-                  DO ji = i1, i2
-                     IF( tabres_child(ji,jj,jk,jn) /= 0._wp ) THEN 
-                        ts(ji,jj,jk,jn,Kmm_a) = tabres_child(ji,jj,jk,jn)
-                     END IF
+         ELSE
+            DO jn = 1,jpts
+               tabres(i1:i2,j1:j2,k1:k2,jn) =  tabres(i1:i2,j1:j2,k1:k2,jn) * e3t_0(i1:i2,j1:j2,k1:k2) &
+                                            & * tmask(i1:i2,j1:j2,k1:k2)
+            ENDDO
+ 
+            IF (.NOT.(lk_agrif_fstep.AND.(l_1st_euler))) THEN
+               ! Add asselin part
+               DO jn = 1,jpts
+                  DO jk = k1, k2
+                     DO jj = j1, j2
+                        DO ji = i1, i2
+                           IF( tabres(ji,jj,jk,jn) /= 0._wp ) THEN
+                              ztb  = ts(ji,jj,jk,jn,Kbb_a) * e3t(ji,jj,jk,Kbb_a) ! fse3t_b prior update should be used
+                              ztnu = tabres(ji,jj,jk,jn)
+                              ztno = ts(ji,jj,jk,jn,Kmm_a) * e3t(ji,jj,jk,Krhs_a)
+                              ts(ji,jj,jk,jn,Kbb_a) = ( ztb + rn_atfp * ( ztnu - ztno) )  & 
+                                        &        * tmask(ji,jj,jk) / e3t(ji,jj,jk,Kbb_a)
+                           ENDIF
+                        END DO
+                     END DO
                   END DO
                END DO
-            END DO
-         END DO
-         !
+            ENDIF
+            DO jn = 1,jpts
+               DO jk=k1,k2
+                  DO jj=j1,j2
+                     DO ji=i1,i2
+                        IF( tabres(ji,jj,jk,jn) /= 0._wp ) THEN 
+                           ts(ji,jj,jk,jn,Kmm_a) = tabres(ji,jj,jk,jn) / e3t(ji,jj,jk,Kmm_a)
+                        END IF
+                     END DO
+                  END DO
+               END DO
+            END DO
+            !
+         ENDIF
          IF  ((l_1st_euler).AND.(Agrif_Nb_Step()==0) ) THEN
             ts(i1:i2,j1:j2,1:jpkm1,1:jpts,Kbb_a)  = ts(i1:i2,j1:j2,1:jpkm1,1:jpts,Kmm_a)
@@ -398,79 +433,4 @@
    END SUBROUTINE updateTS
 
-# else
-
-   SUBROUTINE updateTS( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before )
-      !!---------------------------------------------
-      !!           *** ROUTINE updateT ***
-      !!---------------------------------------------
-      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,n1,n2
-      REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres
-      LOGICAL, INTENT(in) :: before
-      !!
-      INTEGER :: ji,jj,jk,jn
-      REAL(wp) :: ztb, ztnu, ztno
-      !!---------------------------------------------
-      !
-      IF (before) THEN
-         DO jn = 1,jpts
-            DO jk=k1,k2
-               DO jj=j1,j2
-                  DO ji=i1,i2
-!> jc tmp
-                     tabres(ji,jj,jk,jn) = ts(ji,jj,jk,jn,Kmm_a)  * e3t(ji,jj,jk,Kmm_a) / e3t_0(ji,jj,jk)
-!                     tabres(ji,jj,jk,jn) = ts(ji,jj,jk,jn,Kmm_a)  * e3t(ji,jj,jk,Kmm_a)
-!< jc tmp
-                  END DO
-               END DO
-            END DO
-         END DO
-      ELSE
-!> jc tmp
-         DO jn = 1,jpts
-            tabres(i1:i2,j1:j2,k1:k2,jn) =  tabres(i1:i2,j1:j2,k1:k2,jn) * e3t_0(i1:i2,j1:j2,k1:k2) &
-                                         & * tmask(i1:i2,j1:j2,k1:k2)
-         ENDDO
-!< jc tmp
-         IF (.NOT.(lk_agrif_fstep.AND.(l_1st_euler))) THEN
-            ! Add asselin part
-            DO jn = 1,jpts
-               DO jk = k1, k2
-                  DO jj = j1, j2
-                     DO ji = i1, i2
-                        IF( tabres(ji,jj,jk,jn) /= 0._wp ) THEN
-                           ztb  = ts(ji,jj,jk,jn,Kbb_a) * e3t(ji,jj,jk,Kbb_a) ! fse3t_b prior update should be used
-                           ztnu = tabres(ji,jj,jk,jn)
-                           ztno = ts(ji,jj,jk,jn,Kmm_a) * e3t(ji,jj,jk,Krhs_a)
-                           ts(ji,jj,jk,jn,Kbb_a) = ( ztb + rn_atfp * ( ztnu - ztno) )  & 
-                                     &        * tmask(ji,jj,jk) / e3t(ji,jj,jk,Kbb_a)
-                        ENDIF
-                     END DO
-                  END DO
-               END DO
-            END DO
-         ENDIF
-         DO jn = 1,jpts
-            DO jk=k1,k2
-               DO jj=j1,j2
-                  DO ji=i1,i2
-                     IF( tabres(ji,jj,jk,jn) /= 0._wp ) THEN 
-                        ts(ji,jj,jk,jn,Kmm_a) = tabres(ji,jj,jk,jn) / e3t(ji,jj,jk,Kmm_a)
-                     END IF
-                  END DO
-               END DO
-            END DO
-         END DO
-         !
-         IF  ((l_1st_euler).AND.(Agrif_Nb_Step()==0) ) THEN
-            ts(i1:i2,j1:j2,k1:k2,1:jpts,Kbb_a)  = ts(i1:i2,j1:j2,k1:k2,1:jpts,Kmm_a)
-         ENDIF
-         !
-      ENDIF
-      ! 
-   END SUBROUTINE updateTS
-
-# endif
-
-# if defined key_vertical
 
    SUBROUTINE updateu( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before )
@@ -496,65 +456,70 @@
       IF( before ) THEN
          zrhoy = Agrif_Rhoy()
-!jc_alt
-!         AGRIF_SpecialValue = -999._wp
          DO jk=k1,k2
+            tabres(i1:i2,j1:j2,jk,1) = zrhoy * e2u(i1:i2,j1:j2) * e3u(i1:i2,j1:j2,jk,Kmm_a) & 
+                                     &   * umask(i1:i2,j1:j2,jk) * uu(i1:i2,j1:j2,jk,Kmm_a)  
+         END DO
+
+         IF ( l_vremap ) THEN
+            DO jk=k1,k2
+               tabres(i1:i2,j1:j2,jk,2) = zrhoy * umask(i1:i2,j1:j2,jk) * e2u(i1:i2,j1:j2) * e3u(i1:i2,j1:j2,jk,Kmm_a)
+            END DO
+         ENDIF
+
+      ELSE
+
+         tabres_child(:,:,:) = 0._wp
+         AGRIF_SpecialValue = 0._wp
+
+         IF ( l_vremap ) THEN
+
             DO jj=j1,j2
                DO ji=i1,i2
-!jc_alt
-!                  tabres(ji,jj,jk,1) = zrhoy * e2u(ji,jj) * e3u(ji,jj,jk,Kmm_a) * umask(ji,jj,jk) * uu(ji,jj,jk,Kmm_a)  &
-!                                     &  + (umask(ji,jj,jk)-1._wp)*999._wp
-                  tabres(ji,jj,jk,1) = zrhoy * e2u(ji,jj) * e3u(ji,jj,jk,Kmm_a) * umask(ji,jj,jk) * uu(ji,jj,jk,Kmm_a)  
-!jc_alt
-!                  tabres(ji,jj,jk,2) = zrhoy * umask(ji,jj,jk) * e2u(ji,jj) * e3u(ji,jj,jk,Kmm_a)  &
-!                                     &  + (umask(ji,jj,jk)-1._wp)*999._wp
-                  tabres(ji,jj,jk,2) = zrhoy * umask(ji,jj,jk) * e2u(ji,jj) * e3u(ji,jj,jk,Kmm_a)
-               END DO
-            END DO
-         END DO
-      ELSE
-         tabres_child(:,:,:) = 0.
-         AGRIF_SpecialValue = 0._wp
-         DO jj=j1,j2
-            DO ji=i1,i2
-               N_in = 0
-               h_in(:) = 0._wp
-               tabin(:) = 0._wp
-               DO jk=k1,k2 !k2=jpk of child grid
-!jc_alt
-!                  IF( tabres(ji,jj,jk,2) < -900._wp) EXIT
-                  IF( tabres(ji,jj,jk,2) == 0.) EXIT
-                  N_in = N_in + 1
-                  tabin(jk) = tabres(ji,jj,jk,1)/tabres(ji,jj,jk,2)
-                  h_in(N_in) = tabres(ji,jj,jk,2)/e2u(ji,jj)
+                  N_in = 0
+                  h_in(:) = 0._wp
+                  tabin(:) = 0._wp
+                  DO jk=k1,k2 !k2=jpk of child grid
+                     IF( tabres(ji,jj,jk,2) == 0.) EXIT
+                     N_in = N_in + 1
+                     tabin(jk) = tabres(ji,jj,jk,1)/tabres(ji,jj,jk,2)
+                     h_in(N_in) = tabres(ji,jj,jk,2) * r1_e2u(ji,jj)
+                  ENDDO
+                  N_out = 0
+                  DO jk=1,jpk
+                     IF (umask(ji,jj,jk) == 0) EXIT
+                     N_out = N_out + 1
+                     h_out(N_out) = e3u(ji,jj,jk,Kmm_a)
+                  ENDDO
+                  IF (N_in * N_out > 0) THEN
+                     h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in))
+                     excess = 0._wp
+                     IF (h_diff < -1.e-4) THEN
+                        DO jk=N_in,1,-1
+                           thick = MIN(-1*h_diff, h_in(jk))
+                           excess = excess + tabin(jk)*thick*e2u(ji,jj)
+                           tabin(jk) = tabin(jk)*(1. - thick/h_in(jk))
+                           h_diff = h_diff + thick
+                           IF ( h_diff == 0) THEN
+                              N_in = jk
+                              h_in(jk) = h_in(jk) - thick
+                              EXIT
+                           ENDIF
+                        ENDDO
+                     ENDIF
+                     CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out,1)
+                     tabres_child(ji,jj,N_out) = tabres_child(ji,jj,N_out) + excess/(e2u(ji,jj)*h_out(N_out))
+                  ENDIF
                ENDDO
-               N_out = 0
-               DO jk=1,jpk
-                  IF (umask(ji,jj,jk) == 0) EXIT
-                  N_out = N_out + 1
-                  h_out(N_out) = e3u(ji,jj,jk,Kmm_a)
-               ENDDO
-               IF (N_in * N_out > 0) THEN
-                  h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in))
-                  excess = 0._wp
-                  IF (h_diff < -1.e-4) THEN
-!Even if bathy at T points match it's possible for the U points to be deeper in the child grid. 
-!In this case we need to move transport from the child grid cells below bed of parent grid into the bottom cell.
-                     DO jk=N_in,1,-1
-                        thick = MIN(-1*h_diff, h_in(jk))
-                        excess = excess + tabin(jk)*thick*e2u(ji,jj)
-                        tabin(jk) = tabin(jk)*(1. - thick/h_in(jk))
-                        h_diff = h_diff + thick
-                        IF ( h_diff == 0) THEN
-                           N_in = jk
-                           h_in(jk) = h_in(jk) - thick
-                           EXIT
-                        ENDIF
-                     ENDDO
-                  ENDIF
-                  CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out,1)
-                  tabres_child(ji,jj,N_out) = tabres_child(ji,jj,N_out) + excess/(e2u(ji,jj)*h_out(N_out))
-               ENDIF
             ENDDO
-         ENDDO
+
+         ELSE
+            DO jk=1,jpk
+               DO jj=j1,j2
+                  DO ji=i1,i2
+                     tabres_child(ji,jj,jk) = tabres(ji,jj,jk,1) * r1_e2u(ji,jj) /  e3u(ji,jj,jk,Kmm_a)
+                  END DO
+               END DO
+            END DO
+         ENDIF
          !
          DO jk=1,jpk
@@ -582,52 +547,4 @@
    END SUBROUTINE updateu
 
-#else
-
-   SUBROUTINE updateu( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before )
-      !!---------------------------------------------
-      !!           *** ROUTINE updateu ***
-      !!---------------------------------------------
-      INTEGER                               , INTENT(in   ) :: i1, i2, j1, j2, k1, k2, n1, n2
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres
-      LOGICAL                                     , INTENT(in   ) :: before
-      !
-      INTEGER  :: ji, jj, jk
-      REAL(wp) :: zrhoy, zub, zunu, zuno
-      !!---------------------------------------------
-      ! 
-      IF( before ) THEN
-         zrhoy = Agrif_Rhoy()
-         DO jk = k1, k2
-            tabres(i1:i2,j1:j2,jk,1) = zrhoy * e2u(i1:i2,j1:j2) * e3u(i1:i2,j1:j2,jk,Kmm_a) * uu(i1:i2,j1:j2,jk,Kmm_a)
-         END DO
-      ELSE
-         DO jk=k1,k2
-            DO jj=j1,j2
-               DO ji=i1,i2
-                  tabres(ji,jj,jk,1) = tabres(ji,jj,jk,1) * r1_e2u(ji,jj) 
-                  !
-                  IF (.NOT.(lk_agrif_fstep.AND.(l_1st_euler))) THEN ! Add asselin part
-                     zub  = uu(ji,jj,jk,Kbb_a) * e3u(ji,jj,jk,Kbb_a)  ! fse3t_b prior update should be used
-                     zuno = uu(ji,jj,jk,Kmm_a) * e3u(ji,jj,jk,Krhs_a)
-                     zunu = tabres(ji,jj,jk,1)
-                     uu(ji,jj,jk,Kbb_a) = ( zub + rn_atfp * ( zunu - zuno) ) &      
-                                    & * umask(ji,jj,jk) / e3u(ji,jj,jk,Kbb_a)
-                  ENDIF
-                  !
-                  uu(ji,jj,jk,Kmm_a) = tabres(ji,jj,jk,1) * umask(ji,jj,jk) / e3u(ji,jj,jk,Kmm_a)
-               END DO
-            END DO
-         END DO
-         !
-         IF  ((l_1st_euler).AND.(Agrif_Nb_Step()==0) ) THEN
-            uu(i1:i2,j1:j2,k1:k2,Kbb_a)  = uu(i1:i2,j1:j2,k1:k2,Kmm_a)
-         ENDIF
-         !
-      ENDIF
-      ! 
-   END SUBROUTINE updateu
-
-# endif
-
    SUBROUTINE correct_u_bdy( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before, nb, ndir )
       !!---------------------------------------------
@@ -674,5 +591,4 @@
    END SUBROUTINE correct_u_bdy
 
-# if  defined key_vertical
 
    SUBROUTINE updatev( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before )
@@ -698,63 +614,70 @@
       IF( before ) THEN
          zrhox = Agrif_Rhox()
-!jc_alt
-!         AGRIF_SpecialValue = -999._wp
          DO jk=k1,k2
+            tabres(i1:i2,j1:j2,jk,1) = zrhox * e1v(i1:i2,j1:j2) * e3v(i1:i2,j1:j2,jk,Kmm_a) & 
+                                     &   * vmask(i1:i2,j1:j2,jk) * vv(i1:i2,j1:j2,jk,Kmm_a)  
+         END DO
+
+         IF ( l_vremap ) THEN
+            DO jk=k1,k2
+               tabres(i1:i2,j1:j2,jk,2) = zrhox * e1v(i1:i2,j1:j2) * e3v(i1:i2,j1:j2,jk,Kmm_a) * vmask(i1:i2,j1:j2,jk)
+            END DO
+         ENDIF
+
+      ELSE
+
+         tabres_child(:,:,:) = 0._wp
+         AGRIF_SpecialValue = 0._wp
+
+         IF ( l_vremap ) THEN
+
             DO jj=j1,j2
                DO ji=i1,i2
-!jc_alt
-!                  tabres(ji,jj,jk,1) = zrhox * e1v(ji,jj) * e3v(ji,jj,jk,Kmm_a) * vmask(ji,jj,jk) * vv(ji,jj,jk,Kmm_a) &
-!                                     & + (vmask(ji,jj,jk)-1._wp) * 999._wp
-                  tabres(ji,jj,jk,1) = zrhox * e1v(ji,jj) * e3v(ji,jj,jk,Kmm_a) * vmask(ji,jj,jk) * vv(ji,jj,jk,Kmm_a) 
-!jc_alt
-!                  tabres(ji,jj,jk,2) = zrhox * e1v(ji,jj) * e3v(ji,jj,jk,Kmm_a) * vmask(ji,jj,jk) &
-!                                     & + (vmask(ji,jj,jk)-1._wp) * 999._wp
-                  tabres(ji,jj,jk,2) = zrhox * e1v(ji,jj) * e3v(ji,jj,jk,Kmm_a) * vmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-      ELSE
-         tabres_child(:,:,:) = 0.
-         AGRIF_SpecialValue = 0._wp
-         DO jj=j1,j2
-            DO ji=i1,i2
-               N_in = 0
-               DO jk=k1,k2
-!jc_alt
-!                  IF (tabres(ji,jj,jk,2) < -900._wp) EXIT
-                  IF (tabres(ji,jj,jk,2) == 0) EXIT
-                  N_in = N_in + 1
-                  tabin(jk) = tabres(ji,jj,jk,1)/tabres(ji,jj,jk,2)
-                  h_in(N_in) = tabres(ji,jj,jk,2)/e1v(ji,jj)
-               ENDDO
-               N_out = 0
-               DO jk=1,jpk
-                  IF (vmask(ji,jj,jk) == 0) EXIT
-                  N_out = N_out + 1
-                  h_out(N_out) = e3v(ji,jj,jk,Kmm_a)
-               ENDDO
-               IF (N_in * N_out > 0) THEN
-                  h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in))
-                  excess = 0._wp
-                  IF (h_diff < -1.e-4) then
+                  N_in = 0
+                  DO jk=k1,k2
+                     IF (tabres(ji,jj,jk,2) == 0) EXIT
+                     N_in = N_in + 1
+                     tabin(jk) = tabres(ji,jj,jk,1)/tabres(ji,jj,jk,2)
+                     h_in(N_in) = tabres(ji,jj,jk,2) * r1_e1v(ji,jj)
+                  ENDDO
+                  N_out = 0
+                  DO jk=1,jpk
+                     IF (vmask(ji,jj,jk) == 0) EXIT
+                     N_out = N_out + 1
+                     h_out(N_out) = e3v(ji,jj,jk,Kmm_a)
+                  ENDDO
+                  IF (N_in * N_out > 0) THEN
+                     h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in))
+                     excess = 0._wp
+                     IF (h_diff < -1.e-4) then
 !Even if bathy at T points match it's possible for the V points to be deeper in the child grid. 
 !In this case we need to move transport from the child grid cells below bed of parent grid into the bottom cell.
-                     DO jk=N_in,1,-1
-                        thick = MIN(-1*h_diff, h_in(jk))
-                        excess = excess + tabin(jk)*thick*e2u(ji,jj)
-                        tabin(jk) = tabin(jk)*(1. - thick/h_in(jk))
-                        h_diff = h_diff + thick
-                        IF ( h_diff == 0) THEN
-                           N_in = jk
-                           h_in(jk) = h_in(jk) - thick
-                           EXIT
-                        ENDIF
-                     ENDDO
+                        DO jk=N_in,1,-1
+                           thick = MIN(-1*h_diff, h_in(jk))
+                           excess = excess + tabin(jk)*thick*e2u(ji,jj)
+                           tabin(jk) = tabin(jk)*(1. - thick/h_in(jk))
+                           h_diff = h_diff + thick
+                           IF ( h_diff == 0) THEN
+                              N_in = jk
+                              h_in(jk) = h_in(jk) - thick
+                              EXIT
+                           ENDIF
+                        ENDDO
+                     ENDIF
+                     CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out,1)
+                     tabres_child(ji,jj,N_out) = tabres_child(ji,jj,N_out) + excess/(e1v(ji,jj)*h_out(N_out))
                   ENDIF
-                  CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out,1)
-                  tabres_child(ji,jj,N_out) = tabres_child(ji,jj,N_out) + excess/(e1v(ji,jj)*h_out(N_out))
-               ENDIF
+               ENDDO
             ENDDO
-         ENDDO
+
+         ELSE
+            DO jk=1,jpk
+               DO jj=j1,j2
+                  DO ji=i1,i2
+                     tabres_child(ji,jj,jk) = tabres(ji,jj,jk,1) * r1_e1v(ji,jj) /  e3v(ji,jj,jk,Kmm_a)
+                  END DO
+               END DO
+            END DO
+         ENDIF
          !
          DO jk=1,jpkm1
@@ -782,55 +705,4 @@
    END SUBROUTINE updatev
 
-# else
-
-   SUBROUTINE updatev( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before)
-      !!---------------------------------------------
-      !!           *** ROUTINE updatev ***
-      !!---------------------------------------------
-      INTEGER                                     , INTENT(in   ) :: i1, i2, j1, j2, k1, k2, n1, n2
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres
-      LOGICAL                                     , INTENT(in   ) :: before
-      !
-      INTEGER  :: ji, jj, jk
-      REAL(wp) :: zrhox, zvb, zvnu, zvno
-      !!---------------------------------------------      
-      !
-      IF (before) THEN
-         zrhox = Agrif_Rhox()
-         DO jk=k1,k2
-            DO jj=j1,j2
-               DO ji=i1,i2
-                  tabres(ji,jj,jk,1) = zrhox * e1v(ji,jj) * e3v(ji,jj,jk,Kmm_a) * vv(ji,jj,jk,Kmm_a)
-               END DO
-            END DO
-         END DO
-      ELSE
-         DO jk=k1,k2
-            DO jj=j1,j2
-               DO ji=i1,i2
-                  tabres(ji,jj,jk,1) = tabres(ji,jj,jk,1) * r1_e1v(ji,jj)
-                  !
-                  IF (.NOT.(lk_agrif_fstep.AND.(l_1st_euler))) THEN ! Add asselin part
-                     zvb  = vv(ji,jj,jk,Kbb_a) * e3v(ji,jj,jk,Kbb_a) ! fse3t_b prior update should be used
-                     zvno = vv(ji,jj,jk,Kmm_a) * e3v(ji,jj,jk,Krhs_a)
-                     zvnu = tabres(ji,jj,jk,1)
-                     vv(ji,jj,jk,Kbb_a) = ( zvb + rn_atfp * ( zvnu - zvno) ) &      
-                                    & * vmask(ji,jj,jk) / e3v(ji,jj,jk,Kbb_a)
-                  ENDIF
-                  !
-                  vv(ji,jj,jk,Kmm_a) = tabres(ji,jj,jk,1) * vmask(ji,jj,jk) / e3v(ji,jj,jk,Kmm_a)
-               END DO
-            END DO
-         END DO
-         !
-         IF  ((l_1st_euler).AND.(Agrif_Nb_Step()==0) ) THEN
-            vv(i1:i2,j1:j2,k1:k2,Kbb_a)  = vv(i1:i2,j1:j2,k1:k2,Kmm_a)
-         ENDIF
-         !
-      ENDIF
-      ! 
-   END SUBROUTINE updatev
-
-# endif
 
    SUBROUTINE correct_v_bdy( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before, nb, ndir )
