Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_all_update.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_all_update.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_all_update.F90	(revision 11574)
@@ -1,5 +1,3 @@
-#define TWO_WAY
-
- MODULE agrif_all_update
+MODULE agrif_all_update
    !!======================================================================
    !!                   ***  MODULE  agrif_all_update  ***
@@ -41,6 +39,5 @@
       !!               Order of update matters here !
       !!----------------------------------------------------------------------
-# if defined TWO_WAY
-      IF (Agrif_Root()) RETURN
+      IF (( .NOT.ln_agrif_2way ).OR.(Agrif_Root())) RETURN
       !
       IF (lwp.AND.lk_agrif_debug) Write(*,*) ' --> START AGRIF UPDATE from grid Number',Agrif_Fixed()
@@ -67,5 +64,4 @@
       !
       Agrif_UseSpecialValueInUpdate = .FALSE.
-#endif
     END SUBROUTINE agrif_Update_All
 
Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_ice_update.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_ice_update.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_ice_update.F90	(revision 11574)
@@ -1,4 +1,2 @@
-#define TWO_WAY
-!!#undef TWO_WAY
 #undef DECAL_FEEDBACK  /* SEPARATION of INTERFACES*/
 
@@ -63,5 +61,4 @@
       Agrif_UseSpecialValueInUpdate = .TRUE.
 
-# if defined TWO_WAY
 # if ! defined DECAL_FEEDBACK
       CALL Agrif_Update_Variable( tra_ice_id , procname = update_tra_ice  )
@@ -79,5 +76,4 @@
 !      CALL Agrif_Update_Variable( u_ice_id   , locupdate=(/0,1/), procname = update_u_ice    )
 !      CALL Agrif_Update_Variable( v_ice_id   , locupdate=(/0,1/), procname = update_v_ice    )
-# endif
       Agrif_SpecialValueFineGrid    = 0.
       Agrif_UseSpecialValueInUpdate = .FALSE.
Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce.F90	(revision 11574)
@@ -21,14 +21,12 @@
 #endif   
    !                                              !!* Namelist namagrif: AGRIF parameters
-   LOGICAL , PUBLIC ::   ln_spc_dyn    = .FALSE.   !:
-   INTEGER , PUBLIC, PARAMETER ::   nn_sponge_len = 2  !: Sponge width (in number of parent grid points)
+   LOGICAL , PUBLIC ::   ln_agrif_2way = .TRUE.    !: activate two way nesting 
+   LOGICAL , PUBLIC ::   ln_spc_dyn    = .FALSE.   !: use zeros (.false.) or not (.true.) in
+                                                   !: bdys dynamical fields interpolation
    REAL(wp), PUBLIC ::   rn_sponge_tra = 2800.     !: sponge coeff. for tracers
    REAL(wp), PUBLIC ::   rn_sponge_dyn = 2800.     !: sponge coeff. for dynamics
    LOGICAL , PUBLIC ::   ln_chk_bathy  = .FALSE.   !: check of parent bathymetry 
-   LOGICAL , PUBLIC ::   lk_agrif_clp  = .FALSE.   !: Force clamped bcs
-   !                                              !!! OLD namelist names
-   REAL(wp), PUBLIC ::   visc_tra                  !: sponge coeff. for tracers
-   REAL(wp), PUBLIC ::   visc_dyn                  !: sponge coeff. for dynamics
-
+   !
+   INTEGER , PUBLIC, PARAMETER ::   nn_sponge_len = 2  !: Sponge width (in number of parent grid points)
    LOGICAL , PUBLIC :: spongedoneT = .FALSE.       !: tracer   sponge layer indicator
    LOGICAL , PUBLIC :: spongedoneU = .FALSE.       !: dynamics sponge layer indicator
@@ -42,12 +40,11 @@
    LOGICAL , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: tabspongedone_u
    LOGICAL , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: tabspongedone_v
+   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: utint_stage
+   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: vtint_stage
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: fsaht_spu, fsaht_spv !: sponge diffusivities
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: fsahm_spt, fsahm_spf !: sponge viscosities
 
    ! Barotropic arrays used to store open boundary data during time-splitting loop:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  ubdy_w, vbdy_w, hbdy_w
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  ubdy_e, vbdy_e, hbdy_e
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  ubdy_n, vbdy_n, hbdy_n
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  ubdy_s, vbdy_s, hbdy_s
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  ubdy, vbdy, hbdy
 
 
@@ -82,7 +79,8 @@
       ierr(:) = 0
       !
