Index: /NEMO/trunk/src/NST/agrif_all_update.F90
===================================================================
--- /NEMO/trunk/src/NST/agrif_all_update.F90	(revision 9780)
+++ /NEMO/trunk/src/NST/agrif_all_update.F90	(revision 9780)
@@ -0,0 +1,84 @@
+#define TWO_WAY
+
+ MODULE agrif_all_update
+   !!======================================================================
+   !!                   ***  MODULE  agrif_all_update  ***
+   !! AGRIF: Main update driver for ocean, ice and passive tracers
+   !!======================================================================
+   !! History :  4.0  !  2018-06  (J. Chanut)  Original code 
+   !!----------------------------------------------------------------------
+#if defined key_agrif 
+   !!----------------------------------------------------------------------
+   !!   'key_agrif'                                              AGRIF zoom
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE agrif_oce
+   USE agrif_oce_update
+#if defined key_top
+   USE agrif_top_update
+#endif
+#if defined key_si3
+   USE agrif_ice_update
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   Agrif_Update_All
+
+   !!----------------------------------------------------------------------
+   !! NEMO/NST 4.0 , NEMO Consortium (2018)
+   !! $Id: agrif_all_update.F90 9758 2018-06-07 09:18:26Z jchanut $
+   !! Software governed by the CeCILL licence (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE Agrif_Update_All( )
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_Update_All ***
+      !!
+      !! ** Purpose :: Update nested grids for all components (Ocean, Sea Ice, TOP)
+      !!               Order of update matters here !
+      !!----------------------------------------------------------------------
+# if defined TWO_WAY
+      IF (Agrif_Root()) RETURN
+      !
+      IF (lwp.AND.lk_agrif_debug) Write(*,*) ' --> START AGRIF UPDATE from grid Number',Agrif_Fixed()
+      !
+      CALL Agrif_Update_ssh()                      ! Update sea level
+      !
+      IF (.NOT.ln_linssh) CALL Agrif_Update_vvl()  ! Update scale factors
+      !
+      CALL Agrif_Update_tra()                      ! Update temperature/salinity
+      !
+#if defined key_top
+      CALL Agrif_Update_Trc()                      ! Update passive tracers
+#endif
+      !
+      CALL Agrif_Update_dyn()                      ! Update dynamics
+      !
+! JC remove update because this precludes from perfect restartability
+!!      CALL Agrif_Update_tke()                  ! Update tke 
+
+#if defined key_si3
+      CALL agrif_update_ice()                      ! Update sea ice
+#endif
+      IF (lwp.AND.lk_agrif_debug) Write(*,*) ' <-- END AGRIF UPDATE from grid Number',Agrif_Fixed()
+      !
+      Agrif_UseSpecialValueInUpdate = .FALSE.
+#endif
+    END SUBROUTINE agrif_Update_All
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Empty module                                          no AGRIF zoom
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE Agrif_Update_all( )
+      WRITE(*,*)  'Agrif_Update_All : You should not have seen this print! error?'
+   END SUBROUTINE Agrif_Update_all
+#endif
+
+   !!======================================================================
+END MODULE agrif_all_update
+
Index: /NEMO/trunk/src/NST/agrif_ice_update.F90
===================================================================
--- /NEMO/trunk/src/NST/agrif_ice_update.F90	(revision 9779)
+++ /NEMO/trunk/src/NST/agrif_ice_update.F90	(revision 9780)
@@ -42,5 +42,5 @@
 CONTAINS
 
-   SUBROUTINE agrif_update_ice( kt )
+   SUBROUTINE agrif_update_ice( )
       !!----------------------------------------------------------------------
       !!                     *** ROUTINE agrif_update_ice ***
@@ -49,10 +49,10 @@
       !! ** Action : - Update (u_ice,v_ice) and ice tracers
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) :: kt
-      !!----------------------------------------------------------------------
       !
       IF( Agrif_Root() .OR. nn_ice == 0 ) RETURN   ! do not update if inside Parent Grid or if child domain does not have ice
       !
