Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_lim3_interp.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_lim3_interp.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_lim3_interp.F90	(revision 8129)
@@ -52,5 +52,5 @@
       !!-----------------------------------------------------------------------
       !
-      IF( Agrif_Root() )  RETURN
+      IF( Agrif_Root() .OR. nn_ice==0 )  RETURN   ! clem2017: do not interpolate if inside Parent domain or if child domain does not have ice
       !
       SELECT CASE(cd_type)
@@ -154,4 +154,5 @@
       REAL(wp) ::   zrhox, z1, z2, z3, z4, z5, z6, z7
       LOGICAL  ::   western_side, eastern_side, northern_side, southern_side
+      INTEGER  ::   ind1, ind2, ind3
 
       !!-----------------------------------------------------------------------
@@ -233,8 +234,13 @@
 !         ! Remove corners
 !         imin = i1  ;  imax = i2  ;  jmin = j1  ;  jmax = j2
-!         IF( (nbondj == -1) .OR. (nbondj == 2) )   jmin = 3
-!         IF( (nbondj == +1) .OR. (nbondj == 2) )   jmax = nlcj-2
-!         IF( (nbondi == -1) .OR. (nbondi == 2) )   imin = 3
-!         IF( (nbondi == +1) .OR. (nbondi == 2) )   imax = nlci-2
+!         !!clem2017 ghost
+!         ind1 =     nbghostcells
+!         ind2 = 1 + nbghostcells
+!         ind3 = 2 + nbghostcells
+!         IF( (nbondj == -1) .OR. (nbondj == 2) )   jmin = ind3
+!         IF( (nbondj == +1) .OR. (nbondj == 2) )   jmax = nlcj-ind2
+!         IF( (nbondi == -1) .OR. (nbondi == 2) )   imin = ind3
+!         IF( (nbondi == +1) .OR. (nbondi == 2) )   imax = nlci-ind2
+!         !!clem2017 ghost
 !
 !         ! smoothed fields
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_lim3_update.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_lim3_update.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_lim3_update.F90	(revision 8129)
@@ -56,4 +56,6 @@
       IF( ( MOD( (kt-nit000)/nn_fsbc + 1, Agrif_irhot() * Agrif_Parent(nn_fsbc) / nn_fsbc ) /=0 ) .AND. (kt /= 0) ) RETURN ! do not update if nb of child time steps differ from time refinement
                                                                                                                            ! i.e. update only at the parent time step
+      IF( nn_ice == 0 ) RETURN   ! clem2017: do not update if child domain does not have ice
+      !
       Agrif_UseSpecialValueInUpdate = .TRUE.
       Agrif_SpecialValueFineGrid = -9999.
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 8129)
@@ -35,5 +35,5 @@
    PUBLIC   Agrif_tra, Agrif_dyn, Agrif_ssh, Agrif_dyn_ts, Agrif_ssh_ts, Agrif_dta_ts
    PUBLIC   interpun, interpvn
-   PUBLIC   interptsn,  interpsshn
+   PUBLIC   interptsn, interpsshn
    PUBLIC   interpunb, interpvnb, interpub2b, interpvb2b
    PUBLIC   interpe3t, interpumsk, interpvmsk
@@ -100,277 +100,251 @@
       IF( nbondi == +1 .OR. nbondi == 2 )   i2 = nlci-2
 
+      ! --- West --- !
       IF( nbondi == -1 .OR. nbondi == 2 ) THEN
          !
-         ! Smoothing
-         ! ---------
          IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-            ua_b(2,:) = 0._wp
+            ua_b(1:1+nbghostcells,:) = 0._wp
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  ua_b(2,jj) = ua_b(2,jj) + e3u_a(2,jj,jk) * ua(2,jj,jk)
+                  ua_b(1:1+nbghostcells,jj) = ua_b(1:1+nbghostcells,jj) + e3u_a(1:1+nbghostcells,jj,jk) * ua(1:1+nbghostcells,jj,jk)
                END DO
             END DO
             DO jj = 1, jpj
-               ua_b(2,jj) = ua_b(2,jj) * r1_hu_a(2,jj)            
-            END DO
-         ENDIF
-         !
-         DO jk=1,jpkm1                 ! Smooth
-            DO jj=j1,j2
-               ua(2,jj,jk) = 0.25_wp*(ua(1,jj,jk)+2._wp*ua(2,jj,jk)+ua(3,jj,jk))
-               ua(2,jj,jk) = ua(2,jj,jk) * umask(2,jj,jk)
-            END DO
-         END DO
-         !
-         zub(2,:) = 0._wp              ! Correct transport
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               zub(2,jj) = zub(2,jj) + e3u_a(2,jj,jk) * ua(2,jj,jk)
-            END DO
-         END DO
-         DO jj=1,jpj
-            zub(2,jj) = zub(2,jj) * r1_hu_a(2,jj)
-         END DO
-
-         DO jk=1,jpkm1
-            DO jj=1,jpj
-               ua(2,jj,jk) = (ua(2,jj,jk)+ua_b(2,jj)-zub(2,jj))*umask(2,jj,jk)
-            END DO
-         END DO
-
-         ! Set tangential velocities to time splitting estimate
-         !-----------------------------------------------------
-         IF( ln_dynspg_ts ) THEN
-            zvb(2,:) = 0._wp
+               ua_b(1:1+nbghostcells,jj) = ua_b(1:1+nbghostcells,jj) * r1_hu_a(1:1+nbghostcells,jj)            
+            END DO
+         ENDIF
+         !
+         ! Smoothing if only 1 ghostcell
+         ! -----------------------------
+         IF( nbghostcells == 1 ) THEN
+            DO jk=1,jpkm1                 ! Smooth
+               DO jj=j1,j2
+                  ua(2,jj,jk) = 0.25_wp*(ua(1,jj,jk)+2._wp*ua(2,jj,jk)+ua(3,jj,jk))
+                  ua(2,jj,jk) = ua(2,jj,jk) * umask(2,jj,jk)
+               END DO
+            END DO
+            !
+            zub(2,:) = 0._wp              ! Correct transport
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  zvb(2,jj) = zvb(2,jj) + e3v_a(2,jj,jk) * va(2,jj,jk)
-               END DO
-            END DO
-            DO jj = 1, jpj
-               zvb(2,jj) = zvb(2,jj) * r1_hv_a(2,jj)
-            END DO
+                  zub(2,jj) = zub(2,jj) + e3u_a(2,jj,jk) * ua(2,jj,jk)
+               END DO
+            END DO
+            DO jj=1,jpj
+               zub(2,jj) = zub(2,jj) * r1_hu_a(2,jj)
+            END DO
+            
+            DO jk=1,jpkm1
+               DO jj=1,jpj
+                  ua(2,jj,jk) = (ua(2,jj,jk)+ua_b(2,jj)-zub(2,jj))*umask(2,jj,jk)
+               END DO
+            END DO
+            
+            IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+               zvb(2,:) = 0._wp
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     zvb(2,jj) = zvb(2,jj) + e3v_a(2,jj,jk) * va(2,jj,jk)
+                  END DO
+               END DO
+               DO jj = 1, jpj
+                  zvb(2,jj) = zvb(2,jj) * r1_hv_a(2,jj)
+               END DO
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     va(2,jj,jk) = (va(2,jj,jk)+va_b(2,jj)-zvb(2,jj)) * vmask(2,jj,jk)
+                  END DO
+               END DO
+            ENDIF
+            !
+         ENDIF
+         !
+      ENDIF
+
+      ! --- East --- !
+      IF( nbondi == 1 .OR. nbondi == 2 ) THEN
+
+         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+            ua_b(nlci-nbghostcells-1:nlci,:) = 0._wp
+            DO jk=1,jpkm1
+               DO jj=1,jpj
+                  ua_b(nlci-nbghostcells-1:nlci,jj) = ua_b(nlci-nbghostcells-1:nlci,jj) + e3u_a(nlci-nbghostcells-1:nlci,jj,jk)  &
+                     &                                                                     * ua(nlci-nbghostcells-1:nlci,jj,jk)
+               END DO
+            END DO
+            DO jj=1,jpj
+               ua_b(nlci-nbghostcells-1:nlci,jj) = ua_b(nlci-nbghostcells-1:nlci,jj) * r1_hu_a(nlci-nbghostcells-1:nlci,jj)            
+            END DO
+         ENDIF
+         !
+         ! Smoothing if only 1 ghostcell
+         ! -----------------------------
+         IF( nbghostcells == 1 ) THEN
+            DO jk = 1, jpkm1              ! Smooth
+               DO jj = j1, j2
+                  ua(nlci-2,jj,jk) = 0.25_wp * umask(nlci-2,jj,jk)      &
+                     &             * ( ua(nlci-3,jj,jk) + 2._wp*ua(nlci-2,jj,jk) + ua(nlci-1,jj,jk) )
+               END DO
+            END DO
+            
+            zub(nlci-2,:) = 0._wp        ! Correct transport
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  va(2,jj,jk) = (va(2,jj,jk)+va_b(2,jj)-zvb(2,jj)) * vmask(2,jj,jk)
-               END DO
-            END DO
-         ENDIF
-         !
-         ! Mask domain edges:
-         !-------------------
-         DO jk = 1, jpkm1
+                  zub(nlci-2,jj) = zub(nlci-2,jj) + e3u_a(nlci-2,jj,jk) * ua(nlci-2,jj,jk)
+               END DO
+            END DO
             DO jj = 1, jpj