-      ALLOCATE( fsaht_spu(jpi,jpj), fsaht_spv(jpi,jpj),   &
-         &      fsahm_spt(jpi,jpj), fsahm_spf(jpi,jpj),   &
-         &      tabspongedone_tsn(jpi,jpj),           &
+      ALLOCATE( fsaht_spu(jpi,jpj), fsaht_spv(jpi,jpj),     &
+         &      fsahm_spt(jpi,jpj), fsahm_spf(jpi,jpj),     &
+         &      tabspongedone_tsn(jpi,jpj),                 &
+         &      utint_stage(jpi,jpj), vtint_stage(jpi,jpj), &
 # if defined key_top         
          &      tabspongedone_trn(jpi,jpj),           &
@@ -91,8 +89,5 @@
          &      tabspongedone_v  (jpi,jpj), STAT = ierr(1) )
 
-      ALLOCATE( ubdy_w(nbghostcells,jpj), vbdy_w(nbghostcells,jpj), hbdy_w(nbghostcells,jpj),   &
-         &      ubdy_e(nbghostcells,jpj), vbdy_e(nbghostcells,jpj), hbdy_e(nbghostcells,jpj),   & 
-         &      ubdy_n(jpi,nbghostcells), vbdy_n(jpi,nbghostcells), hbdy_n(jpi,nbghostcells),   & 
-         &      ubdy_s(jpi,nbghostcells), vbdy_s(jpi,nbghostcells), hbdy_s(jpi,nbghostcells), STAT = ierr(2) )
+      ALLOCATE( ubdy(jpi,jpj), vbdy(jpi,jpj), hbdy(jpi,jpj), STAT = ierr(2) )
 
       agrif_oce_alloc = MAXVAL(ierr)
Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_interp.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_interp.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_interp.F90	(revision 11574)
@@ -37,5 +37,5 @@
    PRIVATE
 
-   PUBLIC   Agrif_dyn, Agrif_ssh, Agrif_dyn_ts, Agrif_ssh_ts, Agrif_dta_ts
+   PUBLIC   Agrif_dyn, Agrif_ssh, Agrif_dyn_ts, Agrif_dyn_ts_flux, Agrif_ssh_ts, Agrif_dta_ts
    PUBLIC   Agrif_tra, Agrif_avm
    PUBLIC   interpun , interpvn
@@ -43,6 +43,4 @@
    PUBLIC   interpunb, interpvnb , interpub2b, interpvb2b
    PUBLIC   interpe3t, interpumsk, interpvmsk
-
-   INTEGER ::   bdy_tinterp = 0
 
 #  include "vectopt_loop_substitute.h90"
@@ -78,5 +76,4 @@
       !
       INTEGER ::   ji, jj, jk       ! dummy loop indices
-      INTEGER ::   j1, j2, i1, i2
       INTEGER ::   ibdy1, jbdy1, ibdy2, jbdy2
       REAL(wp), DIMENSION(jpi,jpj) ::   zub, zvb
@@ -93,300 +90,246 @@
       Agrif_UseSpecialValue = .FALSE.
       !
-      ! prevent smoothing in ghost cells
-      i1 =  1   ;   i2 = nlci
-      j1 =  1   ;   j2 = nlcj
-      IF( nbondj == -1 .OR. nbondj == 2 )   j1 = 2 + nbghostcells
-      IF( nbondj == +1 .OR. nbondj == 2 )   j2 = nlcj - nbghostcells - 1
-      IF( nbondi == -1 .OR. nbondi == 2 )   i1 = 2 + nbghostcells 
-      IF( nbondi == +1 .OR. nbondi == 2 )   i2 = nlci - nbghostcells - 1
-
       ! --- West --- !
-      IF( nbondi == -1 .OR. nbondi == 2 ) THEN
-         ibdy1 = 2
-         ibdy2 = 1+nbghostcells 
-         !
-         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-            ua_b(ibdy1:ibdy2,:) = 0._wp
+      ibdy1 = 2
+      ibdy2 = 1+nbghostcells 
+      !
+      IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+         DO ji = mi0(ibdy1), mi1(ibdy2)
+            ua_b(ji,:) = 0._wp
+
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  ua_b(ibdy1:ibdy2,jj) = ua_b(ibdy1:ibdy2,jj) & 
-                      & + e3u_a(ibdy1:ibdy2,jj,jk) * ua(ibdy1:ibdy2,jj,jk) * umask(ibdy1:ibdy2,jj,jk)
-               END DO
-            END DO
+                  ua_b(ji,jj) = ua_b(ji,jj) + e3u_a(ji,jj,jk) * ua(ji,jj,jk) * umask(ji,jj,jk)
+               END DO
+            END DO
+
             DO jj = 1, jpj
-               ua_b(ibdy1:ibdy2,jj) = ua_b(ibdy1:ibdy2,jj) * r1_hu_a(ibdy1:ibdy2,jj)
-            END DO
-         ENDIF
-         !
-         IF( .NOT.lk_agrif_clp ) THEN
-            DO jk=1,jpkm1              ! Smooth
-               DO jj=j1,j2
-                  ua(ibdy2,jj,jk) = 0.25_wp*(ua(ibdy2-1,jj,jk)+2._wp*ua(ibdy2,jj,jk)+ua(ibdy2+1,jj,jk))
-               END DO
-            END DO
-         ENDIF
-         !
-         zub(ibdy1:ibdy2,:) = 0._wp    ! Correct transport
+               ua_b(ji,jj) = ua_b(ji,jj) * r1_hu_a(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !
+      DO ji = mi0(ibdy1), mi1(ibdy2)
+         zub(ji,:) = 0._wp    ! Correct transport
          DO jk = 1, jpkm1
             DO jj = 1, jpj
-               zub(ibdy1:ibdy2,jj) = zub(ibdy1:ibdy2,jj) & 
-                  & + e3u_a(ibdy1:ibdy2,jj,jk)  * ua(ibdy1:ibdy2,jj,jk)*umask(ibdy1:ibdy2,jj,jk)
+               zub(ji,jj) = zub(ji,jj) & 
+                  & + e3u_a(ji,jj,jk)  * ua(ji,jj,jk)*umask(ji,jj,jk)
             END DO
          END DO
          DO jj=1,jpj
-            zub(ibdy1:ibdy2,jj) = zub(ibdy1:ibdy2,jj) * r1_hu_a(ibdy1:ibdy2,jj)
+            zub(ji,jj) = zub(ji,jj) * r1_hu_a(ji,jj)
          END DO
             
          DO jk = 1, jpkm1
             DO jj = 1, jpj
-               ua(ibdy1:ibdy2,jj,jk) = ( ua(ibdy1:ibdy2,jj,jk) &
-                 & + ua_b(ibdy1:ibdy2,jj)-zub(ibdy1:ibdy2,jj)) * umask(ibdy1:ibdy2,jj,jk)
-            END DO
-         END DO
+               ua(ji,jj,jk) = ( ua(ji,jj,jk) + ua_b(ji,jj)-zub(ji,jj)) * umask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
             
-         IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
-            zvb(ibdy1:ibdy2,:) = 0._wp
+      IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+         DO ji = mi0(ibdy1), mi1(ibdy2)
+            zvb(ji,:) = 0._wp
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  zvb(ibdy1:ibdy2,jj) = zvb(ibdy1:ibdy2,jj) & 
-                     & + e3v_a(ibdy1:ibdy2,jj,jk) * va(ibdy1:ibdy2,jj,jk) * vmask(ibdy1:ibdy2,jj,jk)
+                  zvb(ji,jj) = zvb(ji,jj) + e3v_a(ji,jj,jk) * va(ji,jj,jk) * vmask(ji,jj,jk)
                END DO
             END DO
             DO jj = 1, jpj
-               zvb(ibdy1:ibdy2,jj) = zvb(ibdy1:ibdy2,jj) * r1_hv_a(ibdy1:ibdy2,jj)
+               zvb(ji,jj) = zvb(ji,jj) * r1_hv_a(ji,jj)
             END DO
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  va(ibdy1:ibdy2,jj,jk) = ( va(ibdy1:ibdy2,jj,jk) & 
-                    & + va_b(ibdy1:ibdy2,jj)-zvb(ibdy1:ibdy2,jj))*vmask(ibdy1:ibdy2,jj,jk)
-               END DO
-            END DO
-         ENDIF
-         !
-         DO jk = 1, jpkm1              ! Mask domain edges
-            DO jj = 1, jpj
-               ua(1,jj,jk) = 0._wp
-               va(1,jj,jk) = 0._wp
-            END DO
-         END DO 
+                  va(ji,jj,jk) = ( va(ji,jj,jk) + va_b(ji,jj)-zvb(ji,jj))*vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
       ENDIF
 
       ! --- East --- !
-      IF( nbondi ==  1 .OR. nbondi == 2 ) THEN
-         ibdy1 = nlci-1-nbghostcells
-         ibdy2 = nlci-2 
-         !
-         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-            ua_b(ibdy1:ibdy2,:) = 0._wp
+      ibdy1 = jpiglo-1-nbghostcells
+      ibdy2 = jpiglo-2 
+      !
+      IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+         DO ji = mi0(ibdy1), mi1(ibdy2)
+            ua_b(ji,:) = 0._wp
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  ua_b(ibdy1:ibdy2,jj) = ua_b(ibdy1:ibdy2,jj) & 
-                      & + e3u_a(ibdy1:ibdy2,jj,jk) * ua(ibdy1:ibdy2,jj,jk) * umask(ibdy1:ibdy2,jj,jk)
+                  ua_b(ji,jj) = ua_b(ji,jj) & 
+                      & + e3u_a(ji,jj,jk) * ua(ji,jj,jk) * umask(ji,jj,jk)
                END DO
             END DO
             DO jj = 1, jpj
-               ua_b(ibdy1:ibdy2,jj) = ua_b(ibdy1:ibdy2,jj) * r1_hu_a(ibdy1:ibdy2,jj)
-            END DO
-         ENDIF
-         !
-         IF( .NOT.lk_agrif_clp ) THEN
-            DO jk=1,jpkm1              ! Smooth
-               DO jj=j1,j2
-                  ua(ibdy1,jj,jk) = 0.25_wp*(ua(ibdy1-1,jj,jk)+2._wp*ua(ibdy1,jj,jk)+ua(ibdy1+1,jj,jk))
-               END DO
-            END DO
-         ENDIF
-         !
-         zub(ibdy1:ibdy2,:) = 0._wp    ! Correct transport
+               ua_b(ji,jj) = ua_b(ji,jj) * r1_hu_a(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !
+      DO ji = mi0(ibdy1), mi1(ibdy2)
+         zub(ji,:) = 0._wp    ! Correct transport
          DO jk = 1, jpkm1
             DO jj = 1, jpj
-               zub(ibdy1:ibdy2,jj) = zub(ibdy1:ibdy2,jj) & 
-                  & + e3u_a(ibdy1:ibdy2,jj,jk)  * ua(ibdy1:ibdy2,jj,jk) * umask(ibdy1:ibdy2,jj,jk)
+               zub(ji,jj) = zub(ji,jj) & 
+                  & + e3u_a(ji,jj,jk)  * ua(ji,jj,jk) * umask(ji,jj,jk)
             END DO
          END DO
          DO jj=1,jpj
-            zub(ibdy1:ibdy2,jj) = zub(ibdy1:ibdy2,jj) * r1_hu_a(ibdy1:ibdy2,jj)
+            zub(ji,jj) = zub(ji,jj) * r1_hu_a(ji,jj)
          END DO
             
          DO jk = 1, jpkm1
             DO jj = 1, jpj
-               ua(ibdy1:ibdy2,jj,jk) = ( ua(ibdy1:ibdy2,jj,jk) & 
-                 & + ua_b(ibdy1:ibdy2,jj)-zub(ibdy1:ibdy2,jj))*umask(ibdy1:ibdy2,jj,jk)
-            END DO
-         END DO
+               ua(ji,jj,jk) = ( ua(ji,jj,jk) & 
+                 & + ua_b(ji,jj)-zub(ji,jj))*umask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
             
-         IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
-            ibdy1 = ibdy1 + 1
-            ibdy2 = ibdy2 + 1 
-            zvb(ibdy1:ibdy2,:) = 0._wp
+      IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+         ibdy1 = jpiglo-nbghostcells
+         ibdy2 = jpiglo-1 
+         DO ji = mi0(ibdy1), mi1(ibdy2)
+            zvb(ji,:) = 0._wp
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  zvb(ibdy1:ibdy2,jj) = zvb(ibdy1:ibdy2,jj) &
-                     & + e3v_a(ibdy1:ibdy2,jj,jk) * va(ibdy1:ibdy2,jj,jk) * vmask(ibdy1:ibdy2,jj,jk)
+                  zvb(ji,jj) = zvb(ji,jj) &
+                     & + e3v_a(ji,jj,jk) * va(ji,jj,jk) * vmask(ji,jj,jk)
                END DO
             END DO
             DO jj = 1, jpj
-               zvb(ibdy1:ibdy2,jj) = zvb(ibdy1:ibdy2,jj) * r1_hv_a(ibdy1:ibdy2,jj)
+               zvb(ji,jj) = zvb(ji,jj) * r1_hv_a(ji,jj)
             END DO
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  va(ibdy1:ibdy2,jj,jk) = ( va(ibdy1:ibdy2,jj,jk) & 
-                      & + va_b(ibdy1:ibdy2,jj)-zvb(ibdy1:ibdy2,jj)) * vmask(ibdy1:ibdy2,jj,jk)
-               END DO
-            END DO
-         ENDIF
-         !
-         DO jk = 1, jpkm1              ! Mask domain edges
-            DO jj = 1, jpj
-               ua(nlci-1,jj,jk) = 0._wp
-               va(nlci  ,jj,jk) = 0._wp
-            END DO
-         END DO 
+                  va(ji,jj,jk) = ( va(ji,jj,jk) & 
+                      & + va_b(ji,jj)-zvb(ji,jj)) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
       ENDIF
 
       ! --- South --- !
-      IF( nbondj == -1 .OR. nbondj == 2 ) THEN
-         jbdy1 = 2
-         jbdy2 = 1+nbghostcells 
-         !
-         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-            va_b(:,jbdy1:jbdy2) = 0._wp
+      jbdy1 = 2
+      jbdy2 = 1+nbghostcells 
+      !
+      IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+         DO jj = mj0(jbdy1), mj1(jbdy2)
+            va_b(:,jj) = 0._wp
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  va_b(ji,jbdy1:jbdy2) = va_b(ji,jbdy1:jbdy2) & 
-                      & + e3v_a(ji,jbdy1:jbdy2,jk) * va(ji,jbdy1:jbdy2,jk) * vmask(ji,jbdy1:jbdy2,jk)
+                  va_b(ji,jj) = va_b(ji,jj) & 
+                      & + e3v_a(ji,jj,jk) * va(ji,jj,jk) * vmask(ji,jj,jk)
                END DO
             END DO
             DO ji=1,jpi
-               va_b(ji,jbdy1:jbdy2) = va_b(ji,jbdy1:jbdy2) * r1_hv_a(ji,jbdy1:jbdy2)
-            END DO
-         ENDIF
-         !
-         IF ( .NOT.lk_agrif_clp ) THEN
-            DO jk = 1, jpkm1           ! Smooth
-               DO ji = i1, i2
-                  va(ji,jbdy2,jk) = 0.25_wp*(va(ji,jbdy2-1,jk)+2._wp*va(ji,jbdy2,jk)+va(ji,jbdy2+1,jk))
-               END DO
-            END DO
-         ENDIF
-         !
-         zvb(:,jbdy1:jbdy2) = 0._wp    ! Correct transport
+               va_b(ji,jj) = va_b(ji,jj) * r1_hv_a(ji,jj)     
+            END DO
+         END DO
+      ENDIF
+      !
+      DO jj = mj0(jbdy1), mj1(jbdy2)
+         zvb(:,jj) = 0._wp    ! Correct transport
          DO jk=1,jpkm1
             DO ji=1,jpi
-               zvb(ji,jbdy1:jbdy2) = zvb(ji,jbdy1:jbdy2) & 
-                  & + e3v_a(ji,jbdy1:jbdy2,jk) * va(ji,jbdy1:jbdy2,jk) * vmask(ji,jbdy1:jbdy2,jk)
+               zvb(ji,jj) = zvb(ji,jj) & 
+                  & + e3v_a(ji,jj,jk) * va(ji,jj,jk) * vmask(ji,jj,jk)
             END DO
          END DO
          DO ji = 1, jpi
-            zvb(ji,jbdy1:jbdy2) = zvb(ji,jbdy1:jbdy2) * r1_hv_a(ji,jbdy1:jbdy2)
+            zvb(ji,jj) = zvb(ji,jj) * r1_hv_a(ji,jj)
          END DO
 
          DO jk = 1, jpkm1
             DO ji = 1, jpi
-               va(ji,jbdy1:jbdy2,jk) = ( va(ji,jbdy1:jbdy2,jk) & 
-                 & + va_b(ji,jbdy1:jbdy2) - zvb(ji,jbdy1:jbdy2) ) * vmask(ji,jbdy1:jbdy2,jk)
-            END DO
-         END DO
+               va(ji,jj,jk) = ( va(ji,jj,jk) & 
+                 & + va_b(ji,jj) - zvb(ji,jj) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
             
-         IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
-            zub(:,jbdy1:jbdy2) = 0._wp
+      IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+         DO jj = mj0(jbdy1), mj1(jbdy2)
+            zub(:,jj) = 0._wp
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  zub(ji,jbdy1:jbdy2) = zub(ji,jbdy1:jbdy2) & 
-                     & + e3u_a(ji,jbdy1:jbdy2,jk) * ua(ji,jbdy1:jbdy2,jk) * umask(ji,jbdy1:jbdy2,jk)
+                  zub(ji,jj) = zub(ji,jj) & 
+                     & + e3u_a(ji,jj,jk) * ua(ji,jj,jk) * umask(ji,jj,jk)
                END DO
             END DO
             DO ji = 1, jpi
-               zub(ji,jbdy1:jbdy2) = zub(ji,jbdy1:jbdy2) * r1_hu_a(ji,jbdy1:jbdy2)
+               zub(ji,jj) = zub(ji,jj) * r1_hu_a(ji,jj)
             END DO
                
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  ua(ji,jbdy1:jbdy2,jk) = ( ua(ji,jbdy1:jbdy2,jk) & 
-                    & + ua_b(ji,jbdy1:jbdy2) - zub(ji,jbdy1:jbdy2) ) * umask(ji,jbdy1:jbdy2,jk)
-               END DO
-            END DO
-         ENDIF
-         !
-         DO jk = 1, jpkm1              ! Mask domain edges
-            DO ji = 1, jpi
-               ua(ji,1,jk) = 0._wp
-               va(ji,1,jk) = 0._wp
-            END DO
-         END DO 
+                  ua(ji,jj,jk) = ( ua(ji,jj,jk) & 
+                    & + ua_b(ji,jj) - zub(ji,jj) ) * umask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
       ENDIF
 
       ! --- North --- !
-      IF( nbondj ==  1 .OR. nbondj == 2 ) THEN
-         jbdy1 = nlcj-1-nbghostcells
-         jbdy2 = nlcj-2 
-         !
-         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-            va_b(:,jbdy1:jbdy2) = 0._wp
+      jbdy1 = jpjglo-1-nbghostcells
+      jbdy2 = jpjglo-2 
+      !
+      IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+         DO jj = mj0(jbdy1), mj1(jbdy2)
+            va_b(:,jj) = 0._wp
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  va_b(ji,jbdy1:jbdy2) = va_b(ji,jbdy1:jbdy2) & 
-                      & + e3v_a(ji,jbdy1:jbdy2,jk) * va(ji,jbdy1:jbdy2,jk) * vmask(ji,jbdy1:jbdy2,jk)
+                  va_b(ji,jj) = va_b(ji,jj) & 
+                      & + e3v_a(ji,jj,jk) * va(ji,jj,jk) * vmask(ji,jj,jk)
                END DO
             END DO
             DO ji=1,jpi
-               va_b(ji,jbdy1:jbdy2) = va_b(ji,jbdy1:jbdy2) * r1_hv_a(ji,jbdy1:jbdy2)
-            END DO
-         ENDIF
-         !
-         IF ( .NOT.lk_agrif_clp ) THEN
-            DO jk = 1, jpkm1           ! Smooth
-               DO ji = i1, i2
-                  va(ji,jbdy1,jk) = 0.25_wp*(va(ji,jbdy1-1,jk)+2._wp*va(ji,jbdy1,jk)+va(ji,jbdy1+1,jk))
-               END DO
-            END DO
-         ENDIF
-         !
-         zvb(:,jbdy1:jbdy2) = 0._wp    ! Correct transport
+               va_b(ji,jj) = va_b(ji,jj) * r1_hv_a(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !
+      DO jj = mj0(jbdy1), mj1(jbdy2)
+         zvb(:,jj) = 0._wp    ! Correct transport
          DO jk=1,jpkm1
             DO ji=1,jpi
-               zvb(ji,jbdy1:jbdy2) = zvb(ji,jbdy1:jbdy2) & 
-                  & + e3v_a(ji,jbdy1:jbdy2,jk) * va(ji,jbdy1:jbdy2,jk) * vmask(ji,jbdy1:jbdy2,jk)
+               zvb(ji,jj) = zvb(ji,jj) & 
+                  & + e3v_a(ji,jj,jk) * va(ji,jj,jk) * vmask(ji,jj,jk)
             END DO
          END DO
          DO ji = 1, jpi
-            zvb(ji,jbdy1:jbdy2) = zvb(ji,jbdy1:jbdy2) * r1_hv_a(ji,jbdy1:jbdy2)
+            zvb(ji,jj) = zvb(ji,jj) * r1_hv_a(ji,jj)
          END DO
 
          DO jk = 1, jpkm1
             DO ji = 1, jpi
-               va(ji,jbdy1:jbdy2,jk) = ( va(ji,jbdy1:jbdy2,jk) & 
-                 & + va_b(ji,jbdy1:jbdy2) - zvb(ji,jbdy1:jbdy2) ) * vmask(ji,jbdy1:jbdy2,jk)
-            END DO
-         END DO
+               va(ji,jj,jk) = ( va(ji,jj,jk) & 
+                 & + va_b(ji,jj) - zvb(ji,jj) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
             
-         IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
-            jbdy1 = jbdy1 + 1
-            jbdy2 = jbdy2 + 1 
-            zub(:,jbdy1:jbdy2) = 0._wp
+      IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+         jbdy1 = jpjglo-nbghostcells
+         jbdy2 = jpjglo-1
+         DO jj = mj0(jbdy1), mj1(jbdy2)
+            zub(:,jj) = 0._wp
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  zub(ji,jbdy1:jbdy2) = zub(ji,jbdy1:jbdy2) & 
-                     & + e3u_a(ji,jbdy1:jbdy2,jk) * ua(ji,jbdy1:jbdy2,jk) * umask(ji,jbdy1:jbdy2,jk)
+                  zub(ji,jj) = zub(ji,jj) & 
+                     & + e3u_a(ji,jj,jk) * ua(ji,jj,jk) * umask(ji,jj,jk)
                END DO
             END DO
             DO ji = 1, jpi
-               zub(ji,jbdy1:jbdy2) = zub(ji,jbdy1:jbdy2) * r1_hu_a(ji,jbdy1:jbdy2)
+               zub(ji,jj) = zub(ji,jj) * r1_hu_a(ji,jj)
             END DO
                
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  ua(ji,jbdy1:jbdy2,jk) = ( ua(ji,jbdy1:jbdy2,jk) & 
-                    & + ua_b(ji,jbdy1:jbdy2) - zub(ji,jbdy1:jbdy2) ) * umask(ji,jbdy1:jbdy2,jk)
-               END DO
-            END DO
-         ENDIF
-         !
-         DO jk = 1, jpkm1              ! Mask domain edges
-            DO ji = 1, jpi
-               ua(ji,nlcj  ,jk) = 0._wp
-               va(ji,nlcj-1,jk) = 0._wp
-            END DO
-         END DO 
+                  ua(ji,jj,jk) = ( ua(ji,jj,jk) & 
+                    & + ua_b(ji,jj) - zub(ji,jj) ) * umask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
       ENDIF
       !
@@ -401,54 +344,129 @@
       !!
       INTEGER :: ji, jj
+      INTEGER :: istart, iend, jstart, jend
       !!----------------------------------------------------------------------  
       !
       IF( Agrif_Root() )   RETURN
       !
-      IF((nbondi == -1).OR.(nbondi == 2)) THEN
+      !--- West ---!
+      istart = 2
+      iend   = nbghostcells+1
+      DO ji = mi0(istart), mi1(iend)
          DO jj=1,jpj
-            va_e(2:nbghostcells+1,jj) = vbdy_w(1:nbghostcells,jj) * hvr_e(2:nbghostcells+1,jj)
-            ! Specified fluxes:
-            ua_e(2:nbghostcells+1,jj) = ubdy_w(1:nbghostcells,jj) * hur_e(2:nbghostcells+1,jj)
-            ! Characteristics method (only if ghostcells=1):
-            !alt            ua_e(2,jj) = 0.5_wp * ( ubdy_w(jj) * hur_e(2,jj) + ua_e(3,jj) &
-            !alt                       &           - sqrt(grav * hur_e(2,jj)) * (sshn_e(3,jj) - hbdy_w(jj)) )
-         END DO
-      ENDIF
-      !
-      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+         END DO
+      END DO
+      !
+      !--- East ---!
+      istart = jpiglo-nbghostcells
+      iend   = jpiglo-1
+      DO ji = mi0(istart), mi1(iend)
          DO jj=1,jpj
-            va_e(nlci-nbghostcells:nlci-1,jj)   = vbdy_e(1:nbghostcells,jj) * hvr_e(nlci-nbghostcells:nlci-1,jj)
-            ! Specified fluxes:
-            ua_e(nlci-nbghostcells-1:nlci-2,jj) = ubdy_e(1:nbghostcells,jj) * hur_e(nlci-nbghostcells-1:nlci-2,jj)
-            ! Characteristics method (only if ghostcells=1):
-            !alt            ua_e(nlci-2,jj) = 0.5_wp * ( ubdy_e(jj) * hur_e(nlci-2,jj) + ua_e(nlci-3,jj) &
-            !alt                            &           + sqrt(grav * hur_e(nlci-2,jj)) * (sshn_e(nlci-2,jj) - hbdy_e(jj)) )
-         END DO
-      ENDIF
-      !
-      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+         END DO
+      END DO
+      istart = jpiglo-nbghostcells-1
+      iend   = jpiglo-2
+      DO ji = mi0(istart), mi1(iend)
+         DO jj=1,jpj
+            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+         END DO
+      END DO
+      !
+      !--- South ---!
+      jstart = 2
+      jend   = nbghostcells+1
+      DO jj = mj0(jstart), mj1(jend)
          DO ji=1,jpi
-            ua_e(ji,2:nbghostcells+1) = ubdy_s(ji,1:nbghostcells) * hur_e(ji,2:nbghostcells+1)
-            ! Specified fluxes:
-            va_e(ji,2:nbghostcells+1) = vbdy_s(ji,1:nbghostcells) * hvr_e(ji,2:nbghostcells+1)
-            ! Characteristics method (only if ghostcells=1):
-            !alt            va_e(ji,2) = 0.5_wp * ( vbdy_s(ji) * hvr_e(ji,2) + va_e(ji,3) &
-            !alt                       &           - sqrt(grav * hvr_e(ji,2)) * (sshn_e(ji,3) - hbdy_s(ji)) )
-         END DO
-      ENDIF
-      !
-      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+         END DO
+      END DO
+      !
+      !--- North ---!
+      jstart = jpjglo-nbghostcells
+      jend   = jpjglo-1
+      DO jj = mj0(jstart), mj1(jend)
          DO ji=1,jpi
-            ua_e(ji,nlcj-nbghostcells:nlcj-1)   = ubdy_n(ji,1:nbghostcells) * hur_e(ji,nlcj-nbghostcells:nlcj-1)
-            ! Specified fluxes:
-            va_e(ji,nlcj-nbghostcells-1:nlcj-2) = vbdy_n(ji,1:nbghostcells) * hvr_e(ji,nlcj-nbghostcells-1:nlcj-2)
-            ! Characteristics method (only if ghostcells=1):
-            !alt            va_e(ji,nlcj-2) = 0.5_wp * ( vbdy_n(ji) * hvr_e(ji,nlcj-2)  + va_e(ji,nlcj-3) &
-            !alt                            &           + sqrt(grav * hvr_e(ji,nlcj-2)) * (sshn_e(ji,nlcj-2) - hbdy_n(ji)) )
-         END DO
-      ENDIF
+            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+         END DO
+      END DO
+      jstart = jpjglo-nbghostcells-1
+      jend   = jpjglo-2
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji=1,jpi
+            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+         END DO
+      END DO
       !
    END SUBROUTINE Agrif_dyn_ts
 
+   SUBROUTINE Agrif_dyn_ts_flux( jn, zu, zv )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE Agrif_dyn_ts_flux  ***
+      !!----------------------------------------------------------------------  
+      INTEGER, INTENT(in) ::   jn
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   zu, zv
+      !!
+      INTEGER :: ji, jj
+      INTEGER :: istart, iend, jstart, jend
+      !!----------------------------------------------------------------------  
+      !
+      IF( Agrif_Root() )   RETURN
+      !
+      !--- West ---!
+      istart = 2
+      iend   = nbghostcells+1
+      DO ji = mi0(istart), mi1(iend)
+         DO jj=1,jpj
+            zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
+            zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
+         END DO
+      END DO
+      !
+      !--- East ---!
+      istart = jpiglo-nbghostcells
+      iend   = jpiglo-1
+      DO ji = mi0(istart), mi1(iend)
+         DO jj=1,jpj
+            zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
+         END DO
+      END DO
+      istart = jpiglo-nbghostcells-1
+      iend   = jpiglo-2
+      DO ji = mi0(istart), mi1(iend)
+         DO jj=1,jpj
+            zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
+         END DO
+      END DO
+      !
+      !--- South ---!
+      jstart = 2
+      jend   = nbghostcells+1
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji=1,jpi
+            zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
+            zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
+         END DO
+      END DO
+      !
+      !--- North ---!
+      jstart = jpjglo-nbghostcells
+      jend   = jpjglo-1
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji=1,jpi
+            zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
+         END DO
+      END DO
+      jstart = jpjglo-nbghostcells-1
+      jend   = jpjglo-2
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji=1,jpi
+            zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
+         END DO
+      END DO
+      !
+   END SUBROUTINE Agrif_dyn_ts_flux
 
    SUBROUTINE Agrif_dta_ts( kt )
@@ -470,23 +488,24 @@
       !
       ! Interpolate barotropic fluxes
-      Agrif_SpecialValue=0._wp
+      Agrif_SpecialValue = 0._wp
       Agrif_UseSpecialValue = ln_spc_dyn
+      !
+      ! Set bdy time interpolation stage to 0 (latter incremented locally do deal with corners)
+      utint_stage(:,:) = 0
+      vtint_stage(:,:) = 0
       !
       IF( ll_int_cons ) THEN  ! Conservative interpolation
          ! order matters here !!!!!!
          CALL Agrif_Bc_variable( ub2b_interp_id, calledweight=1._wp, procname=interpub2b ) ! Time integrated
-         CALL Agrif_Bc_variable( vb2b_interp_id, calledweight=1._wp, procname=interpvb2b )
-         bdy_tinterp = 1
+         CALL Agrif_Bc_variable( vb2b_interp_id, calledweight=1._wp, procname=interpvb2b ) 
+         !
          CALL Agrif_Bc_variable( unb_id        , calledweight=1._wp, procname=interpunb  ) ! After
          CALL Agrif_Bc_variable( vnb_id        , calledweight=1._wp, procname=interpvnb  )
-         bdy_tinterp = 2
+         !
          CALL Agrif_Bc_variable( unb_id        , calledweight=0._wp, procname=interpunb  ) ! Before
          CALL Agrif_Bc_variable( vnb_id        , calledweight=0._wp, procname=interpvnb  )         
       ELSE ! Linear interpolation
-         bdy_tinterp = 0
-         ubdy_w(:,:) = 0._wp   ;   vbdy_w(:,:) = 0._wp 
-         ubdy_e(:,:) = 0._wp   ;   vbdy_e(:,:) = 0._wp 
-         ubdy_n(:,:) = 0._wp   ;   vbdy_n(:,:) = 0._wp 
-         ubdy_s(:,:) = 0._wp   ;   vbdy_s(:,:) = 0._wp
+         !
+         ubdy(:,:) = 0._wp   ;   vbdy(:,:) = 0._wp 
          CALL Agrif_Bc_variable( unb_id, procname=interpunb )
          CALL Agrif_Bc_variable( vnb_id, procname=interpvnb )
@@ -503,5 +522,6 @@
       INTEGER, INTENT(in) ::   kt
       !
-      INTEGER  :: ji, jj, indx, indy
+      INTEGER  :: ji, jj
+      INTEGER  :: istart, iend, jstart, jend
       !!----------------------------------------------------------------------  
       !
@@ -516,42 +536,38 @@
       !
       ! --- West --- !
-      IF((nbondi == -1).OR.(nbondi == 2)) THEN
-         indx = 1+nbghostcells
+      istart = 2
+      iend   = 1 + nbghostcells
+      DO ji = mi0(istart), mi1(iend)
          DO jj = 1, jpj
-            DO ji = 2, indx
-               ssha(ji,jj) = hbdy_w(ji-1,jj)
-            ENDDO
+            ssha(ji,jj) = hbdy(ji,jj)
          ENDDO
-      ENDIF
+      ENDDO
       !
       ! --- East --- !
-      IF((nbondi == 1).OR.(nbondi == 2)) THEN
-         indx = nlci-nbghostcells
+      istart = jpiglo - nbghostcells
+      iend   = jpiglo - 1
+      DO ji = mi0(istart), mi1(iend)
          DO jj = 1, jpj
-            DO ji = indx, nlci-1
-               ssha(ji,jj) = hbdy_e(ji-indx+1,jj)
-            ENDDO
+            ssha(ji,jj) = hbdy(ji,jj)
          ENDDO
-      ENDIF
+      ENDDO
       !
       ! --- South --- !
-      IF((nbondj == -1).OR.(nbondj == 2)) THEN
-         indy = 1+nbghostcells
-         DO jj = 2, indy
-            DO ji = 1, jpi
-               ssha(ji,jj) = hbdy_s(ji,jj-1)
-            ENDDO
+      jstart = 2
+      jend   = 1 + nbghostcells
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji = 1, jpi
+            ssha(ji,jj) = hbdy(ji,jj)
          ENDDO
-      ENDIF
+      ENDDO
       !
       ! --- North --- !
-      IF((nbondj == 1).OR.(nbondj == 2)) THEN
-         indy = nlcj-nbghostcells
-         DO jj = indy, nlcj-1
-            DO ji = 1, jpi
-               ssha(ji,jj) = hbdy_n(ji,jj-indy+1)
-            ENDDO
+      jstart = jpjglo - nbghostcells
+      jend   = jpjglo - 1
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji = 1, jpi
+            ssha(ji,jj) = hbdy(ji,jj)
          ENDDO
-      ENDIF
+      ENDDO
       !
    END SUBROUTINE Agrif_ssh
@@ -564,49 +580,45 @@
       INTEGER, INTENT(in) ::   jn
       !!
-      INTEGER :: ji, jj, indx, indy
-      !!----------------------------------------------------------------------  
-      !! clem ghost (starting at i,j=1 is important I think otherwise you introduce a grad(ssh)/=0 at point 2)
+      INTEGER :: ji, jj
+      INTEGER  :: istart, iend, jstart, jend
+      !!----------------------------------------------------------------------  
       !
       IF( Agrif_Root() )   RETURN
       !
       ! --- West --- !
-      IF((nbondi == -1).OR.(nbondi == 2)) THEN
-         indx = 1+nbghostcells
+      istart = 2
+      iend   = 1+nbghostcells
+      DO ji = mi0(istart), mi1(iend)
          DO jj = 1, jpj
-            DO ji = 2, indx
-               ssha_e(ji,jj) = hbdy_w(ji-1,jj)
-            ENDDO
+            ssha_e(ji,jj) = hbdy(ji,jj)
          ENDDO
-      ENDIF
+      ENDDO
       !
       ! --- East --- !
-      IF((nbondi == 1).OR.(nbondi == 2)) THEN
-         indx = nlci-nbghostcells
+      istart = jpiglo - nbghostcells
+      iend   = jpiglo - 1
+      DO ji = mi0(istart), mi1(iend)
          DO jj = 1, jpj
-            DO ji = indx, nlci-1
-               ssha_e(ji,jj) = hbdy_e(ji-indx+1,jj)
-            ENDDO
+            ssha_e(ji,jj) = hbdy(ji,jj)
          ENDDO
-      ENDIF
+      ENDDO
       !
       ! --- South --- !
-      IF((nbondj == -1).OR.(nbondj == 2)) THEN
-         indy = 1+nbghostcells
-         DO jj = 2, indy
-            DO ji = 1, jpi
-               ssha_e(ji,jj) = hbdy_s(ji,jj-1)
-            ENDDO
+      jstart = 2
+      jend   = 1+nbghostcells
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji = 1, jpi
+            ssha_e(ji,jj) = hbdy(ji,jj)
          ENDDO
-      ENDIF
+      ENDDO
       !
       ! --- North --- !
-      IF((nbondj == 1).OR.(nbondj == 2)) THEN
-         indy = nlcj-nbghostcells
-         DO jj = indy, nlcj-1
-            DO ji = 1, jpi
-               ssha_e(ji,jj) = hbdy_n(ji,jj-indy+1)
-            ENDDO
+      jstart = jpjglo - nbghostcells
+      jend   = jpjglo - 1
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji = 1, jpi
+            ssha_e(ji,jj) = hbdy(ji,jj)
          ENDDO
-      ENDIF
+      ENDDO
       !
    END SUBROUTINE Agrif_ssh_ts
@@ -634,5 +646,5 @@
    
 
-   SUBROUTINE interptsn( ptab, i1, i2, j1, j2, k1, k2, n1, n2, before, nb, ndir )
+   SUBROUTINE interptsn( ptab, i1, i2, j1, j2, k1, k2, n1, n2, before )
       !!----------------------------------------------------------------------
       !!                  *** ROUTINE interptsn ***
@@ -641,10 +653,7 @@
       INTEGER                                     , INTENT(in   ) ::   i1, i2, j1, j2, k1, k2, n1, n2
       LOGICAL                                     , INTENT(in   ) ::   before
-      INTEGER                                     , INTENT(in   ) ::   nb , ndir
-      !
-      INTEGER  ::   ji, jj, jk, jn, iref, jref, ibdy, jbdy   ! dummy loop indices
-      INTEGER  ::   imin, imax, jmin, jmax, N_in, N_out
-      REAL(wp) ::   zrho, z1, z2, z3, z4, z5, z6, z7
-      LOGICAL :: western_side, eastern_side,northern_side,southern_side
+      !
+      INTEGER  ::   ji, jj, jk, jn  ! dummy loop indices
+      INTEGER  ::   N_in, N_out
       ! vertical interpolation:
       REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,n1:n2) :: ptab_child
@@ -652,5 +661,4 @@
       REAL(wp), DIMENSION(k1:k2) :: h_in
       REAL(wp), DIMENSION(1:jpk) :: h_out
-      REAL(wp) :: h_diff
 
       IF( before ) THEN         
@@ -676,16 +684,7 @@
       ELSE 
 
-         western_side  = (nb == 1).AND.(ndir == 1)   ;   eastern_side  = (nb == 1).AND.(ndir == 2)
-         southern_side = (nb == 2).AND.(ndir == 1)   ;   northern_side = (nb == 2).AND.(ndir == 2)
-
 # if defined key_vertical              
          DO jj=j1,j2
             DO ji=i1,i2
-               iref = ji
-               jref = jj
-               if(western_side) iref=MAX(2,ji)
-               if(eastern_side) iref=MIN(nlci-1,ji)
-               if(southern_side) jref=MAX(2,jj)
-               if(northern_side) jref=MIN(nlcj-1,jj)
                N_in = 0
                DO jk=k1,k2 !k2 = jpk of parent grid
@@ -697,7 +696,7 @@
                N_out = 0
                DO jk=1,jpk ! jpk of child grid
-                  IF (tmask(iref,jref,jk) == 0) EXIT 
+                  IF (tmask(ji,jj,jk) == 0) EXIT 
                   N_out = N_out + 1
-                  h_out(jk) = e3t_n(iref,jref,jk)
+                  h_out(jk) = e3t_n(ji,jj,jk)
                ENDDO
                IF (N_in > 0) THEN
@@ -716,137 +715,9 @@
          END DO
 
-         IF ( .NOT.lk_agrif_clp ) THEN 
-            !
-            imin = i1 ; imax = i2
-            jmin = j1 ; jmax = j2
-            ! 
-            ! Remove CORNERS
-            IF((nbondj == -1).OR.(nbondj == 2)) jmin = 2 + nbghostcells
-            IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj - nbghostcells - 1
-            IF((nbondi == -1).OR.(nbondi == 2)) imin = 2 + nbghostcells
-            IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci - nbghostcells - 1      
-            !
-            IF( eastern_side ) THEN
-               zrho = Agrif_Rhox()
-               z1 = ( zrho - 1._wp ) * 0.5_wp                    
-               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
-               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
-               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
-               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
-               !
-               ibdy = nlci-nbghostcells
-               DO jn = 1, jpts
-                  tsa(ibdy+1,jmin:jmax,1:jpkm1,jn) = z1 * ptab_child(ibdy+1,jmin:jmax,1:jpkm1,jn) + z2 * ptab_child(ibdy,jmin:jmax,1:jpkm1,jn)
-                  DO jk = 1, jpkm1
-                     DO jj = jmin,jmax
-                        IF( umask(ibdy-1,jj,jk) == 0._wp ) THEN
-                           tsa(ibdy,jj,jk,jn) = tsa(ibdy+1,jj,jk,jn) * tmask(ibdy,jj,jk)
-                        ELSE
-                           tsa(ibdy,jj,jk,jn)=(z4*tsa(ibdy+1,jj,jk,jn)+z3*tsa(ibdy-1,jj,jk,jn))*tmask(ibdy,jj,jk)
-                           IF( un(ibdy-1,jj,jk) > 0._wp ) THEN
-                              tsa(ibdy,jj,jk,jn)=( z6*tsa(ibdy-1,jj,jk,jn)+z5*tsa(ibdy+1,jj,jk,jn) & 
-                                                 + z7*tsa(ibdy-2,jj,jk,jn) ) * tmask(ibdy,jj,jk)
-                           ENDIF
-                        ENDIF
-                     END DO
-                  END DO
-                  ! Restore ghost points:
-                  tsa(ibdy+1,jmin:jmax,1:jpkm1,jn) = ptab_child(ibdy+1,jmin:jmax,1:jpkm1,jn) * tmask(ibdy+1,jmin:jmax,1:jpkm1)
-               END DO
-            ENDIF
-            ! 
-            IF( northern_side ) THEN
-               zrho = Agrif_Rhoy()
-               z1 = ( zrho - 1._wp ) * 0.5_wp                    
-               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
-               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
-               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
-               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
-               !
-               jbdy = nlcj-nbghostcells         
-               DO jn = 1, jpts
-                  tsa(imin:imax,jbdy+1,1:jpkm1,jn) = z1 * ptab_child(imin:imax,jbdy+1,1:jpkm1,jn) + z2 * ptab_child(imin:imax,jbdy,1:jpkm1,jn)
-                  DO jk = 1, jpkm1
-                     DO ji = imin,imax
-                        IF( vmask(ji,jbdy-1,jk) == 0._wp ) THEN
-                           tsa(ji,jbdy,jk,jn) = tsa(ji,jbdy+1,jk,jn) * tmask(ji,jbdy,jk)
-                        ELSE
-                           tsa(ji,jbdy,jk,jn)=(z4*tsa(ji,jbdy+1,jk,jn)+z3*tsa(ji,jbdy-1,jk,jn))*tmask(ji,jbdy,jk)        
-                           IF (vn(ji,jbdy-1,jk) > 0._wp ) THEN
-                              tsa(ji,jbdy,jk,jn)=( z6*tsa(ji,jbdy-1,jk,jn)+z5*tsa(ji,jbdy+1,jk,jn)  &
-                                                 + z7*tsa(ji,jbdy-2,jk,jn) ) * tmask(ji,jbdy,jk)
-                           ENDIF
-                        ENDIF
-                     END DO
-                  END DO
-                  ! Restore ghost points:
-                  tsa(imin:imax,jbdy+1,1:jpkm1,jn) = ptab_child(imin:imax,jbdy+1,1:jpkm1,jn) * tmask(imin:imax,jbdy+1,1:jpkm1)
-               END DO
-            ENDIF
-            !
-            IF( western_side ) THEN
-               zrho = Agrif_Rhox()
-               z1 = ( zrho - 1._wp ) * 0.5_wp                    
-               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
-               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
-               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
-               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
-               !    
-               ibdy = 1+nbghostcells       
-               DO jn = 1, jpts
-                  tsa(ibdy-1,jmin:jmax,1:jpkm1,jn) = z1 * ptab_child(ibdy-1,jmin:jmax,1:jpkm1,jn) + z2 * ptab_child(ibdy,jmin:jmax,1:jpkm1,jn)
-                  DO jk = 1, jpkm1
-                     DO jj = jmin,jmax
-                        IF( umask(ibdy,jj,jk) == 0._wp ) THEN
-                           tsa(ibdy,jj,jk,jn) = tsa(ibdy-1,jj,jk,jn) * tmask(ibdy,jj,jk)
-                        ELSE
-                           tsa(ibdy,jj,jk,jn)=(z4*tsa(ibdy-1,jj,jk,jn)+z3*tsa(ibdy+1,jj,jk,jn))*tmask(ibdy,jj,jk)        
-                           IF( un(ibdy,jj,jk) < 0._wp ) THEN
-                              tsa(ibdy,jj,jk,jn)=( z6*tsa(ibdy+1,jj,jk,jn)+z5*tsa(ibdy-1,jj,jk,jn) &
-                                                 + z7*tsa(ibdy+2,jj,jk,jn) ) * tmask(ibdy,jj,jk)
-                           ENDIF
-                        ENDIF
-                     END DO
-                  END DO
-                  ! Restore ghost points:
-                  tsa(ibdy-1,jmin:jmax,1:jpkm1,jn) = ptab_child(ibdy-1,jmin:jmax,1:jpkm1,jn) * tmask(ibdy-1,jmin:jmax,1:jpkm1)
-               END DO
-            ENDIF
-            !
-            IF( southern_side ) THEN
-               zrho = Agrif_Rhoy()
-               z1 = ( zrho - 1._wp ) * 0.5_wp                    
-               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
-               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
-               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
-               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
-               !  
-               jbdy=1+nbghostcells        
-               DO jn = 1, jpts
-                  tsa(imin:imax,jbdy-1,1:jpkm1,jn) = z1 * ptab_child(imin:imax,jbdy-1,1:jpkm1,jn) + z2 * ptab_child(imin:imax,jbdy,1:jpkm1,jn)
-                  DO jk = 1, jpkm1      
-                     DO ji = imin,imax
-                        IF( vmask(ji,jbdy,jk) == 0._wp ) THEN
-                           tsa(ji,jbdy,jk,jn)=tsa(ji,jbdy-1,jk,jn) * tmask(ji,jbdy,jk)
-                        ELSE
-                           tsa(ji,jbdy,jk,jn)=(z4*tsa(ji,jbdy-1,jk,jn)+z3*tsa(ji,jbdy+1,jk,jn))*tmask(ji,jbdy,jk)
-                           IF( vn(ji,jbdy,jk) < 0._wp ) THEN
-                              tsa(ji,jbdy,jk,jn)=( z6*tsa(ji,jbdy+1,jk,jn)+z5*tsa(ji,jbdy-1,jk,jn) & 
-                                                 + z7*tsa(ji,jbdy+2,jk,jn) ) * tmask(ji,jbdy,jk)
-                           ENDIF
-                        ENDIF
-                     END DO
-                  END DO
-                  ! Restore ghost points:
-                  tsa(imin:imax,jbdy-1,1:jpkm1,jn) = ptab_child(imin:imax,jbdy-1,1:jpkm1,jn) * tmask(imin:imax,jbdy-1,1:jpkm1)
-               END DO
-            ENDIF
-            !
-         ENDIF
       ENDIF
       !
    END SUBROUTINE interptsn
 
-   SUBROUTINE interpsshn( ptab, i1, i2, j1, j2, before, nb, ndir )
+   SUBROUTINE interpsshn( ptab, i1, i2, j1, j2, before )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE interpsshn  ***
@@ -855,7 +726,5 @@
       REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) ::   ptab
       LOGICAL                         , INTENT(in   ) ::   before
-      INTEGER                         , INTENT(in   ) ::   nb , ndir
-      !
-      LOGICAL :: western_side, eastern_side,northern_side,southern_side
+      !
       !!----------------------------------------------------------------------  
       !
@@ -863,13 +732,5 @@
          ptab(i1:i2,j1:j2) = sshn(i1:i2,j1:j2)
       ELSE
-         western_side  = (nb == 1).AND.(ndir == 1)
-         eastern_side  = (nb == 1).AND.(ndir == 2)
-         southern_side = (nb == 2).AND.(ndir == 1)
-         northern_side = (nb == 2).AND.(ndir == 2)
-         !! clem ghost
-         IF(western_side)  hbdy_w(1:nbghostcells,j1:j2) = ptab(i1:i2,j1:j2) * tmask(i1:i2,j1:j2,1)
-         IF(eastern_side)  hbdy_e(1:nbghostcells,j1:j2) = ptab(i1:i2,j1:j2) * tmask(i1:i2,j1:j2,1)
-         IF(southern_side) hbdy_s(i1:i2,1:nbghostcells) = ptab(i1:i2,j1:j2) * tmask(i1:i2,j1:j2,1) 
-         IF(northern_side) hbdy_n(i1:i2,1:nbghostcells) = ptab(i1:i2,j1:j2) * tmask(i1:i2,j1:j2,1)
+         hbdy(i1:i2,j1:j2) = ptab(i1:i2,j1:j2) * tmask(i1:i2,j1:j2,1)
       ENDIF
       !
@@ -1045,5 +906,5 @@
    END SUBROUTINE interpvn
 
-   SUBROUTINE interpunb( ptab, i1, i2, j1, j2, before, nb, ndir )
+   SUBROUTINE interpunb( ptab, i1, i2, j1, j2, before)
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE interpunb  ***
@@ -1052,9 +913,7 @@
       REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) ::   ptab
       LOGICAL                         , INTENT(in   ) ::   before
-      INTEGER                         , INTENT(in   ) ::   nb , ndir
       !
       INTEGER  ::   ji, jj
       REAL(wp) ::   zrhoy, zrhot, zt0, zt1, ztcoeff
-      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
       !!----------------------------------------------------------------------  
       !
@@ -1062,8 +921,4 @@
          ptab(i1:i2,j1:j2) = e2u(i1:i2,j1:j2) * hu_n(i1:i2,j1:j2) * un_b(i1:i2,j1:j2)
       ELSE
-         western_side  = (nb == 1).AND.(ndir == 1)
-         eastern_side  = (nb == 1).AND.(ndir == 2)
-         southern_side = (nb == 2).AND.(ndir == 1)
-         northern_side = (nb == 2).AND.(ndir == 2)
          zrhoy = Agrif_Rhoy()
          zrhot = Agrif_rhot()
@@ -1071,32 +926,35 @@
          zt0 = REAL(Agrif_NbStepint()  , wp) / zrhot
          zt1 = REAL(Agrif_NbStepint()+1, wp) / zrhot      
-         ! Polynomial interpolation coefficients:
-         IF( bdy_tinterp == 1 ) THEN
-            ztcoeff = zrhot * (  zt1**2._wp * (       zt1 - 1._wp)        &
-               &               - zt0**2._wp * (       zt0 - 1._wp)        )
-         ELSEIF( bdy_tinterp == 2 ) THEN
-            ztcoeff = zrhot * (  zt1        * (       zt1 - 1._wp)**2._wp &
-               &               - zt0        * (       zt0 - 1._wp)**2._wp )
-         ELSE
-            ztcoeff = 1
-         ENDIF
-         !   
-         IF(western_side)   ubdy_w(1:nbghostcells,j1:j2) = ubdy_w(1:nbghostcells,j1:j2) + ztcoeff * ptab(i1:i2,j1:j2)  
-         IF(eastern_side)   ubdy_e(1:nbghostcells,j1:j2) = ubdy_e(1:nbghostcells,j1:j2) + ztcoeff * ptab(i1:i2,j1:j2)  
-         IF(southern_side)  ubdy_s(i1:i2,1:nbghostcells) = ubdy_s(i1:i2,1:nbghostcells) + ztcoeff * ptab(i1:i2,j1:j2)
-         IF(northern_side)  ubdy_n(i1:i2,1:nbghostcells) = ubdy_n(i1:i2,1:nbghostcells) + ztcoeff * ptab(i1:i2,j1:j2) 
-         !            
-         IF( bdy_tinterp == 0 .OR. bdy_tinterp == 2) THEN
-            IF(western_side)   ubdy_w(1:nbghostcells,j1:j2) = ubdy_w(1:nbghostcells,j1:j2) / (zrhoy*e2u(i1:i2,j1:j2)) * umask(i1:i2,j1:j2,1)
-            IF(eastern_side)   ubdy_e(1:nbghostcells,j1:j2) = ubdy_e(1:nbghostcells,j1:j2) / (zrhoy*e2u(i1:i2,j1:j2)) * umask(i1:i2,j1:j2,1)
-            IF(southern_side)  ubdy_s(i1:i2,1:nbghostcells) = ubdy_s(i1:i2,1:nbghostcells) / (zrhoy*e2u(i1:i2,j1:j2)) * umask(i1:i2,j1:j2,1)
-            IF(northern_side)  ubdy_n(i1:i2,1:nbghostcells) = ubdy_n(i1:i2,1:nbghostcells) / (zrhoy*e2u(i1:i2,j1:j2)) * umask(i1:i2,j1:j2,1)
-         ENDIF
-      ENDIF
+         ! 
+         DO ji = i1, i2
+            DO jj = j1, j2
+               IF    ( utint_stage(ji,jj) == 1  ) THEN
+                  ztcoeff = zrhot * (  zt1**2._wp * (       zt1 - 1._wp)        &
+                     &               - zt0**2._wp * (       zt0 - 1._wp)        )
+               ELSEIF( utint_stage(ji,jj) == 2  ) THEN
+                  ztcoeff = zrhot * (  zt1        * (       zt1 - 1._wp)**2._wp &
+                     &               - zt0        * (       zt0 - 1._wp)**2._wp )
+               ELSEIF( utint_stage(ji,jj) == 0  ) THEN                
+                  ztcoeff = 1._wp
+               ELSE
+                  ztcoeff = 0._wp
+               ENDIF
+               !   
+               ubdy(ji,jj) = ubdy(ji,jj) + ztcoeff * ptab(ji,jj)
+               !            
+               IF (( utint_stage(ji,jj) == 2 ).OR.( utint_stage(ji,jj) == 0 )) THEN
+                  ubdy(ji,jj) = ubdy(ji,jj) / (zrhoy*e2u(ji,jj)) * umask(ji,jj,1)
+                  utint_stage(ji,jj) = 3
+               ELSE
+                  utint_stage(ji,jj) = utint_stage(ji,jj) + 1
+               ENDIF
+            END DO
+         END DO
+      END IF
       ! 
    END SUBROUTINE interpunb
 
 
-   SUBROUTINE interpvnb( ptab, i1, i2, j1, j2, before, nb, ndir )
+   SUBROUTINE interpvnb( ptab, i1, i2, j1, j2, before )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE interpvnb  ***
@@ -1105,9 +963,7 @@
       REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) ::   ptab
       LOGICAL                         , INTENT(in   ) ::   before
-      INTEGER                         , INTENT(in   ) ::   nb , ndir
-      !
-      INTEGER  ::   ji,jj
+      !
+      INTEGER  ::   ji, jj
       REAL(wp) ::   zrhox, zrhot, zt0, zt1, ztcoeff   
-      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
       !!----------------------------------------------------------------------  
       ! 
@@ -1115,34 +971,34 @@
          ptab(i1:i2,j1:j2) = e1v(i1:i2,j1:j2) * hv_n(i1:i2,j1:j2) * vn_b(i1:i2,j1:j2)
       ELSE
-         western_side  = (nb == 1).AND.(ndir == 1)
-         eastern_side  = (nb == 1).AND.(ndir == 2)
-         southern_side = (nb == 2).AND.(ndir == 1)
-         northern_side = (nb == 2).AND.(ndir == 2)
          zrhox = Agrif_Rhox()
          zrhot = Agrif_rhot()
          ! Time indexes bounds for integration
          zt0 = REAL(Agrif_NbStepint()  , wp) / zrhot
-         zt1 = REAL(Agrif_NbStepint()+1, wp) / zrhot      
-         IF( bdy_tinterp == 1 ) THEN
-            ztcoeff = zrhot * (  zt1**2._wp * (       zt1 - 1._wp)        &
-               &               - zt0**2._wp * (       zt0 - 1._wp)        )
-         ELSEIF( bdy_tinterp == 2 ) THEN
-            ztcoeff = zrhot * (  zt1        * (       zt1 - 1._wp)**2._wp &
-               &               - zt0        * (       zt0 - 1._wp)**2._wp ) 
-         ELSE
-            ztcoeff = 1
-         ENDIF
-         !! clem ghost
-         IF(western_side)   vbdy_w(1:nbghostcells,j1:j2) = vbdy_w(1:nbghostcells,j1:j2) + ztcoeff * ptab(i1:i2,j1:j2)  
-         IF(eastern_side)   vbdy_e(1:nbghostcells,j1:j2) = vbdy_e(1:nbghostcells,j1:j2) + ztcoeff * ptab(i1:i2,j1:j2)   
-         IF(southern_side)  vbdy_s(i1:i2,1:nbghostcells) = vbdy_s(i1:i2,1:nbghostcells) + ztcoeff * ptab(i1:i2,j1:j2)
-         IF(northern_side)  vbdy_n(i1:i2,1:nbghostcells) = vbdy_n(i1:i2,1:nbghostcells) + ztcoeff * ptab(i1:i2,j1:j2) 
-         !            
-         IF( bdy_tinterp == 0 .OR. bdy_tinterp == 2) THEN
-            IF(western_side)   vbdy_w(1:nbghostcells,j1:j2) = vbdy_w(1:nbghostcells,j1:j2) / (zrhox*e1v(i1:i2,j1:j2)) * vmask(i1:i2,j1:j2,1)
-            IF(eastern_side)   vbdy_e(1:nbghostcells,j1:j2) = vbdy_e(1:nbghostcells,j1:j2) / (zrhox*e1v(i1:i2,j1:j2)) * vmask(i1:i2,j1:j2,1)
-            IF(southern_side)  vbdy_s(i1:i2,1:nbghostcells) = vbdy_s(i1:i2,1:nbghostcells) / (zrhox*e1v(i1:i2,j1:j2)) * vmask(i1:i2,j1:j2,1)
-            IF(northern_side)  vbdy_n(i1:i2,1:nbghostcells) = vbdy_n(i1:i2,1:nbghostcells) / (zrhox*e1v(i1:i2,j1:j2)) * vmask(i1:i2,j1:j2,1)
-         ENDIF
+         zt1 = REAL(Agrif_NbStepint()+1, wp) / zrhot 
+         !     
+         DO ji = i1, i2
+            DO jj = j1, j2
+               IF    ( vtint_stage(ji,jj) == 1  ) THEN
+                  ztcoeff = zrhot * (  zt1**2._wp * (       zt1 - 1._wp)        &
+                     &               - zt0**2._wp * (       zt0 - 1._wp)        )
+               ELSEIF( vtint_stage(ji,jj) == 2  ) THEN
+                  ztcoeff = zrhot * (  zt1        * (       zt1 - 1._wp)**2._wp &
+                     &               - zt0        * (       zt0 - 1._wp)**2._wp )
+               ELSEIF( vtint_stage(ji,jj) == 0  ) THEN                
+                  ztcoeff = 1._wp
+               ELSE
+                  ztcoeff = 0._wp
+               ENDIF
+               !   
+               vbdy(ji,jj) = vbdy(ji,jj) + ztcoeff * ptab(ji,jj)
+               !            
+               IF (( vtint_stage(ji,jj) == 2 ).OR.( vtint_stage(ji,jj) == 0 )) THEN
+                  vbdy(ji,jj) = vbdy(ji,jj) / (zrhox*e1v(ji,jj)) * vmask(ji,jj,1)
+                  vtint_stage(ji,jj) = 3
+               ELSE
+                  vtint_stage(ji,jj) = vtint_stage(ji,jj) + 1
+               ENDIF
+            END DO
+         END DO          
       ENDIF
       !
@@ -1150,5 +1006,5 @@
 
 
-   SUBROUTINE interpub2b( ptab, i1, i2, j1, j2, before, nb, ndir )
+   SUBROUTINE interpub2b( ptab, i1, i2, j1, j2, before )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE interpub2b  ***
@@ -1157,9 +1013,7 @@
       REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) ::   ptab
       LOGICAL                         , INTENT(in   ) ::   before
-      INTEGER                         , INTENT(in   ) ::   nb , ndir
       !
       INTEGER  ::   ji,jj
-      REAL(wp) ::   zrhot, zt0, zt1,zat
-      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
+      REAL(wp) ::   zrhot, zt0, zt1, zat
       !!----------------------------------------------------------------------  
       IF( before ) THEN
@@ -1170,50 +1024,4 @@
          ENDIF
       ELSE
-         western_side  = (nb == 1).AND.(ndir == 1)
-         eastern_side  = (nb == 1).AND.(ndir == 2)
-         southern_side = (nb == 2).AND.(ndir == 1)
-         northern_side = (nb == 2).AND.(ndir == 2)
-         zrhot = Agrif_rhot()
-         ! Time indexes bounds for integration
-         zt0 = REAL(Agrif_NbStepint()  , wp) / zrhot
-         zt1 = REAL(Agrif_NbStepint()+1, wp) / zrhot
-         ! Polynomial interpolation coefficients:
-         zat = zrhot * (  zt1**2._wp * (-2._wp*zt1 + 3._wp)    &
-            &           - zt0**2._wp * (-2._wp*zt0 + 3._wp)    ) 
-         !! clem ghost
-         IF(western_side ) ubdy_w(1:nbghostcells,j1:j2) = zat * ptab(i1:i2,j1:j2)  
-         IF(eastern_side ) ubdy_e(1:nbghostcells,j1:j2) = zat * ptab(i1:i2,j1:j2)  
-         IF(southern_side) ubdy_s(i1:i2,1:nbghostcells) = zat * ptab(i1:i2,j1:j2)
-         IF(northern_side) ubdy_n(i1:i2,1:nbghostcells) = zat * ptab(i1:i2,j1:j2) 
-      ENDIF
-      ! 
-   END SUBROUTINE interpub2b
-   
-
-   SUBROUTINE interpvb2b( ptab, i1, i2, j1, j2, before, nb, ndir )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE interpvb2b  ***
-      !!----------------------------------------------------------------------  
-      INTEGER                         , INTENT(in   ) ::   i1, i2, j1, j2
-      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) ::   ptab
-      LOGICAL                         , INTENT(in   ) ::   before
-      INTEGER                         , INTENT(in   ) ::   nb , ndir
-      !
-      INTEGER ::   ji,jj
-      REAL(wp) ::   zrhot, zt0, zt1,zat
-      LOGICAL ::   western_side, eastern_side,northern_side,southern_side
-      !!----------------------------------------------------------------------  
-      !
-      IF( before ) THEN
-         IF ( ln_bt_fw ) THEN
-            ptab(i1:i2,j1:j2) = e1v(i1:i2,j1:j2) * vb2_b(i1:i2,j1:j2)
-         ELSE
-            ptab(i1:i2,j1:j2) = e1v(i1:i2,j1:j2) * vn_adv(i1:i2,j1:j2)
-         ENDIF
-      ELSE      
-         western_side  = (nb == 1).AND.(ndir == 1)
-         eastern_side  = (nb == 1).AND.(ndir == 2)
-         southern_side = (nb == 2).AND.(ndir == 1)
-         northern_side = (nb == 2).AND.(ndir == 2)
          zrhot = Agrif_rhot()
          ! Time indexes bounds for integration
