Index: trunk/NEMO/TOP_SRC/trcwri.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcwri.F90	(revision 1656)
+++ trunk/NEMO/TOP_SRC/trcwri.F90	(revision 1836)
@@ -1,9 +1,9 @@
 MODULE trcwri
-   !!======================================================================
+   !!===================================================================================
    !!                       *** MODULE trcwri ***
-   !!    TOP :   Output of passive tracers 
-   !!======================================================================
-   !!             1.0  !  
-   !!                  !  2009-05 (C. Ethe )
+   !!    TOP :   Output of passive tracers
+   !!====================================================================================
+   !! History :   1.0  !  2009-05 (C. Ethe)  Original code
+   !!                  !  2010-03 (C. Ethe, R. Seferian ) Add the tracer transport trends
    !!----------------------------------------------------------------------
 #if defined key_top &&  defined key_iomput
@@ -11,7 +11,12 @@
    !!   'key_top' && 'key_iomput'                              TOP models
    !!----------------------------------------------------------------------
-   !! trc_wri     :  outputs of concentration fields
+   !! trc_wri_trc   :  outputs of concentration fields
+   !! trc_wri_trd   :  outputs of transport trends
    !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain variables
+   USE oce_trc
+   USE trp_trc
    USE trc
+   USE trdmld_trc_oce, ONLY : luttrd
    USE iom
 #if defined key_off_tra
@@ -35,7 +40,24 @@
 CONTAINS
 
-   SUBROUTINE trc_wri( kt )  
+   SUBROUTINE trc_wri( kt )
       !!---------------------------------------------------------------------
       !!                     ***  ROUTINE trc_wri  ***
+      !! 
+      !! ** Purpose :   output passive tracers fields and dynamical trends
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) :: kt
+      !!---------------------------------------------------------------------
+
+      !
+      CALL iom_setkt  ( kt + ndttrc - 1 )       ! set the passive tracer time step
+      CALL trc_wri_trc( kt              )       ! outputs for tracer concentration
+      CALL trc_wri_trd( kt              )       ! outputs for dynamical trends
+      CALL iom_setkt  ( kt              )       ! set the model time step
+      !
+   END SUBROUTINE trc_wri
+
+   SUBROUTINE trc_wri_trc( kt )  
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_wri_trc  ***
       !!
       !! ** Purpose :   output passive tracers fields 
@@ -43,17 +65,11 @@
       INTEGER, INTENT( in ) :: kt       ! ocean time-step
       INTEGER               :: jn
-      CHARACTER (len=20)    :: cltra
+      CHARACTER (len=20)    :: cltra, cltras
 #if defined key_off_tra
       CHARACTER (len=40) :: clhstnam
       INTEGER ::   inum = 11            ! temporary logical unit
 #endif
-
       !!---------------------------------------------------------------------
  
-      ! Initialisation
-      ! --------------
-
-      CALL iom_setkt( kt + ndttrc - 1 ) ! set the passive tracer time step
-
 #if defined key_off_tra
       IF( kt == nittrc000 ) THEN
@@ -67,6 +83,4 @@
       ENDIF
 #endif
-
-
       ! write the tracer concentrations in the file
       ! ---------------------------------------
@@ -76,9 +90,53 @@
       END DO
       !
-      CALL iom_setkt( kt )       ! set the model time step
+   END SUBROUTINE trc_wri_trc
 
+# if defined key_trc_diatrd
+
+   SUBROUTINE trc_wri_trd( kt )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_wri_trd  ***
+      !!
+      !! ** Purpose :   output of passive tracer : advection-diffusion trends
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
+      !!
+      CHARACTER (len=3) ::   cltra
+      INTEGER  ::   jn, jl, ikn
+      !!----------------------------------------------------------------------
+
+      DO jn = 1, jptra
+         IF( luttrd(jn) ) THEN
+            ikn = ikeep(jn)
+            DO jl = 1, jpdiatrc
+               IF( jl == jptrc_xad ) WRITE (cltra,"(3a)") 'XAD' ! x advection for tracer
+               IF( jl == jptrc_yad ) WRITE (cltra,"(3a)") 'YAD'  ! y advection for tracer
+               IF( jl == jptrc_zad ) WRITE (cltra,"(3a)") 'ZAD'  ! z advection for tracer
+               IF( jl == jptrc_xdf ) WRITE (cltra,"(3a)") 'XDF'  ! x diffusion for tracer
+               IF( jl == jptrc_ydf ) WRITE (cltra,"(3a)") 'YDF'  ! y diffusion for tracer
+               IF( jl == jptrc_zdf ) WRITE (cltra,"(3a)") 'ZDF'  ! z diffusion for tracer
+# if defined key_trcldf_eiv
+               IF( jl == jptrc_xei ) WRITE (cltra,"(3a)") 'XGV'  ! x gent velocity for tracer
+               IF( jl == jptrc_yei ) WRITE (cltra,"(3a)") 'YGV'  ! y gent velocity for tracer
+               IF( jl == jptrc_zei ) WRITE (cltra,"(3a)") 'ZGV'  ! z gent velocity for tracer
+# endif
+# if defined key_trcdmp
+               IF( jl == jptrc_dmp ) WRITE (cltra,"(3a)") 'DMP'  ! damping
+# endif
+               IF( jl == jptrc_sbc ) WRITE (cltra,"(3a)") 'SBC'  ! surface boundary conditions
+               ! write the trends
+               CALL iom_put( cltra, trtrd(:,:,:,ikn,jl) )
+            END DO
+         END IF
+      END DO
       !
-   END SUBROUTINE trc_wri
+   END SUBROUTINE trc_wri_trd
 
+# else
+   SUBROUTINE trc_wri_trd( kt )                      ! Dummy routine
+      INTEGER, INTENT ( in ) ::   kt
+   END SUBROUTINE trc_wri_trd
+#endif
 #else
    !!----------------------------------------------------------------------
@@ -90,5 +148,4 @@
    INTEGER, INTENT(in) :: kt
    END SUBROUTINE trc_wri
-
 #endif
 