-               ua(1,jj,jk) = 0._wp
-               va(1,jj,jk) = 0._wp
-            END DO
-         END DO         
-         !
-      ENDIF
-
-      IF( nbondi == 1 .OR. nbondi == 2 ) THEN
-
-         ! Smoothing
-         ! ---------
-         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-            ua_b(nlci-2,:) = 0._wp
-            DO jk=1,jpkm1
-               DO jj=1,jpj
-                  ua_b(nlci-2,jj) = ua_b(nlci-2,jj) + e3u_a(nlci-2,jj,jk) * ua(nlci-2,jj,jk)
-               END DO
-            END DO
-            DO jj=1,jpj
-               ua_b(nlci-2,jj) = ua_b(nlci-2,jj) * r1_hu_a(nlci-2,jj)            
-            END DO
-         ENDIF
-
-         DO jk = 1, jpkm1              ! Smooth
-            DO jj = j1, j2
-               ua(nlci-2,jj,jk) = 0.25_wp * umask(nlci-2,jj,jk)      &
-                  &             * ( ua(nlci-3,jj,jk) + 2._wp*ua(nlci-2,jj,jk) + ua(nlci-1,jj,jk) )
-            END DO
-         END DO
-
-         zub(nlci-2,:) = 0._wp        ! Correct transport
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               zub(nlci-2,jj) = zub(nlci-2,jj) + e3u_a(nlci-2,jj,jk) * ua(nlci-2,jj,jk)
-            END DO
-         END DO
-         DO jj = 1, jpj
-            zub(nlci-2,jj) = zub(nlci-2,jj) * r1_hu_a(nlci-2,jj)
-         END DO
-
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               ua(nlci-2,jj,jk) = ( ua(nlci-2,jj,jk) + ua_b(nlci-2,jj) - zub(nlci-2,jj) ) * umask(nlci-2,jj,jk)
-            END DO
-         END DO
-         !
-         ! Set tangential velocities to time splitting estimate
-         !-----------------------------------------------------
-         IF( ln_dynspg_ts ) THEN
-            zvb(nlci-1,:) = 0._wp
+               zub(nlci-2,jj) = zub(nlci-2,jj) * r1_hu_a(nlci-2,jj)
+            END DO
+            
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  zvb(nlci-1,jj) = zvb(nlci-1,jj) + e3v_a(nlci-1,jj,jk) * va(nlci-1,jj,jk)
-               END DO
-            END DO
-            DO jj=1,jpj
-               zvb(nlci-1,jj) = zvb(nlci-1,jj) * r1_hv_a(nlci-1,jj)
-            END DO
-            DO jk = 1, jpkm1
-               DO jj = 1, jpj
-                  va(nlci-1,jj,jk) = ( va(nlci-1,jj,jk) + va_b(nlci-1,jj) - zvb(nlci-1,jj) ) * vmask(nlci-1,jj,jk)
-               END DO
-            END DO
-         ENDIF
-         !
-         ! Mask domain edges:
-         !-------------------
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               ua(nlci-1,jj,jk) = 0._wp
-               va(nlci  ,jj,jk) = 0._wp
-            END DO
-         END DO 
-         !
-      ENDIF
-
+                  ua(nlci-2,jj,jk) = ( ua(nlci-2,jj,jk) + ua_b(nlci-2,jj) - zub(nlci-2,jj) ) * umask(nlci-2,jj,jk)
+               END DO
+            END DO
+            !
+            IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+               zvb(nlci-1,:) = 0._wp
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     zvb(nlci-1,jj) = zvb(nlci-1,jj) + e3v_a(nlci-1,jj,jk) * va(nlci-1,jj,jk)
+                  END DO
+               END DO
+               DO jj=1,jpj
+                  zvb(nlci-1,jj) = zvb(nlci-1,jj) * r1_hv_a(nlci-1,jj)
+               END DO
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     va(nlci-1,jj,jk) = ( va(nlci-1,jj,jk) + va_b(nlci-1,jj) - zvb(nlci-1,jj) ) * vmask(nlci-1,jj,jk)
+                  END DO
+               END DO
+            ENDIF
+            !
+         ENDIF
+         !
+      ENDIF
+
+      ! --- South --- !
       IF( nbondj == -1 .OR. nbondj == 2 ) THEN
 
-         ! Smoothing
-         ! ---------
          IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-            va_b(:,2) = 0._wp
+            va_b(:,1:nbghostcells+1) = 0._wp
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  va_b(ji,2) = va_b(ji,2) + e3v_a(ji,2,jk) * va(ji,2,jk)
+                  va_b(ji,1:nbghostcells+1) = va_b(ji,1:nbghostcells+1) + e3v_a(ji,1:nbghostcells+1,jk) * va(ji,1:nbghostcells+1,jk)
                END DO
             END DO
             DO ji=1,jpi
-               va_b(ji,2) = va_b(ji,2) * r1_hv_a(ji,2)            
-            END DO
-         ENDIF
-         !
-         DO jk = 1, jpkm1              ! Smooth
-            DO ji = i1, i2
-               va(ji,2,jk) = 0.25_wp * vmask(ji,2,jk)    &
-                  &        * ( va(ji,1,jk) + 2._wp*va(ji,2,jk) + va(ji,3,jk) )
-            END DO
-         END DO
-         !
-         zvb(:,2) = 0._wp              ! Correct transport
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               zvb(ji,2) = zvb(ji,2) + e3v_a(ji,2,jk) * va(ji,2,jk) * vmask(ji,2,jk)
-            END DO
-         END DO
-         DO ji = 1, jpi
-            zvb(ji,2) = zvb(ji,2) * r1_hv_a(ji,2)
-         END DO
-         DO jk = 1, jpkm1
+               va_b(ji,1:nbghostcells+1) = va_b(ji,1:nbghostcells+1) * r1_hv_a(ji,1:nbghostcells+1)            
+            END DO
+         ENDIF
+         !
+         ! Smoothing if only 1 ghostcell
+         ! -----------------------------
+         IF( nbghostcells == 1 ) THEN
+            DO jk = 1, jpkm1              ! Smooth
+               DO ji = i1, i2
+                  va(ji,2,jk) = 0.25_wp * vmask(ji,2,jk)    &
+                     &        * ( va(ji,1,jk) + 2._wp*va(ji,2,jk) + va(ji,3,jk) )
+               END DO
+            END DO
+            !
+            zvb(:,2) = 0._wp              ! Correct transport
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  zvb(ji,2) = zvb(ji,2) + e3v_a(ji,2,jk) * va(ji,2,jk) * vmask(ji,2,jk)
+               END DO
+            END DO
             DO ji = 1, jpi
-               va(ji,2,jk) = ( va(ji,2,jk) + va_b(ji,2) - zvb(ji,2) ) * vmask(ji,2,jk)
-            END DO
-         END DO
-
-         ! Set tangential velocities to time splitting estimate
-         !-----------------------------------------------------
-         IF( ln_dynspg_ts ) THEN
-            zub(:,2) = 0._wp
+               zvb(ji,2) = zvb(ji,2) * r1_hv_a(ji,2)
+            END DO
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  zub(ji,2) = zub(ji,2) + e3u_a(ji,2,jk) * ua(ji,2,jk) * umask(ji,2,jk)
-               END DO
-            END DO
-            DO ji = 1, jpi
-               zub(ji,2) = zub(ji,2) * r1_hu_a(ji,2)
-            END DO
-
+                  va(ji,2,jk) = ( va(ji,2,jk) + va_b(ji,2) - zvb(ji,2) ) * vmask(ji,2,jk)
+               END DO
+            END DO
+            
+            IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+               zub(:,2) = 0._wp
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpi
+                     zub(ji,2) = zub(ji,2) + e3u_a(ji,2,jk) * ua(ji,2,jk) * umask(ji,2,jk)
+                  END DO
+               END DO
+               DO ji = 1, jpi
+                  zub(ji,2) = zub(ji,2) * r1_hu_a(ji,2)
+               END DO
+               
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpi
+                     ua(ji,2,jk) = ( ua(ji,2,jk) + ua_b(ji,2) - zub(ji,2) ) * umask(ji,2,jk)
+                  END DO
+               END DO
+            ENDIF
+            !
+         ENDIF
+         !
+      ENDIF
+
+      ! --- North --- !
+      IF( nbondj == 1 .OR. nbondj == 2 ) THEN
+         !
+         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+            va_b(:,nlcj-nbghostcells-1:nlcj) = 0._wp
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  ua(ji,2,jk) = ( ua(ji,2,jk) + ua_b(ji,2) - zub(ji,2) ) * umask(ji,2,jk)
-               END DO
-            END DO
-         ENDIF
-
-         ! Mask domain edges:
-         !-------------------
-         DO jk = 1, jpkm1
+                  va_b(ji,nlcj-nbghostcells-1:nlcj) = va_b(ji,nlcj-nbghostcells-1:nlcj) + e3v_a(ji,nlcj-nbghostcells-1:nlcj,jk)  &
+                     &                                                                     * va(ji,nlcj-nbghostcells-1:nlcj,jk)
+               END DO
+            END DO
             DO ji = 1, jpi
-               ua(ji,1,jk) = 0._wp
-               va(ji,1,jk) = 0._wp
-            END DO
-         END DO 
-
-      ENDIF
-
-      IF( nbondj == 1 .OR. nbondj == 2 ) THEN
-         !
-         ! Smoothing
-         ! ---------
-         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-            va_b(:,nlcj-2) = 0._wp
+               va_b(ji,nlcj-nbghostcells-1:nlcj) = va_b(ji,nlcj-nbghostcells-1:nlcj) * r1_hv_a(ji,nlcj-nbghostcells-1:nlcj)            
+            END DO
+         ENDIF
+         !
+         ! Smoothing if only 1 ghostcell
+         ! -----------------------------
+         IF( nbghostcells == 1 ) THEN
+            DO jk = 1, jpkm1              ! Smooth
+               DO ji = i1, i2
+                  va(ji,nlcj-2,jk) = 0.25_wp * vmask(ji,nlcj-2,jk)   &
+                     &             * ( va(ji,nlcj-3,jk) + 2._wp * va(ji,nlcj-2,jk) + va(ji,nlcj-1,jk) )
+               END DO
+            END DO
+            !
+            zvb(:,nlcj-2) = 0._wp         ! Correct transport
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  va_b(ji,nlcj-2) = va_b(ji,nlcj-2) + e3v_a(ji,nlcj-2,jk) * va(ji,nlcj-2,jk)
+                  zvb(ji,nlcj-2) = zvb(ji,nlcj-2) + e3v_a(ji,nlcj-2,jk) * va(ji,nlcj-2,jk) * vmask(ji,nlcj-2,jk)
                END DO
             END DO
             DO ji = 1, jpi
-               va_b(ji,nlcj-2) = va_b(ji,nlcj-2) * r1_hv_a(ji,nlcj-2)            
-            END DO
-         ENDIF
-         !
-         DO jk = 1, jpkm1              ! Smooth
-            DO ji = i1, i2
-               va(ji,nlcj-2,jk) = 0.25_wp * vmask(ji,nlcj-2,jk)   &
-                  &             * ( va(ji,nlcj-3,jk) + 2._wp * va(ji,nlcj-2,jk) + va(ji,nlcj-1,jk) )
-            END DO
-         END DO
-         !
-         zvb(:,nlcj-2) = 0._wp         ! Correct transport
-         DO jk = 1, jpkm1
-            DO ji = 1, jpi
-               zvb(ji,nlcj-2) = zvb(ji,nlcj-2) + e3v_a(ji,nlcj-2,jk) * va(ji,nlcj-2,jk) * vmask(ji,nlcj-2,jk)
-            END DO
-         END DO
-         DO ji = 1, jpi
-            zvb(ji,nlcj-2) = zvb(ji,nlcj-2) * r1_hv_a(ji,nlcj-2)
-         END DO
-         DO jk = 1, jpkm1
-            DO ji = 1, jpi
-               va(ji,nlcj-2,jk) = ( va(ji,nlcj-2,jk) + va_b(ji,nlcj-2) - zvb(ji,nlcj-2) ) * vmask(ji,nlcj-2,jk)
-            END DO
-         END DO
-         !
-         ! Set tangential velocities to time splitting estimate
-         !-----------------------------------------------------
-         IF( ln_dynspg_ts ) THEN
-            zub(:,nlcj-1) = 0._wp
+               zvb(ji,nlcj-2) = zvb(ji,nlcj-2) * r1_hv_a(ji,nlcj-2)
+            END DO
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  zub(ji,nlcj-1) = zub(ji,nlcj-1) + e3u_a(ji,nlcj-1,jk) * ua(ji,nlcj-1,jk) * umask(ji,nlcj-1,jk)
-               END DO
-            END DO
-            DO ji = 1, jpi
-               zub(ji,nlcj-1) = zub(ji,nlcj-1) * r1_hu_a(ji,nlcj-1)
-            END DO
-            !
-            DO jk = 1, jpkm1
+                  va(ji,nlcj-2,jk) = ( va(ji,nlcj-2,jk) + va_b(ji,nlcj-2) - zvb(ji,nlcj-2) ) * vmask(ji,nlcj-2,jk)
+               END DO
+            END DO
+            !
+            IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+               zub(:,nlcj-1) = 0._wp
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpi
+                     zub(ji,nlcj-1) = zub(ji,nlcj-1) + e3u_a(ji,nlcj-1,jk) * ua(ji,nlcj-1,jk) * umask(ji,nlcj-1,jk)
+                  END DO
+               END DO
                DO ji = 1, jpi
