Index: trunk/NEMO/OPA_SRC/TRA/tranxt.F90
===================================================================
--- trunk/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 457)
+++ trunk/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 503)
@@ -4,17 +4,18 @@
    !! Ocean active tracers:  time stepping on temperature and salinity
    !!======================================================================
-   !! History :
-   !!   7.0  !  91-11  (G. Madec)  Original code
-   !!        !  93-03  (M. Guyon)  symetrical conditions
-   !!        !  96-02  (G. Madec & M. Imbard)  opa release 8.0
-   !!   8.0  !  96-04  (A. Weaver)  Euler forward step
-   !!   8.2  !  99-02  (G. Madec, N. Grima)  semi-implicit pressure grad.
-   !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
-   !!        !  02-11  (C. Talandier, A-M Treguier) Open boundaries
-   !!   9.0  !  06-02  (L. Debreu, C. Mazauric) Agrif implementation
+   !! History :  7.0  !  91-11  (G. Madec)  Original code
+   !!                 !  93-03  (M. Guyon)  symetrical conditions
+   !!                 !  96-02  (G. Madec & M. Imbard)  opa release 8.0
+   !!            8.0  !  96-04  (A. Weaver)  Euler forward step
+   !!            8.2  !  99-02  (G. Madec, N. Grima)  semi-implicit pressure grad.
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!                 !  02-11  (C. Talandier, A-M Treguier) Open boundaries
+   !!                 !  05-04  (C. Deltel) Add Asselin trend in the ML budget
+   !!            9.0  !  06-02  (L. Debreu, C. Mazauric) Agrif implementation
+   !!----------------------------------------------------------------------
+
    !!----------------------------------------------------------------------
    !!   tra_nxt     : time stepping on temperature and salinity
    !!----------------------------------------------------------------------
-   !! * Modules used
    USE oce             ! ocean dynamics and tracers variables
    USE dom_oce         ! ocean space and time domain variables 
@@ -23,4 +24,6 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE obctra          ! open boundary condition (obc_tra routine)
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
    USE prtctl          ! Print control
    USE agrif_opa_update
@@ -31,9 +34,9 @@
 
    !! * Routine accessibility
-   PUBLIC tra_nxt          ! routine called by step.F90
-   !!----------------------------------------------------------------------
-   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   PUBLIC   tra_nxt   ! routine called by step.F90
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
    !! $Header$ 
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 
@@ -67,16 +70,19 @@
       !! ** Action  : - update (tb,sb) and (tn,sn) 
       !!              - (ta,sa) time averaged (t,s)      (ln_dynhpg_imp = T)
-      !!
       !!----------------------------------------------------------------------
-      !! * Arguments
-      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
-
-      !! * Local declarations
-      INTEGER ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zt, zs      ! temporary scalars
-      REAL(wp) ::   zfact       ! temporary scalar
+      USE oce, ONLY :    ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :    ztrds => va   ! use va as 3D workspace   
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zt, zs       ! temporary scalars
+      REAL(wp) ::   zfact        ! temporary scalar
       !!----------------------------------------------------------------------
 
-
+      IF( l_trdtra ) THEN
+         ztrdt(:,:,jpk) = 0.e0
+         ztrds(:,:,jpk) = 0.e0
+      ENDIF
       ! 0. Lateral boundary conditions on ( ta, sa )   (T-point, unchanged sign)
       ! ---------------------------------============
@@ -84,5 +90,4 @@
       CALL lbc_lnk( sa, 'T', 1. )
 
-
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
@@ -93,7 +98,8 @@
          IF( ln_zdfexp ) THEN
             zfact = 2. * rdttra(jk)
-            IF( neuler == 0 .AND. kt == nit000 ) zfact = rdttra(jk)
+            IF( neuler == 0 .AND. kt == nit000 )   zfact = rdttra(jk)
             ta(:,:,jk) = ( tb(:,:,jk) + zfact * ta(:,:,jk) ) * tmask(:,:,jk)
             sa(:,:,jk) = ( sb(:,:,jk) + zfact * sa(:,:,jk) ) * tmask(:,:,jk)