-      IF( ( MOD( (kt-nit000)/nn_fsbc + 1, Agrif_irhot() * Agrif_Parent(nn_fsbc)/nn_fsbc ) /=0 ) .AND. (kt /= 0) ) RETURN   ! update only at the parent ice time step
+      IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update sea ice from grid Number',Agrif_Fixed()
+      !
+!      IF( ( MOD( (kt-nit000)/nn_fsbc + 1, Agrif_irhot() * Agrif_Parent(nn_fsbc)/nn_fsbc ) /=0 ) .AND. (kt /= 0) ) RETURN   ! update only at the parent ice time step
       !
       Agrif_SpecialValueFineGrid    = -9999.
Index: /NEMO/trunk/src/NST/agrif_oce_update.F90
===================================================================
--- /NEMO/trunk/src/NST/agrif_oce_update.F90	(revision 9779)
+++ /NEMO/trunk/src/NST/agrif_oce_update.F90	(revision 9780)
@@ -144,9 +144,14 @@
       Agrif_UseSpecialValueInUpdate = .FALSE.
       !
-#  if defined DECAL_FEEDBACK && defined VOL_REFLUX
+#  if defined VOL_REFLUX
       IF ( ln_dynspg_ts.AND.ln_bt_fw ) THEN
          ! Refluxing on ssh:
+#  if defined DECAL_FEEDBACK
          CALL Agrif_Update_Variable(ub2b_update_id,locupdate1=(/0, 0/),locupdate2=(/1, 1/),procname = reflux_sshu)
          CALL Agrif_Update_Variable(vb2b_update_id,locupdate1=(/1, 1/),locupdate2=(/0, 0/),procname = reflux_sshv)
+#  else
+         CALL Agrif_Update_Variable(ub2b_update_id,locupdate1=(/-1,-1/),locupdate2=(/ 0, 0/),procname = reflux_sshu)
+         CALL Agrif_Update_Variable(vb2b_update_id,locupdate1=(/ 0, 0/),locupdate2=(/-1,-1/),procname = reflux_sshv)
+#  endif
       END IF
 #  endif
@@ -157,14 +162,12 @@
 
 
-   SUBROUTINE Agrif_Update_Tke( kt )
+   SUBROUTINE Agrif_Update_Tke( )
       !!---------------------------------------------
       !!   *** ROUTINE Agrif_Update_Tke ***
       !!---------------------------------------------
       !!
-      INTEGER, INTENT(in) :: kt 
       ! 
       IF (Agrif_Root()) RETURN
       !       
-      IF( ( Agrif_NbStepint() .NE. 0 ) .AND. (kt /= 0) ) RETURN
 #  if defined TWO_WAY
 
Index: /NEMO/trunk/src/NST/agrif_user.F90
===================================================================
--- /NEMO/trunk/src/NST/agrif_user.F90	(revision 9779)
+++ /NEMO/trunk/src/NST/agrif_user.F90	(revision 9780)
@@ -64,9 +64,5 @@
    CALL Agrif_InitValues_cont_ice
 # endif
-   !
-   IF ( Agrif_Level().EQ.Agrif_MaxLevel() ) CALL agrif_Update_ini()
-
-   Agrif_UseSpecialValueInUpdate = .FALSE.     
-
+   !    
 END SUBROUTINE Agrif_initvalues
 
@@ -296,44 +292,4 @@
 END SUBROUTINE Agrif_InitValues_cont
 