-                  ua(ji,nlcj-1,jk) = ( ua(ji,nlcj-1,jk) + ua_b(ji,nlcj-1) - zub(ji,nlcj-1) ) * umask(ji,nlcj-1,jk)
-               END DO
-            END DO
-         ENDIF
-         !
-         ! Mask domain edges:
-         !-------------------
-         DO jk = 1, jpkm1
-            DO ji = 1, jpi
-               ua(ji,nlcj  ,jk) = 0._wp
-               va(ji,nlcj-1,jk) = 0._wp
-            END DO
-         END DO 
+                  zub(ji,nlcj-1) = zub(ji,nlcj-1) * r1_hu_a(ji,nlcj-1)
+               END DO
+               !
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpi
+                     ua(ji,nlcj-1,jk) = ( ua(ji,nlcj-1,jk) + ua_b(ji,nlcj-1) - zub(ji,nlcj-1) ) * umask(ji,nlcj-1,jk)
+                  END DO
+               END DO
+            ENDIF
+            !
+         ENDIF
          !
       ENDIF
@@ -392,11 +366,11 @@
       !
       IF( Agrif_Root() )   RETURN
-      !
+      !! clem ghost
       IF((nbondi == -1).OR.(nbondi == 2)) THEN
          DO jj=1,jpj
-            va_e(2,jj) = vbdy_w(jj) * hvr_e(2,jj)
+            va_e(1:nbghostcells+1,jj) = vbdy_w(jj) * hvr_e(1:nbghostcells+1,jj)
             ! Specified fluxes:
-            ua_e(2,jj) = ubdy_w(jj) * hur_e(2,jj)
-            ! Characteristics method:
+            ua_e(1:nbghostcells+1,jj) = ubdy_w(jj) * hur_e(1: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)) )
@@ -406,8 +380,8 @@
       IF((nbondi == 1).OR.(nbondi == 2)) THEN
          DO jj=1,jpj
-            va_e(nlci-1,jj) = vbdy_e(jj) * hvr_e(nlci-1,jj)
+            va_e(nlci-nbghostcells:nlci,jj)     = vbdy_e(jj) * hvr_e(nlci-nbghostcells:nlci,jj)
             ! Specified fluxes:
-            ua_e(nlci-2,jj) = ubdy_e(jj) * hur_e(nlci-2,jj)
-            ! Characteristics method:
+            ua_e(nlci-nbghostcells-1:nlci-1,jj) = ubdy_e(jj) * hur_e(nlci-nbghostcells-1:nlci-1,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)) )
@@ -417,8 +391,8 @@
       IF((nbondj == -1).OR.(nbondj == 2)) THEN
          DO ji=1,jpi
-            ua_e(ji,2) = ubdy_s(ji) * hur_e(ji,2)
+            ua_e(ji,1:nbghostcells+1) = ubdy_s(ji) * hur_e(ji,1:nbghostcells+1)
             ! Specified fluxes:
-            va_e(ji,2) = vbdy_s(ji) * hvr_e(ji,2)
-            ! Characteristics method:
+            va_e(ji,1:nbghostcells+1) = vbdy_s(ji) * hvr_e(ji,1: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)) )
@@ -428,8 +402,8 @@
       IF((nbondj == 1).OR.(nbondj == 2)) THEN
          DO ji=1,jpi
-            ua_e(ji,nlcj-1) = ubdy_n(ji) * hur_e(ji,nlcj-1)
+            ua_e(ji,nlcj-nbghostcells:nlcj)     = ubdy_n(ji) * hur_e(ji,nlcj-nbghostcells:nlcj)
             ! Specified fluxes:
-            va_e(ji,nlcj-2) = vbdy_n(ji) * hvr_e(ji,nlcj-2)
-            ! Characteristics method:
+            va_e(ji,nlcj-nbghostcells-1:nlcj-1) = vbdy_n(ji) * hvr_e(ji,nlcj-nbghostcells-1:nlcj-1)
+            ! 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)) )
@@ -476,5 +450,5 @@
       !
       IF( ll_int_cons ) THEN  ! Conservative interpolation
-         ! orders matters here !!!!!!
+         ! 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 )
@@ -504,27 +478,52 @@
       !!----------------------------------------------------------------------  
       INTEGER, INTENT(in) ::   kt
-      !!
+      !
+      INTEGER  :: ji, jj, indx
       !!----------------------------------------------------------------------  
       !
       IF( Agrif_Root() )   RETURN
-      !
+      !! clem ghost
+      ! --- West --- !
       IF((nbondi == -1).OR.(nbondi == 2)) THEN
-         ssha(2,:)=ssha(3,:)
-         sshn(2,:)=sshn(3,:)
-      ENDIF
-      !
+         indx = 1+nbghostcells
+         DO jj = 1, jpj
+            DO ji = 1, indx
+               ssha(ji,jj)=ssha(indx+1,jj)
+               sshn(ji,jj)=sshn(indx+1,jj)
+            ENDDO
+         ENDDO
+      ENDIF
+      !
+      ! --- East --- !
       IF((nbondi == 1).OR.(nbondi == 2)) THEN
-         ssha(nlci-1,:)=ssha(nlci-2,:)
-         sshn(nlci-1,:)=sshn(nlci-2,:)
-      ENDIF
-      !
+         indx = nlci-nbghostcells
+         DO jj = 1, jpj
+            DO ji = indx, nlci
+               ssha(ji,jj)=ssha(indx-1,jj)
+               sshn(ji,jj)=sshn(indx-1,jj)
+            ENDDO
+         ENDDO
+      ENDIF
+      !
+      ! --- South --- !
       IF((nbondj == -1).OR.(nbondj == 2)) THEN
-         ssha(:,2)=ssha(:,3)
-         sshn(:,2)=sshn(:,3)
-      ENDIF
-      !
+         indx = 1+nbghostcells
+         DO jj = 1, indx
+            DO ji = 1, jpi
+               ssha(ji,jj)=ssha(ji,indx+1)
+               sshn(ji,jj)=sshn(ji,indx+1)
+            ENDDO
+         ENDDO
+      ENDIF
+      !
+      ! --- North --- !
       IF((nbondj == 1).OR.(nbondj == 2)) THEN
-         ssha(:,nlcj-1)=ssha(:,nlcj-2)
-         sshn(:,nlcj-1)=sshn(:,nlcj-2)
+         indx = nlcj-nbghostcells
+         DO jj = indx, nlcj
+            DO ji = 1, jpi
+               ssha(ji,jj)=ssha(ji,indx-1)
+               sshn(ji,jj)=sshn(ji,indx-1)
+            ENDDO
+         ENDDO
       ENDIF
       !
@@ -538,10 +537,10 @@
       INTEGER, INTENT(in) ::   jn
       !!
-      INTEGER :: ji,jj
-      !!----------------------------------------------------------------------  
-      !
+      INTEGER :: ji, jj
+      !!----------------------------------------------------------------------  
+      !! clem ghost (starting at i,j=1 is important I think otherwise you introduce a grad(ssh)/=0 at point 2)
       IF((nbondi == -1).OR.(nbondi == 2)) THEN
          DO jj = 1, jpj
-            ssha_e(2,jj) = hbdy_w(jj)
+            ssha_e(1:nbghostcells+1,jj) = hbdy_w(jj)
          END DO
       ENDIF
@@ -549,5 +548,5 @@
       IF((nbondi == 1).OR.(nbondi == 2)) THEN
          DO jj = 1, jpj
-            ssha_e(nlci-1,jj) = hbdy_e(jj)
+            ssha_e(nlci-nbghostcells:nlci,jj) = hbdy_e(jj)
          END DO
       ENDIF
@@ -555,5 +554,5 @@
       IF((nbondj == -1).OR.(nbondj == 2)) THEN
          DO ji = 1, jpi
-            ssha_e(ji,2) = hbdy_s(ji)
+            ssha_e(ji,1:nbghostcells+1) = hbdy_s(ji)
          END DO
       ENDIF
@@ -561,5 +560,5 @@
       IF((nbondj == 1).OR.(nbondj == 2)) THEN
          DO ji = 1, jpi
-            ssha_e(ji,nlcj-1) = hbdy_n(ji)
+            ssha_e(ji,nlcj-nbghostcells:nlcj) = hbdy_n(ji)
          END DO
       ENDIF
@@ -601,6 +600,5 @@
       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
       INTEGER  ::   imin, imax, jmin, jmax
-      REAL(wp) ::   zrhox , zalpha1, zalpha2, zalpha3
-      REAL(wp) ::   zalpha4, zalpha5, zalpha6, zalpha7
+      REAL(wp) ::   zrhox, z1, z2, z3, z4, z5, z6, z7
       LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
       !!----------------------------------------------------------------------
@@ -610,129 +608,115 @@
       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()
-         ! 
-         zalpha1 = ( zrhox - 1. ) * 0.5
-         zalpha2 = 1. - zalpha1
-         ! 
-         zalpha3 = ( zrhox - 1. ) / ( zrhox + 1. )
-         zalpha4 = 1. - zalpha3
-         ! 
-         zalpha6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. )
-         zalpha7 =    - ( zrhox - 1. ) / ( zrhox + 3. )
-         zalpha5 = 1. - zalpha6 - zalpha7
-         !
-         imin = i1
-         imax = i2
-         jmin = j1
-         jmax = j2
-         ! 
-         ! Remove CORNERS
-         IF((nbondj == -1).OR.(nbondj == 2)) jmin = 3
-         IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj-2
-         IF((nbondi == -1).OR.(nbondi == 2)) imin = 3
-         IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci-2        
-         !
-         IF( eastern_side ) THEN
-            DO jn = 1, jpts
-               tsa(nlci,j1:j2,k1:k2,jn) = zalpha1 * ptab(nlci,j1:j2,k1:k2,jn) + zalpha2 * ptab(nlci-1,j1:j2,k1:k2,jn)
-               DO jk = 1, jpkm1
-                  DO jj = jmin,jmax
-                     IF( umask(nlci-2,jj,jk) == 0._wp ) THEN
-                        tsa(nlci-1,jj,jk,jn) = tsa(nlci,jj,jk,jn) * tmask(nlci-1,jj,jk)
-                     ELSE
-                        tsa(nlci-1,jj,jk,jn)=(zalpha4*tsa(nlci,jj,jk,jn)+zalpha3*tsa(nlci-2,jj,jk,jn))*tmask(nlci-1,jj,jk)
-                        IF( un(nlci-2,jj,jk) > 0._wp ) THEN
-                           tsa(nlci-1,jj,jk,jn)=( zalpha6*tsa(nlci-2,jj,jk,jn)+zalpha5*tsa(nlci,jj,jk,jn) & 
-                                 + zalpha7*tsa(nlci-3,jj,jk,jn) ) * tmask(nlci-1,jj,jk)
+         IF( nbghostcells > 1 ) THEN  ! no smoothing
+            tsa(i1:i2,j1:j2,k1:k2,n1:n2) = ptab(i1:i2,j1:j2,k1:k2,n1:n2)
+         ELSE                         ! smoothing
+            !
+            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()
+            z1 = ( zrhox - 1. ) * 0.5
+            z3 = ( zrhox - 1. ) / ( zrhox + 1. )
+            z6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. )
+            z7 =    - ( zrhox - 1. ) / ( zrhox + 3. )
+            !
+            z2 = 1. - z1
+            z4 = 1. - z3
+            z5 = 1. - z6 - z7
+            !
+            imin = i1 ; imax = i2
+            jmin = j1 ; jmax = j2
+            ! 
+            ! Remove CORNERS
+            IF((nbondj == -1).OR.(nbondj == 2)) jmin = 3
+            IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj-2
+            IF((nbondi == -1).OR.(nbondi == 2)) imin = 3
+            IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci-2        
+            !
+            IF( eastern_side ) THEN
+               DO jn = 1, jpts
+                  tsa(nlci,j1:j2,k1:k2,jn) = z1 * ptab(nlci,j1:j2,k1:k2,jn) + z2 * ptab(nlci-1,j1:j2,k1:k2,jn)
+                  DO jk = 1, jpkm1
+                     DO jj = jmin,jmax
+                        IF( umask(nlci-2,jj,jk) == 0._wp ) THEN
+                           tsa(nlci-1,jj,jk,jn) = tsa(nlci,jj,jk,jn) * tmask(nlci-1,jj,jk)
+                        ELSE
+                           tsa(nlci-1,jj,jk,jn)=(z4*tsa(nlci,jj,jk,jn)+z3*tsa(nlci-2,jj,jk,jn))*tmask(nlci-1,jj,jk)
+                           IF( un(nlci-2,jj,jk) > 0._wp ) THEN
+                              tsa(nlci-1,jj,jk,jn)=( z6*tsa(nlci-2,jj,jk,jn)+z5*tsa(nlci,jj,jk,jn) & 
+                                                   + z7*tsa(nlci-3,jj,jk,jn) ) * tmask(nlci-1,jj,jk)
+                           ENDIF
                         ENDIF