@@ -1224,8 +1032,44 @@
             &           - zt0**2._wp * (-2._wp*zt0 + 3._wp)    ) 
          !
-         IF(western_side )   vbdy_w(1:nbghostcells,j1:j2) = zat * ptab(i1:i2,j1:j2)  
-         IF(eastern_side )   vbdy_e(1:nbghostcells,j1:j2) = zat * ptab(i1:i2,j1:j2)  
-         IF(southern_side)   vbdy_s(i1:i2,1:nbghostcells) = zat * ptab(i1:i2,j1:j2)
-         IF(northern_side)   vbdy_n(i1:i2,1:nbghostcells) = zat * ptab(i1:i2,j1:j2) 
+         ubdy(i1:i2,j1:j2) = zat * ptab(i1:i2,j1:j2) 
+         !
+         ! Update interpolation stage:
+         utint_stage(i1:i2,j1:j2) = 1
+      ENDIF
+      ! 
+   END SUBROUTINE interpub2b
+   
+
+   SUBROUTINE interpvb2b( ptab, i1, i2, j1, j2, before )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpvb2b  ***
+      !!----------------------------------------------------------------------  
+      INTEGER                         , INTENT(in   ) ::   i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) ::   ptab
+      LOGICAL                         , INTENT(in   ) ::   before
+      !
+      INTEGER ::   ji,jj
+      REAL(wp) ::   zrhot, zt0, zt1, zat
+      !!----------------------------------------------------------------------  
+      !
+      IF( before ) THEN
+         IF ( ln_bt_fw ) THEN
+            ptab(i1:i2,j1:j2) = e1v(i1:i2,j1:j2) * vb2_b(i1:i2,j1:j2)
+         ELSE
+            ptab(i1:i2,j1:j2) = e1v(i1:i2,j1:j2) * vn_adv(i1:i2,j1:j2)
+         ENDIF
+      ELSE      
+         zrhot = Agrif_rhot()
+         ! Time indexes bounds for integration
+         zt0 = REAL(Agrif_NbStepint()  , wp) / zrhot
+         zt1 = REAL(Agrif_NbStepint()+1, wp) / zrhot
+         ! Polynomial interpolation coefficients:
+         zat = zrhot * (  zt1**2._wp * (-2._wp*zt1 + 3._wp)    &
+            &           - zt0**2._wp * (-2._wp*zt0 + 3._wp)    ) 
+         !
+         vbdy(i1:i2,j1:j2) = zat * ptab(i1:i2,j1:j2)
+         !
+         ! update interpolation stage:
+         vtint_stage(i1:i2,j1:j2) = 1
       ENDIF
       !      
Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_sponge.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_sponge.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_sponge.F90	(revision 11574)
@@ -22,4 +22,5 @@
    USE agrif_oce
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE iom
 
    IMPLICIT NONE
