Index: /NEMO/branches/CNRS/dev_r6568_Subduction_Diagnostics/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90
===================================================================
--- /NEMO/branches/CNRS/dev_r6568_Subduction_Diagnostics/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90	(revision 9708)
+++ /NEMO/branches/CNRS/dev_r6568_Subduction_Diagnostics/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90	(revision 9709)
@@ -1,2 +1,3 @@
+!! 18 SEP 2016 : DC
 MODULE trcwri_pisces
    !!======================================================================
@@ -15,4 +16,6 @@
    USE sms_pisces  ! PISCES variables
    USE iom         ! I/O manager
+   USE diasub
+   USE trcdiasub
 
    IMPLICIT NONE
@@ -30,8 +33,7 @@
       !! ** Purpose :   output passive tracers fields 
       !!---------------------------------------------------------------------
-      CHARACTER (len=20)           :: cltra
-      REAL(wp)                     :: zfact
-      INTEGER                      :: ji, jj, jk, jn
-      REAL(wp), DIMENSION(jpi,jpj) :: zdic, zo2min, zdepo2min
+      CHARACTER (len=20)   :: cltra
+      REAL(wp)             :: zrfact
+      INTEGER              :: jn
       !!---------------------------------------------------------------------
  
@@ -41,46 +43,113 @@
       DO jn = jp_pcs0, jp_pcs1
          cltra = TRIM( ctrcnm(jn) )                  ! short title for tracer
-         CALL iom_put( cltra, trn(:,:,:,jn) )
+         IF( lk_vvl ) THEN
+            CALL iom_put( cltra, trn(:,:,:,jn) * fse3t_n(:,:,:) )
+         ELSE
+            CALL iom_put( cltra, trn(:,:,:,jn) )
+         ENDIF
       END DO
 #else
       DO jn = jp_pcs0, jp_pcs1
-         zfact = 1.0e+6 
-         IF( jn == jpno3 .OR. jn == jpnh4 ) zfact = rno3 * 1.0e+6 
-         IF( jn == jppo4  )                 zfact = po4r * 1.0e+6
+         zrfact = 1.0e+6 
+         IF( jn == jpno3 .OR. jn == jpnh4 ) zrfact = rno3 * 1.0e+6 
+         IF( jn == jppo4  )                 zrfact = po4r * 1.0e+6
          cltra = TRIM( ctrcnm(jn) )                  ! short title for tracer
-         IF( iom_use( cltra ) )  CALL iom_put( cltra, trn(:,:,:,jn) * zfact )
+         IF( lk_vvl ) THEN
+            CALL iom_put( cltra, trn(:,:,:,jn) * fse3t_n(:,:,:) * zrfact )
+         ELSE
+            CALL iom_put( cltra, trn(:,:,:,jn) * zrfact )
+         ENDIF
       END DO
+#endif
+      CALL trc_wri_sub !!! WORK DC
+      !
+   END SUBROUTINE trc_wri_pisces
 