-                     ENDIF
+                     END DO
                   END DO
-               END DO
-               tsa(nlci,j1:j2,k1:k2,jn) = 0._wp
-            END DO
-         ENDIF
-         ! 
-         IF( northern_side ) THEN            
-            DO jn = 1, jpts
-               tsa(i1:i2,nlcj,k1:k2,jn) = zalpha1 * ptab(i1:i2,nlcj,k1:k2,jn) + zalpha2 * ptab(i1:i2,nlcj-1,k1:k2,jn)
-               DO jk = 1, jpkm1
-                  DO ji = imin,imax
-                     IF( vmask(ji,nlcj-2,jk) == 0._wp ) THEN
-                        tsa(ji,nlcj-1,jk,jn) = tsa(ji,nlcj,jk,jn) * tmask(ji,nlcj-1,jk)
-                     ELSE
-                        tsa(ji,nlcj-1,jk,jn)=(zalpha4*tsa(ji,nlcj,jk,jn)+zalpha3*tsa(ji,nlcj-2,jk,jn))*tmask(ji,nlcj-1,jk)        
-                        IF (vn(ji,nlcj-2,jk) > 0._wp ) THEN
-                           tsa(ji,nlcj-1,jk,jn)=( zalpha6*tsa(ji,nlcj-2,jk,jn)+zalpha5*tsa(ji,nlcj,jk,jn)  &
-                                 + zalpha7*tsa(ji,nlcj-3,jk,jn) ) * tmask(ji,nlcj-1,jk)
+                  tsa(nlci,j1:j2,k1:k2,jn) = 0._wp
+               END DO
+            ENDIF
+            ! 
+            IF( northern_side ) THEN            
+               DO jn = 1, jpts
+                  tsa(i1:i2,nlcj,k1:k2,jn) = z1 * ptab(i1:i2,nlcj,k1:k2,jn) + z2 * ptab(i1:i2,nlcj-1,k1:k2,jn)
+                  DO jk = 1, jpkm1
+                     DO ji = imin,imax
+                        IF( vmask(ji,nlcj-2,jk) == 0._wp ) THEN
+                           tsa(ji,nlcj-1,jk,jn) = tsa(ji,nlcj,jk,jn) * tmask(ji,nlcj-1,jk)
+                        ELSE
+                           tsa(ji,nlcj-1,jk,jn)=(z4*tsa(ji,nlcj,jk,jn)+z3*tsa(ji,nlcj-2,jk,jn))*tmask(ji,nlcj-1,jk)        
+                           IF (vn(ji,nlcj-2,jk) > 0._wp ) THEN
+                              tsa(ji,nlcj-1,jk,jn)=( z6*tsa(ji,nlcj-2,jk,jn)+z5*tsa(ji,nlcj,jk,jn)  &
+                                                   + z7*tsa(ji,nlcj-3,jk,jn) ) * tmask(ji,nlcj-1,jk)
+                           ENDIF
                         ENDIF
-                     ENDIF
+                     END DO
                   END DO
-               END DO
-               tsa(i1:i2,nlcj,k1:k2,jn) = 0._wp
-            END DO
-         ENDIF
-         !
-         IF( western_side ) THEN            
-            DO jn = 1, jpts
-               tsa(1,j1:j2,k1:k2,jn) = zalpha1 * ptab(1,j1:j2,k1:k2,jn) + zalpha2 * ptab(2,j1:j2,k1:k2,jn)
-               DO jk = 1, jpkm1
-                  DO jj = jmin,jmax
-                     IF( umask(2,jj,jk) == 0._wp ) THEN
-                        tsa(2,jj,jk,jn) = tsa(1,jj,jk,jn) * tmask(2,jj,jk)
-                     ELSE
-                        tsa(2,jj,jk,jn)=(zalpha4*tsa(1,jj,jk,jn)+zalpha3*tsa(3,jj,jk,jn))*tmask(2,jj,jk)        
-                        IF( un(2,jj,jk) < 0._wp ) THEN
-                           tsa(2,jj,jk,jn)=(zalpha6*tsa(3,jj,jk,jn)+zalpha5*tsa(1,jj,jk,jn)+zalpha7*tsa(4,jj,jk,jn))*tmask(2,jj,jk)
+                  tsa(i1:i2,nlcj,k1:k2,jn) = 0._wp
+               END DO
+            ENDIF
+            !
+            IF( western_side ) THEN            
+               DO jn = 1, jpts
+                  tsa(1,j1:j2,k1:k2,jn) = z1 * ptab(1,j1:j2,k1:k2,jn) + z2 * ptab(2,j1:j2,k1:k2,jn)
+                  DO jk = 1, jpkm1
+                     DO jj = jmin,jmax
+                        IF( umask(2,jj,jk) == 0._wp ) THEN
+                           tsa(2,jj,jk,jn) = tsa(1,jj,jk,jn) * tmask(2,jj,jk)
+                        ELSE
+                           tsa(2,jj,jk,jn)=(z4*tsa(1,jj,jk,jn)+z3*tsa(3,jj,jk,jn))*tmask(2,jj,jk)        
+                           IF( un(2,jj,jk) < 0._wp ) THEN
+                              tsa(2,jj,jk,jn)=(z6*tsa(3,jj,jk,jn)+z5*tsa(1,jj,jk,jn)+z7*tsa(4,jj,jk,jn))*tmask(2,jj,jk)
+                           ENDIF
                         ENDIF
-                     ENDIF
+                     END DO
                   END DO
-               END DO
-               tsa(1,j1:j2,k1:k2,jn) = 0._wp
-            END DO
-         ENDIF
-         !
-         IF( southern_side ) THEN           
-            DO jn = 1, jpts
-               tsa(i1:i2,1,k1:k2,jn) = zalpha1 * ptab(i1:i2,1,k1:k2,jn) + zalpha2 * ptab(i1:i2,2,k1:k2,jn)
-               DO jk = 1, jpk      
-                  DO ji=imin,imax
-                     IF( vmask(ji,2,jk) == 0._wp ) THEN
-                        tsa(ji,2,jk,jn)=tsa(ji,1,jk,jn) * tmask(ji,2,jk)
-                     ELSE
-                        tsa(ji,2,jk,jn)=(zalpha4*tsa(ji,1,jk,jn)+zalpha3*tsa(ji,3,jk,jn))*tmask(ji,2,jk)
-                        IF( vn(ji,2,jk) < 0._wp ) THEN
-                           tsa(ji,2,jk,jn)=(zalpha6*tsa(ji,3,jk,jn)+zalpha5*tsa(ji,1,jk,jn)+zalpha7*tsa(ji,4,jk,jn))*tmask(ji,2,jk)
+                  tsa(1,j1:j2,k1:k2,jn) = 0._wp
+               END DO
+            ENDIF
+            !
+            IF( southern_side ) THEN           
+               DO jn = 1, jpts
+                  tsa(i1:i2,1,k1:k2,jn) = z1 * ptab(i1:i2,1,k1:k2,jn) + z2 * ptab(i1:i2,2,k1:k2,jn)
+                  DO jk = 1, jpk      
+                     DO ji=imin,imax
+                        IF( vmask(ji,2,jk) == 0._wp ) THEN
+                           tsa(ji,2,jk,jn)=tsa(ji,1,jk,jn) * tmask(ji,2,jk)
+                        ELSE
+                           tsa(ji,2,jk,jn)=(z4*tsa(ji,1,jk,jn)+z3*tsa(ji,3,jk,jn))*tmask(ji,2,jk)
+                           IF( vn(ji,2,jk) < 0._wp ) THEN
+                              tsa(ji,2,jk,jn)=(z6*tsa(ji,3,jk,jn)+z5*tsa(ji,1,jk,jn)+z7*tsa(ji,4,jk,jn))*tmask(ji,2,jk)
+                           ENDIF
                         ENDIF
-                     ENDIF
+                     END DO
                   END DO
-               END DO
-               tsa(i1:i2,1,k1:k2,jn) = 0._wp
-            END DO
-         ENDIF
-         !
-         ! Treatment of corners
-         ! 
-         ! East south
-         IF ((eastern_side).AND.((nbondj == -1).OR.(nbondj == 2))) THEN
-            tsa(nlci-1,2,:,:) = ptab(nlci-1,2,:,:)
-         ENDIF
-         ! East north
-         IF ((eastern_side).AND.((nbondj == 1).OR.(nbondj == 2))) THEN
-            tsa(nlci-1,nlcj-1,:,:) = ptab(nlci-1,nlcj-1,:,:)
-         ENDIF
-         ! West south
-         IF ((western_side).AND.((nbondj == -1).OR.(nbondj == 2))) THEN
-            tsa(2,2,:,:) = ptab(2,2,:,:)
-         ENDIF
-         ! West north
-         IF ((western_side).AND.((nbondj == 1).OR.(nbondj == 2))) THEN
-            tsa(2,nlcj-1,:,:) = ptab(2,nlcj-1,:,:)
-         ENDIF
-         !
+                  tsa(i1:i2,1,k1:k2,jn) = 0._wp
+               END DO
+            ENDIF
+            !
+            ! Treatment of corners
+            IF ((eastern_side).AND.((nbondj == -1).OR.(nbondj == 2)))   tsa(nlci-1,2,:,:) = ptab(nlci-1,2,:,:)            ! East south
+            IF ((eastern_side).AND.((nbondj ==  1).OR.(nbondj == 2)))   tsa(nlci-1,nlcj-1,:,:) = ptab(nlci-1,nlcj-1,:,:)  ! East north
+            IF ((western_side).AND.((nbondj == -1).OR.(nbondj == 2)))   tsa(2,2,:,:) = ptab(2,2,:,:)                      ! West south
+            IF ((western_side).AND.((nbondj ==  1).OR.(nbondj == 2)))   tsa(2,nlcj-1,:,:) = ptab(2,nlcj-1,:,:)            ! West north
+            !
+         ENDIF
       ENDIF
       !