@@ -58,4 +59,7 @@
 #endif
       !
+      CALL iom_put("fsaht_spu", fsaht_spu(:,:))
+      CALL iom_put("fsaht_spv", fsaht_spv(:,:))
+      !
    END SUBROUTINE Agrif_Sponge_Tra
 
@@ -85,4 +89,7 @@
 #endif
       !
+      CALL iom_put("fsahm_spt", fsahm_spt(:,:))
+      CALL iom_put("fsahm_spf", fsahm_spf(:,:))
+      !
    END SUBROUTINE Agrif_Sponge_dyn
 
@@ -93,62 +100,146 @@
       !!----------------------------------------------------------------------
       INTEGER  ::   ji, jj, ind1, ind2
-      INTEGER  ::   ispongearea
-      REAL(wp) ::   z1_spongearea
+      INTEGER  ::   ispongearea, jspongearea
+      REAL(wp) ::   z1_ispongearea, z1_jspongearea
       REAL(wp), DIMENSION(jpi,jpj) :: ztabramp
+      REAL(wp), DIMENSION(jpjmax)  :: zmskwest,  zmskeast
+      REAL(wp), DIMENSION(jpimax)  :: zmsknorth, zmsksouth
       !!----------------------------------------------------------------------
       !
 #if defined SPONGE || defined SPONGE_TOP
       IF (( .NOT. spongedoneT ).OR.( .NOT. spongedoneU )) THEN
+         !
+         ! Retrieve masks at open boundaries:
+
+         ! --- West --- !
+         ztabramp(:,:) = 0._wp
+         ind1 = 1+nbghostcells
+         DO ji = mi0(ind1), mi1(ind1)                
+            ztabramp(ji,:) = umask(ji,:,1)
+         END DO
+         !
+         zmskwest(:) = 0._wp
+         zmskwest(1:jpj) = MAXVAL(ztabramp(:,:), dim=1)
+
+         ! --- East --- !
+         ztabramp(:,:) = 0._wp
+         ind1 = jpiglo - nbghostcells - 1
+         DO ji = mi0(ind1), mi1(ind1)                 
+            ztabramp(ji,:) = umask(ji,:,1)
+         END DO
+         !
+         zmskeast(:) = 0._wp
+         zmskeast(1:jpj) = MAXVAL(ztabramp(:,:), dim=1)
+
+         ! --- South --- !
+         ztabramp(:,:) = 0._wp
+         ind1 = 1+nbghostcells
+         DO jj = mj0(ind1), mj1(ind1)                 
+            ztabramp(:,jj) = vmask(:,jj,1)
+         END DO
+         !
+         zmsksouth(:) = 0._wp
+         zmsksouth(1:jpi) = MAXVAL(ztabramp(:,:), dim=2)
+
+         ! --- North --- !
+         ztabramp(:,:) = 0._wp
+         ind1 = jpjglo - nbghostcells - 1
+         DO jj = mj0(ind1), mj1(ind1)                 
+            ztabramp(:,jj) = vmask(:,jj,1)
+         END DO
+         !
+         zmsknorth(:) = 0._wp
+         zmsknorth(1:jpi) = MAXVAL(ztabramp(:,:), dim=2)
+
+#if defined key_mpp_mpi
+         CALL mpp_max( 'AGRIF_sponge', zmskwest(:) , jpjmax )
+         CALL mpp_max( 'AGRIF_Sponge', zmskeast(:) , jpjmax )
+         CALL mpp_max( 'AGRIF_Sponge', zmsksouth(:), jpimax )
+         CALL mpp_max( 'AGRIF_Sponge', zmsknorth(:), jpimax )
+#endif
+
          ! Define ramp from boundaries towards domain interior at T-points
          ! Store it in ztabramp
 
          ispongearea  = 1 + nn_sponge_len * Agrif_irhox()
-         z1_spongearea = 1._wp / REAL( ispongearea )
+         z1_ispongearea = 1._wp / REAL( ispongearea )
+         jspongearea  = 1 + nn_sponge_len * Agrif_irhoy()
+         z1_jspongearea = 1._wp / REAL( jspongearea )
          
          ztabramp(:,:) = 0._wp
+         IF ( Agrif_irhox()==1 ) ispongearea =-1
+         IF ( Agrif_irhoy()==1 ) jspongearea =-1
 
          ! --- West --- !
-         IF( (nbondi == -1) .OR. (nbondi == 2) ) THEN
-            ind1 = 1+nbghostcells
-            ind2 = 1+nbghostcells + ispongearea 
+         ind1 = 1+nbghostcells
+         ind2 = 1+nbghostcells + ispongearea 
+         DO ji = mi0(ind1), mi1(ind2)   
+            DO jj = 1, jpj               
+               ztabramp(ji,jj) = REAL( ind2 - mig(ji) ) * z1_ispongearea * zmskwest(jj)
+            END DO
+         END DO
+
+         ! ghost cells (cosmetic):
+         ind1 = 1
+         ind2 = nbghostcells
+         DO ji = mi0(ind1), mi1(ind2)   
+            DO jj = 1, jpj               
+               ztabramp(ji,jj) = zmskwest(jj)
+            END DO
+         END DO
+
+         ! --- East --- !
+         ind1 = jpiglo - nbghostcells - ispongearea
+         ind2 = jpiglo - nbghostcells
+         DO ji = mi0(ind1), mi1(ind2)
             DO jj = 1, jpj
-               DO ji = ind1, ind2                
-                  ztabramp(ji,jj) = REAL( ind2 - ji ) * z1_spongearea * umask(ind1,jj,1)
-               END DO
+               ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( mig(ji) - ind1 ) * z1_ispongearea) * zmskeast(jj)
             ENDDO
-         ENDIF
-
-         ! --- East --- !
-         IF( (nbondi == 1) .OR. (nbondi == 2) ) THEN
-            ind1 = nlci - nbghostcells - ispongearea
-            ind2 = nlci - nbghostcells
+         END DO
+
+         ! ghost cells (cosmetic):
+         ind1 = jpiglo - nbghostcells + 1
+         ind2 = jpiglo
+         DO ji = mi0(ind1), mi1(ind2)
             DO jj = 1, jpj
