Index: NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce.F90
===================================================================
--- NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce.F90	(revision 11204)
+++ NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce.F90	(revision 11205)
@@ -46,8 +46,5 @@
 
    ! 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
 
 
@@ -91,8 +88,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_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce_interp.F90
===================================================================
--- NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce_interp.F90	(revision 11204)
+++ NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce_interp.F90	(revision 11205)
@@ -401,51 +401,98 @@
       !!
       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)
+            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,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
+            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+         END DO
+      END DO
+      ! Characteristics method (only at boundary point):
+!      istart = 2
+!      iend   = 2
+!      DO ji = mi0(istart), mi1(iend)
+!         DO jj=1,jpj
+!            ua_e(ji,jj) = 0.5_wp * ( ubdy(ji,jj) * hur_e(ji,jj) + ua_e(ji+1,jj) &
+!                        &            - sqrt(grav * hur_e(ji,jj)) * (sshn_e(ji+1,jj) - hbdy(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)
+            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
+      ! Characteristics method (only at boundary point):
+!      istart = jpiglo-2
+!      iend   = jpiglo-2
+!      DO ji = mi0(istart), mi1(iend)
+!         DO jj=1,jpj
+!            ua_e(ji,jj) = 0.5_wp * ( ubdy(ji,jj) * hur_e(ji,jj) + ua_e(ji-1,jj) &
+!                        &            + sqrt(grav * hur_e(ji,jj)) * (sshn_e(ji,jj) - hbdy(ji+1,jj)) )
+!         END DO
+!      END DO
+      !
+      !--- South ---!
+      jstart = 2
+      jend   = nbghostcells+1
+      DO jj = mj0(jstart), mj1(jend)
+         DO ji=1,jpi
+            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,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
+      ! Characteristics method (only at boundary point):
+!      jstart = 2
+!      jend   = 2
+!      DO jj = mj0(jstart), mj1(jend)
+!         DO ji=1,jpi
+!            va_e(ji,jj) = 0.5_wp * ( vbdy(ji,jj) * hvr_e(ji,jj) + va_e(ji,jj+1) &
+!                        &            - sqrt(grav * hvr_e(ji,jj)) * (sshn_e(ji,jj+1) - hbdy(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,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)
+         END DO
+      END DO
+      jstart = jpjglo-nbghostcells-1
+      jend   = jpjglo-2
+      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
+            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+         END DO
+      END DO
+      ! Characteristics method (only at boundary point):
+!      jstart = jpjglo-2
+!      jend   = jpjglo-2
+!      DO jj = mj0(jstart), mj1(jend)
+!         DO ji=1,jpi
+!            va_e(ji,jj) = 0.5_wp * ( vbdy(ji,jj) * hvr_e(ji,jj) + va_e(ji,jj-1) &
+!                        &            + sqrt(grav * hvr_e(ji,jj)) * (sshn_e(ji,jj) - hbdy(ji,jj+1)) )
+!         END DO
+!      END DO
       !
    END SUBROUTINE Agrif_dyn_ts
@@ -485,8 +532,5 @@
       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 +547,6 @@
       INTEGER, INTENT(in) ::   kt
       !
-      INTEGER  :: ji, jj, indx, indy
+      INTEGER  :: ji, jj
+      INTEGER  :: istart, iend, jstart, jend
       !!----------------------------------------------------------------------  
       !
@@ -516,42 +561,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 +605,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
@@ -848,5 +885,5 @@
    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 +892,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 +898,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 +1072,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 +1079,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 +1087,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()
@@ -1082,14 +1103,8 @@
          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) 
+         ubdy(i1:i2,j1:j2) = ubdy(i1:i2,j1:j2) + 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)
+            ubdy(i1:i2,j1:j2) = ubdy(i1:i2,j1:j2) / (zrhoy*e2u(i1:i2,j1:j2)) * umask(i1:i2,j1:j2,1)
          ENDIF
       ENDIF
@@ -1098,5 +1113,5 @@
 
 
-   SUBROUTINE interpvnb( ptab, i1, i2, j1, j2, before, nb, ndir )
+   SUBROUTINE interpvnb( ptab, i1, i2, j1, j2, before )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE interpvnb  ***
@@ -1105,9 +1120,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) ::   zrhox, zrhot, zt0, zt1, ztcoeff   
-      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
       !!----------------------------------------------------------------------  
       ! 
@@ -1115,8 +1128,4 @@
          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()
@@ -1133,16 +1142,9 @@
             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) 
+         vbdy(i1:i2,j1:j2) = vbdy(i1:i2,j1:j2) + 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
+            vbdy(i1:i2,j1:j2) = vbdy(i1:i2,j1:j2) / (zrhox*e1v(i1:i2,j1:j2)) * vmask(i1:i2,j1:j2,1)
+         ENDIF            
       ENDIF
       !
@@ -1150,5 +1152,5 @@
 
 
-   SUBROUTINE interpub2b( ptab, i1, i2, j1, j2, before, nb, ndir )
+   SUBROUTINE interpub2b( ptab, i1, i2, j1, j2, before )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE interpub2b  ***
@@ -1157,9 +1159,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,8 +1170,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
@@ -1181,9 +1177,6 @@
          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) 