@@ -759,8 +743,9 @@
          southern_side = (nb == 2).AND.(ndir == 1)
          northern_side = (nb == 2).AND.(ndir == 2)
-         IF(western_side)  hbdy_w(j1:j2) = ptab(i1,j1:j2) * tmask(i1,j1:j2,1)
-         IF(eastern_side)  hbdy_e(j1:j2) = ptab(i1,j1:j2) * tmask(i1,j1:j2,1)
-         IF(southern_side) hbdy_s(i1:i2) = ptab(i1:i2,j1) * tmask(i1:i2,j1,1)
-         IF(northern_side) hbdy_n(i1:i2) = ptab(i1:i2,j1) * tmask(i1:i2,j1,1)
+         !! clem ghost
+         IF(western_side)  hbdy_w(j1:j2) = ptab(i2,j1:j2) * tmask(i1,j1:j2,1)
+         IF(eastern_side)  hbdy_e(j1:j2) = ptab(i2,j1:j2) * tmask(i2,j1:j2,1) !clem previously i1
+         IF(southern_side) hbdy_s(i1:i2) = ptab(i1:i2,j2) * tmask(i1:i2,j2,1) !clem previously j1
+         IF(northern_side) hbdy_n(i1:i2) = ptab(i1:i2,j2) * tmask(i1:i2,j1,1)
       ENDIF
       !
@@ -854,36 +839,19 @@
          ELSEIF( bdy_tinterp == 2 ) THEN
             ztcoeff = zrhot * (  zt1        * (       zt1 - 1._wp)**2._wp &
-               &               - zt0        * (       zt0 - 1._wp)**2._wp ) 
-
+               &               - zt0        * (       zt0 - 1._wp)**2._wp )
          ELSE
             ztcoeff = 1
          ENDIF
-         !   
-         IF(western_side) THEN
-            ubdy_w(j1:j2) = ubdy_w(j1:j2) + ztcoeff * ptab(i1,j1:j2)  
-         ENDIF
-         IF(eastern_side) THEN
-            ubdy_e(j1:j2) = ubdy_e(j1:j2) + ztcoeff * ptab(i1,j1:j2)  
-         ENDIF
-         IF(southern_side) THEN
-            ubdy_s(i1:i2) = ubdy_s(i1:i2) + ztcoeff * ptab(i1:i2,j1) 
-         ENDIF
-         IF(northern_side) THEN
-            ubdy_n(i1:i2) = ubdy_n(i1:i2) + ztcoeff * ptab(i1:i2,j1) 
-         ENDIF
+         !! clem ghost   
+         IF(western_side)   ubdy_w(j1:j2) = ubdy_w(j1:j2) + ztcoeff * ptab(i1,j1:j2)  
+         IF(eastern_side)   ubdy_e(j1:j2) = ubdy_e(j1:j2) + ztcoeff * ptab(i2,j1:j2) !clem previously i1  
+         IF(southern_side)  ubdy_s(i1:i2) = ubdy_s(i1:i2) + ztcoeff * ptab(i1:i2,j2) !clem previously j1
+         IF(northern_side)  ubdy_n(i1:i2) = ubdy_n(i1:i2) + ztcoeff * ptab(i1:i2,j1) 
          !            
          IF( bdy_tinterp == 0 .OR. bdy_tinterp == 2) THEN
-            IF(western_side) THEN
-               ubdy_w(j1:j2) = ubdy_w(j1:j2) / (zrhoy*e2u(i1,j1:j2)) * umask(i1,j1:j2,1)
-            ENDIF
-            IF(eastern_side) THEN
-               ubdy_e(j1:j2) = ubdy_e(j1:j2) / (zrhoy*e2u(i1,j1:j2)) * umask(i1,j1:j2,1)
-            ENDIF
-            IF(southern_side) THEN
-               ubdy_s(i1:i2) = ubdy_s(i1:i2) / (zrhoy*e2u(i1:i2,j1)) * umask(i1:i2,j1,1)
-            ENDIF
-            IF(northern_side) THEN
-               ubdy_n(i1:i2) = ubdy_n(i1:i2) / (zrhoy*e2u(i1:i2,j1)) * umask(i1:i2,j1,1)
-            ENDIF
+            IF(western_side)   ubdy_w(j1:j2) = ubdy_w(j1:j2) / (zrhoy*e2u(i1,j1:j2)) * umask(i1,j1:j2,1)
+            IF(eastern_side)   ubdy_e(j1:j2) = ubdy_e(j1:j2) / (zrhoy*e2u(i2,j1:j2)) * umask(i2,j1:j2,1)
+            IF(southern_side)  ubdy_s(i1:i2) = ubdy_s(i1:i2) / (zrhoy*e2u(i1:i2,j2)) * umask(i1:i2,j2,1)
+            IF(northern_side)  ubdy_n(i1:i2) = ubdy_n(i1:i2) / (zrhoy*e2u(i1:i2,j1)) * umask(i1:i2,j1,1)
          ENDIF
       ENDIF
@@ -927,35 +895,15 @@
             ztcoeff = 1
          ENDIF
-         !
-         IF(western_side) THEN
-            vbdy_w(j1:j2) = vbdy_w(j1:j2) + ztcoeff * ptab(i1,j1:j2)  
-         ENDIF
-         IF(eastern_side) THEN
-            vbdy_e(j1:j2) = vbdy_e(j1:j2) + ztcoeff * ptab(i1,j1:j2)  
-         ENDIF
-         IF(southern_side) THEN
-            vbdy_s(i1:i2) = vbdy_s(i1:i2) + ztcoeff * ptab(i1:i2,j1)
-         ENDIF
-         IF(northern_side) THEN
-            vbdy_n(i1:i2) = vbdy_n(i1:i2) + ztcoeff * ptab(i1:i2,j1) 
-         ENDIF
+         !! clem ghost
+         IF(western_side)   vbdy_w(j1:j2) = vbdy_w(j1:j2) + ztcoeff * ptab(i1,j1:j2)  
+         IF(eastern_side)   vbdy_e(j1:j2) = vbdy_e(j1:j2) + ztcoeff * ptab(i2,j1:j2) !clem previously i1  
+         IF(southern_side)  vbdy_s(i1:i2) = vbdy_s(i1:i2) + ztcoeff * ptab(i1:i2,j2) !clem previously j1
+         IF(northern_side)  vbdy_n(i1:i2) = vbdy_n(i1:i2) + ztcoeff * ptab(i1:i2,j1) 
          !            
          IF( bdy_tinterp == 0 .OR. bdy_tinterp == 2) THEN
-            IF(western_side) THEN
-               vbdy_w(j1:j2) = vbdy_w(j1:j2) / (zrhox*e1v(i1,j1:j2))   &
-                     &                                  * vmask(i1,j1:j2,1)
-            ENDIF
-            IF(eastern_side) THEN
-               vbdy_e(j1:j2) = vbdy_e(j1:j2) / (zrhox*e1v(i1,j1:j2))   &
-                     &                                  * vmask(i1,j1:j2,1)
-            ENDIF
-            IF(southern_side) THEN
-               vbdy_s(i1:i2) = vbdy_s(i1:i2) / (zrhox*e1v(i1:i2,j1))   &
-                     &                                  * vmask(i1:i2,j1,1)
-            ENDIF
-            IF(northern_side) THEN
-               vbdy_n(i1:i2) = vbdy_n(i1:i2) / (zrhox*e1v(i1:i2,j1))   &
-                     &                                  * vmask(i1:i2,j1,1)
-            ENDIF
+            IF(western_side)   vbdy_w(j1:j2) = vbdy_w(j1:j2) / (zrhox*e1v(i1,j1:j2)) * vmask(i1,j1:j2,1)
+            IF(eastern_side)   vbdy_e(j1:j2) = vbdy_e(j1:j2) / (zrhox*e1v(i2,j1:j2)) * vmask(i2,j1:j2,1)
+            IF(southern_side)  vbdy_s(i1:i2) = vbdy_s(i1:i2) / (zrhox*e1v(i1:i2,j2)) * vmask(i1:i2,j2,1)
+            IF(northern_side)  vbdy_n(i1:i2) = vbdy_n(i1:i2) / (zrhox*e1v(i1:i2,j1)) * vmask(i1:i2,j1,1)
          ENDIF
       ENDIF
@@ -991,8 +939,8 @@
          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(j1:j2) = zat * ptab(i1,j1:j2)  
-         IF(eastern_side ) ubdy_e(j1:j2) = zat * ptab(i1,j1:j2)  
-         IF(southern_side) ubdy_s(i1:i2) = zat * ptab(i1:i2,j1) 
+         IF(eastern_side ) ubdy_e(j1:j2) = zat * ptab(i2,j1:j2) !clem previously i1  
+         IF(southern_side) ubdy_s(i1:i2) = zat * ptab(i1:i2,j2) !clem previously j1
          IF(northern_side) ubdy_n(i1:i2) = zat * ptab(i1:i2,j1) 
       ENDIF
@@ -1031,6 +979,6 @@
          !
          IF(western_side )   vbdy_w(j1:j2) = zat * ptab(i1,j1:j2)  
-         IF(eastern_side )   vbdy_e(j1:j2) = zat * ptab(i1,j1:j2)  
-         IF(southern_side)   vbdy_s(i1:i2) = zat * ptab(i1:i2,j1) 
+         IF(eastern_side )   vbdy_e(j1:j2) = zat * ptab(i2,j1:j2) !clem previously i1  
+         IF(southern_side)   vbdy_s(i1:i2) = zat * ptab(i1:i2,j2) !clem previously j1 
          IF(northern_side)   vbdy_n(i1:i2) = zat * ptab(i1:i2,j1) 
       ENDIF
@@ -1050,5 +998,4 @@
       INTEGER :: ji, jj, jk
       LOGICAL :: western_side, eastern_side, northern_side, southern_side
-      REAL(wp) :: ztmpmsk      
       !!----------------------------------------------------------------------  
       !    
@@ -1060,15 +1007,10 @@
          southern_side = (nb == 2).AND.(ndir == 1)
          northern_side = (nb == 2).AND.(ndir == 2)
-
+         !
          DO jk = k1, k2
             DO jj = j1, j2
                DO ji = i1, i2
-                  ! Get velocity mask at boundary edge points:
-                  IF( western_side )   ztmpmsk = umask(ji    ,jj    ,1)
-                  IF( eastern_side )   ztmpmsk = umask(nlci-2,jj    ,1)
-                  IF( northern_side)   ztmpmsk = vmask(ji    ,nlcj-2,1)
-                  IF( southern_side)   ztmpmsk = vmask(ji    ,2     ,1)
                   !
-                  IF( ABS( ptab(ji,jj,jk) - tmask(ji,jj,jk) * e3t_0(ji,jj,jk) )*ztmpmsk > 1.D-2) THEN
+                  IF( ABS( ptab(ji,jj,jk) - tmask(ji,jj,jk) * e3t_0(ji,jj,jk) ) > 1.D-2) THEN
                      IF (western_side) THEN
                         WRITE(numout,*) 'ERROR bathymetry merge at the western border ji,jj,jk ', ji+nimpp-1,jj+njmpp-1,jk
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 8129)
@@ -34,9 +34,9 @@
       !!   *** ROUTINE Agrif_Sponge_Tra ***
       !!---------------------------------------------