-               DO ji = ind1, ind2
-                  ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( ji - ind1 ) * z1_spongearea * umask(ind2-1,jj,1) )
-               ENDDO
+               ztabramp(ji,jj) = zmskeast(jj)
             ENDDO
-         ENDIF
+         END DO
 
          ! --- South --- !
-         IF( (nbondj == -1) .OR. (nbondj == 2) ) THEN
-            ind1 = 1+nbghostcells
-            ind2 = 1+nbghostcells + ispongearea
-            DO jj = ind1, ind2 
-               DO ji = 1, jpi
-                  ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( ind2 - jj ) * z1_spongearea * vmask(ji,ind1,1) )
-               END DO
-            ENDDO
-         ENDIF
+         ind1 = 1+nbghostcells
+         ind2 = 1+nbghostcells + jspongearea
+         DO jj = mj0(ind1), mj1(ind2) 
+            DO ji = 1, jpi
+               ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( ind2 - mjg(jj) ) * z1_jspongearea) * zmsksouth(ji)
+            END DO
+         END DO
+
+         ! ghost cells (cosmetic):
+         ind1 = 1
+         ind2 = nbghostcells
+         DO jj = mj0(ind1), mj1(ind2) 
+            DO ji = 1, jpi
+               ztabramp(ji,jj) = zmsksouth(ji)
+            END DO
+         END DO
 
          ! --- North --- !
-         IF( (nbondj == 1) .OR. (nbondj == 2) ) THEN
-            ind1 = nlcj - nbghostcells - ispongearea
-            ind2 = nlcj - nbghostcells
-            DO jj = ind1, ind2
-               DO ji = 1, jpi
-                  ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( jj - ind1 ) * z1_spongearea * vmask(ji,ind2-1,1) )
-               END DO
-            ENDDO
-         ENDIF
+         ind1 = jpjglo - nbghostcells - jspongearea
+         ind2 = jpjglo - nbghostcells
+         DO jj = mj0(ind1), mj1(ind2)
+            DO ji = 1, jpi
+               ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( mjg(jj) - ind1 ) * z1_jspongearea) * zmsknorth(ji)
+            END DO
+         END DO
+
+         ! ghost cells (cosmetic):
+         ind1 = jpjglo - nbghostcells + 1
+         ind2 = jpjglo
+         DO jj = mj0(ind1), mj1(ind2)
+            DO ji = 1, jpi
+               ztabramp(ji,jj) = zmsknorth(ji)
+            END DO
+         END DO
 
       ENDIF
@@ -160,10 +251,10 @@
          DO jj = 2, jpjm1
             DO ji = 2, jpim1   ! vector opt.
-               fsaht_spu(ji,jj) = 0.5_wp * visc_tra * ( ztabramp(ji,jj) + ztabramp(ji+1,jj  ) )
-               fsaht_spv(ji,jj) = 0.5_wp * visc_tra * ( ztabramp(ji,jj) + ztabramp(ji  ,jj+1) )
-            END DO
-         END DO
-         CALL lbc_lnk( 'agrif_oce_sponge', fsaht_spu, 'U', 1. )   ! Lateral boundary conditions
-         CALL lbc_lnk( 'agrif_oce_sponge', fsaht_spv, 'V', 1. )
+               fsaht_spu(ji,jj) = 0.5_wp * rn_sponge_tra * ( ztabramp(ji,jj) + ztabramp(ji+1,jj  ) )
+               fsaht_spv(ji,jj) = 0.5_wp * rn_sponge_tra * ( ztabramp(ji,jj) + ztabramp(ji  ,jj+1) )
+            END DO
+         END DO
+         CALL lbc_lnk( 'agrif_Sponge', fsaht_spu, 'U', 1. )   ! Lateral boundary conditions
+         CALL lbc_lnk( 'agrif_Sponge', fsaht_spv, 'V', 1. )
          
          spongedoneT = .TRUE.
@@ -176,11 +267,11 @@
          DO jj = 2, jpjm1
             DO ji = 2, jpim1   ! vector opt.
-               fsahm_spt(ji,jj) = visc_dyn * ztabramp(ji,jj)
-               fsahm_spf(ji,jj) = 0.25_wp * visc_dyn * ( ztabramp(ji  ,jj  ) + ztabramp(ji  ,jj+1) &
-                                                     &  +ztabramp(ji+1,jj+1) + ztabramp(ji+1,jj  ) )
-            END DO
-         END DO
-         CALL lbc_lnk( 'agrif_oce_sponge', fsahm_spt, 'T', 1. )   ! Lateral boundary conditions
-         CALL lbc_lnk( 'agrif_oce_sponge', fsahm_spf, 'F', 1. )
+               fsahm_spt(ji,jj) = rn_sponge_dyn * ztabramp(ji,jj)
+               fsahm_spf(ji,jj) = 0.25_wp * rn_sponge_dyn * ( ztabramp(ji  ,jj  ) + ztabramp(ji  ,jj+1) &
+                                                          &  +ztabramp(ji+1,jj+1) + ztabramp(ji+1,jj  ) )
+            END DO
+         END DO
+         CALL lbc_lnk( 'agrif_Sponge', fsahm_spt, 'T', 1. )   ! Lateral boundary conditions
+         CALL lbc_lnk( 'agrif_Sponge', fsahm_spf, 'F', 1. )
          
          spongedoneU = .TRUE.
Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_update.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_update.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_update.F90	(revision 11574)
@@ -1,3 +1,2 @@
-#define TWO_WAY        /* TWO WAY NESTING */
 #undef DECAL_FEEDBACK  /* SEPARATION of INTERFACES*/
 #undef VOL_REFLUX      /* VOLUME REFLUXING*/
@@ -46,5 +45,4 @@
       IF (Agrif_Root()) RETURN
       !
-#if defined TWO_WAY  
       IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update tracers  from grid Number',Agrif_Fixed()
 
@@ -64,5 +62,4 @@
       Agrif_UseSpecialValueInUpdate = .FALSE.
       !
-#endif
       !
    END SUBROUTINE Agrif_Update_Tra
@@ -75,5 +72,4 @@
       IF (Agrif_Root()) RETURN
       !
-#if defined TWO_WAY
       IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update momentum from grid Number',Agrif_Fixed()
 
@@ -121,5 +117,4 @@
 #  endif
       END IF
-#endif
       !
    END SUBROUTINE Agrif_Update_Dyn
@@ -131,6 +126,4 @@
       ! 
       IF (Agrif_Root()) RETURN
-      !
-#if defined TWO_WAY
       !
       Agrif_UseSpecialValueInUpdate = .TRUE.
@@ -157,6 +150,4 @@
 #  endif
       !
-#endif
-      !
    END SUBROUTINE Agrif_Update_ssh
 
@@ -170,6 +161,4 @@
       IF (Agrif_Root()) RETURN
       !       
-#  if defined TWO_WAY
-
       Agrif_UseSpecialValueInUpdate = .TRUE.
       Agrif_SpecialValueFineGrid = 0.
@@ -180,6 +169,4 @@
 
       Agrif_UseSpecialValueInUpdate = .FALSE.
-
-#  endif
       
    END SUBROUTINE Agrif_Update_Tke
@@ -192,6 +179,4 @@
       !
       IF (Agrif_Root()) RETURN
-      !
-#if defined TWO_WAY  
       !
       IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update e3 from grid Number',Agrif_Fixed(), 'Step', Agrif_Nb_Step()
@@ -209,6 +194,4 @@
       CALL dom_vvl_update_UVF
       CALL Agrif_ParentGrid_To_ChildGrid()
-      !
-#endif
       !
    END SUBROUTINE Agrif_Update_vvl
Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_interp.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_interp.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_interp.F90	(revision 11574)
@@ -90,8 +90,8 @@
       ELSE 
 
+# if defined key_vertical
          western_side  = (nb == 1).AND.(ndir == 1)   ;   eastern_side  = (nb == 1).AND.(ndir == 2)
          southern_side = (nb == 2).AND.(ndir == 1)   ;   northern_side = (nb == 2).AND.(ndir == 2)
 
-# if defined key_vertical              
          DO jj=j1,j2
             DO ji=i1,i2
@@ -130,133 +130,4 @@
          END DO
 
-         IF ( .NOT.lk_agrif_clp ) THEN 
-            !
-            imin = i1 ; imax = i2
-            jmin = j1 ; jmax = j2
-            ! 
-            ! Remove CORNERS
-            IF((nbondj == -1).OR.(nbondj == 2)) jmin = 2 + nbghostcells
-            IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj - nbghostcells - 1
-            IF((nbondi == -1).OR.(nbondi == 2)) imin = 2 + nbghostcells
-            IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci - nbghostcells - 1      
-            !
-            IF( eastern_side ) THEN
-               zrho = Agrif_Rhox()
-               z1 = ( zrho - 1._wp ) * 0.5_wp                    
-               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
-               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
-               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
-               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
-               !
-               ibdy = nlci-nbghostcells
-               DO jn = 1, jptra
-                  tra(ibdy+1,jmin:jmax,1:jpkm1,jn) = z1 * ptab_child(ibdy+1,jmin:jmax,1:jpkm1,jn) + z2 * ptab_child(ibdy,jmin:jmax,1:jpkm1,jn)
-                  DO jk = 1, jpkm1
-                     DO jj = jmin,jmax
-                        IF( umask(ibdy-1,jj,jk) == 0._wp ) THEN
-                           tra(ibdy,jj,jk,jn) = tra(ibdy+1,jj,jk,jn) * tmask(ibdy,jj,jk)
-                        ELSE
-                           tra(ibdy,jj,jk,jn)=(z4*tra(ibdy+1,jj,jk,jn)+z3*tra(ibdy-1,jj,jk,jn))*tmask(ibdy,jj,jk)
-                           IF( un(ibdy-1,jj,jk) > 0._wp ) THEN
-                              tra(ibdy,jj,jk,jn)=( z6*tra(ibdy-1,jj,jk,jn)+z5*tra(ibdy+1,jj,jk,jn) & 
-                                                 + z7*tra(ibdy-2,jj,jk,jn) ) * tmask(ibdy,jj,jk)
-                           ENDIF
-                        ENDIF
-                     END DO
-                  END DO
-                  ! Restore ghost points:
-                  tra(ibdy+1,jmin:jmax,1:jpkm1,jn) = ptab_child(ibdy+1,jmin:jmax,1:jpkm1,jn) * tmask(ibdy+1,jmin:jmax,1:jpkm1)
-               END DO
-            ENDIF
-            ! 
-            IF( northern_side ) THEN
-               zrho = Agrif_Rhoy()
-               z1 = ( zrho - 1._wp ) * 0.5_wp                    
-               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
-               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
-               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
-               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
-               !
-               jbdy = nlcj-nbghostcells         
-               DO jn = 1, jptra
-                  tra(imin:imax,jbdy+1,1:jpkm1,jn) = z1 * ptab_child(imin:imax,jbdy+1,1:jpkm1,jn) + z2 * ptab_child(imin:imax,jbdy,1:jpkm1,jn)
-                  DO jk = 1, jpkm1
-                     DO ji = imin,imax
-                        IF( vmask(ji,jbdy-1,jk) == 0._wp ) THEN
-                           tra(ji,jbdy,jk,jn) = tra(ji,jbdy+1,jk,jn) * tmask(ji,jbdy,jk)
-                        ELSE
-                           tra(ji,jbdy,jk,jn)=(z4*tra(ji,jbdy+1,jk,jn)+z3*tra(ji,jbdy-1,jk,jn))*tmask(ji,jbdy,jk)        
-                           IF (vn(ji,jbdy-1,jk) > 0._wp ) THEN
-                              tra(ji,jbdy,jk,jn)=( z6*tra(ji,jbdy-1,jk,jn)+z5*tra(ji,jbdy+1,jk,jn)  &
-                                                 + z7*tra(ji,jbdy-2,jk,jn) ) * tmask(ji,jbdy,jk)
-                           ENDIF
-                        ENDIF
-                     END DO
-                  END DO
-                  ! Restore ghost points:
-                  tra(imin:imax,jbdy+1,1:jpkm1,jn) = ptab_child(imin:imax,jbdy+1,1:jpkm1,jn) * tmask(imin:imax,jbdy+1,1:jpkm1)
-               END DO
-            ENDIF
-            !
-            IF( western_side ) THEN
-               zrho = Agrif_Rhox()
-               z1 = ( zrho - 1._wp ) * 0.5_wp                    
-               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
-               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
-               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
-               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
-               !    
-               ibdy = 1+nbghostcells       
-               DO jn = 1, jptra
-                  tra(ibdy-1,jmin:jmax,1:jpkm1,jn) = z1 * ptab_child(ibdy-1,jmin:jmax,1:jpkm1,jn) + z2 * ptab_child(ibdy,jmin:jmax,1:jpkm1,jn)
-                  DO jk = 1, jpkm1
-                     DO jj = jmin,jmax
-                        IF( umask(ibdy,jj,jk) == 0._wp ) THEN
-                           tra(ibdy,jj,jk,jn) = tra(ibdy-1,jj,jk,jn) * tmask(ibdy,jj,jk)
-                        ELSE
-                           tra(ibdy,jj,jk,jn)=(z4*tra(ibdy-1,jj,jk,jn)+z3*tra(ibdy+1,jj,jk,jn))*tmask(ibdy,jj,jk)        
-                           IF( un(ibdy,jj,jk) < 0._wp ) THEN
-                              tra(ibdy,jj,jk,jn)=( z6*tra(ibdy+1,jj,jk,jn)+z5*tra(ibdy-1,jj,jk,jn) &
-                                                 + z7*tra(ibdy+2,jj,jk,jn) ) * tmask(ibdy,jj,jk)
-                           ENDIF
-                        ENDIF
-                     END DO
-                  END DO
-                  ! Restore ghost points:
-                  tra(ibdy-1,jmin:jmax,1:jpkm1,jn) = ptab_child(ibdy-1,jmin:jmax,1:jpkm1,jn) * tmask(ibdy-1,jmin:jmax,1:jpkm1)
-               END DO
-            ENDIF
-            !
-            IF( southern_side ) THEN
-               zrho = Agrif_Rhoy()
-               z1 = ( zrho - 1._wp ) * 0.5_wp                    
-               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
-               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
-               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
-               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
-               !  
-               jbdy=1+nbghostcells        
-               DO jn = 1, jptra
-                  tra(imin:imax,jbdy-1,1:jpkm1,jn) = z1 * ptab_child(imin:imax,jbdy-1,1:jpkm1,jn) + z2 * ptab_child(imin:imax,jbdy,1:jpkm1,jn)
-                  DO jk = 1, jpkm1      
-                     DO ji = imin,imax
-                        IF( vmask(ji,jbdy,jk) == 0._wp ) THEN
-                           tra(ji,jbdy,jk,jn)=tra(ji,jbdy-1,jk,jn) * tmask(ji,jbdy,jk)
-                        ELSE
-                           tra(ji,jbdy,jk,jn)=(z4*tra(ji,jbdy-1,jk,jn)+z3*tra(ji,jbdy+1,jk,jn))*tmask(ji,jbdy,jk)
-                           IF( vn(ji,jbdy,jk) < 0._wp ) THEN
-                              tra(ji,jbdy,jk,jn)=( z6*tra(ji,jbdy+1,jk,jn)+z5*tra(ji,jbdy-1,jk,jn) & 
-                                                 + z7*tra(ji,jbdy+2,jk,jn) ) * tmask(ji,jbdy,jk)
-                           ENDIF
-                        ENDIF
-                     END DO
-                  END DO
-                  ! Restore ghost points:
-                  tra(imin:imax,jbdy-1,1:jpkm1,jn) = ptab_child(imin:imax,jbdy-1,1:jpkm1,jn) * tmask(imin:imax,jbdy-1,1:jpkm1)
-               END DO
-            ENDIF
-            !
-         ENDIF
-
       ENDIF
       !
Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_update.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_update.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_update.F90	(revision 11574)
@@ -1,3 +1,2 @@
-#define TWO_WAY
 #undef DECAL_FEEDBACK
 
@@ -40,5 +39,4 @@
       IF (Agrif_Root()) RETURN 
       !
-#if defined TWO_WAY   
       Agrif_UseSpecialValueInUpdate = .TRUE.
       Agrif_SpecialValueFineGrid    = 0._wp
@@ -53,6 +51,4 @@
       !
       Agrif_UseSpecialValueInUpdate = .FALSE.
-      !
-#endif
       !
    END SUBROUTINE Agrif_Update_Trc
Index: NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_user.F90
===================================================================
--- NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_user.F90	(revision 11573)
+++ NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_user.F90	(revision 11574)
@@ -6,446 +6,382 @@
    !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
-SUBROUTINE agrif_user
-END SUBROUTINE agrif_user
-
-SUBROUTINE agrif_before_regridding
-END SUBROUTINE agrif_before_regridding
-
-SUBROUTINE Agrif_InitWorkspace
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE Agrif_InitWorkspace ***
-      !!----------------------------------------------------------------------
-   USE par_oce
-   USE dom_oce
-   USE nemogcm
-   USE mppini
-      !!
-   IMPLICIT NONE
-      !!----------------------------------------------------------------------
-   !
-   IF( .NOT. Agrif_Root() ) THEN
-      ! no more static variables
-!!$! JC: change to allow for different vertical levels
-!!$!     jpk is already set
-!!$!     keep it jpk possibly different from jpkglo which 
-!!$!     hold parent grid vertical levels number (set earlier)
-!!$!      jpk     = jpkglo 
-   ENDIF
-   !
-END SUBROUTINE Agrif_InitWorkspace
-
-
-SUBROUTINE Agrif_InitValues
+   SUBROUTINE agrif_user
+   END SUBROUTINE agrif_user
+
+   SUBROUTINE agrif_before_regridding
+   END SUBROUTINE agrif_before_regridding
+
+   SUBROUTINE Agrif_InitWorkspace
+   END SUBROUTINE Agrif_InitWorkspace
+
+   SUBROUTINE Agrif_InitValues
       !!----------------------------------------------------------------------
       !!                 *** ROUTINE Agrif_InitValues ***
-      !!
-      !! ** Purpose :: Declaration of variables to be interpolated
-      !!----------------------------------------------------------------------
-   USE Agrif_Util
-   USE oce 
-   USE dom_oce
-   USE nemogcm
-   USE tradmp
-   USE bdy_oce   , ONLY: ln_bdy
-   !!
-   IMPLICIT NONE
-      !!----------------------------------------------------------------------
-   !
-   CALL nemo_init       !* Initializations of each fine grid
-
-   !                    !* Agrif initialization
-   CALL agrif_nemo_init
-   CALL Agrif_InitValues_cont_dom
-   CALL Agrif_InitValues_cont
+      !!----------------------------------------------------------------------
+      USE nemogcm
+      !!----------------------------------------------------------------------
+      !
+      CALL nemo_init       !* Initializations of each fine grid
+      !
+      !                    !* Agrif initialization
+      CALL agrif_nemo_init
+      CALL Agrif_InitValues_cont_dom
+      CALL Agrif_InitValues_cont
 # if defined key_top
-   CALL Agrif_InitValues_cont_top
+      CALL Agrif_InitValues_cont_top
 # endif
 # if defined key_si3
-   CALL Agrif_InitValues_cont_ice
+      CALL Agrif_InitValues_cont_ice
 # endif
