Index: trunk/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- trunk/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 3294)
+++ trunk/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 3604)
@@ -29,5 +29,5 @@
    !!   stp             : OPA system time-stepping
    !!----------------------------------------------------------------------
-   USE step_oce         ! time stepping definition modules 
+   USE step_oce         ! time stepping definition modules
 #if defined key_top
    USE trcstp           ! passive tracer time-stepping      (trc_stp routine)
@@ -61,13 +61,13 @@
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE stp  ***
-      !!                      
+      !!
       !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
       !!              - Time stepping of LIM (dynamic and thermodynamic eqs.)
       !!              - Tme stepping  of TRC (passive tracer eqs.)
-      !! 
-      !! ** Method  : -1- Update forcings and data  
-      !!              -2- Update ocean physics 
-      !!              -3- Compute the t and s trends 
-      !!              -4- Update t and s 
+      !!
+      !! ** Method  : -1- Update forcings and data
+      !!              -2- Update ocean physics
+      !!              -3- Compute the t and s trends
+      !!              -4- Update t and s
       !!              -5- Compute the momentum trends
       !!              -6- Update the horizontal velocity
@@ -85,6 +85,6 @@
 # if defined key_iomput
       IF( Agrif_Nbstepint() == 0 )   CALL iom_swap
-# endif   
-#endif   
+# endif
+#endif
                              indic = 0                ! reset to no error condition
       IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
@@ -111,7 +111,7 @@
                          CALL bn2( tsn, rn2  )        ! now    Brunt-Vaisala frequency
       !
-      !  VERTICAL PHYSICS   
+      !  VERTICAL PHYSICS
                          CALL zdf_bfr( kstp )         ! bottom friction
-                         
+
       !                                               ! Vertical eddy viscosity and diffusivity coefficients
       IF( lk_zdfric  )   CALL zdf_ric( kstp )            ! Richardson number dependent Kz
@@ -133,5 +133,5 @@
       IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
          &               CALL zdf_ddm( kstp )         ! double diffusive mixing
-         
+
                          CALL zdf_mxl( kstp )         ! mixed layer depth
 
@@ -140,5 +140,5 @@
       IF( lrst_oce .AND. lk_zdfgls )   CALL gls_rst( kstp, 'WRITE' )
       !
-      !  LATERAL  PHYSICS 
+      !  LATERAL  PHYSICS
       !
       IF( lk_ldfslp ) THEN                            ! slope of lateral mixing
@@ -179,4 +179,7 @@
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                              tsa(:,:,:,:) = 0.e0            ! set tracer trends to zero
+      ! Saving non-linear trajectory at restart state
+      ! May not be exact for sbc and zdf parameters
+      IF( ( ln_trjhand ) .AND. ( kstp == nit000 ) ) CALL tam_trj_wri( kstp - 1 )
 
       IF(  ln_asmiau .AND. &
@@ -201,5 +204,5 @@
          IF( ln_zps      )   CALL zps_hde( kstp, jpts, tsa, gtsu, gtsv,  &    ! zps: time filtered hor. derivative
             &                                          rhd, gru , grv  )      ! of t, s, rd at the last ocean level
-         
+
       ELSE                                                  ! centered hpg  (eos then time stepping)
                              CALL eos    ( tsn, rhd, rhop )      ! now in situ density for hpg computation
@@ -208,5 +211,5 @@
          IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection
                              CALL tra_nxt( kstp )                ! tracer fields at next time step
-      ENDIF 
+      ENDIF
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -218,4 +221,5 @@
       IF(  ln_asmiau .AND. &
          & ln_dyninc       )   CALL dyn_asm_inc( kstp )     ! apply dynamics assimilation increment
+      IF( ln_bkgwri )          CALL asm_bkg_wri( kstp )     ! output background fields
       IF( ln_neptsimp )        CALL dyn_nept_cor( kstp )    ! subtract Neptune velocities (simplified)
                                CALL dyn_adv( kstp )         ! advection (vector or flux form)
@@ -227,5 +231,5 @@
 #endif
                                CALL dyn_hpg( kstp )         ! horizontal gradient of Hydrostatic pressure
-                               CALL dyn_bfr( kstp )         ! bottom friction   
+                               CALL dyn_bfr( kstp )         ! bottom friction
                                CALL dyn_zdf( kstp )         ! vertical diffusion
                                CALL dyn_spg( kstp, indic )  ! surface pressure gradient
@@ -252,10 +256,16 @@
       ! Trends                              (ua, va, tsa used as workspace)
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( nstop == 0 ) THEN                         
-         IF( lk_trddyn     )   CALL trd_dwr( kstp )         ! trends: dynamics 
+      IF( nstop == 0 ) THEN
+         IF( lk_trddyn     )   CALL trd_dwr( kstp )         ! trends: dynamics
          IF( lk_trdtra     )   CALL trd_twr( kstp )         ! trends: active tracers
-         IF( lk_trdmld     )   CALL trd_mld( kstp )         ! trends: Mixed-layer 
+         IF( lk_trdmld     )   CALL trd_mld( kstp )         ! trends: Mixed-layer
          IF( lk_trdvor     )   CALL trd_vor( kstp )         ! trends: vorticity budget
       ENDIF
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Trajectory for TAM
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+      IF( ln_trjhand ) CALL tam_trj_wri( kstp )          ! Output trajectory fields
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