-      REAL(wp) :: timecoeff
+      REAL(wp) :: zcoef
       !!---------------------------------------------
       !
 #if defined SPONGE
-      timecoeff = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
+      zcoef = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
 
       CALL Agrif_Sponge
@@ -45,5 +45,5 @@
       tabspongedone_tsn = .FALSE.
 
-      CALL Agrif_Bc_Variable(tsn_sponge_id,calledweight=timecoeff,procname=interptsn_sponge)
+      CALL Agrif_Bc_Variable(tsn_sponge_id,calledweight=zcoef,procname=interptsn_sponge)
 
       Agrif_UseSpecialValue = .FALSE.
@@ -57,9 +57,9 @@
       !!   *** ROUTINE Agrif_Sponge_dyn ***
       !!---------------------------------------------
-      REAL(wp) :: timecoeff
+      REAL(wp) :: zcoef
       !!---------------------------------------------
 
 #if defined SPONGE
-      timecoeff = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
+      zcoef = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
 
       Agrif_SpecialValue=0.
@@ -68,9 +68,9 @@
       tabspongedone_u = .FALSE.
       tabspongedone_v = .FALSE.         
-      CALL Agrif_Bc_Variable(un_sponge_id,calledweight=timecoeff,procname=interpun_sponge)
+      CALL Agrif_Bc_Variable(un_sponge_id,calledweight=zcoef,procname=interpun_sponge)
 
       tabspongedone_u = .FALSE.
       tabspongedone_v = .FALSE.
-      CALL Agrif_Bc_Variable(vn_sponge_id,calledweight=timecoeff,procname=interpvn_sponge)
+      CALL Agrif_Bc_Variable(vn_sponge_id,calledweight=zcoef,procname=interpvn_sponge)
 
       Agrif_UseSpecialValue = .FALSE.
@@ -84,67 +84,62 @@
       !!   *** ROUTINE  Agrif_Sponge ***
       !!---------------------------------------------
-      INTEGER  :: ji,jj,jk
-      INTEGER  :: ispongearea, ilci, ilcj
-      LOGICAL  :: ll_spdone
-      REAL(wp) :: z1spongearea, zramp
-      REAL(wp), POINTER, DIMENSION(:,:) :: ztabramp
+      REAL(wp), DIMENSION(jpi,jpj) :: ztabramp
+      !
+      INTEGER  :: ji, jj, ind1, ind2
+      INTEGER  :: ispongearea
+      REAL(wp) :: z1_spongearea
+      !!---------------------------------------------
 
 #if defined SPONGE || defined SPONGE_TOP
-      ll_spdone=.TRUE.
       IF (( .NOT. spongedoneT ).OR.( .NOT. spongedoneU )) THEN
-         ! Define ramp from boundaries towards domain interior
-         ! at T-points
+         ! Define ramp from boundaries towards domain interior at T-points
          ! Store it in ztabramp
-         ll_spdone=.FALSE.
-
-         CALL wrk_alloc( jpi, jpj, ztabramp )
 
          ispongearea  = 2 + nn_sponge_len * Agrif_irhox()
-         ilci = nlci - ispongearea
-         ilcj = nlcj - ispongearea 
-         z1spongearea = 1._wp / REAL( ispongearea - 2 )
-
+         z1_spongearea = 1._wp / REAL( ispongearea - 1 )
+         
          ztabramp(:,:) = 0._wp
 
+         ! --- West --- !
          IF( (nbondi == -1) .OR. (nbondi == 2) ) THEN
+            ind1 = 1+nbghostcells
+            ind2 = 1+nbghostcells + (ispongearea-1)
             DO jj = 1, jpj
-               IF ( umask(2,jj,1) == 1._wp ) THEN
-                 DO ji = 2, ispongearea                  
-                    ztabramp(ji,jj) = ( ispongearea-ji ) * z1spongearea
-                 END DO
-               ENDIF
+               DO ji = ind1, ind2                  
+                  ztabramp(ji,jj) = REAL( ind2 - ji ) * z1_spongearea * umask(ind1,jj,1)
+               END DO
             ENDDO
          ENDIF
 
+         ! --- East --- !
          IF( (nbondi == 1) .OR. (nbondi == 2) ) THEN
+            ind1 = nlci - (1+nbghostcells) - (ispongearea-1)
+            ind2 = nlci - (1+nbghostcells)
             DO jj = 1, jpj
-               IF ( umask(nlci-2,jj,1) == 1._wp ) THEN
-                  DO ji = ilci+1,nlci-1
-                     zramp = (ji - (ilci+1) ) * z1spongearea
-                     ztabramp(ji,jj) = MAX( ztabramp(ji,jj), zramp )
-                  ENDDO
-               ENDIF
+               DO ji = ind1, ind2
+                  ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( ji - ind2 ) * z1_spongearea * umask(ind2-1,jj,1) )
+               ENDDO
             ENDDO
          ENDIF
 
+         ! --- South --- !
          IF( (nbondj == -1) .OR. (nbondj == 2) ) THEN
-            DO ji = 1, jpi
-               IF ( vmask(ji,2,1) == 1._wp ) THEN
-                  DO jj = 2, ispongearea
-                     zramp = ( ispongearea-jj ) * z1spongearea
-                     ztabramp(ji,jj) = MAX( ztabramp(ji,jj), zramp )
-                  END DO
-               ENDIF
+            ind1 = 1+nbghostcells
+            ind2 = 1+nbghostcells + (ispongearea-1)
+            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
 
+         ! --- North --- !
          IF( (nbondj == 1) .OR. (nbondj == 2) ) THEN
-            DO ji = 1, jpi
-               IF ( vmask(ji,nlcj-2,1) == 1._wp ) THEN
-                  DO jj = ilcj+1,nlcj-1
-                     zramp = (jj - (ilcj+1) ) * z1spongearea
-                     ztabramp(ji,jj) = MAX( ztabramp(ji,jj), zramp )
-                  END DO
-               ENDIF
+            ind1 = nlcj - (1+nbghostcells) - (ispongearea-1)
+            ind2 = nlcj - (1+nbghostcells)
+            DO jj = ind1, ind2
+               DO ji = 1, jpi
+                  ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( jj - ind2 ) * z1_spongearea * vmask(ji,ind2-1,1) )
+               END DO
             ENDDO
          ENDIF
@@ -158,11 +153,11 @@
          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
-
+               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( fsaht_spu, 'U', 1. )   ! Lateral boundary conditions
          CALL lbc_lnk( fsaht_spv, 'V', 1. )
+         
          spongedoneT = .TRUE.
       ENDIF
@@ -179,11 +174,9 @@
             END DO
          END DO
-
          CALL lbc_lnk( fsahm_spt, 'T', 1. )   ! Lateral boundary conditions
          CALL lbc_lnk( fsahm_spf, 'F', 1. )
+         
          spongedoneU = .TRUE.
       ENDIF
-      !
-      IF (.NOT.ll_spdone) CALL wrk_dealloc( jpi, jpj, ztabramp )
       !
 #endif
@@ -205,4 +198,5 @@
       REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: ztu, ztv
       REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2) ::tsbdiff
+      !!---------------------------------------------    
       !
       IF( before ) THEN
@@ -327,5 +321,5 @@
 
          jmax = j2-1
-         IF ((nbondj == 1).OR.(nbondj == 2)) jmax = MIN(jmax,nlcj-3)
+         IF ((nbondj == 1).OR.(nbondj == 2)) jmax = MIN(jmax,nlcj-nbghostcells-2)   ! North
 
          DO jj = j1+1, jmax
@@ -404,5 +398,5 @@
 
          imax = i2-1
-         IF ((nbondi == 1).OR.(nbondi == 2))   imax = MIN(imax,nlci-3)
+         IF ((nbondi == 1).OR.(nbondi == 2))   imax = MIN(imax,nlci-nbghostcells-2)   ! East
 
          DO jj = j1+1, j2
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_top_interp.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_top_interp.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_top_interp.F90	(revision 8129)
@@ -50,134 +50,120 @@
       !
       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
-      INTEGER :: imin, imax, jmin, jmax
-      REAL(wp) ::   zrhox , zalpha1, zalpha2, zalpha3
-      REAL(wp) ::   zalpha4, zalpha5, zalpha6, zalpha7
-      LOGICAL :: western_side, eastern_side,northern_side,southern_side
-
+      INTEGER  ::   imin, imax, jmin, jmax
+      REAL(wp) ::   zrhox, z1, z2, z3, z4, z5, z6, z7
+      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
+      !!-----------------------------------------------------------------------
+      !
       IF (before) THEN         
          ptab(i1:i2,j1:j2,k1:k2,n1:n2) = trn(i1:i2,j1:j2,k1:k2,n1:n2)
       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()
-         ! 
-         zalpha1 = ( zrhox - 1. ) * 0.5
-         zalpha2 = 1. - zalpha1
-         ! 
-         zalpha3 = ( zrhox - 1. ) / ( zrhox + 1. )
-         zalpha4 = 1. - zalpha3
-         ! 
-         zalpha6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. )
-         zalpha7 =    - ( zrhox - 1. ) / ( zrhox + 3. )
-         zalpha5 = 1. - zalpha6 - zalpha7
-         !
-         imin = i1
-         imax = i2
-         jmin = j1
-         jmax = j2
-         ! 
-         ! Remove CORNERS
-         IF((nbondj == -1).OR.(nbondj == 2)) jmin = 3
-         IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj-2
-         IF((nbondi == -1).OR.(nbondi == 2)) imin = 3
-         IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci-2        
-         !
-         IF( eastern_side) THEN
-            DO jn = 1, jptra
-               tra(nlci,j1:j2,k1:k2,jn) = zalpha1 * ptab(nlci,j1:j2,k1:k2,jn) + zalpha2 * ptab(nlci-1,j1:j2,k1:k2,jn)
-               DO jk = 1, jpkm1
-                  DO jj = jmin,jmax
-                     IF( umask(nlci-2,jj,jk) == 0.e0 ) THEN
-                        tra(nlci-1,jj,jk,jn) = tra(nlci,jj,jk,jn) * tmask(nlci-1,jj,jk)
-                     ELSE
-                        tra(nlci-1,jj,jk,jn)=(zalpha4*tra(nlci,jj,jk,jn)+zalpha3*tra(nlci-2,jj,jk,jn))*tmask(nlci-1,jj,jk)
-                        IF( un(nlci-2,jj,jk) > 0.e0 ) THEN
-                           tra(nlci-1,jj,jk,jn)=( zalpha6*tra(nlci-2,jj,jk,jn)+zalpha5*tra(nlci,jj,jk,jn) & 
-                                 + zalpha7*tra(nlci-3,jj,jk,jn) ) * tmask(nlci-1,jj,jk)
+         IF( nbghostcells > 1 ) THEN  ! no smoothing
+            tra(i1:i2,j1:j2,k1:k2,n1:n2) = ptab(i1:i2,j1:j2,k1:k2,n1:n2)
+         ELSE                         ! smoothing
+            !
+            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()
+            z1 = ( zrhox - 1. ) * 0.5
+            z3 = ( zrhox - 1. ) / ( zrhox + 1. )
+            z6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. )
+            z7 =    - ( zrhox - 1. ) / ( zrhox + 3. )
+            !
+            z2 = 1. - z1
+            z4 = 1. - z3
+            z5 = 1. - z6 - z7
+            !
+            imin = i1 ; imax = i2
+            jmin = j1 ; jmax = j2
+            ! 
+            ! Remove CORNERS
+            IF((nbondj == -1).OR.(nbondj == 2)) jmin = 3
+            IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj-2
+            IF((nbondi == -1).OR.(nbondi == 2)) imin = 3
+            IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci-2        
+            !
+            IF( eastern_side) THEN
+               DO jn = 1, jptra
+                  tra(nlci,j1:j2,k1:k2,jn) = z1 * ptab(nlci,j1:j2,k1:k2,jn) + z2 * ptab(nlci-1,j1:j2,k1:k2,jn)
+                  DO jk = 1, jpkm1
+                     DO jj = jmin,jmax
+                        IF( umask(nlci-2,jj,jk) == 0.e0 ) THEN
+                           tra(nlci-1,jj,jk,jn) = tra(nlci,jj,jk,jn) * tmask(nlci-1,jj,jk)
+                        ELSE
+                           tra(nlci-1,jj,jk,jn)=(z4*tra(nlci,jj,jk,jn)+z3*tra(nlci-2,jj,jk,jn))*tmask(nlci-1,jj,jk)
+                           IF( un(nlci-2,jj,jk) > 0.e0 ) THEN
+                              tra(nlci-1,jj,jk,jn)=( z6*tra(nlci-2,jj,jk,jn)+z5*tra(nlci,jj,jk,jn) & 
+                                                   + z7*tra(nlci-3,jj,jk,jn) ) * tmask(nlci-1,jj,jk)
+                           ENDIF
                         ENDIF