-   !    
-END SUBROUTINE Agrif_initvalues
-
-
-SUBROUTINE Agrif_InitValues_cont_dom
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE Agrif_InitValues_cont ***
-      !!
-      !! ** Purpose ::   Declaration of variables to be interpolated
-      !!----------------------------------------------------------------------
-   USE Agrif_Util
-   USE oce 
-   USE dom_oce
-   USE nemogcm
-   USE in_out_manager
-   USE agrif_oce_update
-   USE agrif_oce_interp
-   USE agrif_oce_sponge
-   !
-   IMPLICIT NONE
-      !!----------------------------------------------------------------------
-   !
-   ! Declaration of the type of variable which have to be interpolated
-   !
-   CALL agrif_declare_var_dom
-   !
-END SUBROUTINE Agrif_InitValues_cont_dom
-
-
-SUBROUTINE agrif_declare_var_dom
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE agrif_declare_var ***
-      !!
-      !! ** Purpose :: Declaration of variables to be interpolated
-      !!----------------------------------------------------------------------
-   USE agrif_util
-   USE par_oce       
-   USE oce
-   !
-   IMPLICIT NONE
-   !
-   INTEGER :: ind1, ind2, ind3
+      !    
+   END SUBROUTINE Agrif_initvalues
+
+   SUBROUTINE Agrif_InitValues_cont_dom
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues_cont_dom ***
+      !!----------------------------------------------------------------------
+      !
+      CALL agrif_declare_var_dom
+      !
+   END SUBROUTINE Agrif_InitValues_cont_dom
+
+   SUBROUTINE agrif_declare_var_dom
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE agrif_declare_var_dom ***
+      !!----------------------------------------------------------------------
+      USE par_oce, ONLY:  nbghostcells      
+      !
+      IMPLICIT NONE
+      !
+      INTEGER :: ind1, ind2, ind3
       !!----------------------------------------------------------------------
 
       ! 1. Declaration of the type of variable which have to be interpolated
       !---------------------------------------------------------------------
-   ind1 =     nbghostcells
-   ind2 = 1 + nbghostcells
-   ind3 = 2 + nbghostcells
-   CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e1u_id)
-   CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e2v_id)
+      ind1 =     nbghostcells
+      ind2 = 1 + nbghostcells
+      ind3 = 2 + nbghostcells
+      CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e1u_id)
+      CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e2v_id)
 
       ! 2. Type of interpolation
       !-------------------------
-   CALL Agrif_Set_bcinterp( e1u_id, interp1=Agrif_linear, interp2=AGRIF_ppm    )
-   CALL Agrif_Set_bcinterp( e2v_id, interp1=AGRIF_ppm   , interp2=Agrif_linear )
+      CALL Agrif_Set_bcinterp( e1u_id, interp1=Agrif_linear, interp2=AGRIF_ppm    )
+      CALL Agrif_Set_bcinterp( e2v_id, interp1=AGRIF_ppm   , interp2=Agrif_linear )
 
       ! 3. Location of interpolation
       !-----------------------------
-   CALL Agrif_Set_bc(e1u_id,(/0,ind1-1/))
-   CALL Agrif_Set_bc(e2v_id,(/0,ind1-1/))
+      CALL Agrif_Set_bc(e1u_id,(/0,ind1-1/))
+      CALL Agrif_Set_bc(e2v_id,(/0,ind1-1/))
 
       ! 4. Update type
       !--------------- 
 # if defined UPD_HIGH
-   CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Full_Weighting)
-   CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Full_Weighting, update2=Agrif_Update_Average)
+      CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Full_Weighting)
+      CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Full_Weighting, update2=Agrif_Update_Average)
 #else
-   CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average)
-   CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy)
+      CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average)
+      CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy)
 #endif
 
-END SUBROUTINE agrif_declare_var_dom
-
-
-SUBROUTINE Agrif_InitValues_cont
+   END SUBROUTINE agrif_declare_var_dom
+
+   SUBROUTINE Agrif_InitValues_cont
       !!----------------------------------------------------------------------
       !!                 *** ROUTINE Agrif_InitValues_cont ***
-      !!
-      !! ** Purpose ::   Declaration of variables to be interpolated
-      !!----------------------------------------------------------------------
-   USE agrif_oce_update
-   USE agrif_oce_interp
-   USE agrif_oce_sponge
-   USE Agrif_Util
-   USE oce 
-   USE dom_oce
-   USE zdf_oce
-   USE nemogcm
-   !
-   USE lib_mpp
-   USE in_out_manager
-   !
-   IMPLICIT NONE
-   !
-   LOGICAL :: check_namelist
-   CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4 
-      !!----------------------------------------------------------------------
-
-   ! 1. Declaration of the type of variable which have to be interpolated
-   !---------------------------------------------------------------------
-   CALL agrif_declare_var
-
-   ! 2. First interpolations of potentially non zero fields
-   !-------------------------------------------------------
-   Agrif_SpecialValue    = 0._wp
-   Agrif_UseSpecialValue = .TRUE.
-   CALL Agrif_Bc_variable(tsn_id,calledweight=1.,procname=interptsn)
-   CALL Agrif_Sponge
-   tabspongedone_tsn = .FALSE.
-   CALL Agrif_Bc_variable(tsn_sponge_id,calledweight=1.,procname=interptsn_sponge)
-   ! reset tsa to zero
-   tsa(:,:,:,:) = 0.
-
-   Agrif_UseSpecialValue = ln_spc_dyn
-   CALL Agrif_Bc_variable(un_interp_id,calledweight=1.,procname=interpun)
-   CALL Agrif_Bc_variable(vn_interp_id,calledweight=1.,procname=interpvn)
-   tabspongedone_u = .FALSE.
-   tabspongedone_v = .FALSE.
-   CALL Agrif_Bc_variable(un_sponge_id,calledweight=1.,procname=interpun_sponge)
-   tabspongedone_u = .FALSE.
-   tabspongedone_v = .FALSE.
-   CALL Agrif_Bc_variable(vn_sponge_id,calledweight=1.,procname=interpvn_sponge)
-
-   Agrif_UseSpecialValue = .TRUE.
-   CALL Agrif_Bc_variable(sshn_id,calledweight=1., procname=interpsshn )
-   hbdy_w(:,:) = 0.e0 ; hbdy_e(:,:) = 0.e0 ; hbdy_n(:,:) = 0.e0 ; hbdy_s(:,:) = 0.e0
-   ssha(:,:) = 0.e0
-
-   IF ( ln_dynspg_ts ) THEN
+      !!----------------------------------------------------------------------
+      USE agrif_oce
+      USE agrif_oce_interp
+      USE agrif_oce_sponge
+      USE dom_oce
+      USE oce
+      USE lib_mpp
+      !
+      IMPLICIT NONE
+      !
+      LOGICAL :: check_namelist
+      CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4 
+      !!----------------------------------------------------------------------
+
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      CALL agrif_declare_var
+
+      ! 2. First interpolations of potentially non zero fields
+      !-------------------------------------------------------
+      Agrif_SpecialValue    = 0._wp
+      Agrif_UseSpecialValue = .TRUE.
+      CALL Agrif_Bc_variable(tsn_id,calledweight=1.,procname=interptsn)
+      CALL Agrif_Sponge
+      tabspongedone_tsn = .FALSE.
+      CALL Agrif_Bc_variable(tsn_sponge_id,calledweight=1.,procname=interptsn_sponge)
+      ! reset tsa to zero
+      tsa(:,:,:,:) = 0._wp
+
       Agrif_UseSpecialValue = ln_spc_dyn
-      CALL Agrif_Bc_variable(unb_id,calledweight=1.,procname=interpunb)
-      CALL Agrif_Bc_variable(vnb_id,calledweight=1.,procname=interpvnb)
-      CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b)
-      CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b)
-      ubdy_w(:,:) = 0.e0 ; vbdy_w(:,:) = 0.e0
-      ubdy_e(:,:) = 0.e0 ; vbdy_e(:,:) = 0.e0
-      ubdy_n(:,:) = 0.e0 ; vbdy_n(:,:) = 0.e0
-      ubdy_s(:,:) = 0.e0 ; vbdy_s(:,:) = 0.e0
-   ENDIF
-
-   Agrif_UseSpecialValue = .FALSE. 
-   ! reset velocities to zero
-   ua(:,:,:) = 0.
-   va(:,:,:) = 0.
-
-   ! 3. Some controls
-   !-----------------
-   check_namelist = .TRUE.
-
-   IF( check_namelist ) THEN 
-
-      ! Check time steps           
-      IF( NINT(Agrif_Rhot()) * NINT(rdt) .NE. Agrif_Parent(rdt) ) THEN
-         WRITE(cl_check1,*)  NINT(Agrif_Parent(rdt))
-         WRITE(cl_check2,*)  NINT(rdt)
-         WRITE(cl_check3,*)  NINT(Agrif_Parent(rdt)/Agrif_Rhot())
-         CALL ctl_stop( 'Incompatible time step between ocean grids',   &
-               &               'parent grid value : '//cl_check1    ,   & 
-               &               'child  grid value : '//cl_check2    ,   & 
-               &               'value on child grid should be changed to : '//cl_check3 )
-      ENDIF
-
-      ! Check run length
-      IF( Agrif_IRhot() * (Agrif_Parent(nitend)- &
-            Agrif_Parent(nit000)+1) .NE. (nitend-nit000+1) ) THEN
-         WRITE(cl_check1,*)  (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
-         WRITE(cl_check2,*)   Agrif_Parent(nitend)   *Agrif_IRhot()
-         CALL ctl_warn( 'Incompatible run length between grids'                      ,   &
-               &               'nit000 on fine grid will be changed to : '//cl_check1,   &
-               &               'nitend on fine grid will be changed to : '//cl_check2    )
-         nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
-         nitend =  Agrif_Parent(nitend)   *Agrif_IRhot()
-      ENDIF
-
-      ! Check free surface scheme
-      IF ( ( Agrif_Parent(ln_dynspg_ts ).AND.ln_dynspg_exp ).OR.&
-         & ( Agrif_Parent(ln_dynspg_exp).AND.ln_dynspg_ts ) ) THEN
-         WRITE(cl_check1,*)  Agrif_Parent( ln_dynspg_ts )
-         WRITE(cl_check2,*)  ln_dynspg_ts
-         WRITE(cl_check3,*)  Agrif_Parent( ln_dynspg_exp )
-         WRITE(cl_check4,*)  ln_dynspg_exp
-         CALL ctl_stop( 'Incompatible free surface scheme between grids' ,  &
-               &               'parent grid ln_dynspg_ts  :'//cl_check1  ,  & 
-               &               'child  grid ln_dynspg_ts  :'//cl_check2  ,  &
-               &               'parent grid ln_dynspg_exp :'//cl_check3  ,  &
-               &               'child  grid ln_dynspg_exp :'//cl_check4  ,  &
-               &               'those logicals should be identical' )                 
-         STOP
-      ENDIF
-
-      ! Check if identical linear free surface option
-      IF ( ( Agrif_Parent(ln_linssh ).AND.(.NOT.ln_linssh )).OR.&
-         & ( (.NOT.Agrif_Parent(ln_linssh)).AND.ln_linssh ) ) THEN
-         WRITE(cl_check1,*)  Agrif_Parent(ln_linssh )
-         WRITE(cl_check2,*)  ln_linssh
-         CALL ctl_stop( 'Incompatible linearized fs option between grids',  &
-               &               'parent grid ln_linssh  :'//cl_check1     ,  &
-               &               'child  grid ln_linssh  :'//cl_check2     ,  &
-               &               'those logicals should be identical' )                  
-         STOP
-      ENDIF
-
-      ! check if masks and bathymetries match
-      IF(ln_chk_bathy) THEN
+      CALL Agrif_Bc_variable(un_interp_id,calledweight=1.,procname=interpun)
+      CALL Agrif_Bc_variable(vn_interp_id,calledweight=1.,procname=interpvn)
+      tabspongedone_u = .FALSE.
+      tabspongedone_v = .FALSE.
+      CALL Agrif_Bc_variable(un_sponge_id,calledweight=1.,procname=interpun_sponge)
+      tabspongedone_u = .FALSE.
+      tabspongedone_v = .FALSE.
+      CALL Agrif_Bc_variable(vn_sponge_id,calledweight=1.,procname=interpvn_sponge)
+      ua(:,:,:) = 0._wp
+      va(:,:,:) = 0._wp
+
+      Agrif_UseSpecialValue = .TRUE.
+      CALL Agrif_Bc_variable(sshn_id,calledweight=1., procname=interpsshn )
+      hbdy(:,:) = 0._wp
+      ssha(:,:) = 0._wp
+
+      IF ( ln_dynspg_ts ) THEN
+         Agrif_UseSpecialValue = ln_spc_dyn
+         CALL Agrif_Bc_variable(unb_id,calledweight=1.,procname=interpunb)
+         CALL Agrif_Bc_variable(vnb_id,calledweight=1.,procname=interpvnb)
+         CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b)
+         CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b)
+         ubdy(:,:) = 0._wp
+         vbdy(:,:) = 0._wp
+      ENDIF
+
+      Agrif_UseSpecialValue = .FALSE.
+
+      ! 3. Some controls
+      !-----------------
+      check_namelist = .TRUE.
+
+      IF( check_namelist ) THEN 
+
+         ! Check time steps           
+         IF( NINT(Agrif_Rhot()) * NINT(rdt) .NE. Agrif_Parent(rdt) ) THEN
+            WRITE(cl_check1,*)  NINT(Agrif_Parent(rdt))
+            WRITE(cl_check2,*)  NINT(rdt)
+            WRITE(cl_check3,*)  NINT(Agrif_Parent(rdt)/Agrif_Rhot())
+            CALL ctl_stop( 'Incompatible time step between ocean grids',   &
+                  &               'parent grid value : '//cl_check1    ,   & 
+                  &               'child  grid value : '//cl_check2    ,   & 
+                  &               'value on child grid should be changed to : '//cl_check3 )
+         ENDIF
+
+         ! Check run length
+         IF( Agrif_IRhot() * (Agrif_Parent(nitend)- &
+               Agrif_Parent(nit000)+1) .NE. (nitend-nit000+1) ) THEN
+            WRITE(cl_check1,*)  (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
+            WRITE(cl_check2,*)   Agrif_Parent(nitend)   *Agrif_IRhot()
+            CALL ctl_warn( 'Incompatible run length between grids'                      ,   &
+                  &               'nit000 on fine grid will be changed to : '//cl_check1,   &
+                  &               'nitend on fine grid will be changed to : '//cl_check2    )
+            nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
+            nitend =  Agrif_Parent(nitend)   *Agrif_IRhot()
+         ENDIF
+
+         ! Check free surface scheme
+         IF ( ( Agrif_Parent(ln_dynspg_ts ).AND.ln_dynspg_exp ).OR.&
+            & ( Agrif_Parent(ln_dynspg_exp).AND.ln_dynspg_ts ) ) THEN
+            WRITE(cl_check1,*)  Agrif_Parent( ln_dynspg_ts )
+            WRITE(cl_check2,*)  ln_dynspg_ts
+            WRITE(cl_check3,*)  Agrif_Parent( ln_dynspg_exp )
+            WRITE(cl_check4,*)  ln_dynspg_exp
+            CALL ctl_stop( 'Incompatible free surface scheme between grids' ,  &
+                  &               'parent grid ln_dynspg_ts  :'//cl_check1  ,  & 
+                  &               'child  grid ln_dynspg_ts  :'//cl_check2  ,  &
+                  &               'parent grid ln_dynspg_exp :'//cl_check3  ,  &
+                  &               'child  grid ln_dynspg_exp :'//cl_check4  ,  &
+                  &               'those logicals should be identical' )                 
+            STOP
+         ENDIF
+
+         ! Check if identical linear free surface option
+         IF ( ( Agrif_Parent(ln_linssh ).AND.(.NOT.ln_linssh )).OR.&
+            & ( (.NOT.Agrif_Parent(ln_linssh)).AND.ln_linssh ) ) THEN
+            WRITE(cl_check1,*)  Agrif_Parent(ln_linssh )
+            WRITE(cl_check2,*)  ln_linssh
+            CALL ctl_stop( 'Incompatible linearized fs option between grids',  &
+                  &               'parent grid ln_linssh  :'//cl_check1     ,  &
+                  &               'child  grid ln_linssh  :'//cl_check2     ,  &
+                  &               'those logicals should be identical' )                  
+            STOP
+         ENDIF
+
+         ! check if masks and bathymetries match
+         IF(ln_chk_bathy) THEN
+            !
+            IF(lwp) WRITE(numout,*) 'AGRIF: Check Bathymetry and masks near bdys. Level: ', Agrif_Level()
+            !
+            kindic_agr = 0
+            ! check if umask agree with parent along western and eastern boundaries:
+            CALL Agrif_Bc_variable(umsk_id,calledweight=1.,procname=interpumsk)
+            ! check if vmask agree with parent along northern and southern boundaries:
+            CALL Agrif_Bc_variable(vmsk_id,calledweight=1.,procname=interpvmsk)
+            ! check if tmask and vertical scale factors agree with parent over first two coarse grid points:
+            CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t)
+            !
+            CALL mpp_sum( 'agrif_user', kindic_agr )
+            IF( kindic_agr /= 0 ) THEN
+               CALL ctl_stop('Child Bathymetry is not correct near boundaries.')
+            ELSE
+               IF(lwp) WRITE(numout,*) 'Child Bathymetry is ok near boundaries.'
+            END IF
+         ENDIF
          !
-         IF(lwp) WRITE(numout,*) 'AGRIF: Check Bathymetry and masks near bdys. Level: ', Agrif_Level()
-         !
-         kindic_agr = 0
-         ! check if umask agree with parent along western and eastern boundaries:
-         CALL Agrif_Bc_variable(umsk_id,calledweight=1.,procname=interpumsk)
-         ! check if vmask agree with parent along northern and southern boundaries:
-         CALL Agrif_Bc_variable(vmsk_id,calledweight=1.,procname=interpvmsk)
-         ! check if tmask and vertical scale factors agree with parent over first two coarse grid points:
-         CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t)
-         !
-         CALL mpp_sum( 'agrif_user', kindic_agr )
-         IF( kindic_agr /= 0 ) THEN
-            CALL ctl_stop('Child Bathymetry is not correct near boundaries.')
-         ELSE
-            IF(lwp) WRITE(numout,*) 'Child Bathymetry is ok near boundaries.'
-         END IF
-      ENDIF
-      !
-   ENDIF
-   ! 
-END SUBROUTINE Agrif_InitValues_cont
-
-SUBROUTINE agrif_declare_var
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE agrif_declarE_var ***
-      !!
-      !! ** Purpose :: Declaration of variables to be interpolated
-      !!----------------------------------------------------------------------
-   USE agrif_util
-   USE agrif_oce
-   USE par_oce       ! ocean parameters
-   USE zdf_oce       ! vertical physics
-   USE oce
-   !
-   IMPLICIT NONE
-   !
-   INTEGER :: ind1, ind2, ind3
-      !!----------------------------------------------------------------------
-
-   ! 1. Declaration of the type of variable which have to be interpolated
-   !---------------------------------------------------------------------
-   ind1 =     nbghostcells
-   ind2 = 1 + nbghostcells
-   ind3 = 2 + nbghostcells
+      ENDIF
+      ! 
+   END SUBROUTINE Agrif_InitValues_cont
+
+   SUBROUTINE agrif_declare_var
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE agrif_declare_var ***
+      !!----------------------------------------------------------------------
+      USE agrif_util
+      USE agrif_oce
+      USE par_oce
+      USE zdf_oce 
+      USE oce
+      !
+      IMPLICIT NONE
+      !
+      INTEGER :: ind1, ind2, ind3
+      !!----------------------------------------------------------------------
+
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      ind1 =     nbghostcells
+      ind2 = 1 + nbghostcells
+      ind3 = 2 + nbghostcells
 # if defined key_vertical
-   CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts+1/),tsn_id)
-   CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts+1/),tsn_sponge_id)
-
-   CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_interp_id)
-   CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_interp_id)
-   CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_update_id)
-   CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_update_id)
-   CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_sponge_id)
-   CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_sponge_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts+1/),tsn_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts+1/),tsn_sponge_id)
+
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_interp_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_interp_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_update_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_update_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_sponge_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_sponge_id)
 # else