+            IF(l_trdtra)   CALL ctl_stop( 'tranxt: Asselin ML trend not yet accounted for.' )
          ENDIF
 
@@ -102,8 +108,6 @@
       END DO                                           !   End of slab
       !                                                ! ===============
-
       ! Update tracers on open boundaries.
       CALL obc_tra( kt )
-
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
@@ -114,14 +118,10 @@
       END DO                                           !   End of slab
       !                                                ! ===============
-
       ! Update tracers on open boundaries.
       CALL Agrif_tra( kt )
-
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
          !                                             ! ===============
 #endif
-
-
          ! 2. Time filter and swap of arrays
          ! ---------------------------------
@@ -141,4 +141,8 @@
                   END DO
                END DO
+               IF( l_trdtra ) THEN
+                  ztrdt(:,:,jk) = 0.e0
+                  ztrds(:,:,jk) = 0.e0
+               END IF
             ELSE
                DO jj = 1, jpj
@@ -148,4 +152,8 @@
                      tb(ji,jj,jk) = atfp  * ( tb(ji,jj,jk) + ta(ji,jj,jk) ) + atfp1 * tn(ji,jj,jk)
                      sb(ji,jj,jk) = atfp  * ( sb(ji,jj,jk) + sa(ji,jj,jk) ) + atfp1 * sn(ji,jj,jk)
+                     IF( l_trdtra ) THEN ! ChD ceci est a optimiser, mais ca marche
+                        ztrdt(ji,jj,jk) = tb(ji,jj,jk) - tn(ji,jj,jk)
+                        ztrds(ji,jj,jk) = sb(ji,jj,jk) - sn(ji,jj,jk)
+                     END IF
                      tn(ji,jj,jk) = ta(ji,jj,jk)
                      sn(ji,jj,jk) = sa(ji,jj,jk)
@@ -165,5 +173,17 @@
                   END DO
                END DO
+               IF( l_trdtra ) THEN
+                  ztrdt(:,:,jk) = 0.e0
+                  ztrds(:,:,jk) = 0.e0
+               END IF
             ELSE
+               IF( l_trdtra ) THEN
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        ztrdt(ji,jj,jk) = atfp * ( tb(ji,jj,jk) - 2*tn(ji,jj,jk) + ta(ji,jj,jk) )
+                        ztrds(ji,jj,jk) = atfp * ( sb(ji,jj,jk) - 2*sn(ji,jj,jk) + sa(ji,jj,jk) )
+                     END DO
+                  END DO
+               END IF
                DO jj = 1, jpj
                   DO ji = 1, jpi
@@ -180,13 +200,16 @@
       !                                                ! ===============
 
-      IF(ln_ctl) THEN         ! print mean field (used for debugging)
-         CALL prt_ctl(tab3d_1=tn, clinfo1=' nxt  - Tn: ', mask1=tmask, &
-            &         tab3d_2=sn, clinfo2=' Sn: ', mask2=tmask)
-      ENDIF
-      
+      IF( l_trdtra )   THEN      ! Take the Asselin trend into account 
+         ztrdt(:,:,:) = ztrdt(:,:,:) / ( 2.*rdt )
+         ztrds(:,:,:) = ztrds(:,:,:) / ( 2.*rdt )         
+         CALL trd_mod( ztrdt, ztrds, jptra_trd_atf, 'TRA', kt )
+      END IF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tn, clinfo1=' nxt  - Tn: ', mask1=tmask,   &
+         &                       tab3d_2=sn, clinfo2=       ' Sn: ', mask2=tmask )
 #if defined key_agrif
       IF (.NOT.Agrif_Root())    CALL Agrif_Update_Tra( kt )
 #endif      
-
+      !
    END SUBROUTINE tra_nxt
 