-RECURSIVE SUBROUTINE Agrif_Update_ini( )
-   !!----------------------------------------------------------------------
-   !!                 *** ROUTINE agrif_Update_ini ***
-   !!
-   !! ** Purpose :: Recursive update done at initialization
-   !!----------------------------------------------------------------------
-   USE dom_oce
-   USE agrif_oce_update
-#if defined key_top
-   USE agrif_top_update
-#endif
-#if defined key_si3
-   USE agrif_ice_update
-#endif
-   !
-   IMPLICIT NONE
-   !!----------------------------------------------------------------------
-   !
-   IF (Agrif_Root()) RETURN
-   !
-   CALL Agrif_Update_ssh()
-   IF (.NOT.ln_linssh) CALL Agrif_Update_vvl()
-   CALL Agrif_Update_tra()
-#if defined key_top
-   CALL Agrif_Update_Trc()
-#endif
-   CALL Agrif_Update_dyn()
-! JC remove update because this precludes from perfect restartability
-!!   CALL Agrif_Update_tke(0)
-
-#if defined key_si3
-   CALL agrif_update_ice(0)
-#endif
-   
-   CALL Agrif_ChildGrid_To_ParentGrid()
-   CALL Agrif_Update_ini()
-   CALL Agrif_ParentGrid_To_ChildGrid()
-
-END SUBROUTINE agrif_update_ini
-
 SUBROUTINE agrif_declare_var
    !!----------------------------------------------------------------------
Index: /NEMO/trunk/src/OCE/nemogcm.F90
===================================================================
--- /NEMO/trunk/src/OCE/nemogcm.F90	(revision 9779)
+++ /NEMO/trunk/src/OCE/nemogcm.F90	(revision 9780)
@@ -89,4 +89,7 @@
    USE xios           ! xIOserver
 #endif
+#if defined key_agrif
+   USE agrif_all_update   ! Master Agrif update
+#endif
 
    IMPLICIT NONE
@@ -160,4 +163,7 @@
       !                                               !==  AGRIF time-stepping  ==!
       CALL Agrif_Regrid()
+      !
+      ! Recursive update from highest nested level to lowest:
+      CALL Agrif_step_child_adj(Agrif_Update_All)
       !
       DO WHILE( istp <= nitend .AND. nstop == 0 )
Index: /NEMO/trunk/src/OCE/step.F90
===================================================================
--- /NEMO/trunk/src/OCE/step.F90	(revision 9779)
+++ /NEMO/trunk/src/OCE/step.F90	(revision 9780)
@@ -294,17 +294,5 @@
                          CALL Agrif_Integrate_ChildGrids( stp )  ! allows to finish all the Child Grids before updating
 
-      IF( Agrif_NbStepint() == 0 ) THEN               ! AGRIF Update from zoom N to zoom 1 then to Parent 
-!!jc in fact update is useless at last time step, but do it for global diagnostics
-#if defined key_si3
-                              CALL Agrif_Update_ice( kstp )   ! update sea-ice
-#endif
-                              CALL Agrif_Update_ssh()          ! Update ssh
-         IF(.NOT.ln_linssh)   CALL Agrif_Update_vvl()          ! Update vertical scale factors  
-                              CALL Agrif_Update_Tra()          ! Update active tracers
-                              CALL Agrif_Update_Dyn()          ! Update momentum
-# if defined key_top
-                              CALL Agrif_Update_Trc()          ! Update passive tracers
-# endif
-      ENDIF
+                         IF( Agrif_NbStepint() == 0 ) CALL Agrif_update_all( ) ! Update all components
 #endif
       IF( ln_diaobs  )   CALL dia_obs      ( kstp )      ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
Index: /NEMO/trunk/src/OCE/step_oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/step_oce.F90	(revision 9779)
+++ /NEMO/trunk/src/OCE/step_oce.F90	(revision 9780)
@@ -104,11 +104,5 @@
 #if defined key_agrif
    USE agrif_oce_sponge ! Momemtum and tracers sponges
-   USE agrif_oce_update ! Update (2-way nesting)
-#if defined key_si3
-   USE agrif_ice_update
-#endif
-#if defined key_top
-   USE agrif_top_update ! passive tracers update (2-way nesting)
-#endif
+   USE agrif_all_update ! Main update driver
 #endif
 #if defined key_top