-   CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_id)
-   CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_sponge_id)
-
-   CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_interp_id)
-   CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_interp_id)
-   CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_update_id)
-   CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_update_id)
-   CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_sponge_id)
-   CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_sponge_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_sponge_id)
+
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_interp_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_interp_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_update_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_update_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_sponge_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_sponge_id)
 # endif
 
-   CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),e3t_id)
-   CALL agrif_declare_variable((/1,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),umsk_id)
-   CALL agrif_declare_variable((/2,1,0/),(/ind3,ind2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vmsk_id)
-
-   CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,3/),scales_t_id)
-
-   CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),unb_id)
-   CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vnb_id)
-   CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_interp_id)
-   CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_interp_id)
-   CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_update_id)
-   CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_update_id)
-
-   CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),sshn_id)
-
-   IF( ln_zdftke.OR.ln_zdfgls ) THEN
-!      CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/), en_id)
-!      CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),avt_id)
+      CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),e3t_id)
+      CALL agrif_declare_variable((/1,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),umsk_id)
+      CALL agrif_declare_variable((/2,1,0/),(/ind3,ind2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vmsk_id)
+
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,3/),scales_t_id)
+
+      CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),unb_id)
+      CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vnb_id)
+      CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_interp_id)
+      CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_interp_id)
+      CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_update_id)
+      CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_update_id)
+
+      CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),sshn_id)
+
+      IF( ln_zdftke.OR.ln_zdfgls ) THEN
+!         CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/), en_id)
+!         CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),avt_id)
 # if defined key_vertical
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),avm_id)
+         CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),avm_id)
 # else
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),avm_id)
+         CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),avm_id)
 # endif
-   ENDIF
-
-   ! 2. Type of interpolation
-   !-------------------------
-   CALL Agrif_Set_bcinterp(tsn_id,interp=AGRIF_linear)
-
-   CALL Agrif_Set_bcinterp(un_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
-   CALL Agrif_Set_bcinterp(vn_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
-
-   CALL Agrif_Set_bcinterp(tsn_sponge_id,interp=AGRIF_linear)
-
-   CALL Agrif_Set_bcinterp(sshn_id,interp=AGRIF_linear)
-   CALL Agrif_Set_bcinterp(unb_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
-   CALL Agrif_Set_bcinterp(vnb_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
-   CALL Agrif_Set_bcinterp(ub2b_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
-   CALL Agrif_Set_bcinterp(vb2b_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
-
-
-   CALL Agrif_Set_bcinterp(un_sponge_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
-   CALL Agrif_Set_bcinterp(vn_sponge_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
-
-   CALL Agrif_Set_bcinterp(e3t_id,interp=AGRIF_constant)
-   CALL Agrif_Set_bcinterp(umsk_id,interp=AGRIF_constant)
-   CALL Agrif_Set_bcinterp(vmsk_id,interp=AGRIF_constant)
-
-   IF( ln_zdftke.OR.ln_zdfgls )   CALL Agrif_Set_bcinterp( avm_id, interp=AGRIF_linear )
-
-   ! 3. Location of interpolation
-   !-----------------------------
-   CALL Agrif_Set_bc(       tsn_id, (/0,ind1/) )
-   CALL Agrif_Set_bc( un_interp_id, (/0,ind1/) )
-   CALL Agrif_Set_bc( vn_interp_id, (/0,ind1/) )
-
-   CALL Agrif_Set_bc( tsn_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) )  ! if west and rhox=3 and sponge=2 and ghost=1: columns 2 to 9 
-   CALL Agrif_Set_bc(  un_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) )
-   CALL Agrif_Set_bc(  vn_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) )
-
-   CALL Agrif_Set_bc(        sshn_id, (/0,ind1-1/) )
-   CALL Agrif_Set_bc(         unb_id, (/0,ind1-1/) )
-   CALL Agrif_Set_bc(         vnb_id, (/0,ind1-1/) )
-   CALL Agrif_Set_bc( ub2b_interp_id, (/0,ind1-1/) )
-   CALL Agrif_Set_bc( vb2b_interp_id, (/0,ind1-1/) )
-
-   CALL Agrif_Set_bc(  e3t_id, (/-nn_sponge_len*Agrif_irhox(),ind1-1/) )   ! if west and rhox=3 and ghost=1: column 2 to 6 
-   CALL Agrif_Set_bc( umsk_id, (/0,0/) )
-   CALL Agrif_Set_bc( vmsk_id, (/0,0/) )
-
-
-   IF( ln_zdftke.OR.ln_zdfgls )   CALL Agrif_Set_bc( avm_id, (/0,ind1/) )
-
-   ! 4. Update type
-   !--------------- 
-   CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average)
+      ENDIF
+
+      ! 2. Type of interpolation
+      !-------------------------
+      CALL Agrif_Set_bcinterp(tsn_id,interp=AGRIF_linear)
+
+      CALL Agrif_Set_bcinterp(un_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      CALL Agrif_Set_bcinterp(vn_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+      CALL Agrif_Set_bcinterp(tsn_sponge_id,interp=AGRIF_linear)
+
+      CALL Agrif_Set_bcinterp(sshn_id,interp=AGRIF_linear)
+      CALL Agrif_Set_bcinterp(unb_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      CALL Agrif_Set_bcinterp(vnb_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
+      CALL Agrif_Set_bcinterp(ub2b_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      CALL Agrif_Set_bcinterp(vb2b_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+
+      CALL Agrif_Set_bcinterp(un_sponge_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      CALL Agrif_Set_bcinterp(vn_sponge_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+      CALL Agrif_Set_bcinterp(e3t_id,interp=AGRIF_constant)
+      CALL Agrif_Set_bcinterp(umsk_id,interp=AGRIF_constant)
+      CALL Agrif_Set_bcinterp(vmsk_id,interp=AGRIF_constant)
+
+      IF( ln_zdftke.OR.ln_zdfgls )   CALL Agrif_Set_bcinterp( avm_id, interp=AGRIF_linear )
+
+      ! 3. Location of interpolation
+      !-----------------------------
+      CALL Agrif_Set_bc(       tsn_id, (/0,ind1/) )
+      CALL Agrif_Set_bc( un_interp_id, (/0,ind1/) )
+      CALL Agrif_Set_bc( vn_interp_id, (/0,ind1/) )
+
+      CALL Agrif_Set_bc( tsn_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) )  ! if west and rhox=3 and sponge=2 and ghost=1: columns 2 to 9 
+      CALL Agrif_Set_bc(  un_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) )
+      CALL Agrif_Set_bc(  vn_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) )
+
+      CALL Agrif_Set_bc(        sshn_id, (/0,ind1-1/) )
+      CALL Agrif_Set_bc(         unb_id, (/0,ind1-1/) )
+      CALL Agrif_Set_bc(         vnb_id, (/0,ind1-1/) )
+      CALL Agrif_Set_bc( ub2b_interp_id, (/0,ind1-1/) )
+      CALL Agrif_Set_bc( vb2b_interp_id, (/0,ind1-1/) )
+
+      CALL Agrif_Set_bc(  e3t_id, (/-nn_sponge_len*Agrif_irhox(),ind1-1/) )   ! if west and rhox=3 and ghost=1: column 2 to 6 
+      CALL Agrif_Set_bc( umsk_id, (/0,0/) )
+      CALL Agrif_Set_bc( vmsk_id, (/0,0/) )
+
+
+      IF( ln_zdftke.OR.ln_zdfgls )   CALL Agrif_Set_bc( avm_id, (/0,ind1/) )
+
+      ! 4. Update type
+      !--------------- 
+      CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average)
 
 # if defined UPD_HIGH
-   CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting)
-   CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting)
-   CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average)
-
-   CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting)
-   CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average)
-   CALL Agrif_Set_Updatetype(sshn_id, update = Agrif_Update_Full_Weighting)
-   CALL Agrif_Set_Updatetype(e3t_id, update = Agrif_Update_Full_Weighting)
-
-   IF( ln_zdftke.OR.ln_zdfgls ) THEN
-!      CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Full_Weighting)
-!      CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Full_Weighting)
-!      CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Full_Weighting)
-   ENDIF
+      CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting)
+      CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting)
+      CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average)
+
+      CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting)
+      CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average)
+      CALL Agrif_Set_Updatetype(sshn_id,update = Agrif_Update_Full_Weighting)
+      CALL Agrif_Set_Updatetype(e3t_id, update = Agrif_Update_Full_Weighting)
+
+      IF( ln_zdftke.OR.ln_zdfgls ) THEN
+!         CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Full_Weighting)
+!         CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Full_Weighting)
+!         CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Full_Weighting)
+      ENDIF
 
 #else
-   CALL Agrif_Set_Updatetype(tsn_id, update = AGRIF_Update_Average)
-   CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
-   CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
-
-   CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
-   CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
-   CALL Agrif_Set_Updatetype(sshn_id, update = AGRIF_Update_Average)
-   CALL Agrif_Set_Updatetype(e3t_id, update = AGRIF_Update_Average)
-
-   IF( ln_zdftke.OR.ln_zdfgls ) THEN
-!      CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Average)
-!      CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Average)
-!      CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Average)
-   ENDIF
+      CALL Agrif_Set_Updatetype(tsn_id, update = AGRIF_Update_Average)
+      CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
+      CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
+
+      CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
+      CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
+      CALL Agrif_Set_Updatetype(sshn_id,update = AGRIF_Update_Average)
+      CALL Agrif_Set_Updatetype(e3t_id, update = AGRIF_Update_Average)
+
+      IF( ln_zdftke.OR.ln_zdfgls ) THEN
+!         CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Average)
+!         CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Average)
+!         CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Average)
+      ENDIF
 
 #endif
-   !
-END SUBROUTINE agrif_declare_var
+      !
+   END SUBROUTINE agrif_declare_var
 
 #if defined key_si3
@@ -453,152 +389,143 @@
       !!----------------------------------------------------------------------
       !!                 *** ROUTINE Agrif_InitValues_cont_ice ***
+      !!----------------------------------------------------------------------
+      USE Agrif_Util
+      USE sbc_oce, ONLY : nn_fsbc  ! clem: necessary otherwise Agrif_Parent(nn_fsbc) = nn_fsbc
+      USE ice
+      USE agrif_ice
+      USE in_out_manager
+      USE agrif_ice_interp
+      USE lib_mpp
+      !
+      IMPLICIT NONE
+      !!----------------------------------------------------------------------
+      !
+      ! Declaration of the type of variable which have to be interpolated (parent=>child)
+      !----------------------------------------------------------------------------------
+      CALL agrif_declare_var_ice
+
+      ! Controls
+
+      ! clem: For some reason, nn_fsbc(child)/=1 does not work properly (signal can be largely degraded by the agrif zoom)
+      !          the run must satisfy CFL=Uice/(dx/dt) < 0.6/nn_fsbc(child)
+      !          therefore, if nn_fsbc(child)>1 one must reduce the time-step in proportion to nn_fsbc(child), which is not acceptable
+      !       If a solution is found, the following stop could be removed because the rest of the code take nn_fsbc(child) into account
+      IF( nn_fsbc > 1 )  CALL ctl_stop('nn_fsbc(child) must be set to 1 otherwise agrif and sea-ice may not work properly')
+
+      ! stop if rhot * nn_fsbc(parent) /= N * nn_fsbc(child) with N being integer
+      IF( MOD( Agrif_irhot() * Agrif_Parent(nn_fsbc), nn_fsbc ) /= 0 )  THEN
+         CALL ctl_stop('rhot * nn_fsbc(parent) /= N * nn_fsbc(child), therefore nn_fsbc(child) should be set to 1 or nn_fsbc(parent)')
+      ENDIF
+      ! First Interpolations (using "after" ice subtime step => nbstep_ice=1)
+      !----------------------------------------------------------------------
+      nbstep_ice = ( Agrif_irhot() * Agrif_Parent(nn_fsbc) / nn_fsbc ) ! clem: to have calledweight=1 in interp (otherwise the western border of the zoom is wrong)
+      CALL agrif_interp_ice('U') ! interpolation of ice velocities
+      CALL agrif_interp_ice('V') ! interpolation of ice velocities
+      CALL agrif_interp_ice('T') ! interpolation of ice tracers 
+      nbstep_ice = 0   
+      !
+   END SUBROUTINE Agrif_InitValues_cont_ice
+
+   SUBROUTINE agrif_declare_var_ice
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE agrif_declare_var_ice ***
+      !!----------------------------------------------------------------------
+      USE Agrif_Util
+      USE ice
+      USE par_oce, ONLY : nbghostcells
+      !
+      IMPLICIT NONE
+      !
+      INTEGER :: ind1, ind2, ind3
+      !!----------------------------------------------------------------------
+      !
+      ! 1. Declaration of the type of variable which have to be interpolated (parent=>child)
+      !       agrif_declare_variable(position,1st point index,--,--,dimensions,name)
+      !           ex.:  position=> 1,1 = not-centered (in i and j)
+      !                            2,2 =     centered (    -     )
+      !                 index   => 1,1 = one ghost line
+      !                            2,2 = two ghost lines
+      !-------------------------------------------------------------------------------------
+      ind1 =     nbghostcells
+      ind2 = 1 + nbghostcells
+      ind3 = 2 + nbghostcells
+      CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpl*(8+nlay_s+nlay_i)/),tra_ice_id)
+      CALL agrif_declare_variable((/1,2/)  ,(/ind2,ind3/)  ,(/'x','y'/)    ,(/1,1/)  ,(/nlci,nlcj/)                      ,u_ice_id  )
+      CALL agrif_declare_variable((/2,1/)  ,(/ind3,ind2/)  ,(/'x','y'/)    ,(/1,1/)  ,(/nlci,nlcj/)                      ,v_ice_id  )
+
+      ! 2. Set interpolations (normal & tangent to the grid cell for velocities)
+      !-----------------------------------
+      CALL Agrif_Set_bcinterp(tra_ice_id, interp  = AGRIF_linear)
+      CALL Agrif_Set_bcinterp(u_ice_id  , interp1 = Agrif_linear,interp2 = AGRIF_ppm   )
+      CALL Agrif_Set_bcinterp(v_ice_id  , interp1 = AGRIF_ppm   ,interp2 = Agrif_linear)
+
+      ! 3. Set location of interpolations
+      !----------------------------------
+      CALL Agrif_Set_bc(tra_ice_id,(/0,ind1/))
+      CALL Agrif_Set_bc(u_ice_id  ,(/0,ind1/))
+      CALL Agrif_Set_bc(v_ice_id  ,(/0,ind1/))
+
+      ! 4. Set update type in case 2 ways (child=>parent) (normal & tangent to the grid cell for velocities)
+      !--------------------------------------------------
+# if defined UPD_HIGH
+      CALL Agrif_Set_Updatetype(tra_ice_id, update  = Agrif_Update_Full_Weighting)
+      CALL Agrif_Set_Updatetype(u_ice_id  , update1 = Agrif_Update_Average       , update2 = Agrif_Update_Full_Weighting)
+      CALL Agrif_Set_Updatetype(v_ice_id  , update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average       )
+#else
+      CALL Agrif_Set_Updatetype(tra_ice_id, update  = AGRIF_Update_Average)
+      CALL Agrif_Set_Updatetype(u_ice_id  , update1 = Agrif_Update_Copy   , update2 = Agrif_Update_Average)
+      CALL Agrif_Set_Updatetype(v_ice_id  , update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy   )
+#endif
+
+   END SUBROUTINE agrif_declare_var_ice
+#endif
+
+
+# if defined key_top
+   SUBROUTINE Agrif_InitValues_cont_top
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues_cont_top ***
+      !!----------------------------------------------------------------------
+      USE Agrif_Util
+      USE oce 
+      USE dom_oce
+      USE nemogcm
+      USE par_trc
+      USE lib_mpp
+      USE trc
+      USE in_out_manager
+      USE agrif_oce_sponge
+      USE agrif_top_update
+      USE agrif_top_interp
+      USE agrif_top_sponge
       !!