-      IF( iom_use( "INTDIC" ) ) THEN                     !   DIC content in kg/m2
-         zdic(:,:) = 0.
-         DO jk = 1, jpkm1
-            zdic(:,:) = zdic(:,:) + trn(:,:,jk,jpdic) * fse3t(:,:,jk) * tmask(:,:,jk) * 12.
-         ENDDO
-         CALL iom_put( 'INTDIC', zdic )     
-      ENDIF
-      !
-      IF( iom_use( "O2MIN" ) .OR. iom_use ( "ZO2MIN" ) ) THEN  ! Oxygen minimum concentration and depth 
-         zo2min   (:,:) = trn(:,:,1,jpoxy) * tmask(:,:,1)
-         zdepo2min(:,:) = fsdepw(:,:,1)    * tmask(:,:,1)
-         DO jk = 2, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  IF( tmask(ji,jj,jk) == 1 ) then
-                     IF( trn(ji,jj,jk,jpoxy) < zo2min(ji,jj) ) then
-                        zo2min   (ji,jj) = trn(ji,jj,jk,jpoxy)
-                        zdepo2min(ji,jj) = fsdepw(ji,jj,jk)
-                     ENDIF
-                  ENDIF
-               END DO
-            END DO
-         END DO
-         !
-         CALL iom_put('O2MIN' , zo2min     )                              ! oxygen minimum concentration
-         CALL iom_put('ZO2MIN', zdepo2min  )                              ! depth of oxygen minimum concentration
-          !
-      ENDIF
+# if defined key_diasub
+
+   SUBROUTINE trc_wri_sub
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_wri_sub  ***
+      !!
+      !! ** Purpose :   output of passive tracer : advection-diffusion  subduction subduction
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=8), DIMENSION(jptrsub)   :: cltra1
+      CHARACTER(len=20)  :: cltra, cltra2
+      INTEGER            :: jn, jl, ji, jj, ik
+      REAL(wp), DIMENSION(jpi,jpj)         :: zsed
+      REAL(wp), DIMENSION(jpi,jpj,jptrsub) :: ztrsubtpoc
+      !!----------------------------------------------------------------------
+
+      DO jl = 1, jptrsub
+         IF( jl == jpsub_xad ) cltra1(jl) = TRIM("xad_sub_")   ! x advection for tracer
+         IF( jl == jpsub_yad ) cltra1(jl) = TRIM("yad_sub_")   ! y advection for tracer
+         IF( jl == jpsub_zad ) cltra1(jl) = TRIM("zad_sub_")   ! z advection for tracer
+         IF( jl == jpsub_mld ) cltra1(jl) = TRIM("mld_sub_")   ! mld for tracer
+         IF( jl == jpsub_xlf ) cltra1(jl) = TRIM("xlf_sub_")   ! x lateral diffusion for tracer
+         IF( jl == jpsub_ylf ) cltra1(jl) = TRIM("ylf_sub_")   ! y lateral diffusion for tracer
+         IF( jl == jpsub_zlf ) cltra1(jl) = TRIM("zlf_sub_")   ! z lateral diffusion for tracer
+         IF( jl == jpsub_zdf ) cltra1(jl) = TRIM("zdf_sub_")   ! z vertical diffusion for tracer
+#if defined key_trcldf_eiv
+         IF( jl == jpsub_xei ) cltra1(jl) = TRIM("xei_sub_")   ! x gent velocity for tracer
+         IF( jl == jpsub_yei ) cltra1(jl) = TRIM("yei_sub_")   ! y gent velocity for tracer
+         IF( jl == jpsub_zei ) cltra1(jl) = TRIM("zei_sub_")   ! z gent velocity for tracer
+#endif
+     ENDDO
+     !
+# if defined key_pisces
+     DO jl = 1, jptrsub
+        ! write the trends
+        DO jn = 1, jptra
+           IF(     jn == jpdic .OR. jn == jptal .OR. jn == jpoxy .OR. jn == jpdoc .OR. jn == jpcal  &
+            & .OR. jn == jpno3 .OR. jn == jppo4 .OR. jn == jpsil .OR. jn == jpfer .OR. jn == jpnh4 ) THEN
+              cltra = TRIM(cltra1(jl))//TRIM(ctrcnm(jn))
+              CALL iom_put( cltra, trsub(:,:,jn,jl) )
+           ENDIF
+        END DO
+        !
+        ! Sum of subduction of phy, phy2, zoo, zoo2, POC et GOC
+        ztrsubtpoc(:,:,jl) = trsub(:,:,jpphy,jl) + trsub(:,:,jpdia,jl)  &
+           &               + trsub(:,:,jpzoo,jl) + trsub(:,:,jpmes,jl)  &
+           &               + trsub(:,:,jppoc,jl) + trsub(:,:,jpgoc,jl)
+        cltra2 = "TOC"
+        cltra  = TRIM(cltra1(jl))//TRIM(cltra2)
+        CALL iom_put( cltra, ztrsubtpoc(:,:,jl))
+     END DO
+
+     ! Sedimentation a la base de la couche de mélane
+     cltra = TRIM("sedsed")
+     DO jj = 1, jpj
+        DO ji = 1, jpi
+           ik = nmln(ji,jj)
+           zsed(ji,jj) = ( sinking(ji,jj,ik) + sinking2(ji,jj,ik) ) * tmask(ji,jj,ik)
+        END DO
+     END DO
+     CALL iom_put( cltra, zsed(:,:) )
+#else
+     DO jl = 1, jptrsub
+        ! write the trends
+        DO jn = 1, jptra
+             cltra = TRIM(cltra1(jl))//TRIM(ctrcnm(jn))
+             CALL iom_put( cltra, trsub(:,:,jn,jl) )
+        END DO
+        !
+     END DO
 #endif
       !
-   END SUBROUTINE trc_wri_pisces
+      ! une fois ecrit, trsub est remis a 0
+      DO jl = 1, jptrsub
+         DO jn = 1, jptra
+            trsub(:,:,jn,jl) = 0.
+         END DO
+      END DO
+      !
+   END SUBROUTINE trc_wri_sub
+
+# else
+   SUBROUTINE trc_wri_sub                      ! Dummy routine
+   END SUBROUTINE trc_wri_sub
+# endif
+
 
 #else