+         !
+         ubdy(i1:i2,j1:j2) = zat * ptab(i1:i2,j1:j2) 
       ENDIF
       ! 
@@ -1191,5 +1184,5 @@
    
 
-   SUBROUTINE interpvb2b( ptab, i1, i2, j1, j2, before, nb, ndir )
+   SUBROUTINE interpvb2b( ptab, i1, i2, j1, j2, before )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE interpvb2b  ***
@@ -1198,9 +1191,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
       !!----------------------------------------------------------------------  
       !
@@ -1212,8 +1203,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
@@ -1224,8 +1211,5 @@
             &           - 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) 
+         vbdy(i1:i2,j1:j2) = zat * ptab(i1:i2,j1:j2)
       ENDIF
       !      
Index: NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce_sponge.F90
===================================================================
--- NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce_sponge.F90	(revision 11204)
+++ NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_oce_sponge.F90	(revision 11205)
@@ -93,6 +93,6 @@
       !!----------------------------------------------------------------------
       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
       !!----------------------------------------------------------------------
@@ -104,51 +104,45 @@
 
          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
 
          ! --- 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
+            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)
             ENDDO
-         ENDIF
-
-         ! --- East --- !
-         IF( (nbondi == 1) .OR. (nbondi == 2) ) THEN
-            ind1 = nlci - nbghostcells - ispongearea
-            ind2 = nlci - nbghostcells
-            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
-            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)
+            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)
+            END DO
+         END DO
 
       ENDIF
Index: NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_user.F90
===================================================================
--- NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_user.F90	(revision 11204)
+++ NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/NST/agrif_user.F90	(revision 11205)
@@ -190,5 +190,5 @@
    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
+   hbdy(:,:) = 0.e0
    ssha(:,:) = 0.e0
 
@@ -199,8 +199,5 @@
       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
+      ubdy(:,:) = 0.e0 ; vbdy(:,:) = 0.e0
    ENDIF
 
@@ -736,7 +733,7 @@
    !
    ! 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')
+!   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')
Index: NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/OCE/DYN/dynspg_ts.F90	(revision 11204)
+++ NEMO/branches/2019/dev_r10973_AGRIF-01_jchanut_small_jpi_jpj/src/OCE/DYN/dynspg_ts.F90	(revision 11205)
@@ -797,36 +797,11 @@
          IF( ln_bdy .AND. ln_vol ) CALL bdy_vol2d( kt, jn, ua_e, va_e, zhup2_e, zhvp2_e )
          !
+#if  defined key_agrif
+         ! Set fluxes during predictor step to ensure volume conservation
+         IF( .NOT.Agrif_Root() .AND. ln_bt_fw ) CALL agrif_dyn_ts( jn )
+#endif      
          zwx(:,:) = e2u(:,:) * ua_e(:,:) * zhup2_e(:,:)         ! fluxes at jn+0.5
          zwy(:,:) = e1v(:,:) * va_e(:,:) * zhvp2_e(:,:)
          !
-#if defined key_agrif
-         ! Set fluxes during predictor step to ensure volume conservation
-         IF( .NOT.Agrif_Root() .AND. ln_bt_fw ) THEN
-            IF((nbondi == -1).OR.(nbondi == 2)) THEN
-               DO jj = 1, jpj
-                  zwx(2:nbghostcells+1,jj) = ubdy_w(1:nbghostcells,jj) * e2u(2:nbghostcells+1,jj)
-                  zwy(2:nbghostcells+1,jj) = vbdy_w(1:nbghostcells,jj) * e1v(2:nbghostcells+1,jj)
-               END DO
-            ENDIF
-            IF((nbondi ==  1).OR.(nbondi == 2)) THEN
-               DO jj=1,jpj
-                  zwx(nlci-nbghostcells-1:nlci-2,jj) = ubdy_e(1:nbghostcells,jj) * e2u(nlci-nbghostcells-1:nlci-2,jj)
-                  zwy(nlci-nbghostcells  :nlci-1,jj) = vbdy_e(1:nbghostcells,jj) * e1v(nlci-nbghostcells  :nlci-1,jj)
-               END DO
-            ENDIF
-            IF((nbondj == -1).OR.(nbondj == 2)) THEN
-               DO ji=1,jpi
-                  zwy(ji,2:nbghostcells+1) = vbdy_s(ji,1:nbghostcells) * e1v(ji,2:nbghostcells+1)
-                  zwx(ji,2:nbghostcells+1) = ubdy_s(ji,1:nbghostcells) * e2u(ji,2:nbghostcells+1)
-               END DO
-            ENDIF
-            IF((nbondj ==  1).OR.(nbondj == 2)) THEN
-               DO ji=1,jpi
-                  zwy(ji,nlcj-nbghostcells-1:nlcj-2) = vbdy_n(ji,1:nbghostcells) * e1v(ji,nlcj-nbghostcells-1:nlcj-2)
-                  zwx(ji,nlcj-nbghostcells  :nlcj-1) = ubdy_n(ji,1:nbghostcells) * e2u(ji,nlcj-nbghostcells  :nlcj-1)
-               END DO
-            ENDIF
-         ENDIF
-#endif
          IF( ln_wd_il )   CALL wad_lmt_bt(zwx, zwy, sshn_e, zssh_frc, rdtbt)
 