-      !! ** Purpose :: Initialisation of variables to be interpolated for ice
-      !!----------------------------------------------------------------------
-   USE Agrif_Util
-   USE sbc_oce, ONLY : nn_fsbc  ! clem: necessary otherwise Agrif_Parent(nn_fsbc) = nn_fsbc
-   USE ice
-   USE agrif_ice
-   USE in_out_manager
-   USE agrif_ice_interp
-   USE lib_mpp
-   !
-   IMPLICIT NONE
-      !!----------------------------------------------------------------------
-   !
-   ! Declaration of the type of variable which have to be interpolated (parent=>child)
-   !----------------------------------------------------------------------------------
-   CALL agrif_declare_var_ice
-
-   ! Controls
-
-   ! clem: For some reason, nn_fsbc(child)/=1 does not work properly (signal can be largely degraded by the agrif zoom)
-   !          the run must satisfy CFL=Uice/(dx/dt) < 0.6/nn_fsbc(child)
-   !          therefore, if nn_fsbc(child)>1 one must reduce the time-step in proportion to nn_fsbc(child), which is not acceptable
-   !       If a solution is found, the following stop could be removed because the rest of the code take nn_fsbc(child) into account
-   IF( nn_fsbc > 1 )  CALL ctl_stop('nn_fsbc(child) must be set to 1 otherwise agrif and sea-ice may not work properly')
-
-   ! stop if rhot * nn_fsbc(parent) /= N * nn_fsbc(child) with N being integer
-   IF( MOD( Agrif_irhot() * Agrif_Parent(nn_fsbc), nn_fsbc ) /= 0 )  THEN
-      CALL ctl_stop('rhot * nn_fsbc(parent) /= N * nn_fsbc(child), therefore nn_fsbc(child) should be set to 1 or nn_fsbc(parent)')
-   ENDIF
-   ! First Interpolations (using "after" ice subtime step => nbstep_ice=1)
-   !----------------------------------------------------------------------
-   nbstep_ice = ( Agrif_irhot() * Agrif_Parent(nn_fsbc) / nn_fsbc ) ! clem: to have calledweight=1 in interp (otherwise the western border of the zoom is wrong)
-   CALL agrif_interp_ice('U') ! interpolation of ice velocities
-   CALL agrif_interp_ice('V') ! interpolation of ice velocities
-   CALL agrif_interp_ice('T') ! interpolation of ice tracers 
-   nbstep_ice = 0
-   
-   !
-END SUBROUTINE Agrif_InitValues_cont_ice
-
-SUBROUTINE agrif_declare_var_ice
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE agrif_declare_var_ice ***
-      !!
-      !! ** Purpose :: Declaration of variables to be interpolated for ice
-      !!----------------------------------------------------------------------
-   USE Agrif_Util
-   USE ice
-   USE par_oce, ONLY : nbghostcells
-   !
-   IMPLICIT NONE
-   !
-   INTEGER :: ind1, ind2, ind3
-      !!----------------------------------------------------------------------
-   !
-   ! 1. Declaration of the type of variable which have to be interpolated (parent=>child)
-   !       agrif_declare_variable(position,1st point index,--,--,dimensions,name)
-   !           ex.:  position=> 1,1 = not-centered (in i and j)
-   !                            2,2 =     centered (    -     )
-   !                 index   => 1,1 = one ghost line
-   !                            2,2 = two ghost lines
-   !-------------------------------------------------------------------------------------
-   ind1 =     nbghostcells
-   ind2 = 1 + nbghostcells
-   ind3 = 2 + nbghostcells
-   CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpl*(8+nlay_s+nlay_i)/),tra_ice_id)
-   CALL agrif_declare_variable((/1,2/)  ,(/ind2,ind3/)  ,(/'x','y'/)    ,(/1,1/)  ,(/nlci,nlcj/)                      ,u_ice_id  )
-   CALL agrif_declare_variable((/2,1/)  ,(/ind3,ind2/)  ,(/'x','y'/)    ,(/1,1/)  ,(/nlci,nlcj/)                      ,v_ice_id  )
-
-   ! 2. Set interpolations (normal & tangent to the grid cell for velocities)
-   !-----------------------------------
-   CALL Agrif_Set_bcinterp(tra_ice_id, interp  = AGRIF_linear)
-   CALL Agrif_Set_bcinterp(u_ice_id  , interp1 = Agrif_linear,interp2 = AGRIF_ppm   )
-   CALL Agrif_Set_bcinterp(v_ice_id  , interp1 = AGRIF_ppm   ,interp2 = Agrif_linear)
-
-   ! 3. Set location of interpolations
-   !----------------------------------
-   CALL Agrif_Set_bc(tra_ice_id,(/0,ind1/))
-   CALL Agrif_Set_bc(u_ice_id  ,(/0,ind1/))
-   CALL Agrif_Set_bc(v_ice_id  ,(/0,ind1/))
-
-   ! 4. Set update type in case 2 ways (child=>parent) (normal & tangent to the grid cell for velocities)
-   !--------------------------------------------------
-# if defined UPD_HIGH
-   CALL Agrif_Set_Updatetype(tra_ice_id, update  = Agrif_Update_Full_Weighting)
-   CALL Agrif_Set_Updatetype(u_ice_id  , update1 = Agrif_Update_Average       , update2 = Agrif_Update_Full_Weighting)
-   CALL Agrif_Set_Updatetype(v_ice_id  , update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average       )
-#else
-   CALL Agrif_Set_Updatetype(tra_ice_id, update  = AGRIF_Update_Average)
-   CALL Agrif_Set_Updatetype(u_ice_id  , update1 = Agrif_Update_Copy   , update2 = Agrif_Update_Average)
-   CALL Agrif_Set_Updatetype(v_ice_id  , update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy   )
-#endif
-
-END SUBROUTINE agrif_declare_var_ice
-#endif
-
-
-# if defined key_top
-SUBROUTINE Agrif_InitValues_cont_top
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE Agrif_InitValues_cont_top ***
-      !!
-      !! ** Purpose :: Declaration of variables to be interpolated
-      !!----------------------------------------------------------------------
-   USE Agrif_Util
-   USE oce 
-   USE dom_oce
-   USE nemogcm
-   USE par_trc
-   USE lib_mpp
-   USE trc
-   USE in_out_manager
-   USE agrif_oce_sponge
-   USE agrif_top_update
-   USE agrif_top_interp
-   USE agrif_top_sponge
-   !!
-   IMPLICIT NONE
-   !
-   CHARACTER(len=10) :: cl_check1, cl_check2, cl_check3
-   LOGICAL :: check_namelist
-      !!----------------------------------------------------------------------
-
-
-   ! 1. Declaration of the type of variable which have to be interpolated
-   !---------------------------------------------------------------------
-   CALL agrif_declare_var_top
-
-   ! 2. First interpolations of potentially non zero fields
-   !-------------------------------------------------------
-   Agrif_SpecialValue=0.
-   Agrif_UseSpecialValue = .TRUE.
-   CALL Agrif_Bc_variable(trn_id,calledweight=1.,procname=interptrn)
-   Agrif_UseSpecialValue = .FALSE.
-   CALL Agrif_Sponge
-   tabspongedone_trn = .FALSE.
-   CALL Agrif_Bc_variable(trn_sponge_id,calledweight=1.,procname=interptrn_sponge)
-   ! reset tsa to zero
-   tra(:,:,:,:) = 0.
-
-
-   ! 3. Some controls
-   !-----------------
-   check_namelist = .TRUE.
-
-   IF( check_namelist ) THEN
-      ! Check time steps
+      IMPLICIT NONE
+      !
+      CHARACTER(len=10) :: cl_check1, cl_check2, cl_check3
+      LOGICAL :: check_namelist
+      !!----------------------------------------------------------------------
+
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      CALL agrif_declare_var_top
+
+      ! 2. First interpolations of potentially non zero fields
+      !-------------------------------------------------------
+      Agrif_SpecialValue=0._wp
+      Agrif_UseSpecialValue = .TRUE.
+      CALL Agrif_Bc_variable(trn_id,calledweight=1.,procname=interptrn)
+      Agrif_UseSpecialValue = .FALSE.
+      CALL Agrif_Sponge
+      tabspongedone_trn = .FALSE.
+      CALL Agrif_Bc_variable(trn_sponge_id,calledweight=1.,procname=interptrn_sponge)
+      ! reset tsa to zero
+      tra(:,:,:,:) = 0._wp
+
+      ! 3. Some controls
+      !-----------------
+      check_namelist = .TRUE.
+
+      IF( check_namelist ) THEN
+         ! Check time steps
       IF( NINT(Agrif_Rhot()) * NINT(rdt) .NE. Agrif_Parent(rdt) ) THEN
          WRITE(cl_check1,*)  Agrif_Parent(rdt)
@@ -630,187 +557,174 @@
    ENDIF
    !
-END SUBROUTINE Agrif_InitValues_cont_top
-
-
-SUBROUTINE agrif_declare_var_top
+   END SUBROUTINE Agrif_InitValues_cont_top
+
+
+   SUBROUTINE agrif_declare_var_top
       !!----------------------------------------------------------------------
       !!                 *** ROUTINE agrif_declare_var_top ***
+      !!----------------------------------------------------------------------
+      USE agrif_util
+      USE agrif_oce
+      USE dom_oce
+      USE trc
       !!
-      !! ** Purpose :: Declaration of TOP variables to be interpolated
-      !!----------------------------------------------------------------------
-   USE agrif_util
-   USE agrif_oce
-   USE dom_oce
-   USE trc
-   !!
-   IMPLICIT NONE
-   !
-   INTEGER :: ind1, ind2, ind3
-      !!----------------------------------------------------------------------
-
-   ! 1. Declaration of the type of variable which have to be interpolated
-   !---------------------------------------------------------------------
-   ind1 =     nbghostcells
-   ind2 = 1 + nbghostcells
-   ind3 = 2 + nbghostcells
+      IMPLICIT NONE
+      !
+      INTEGER :: ind1, ind2, ind3
+      !!----------------------------------------------------------------------
+
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      ind1 =     nbghostcells
+      ind2 = 1 + nbghostcells
+      ind3 = 2 + nbghostcells
 # if defined key_vertical
-   CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra+1/),trn_id)
-   CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra+1/),trn_sponge_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra+1/),trn_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra+1/),trn_sponge_id)
 # else
-   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_id)
-   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_sponge_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_sponge_id)
 # endif
 
-   ! 2. Type of interpolation
-   !-------------------------
-   CALL Agrif_Set_bcinterp(trn_id,interp=AGRIF_linear)
-   CALL Agrif_Set_bcinterp(trn_sponge_id,interp=AGRIF_linear)
-
-   ! 3. Location of interpolation
-   !-----------------------------
-   CALL Agrif_Set_bc(trn_id,(/0,ind1/))
-   CALL Agrif_Set_bc(trn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/))
-
-   ! 4. Update type
-   !--------------- 
+      ! 2. Type of interpolation
+      !-------------------------
+      CALL Agrif_Set_bcinterp(trn_id,interp=AGRIF_linear)
+      CALL Agrif_Set_bcinterp(trn_sponge_id,interp=AGRIF_linear)
+
+      ! 3. Location of interpolation
+      !-----------------------------
+      CALL Agrif_Set_bc(trn_id,(/0,ind1/))
+      CALL Agrif_Set_bc(trn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/))
+
+      ! 4. Update type
+      !--------------- 
 # if defined UPD_HIGH
-   CALL Agrif_Set_Updatetype(trn_id, update = Agrif_Update_Full_Weighting)
+      CALL Agrif_Set_Updatetype(trn_id, update = Agrif_Update_Full_Weighting)
 #else
-   CALL Agrif_Set_Updatetype(trn_id, update = AGRIF_Update_Average)
+      CALL Agrif_Set_Updatetype(trn_id, update = AGRIF_Update_Average)
 #endif
    !
-END SUBROUTINE agrif_declare_var_top
+   END SUBROUTINE agrif_declare_var_top
 # endif
 
-SUBROUTINE Agrif_detect( kg, ksizex )
+   SUBROUTINE Agrif_detect( kg, ksizex )
       !!----------------------------------------------------------------------
       !!                      *** ROUTINE Agrif_detect ***
       !!----------------------------------------------------------------------
-   INTEGER, DIMENSION(2) :: ksizex
-   INTEGER, DIMENSION(ksizex(1),ksizex(2)) :: kg 
-      !!----------------------------------------------------------------------
-   !
-   RETURN
-   !
-END SUBROUTINE Agrif_detect
-
-
-SUBROUTINE agrif_nemo_init
+      INTEGER, DIMENSION(2) :: ksizex
+      INTEGER, DIMENSION(ksizex(1),ksizex(2)) :: kg 
+      !!----------------------------------------------------------------------
+      !
+      RETURN
+      !
+   END SUBROUTINE Agrif_detect
+
+   SUBROUTINE agrif_nemo_init
       !!----------------------------------------------------------------------
       !!                     *** ROUTINE agrif_init ***
       !!----------------------------------------------------------------------
-   USE agrif_oce 
-   USE agrif_ice
-   USE in_out_manager
-   USE lib_mpp
-   !!
-   IMPLICIT NONE
-   !
-   INTEGER  ::   ios                 ! Local integer output status for namelist read
-   INTEGER  ::   iminspon
-   NAMELIST/namagrif/ rn_sponge_tra, rn_sponge_dyn, ln_spc_dyn, ln_chk_bathy
+      USE agrif_oce 
+      USE agrif_ice
+      USE in_out_manager
+      USE lib_mpp
+      !!
+      IMPLICIT NONE
+      !
+      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      NAMELIST/namagrif/ ln_agrif_2way, rn_sponge_tra, rn_sponge_dyn, ln_spc_dyn, ln_chk_bathy
       !!--------------------------------------------------------------------------------------
-   !
-   REWIND( numnam_ref )              ! Namelist namagrif in reference namelist : AGRIF zoom
-   READ  ( numnam_ref, namagrif, IOSTAT = ios, ERR = 901)
+      !
+      REWIND( numnam_ref )              ! Namelist namagrif in reference namelist : AGRIF zoom
+      READ  ( numnam_ref, namagrif, IOSTAT = ios, ERR = 901)
 901 IF( ios /= 0 )   CALL ctl_nam ( ios , 'namagrif in reference namelist' )
-   REWIND( numnam_cfg )              ! Namelist namagrif in configuration namelist : AGRIF zoom
-   READ  ( numnam_cfg, namagrif, IOSTAT = ios, ERR = 902 )
+      REWIND( numnam_cfg )              ! Namelist namagrif in configuration namelist : AGRIF zoom
+      READ  ( numnam_cfg, namagrif, IOSTAT = ios, ERR = 902 )
 902 IF( ios >  0 )   CALL ctl_nam ( ios , 'namagrif in configuration namelist' )
-   IF(lwm) WRITE ( numond, namagrif )
-   !
-   IF(lwp) THEN                    ! control print
-      WRITE(numout,*)
-      WRITE(numout,*) 'agrif_nemo_init : AGRIF parameters'
-      WRITE(numout,*) '~~~~~~~~~~~~~~~'
-      WRITE(numout,*) '   Namelist namagrif : set AGRIF parameters'
-      WRITE(numout,*) '      sponge coefficient for tracers    rn_sponge_tra = ', rn_sponge_tra, ' s'
-      WRITE(numout,*) '      sponge coefficient for dynamics   rn_sponge_tra = ', rn_sponge_dyn, ' s'
-      WRITE(numout,*) '      use special values for dynamics   ln_spc_dyn    = ', ln_spc_dyn
-      WRITE(numout,*) '      check bathymetry                  ln_chk_bathy  = ', ln_chk_bathy
-   ENDIF
-   !
-   ! convert DOCTOR namelist name into OLD names
-   visc_tra      = rn_sponge_tra
-   visc_dyn      = rn_sponge_dyn
-   !
-   ! Check sponge length:
-   iminspon = MIN(FLOOR(REAL(jpiglo-4)/REAL(2*Agrif_irhox())), FLOOR(REAL(jpjglo-4)/REAL(2*Agrif_irhox())) )
-   IF (lk_mpp) iminspon = MIN(iminspon,FLOOR(REAL(jpi-2)/REAL(Agrif_irhox())), FLOOR(REAL(jpj-2)/REAL(Agrif_irhox())) )
-   IF (nn_sponge_len > iminspon)  CALL ctl_stop('agrif sponge length is too large')
-   !
-   IF( agrif_oce_alloc()  > 0 )   CALL ctl_warn('agrif agrif_oce_alloc: allocation of arrays failed')
-   !
-END SUBROUTINE agrif_nemo_init
+      IF(lwm) WRITE ( numond, namagrif )
+      !
+      IF(lwp) THEN                    ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'agrif_nemo_init : AGRIF parameters'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namagrif : set AGRIF parameters'
+         WRITE(numout,*) '      Two way nesting activated ln_agrif_2way         = ', ln_agrif_2way
+         WRITE(numout,*) '      sponge coefficient for tracers    rn_sponge_tra = ', rn_sponge_tra, ' m^2/s'
+         WRITE(numout,*) '      sponge coefficient for dynamics   rn_sponge_tra = ', rn_sponge_dyn, ' m^2/s'
+         WRITE(numout,*) '      use special values for dynamics   ln_spc_dyn    = ', ln_spc_dyn
+         WRITE(numout,*) '      check bathymetry                  ln_chk_bathy  = ', ln_chk_bathy
+      ENDIF
+      !
+      !
+      IF( agrif_oce_alloc()  > 0 )   CALL ctl_warn('agrif agrif_oce_alloc: allocation of arrays failed')
+      !
+   END SUBROUTINE agrif_nemo_init
 
 # if defined key_mpp_mpi
 
-SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob )
+   SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob )
       !!----------------------------------------------------------------------
       !!                     *** ROUTINE Agrif_InvLoc ***
       !!----------------------------------------------------------------------
-   USE dom_oce
-   !!
-   IMPLICIT NONE
-   !
-   INTEGER :: indglob, indloc, nprocloc, i
-      !!----------------------------------------------------------------------
-   !
-   SELECT CASE( i )
-   CASE(1)   ;   indglob = indloc + nimppt(nprocloc+1) - 1
-   CASE(2)   ;   indglob = indloc + njmppt(nprocloc+1) - 1
-   CASE DEFAULT
-      indglob = indloc
-   END SELECT
-   !
-END SUBROUTINE Agrif_InvLoc
-
-
-SUBROUTINE Agrif_get_proc_info( imin, imax, jmin, jmax )
+      USE dom_oce
+      !!
+      IMPLICIT NONE
+      !
+      INTEGER :: indglob, indloc, nprocloc, i
+      !!----------------------------------------------------------------------
+      !
+      SELECT CASE( i )
+      CASE(1)   ;   indglob = indloc + nimppt(nprocloc+1) - 1
+      CASE(2)   ;   indglob = indloc + njmppt(nprocloc+1) - 1
+      CASE DEFAULT
+         indglob = indloc
+      END SELECT
+      !
+   END SUBROUTINE Agrif_InvLoc
+
+   SUBROUTINE Agrif_get_proc_info( imin, imax, jmin, jmax )
       !!----------------------------------------------------------------------
       !!                 *** ROUTINE Agrif_get_proc_info ***
       !!----------------------------------------------------------------------
-   USE par_oce
-   !!
-   IMPLICIT NONE
-   !
-   INTEGER, INTENT(out) :: imin, imax
-   INTEGER, INTENT(out) :: jmin, jmax
-      !!----------------------------------------------------------------------
-   !
-   imin = nimppt(Agrif_Procrank+1)  ! ?????
-   jmin = njmppt(Agrif_Procrank+1)  ! ?????
-   imax = imin + jpi - 1
-   jmax = jmin + jpj - 1
-   ! 
-END SUBROUTINE Agrif_get_proc_info
-
-
-SUBROUTINE Agrif_estimate_parallel_cost(imin, imax,jmin, jmax, nbprocs, grid_cost)
+      USE par_oce
+      !!
+      IMPLICIT NONE
+      !
+      INTEGER, INTENT(out) :: imin, imax
+      INTEGER, INTENT(out) :: jmin, jmax
+      !!----------------------------------------------------------------------
+      !
+      imin = nimppt(Agrif_Procrank+1)  ! ?????
+      jmin = njmppt(Agrif_Procrank+1)  ! ?????
+      imax = imin + jpi - 1
+      jmax = jmin + jpj - 1
+      ! 
+   END SUBROUTINE Agrif_get_proc_info
+
+   SUBROUTINE Agrif_estimate_parallel_cost(imin, imax,jmin, jmax, nbprocs, grid_cost)
       !!----------------------------------------------------------------------
       !!                 *** ROUTINE Agrif_estimate_parallel_cost ***
       !!----------------------------------------------------------------------
-   USE par_oce
-   !!
-   IMPLICIT NONE
-   !
-   INTEGER,  INTENT(in)  :: imin, imax
-   INTEGER,  INTENT(in)  :: jmin, jmax
-   INTEGER,  INTENT(in)  :: nbprocs
-   REAL(wp), INTENT(out) :: grid_cost
-      !!----------------------------------------------------------------------
-   !
-   grid_cost = REAL(imax-imin+1,wp)*REAL(jmax-jmin+1,wp) / REAL(nbprocs,wp)
-   !
-END SUBROUTINE Agrif_estimate_parallel_cost
+      USE par_oce
+      !!
+      IMPLICIT NONE
+      !
+      INTEGER,  INTENT(in)  :: imin, imax
+      INTEGER,  INTENT(in)  :: jmin, jmax
+      INTEGER,  INTENT(in)  :: nbprocs
+      REAL(wp), INTENT(out) :: grid_cost
+      !!----------------------------------------------------------------------
+      !
+      grid_cost = REAL(imax-imin+1,wp)*REAL(jmax-jmin+1,wp) / REAL(nbprocs,wp)
+      !
+   END SUBROUTINE Agrif_estimate_parallel_cost
 
 # endif
 
 #else
-SUBROUTINE Subcalledbyagrif
+   SUBROUTINE Subcalledbyagrif
       !!----------------------------------------------------------------------
       !!                   *** ROUTINE Subcalledbyagrif ***
       !!----------------------------------------------------------------------
-   WRITE(*,*) 'Impossible to be here'
-END SUBROUTINE Subcalledbyagrif
+      WRITE(*,*) 'Impossible to be here'
+   END SUBROUTINE Subcalledbyagrif
 #endif
