Index: trunk/NEMO/TOP_SRC/TRP/trcdmp.F90
===================================================================
--- trunk/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 1152)
+++ trunk/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 1175)
@@ -4,8 +4,14 @@
    !! Ocean physics: internal restoring trend on passive tracers
    !!======================================================================
-#if  defined key_top  &&  defined key_trcdmp 
+   !! History :  7.0  !         (G. Madec)  Original code
+   !!                 !  96-01  (G. Madec) 
+   !!                 !  97-05  (H. Loukos)  adapted for passive tracers
+   !!            8.5  !  02-08  (G. Madec )  free form + modules
+   !!            9.0  !  04-03  (C. Ethe)    free form + modules
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
    !!----------------------------------------------------------------------
-   !!   'key_top'                                                TOP models
-   !!   'key_trcdmp'                                       internal damping
+#if  defined key_top && defined key_trcdmp 
+   !!----------------------------------------------------------------------
+   !!   key_trcdmp                                         internal damping
    !!----------------------------------------------------------------------
    !!   trc_dmp      : update the tracer trend with the internal damping
@@ -16,20 +22,18 @@
    !!----------------------------------------------------------------------
    USE oce_trc         ! ocean dynamics and tracers variables
-   USE trp_trc             ! ocean passive tracers variables
+   USE trc             ! ocean passive tracers variables
    USE trctrp_lec      ! passive tracers transport
    USE trcdta
    USE prtctl_trc      ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
 
    IMPLICIT NONE
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC trc_dmp   ! routine called by step.F90
-
-   !! * Shared module variables
-   LOGICAL , PUBLIC, PARAMETER ::   lk_trcdmp = .TRUE.    !: internal damping flag
-
-   REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) ::   &
-      restotr         ! restoring coeff. on tracers (s-1)
+   PUBLIC trc_dmp      ! routine called by step.F90
+
+   LOGICAL , PUBLIC, PARAMETER ::   lk_trcdmp = .TRUE.   !: internal damping flag
+   REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) ::   restotr   ! restoring coeff. on tracers (s-1)
 
    !! * Substitutions
@@ -37,6 +41,6 @@
    !!----------------------------------------------------------------------
    !!   TOP 1.0 , LOCEAN-IPSL (2005) 
-   !! $Id$ 
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcdmp.F90,v 1.11 2006/09/01 14:03:49 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 
@@ -60,19 +64,11 @@
       !! ** Action  : - update the tracer trends tra with the newtonian 
       !!                damping trends.
-      !!              - save the trends in trtrd ('key_trc_diatrd')
-      !!
-      !! History :
-      !!   7.0  !         (G. Madec)  Original code
-      !!        !  96-01  (G. Madec) 
-      !!        !  97-05  (H. Loukos)  adapted for passive tracers
-      !!   8.5  !  02-08  (G. Madec )  free form + modules
-      !!   9.0  !  04-03  (C. Ethe)    free form + modules
-      !!----------------------------------------------------------------------
-      !! * Arguments
+      !!              - save the trends ('key_trdmld_trc')
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrtrd => ua  ! use ua as 3D workspace   
+      !!
       INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
-
-      !! * Local declarations
-      INTEGER  ::   ji, jj, jk, jn     ! dummy loop indices
-      REAL(wp) ::   ztest, ztra, zdt   ! temporary scalars
+      INTEGER  ::   ji, jj, jk, jn       ! dummy loop indices
+      REAL(wp) ::   ztest, ztra !!!, zdt    ! temporary scalars
       CHARACTER (len=22) :: charout
       !!----------------------------------------------------------------------
@@ -82,4 +78,5 @@
       IF( kt == nittrc000 ) CALL trc_dmp_init
 
+
       ! 1. Newtonian damping trends on tracer fields
       ! --------------------------------------------
@@ -89,7 +86,10 @@
 
       ! Initialize the input fields for newtonian damping
-      CALL trc_dta( kt )
-
-      DO jn = 1, jptra
+      CALL dta_trc( kt )
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)    ! save trends 
 
          IF( lutini(jn) ) THEN
@@ -106,8 +106,4 @@
 !!                        trn(ji,jj,jk,jn) = trn(ji,jj,jk,jn) + ztra * zdt
                         tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
-#    if defined key_trc_diatrd
-                        ! save the trends for diagnostics
-                        IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),jpdiatrc-1) = ztra
-#    endif
                      END DO
                   END DO
@@ -129,6 +125,7 @@
 #    if defined key_trc_diatrd
                         ! save the trends for diagnostics
-                        IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),jpdiatrc-1) = ztra
+                        IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),jpdiatrc) = ztra
 #    endif
+
                      END DO
                   END DO
@@ -149,6 +146,7 @@
 #    if defined key_trc_diatrd
                         ! save the trends for diagnostics
-                        IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),jpdiatrc-1) = ztra
+                        IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),jpdiatrc) = ztra
 #    endif
+
                      END DO
                   END DO
@@ -159,10 +157,16 @@
          ENDIF
 
-      END DO
-
-     IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         IF( l_trdtrc ) THEN
+            ztrtrd(:,:,:) = tra(:,:,:,jn) -  ztrtrd(:,:,:)
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_dmp, kt )        ! trends diags.
+         END IF
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop
+      !                                                          ! ===========
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
          WRITE(charout, FMT="('dmp')")
-         CALL prt_ctl_trc_info(charout)
-         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd' )
       ENDIF
   
@@ -180,7 +184,4 @@
       !! ** Method  :   read the nammbf namelist and check the parameters
       !!      called by trc_dmp at the first timestep (nit000)
-      !!
-      !! History :
-      !!   8.5  !  02-08  (G. Madec)  Original code
       !!----------------------------------------------------------------------
 
@@ -194,5 +195,5 @@
 
       CASE DEFAULT
-         WRITE(ctmp1,*) '          bad flag value for ndmp = ', ndmp
+         WRITE(ctmp1,*) '          bad flag value for ndmptr = ', ndmptr
          CALL ctl_stop(ctmp1)
 
@@ -212,19 +213,16 @@
 
       CASE DEFAULT
-         WRITE(ctmp1,*) '          bad flag value for nmldmp = ', nmldmp
+         WRITE(ctmp1,*) '          bad flag value for nmldmptr = ', nmldmptr
          CALL ctl_stop(ctmp1)
 
-
       END SELECT
 
-
-      ! 3. Damping coefficients initialization
-     ! --------------------------------------
-
-         IF( lzoom ) THEN
-            CALL trccof_zoom
-         ELSE
-            CALL trccof
-         ENDIF
+      ! Damping coefficients initialization
+      ! -----------------------------------
+      IF( lzoom ) THEN
+         CALL trccof_zoom
+      ELSE
+         CALL trccof
+      ENDIF
  
    END SUBROUTINE trc_dmp_init
@@ -357,5 +355,5 @@
          icot         ! logical unit for file distance to the coast
 
-      CHARACTER (len=32) ::  clname, clname2, clname3
+      CHARACTER (len=32) ::   clname3
       REAL(wp) ::   &
          zdate0, zinfl, zlon,         & ! temporary scalars