-                     ENDIF
+                     END DO
+                  END DO
+               ENDDO
+            ENDIF
+            ! 
+            IF( northern_side ) THEN            
+               DO jn = 1, jptra
+                  tra(i1:i2,nlcj,k1:k2,jn) = z1 * ptab(i1:i2,nlcj,k1:k2,jn) + z2 * ptab(i1:i2,nlcj-1,k1:k2,jn)
+                  DO jk = 1, jpkm1
+                     DO ji = imin,imax
+                        IF( vmask(ji,nlcj-2,jk) == 0.e0 ) THEN
+                           tra(ji,nlcj-1,jk,jn) = tra(ji,nlcj,jk,jn) * tmask(ji,nlcj-1,jk)
+                        ELSE
+                           tra(ji,nlcj-1,jk,jn)=(z4*tra(ji,nlcj,jk,jn)+z3*tra(ji,nlcj-2,jk,jn))*tmask(ji,nlcj-1,jk)        
+                           IF (vn(ji,nlcj-2,jk) > 0.e0 ) THEN
+                              tra(ji,nlcj-1,jk,jn)=( z6*tra(ji,nlcj-2,jk,jn)+z5*tra(ji,nlcj,jk,jn)  &
+                                                   + z7*tra(ji,nlcj-3,jk,jn) ) * tmask(ji,nlcj-1,jk)
+                           ENDIF
+                        ENDIF
+                     END DO
+                  END DO
+               ENDDO
+            ENDIF
+            !
+            IF( western_side) THEN            
+               DO jn = 1, jptra
+                  tra(1,j1:j2,k1:k2,jn) = z1 * ptab(1,j1:j2,k1:k2,jn) + z2 * ptab(2,j1:j2,k1:k2,jn)
+                  DO jk = 1, jpkm1
+                     DO jj = jmin,jmax
+                        IF( umask(2,jj,jk) == 0.e0 ) THEN
+                           tra(2,jj,jk,jn) = tra(1,jj,jk,jn) * tmask(2,jj,jk)
+                        ELSE
+                           tra(2,jj,jk,jn)=(z4*tra(1,jj,jk,jn)+z3*tra(3,jj,jk,jn))*tmask(2,jj,jk)        
+                           IF( un(2,jj,jk) < 0.e0 ) THEN
+                              tra(2,jj,jk,jn)=(z6*tra(3,jj,jk,jn)+z5*tra(1,jj,jk,jn)+z7*tra(4,jj,jk,jn))*tmask(2,jj,jk)
+                           ENDIF
+                        ENDIF
+                     END DO
                   END DO
                END DO
-            ENDDO
+            ENDIF
+            !
+            IF( southern_side ) THEN           
+               DO jn = 1, jptra
+                  tra(i1:i2,1,k1:k2,jn) = z1 * ptab(i1:i2,1,k1:k2,jn) + z2 * ptab(i1:i2,2,k1:k2,jn)
+                  DO jk=1,jpk      
+                     DO ji=imin,imax
+                        IF( vmask(ji,2,jk) == 0.e0 ) THEN
+                           tra(ji,2,jk,jn)=tra(ji,1,jk,jn) * tmask(ji,2,jk)
+                        ELSE
+                           tra(ji,2,jk,jn)=(z4*tra(ji,1,jk,jn)+z3*tra(ji,3,jk,jn))*tmask(ji,2,jk)
+                           IF( vn(ji,2,jk) < 0.e0 ) THEN
+                              tra(ji,2,jk,jn)=(z6*tra(ji,3,jk,jn)+z5*tra(ji,1,jk,jn)+z7*tra(ji,4,jk,jn))*tmask(ji,2,jk)
+                           ENDIF
+                        ENDIF
+                     END DO
+                  END DO
+               ENDDO
+            ENDIF
+            !
+            ! Treatment of corners
+            IF ((eastern_side).AND.((nbondj == -1).OR.(nbondj == 2)))  tra(nlci-1,2,:,:) = ptab(nlci-1,2,:,:)            ! East south
+            IF ((eastern_side).AND.((nbondj ==  1).OR.(nbondj == 2)))  tra(nlci-1,nlcj-1,:,:) = ptab(nlci-1,nlcj-1,:,:)  ! East north
+            IF ((western_side).AND.((nbondj == -1).OR.(nbondj == 2)))  tra(2,2,:,:) = ptab(2,2,:,:)                      ! West south
+            IF ((western_side).AND.((nbondj ==  1).OR.(nbondj == 2)))  tra(2,nlcj-1,:,:) = ptab(2,nlcj-1,:,:)            ! West north
+            !
          ENDIF
-         ! 
-         IF( northern_side ) THEN            
-            DO jn = 1, jptra
-               tra(i1:i2,nlcj,k1:k2,jn) = zalpha1 * ptab(i1:i2,nlcj,k1:k2,jn) + zalpha2 * ptab(i1:i2,nlcj-1,k1:k2,jn)
-               DO jk = 1, jpkm1
-                  DO ji = imin,imax
-                     IF( vmask(ji,nlcj-2,jk) == 0.e0 ) THEN
-                        tra(ji,nlcj-1,jk,jn) = tra(ji,nlcj,jk,jn) * tmask(ji,nlcj-1,jk)
-                     ELSE
-                        tra(ji,nlcj-1,jk,jn)=(zalpha4*tra(ji,nlcj,jk,jn)+zalpha3*tra(ji,nlcj-2,jk,jn))*tmask(ji,nlcj-1,jk)        
-                        IF (vn(ji,nlcj-2,jk) > 0.e0 ) THEN
-                           tra(ji,nlcj-1,jk,jn)=( zalpha6*tra(ji,nlcj-2,jk,jn)+zalpha5*tra(ji,nlcj,jk,jn)  &
-                                 + zalpha7*tra(ji,nlcj-3,jk,jn) ) * tmask(ji,nlcj-1,jk)
-                        ENDIF
-                     ENDIF
-                  END DO
-               END DO
-            ENDDO
-         ENDIF
-         !
-         IF( western_side) THEN            
-            DO jn = 1, jptra
-               tra(1,j1:j2,k1:k2,jn) = zalpha1 * ptab(1,j1:j2,k1:k2,jn) + zalpha2 * ptab(2,j1:j2,k1:k2,jn)
-               DO jk = 1, jpkm1
-                  DO jj = jmin,jmax
-                     IF( umask(2,jj,jk) == 0.e0 ) THEN
-                        tra(2,jj,jk,jn) = tra(1,jj,jk,jn) * tmask(2,jj,jk)
-                     ELSE
-                        tra(2,jj,jk,jn)=(zalpha4*tra(1,jj,jk,jn)+zalpha3*tra(3,jj,jk,jn))*tmask(2,jj,jk)        
-                        IF( un(2,jj,jk) < 0.e0 ) THEN
-                           tra(2,jj,jk,jn)=(zalpha6*tra(3,jj,jk,jn)+zalpha5*tra(1,jj,jk,jn)+zalpha7*tra(4,jj,jk,jn))*tmask(2,jj,jk)
-                        ENDIF
-                     ENDIF
-                  END DO
-               END DO
-            END DO
-         ENDIF
-         !
-         IF( southern_side ) THEN           
-            DO jn = 1, jptra
-               tra(i1:i2,1,k1:k2,jn) = zalpha1 * ptab(i1:i2,1,k1:k2,jn) + zalpha2 * ptab(i1:i2,2,k1:k2,jn)
-               DO jk=1,jpk      
-                  DO ji=imin,imax
-                     IF( vmask(ji,2,jk) == 0.e0 ) THEN
-                        tra(ji,2,jk,jn)=tra(ji,1,jk,jn) * tmask(ji,2,jk)
-                     ELSE
-                        tra(ji,2,jk,jn)=(zalpha4*tra(ji,1,jk,jn)+zalpha3*tra(ji,3,jk,jn))*tmask(ji,2,jk)
-                        IF( vn(ji,2,jk) < 0.e0 ) THEN
-                           tra(ji,2,jk,jn)=(zalpha6*tra(ji,3,jk,jn)+zalpha5*tra(ji,1,jk,jn)+zalpha7*tra(ji,4,jk,jn))*tmask(ji,2,jk)
-                        ENDIF
-                     ENDIF
-                  END DO
-               END DO
-            ENDDO
-         ENDIF
-         !
-         ! Treatment of corners
-         ! 
-         ! East south
-         IF ((eastern_side).AND.((nbondj == -1).OR.(nbondj == 2))) THEN
-            tra(nlci-1,2,:,:) = ptab(nlci-1,2,:,:)
-         ENDIF
-         ! East north
-         IF ((eastern_side).AND.((nbondj == 1).OR.(nbondj == 2))) THEN
-            tra(nlci-1,nlcj-1,:,:) = ptab(nlci-1,nlcj-1,:,:)
-         ENDIF
-         ! West south
-         IF ((western_side).AND.((nbondj == -1).OR.(nbondj == 2))) THEN
-            tra(2,2,:,:) = ptab(2,2,:,:)
-         ENDIF
-         ! West north
-         IF ((western_side).AND.((nbondj == 1).OR.(nbondj == 2))) THEN
-            tra(2,nlcj-1,:,:) = ptab(2,nlcj-1,:,:)
-         ENDIF
-         !
       ENDIF
       !
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 8129)
@@ -127,10 +127,17 @@
    !!
    IMPLICIT NONE
+   !
+   INTEGER :: ind1, ind2, ind3
    !!----------------------------------------------------------------------
 
    ! 1. Declaration of the type of variable which have to be interpolated
    !---------------------------------------------------------------------
-   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e1u_id)
-   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e2v_id)
+   !!clem ghost
+   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)
+   !!clem ghost
 
    ! 2. Type of interpolation
@@ -141,6 +148,8 @@
    ! 3. Location of interpolation
    !-----------------------------
-   CALL Agrif_Set_bc(e1u_id,(/0,0/))
-   CALL Agrif_Set_bc(e2v_id,(/0,0/))
+   !!clem ghost (previously set to /0,0/)
+   CALL Agrif_Set_bc(e1u_id,(/0,ind1/))
+   CALL Agrif_Set_bc(e2v_id,(/0,ind1/))
+   !!clem ghost
 
    ! 5. Update type
@@ -337,43 +346,50 @@
    !!----------------------------------------------------------------------
    USE agrif_util
-   USE par_oce       !   ONLY : jpts
+   USE par_oce       !   ONLY : jpts and ghostcells
    USE oce
    USE agrif_oce
    !!
    IMPLICIT NONE
+   !
+   INTEGER :: ind1, ind2, ind3
    !!----------------------------------------------------------------------
 
    ! 1. Declaration of the type of variable which have to be interpolated
    !---------------------------------------------------------------------
-   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_id)
-   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_sponge_id)
-
-   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_interp_id)
-   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_interp_id)
-   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_update_id)
-   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_update_id)
-   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_sponge_id)
-   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_sponge_id)
-
-   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),e3t_id)
-   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),umsk_id)
-   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vmsk_id)
-
-   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,3/),scales_t_id)
-
-   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),unb_id)
-   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vnb_id)
-   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_interp_id)
-   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_interp_id)
-   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_update_id)
-   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_update_id)
-
-   CALL agrif_declare_variable((/2,2/),(/3,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),sshn_id)
+   !!clem ghost
+   ind1 =     nbghostcells
+   ind2 = 1 + nbghostcells
+   ind3 = 2 + nbghostcells
+   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/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_interp_id)
+   CALL agrif_declare_variable((/2,1,0/),(/ind3,ind2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_interp_id)
+   CALL agrif_declare_variable((/1,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_update_id)
+   CALL agrif_declare_variable((/2,1,0/),(/ind3,ind2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_update_id)
+   CALL agrif_declare_variable((/1,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_sponge_id)
+   CALL agrif_declare_variable((/2,1,0/),(/ind3,ind2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_sponge_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 defined key_zdftke
-   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/), en_id)
-   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id)
-   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avm_id)
+   CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/), en_id)
+   CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id)
+   CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avm_id)
 # endif
+   !!clem ghost
 
    ! 2. Type of interpolation
@@ -407,28 +423,29 @@
    ! 3. Location of interpolation
    !-----------------------------
-   CALL Agrif_Set_bc(tsn_id,(/0,1/))
-   CALL Agrif_Set_bc(un_interp_id,(/0,1/))
-   CALL Agrif_Set_bc(vn_interp_id,(/0,1/))
-
-!   CALL Agrif_Set_bc(tsn_sponge_id,(/-3*Agrif_irhox(),0/))
-!   CALL Agrif_Set_bc(un_sponge_id,(/-2*Agrif_irhox()-1,0/))
-!   CALL Agrif_Set_bc(vn_sponge_id,(/-2*Agrif_irhox()-1,0/))
-   CALL Agrif_Set_bc(tsn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/))
+   !!clem ghost
+   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/))
+
+   ! clem: previously set to /-,0/
+   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,0/))
-   CALL Agrif_Set_bc(unb_id ,(/0,0/))
-   CALL Agrif_Set_bc(vnb_id ,(/0,0/))
-   CALL Agrif_Set_bc(ub2b_interp_id,(/0,0/))
-   CALL Agrif_Set_bc(vb2b_interp_id,(/0,0/))
-
-   CALL Agrif_Set_bc(e3t_id,(/-2*Agrif_irhox()-1,0/))   ! if west and rhox=3: column 2 to 9
-   CALL Agrif_Set_bc(umsk_id,(/0,0/))
-   CALL Agrif_Set_bc(vmsk_id,(/0,0/))
-
+   CALL Agrif_Set_bc(sshn_id,(/0,ind1/))
+   CALL Agrif_Set_bc(unb_id ,(/0,ind1/))
+   CALL Agrif_Set_bc(vnb_id ,(/0,ind1/))
+   CALL Agrif_Set_bc(ub2b_interp_id,(/0,ind1/))
+   CALL Agrif_Set_bc(vb2b_interp_id,(/0,ind1/))
+
+   CALL Agrif_Set_bc(e3t_id,(/-2*Agrif_irhox()-1,ind1/))   ! if west and rhox=3 and ghost=1: column 1 to 9
+   CALL Agrif_Set_bc(umsk_id,(/0,ind1/))
+   CALL Agrif_Set_bc(vmsk_id,(/0,ind1/))
+
+   ! clem: previously set to /0,1/
 # if defined key_zdftke
-   CALL Agrif_Set_bc(avm_id ,(/0,1/))
+   CALL Agrif_Set_bc(avm_id ,(/0,ind1/))
 # endif
+   !!clem ghost
 
    ! 5. Update type
@@ -623,6 +640,9 @@
    USE Agrif_Util
    USE ice
-
-   IMPLICIT NONE
+   USE par_oce, ONLY : nbghostcells
+   !
+   IMPLICIT NONE
+   !
+   INTEGER :: ind1, ind2, ind3
    !!----------------------------------------------------------------------
    !
@@ -634,7 +654,12 @@
    !                            2,2 = two ghost lines
    !-------------------------------------------------------------------------------------
-   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpl*(5+nlay_s+nlay_i)/),tra_ice_id )
-   CALL agrif_declare_variable((/1,2/)    ,(/2,3/),(/'x','y'/)    ,(/1,1/)  ,(/nlci,nlcj/)                      ,u_ice_id   )
-   CALL agrif_declare_variable((/2,1/)    ,(/3,2/),(/'x','y'/)    ,(/1,1/)  ,(/nlci,nlcj/)                      ,v_ice_id   )
+   !!clem ghost
+   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*(5+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   )
+   !!clem ghost
 
    ! 2. Set interpolations (normal & tangent to the grid cell for velocities)
@@ -646,7 +671,9 @@
    ! 3. Set location of interpolations
    !----------------------------------
-   CALL Agrif_Set_bc(tra_ice_id,(/0,1/))
-   CALL Agrif_Set_bc(u_ice_id  ,(/0,1/))
-   CALL Agrif_Set_bc(v_ice_id  ,(/0,1/))
+   !!clem ghost
+   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/))
+   !!clem ghost
 
    ! 4. Set update type in case 2 ways (child=>parent) (normal & tangent to the grid cell for velocities)
@@ -777,10 +804,16 @@
    !!
    IMPLICIT NONE
+   !
+   INTEGER :: ind1, ind2, ind3
    !!----------------------------------------------------------------------
 
    ! 1. Declaration of the type of variable which have to be interpolated
    !---------------------------------------------------------------------
-   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)
+   !!clem ghost
+   ind1 =     nbghostcells
+   ind2 = 1 + nbghostcells
+   ind3 = 2 + nbghostcells
+   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)
 
    ! 2. Type of interpolation
@@ -791,7 +824,8 @@
    ! 3. Location of interpolation
    !-----------------------------
-   CALL Agrif_Set_bc(trn_id,(/0,1/))
-!   CALL Agrif_Set_bc(trn_sponge_id,(/-3*Agrif_irhox(),0/))
-   CALL Agrif_Set_bc(trn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/))
+   !!clem ghost
+   CALL Agrif_Set_bc(trn_id,(/0,ind1/))
+   !clem: previously set to /-,0/
+   CALL Agrif_Set_bc(trn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,ind1/))
 
    ! 5. Update type
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 8129)
@@ -1012,5 +1012,7 @@
       CALL lim_wri_state_2( kt, id_i, nh_i )
 #elif defined key_lim3
-      CALL lim_wri_state( kt, id_i, nh_i )
+      IF( nn_ice == 3 ) THEN   ! clem2017: condition in case agrif + lim but no-ice in child grid
+         CALL lim_wri_state( kt, id_i, nh_i )
+      ENDIF
 #else
       CALL histend( id_i, snc4chunks=snc4set )
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 8129)
@@ -116,5 +116,5 @@
    END TYPE WGT
 
-   INTEGER,     PARAMETER             ::   tot_wgts = 10
+   INTEGER,     PARAMETER             ::   tot_wgts = 20
    TYPE( WGT ), DIMENSION(tot_wgts)   ::   ref_wgts     ! array of wgts
    INTEGER                            ::   nxt_wgt = 1  ! point to next available space in ref_wgts array
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 8129)
@@ -328,11 +328,13 @@
       IF( ln_ssr      )   CALL sbc_ssr_init            ! Sea-Surface Restoring initialization
       !
-      IF( ln_isf      )   CALL sbc_isf_init               ! Compute iceshelves
+      IF( ln_isf      )   CALL sbc_isf_init            ! Compute iceshelves
       !
                           CALL sbc_rnf_init            ! Runof initialization
       !
-      IF( nn_ice == 3 )   CALL sbc_lim_init            ! LIM3 initialization
-      !
-      IF( nn_ice == 4 )   CALL cice_sbc_init( nsbc )   ! CICE initialization
+      IF    ( lk_agrif .AND. nn_ice == 0 ) THEN
+                         IF( sbc_ice_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_ice_alloc : unable to allocate arrays' )  ! clem2017: allocate ice arrays in case agrif + lim + no-ice in child grid              
+      ELSEIF(                nn_ice == 3 ) THEN   ;   CALL sbc_lim_init            ! LIM3 initialization
+      ELSEIF(                nn_ice == 4 ) THEN   ;   CALL cice_sbc_init( nsbc )   ! CICE initialization
+      ENDIF
       !
       IF( ln_wave     )   CALL sbc_wave_init              ! surface wave initialisation
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 8129)
@@ -206,10 +206,10 @@
       !
 #if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
+!!clem2017      IF( .NOT. Agrif_Root() ) THEN
                          CALL Agrif_ParentGrid_To_ChildGrid()
          IF( ln_diaobs ) CALL dia_obs_wri
          IF( nn_timing == 1 )   CALL timing_finalize
                                 CALL Agrif_ChildGrid_To_ParentGrid()
-      ENDIF
+!!clem2017      ENDIF
 #endif
       IF( nn_timing == 1 )   CALL timing_finalize
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/SAS_SRC/diawri.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/SAS_SRC/diawri.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/SAS_SRC/diawri.F90	(revision 8129)
@@ -400,5 +400,7 @@
       CALL lim_wri_state_2( kt, id_i, nh_i )
 #elif defined key_lim3
-      CALL lim_wri_state( kt, id_i, nh_i )
+      IF( nn_ice == 3 ) THEN   ! clem2017: condition in case agrif + lim but no-ice in child grid
+         CALL lim_wri_state( kt, id_i, nh_i )
+      ENDIF
 #else
       CALL histend( id_i, snc4chunks=snc4set )
Index: branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90
===================================================================
--- branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90	(revision 8128)
+++ branches/2017/dev_r8127_AGRIF_LIM3_GHOST/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90	(revision 8129)
@@ -134,9 +134,9 @@
       !
 #if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
+!!clem2017      IF( .NOT. Agrif_Root() ) THEN
          CALL Agrif_ParentGrid_To_ChildGrid()
          IF( nn_timing == 1 )   CALL timing_finalize
          CALL Agrif_ChildGrid_To_ParentGrid()
-      ENDIF
+!!clem2017      ENDIF
 #endif
       IF( nn_timing == 1 )   CALL timing_finalize
