Index: trunk/NEMO/OPA_SRC/opa.F90
===================================================================
--- trunk/NEMO/OPA_SRC/opa.F90	(revision 267)
+++ trunk/NEMO/OPA_SRC/opa.F90	(revision 268)
@@ -50,4 +50,6 @@
    USE dyncor1d        ! Coriolis factor at T-point
    USE step1d          ! Time stepping loop for the 1D configuration
+
+   USE initrc          ! Initialization of the passive tracers
 
    IMPLICIT NONE
@@ -187,5 +189,5 @@
 
 #if defined key_passivetrc
-      CALL initrc                           ! Passive tracers
+      CALL ini_trc                           ! Passive tracers
 #endif
 
Index: trunk/NEMO/OPA_SRC/step.F90
===================================================================
--- trunk/NEMO/OPA_SRC/step.F90	(revision 267)
+++ trunk/NEMO/OPA_SRC/step.F90	(revision 268)
@@ -32,4 +32,6 @@
 
    USE trcstp          ! passive tracer time-stepping      (trc_stp routine)
+   USE trcdia          ! passive tracer diagnostics        (trc_dia routine)
+   USE trcrst          ! restart for passive tracers
 
    USE dynhpg          ! hydrostatic pressure grad.       (dyn_hpg routine)
@@ -279,11 +281,11 @@
       ! N.B. ua, va, ta, sa arrays are used as workspace in this section
       !-----------------------------------------------------------------------
-      IF( kstp == nit000 )   CALL trcdia( kstp, indic )     ! diagnostics init.
+      IF( kstp == nit000 )   CALL trc_dia( kstp, indic )     ! diagnostics init.
 
                              CALL trc_stp( kstp )           ! time-stepping
 
-                             CALL trcwri( kstp )            ! outputs
-
-                             CALL trcdia( kstp, indic )     ! diagnostics
+                             CALL trc_wri( kstp )            ! outputs
+
+                             CALL trc_dia( kstp, indic )     ! diagnostics
 #endif
 
Index: trunk/NEMO/TOP_SRC/trcctl.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcctl.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcctl.F90	(revision 268)
@@ -0,0 +1,169 @@
+MODULE trcctl
+   !!==========================================================================
+   !!
+   !!                       *** MODULE trcctl ***
+   !!
+   !! Only for passive tracer
+   !! control the cpp options for the run and IF files are availables
+   !! control also consistancy between options and namelist values
+   !!  O.Aumont and A.El Moussaoui 03/05 F90 
+   !!=========================================================================
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      !! ==============
+      USE oce_trc
+      USE trc
+      USE sms
+      USE trctrp_ctl
+
+     IMPLICIT NONE
+     PRIVATE
+
+    !! * Accessibility
+    PUBLIC trc_ctl
+
+CONTAINS
+
+#if defined key_passivetrc
+
+SUBROUTINE trc_ctl
+   !!===========================================================================================
+   !!
+   !!
+   !!                       ROUTINE trcctl
+   !!                     ******************
+   !!
+   !!      we use IF/ENDIF inside #IF defined option-cpp
+   !!      FILE name must not exceed 21 characters
+   !!      
+   !!===========================================================================================
+     
+   !!----------------------------------------------------------------------
+   !! local declarations
+   !! ==================
+   INTEGER  :: istop, jn
+
+!!!---------------------------------------------------------------------
+!!!  OPA.9    03/2005  
+!!!---------------------------------------------------------------------
+
+! 0. Parameter
+! ------------
+      istop = 0
+
+! 1. LOGICAL UNIT initialization for specifi! files for passive tracer
+! --------------------------------------------------------------------
+!     nutwrs : OUTPUT for passive tracer restart UNIT (always used)
+!     nutrst : restart FILE  INPUT  UNIT (lrsttr=.TRUE.)
+!     nutini(jptra) : UNIT for initial FILE for tracer
+
+      nutwrs = 72
+      nutrst = 73
+
+! 2. restart for passive tracer (input)
+! -----------------------------
+
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) ' *** PASSIVE TRACER MODEL OPTIONS'
+      IF(lwp) WRITE(numout,*) ' *** CONTROL'
+      IF(lwp) WRITE(numout,*) ' '
+
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) ' *** restart option for passive tracer'
+      IF(lwp) WRITE(numout,*) ' '
+
+      IF(lrsttr) THEN
+          IF(lwp) WRITE(numout,*) ' READ a restart FILE for passive tracer'
+          IF(lwp) WRITE(numout,*) ' '
+      ELSE
+          IF(lwp) WRITE(numout,*) ' no restart FILE'
+          IF(lwp) WRITE(numout,*) ' '
+
+! 3. OPEN FILES for initial tracer value
+! --------------------------------------
+          DO jn=1,jptra
+
+! OPEN input FILE only IF lutini(jn) is true
+! ------------------------------------------
+            IF (lutini(jn)) THEN  
+
+! prepare input FILE name a
+! -------------------------                        
+                IF(lwp) WRITE(numout,*)                          &
+                        ' READ an initial FILE :',               &
+                        ' for passive tracer number :',jn        &
+                        ,' traceur : ',ctrcnm(jn) 
+                IF(lwp) WRITE(numout,*) ' '
+            END IF 
+          END DO   
+      ENDIF
+
+! 4. Don't USE non penetrative convective mixing option
+!     it's not implemented for passive tracer
+! -----------------------------------------------------
+
+      IF( ln_zdfnpc) THEN
+        IF(lwp) WRITE (numout,*) ' ===>>>> : w a r n i n g '
+        IF(lwp) WRITE (numout,*) ' =======   ============= '
+        IF(lwp) WRITE (numout,*) ' STOP, this sheme is not implemented'
+        IF(lwp) WRITE (numout,*) ' in passive tracer model:'
+        IF(lwp) WRITE (numout,*) ' non penetrative convect. mixing scheme'
+        istop = istop + 1
+      ENDIF
+
+! 5. transport scheme option
+! --------------------------
+
+      IF(lwp) WRITE(numout,*) '  '
+      CALL trc_trp_ctl
+      IF(lwp) WRITE(numout,*) '  '
+
+! 6. SMS model
+! ---------------------------------------------
+
+      IF(lwp) WRITE(numout,*) '  '
+      IF(lwp) WRITE(numout,*) ' *** Source/Sink model option'
+      IF(lwp) WRITE(numout,*) '  '
+
+#if defined key_trc_npzd
+      #include "trcctl.npzd.h90" 
+#elif defined key_trc_lobster1
+      #include "trcctl.lobster1.h90"
+#elif defined key_trc_pisces
+      #include "trcctl.pisces.h90"
+#elif defined key_trc_hamocc3
+#   if defined key_trc_p3zd
+      #include "trcctl.p3zd.h90"
+#   else
+      #include "trcctl.hamocc3.h90"
+#   endif
+#else
+
+      IF(lwp) WRITE (numout,*) ' No Source/Sink model '
+      IF(lwp) WRITE (numout,*) ' '
+#endif
+
+! E r r o r  control
+! ------------------
+
+      IF ( istop > 0  ) THEN
+          IF(lwp)WRITE(numout,*)
+          IF(lwp)WRITE(numout,*) istop,' E R R O R found : we stop'
+          IF(lwp)WRITE(numout,*) '**************************'
+          IF(lwp)WRITE(numout,*)
+          STOP 'trcctl'
+      ENDIF
+
+END SUBROUTINE trc_ctl 
+
+#else
+
+SUBROUTINE trc_ctl
+  !!==============
+         ! no passive tracers
+  !!==============
+END SUBROUTINE trc_ctl
+
+#endif
+
+END MODULE trcctl
Index: trunk/NEMO/TOP_SRC/trcdia.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcdia.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcdia.F90	(revision 268)
@@ -0,0 +1,63 @@
+MODULE trcdia
+   !!==========================================================================
+   !!
+   !!                       *** MODULE trcdia ***
+   !! Output  for tracer concentration  
+   !! O.Aumont and A.El Moussaoui 03/05 F90 
+   !!==========================================================================
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      !! ==============
+   USE trcdit
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC trc_dia
+
+   !! * Module variables
+
+CONTAINS
+
+SUBROUTINE trc_dia(kt,kindic)  
+   !!===========================================================================================
+   !!
+   !!                       ROUTINE trcdii_wr
+   !!===========================================================================================
+
+       INTEGER, INTENT( in ) :: kt, kindic
+
+   ! outputs for tracer concentration
+   ! -------------------------------- 
+
+      CALL trcdit_wr(kt,kindic)
+
+#if defined key_trc_diatrd
+
+   ! outputs for dynamical trends
+   ! ----------------------------
+
+      CALL trcdid_wr(kt,kindic)
+
+#endif
+#if defined key_trc_diaadd
+
+   ! outputs for additional arrays
+   ! -----------------------------
+
+      CALL trcdii_wr(kt,kindic)
+
+#endif
+#if defined key_trc_diabio
+
+   ! outputs for biological trends
+   ! -----------------------------
+
+      CALL trcdib_wr(kt,kindic)
+
+#endif
+
+      END SUBROUTINE trc_dia
+
+END MODULE trcdia 
Index: trunk/NEMO/TOP_SRC/trcdit.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcdit.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcdit.F90	(revision 268)
@@ -0,0 +1,1014 @@
+MODULE trcdit
+
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      !! ==============
+   USE oce_trc
+   USE trc
+   USE dianam    ! build name of file (routine)
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC trcdit_wr
+   PUBLIC trcdid_wr
+   PUBLIC trcdii_wr
+   PUBLIC trcdib_wr
+
+   !! * Module variables
+   INTEGER            ::  &
+      nit5     ,  &   !!: id for tracer output file
+      ndepit5  ,  &   !!: id for depth mesh
+      nhorit5  ,  &   !!: id for horizontal mesh
+      ndimt50  ,  &   !!: number of ocean points in index array
+      ndimt51         !!: number of ocean points in index array
+   REAL(wp) :: zjulian
+   INTEGER , DIMENSION (jpij*jpk) ::  ndext50 !!: integer arrays for ocean 3D index
+   INTEGER , DIMENSION (jpij)     ::  ndext51 !!: integer arrays for ocean surface index
+#    if defined key_passivetrc && defined key_trc_diaadd
+   INTEGER            :: &
+      nitd     ,  &   !!: id for additional array output file
+      ndepitd  ,  &   !!: id for depth mesh
+      nhoritd         !!: id for horizontal mesh
+#    endif
+#    if defined key_passivetrc && defined key_trc_diatrd
+   INTEGER , DIMENSION (jptra)  :: &
+      nit6    ,   &   !!: id for additional array output file
+      ndepit6 ,   &   !!: id for depth mesh
+      nhorit6         !!: id for horizontal mesh
+#    endif
+#    if defined key_passivetrc && defined key_trc_diabio
+   INTEGER            :: &
+      nitb     ,   &  !!:  id for additional array output FILE
+      ndepitb  ,   &  !!:  id for depth mesh
+      nhoritb  ,   &  !!:  id for horizontal mesh
+#    endif
+
+
+   !! * Substitutions
+#  include "passivetrc_substitute.h90"
+
+CONTAINS
+
+#    if defined key_passivetrc
+
+      SUBROUTINE trcdit_wr(kt,kindic)
+   !!===========================================================================================
+   !!
+   !!                       ROUTINE trcdit_wr
+   !!===========================================================================================
+   !!
+   !! Purpose :
+   !!---------
+   !!          Standard output of passive tracer : concentration fields
+   !!
+   !!
+   !! Method :
+   !! -------
+   !!
+   !!        At the beginning of the first time step (nit000), define all
+   !!        the NETCDF files and fields for concentration of passive tracer
+   !!
+   !!        At each time step call histdef to compute the mean if necessary
+   !!        Each nwritetrc time step, output the instantaneous or mean fields
+   !!
+   !!        IF kindic <0, output of fields before the model interruption.
+   !!        IF kindic =0, time step loop
+   !!        IF kindic >0, output of fields before the time step loop
+   !!
+   !! Input :
+   !! -----
+   !!   argument
+   !!           kt              : time step
+   !!           kindic          : indicator of abnormal termination
+   !!
+   !! EXTERNAL :
+   !! --------
+   !! prihre, hist..., dianam
+   !!
+   !! History:
+   !! --------
+   !!   original  : 95-01  passive tracers  (M. Levy)
+   !!   additions : 98-01 (C. Levy) NETCDF format using ioipsl interface
+   !!   additions : 99-01 (M.A. Foujols) adapted for passive tracer
+   !!   additions : 99-09 (M.A. Foujols) split into three parts
+   !!   05-03 (O. Aumont and A. El Moussaoui) F90
+   !!==================================================================================================!
+
+      !! Modules used
+      USE ioipsl
+
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt,kindic         ! ocean time-step
+
+      !! * Local declarations
+      INTEGER :: jn
+      LOGICAL :: ll_print = .FALSE.
+
+      CHARACTER (len=40) :: clhstnam, clop
+      CHARACTER (len=20) :: cltra, cltrau
+      CHARACTER (len=80) :: cltral
+
+      REAL(wp) :: zsto, zout, zdt
+      INTEGER  :: iimi, iima, ijmi, ijma, ipk, it
+!
+! 0. Initialisation
+! -----------------
+
+! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+
+! Define frequency of output and means
+
+      zdt = rdt
+#        if defined key_diainstant
+      zsto=nwritetrc*rdt
+      clop='inst(only(x))'
+#        else
+      zsto=zdt
+      clop='ave(only(x))'
+#        endif
+      zout=nwritetrc*zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      it = kt - nit000 + 1
+
+! 1. Define NETCDF files and fields at beginning of first time step
+! -----------------------------------------------------------------
+
+      IF(ll_print)WRITE(numout,*)'trcdit_wr kt=',kt,' kindic ',kindic
+      IF(kt == nit000.and.kindic == 1) THEN
+
+! Compute julian date from starting date of the run
+
+         CALL ymds2ju(nyear,nmonth,nday,0.0,zjulian)
+         IF(lwp)WRITE(numout,*)' '  
+         IF(lwp)WRITE(numout,*)' Date 0 used :',nit000     &
+       &     ,' YEAR ',nyear,' MONTH ',nmonth,' DAY ',nday   &
+       &     ,'Julian day : ',zjulian    
+         IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,  &
+                                 ' limit storage in depth = ', ipk
+
+
+! Define the NETCDF files for passive tracer concentration
+
+         CALL dia_nam(clhstnam,nwritetrc,'ptrc_T')
+
+         IF(lwp)WRITE(numout,*)" Name of NETCDF file ", clhstnam
+! Horizontal grid : glamt and gphit
+ 
+         CALL histbeg(clhstnam, jpi, glamt, jpj, gphit,     &
+         &    iimi, iima-iimi+1, ijmi, ijma-ijmi+1,         & 
+         &    0, zjulian, zdt, nhorit5, nit5)
+! Vertical grid for tracer : gdept
+         CALL histvert(nit5, 'deptht', 'Vertical T levels', &
+         &    'm', ipk, gdept, ndepit5)
+
+! Index of ocean points in 3D and 2D (surface)
+         CALL wheneq(jpi*jpj*ipk,tmask,1,1.,ndext50,ndimt50)
+         CALL wheneq(jpi*jpj,tmask,1,1.,ndext51,ndimt51)
+
+! Declare all the output fields as NETCDF variables
+
+! tracer concentrations
+
+         DO jn=1,jptra
+           cltra=ctrcnm(jn)    ! short title for tracer
+           cltral=ctrcnl(jn)   ! long title for tracer
+           cltrau=ctrcun(jn)   ! UNIT for tracer
+           CALL histdef(nit5, cltra, cltral, cltrau, jpi, jpj, nhorit5,  &
+         &          ipk, 1, ipk,  ndepit5, 32, clop, zsto, zout) 
+         END DO           
+
+! CLOSE netcdf Files
+          
+         CALL histend(nit5)
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdit_wr'
+         IF(ll_print) CALL FLUSH(numout )
+
+      ENDIF
+
+! SOME diagnostics to DO first time
+
+! 2. Start writing data
+! ---------------------
+
+! tracer concentrations
+
+      IF( lwp .AND. MOD( kt, nwritetrc ) == 0 ) THEN
+         WRITE(numout,*) 'trcdit_wr : write NetCDF passive tracer concentrations at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+      DO jn=1,jptra
+         cltra=ctrcnm(jn) ! short title for tracer
+         CALL histwrite(nit5, cltra, it, trn(:,:,:,jn), ndimt50,   &
+      &          ndext50)
+      END DO 
+
+! synchronise FILE
+
+      IF( MOD( kt, nwritetrc ) == 0 .OR. kindic < 0 ) THEN
+              CALL histsync(nit5)
+      ENDIF
+
+! 3. Closing all files
+! --------------------
+      IF( kt == nitend .OR. kindic < 0 ) THEN
+          CALL histclo(nit5)
+      ENDIF
+
+END SUBROUTINE trcdit_wr
+
+#    else
+
+! no passive tracers
+
+SUBROUTINE trcdit_wr(kt,kindic)
+     !!! no passive tracers
+     INTEGER, INTENT ( in ) :: kt, kindic
+     WRITE(*,*) 'trcdit_wr: You should not have seen this print! error?', kt, kindic
+END SUBROUTINE trcdit_wr
+
+#    endif
+
+#    if defined key_passivetrc && defined key_trc_diatrd
+
+      SUBROUTINE trcdid_wr(kt,kindic)
+ !!===========================================================================================
+   !!
+   !!                       ROUTINE trcdid_wr
+   !!===========================================================================================
+   !!
+   !! Purpose :
+   !!---------
+   !!          output of opa: passive tracer dynamical trends
+   !!
+   !!
+   !! Method :
+   !! -------
+   !!
+   !!        At the beginning of the first time step (nit000), define all
+   !!        the NETCDF files and fields for dynamical trends of tracers
+   !!
+   !!        At each time step call histdef to compute the mean if necessary
+   !!        Each nwritetrd time step, output the instantaneous or mean fields
+   !!
+   !!        IF kindic <0, output of fields before the model interruption.
+   !!        IF kindic =0, time step loop
+   !!        IF kindic >0, output of fields before the time step loop
+   !!
+   !! Input :
+   !! -----
+   !!   argument
+   !!           kt              : time step
+   !!           kindic          : indicator of abnormal termination
+   !!
+   !! Output :
+   !! ------
+   !!   file
+   !!           "clhstnam" files : one for concentration
+   !!
+   !! History:
+   !! --------
+   !!   original  : 95-01  passive tracers  (M. Levy)
+   !!   additions : 98-01 (C. Levy) NETCDF format using ioipsl interface
+   !!   additions : 99-01 (M.A. Foujols) adapted for passive tracer
+   !!   additions : 99-09 (M.A. Foujols) split into three parts
+   !!   additions : 01-06 (Mehdi B, Elodie K): suppress initialization
+   !!                                          of nit6,nhorit6,ndepit6
+   !!   05-03 (O. Aumont and A. El Moussaoui) F90
+   !!==================================================================================================!
+
+      !! Modules used
+      USE ioipsl
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt,kindic         ! ocean time-step
+
+      INTEGER :: jn, jl
+      LOGICAL :: ll_print = .FALSE.
+
+      CHARACTER (len=40) :: clhstnam, clop
+      CHARACTER (len=20) :: cltra, cltrau
+      CHARACTER (len=80) :: cltral
+      CHARACTER (len=10) :: csuff
+
+      REAL(wp) :: zsto, zout, zdt
+      INTEGER :: iimi, iima, ijmi, ijma, ipk, it
+
+!
+! 0. Initialisation
+! -----------------
+
+! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+!
+! Define frequency of output and means
+!
+      zdt = rdt
+#        if defined key_diainstant
+      zsto=nwritetrd*rdt
+      clop='inst(only(x))'
+#        else
+      zsto=zdt
+      clop='ave(only(x))'
+#        endif
+      zout=nwritetrd*zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      it = kt - nit000 + 1
+
+! Define the NETCDF files (one per tracer)
+!
+      IF(ll_print)WRITE(numout,*)'trcdid kt=',kt,' kindic ',kindic
+      IF(kt == nit000.and.kindic == 1) THEN
+
+          DO jn=1,jptra
+
+            IF (luttrd(jn)) THEN
+
+! Define the file for dynamical trends - one per each tracer IF required
+
+         IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,  &
+                                 ' limit storage in depth = ', ipk
+                csuff='DY_'//ctrcnm(jn)
+                CALL dia_nam(clhstnam,nwritetrd,csuff)
+                IF(lwp)WRITE(numout,*)     &
+                &      " Name of NETCDF file for dynamical trends",   &
+                &      " of tracer number : ",clhstnam
+
+                CALL histbeg(clhstnam, jpi, glamt, jpj, gphit,   &
+                &    iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
+                &    0, zjulian, rdt, nhorit6(jn),               &
+                &    nit6(jn))
+
+! Vertical grid for tracer trend - one per each tracer IF needed
+                CALL histvert(nit6(jn), 'deptht', 'Vertical T levels',  &
+                &    'm', ipk, gdept, ndepit6(jn)) 
+
+
+            END IF
+          END DO
+
+! Declare all the output fields as NETCDF variables
+
+
+! trends for tracer concentrations
+          DO jn=1,jptra
+            IF (luttrd(jn)) THEN
+                DO jl=1,jpdiatrc
+                  IF (jl.eq.1) THEN
+! short and long title for x advection for tracer
+                      WRITE (cltra,'("XAD_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("X advective trend for ",a)')  &
+                      &      ctrcnl(jn)
+                  END IF
+                  IF (jl.eq.2)  THEN
+! short and long title for y advection for tracer
+                      WRITE (cltra,'("YAD_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("Y advective trend for ",a)')  &
+                      &      ctrcnl(jn)
+                  END IF
+                  IF (jl.eq.3)  THEN
+! short and long title for Z advection for tracer
+                      WRITE (cltra,'("ZAD_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("Z advective trend for ",a)')  &
+                      &      ctrcnl(jn)
+                  END IF
+                  IF (jl.eq.4)  THEN
+! short and long title for X diffusion for tracer
+                      WRITE (cltra,'("XDF_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("X diffusion trend for ",a)')  &
+                      &      ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.5)  THEN
+! short and long title for Y diffusion for tracer
+                      WRITE (cltra,'("YDF_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("Y diffusion trend for ",a)')  &
+                      &      ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.6)  THEN
+! short and long title for Z diffusion for tracer
+                      WRITE (cltra,'("ZDF_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("Z diffusion trend for ",a)')  &
+                      &      ctrcnm(jn)
+                  END IF
+# if defined key_trc_ldfeiv
+                  IF (jl.eq.7) THEN
+! short and long title for x gent velocity for tracer
+                      WRITE (cltra,'("Xgv",a)') ctrcnm(jn)
+                      WRITE (cltral,'("X gent velocity trend for ",a)')  &
+                      &      ctrcnl(jn)
+                  END IF
+                  IF (jl.eq.8)  THEN
+! short and long title for y gent velocity for tracer
+                      WRITE (cltra,'("YGV_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("Y gent velocity trend for ",a)')  &
+                      &i     ctrcnl(jn)
+                  END IF
+                  IF (jl.eq.9)  THEN
+! short and long title for Z gent velocity for tracer
+                      WRITE (cltra,'("ZGV_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("Z gent velocity trend for ",a)')  &
+                      &i     ctrcnl(jn)
+                  END IF
+# endif
+# if defined key_trcdmp
+                  IF (jl.eq.jpdiatrc)  THEN
+! last trends for tracer damping : short and long title
+                      WRITE (cltra,'("TDM_",a)') ctrcnm(jn)
+                      WRITE (cltral,'("Tracer damping trend for ",a)')  &
+                      &      ctrcnl(jn)
+                  END IF
+# endif
+                  cltrau=ctrcun(jn) ! UNIT for tracer /trends
+                  CALL histdef(nit6(jn), cltra, cltral, cltrau, jpi,jpj,  &
+                  &   nhorit6(jn), ipk, 1, ipk,  ndepit6(jn), 32, clop,
+                  &   zsto,zout)
+                END DO
+            END IF
+          END DO
+
+! CLOSE netcdf Files
+
+          DO jn=1,jptra
+             IF (luttrd(jn)) CALL histend(nit6(jn))
+          END DO
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdid'
+         IF(ll_print) CALL FLUSH(numout )
+
+      ENDIF
+
+! SOME diagnostics to DO first time
+
+! 2. Start writing data
+! ---------------------
+
+! trends for tracer concentrations
+
+      IF( lwp .AND. MOD( kt, nwritetrd ) == 0 ) THEN
+         WRITE(numout,*) 'trcdid_wr : write NetCDF dynamical trends at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+          DO jn=1,jptra
+            IF (luttrd(jn)) THEN
+                DO jl=1,jpdiatrc
+                  IF (jl.eq.1) THEN
+! short title for x advection for tracer
+                      WRITE (cltra,'("XAD_",a)') ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.2)  THEN
+! short title for y advection for tracer
+                      WRITE (cltra,'("YAD_",a)') ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.3)  THEN
+! short title for z advection for tracer
+                      WRITE (cltra,'("ZAD_",a)') ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.4)  THEN
+! short title for x diffusion for tracer
+                      WRITE (cltra,'("XDF_",a)') ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.5)  THEN
+! short title for y diffusion for tracer
+                      WRITE (cltra,'("YDF_",a)') ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.6)  THEN
+! short title for z diffusion for tracer
+                      WRITE (cltra,'("ZDF_",a)') ctrcnm(jn)
+                  END IF
+# if defined key_trc_ldfeiv
+                  IF (jl.eq.7) THEN
+! short for x gent velocity for tracer
+                      WRITE (cltra,'("XGV_",a)') ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.8)  THEN
+! short for y gent velocity for tracer
+                      WRITE (cltra,'("YGV_",a)') ctrcnm(jn)
+                  END IF
+                  IF (jl.eq.9)  THEN
+! short title for Z gent velocity for tracer
+                      WRITE (cltra,'("ZGV_",a)') ctrcnm(jn)
+                  END IF
+# endif
+# if defined key_trcdmp
+                  IF (jl.eq.jpdiatrc) THEN
+! short for x gent velocity for tracer
+                      WRITE (cltra,'("TDM_",a)') ctrcnm(jn)
+                  END IF
+# endif
+
+                  CALL histwrite(nit6(jn), cltra, it, trtrd(:,:,:,jn,jl)  &
+                  &    ,ndimt50, ndext50)
+                END DO
+            END IF
+          END DO
+
+! synchronise FILE
+
+      IF( MOD( kt, nwritetrd ) == 0 .OR. kindic < 0 ) THEN
+          DO jn=1,jptra
+              CALL histsync(nit6(jn))
+          END DO
+      ENDIF
+
+! 3. Closing all files
+! --------------------
+
+      IF( kt == nitend .OR. kindic < 0 ) THEN
+          DO jn=1,jptra
+             CALL histclo(nit6(jn))
+          END DO
+      ENDIF
+
+END SUBROUTINE trcdid_wr
+
+#    else
+
+SUBROUTINE trcdid_wr(kt,kindic)
+     !!! no passive tracers
+     INTEGER, INTENT ( in ) :: kt, kindic
+     WRITE(*,*) 'trcdid_wr: You should not have seen this print! error?', kt, kindic
+END SUBROUTINE trcdid_wr
+
+#    endif
+
+#    if defined key_passivetrc && defined key_trc_diaadd
+
+      SUBROUTINE trcdii_wr(kt,kindic)
+   !!===========================================================================================
+   !!
+   !!                       ROUTINE trcdii_wr
+   !!===========================================================================================
+   !!
+   !! Purpose :
+   !!---------
+   !!          output of passive tracer : additional 2D and 3D arrays
+   !!
+   !!
+   !! Method :
+   !! -------
+   !!
+   !!        At the beginning of the first time step (nit000), define all
+   !!        the NETCDF files and fields for additional arrays
+   !!
+   !!        At each time step call histdef to compute the mean if necessary
+   !!        Each nwritetrc time step, output the instantaneous or mean fields
+   !!
+   !!
+   !!        IF kindic <0, output of fields before the model interruption.
+   !!        IF kindic =0, time step loop
+   !!        IF kindic >0, output of fields before the time step loop
+   !!
+   !! Input :
+   !! -----
+   !!   argument
+   !!           kt              : time step
+   !!           kindic          : indicator of abnormal termination
+   !!
+   !! EXTERNAL :
+   !! --------
+   !! prihre, hist..., dianam
+   !!
+   !! History:
+   !! --------
+   !!   original  : 95-01  passive tracers  (M. Levy)
+   !!   additions : 98-01 (C. Levy) NETCDF format using ioipsl interface
+   !!   additions : 99-01 (M.A. Foujols) adapted for passive tracer
+   !!   additions : 99-09 (M.A. Foujols) split into three parts
+   !!   05-03 (O. Aumont and A. El Moussaoui) F90
+   !!==================================================================================================!
+
+      !! Modules used
+      USE ioipsl
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt,kindic         ! ocean time-step
+
+      INTEGER :: jn
+      LOGICAL :: ll_print = .FALSE.
+
+      CHARACTER (len=40) :: clhstnam, clop
+      CHARACTER (len=20) :: cltra, cltrau
+      CHARACTER (len=80) :: cltral
+
+      REAL(wp) :: zsto, zout, zdt
+      INTEGER :: iimi, iima, ijmi, ijma, ipk, it
+
+!
+! 0. Initialisation
+! -----------------
+
+! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+!
+! Define frequency of output and means
+!
+      zdt = rdt
+#        if defined key_diainstant
+      zsto=nwriteadd*zdt
+      clop='inst(only(x))'
+#        else
+      zsto=zdt
+      clop='ave(only(x))'
+#        endif
+      zout=nwriteadd*zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      it = kt - nit000 + 1
+
+! 1. Define NETCDF files and fields at beginning of first time step
+! -----------------------------------------------------------------
+
+      IF(ll_print)WRITE(numout,*)'trcdii_wr kt=',kt,' kindic ',kindic
+      IF(kt == nit000.and.kindic == 1) THEN
+
+! Define the NETCDF files for additional arrays : 2D or 3D
+
+! Define the T grid file for tracer auxiliary files
+
+          CALL dia_nam(clhstnam,nwrite,'diad_T')
+          IF(lwp)WRITE(numout,*)" Name of NETCDF file ", clhstnam
+
+! Define a netcdf FILE for 2d and 3d arrays
+
+          CALL histbeg(clhstnam, jpi, glamt, jpj, gphit,     &
+          &    iimi, iima-iimi+1, ijmi, ijma-ijmi+1,         &
+          &    0, zjulian, zdt, nhoritd, nitd)
+
+! Vertical grid for 2d and 3d arrays
+
+          CALL histvert(nitd, 'deptht', 'Vertical T levels', &
+          &    'm', ipk, gdept, ndepitd)
+
+
+! Declare all the output fields as NETCDF variables
+
+! more 3D horizontal arrays
+
+          DO jn=1,jpdia3d
+            cltra=ctrc3d(jn)    ! short title for 3D diagnostic
+            cltral=ctrc3l(jn)   ! long title for 3D diagnostic
+            cltrau=ctrc3u(jn)   ! UNIT for 3D diagnostic
+            CALL histdef(nitd, cltra, cltral, cltrau, jpi, jpj, nhoritd,  &
+            &    ipk, 1, ipk,  ndepitd, 32, clop, zsto, zout)
+          END DO
+
+
+! more 2D horizontal arrays
+
+          DO jn=1,jpdia2d
+            cltra=ctrc2d(jn)    ! short title for 2D diagnostic
+            cltral=ctrc2l(jn)   ! long title for 2D diagnostic
+            cltrau=ctrc2u(jn)   ! UNIT for 2D diagnostic
+            CALL histdef(nitd, cltra, cltral, cltrau, jpi, jpj, nhoritd,  &
+            &    1, 1, 1,  -99, 32, clop, zsto, zout)
+          END DO
+
+! TODO: more 2D vertical sections arrays : I or J indice fixed
+
+! CLOSE netcdf Files
+
+          CALL histend(nitd)
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdii_wr'
+         IF(ll_print) CALL FLUSH(numout )
+
+      ENDIF
+
+! 2. Start writing data
+! ---------------------
+
+      IF( lwp .AND. MOD( kt, nwriteadd ) == 0 ) THEN
+         WRITE(numout,*) 'trcdii_wr : write NetCDF additional arrays at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+! more 3D horizontal arrays
+
+          DO jn=1,jpdia3d
+            cltra=ctrc3d(jn) ! short title for 3D diagnostic
+            CALL histwrite(nitd, cltra, it, trc3d(:,:,:,jn), ndimt50  &
+            &   ,ndext50)
+          END DO
+
+! more 2D horizontal arrays
+
+          DO jn=1,jpdia2d
+            cltra=ctrc2d(jn) ! short title for 2D diagnostic
+            CALL histwrite(nitd, cltra, kt, trc2d(:,:,jn), ndimt51    &
+            &   ,ndext51)
+          END DO
+
+! synchronise FILE
+
+      IF( MOD( kt, nwriteadd ) == 0 .OR. kindic < 0 ) THEN
+              CALL histsync(nitd)
+      ENDIF
+
+! 3. Closing all files
+! --------------------
+
+      IF( kt == nitend .OR. kindic < 0 ) THEN
+          CALL histclo(nitd)
+      ENDIF
+
+END SUBROUTINE trcdii_wr
+
+#    else
+
+SUBROUTINE trcdii_wr(kt,kindic)
+     !!! no passive tracers
+     INTEGER, INTENT ( in ) :: kt, kindic
+     WRITE(*,*) 'trcdii_wr: You should not have seen this print! error?', kt, kindic
+END SUBROUTINE trcdii_wr
+
+#    endif
+
+#    if defined key_passivetrc && defined key_trc_diabio
+
+      SUBROUTINE trcdib_wr(kt,kindic)
+ !!===========================================================================================
+   !!
+   !!                       ROUTINE trcdib_wr
+   !!===========================================================================================
+   !!
+   !! Purpose :
+   !!---------
+   !!          Specific output of opa: biological fields
+   !!
+   !!
+   !! Method :
+   !! -------
+   !!
+   !!        At the beginning of the first time step (nit000), define all
+   !!        the NETCDF files and fields for biological fields
+   !!
+   !!        At each time step call histdef to compute the mean if necessary
+   !!        Each nwritetrd time step, output the instantaneous or mean fields
+   !!
+   !!        IF kindic <0, output of fields before the model interruption.
+   !!        IF kindic =0, time step loop
+   !!        IF kindic >0, output of fields before the time step loop
+   !!
+   !! Input :
+   !! -----
+   !!   argument
+   !!           kt              : time step
+   !!           kindic          : indicator of abnormal termination
+   !!
+   !! Output :
+   !! ------
+   !!   file
+   !!           "histname" files : at least one file for each grid
+   !!
+   !! History:
+   !! --------
+   !!   original  : 95-01  passive tracers  (M. Levy)
+   !!   additions : 98-01 (C. Levy) NETCDF format using ioipsl interface
+   !!   additions : 99-01 (M.A. Foujols) adapted for passive tracer
+   !!   additions : 99-09 (M.A. Foujols) split into three parts
+   !!   additions : 01-06 (E Kestenare) assign a parameter to name
+   !!                                          individual tracers
+   !!   additions : 05-03 (O. Aumont and A El Moussaoui) F90
+   !!==================================================================================================!
+
+      !! Modules used
+      USE ioipsl
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt,kindic         ! ocean time-step
+
+      INTEGER :: ji, jj, jk, jn, jl
+      LOGICAL :: ll_print = .FALSE.
+
+      CHARACTER (len=40) :: clhstnam, clop
+      CHARACTER (len=20) :: cltra, cltrau
+      CHARACTER (len=80) :: cltral
+
+      REAL(wp) :: zsto, zout, zdt
+      REAL(wp) :: zsec
+      INTEGER  :: iimi, iima, ijmi, ijma, ipk, it
+
+      REAL(wp) :: ztra,zder
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zphy
+
+!
+! 0. Initialisation
+! -----------------
+
+! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+!
+! Define frequency of output and means
+!
+      zdt = rdt
+#        if defined key_diainstant
+      zsto=nwritebio*zdt
+      clop='inst(only(x))'
+#        else
+      zsto=zdt
+      clop='ave(only(x))'
+#        endif
+      zout=nwritebio*zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      it = kt - nit000 + 1
+
+! 1. Define NETCDF files and fields at beginning of first time step
+! -----------------------------------------------------------------
+
+      IF(ll_print)WRITE(numout,*)'trcdib_wr kt=',kt,' kindic ',kindic
+      IF(kt == nit000.and.kindic == 1) THEN
+
+! Define the NETCDF files for biological trends
+
+          CALL dia_nam(clhstnam,nwrite,'biolog')
+          IF(lwp)WRITE(numout,*)        &
+          &      " Name of NETCDF file for biological trends ",clhstnam
+! Horizontal grid : glamt and gphit
+          CALL histbeg(clhstnam, jpi, glamt, jpj, gphit,      &
+          &    iimi, iima-iimi+1, ijmi, ijma-ijmi+1,          &
+          &    0, zjulian, rdt, nhoritb, nitb)
+! Vertical grid for biological trends
+          CALL histvert(nitb, 'deptht', 'Vertical T levels',  &
+          &    'm', ipk, gdept, ndepitb)
+
+! Declare all the output fields as NETCDF variables
+
+! biological trends
+
+          DO jn=1,jpdiabio
+            cltra=ctrbio(jn)    ! short title for biological diagnostic
+            cltral=ctrbil(jn)   ! long title for biological diagnostic
+            cltrau=ctrbiu(jn)   ! UNIT for biological diagnostic
+            CALL histdef(nitb, cltra, cltral, cltrau, jpi, jpj, nhoritb,  &
+            &    ipk, 1, ipk,  ndepitb, 32, clop, zsto, zout)
+          END DO
+
+! CLOSE netcdf Files
+
+          CALL histend(nitb)
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdib_wr'
+         IF(ll_print) CALL FLUSH(numout )
+
+! SOME diagnostics to DO first time
+
+#        if defined key_trc_npzd || defined key_trc_lobster1
+
+! initial total nitrogen
+
+          trai=0.
+          DO jn=1,jptra
+            DO jk=1,jpk
+              DO jj=1,jpj
+                DO ji=1,jpi
+                  trai=trai+trn(ji,jj,jk,jn)*fse3t(ji,jj,jk)*tmask(ji,jj,jk)
+                END DO
+              END DO
+            END DO
+          END DO
+
+          IF (lwp) then
+              WRITE (numout,*) ' *** total nitrogen =  ',trai,    &
+              &                ' at beginning of run it= ',kt
+          ENDIF
+
+          DO jk=1,jpk
+            DO jj=1,jpj
+              DO ji=1,jpi
+                zphy(ji,jj,jk)=trn(ji,jj,jk,jpphy)
+              END DO
+            END DO
+          END DO
+
+          IF (lwp) then
+              WRITE (numout,*) ' -------'
+              WRITE (numout,*) ' phyto'
+              WRITE (numout,*) ' -------'
+              CALL prizre(zphy,jpi,jpj,jpk,62,2,122,20,1,14,1,0.,numout)
+          ENDIF
+
+#        endif
+
+      ENDIF
+
+! 2. Start writing data
+! ---------------------
+
+! biological trends
+
+      IF( lwp .AND. MOD( kt, nwritebio ) == 0 ) THEN
+         WRITE(numout,*) 'trcdit_wr : write NetCDF biological trends at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+
+      DO jn=1,jpdiabio
+         cltra=ctrbio(jn)  ! short title for biological diagnostic
+         CALL histwrite(nitb, cltra, zt, trbio(:,:,:,jn), ndimt50,   &
+         &    ndext50)
+      END DO
+
+#     if defined key_trc_npzd || defined key_trc_lobster1
+
+      IF( MOD(kt-nit000+1,nwritebio) == 0) THEN
+
+! total nitrogen every nwritebio time step
+
+           ztra=0.
+           DO jn=1,jptra
+             DO jk=1,jpk
+               DO jj=1,jpj
+                 DO ji=1,jpi
+                   ztra=ztra+trn(ji,jj,jk,jn)*fse3t(ji,jj,jk)*tmask(ji,jj,jk)
+                 END DO
+               END DO
+             END DO
+           END DO
+
+           zder=(ztra-trai)/trai
+           trai=ztra
+
+           IF (lwp) THEN
+               WRITE (numout,*)
+               WRITE (numout,*) ' *** derive in total nitrogen =  ', zder,' %',' at it= ',kt
+               WRITE (numout,*) ' *** total nitrogen =  ',trai, ' at it= ',kt
+           ENDIF
+
+           zphy(:,:,:)=trn(:,:,:,jpphy)
+
+           IF (lwp) THEN
+               WRITE (numout,*)
+               WRITE (numout,*) ' *** trcdib: at it= ',kt
+               WRITE (numout,*) ' -------'
+               WRITE (numout,*) ' phyto'
+               WRITE (numout,*) ' -------'
+               CALL prizre(zphy,jpi,jpj,jpk,jpj-1,2,jpj-1,20,1,14,1,   &
+               &    0.,numout)
+           ENDIF
+
+       ENDIF
+
+#      endif
+
+! synchronise FILE
+
+      IF( MOD( kt, nwritebio ) == 0 .OR. kindic < 0 ) THEN
+              CALL histsync(nitb)
+      ENDIF
+
+! 3. Closing all files
+! --------------------
+      IF( kt == nitend .OR. kindic < 0 ) THEN
+          CALL histclo(nitb)
+      ENDIF
+
+END SUBROUTINE trcdib_wr
+
+#    else
+
+SUBROUTINE trcdib_wr(kt,kindic)
+     !!! no passive tracers
+     INTEGER, INTENT ( in ) :: kt, kindic
+     WRITE(*,*) 'trcdib_wr: You should not have seen this print! error?', kt, kindic
+END SUBROUTINE trcdib_wr
+
+#    endif
+
+END MODULE trcdit
Index: trunk/NEMO/TOP_SRC/trcdta.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcdta.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcdta.F90	(revision 268)
@@ -0,0 +1,261 @@
+MODULE trcdta
+   !!======================================================================
+   !!                     ***  MODULE  dtatem  ***
+   !! Ocean data  :  read passive tracer data from monthly atlas data
+   !!=====================================================================
+
+#if  defined key_passivetrc && defined key_trc_dta
+   !!----------------------------------------------------------------------
+   !!   'key_trc_dta'                           3D tracer data field
+   !!----------------------------------------------------------------------
+   !!   dta_trc      : read ocean passive tracer data
+   !!----------------------------------------------------------------------
+   !! * Modules used
+      USE oce_trc
+      USE trc
+      USE par_sms
+      USE lib_print
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dta_trc   ! called by trcdtr.F90 and trcdmp.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk,jptra) ::   &  !:
+      trdta             !: temperature data at given time-step
+
+   !! * Module variables
+   REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,2) ::   &
+      tracdta            ! temperature data at two consecutive times
+   INTEGER , DIMENSION(jptra) :: &
+      nlectr  ,   &    !!: switch for reading once
+      ntrc1   ,   &    !!: ????
+      ntrc2            !!: ????
+
+   !! * Substitutions
+#  include "passivetrc_substitute.h90"
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LODYC-IPSL  (2003)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   !!----------------------------------------------------------------------
+   !!   Default case                                            NetCDF file
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE dta_trc( kt )
+!!----------------------------------------------------------------------
+!!                   ***  ROUTINE dta_trc  ***
+!!
+!! ** Purpose :   Reads passive tracer data (Levitus monthly data)
+!!
+!! ** Method  :   Read on unit numtr the interpolated tracer concentra-
+!!      tion onto the global grid. Data begin at january. 
+!!      The value is centered at the middle of month. 
+!!      In the opa model, kt=1 agree with january 1. 
+!!      At each time step, a linear interpolation is applied between 
+!!      two monthly values.
+!!
+!! History :
+!!   8.2  !  02-04  (O. Aumont)  Original code
+!!   9.0  !  04-03  (C. Ethe)    
+!!   9.0  !  05-03  (O. Aumont and A. El Moussaoui) F90
+!!----------------------------------------------------------------------
+!! * Modules used
+      USE ioipsl
+
+!! * Arguments
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step
+
+!! * Local declarations
+      INTEGER :: ji, jj, jn, jl 
+      INTEGER, PARAMETER ::  &
+         jpmois  = 12        ! number of months
+
+      INTEGER ::   &
+         imois, iman, i15, itime, ik, &  ! temporary integers 
+         ipi, ipj, ipk                              !    "        "
+      INTEGER :: istep(jpmois)
+      CHARACTER (len=39) :: clname(jptra)
+      REAL(wp), DIMENSION (jpi,jpj) ::  zlon, zlat
+      REAL(wp), DIMENSION (jpk) ::  zlev
+      REAL(wp) :: zdate0, zxy, zl
+!!----------------------------------------------------------------------
+
+      DO jn = 1, jptra
+
+        IF( lutini(jn) ) THEN 
+
+          IF ( kt == nit000 ) THEN
+!! 3D tracer data
+            IF(lwp)WRITE(numout,*)
+            IF(lwp)WRITE(numout,*) ' trcdta: reading tracer' 
+            IF(lwp)WRITE(numout,*) ' data file ', jn
+            IF(lwp)WRITE(numout,*)
+            nlectr(jn) = 0
+          ENDIF
+! Initialization
+        iman = jpmois
+        i15  = nday/16
+        imois = nmonth + i15 -1
+        IF( imois == 0 ) imois = iman
+        itime = jpmois
+        ipi = jpiglo
+        ipj = jpjglo
+
+! First call kt=nit000
+! --------------------
+
+        IF ( kt == nit000 .AND. nlectr(jn) == 0 ) THEN
+          ntrc1(jn) = 0
+          IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) ' Tracer monthly fields' 
+            WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~'
+            WRITE(numout,*) ' NetCDF FORMAT'
+            WRITE(numout,*)
+          ENDIF
+
+! open file 
+
+          clname(jn) = 'LEVITUS_'//ctrcnm(jn)
+          CALL flinopen(TRIM(clname(jn)),mig(1),nlci,mjg(1),nlcj,    &
+                        .FALSE.,ipi,ipj,ipk,zlon,zlat,zlev,itime,    &
+                        istep,zdate0,rdt,numtr(jn)               )
+
+! title, dimensions and tests
+          IF( itime /= jpmois ) THEN
+            IF(lwp) THEN
+              WRITE(numout,*) ' '
+              WRITE(numout,*) 'problem with time coordinates'
+              WRITE(numout,*) ' itime ',itime,' jpmois ',jpmois
+            ENDIF
+            STOP 'trc_dta'
+          ENDIF
+
+          IF( ipi /= jpidta .OR. ipj /= jpjdta .OR. ipk /= jpk ) THEN
+            IF(lwp) THEN
+              WRITE(numout,*) ' '
+              WRITE(numout,*) 'problem with dimensions'
+              WRITE(numout,*) ' ipi ',ipi,' jpidta ',jpidta
+              WRITE(numout,*) ' ipj ',ipj,' jpjdta ',jpjdta
+              WRITE(numout,*) ' ipk ',ipk,' jpk ',jpk
+            ENDIF
+            STOP 'trc_dta'
+          ENDIF
+          IF(lwp)WRITE(numout,*) itime,istep,zdate0,rdt,numtr(jn)
+          trdta(:,:,:,jn) = 0.
+
+        ENDIF
+
+
+! Read montly file
+        IF( ( kt == nit000 .AND. nlectr(jn) == 0)   & 
+              .OR. imois /= ntrc1(jn) ) THEN
+           nlectr(jn) = 1
+
+! Calendar computation
+
+! ntrc1 number of the first file record used in the simulation
+! ntrc2 number of the last  file record
+
+          ntrc1(jn) = imois
+          ntrc2(jn) = ntrc1(jn) + 1
+          ntrc1(jn) = MOD( ntrc1(jn), iman )
+          IF ( ntrc1(jn) == 0 ) ntrc1(jn) = iman
+          ntrc2(jn) = MOD( ntrc2(jn), iman )
+          IF ( ntrc2(jn) == 0 ) ntrc2(jn) = iman
+          IF(lwp) WRITE(numout,*) 'first record file used ntrc1 ', ntrc1(jn) 
+          IF(lwp) WRITE(numout,*) 'last  record file used ntrc2 ', ntrc2(jn)
+
+! Read montly passive tracer data Levitus 
+
+          CALL flinget( numtr(jn),ctrcnm(jn),jpidta,jpjdta,jpk,    &
+               jpmois,ntrc1(jn),ntrc1(jn),mig(1),nlci,mjg(1),nlcj,  &
+               tracdta(1:nlci,1:nlcj,1:jpk,jn,1)                  )
+
+          CALL flinget( numtr(jn),ctrcnm(jn),jpidta,jpjdta,jpk,     &
+               jpmois,ntrc2(jn),ntrc2(jn),mig(1),nlci,mjg(1),nlcj,   &
+               tracdta(1:nlci,1:nlcj,1:jpk,jn,2)                  )
+
+          IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) ' read tracer data ', ctrcnm(jn),' ok'
+            WRITE(numout,*)
+          ENDIF
+
+! Apply Mask
+          DO jl = 1, 2
+            tracdta(:,:,:  ,jn,jl) = tracdta(:,:,:,jn,jl) * tmask(:,:,:) 
+            tracdta(:,:,jpk,jn,jl) = 0.
+            IF( lk_zps ) THEN                ! z-coord. with partial steps
+               DO jj = 1, jpj                ! interpolation of temperature at the last level
+                  DO ji = 1, jpi
+                     ik = mbathy(ji,jj) - 1
+                     IF( ik > 2 ) THEN
+                        zl = ( gdept(ik) - fsdept(ji,jj,ik) ) / ( gdept(ik) - gdept(ik-1) )
+                        tracdta(ji,jj,ik,jn,jl) = (1.-zl) * tracdta(ji,jj,ik,jn,jl) + zl * tracdta(ji,jj,ik-1,jn,jl)
+                     ENDIF
+                  END DO
+               END DO
+            ENDIF
+
+          END DO
+
+        ENDIF
+
+        IF(lwp) THEN
+          WRITE(numout,*) ctrcnm(jn), 'Levitus month ', ntrc1(jn),   &
+                          ntrc2(jn)
+          WRITE(numout,*)
+          WRITE(numout,*) ' Levitus month = ', ntrc1(jn),   &
+                  '  level = 1'
+          CALL prihre( tracdta(1,1,1,jn,1), jpi, jpj, 1, jpi, 20, 1   &
+                  ,jpj, 20, 1., numout )
+          WRITE(numout,*) ' Levitus month = ', ntrc1(jn),    &
+                  '  level = ',jpk/2
+          CALL prihre( tracdta(1,1,jpk/2,jn,1), jpi, jpj, 1, jpi,    &
+                  20, 1, jpj, 20, 1., numout )
+          WRITE(numout,*) ' Levitus month = ',ntrc1(jn)     &
+                  ,'  level = ',jpkm1
+          CALL prihre( tracdta(1,1,jpkm1,jn,1), jpi, jpj, 1, jpi,     &
+                  20, 1, jpj, 20, 1., numout )
+        ENDIF 
+
+! At every time step compute temperature data
+
+        zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
+        trdta(:,:,:,jn)=  ( 1. - zxy ) * tracdta(:,:,:,jn,1)    &
+                       +       zxy   * tracdta(:,:,:,jn,2) 
+   
+        IF( jn == jpno3) trdta(:,:,:,jn) = trdta(:,:,:,jn) * 7.6E-6
+        IF( jn == jpdic) trdta(:,:,:,jn) = trdta(:,:,:,jn) * 1.E-6
+        IF( jn == jptal) trdta(:,:,:,jn) = trdta(:,:,:,jn) * 1.E-6
+        IF( jn == jpoxy) trdta(:,:,:,jn) = trdta(:,:,:,jn) * 44.6E-6
+        IF( jn == jpsil) trdta(:,:,:,jn) = trdta(:,:,:,jn) * 1.E-6
+
+
+      ENDIF
+
+      END DO
+
+   END SUBROUTINE dta_trc
+
+#else
+
+   !!----------------------------------------------------------------------
+   !!   Default case                        NO 3D passive tracer data field
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dta_trc( kt )        ! Empty routine
+      WRITE(*,*) 'dta_trc: You should not have seen this print! error?', kt
+   END SUBROUTINE dta_trc
+
+#endif
+
+END MODULE trcdta
Index: trunk/NEMO/TOP_SRC/trcdtr.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcdtr.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcdtr.F90	(revision 268)
@@ -0,0 +1,327 @@
+MODULE trcdtr
+   !!=======================================================================================
+   !!
+   !!                       *** MODULE trcdtr ***
+   !!
+   !!  Computes or READ initial DATA for passive tracer
+   !!
+   !!=======================================================================================
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      !! ==============
+      USE oce_trc
+      USE trc
+      USE sms
+      USE trcdta
+      USE lib_mpp
+
+      IMPLICIT NONE
+      PRIVATE
+  !! * Accessibility
+      PUBLIC trc_dtr
+
+CONTAINS
+
+#if defined key_passivetrc
+
+SUBROUTINE trc_dtr
+!!---------------------------------------------------------------------
+!!
+!!                       ROUTINE trci_dtr
+!!                     ******************
+!!  PURPOSE :
+!!  ---------
+!!     computes or READ initial DATA for passive tracer
+!!   -----
+!!      COMMON
+!!            /comdom/          : domain PARAMETER
+!!            /comcoo/          : orthogonal curvilinear coordinates
+!!                                and scale factors
+!!            /comask/          : masks, bathymetry
+!!   OUTPUT :
+!!   ------
+!!      COMMON
+!!            /cottrc/          : passive tracer field now and before
+!!
+!!
+!!   History:
+!!   --------
+!!      original  : 96-11
+!!      additions : 99-9
+!!                : 00-12 (O. Aumont, E. Kestenare) add for POC in sediments 
+!!                         add for POC in sediments  
+!!    03/05  O. Aumont and A. El Moussaoui  F90 
+!!----------------------------------------------------------------------
+!!----------------------------------------------------------------------
+!! local declarations
+!! ================== 
+      INTEGER :: ji,jj,jk,jn 
+      REAL(wp) :: alka0,oxyg0,calc0,bioma0,    &
+                   silic1,po4,no3,                 &
+                   caralk,bicarb,                  &
+                   ztraa, ztrab, ztran
+!!---------------------------------------------------------------------
+!!  OPA.9 
+!!---------------------------------------------------------------------
+!! 0. initialisations
+!! ------------------
+
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) ' *** trcdtr initialisation for '
+      IF(lwp) WRITE(numout,*) '     passive tracers'
+      IF(lwp) WRITE(numout,*) ' '
+
+#if defined key_trc_hamocc3
+      sco2   = 2.15e-3
+      alka0  = 2.45e-3
+      oxyg0  = 2.e-4
+      po4    = 2.1e-6/po4r
+      bioma0 = 1.e-8
+      silic1 = 85.e-6
+      calc0  = 1.e-5
+
+      trn(:,:,:,jpdic) = sco2
+      trn(:,:,:,jptal) = alka0
+      trn(:,:,:,jpoxy) = oxyg0
+      trn(:,:,:,jppo4) = po4
+      trn(:,:,:,jppoc) = bioma0
+      trn(:,:,:,jpsil) = silic1
+      trn(:,:,:,jpcal) = calc0
+#if defined key_trc_p3zd
+      trn(:,:,:,jpphy) = bioma0
+      trn(:,:,:,jpzoo) = bioma0
+      trn(:,:,:,jpdoc) = bioma0
+#endif
+
+      DO jk = 1, jpk
+        DO jj = 1, jpj
+          DO ji = 1, jpi
+            caralk = trn(ji,jj,jk,jptal)-
+     &                 bor/(1.+1.E-7/akb3(ji,jj,jk))
+           co3(ji,jj,jk) = caralk-trn(ji,jj,jk,jpdic)
+           bicarb = (2.*trn(ji,jj,jk,jpdic)-caralk)
+           hi(ji,jj,jk) = ak23(ji,jj,jk)*bicarb/co3(ji,jj,jk)
+          ENDDO
+        ENDDO
+      ENDDO
+
+      h2co3(:,:) = 1.e-5
+
+!!  initialize Silicate and Calcite in sediments
+!!  --------------------------------------------
+
+      sedcal = 0.
+      sedsil = 0.
+
+      IF(lwp) WRITE(numout,*) 'Initialization of P3ZD tracers done'
+      IF(lwp) WRITE(numout,*) '-----------------------------------'
+
+#elif defined key_cfc
+      trn(:,:,:,:)=0.0
+#elif defined key_gosac
+      trn(:,:,:,1)=1895.*1.e-6*1028.*tmask(:,:,:)
+      trn(:,:,:,2)=0.9*1895.*1.e-6*1028.*tmask(:,:,:)
+
+#elif defined key_trc_age
+      trn(:,:,:,1)=1.
+      trn(:,:,:,2)=0. 
+
+#elif defined key_trc_lobster1 && (defined key_eel_r6 || defined key_eel_r2)
+! analytical initialisation used in Levy et al. (2001)
+      
+      DO jk=1,7
+        trn(:,:,jk,jpdet)=0.016*tmask(:,:,jk)
+        trn(:,:,jk,jpzoo)=0.018*tmask(:,:,jk)
+        trn(:,:,jk,jpphy)=0.036*tmask(:,:,jk)
+        trn(:,:,jk,jpno3)=1.e-5*tmask(:,:,jk)
+        trn(:,:,jk,jpnh4)=0.0005*tmask(:,:,jk)
+        trn(:,:,jk,jpdom)=0.017*tmask(:,:,jk)
+      END DO
+
+      trn(:,:,8,jpdet)=0.020*tmask(:,:,1)
+      trn(:,:,8,jpzoo)=0.027*tmask(:,:,1)
+      trn(:,:,8,jpphy)=0.041*tmask(:,:,1)
+      trn(:,:,8,jpno3)=0.00022*tmask(:,:,1)
+      trn(:,:,8,jpnh4)=0.0033*tmask(:,:,1)
+      trn(:,:,8,jpdom)=0.021*tmask(:,:,1)
+
+      trn(:,:,9,jpdet)=0.0556*tmask(:,:,1)
+      trn(:,:,9,jpzoo)=0.123*tmask(:,:,1)
+      trn(:,:,9,jpphy)=0.122*tmask(:,:,1)
+      trn(:,:,9,jpno3)=0.028*tmask(:,:,1)
+      trn(:,:,9,jpnh4)=0.024*tmask(:,:,1)
+      trn(:,:,9,jpdom)=0.06*tmask(:,:,1)
+
+      trn(:,:,10,jpdet)=0.025*tmask(:,:,1)
+      trn(:,:,10,jpzoo)=0.016*tmask(:,:,1)
+      trn(:,:,10,jpphy)=0.029*tmask(:,:,1)
+      trn(:,:,10,jpno3)=2.462*tmask(:,:,1)
+      trn(:,:,10,jpnh4)=0.04*tmask(:,:,1)
+      trn(:,:,10,jpdom)=0.022*tmask(:,:,1)
+
+      trn(:,:,11,jpdet)=0.0057*tmask(:,:,1)
+      trn(:,:,11,jpzoo)=0.0005*tmask(:,:,1)
+      trn(:,:,11,jpphy)=0.0006*tmask(:,:,1)
+      trn(:,:,11,jpno3)=3.336*tmask(:,:,1)
+      trn(:,:,11,jpnh4)=0.005*tmask(:,:,1)
+      trn(:,:,11,jpdom)=0.004*tmask(:,:,1)
+
+      trn(:,:,12,jpdet)=0.002*tmask(:,:,1)
+      trn(:,:,12,jpzoo)=1.e-6*tmask(:,:,1)
+      trn(:,:,12,jpphy)=5.e-6*tmask(:,:,1)
+      trn(:,:,12,jpno3)=4.24*tmask(:,:,1)
+      trn(:,:,12,jpnh4)=0.001*tmask(:,:,1)
+      trn(:,:,12,jpdom)=3.e-5*tmask(:,:,1)
+
+      DO jk=13,jpk
+        trn(:,:,jk,jpdet)=0.0
+        trn(:,:,jk,jpzoo)=0.0
+        trn(:,:,jk,jpphy)=0.0
+        trn(:,:,jk,jpnh4)=0.0
+        trn(:,:,jk,jpdom)=0.0
+      END DO
+
+      trn(:,:,13,jpno3)=5.31*tmask(:,:,13)
+      trn(:,:,14,jpno3)=6.73*tmask(:,:,14)
+      trn(:,:,15,jpno3)=8.32*tmask(:,:,15)
+      trn(:,:,16,jpno3)=10.13*tmask(:,:,16)
+      trn(:,:,17,jpno3)=11.95*tmask(:,:,17)
+      trn(:,:,18,jpno3)=13.57*tmask(:,:,18)
+      trn(:,:,19,jpno3)=15.08*tmask(:,:,19)
+      trn(:,:,20,jpno3)=16.41*tmask(:,:,20)
+      trn(:,:,21,jpno3)=17.47*tmask(:,:,21)
+      trn(:,:,22,jpno3)=18.29*tmask(:,:,22)
+      trn(:,:,23,jpno3)=18.88*tmask(:,:,23)
+      trn(:,:,24,jpno3)=19.30*tmask(:,:,24)
+      trn(:,:,25,jpno3)=19.68*tmask(:,:,25)
+      trn(:,:,26,jpno3)=19.91*tmask(:,:,26)
+      trn(:,:,27,jpno3)=19.99*tmask(:,:,27)
+      trn(:,:,28,jpno3)=20.01*tmask(:,:,28)
+      trn(:,:,29,jpno3)=20.01*tmask(:,:,29)
+      trn(:,:,30,jpno3)=20.01*tmask(:,:,30)
+
+#elif defined key_trc_pisces
+
+      sco2   = 2.3e-3
+      alka0  = 2.39e-3
+      oxyg0  = 1.8e-4
+      po4    = 2.165e-6/po4r
+      bioma0 = 1.e-8
+      silic1 = 91.51e-6
+      calc0  = 1.e-6
+      no3    = 30.88E-6*7.6
+
+      trn(:,:,:,jpdic) = sco2
+      trn(:,:,:,jptal) = alka0
+      trn(:,:,:,jpoxy) = oxyg0
+      trn(:,:,:,jppo4) = po4
+      trn(:,:,:,jppoc) = bioma0
+      trn(:,:,:,jpsil) = silic1
+      trn(:,:,:,jpcal) = calc0
+      trn(:,:,:,jpphy) = bioma0
+      trn(:,:,:,jpzoo) = bioma0
+      trn(:,:,:,jpdoc) = bioma0
+      trn(:,:,:,jpdia) = bioma0
+      trn(:,:,:,jpmes) = bioma0
+      trn(:,:,:,jpbsi) = bioma0*0.15
+      trn(:,:,:,jpfer) = 0.6E-9
+      trn(:,:,:,jpbfe) = bioma0*5E-6
+      trn(:,:,:,jpgoc) = bioma0
+      trn(:,:,:,jpsfe) = bioma0*5.E-6
+      trn(:,:,:,jpdfe) = bioma0*5.E-6
+      trn(:,:,:,jpnfe) = bioma0*5.E-6
+      trn(:,:,:,jpdsi) = bioma0*5.E-6
+      trn(:,:,:,jpnch) = bioma0*12./55.
+      trn(:,:,:,jpdch) = bioma0*12./55.
+      trn(:,:,:,jpno3) = no3 
+      trn(:,:,:,jpnh4) = bioma0
+
+!!  Initialization of chemical variables of the carbon cycle
+!!  --------------------------------------------------------
+
+      DO jk = 1,jpk
+        DO jj = 1,jpj
+          DO ji = 1,jpi
+              caralk = trn(ji,jj,jk,jptal)-         & 
+                      borat(ji,jj,jk)/(1.+1.E-8/(rtrn+akb3(ji,jj,jk)))
+              co3(ji,jj,jk)=(caralk-trn(ji,jj,jk,jpdic))*tmask(ji,jj,jk)       & 
+                     +(1.-tmask(ji,jj,jk))*.5e-3
+              bicarb = (2.*trn(ji,jj,jk,jpdic)-caralk)
+              hi(ji,jj,jk) = (ak23(ji,jj,jk)*bicarb/co3(ji,jj,jk))             &  
+                *tmask(ji,jj,jk)+(1.-tmask(ji,jj,jk))*1.e-9
+          ENDDO
+        ENDDO
+      ENDDO
+
+      h2co3(:,:) = 1.e-5
+
+!!  initialize the half saturation constant for silicate
+!!  ----------------------------------------------------
+
+      xksi(:,:)=2.E-6
+
+!! initialize Silicate and Calcite in sediments
+!! --------------------------------------------
+      sedcal(:,:) = 0.
+      sedsil(:,:) = 0.
+
+      IF(lwp) WRITE(numout,*) 'Initialization of PISCES tracers done'
+      IF(lwp) WRITE(numout,*) ' '
+
+#else
+ 
+!! general case
+
+      trn(:,:,:,:)=0.1
+
+#endif
+
+#if defined key_trc_dta
+!!   Initialization of tracer from a file
+!!   that may also be used for damping
+ 
+      CALL dta_trc( nit000 )
+      DO  jn = 1, jptra
+        IF( lutini(jn) ) THEN 
+!! initialisation from file
+           trn(:,:,:,jn) = trdta(:,:,:,jn)
+        ENDIF
+      END DO
+#endif
+
+!! before field :
+!! -------------
+      trb(:,:,:,:) = trn(:,:,:,:)
+
+      IF(lwp) WRITE(numout,*)  ' '
+      DO jn = 1, jptra
+         IF( ln_ctl .AND. lwp ) THEN ! print mean trends (used for debugging)
+            ztraa = SUM( tra(1:nictle,1:njctle,1:jpk,jn) *   &
+                tmask(1:nictle,1:njctle,1:jpk) )
+            ztrab = SUM( trb(1:nictle,1:njctle,1:jpk,jn) *     &
+                tmask(1:nictle,1:njctle,1:jpk) )
+            ztran = SUM( trn(1:nictle,1:njctle,1:jpk,jn) *    &
+                tmask(1:nictle,1:njctle,1:jpk) )
+            WRITE(numout,*) ' trcdtr  - ',ctrcnm(jn),   &
+                ' : ', ztraa, '  ', ztrab, '  ', ztran
+         ENDIF
+      END DO
+
+!!  initialize the POC in sediments
+#  if defined key_trc_npzd || defined key_trc_lobster1 || defined key_trc_hamocc3 || defined key_trc_pisces
+
+      sedpoc(:,:) = 0.
+
+#  endif
+ END SUBROUTINE trc_dtr 
+
+#else
+
+SUBROUTINE  trc_dtr 
+!!======================
+   !! no passive tracers
+!!======================
+END SUBROUTINE  trc_dtr
+#endif
+
+END MODULE trcdtr
Index: trunk/NEMO/TOP_SRC/trcini.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcini.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcini.F90	(revision 268)
@@ -0,0 +1,128 @@
+MODULE trcini
+   !!==========================================================================
+   !!
+   !!                       *** MODULE trcini ***
+   !!
+   !! Initialization for passive tracer (for restart or not)  
+   !!     
+   !!=========================================================================
+                                                                                                                      
+      !! * Modules used
+      !! ==============
+      USE ioipsl
+      USE oce_trc
+      USE trc
+      USE sms
+      USE lib_mpp
+
+     IMPLICIT NONE
+     PRIVATE
+
+    !! * Accessibility
+    PUBLIC trc_ini
+
+CONTAINS
+
+#if defined key_passivetrc
+
+ SUBROUTINE trc_ini
+!!---------------------------------------------------------------------
+!!                       ROUTINE trcini
+!!                     ******************
+!!  PURPOSE :
+!!  ---------
+!!     initialization for passive tracer
+!!     for restart or not
+!!
+!!   WORKSPACE :
+!!   ---------
+!!      ji jj jk
+!!
+!!   History:
+!!   --------
+!!                 04/00 (O. Aumont, M.A. Foujols) HAMOCC3 and P3ZD
+!!                 03/05  O.Aumont and A.El Moussaoui  F90
+!!----------------------------------------------------------------------
+!!----------------------------------------------------------------------
+!! local declarations
+!! ==================
+
+      INTEGER :: ji,jj,jk,jn,jl
+
+!!----------------------------------------------------------------------
+!! statement functions
+!! ===================
+
+#include "passivetrc_substitute.h90"
+
+!!---------------------------------------------------------------------
+!!  OPA.9   
+!!---------------------------------------------------------------------
+
+#    if defined key_trc_npzd
+#    include "trcini.npzd.h90"
+#    elif defined key_trc_lobster1
+#    include "trcini.lobster1.h90"
+#    elif defined key_trc_hamocc3
+#    include "trcini.hamocc3.h90"
+#    elif defined key_trc_pisces
+#    include "trcini.pisces.h90"
+#    else
+
+! Specific initialization to do
+!!-----------------------------
+#    endif
+
+!! 1. initialization of passives tracers field
+!! -------------------------------------------
+      DO jn=1,jptra
+              trn(:,:,:,jn)=0.e0
+              tra(:,:,:,jn)=0.e0
+      END DO
+
+#if defined key_trc_diaadd
+!! initialization of output 2d and 3d arrays
+
+      DO jn=1,jpdia2d
+            trc2d(:,:,jn)=0.e0
+      END DO
+      DO jn=1,jpdia3d
+              trc3d(:,:,:,jn)=0.e0
+      END DO
+#endif
+
+#if defined key_trc_diabio
+   !! initialization of biological trends
+      DO jn=1,jpdiabio
+              trbio(ji,jj,jk,jn)=0.e0
+      END DO
+#endif
+
+#if defined key_trc_diatrd
+   !! initialization of tracer trends
+      DO jl=1,jpdiatrc
+        DO jn=1,jptra
+                trtrd(:,:,:,jn,jl)=0.e0
+        END DO
+      END DO
+#endif      
+      
+      IF(lwp) THEN
+          WRITE(numout,*) ' '
+          WRITE(numout,*) ' trcini: generic initialisation done '
+          WRITE(numout,*) ' '
+      ENDIF
+
+END SUBROUTINE trc_ini
+
+#else
+
+SUBROUTINE trc_ini
+
+   !! no passive tracers
+   !!===================
+END SUBROUTINE trc_ini
+
+#endif
+
+END MODULE trcini
Index: trunk/NEMO/TOP_SRC/trclec.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trclec.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trclec.F90	(revision 268)
@@ -0,0 +1,272 @@
+MODULE trclec
+   !!==========================================================================
+   !!
+   !!                       *** MODULE trclec ***
+   !! Read and print options for the passive tracer run (namelist)
+   !! O.Aumont and A.El Moussaoui 03/05 F90
+   !!=========================================================================
+
+      !! * Modules used
+      !! ==============
+      USE oce_trc
+      USE trc
+      USE trctrp_lec
+      USE trclsm
+
+     IMPLICIT NONE
+     PRIVATE 
+
+    !! * Accessibility
+    PUBLIC trc_lec
+
+CONTAINS
+
+#if defined key_passivetrc
+
+SUBROUTINE trc_lec
+!!---------------------------------------------------------------------
+!!                       ROUTINE trclec
+!!                     ******************
+!!  PURPOSE :
+!!  ---------
+!!     READ and PRINT options for the passive tracer run (namelist)
+!!
+!!   History:
+!!   --------
+!!      original  : 96-11 (M.A. Foujols, M. Levy) passive tracer
+!!      modification : 98-04 (M.A Foujols, L. Bopp) ahtrb0 for isopycnal
+!!                                                  diffusion
+!!      modification : 99-10(M.A. Foujols, M. Levy) separation of sms
+!!      additions : 00-05(A. Estublier) TVD Limiter Scheme : Tests 
+!!                                      on ndttrc
+!!      additions : 00-06(A. Estublier) MUSCL Scheme : Tests 
+!!                                      on ndttrc
+!!      additions : 00-07(A. Estublier) PPM Scheme : Tests on ndttrc
+!!      modification : 00-11 (M.A Foujols, E Kestenare) trcrat, ahtrc0 and aeivtr0
+!!      modification : 01-01 (E Kestenare) suppress ndttrc=1 
+!!                                         for Arakawa and TVD schemes
+!!     O.Aumont and A.El Moussaoui 03/05 F90
+!!----------------------------------------------------------------------
+
+!! local declarations
+!! ==================
+
+      INTEGER ::  ji
+      CHARACTER (len=32) :: clname
+
+!!----------------------------------------------------------------------
+!! statement functions
+!! ===================
+
+#include "passivetrc_substitute.h90"
+
+!!
+!!---------------------------------------------------------------------
+!!  OPA.90   03/2005 
+!!---------------------------------------------------------------------
+
+!! 0. initializations
+!! ------------------
+
+      namelist/nattrc/nwritetrc,lrsttr,nrsttr, ctrcnm,ctrcnl,ctrcun,lutini     !general   
+
+      namelist/natnum/rsc,rtrn,ncortrc,ndttrc,crosster
+
+#if defined key_trc_diatrd
+      namelist/natrtd/luttrd,nwritetrd                      ! dynamical trends
+#endif
+
+#if defined key_trc_diaadd
+      namelist/natadd/ctrc3d,ctrc3l,ctrc2d,ctrc2l, ctrc3u, ctrc2u,     &
+                      nwriteadd                             !additional diagnostics
+#endif
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' '
+          WRITE(numout,*) ' ROUTINE trclec'
+          WRITE(numout,*) ' **************'
+          WRITE(numout,*) ' '
+          WRITE(numout,*) ' namelist for passive tracer'
+          WRITE(numout,*) ' ***************************'
+          WRITE(numout,*) ' '
+      ENDIF
+
+      numnat=80
+      REWIND (numnat)
+
+      clname='namelist.passivetrc'
+      OPEN( numnat, FILE= clname, FORM='formatted', STATUS = 'old')
+
+!! 1., 2. & 3. initialization with namelist files
+!! ----------------------------------------------
+!! 1.0 namelist nattrc :
+
+      nwritetrc = 10
+      lrsttr=.FALSE.
+      nrsttr = 0
+
+      DO ji=1,jptra
+        WRITE (ctrcnm(ji),'("TR_",I1)') ji
+        WRITE (ctrcnl(ji),'("TRACER NUMBER ",I1)') ji
+        ctrcun(ji)='mmole/m3'
+        lutini(ji)=.FALSE. 
+      END DO
+
+
+      REWIND(numnat)
+      READ(numnat,nattrc)
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' '
+          WRITE(numout,*) 'nattrc'
+          WRITE(numout,*) ' '
+          WRITE(numout,*)          &
+              ' frequency of outputs for passive tracers nwritetrc = '    &
+              ,nwritetrc  
+          WRITE(numout,*) ' restart LOGICAL for passive tr. lrsttr = ',   &
+     &         lrsttr
+          WRITE(numout,*) ' control of time step for p. tr. nrsttr = ',   & 
+     &         nrsttr
+          DO ji=1,jptra
+            WRITE(numout,*) ' tracer nb: ',ji,' name = ',ctrcnm(ji)       & 
+     &           ,ctrcnl(ji) 
+            WRITE(numout,*) ' in unit = ',ctrcun(ji)
+            WRITE(numout,*) ' initial value in FILE : ',lutini(ji) 
+            WRITE(numout,*) ' '
+          END DO
+          WRITE(numout,*) ' '
+      ENDIF
+
+#if defined key_trc_diatrd
+
+!! 1.2 namelist nattrd : passive tracers dynamical trends
+
+      nwritetrd=10
+
+!! default : no dynamical trend recording
+!! --------------------------------------
+      DO ji=1,jptra
+        luttrd(ji) = .FALSE.
+      END DO 
+
+      REWIND(numnat)
+      READ(numnat,natrtd)
+
+      IF(lwp) THEN
+          WRITE(numout,*) 'natrtd'
+          WRITE(numout,*) ' '
+          WRITE(numout,*)                        &
+             ' frequency of outputs for dynamical trends nwritetrd = '   &
+             ,nwritetrd
+          DO ji=1,jptra
+            WRITE(numout,*)                      &
+               ' keep dynamical trends for tracer number :',ji          &
+               ,luttrd(ji)   
+          END DO 
+      ENDIF
+#endif
+
+!!1.3 namelist natadd : passive tracers diagnostics
+!!-------------------------------------------------
+
+#if defined key_trc_diaadd
+
+      nwriteadd = 10
+
+!! default value for 3D output arrays : short and long name, units
+
+      DO ji=1,jpdia3d
+        WRITE (ctrc3d(ji),'("3D_",I1)') ji
+        WRITE (ctrc3l(ji),'("3D DIAGNOSTIC NUMBER ",I2)') ji
+        ctrc3u(ji)=' '
+      END DO 
+
+
+!! default value for 2D output arrays : short and long name, units
+!! ---------------------------------------------------------------
+      DO ji=1,jpdia2d
+        WRITE (ctrc2d(ji),'("2D_",I1)') ji
+        WRITE (ctrc2l(ji),'("2D DIAGNOSTIC NUMBER ",I2)') ji
+        ctrc2u(ji)=' '
+      END DO 
+
+      REWIND(numnat)
+      READ(numnat,natadd)
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' natadd'
+          WRITE(numout,*) ' '
+          WRITE(numout,*)                          &
+             ' frequency of outputs for additional arrays nwriteadd = '   &
+             ,nwriteadd
+          DO ji=1,jpdia3d
+            WRITE(numout,*)                     &
+               'name of 3d output field number :',ji,' : ',ctrc3d(ji)  
+            WRITE(numout,*) ctrc3l(ji)  
+            WRITE(numout,*) ' in unit = ',ctrc3u(ji)
+          END DO 
+          WRITE(numout,*) ' '
+          DO ji=1,jpdia2d
+            WRITE(numout,*)                    &
+               'name of 2d output field number :',ji,' : ',ctrc2d(ji)  
+            WRITE(numout,*) ctrc2l(ji)  
+            WRITE(numout,*) ' in unit = ',ctrc2u(ji)
+          END DO 
+          WRITE(numout,*) ' '
+      ENDIF
+#endif
+
+!! 1.1 namelist natnum :
+!! ---------------------
+      rsc=1.
+      rtrn=1.e-15
+      ncortrc=1
+      ndttrc=4
+      crosster=.FALSE.
+
+      REWIND(numnat)
+      READ(numnat,natnum)
+
+!!Chris  computes the first time step of tracer model
+      nittrc000 = nit000 + ndttrc - 1
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' '
+          WRITE(numout,*) 'natnum'
+          WRITE(numout,*) ' '
+          WRITE(numout,*) ' tuning coefficient              rsc     = ',    &
+             rsc
+          WRITE(numout,*) ' truncation value                rtrn    = ',    &
+             rtrn
+          WRITE(numout,*) ' number of corrective phase      ncortrc = ',    &
+             ncortrc
+          WRITE(numout,*) ' time step freq. for pass. trac. ndttrc  = ',    &
+             ndttrc
+          WRITE(numout,*) ' 1st time step for pass. trac. nittrc000 = ',    &
+             nittrc000
+          WRITE(numout,*) ' computes or not crossterms    crosster  = ',    &
+             crosster
+      ENDIF
+
+
+!! namelist of transport
+!! ---------------------
+      CALL trc_trp_lec
+
+!! namelist of SMS
+!! ---------------      
+      CALL trc_lsm
+
+END SUBROUTINE trc_lec 
+
+#else
+
+SUBROUTINE trc_lec
+  !!==============
+     !! no passive tracers
+  !!==============
+END SUBROUTINE trc_lec
+
+#endif
+
+END MODULE  trclec
Index: trunk/NEMO/TOP_SRC/trclsm.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trclsm.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trclsm.F90	(revision 268)
@@ -0,0 +1,69 @@
+MODULE trclsm
+   !!=======================================================================================
+   !!
+   !!                       *** MODULE trclsm ****
+   !!
+   !!  READS specific NAMELIST for sms terms
+   !!
+   !!=======================================================================================
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      !! ==============
+      USE oce_trc
+      USE trc
+      USE sms
+
+                                                                                                                      
+      IMPLICIT NONE                             
+      PRIVATE
+
+  !! * Accessibility
+   PUBLIC trc_lsm
+
+CONTAINS
+
+#if defined key_passivetrc
+
+SUBROUTINE trc_lsm
+!!---------------------------------------------------------------------
+!!
+!!                       ROUTINE trclsm
+!!                     ******************
+!!  PURPOSE :
+!!  ---------
+!!     READS specific NAMELIST for sms terms 
+!!
+!!   History:
+!!   --------
+!!      original  : 99-10 (M.A. Foujols, M. Levy) passive tracer
+!!                  00-04 (O. Aumont, M.A. Foujols) HAMOCC3 and P3ZD
+!!                  02-05 (O. Aumont) AGE TRACER
+!!     03/2005  O. Aumont and A. El Moussaoui  F90
+!!----------------------------------------------------------------------
+
+#    if defined key_trc_npzd
+#    include "trclsm.npzd.h90"
+#    elif defined key_trc_lobster1
+#    include "trclsm.lobster1.h90"
+#    elif defined key_trc_hamocc3
+#    include "trclsm.hamocc3.h90"
+#    elif defined key_trc_age
+#    include "trclsm.age.h90"
+#    elif defined key_trc_pisces
+#    include "trclsm.pisces.h90"
+#    else
+!!      user can define here his own sms namelist
+#    endif
+
+END  SUBROUTINE  trc_lsm
+
+#else
+
+SUBROUTINE trc_lsm
+!!================
+   !! no passive tracers
+END  SUBROUTINE  trc_lsm
+
+#endif  
+
+END MODULE trclsm  
Index: trunk/NEMO/TOP_SRC/trcrst.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcrst.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcrst.F90	(revision 268)
@@ -0,0 +1,477 @@
+MODULE trcrst
+   !!===========================================================================================
+   !!
+   !!                       *** MODULE trcrst ***
+   !!
+   !!   Read the restart files for passive tracers
+   !!
+   !!===========================================================================================
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      !! ==============
+      USE oce_trc
+      USE trc
+      USE sms
+      USE trctrp_lec   
+                                                                                                                            
+      IMPLICIT NONE
+      PRIVATE
+
+   !! * Accessibility
+   PUBLIC trc_rst
+   PUBLIC trc_wri
+
+   !! * Module variables
+   CHARACTER (len=48) ::   &
+      trestart = 'initial.trc.nc'   ! restart file name
+
+CONTAINS
+
+#if defined key_fdir
+   !!----------------------------------------------------------------------
+   !!   'key_fdir'                                       direct access file
+   !!----------------------------------------------------------------------
+#include "trcrst_fdir.h90"
+
+#else
+    !!  USE ioipsl
+#if defined key_passivetrc    
+
+SUBROUTINE trc_rst 
+   !!===========================================================================================
+   !!
+   !!                       ROUTINE trc_rst
+   !!                     *******************
+   !!
+   !!  PURPOSE :
+   !!  ---------
+   !!     READ files for restart for passive tracer
+   !!
+   !!   METHOD :
+   !!   -------
+   !!      READ the previous fields on the FILE nutrst
+   !!      the first record indicates previous characterics
+   !!      after control with the present run, we READ :
+   !!      - prognostic variables on the second and more record
+   !!
+   !!   History:
+   !!   --------
+   !!  original  : 96-11
+   !!  00-05 (A. Estublier) TVD Limiter Scheme key_trc_tvd 
+   !!  00-12 (O. Aumont, E. Kestenare) read restart file for sediments 
+   !!  01-05 (O. Aumont, E. Kestenare) read restart file for calcite and silicate sediments 
+   !!  05-03 (O. Aumont and A. El Moussaoui) F90           
+   !!------------------------------------------------------------------------
+   !! * Modules used
+      USE ioipsl
+
+
+   !! local declarations
+   !! ==================
+    LOGICAL ::  llog       !!!
+    CHARACTER (len=32) :: clname1,clname2
+    CHARACTER (len=32) :: clname = 'restart.trc'
+    CHARACTER (len=12) :: clvnames(80)  
+
+    INTEGER :: ino1,jn,iarak0,iarak1,          &
+               ji, jj, jk,                   &
+               itime, ibvar
+    REAL(wp) :: caralk,bicarb,zdt,        &     
+                zdate0
+    REAL(wp) ::   zdept(jpk), zlamt(jpi,jpj), zphit(jpi,jpj)
+
+    REAL(wp), DIMENSION(3) :: zinfo
+
+    !!---------------------------------------------------------------------
+    !!  OPA.9 03-2005  
+    !!---------------------------------------------------------------------
+    !! 0. initialisations
+    !!------------------
+
+
+      IF( ln_trcadv_cen2 .OR. ln_trcadv_tvd ) THEN
+          iarak0 = 1
+      ELSE
+          iarak0=0
+      ENDIF
+
+
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) ' *** trc_rst beginning of restart for'
+      IF(lwp) WRITE(numout,*) ' passive tracer'
+      IF(lwp) WRITE(numout,*) ' the present run :'
+      IF(lwp) WRITE(numout,*) '   number job is  : ',no
+      IF(lwp) WRITE(numout,*) '   with the time nit000 : ',nit000
+      IF(lwp) THEN
+          IF(iarak0.eq.1) then
+              WRITE(numout,*) '   and before fields for Arakawa sheme '
+          ENDIF 
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! Time domain : restart
+      ! -------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' *** passive tracer restart option'
+      SELECT CASE ( nrsttr )
+      CASE ( 0 )
+         IF(lwp) WRITE(numout,*) ' nrsttr = 0 no control of nit000'
+      CASE ( 1 )
+         IF(lwp) WRITE(numout,*) ' nrsttr = 1 we control the date of nit000'
+      CASE ( 2 )
+         IF(lwp) WRITE(numout,*) ' nrsttr = 2 the date adatrj is read in restart file'
+      CASE DEFAULT
+         IF(lwp) WRITE(numout,*) '  ===>>>> nrsttr not equal 0, 1 or 2 : no control of the date'
+         IF(lwp) WRITE(numout,*) ' =======                   ========='
+      END SELECT
+
+
+    !! 1. READ nutrst
+    !! --------------
+    !! ... first information
+    !! ---------------------
+      itime=0
+      llog=.false.           !!!
+      zlamt(:,:) = 0.e0
+      zphit(:,:) = 0.e0
+      zdept(:)   = 0.e0
+      CALL restini(clname,jpi,jpj,zlamt,zphit,jpk,zdept,clname         & 
+       &           ,itime,zdate0,zdt,nutrst)
+
+      CALL ioget_vname(nutrst, ibvar, clvnames)
+      CALL restget(nutrst,'info',1,1,3,0,llog,zinfo)
+      ino1  = nint(zinfo(1))
+      iarak1 = nint(zinfo(3))
+
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) ' READ nutrst with '
+      IF(lwp) WRITE(numout,*) '   number job is  : ',ino1
+      IF(lwp) WRITE(numout,*) '   with the time it : ',nint(zinfo(2))
+      IF(lwp) THEN
+          IF(iarak1.eq.1) then
+              WRITE(numout,*) '   and before fields for Arakawa sheme '
+          ENDIF 
+      ENDIF
+      IF(lwp) WRITE(numout,*) '   number of variables   : ', ibvar
+      IF(lwp) WRITE(numout,*) '   NetCDF variables      : '
+      IF(lwp) WRITE(numout,*) ' ',clvnames (:ibvar)
+      IF(lwp) WRITE(numout,*) ' '
+
+   !! 1.2 control of date
+   !! -------------------
+
+      IF( nit000- NINT( zinfo(2) ) /= 1 .AND. nrsttr /= 0 ) THEN
+          IF(lwp) THEN
+              WRITE(numout,*) ' ===>>>> : problem with nit000 for the',    &  
+                  ' passive tracer restart'
+              WRITE(numout,*) ' =======                              ',    &    
+                  ' ======================'
+              WRITE(numout,*) ' we stop. verify the FILE'
+              WRITE(numout,*) ' or rerun with the value  0 for the'
+              WRITE(numout,*) ' control of time PARAMETER   nrstdt'
+              WRITE(numout,*) ' '
+          ENDIF
+          STOP 'trc_rst'       !!
+      ENDIF
+
+    !! 1.3 Control of the sheme
+    !! ------------------------
+
+      IF(iarak0.ne.iarak1) THEN
+          IF(lwp) THEN
+              WRITE(numout,*) ' ===>>>> : problem with the',       &   
+                 ' passive tracer restart file'
+              WRITE(numout,*) ' =======                              ',        & 
+                  ' ==========================='
+              WRITE(numout,*) ' we stop. verify the FILE'
+              WRITE(numout,*) ' before field required IF 1=',iarak0
+              WRITE(numout,*) ' before field present in file IF 1=',           & 
+                 iarak1
+              WRITE(numout,*) ' '
+          ENDIF
+          STOP 'trc_rst'       !!!!!    AVERIFIER AU NIV F90'
+      ENDIF
+
+
+    !! ... READ prognostic variables and computes diagnostic variable
+    !! ---------------------------------------------------------------
+
+       DO jn=1,jptra
+         clname='TRN'//ctrcnm(jn)
+         CALL restget(nutrst,clname,jpi,jpj,jpk,0,llog,trn(:,:,:,jn))
+       END DO
+
+       DO jn=1,jptra
+         clname='TRB'//ctrcnm(jn)
+         CALL restget(nutrst,clname,jpi,jpj,jpk,0,llog,trb(:,:,:,jn))
+       END DO
+
+#if defined key_trc_hamocc3
+         clname='SED'//ctrcnm(jppoc)
+         clname1='SED'//ctrcnm(jpcal)
+         clname2='SED'//ctrcnm(jpsil)
+         CALL restget(nutrst,clname1,jpi,jpj,1,0,llog,sedcal(:,:))
+         CALL restget(nutrst,clname2,jpi,jpj,1,0,llog,sedsil(:,:))
+         CALL restget(nutrst,clname,jpi,jpj,1,0,llog,sedpoc(:,:))
+#elif defined key_trc_npzd || defined key_trc_lobster1
+         clname='SED'//ctrcnm(jpdet)
+         CALL restget(nutrst,clname,jpi,jpj,1,0,llog,sedpoc(:,:))
+#elif defined key_trc_pisces
+
+         clname='Silicalim'
+         CALL restget(nutrst,clname,jpi,jpj,1,0,llog,xksi)
+         xksimax=xksi
+
+         clname='SED'//ctrcnm(jppoc)
+         clname1='SED'//ctrcnm(jpcal)
+         clname2='SED'//ctrcnm(jpsil)
+         CALL restget(nutrst,clname1,jpi,jpj,1,0,llog,sedcal(:,:))
+         CALL restget(nutrst,clname2,jpi,jpj,1,0,llog,sedsil(:,:))
+         CALL restget(nutrst,clname,jpi,jpj,1,0,llog,sedpoc(:,:))
+#endif
+
+#if defined key_trc_hamocc3 || defined key_trc_pisces 
+
+
+    !!  Initialization of chemical variables of the carbon cycle
+    !!  --------------------------------------------------------
+
+        DO jk = 1,jpk
+          DO jj = 1,jpj
+            DO ji = 1,jpi
+              caralk = trn(ji,jj,jk,jptal)-       &
+              &        borat(ji,jj,jk)/(1.+1.E-8/(rtrn+akb3(ji,jj,jk)))
+              co3(ji,jj,jk)=(caralk-trn(ji,jj,jk,jpdic))*tmask(ji,jj,jk)   &
+              &        +(1.-tmask(ji,jj,jk))*.5e-3
+              bicarb = (2.*trn(ji,jj,jk,jpdic)-caralk)
+              hi(ji,jj,jk) = (ak23(ji,jj,jk)*bicarb/co3(ji,jj,jk))     &
+              &  *tmask(ji,jj,jk)+(1.-tmask(ji,jj,jk))*1.e-9
+              h2co3(ji,jj) = 1.e-5
+            ENDDO
+          ENDDO
+        ENDDO
+#endif
+
+END SUBROUTINE trc_rst
+
+SUBROUTINE trc_wri(kt)
+   !! ==================================================================================
+   !!
+   !!                       ROUTINE trc_wri
+   !!                     ******************
+   !!
+   !!  PURPOSE :
+   !!  ---------
+   !!     WRITE restart fields in nutwrs
+   !!   METHOD :
+   !!   -------
+   !!
+   !!   nutwrs FILE:
+   !!   each nstock time step , SAVE fields which are necessary for
+   !!   passive tracer restart
+   !!
+   !!
+   !!   INPUT :
+   !!   -----
+   !!      argument
+   !!              kt              : time step
+   !!      COMMON
+   !!            /cottrc/          : passive tracers fields (before,now
+   !!                                  ,after)
+   !!
+   !!   OUTPUT :
+   !!   ------
+   !!      FILE
+   !!           nutwrs          : standard restart fields OUTPUT
+   !!
+   !!   WORKSPACE :
+   !!   ---------
+   !!      ji,jj,jk,jl,ino0,it0,iarak0
+   !!
+   !!   History:
+   !!   --------
+   !!      original : 96-12
+   !!      addition : 99-12 (M.-A. Foujols) NetCDF FORMAT with ioipsl
+   !!      additions : 00-05 (A. Estublier)
+   !!                  TVD Limiter Scheme : key_trc_tvd
+   !!      additions : 01-01 (M.A Foujols, E. Kestenare) bug fix: restclo
+   !!      additions : 01-01 (O. Aumont, E. Kestenare)
+   !!                  write restart file for sediments
+   !!      additions : 01-05 (O. Aumont, E. Kestenare)
+   !!                  write restart file for calcite and silicate sediments
+   !!   05-03 (O. Aumont and A. El Moussaoui) F90
+   !!========================================================================================!
+      !! * Modules used
+      USE ioipsl
+
+     !! * Arguments
+      !! -----------
+      INTEGER, INTENT( in ) :: kt
+
+      !! * local declarations
+      !! ====================
+
+      LOGICAL :: clbon         !!!
+      CHARACTER (len=50) :: clname,clname1,clname2,cln
+
+      INTEGER :: jn,   &
+                 ino0,it0,iarak0,     &
+                 ic,jc,ji,jj,jk,      &
+                 itime
+
+      REAL(wp) :: zdate0, zinfo(3),zdiag_var,    &
+                  zdiag_varmin, zdiag_varmax
+
+
+   !! 1. OUTPUT of restart fields (nutwrs)
+   !! ---------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_wri : write passive tracers restart.output NetCDF file'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+
+      IF( MOD(kt,nstock) == 0 .OR. kt == nitend ) THEN
+
+   !! 0. initialisations
+   !! ------------------
+
+         IF(lwp) WRITE(numout,*) ' '
+         IF(lwp) WRITE(numout,*) 'trc_wri : write the passive tracer restart file in NetCDF format ',   &
+                                              'at it= ',kt,' date= ',ndastp
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~'
+
+
+          ino0 =no
+          it0  =kt
+#if defined key_trc_cen2 || defined key_trc_tvd
+          iarak0=1
+#else
+          iarak0=0
+#endif
+
+          zinfo(1)=FLOAT(ino0)
+          zinfo(2)=FLOAT(it0)
+          zinfo(3)=FLOAT(iarak0)
+
+   !! 1. WRITE in nutwrs
+   !! ------------------
+   !!... first information
+
+          INQUIRE (FILE=trestart,EXIST=clbon)
+          IF(clbon) THEN
+              OPEN(UNIT=nutwrs,FILE=trestart,STATUS='old')
+              CLOSE(nutwrs,STATUS='delete')
+          ENDIF
+
+          ic=1
+          DO jc=1,16
+            IF(cexper(jc:jc) /= ' ') ic = jc
+          END DO
+          WRITE(cln,'("_",i2.2,i2.2,i2.2,"_restart.trc")') nyear, nmonth, nday
+          clname=cexper(1:ic)//cln
+          ic=1
+          DO jc=1,48
+            IF(clname(jc:jc) /= ' ') ic=jc
+          END DO
+          trestart=clname(1:ic)//".nc"
+          itime=0
+          CALL ymds2ju(nyear,nmonth,nday,0.0,zdate0)
+          CALL restini('NONE',jpi,jpj,glamt,gphit,jpk,gdept,clname           &
+      &        ,itime,zdate0,rdt*nstock,nutwrs)
+
+          CALL restput(nutwrs,'info',1,1,3,0,zinfo)
+
+   ! prognostic variables
+   ! --------------------
+
+         DO jn=1,jptra
+            clname='TRN'//ctrcnm(jn)
+            CALL restput(nutwrs,clname,jpi,jpj,jpk,0,trn(:,:,:,jn))
+
+         zdiag_var=0.
+         zdiag_varmin=0.
+         zdiag_varmax=0.
+         IF (lwp) WRITE(numout,*) '----TRACER STAT----'
+
+         DO ji=1,jpi
+            DO jj=1,jpj
+              DO jk=1,jpk
+
+              zdiag_var=zdiag_var+tmask(ji,jj,jk)*trn(ji,jj,jk,jn)
+
+              IF (tmask(ji,jj,jk).EQ.1.) THEN
+                  IF (zdiag_varmin.GT.trn(ji,jj,jk,jn))        &
+                     zdiag_varmin =  trn(ji,jj,jk,jn)
+                  IF (zdiag_varmax.LT.trn(ji,jj,jk,jn))        &
+                     zdiag_varmax =  trn(ji,jj,jk,jn)
+
+              ENDIF
+
+              END DO
+            END DO
+         END DO
+
+
+         zdiag_var=zdiag_var/(jpi*jpj*jpk)
+
+         IF(lwp) WRITE(numout,*) 'MEAN NO ',jn,' =',zdiag_var,'MIN= '  &
+             ,zdiag_varmin,'MAX= ',zdiag_varmax
+
+         END DO
+
+          DO jn=1,jptra
+            clname='TRB'//ctrcnm(jn)
+            CALL restput(nutwrs,clname,jpi,jpj,jpk,0,trb(:,:,:,jn))
+          END DO
+
+#if defined key_trc_hamocc3
+             clname='SED'//ctrcnm(jppoc)
+             clname1='SED'//ctrcnm(jpcal)
+             clname2='SED'//ctrcnm(jpsil)
+             CALL restput(nutwrs,clname1,jpi,jpj,1,0,sedcal(:,:))
+             CALL restput(nutwrs,clname2,jpi,jpj,1,0,sedsil(:,:))
+             CALL restput(nutwrs,clname,jpi,jpj,1,0,sedpoc(:,:))
+#elif defined key_trc_npzd || defined key_trc_lobster1
+             clname='SED'//ctrcnm(jpdet)
+             CALL restput(nutwrs,clname,jpi,jpj,1,0,sedpoc(:,:))
+#elif defined key_trc_pisces
+             clname='SED'//ctrcnm(jppoc)
+             clname1='SED'//ctrcnm(jpcal)
+             clname2='SED'//ctrcnm(jpsil)
+             CALL restput(nutwrs,clname1,jpi,jpj,1,0,sedcal(:,:))
+             CALL restput(nutwrs,clname2,jpi,jpj,1,0,sedsil(:,:))
+             CALL restput(nutwrs,clname,jpi,jpj,1,0,sedpoc(:,:))
+
+             clname='Silicalim'
+             CALL restput(nutwrs,clname,jpi,jpj,1,0,xksi(:,:))
+#endif
+
+          CALL restclo(nutwrs)
+
+      ENDIF
+
+END SUBROUTINE trc_wri
+
+#else
+
+SUBROUTINE trc_rst
+   !! no passive tracers
+END SUBROUTINE trc_rst
+
+SUBROUTINE trc_wri(kt)
+     !!! no passive tracers
+     INTEGER, INTENT ( in ) :: kt
+      WRITE(*,*) 'trc_wri: You should not have seen this print! error?', kt
+END SUBROUTINE trc_wri
+
+#endif 
+
+#endif
+
+
+END MODULE trcrst  
Index: trunk/NEMO/TOP_SRC/trcrst_fdir.h90
===================================================================
--- trunk/NEMO/TOP_SRC/trcrst_fdir.h90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcrst_fdir.h90	(revision 268)
@@ -0,0 +1,237 @@
+SUBROUTINE trc_rst
+   !!===========================================================================================
+   !!
+   !!                       ROUTINE trc_rst
+   !!                     *******************
+   !!
+   !!------------------------------------------------------------------------
+
+      !! * Local declarations
+      INTEGER :: ino0,ino1,it0,it1,idast1,jn,iarak0,iarak1
+      INTEGER ::   ibloc, ilglo
+      INTEGER :: inum   ! temporary logical unit
+      !!----------------------------------------------------------------------
+      !!  OPA 8.5, LODYC-IPSL (2002)
+      !!----------------------------------------------------------------------
+
+      ! open restart file
+      ibloc = 4096
+      ilglo = ibloc*((jpiglo*jpjglo*jpbyt-1 )/ibloc+1)
+      CALL ctlopn(inum,'restarti.trc','OLD','UNFORMATTED','DIRECT',   &
+                  ilglo,numout,lwp,1)
+      ! restart options
+      IF(nrsttr == 0) THEN
+         IF(lwp) WRITE(numout,*) ' nrsttr = 0 no control of nit000'
+      ELSE IF(nrsttr == 1) THEN
+         IF(lwp) WRITE(numout,*) ' nrsttr = 1 we control the date'
+      ELSE
+         IF(lwp) WRITE(numout,*) '  ===>>>> nrsttr not equal 0 or 1'
+         IF(lwp) WRITE(numout,*) ' =======                   ======'
+         IF(lwp) WRITE(numout,*) ' we dont control the date'
+      ENDIF
+
+      ! 0. initialisations
+      ! ------------------
+
+      ino0 =no
+      it0  =nit000
+
+#if defined key_trc_cen2
+      iarak0=1
+#else
+      iarak0=0
+#endif
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' '
+          WRITE(numout,*) ' *** trcrst beginning of restart for'
+          WRITE(numout,*) ' passive tracer'
+          WRITE(numout,*) ' the present run :'
+          WRITE(numout,*) '   number job is  : ',no
+          WRITE(numout,*) '   with the time nit000 : ',nit000
+          IF(iarak0.eq.1) then
+              WRITE(numout,*) '   and before fields for Arakawa sheme '
+          ENDIF 
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! 1. READ
+      ! -------
+
+      ! 1.1 first record
+
+      READ(inum,REC=1) ino1,it1,iarak1
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' '
+          WRITE(numout,*) ' READ nutrst with '
+          WRITE(numout,*) '   number job is  : ',ino1
+          WRITE(numout,*) '   with the time it : ',it1
+          IF(iarak1.eq.1) then
+              WRITE(numout,*) '   and before fields for Arakawa sheme '
+          ENDIF 
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! 1.2 control of date
+
+      IF((it0-it1) /= 1 .AND. ABS(nrsttr) == 1) THEN
+          IF(lwp) THEN
+              WRITE(numout,*) ' ===>>>> : problem with nit000 for the',   &
+                 ' passive tracer restart'
+              WRITE(numout,*) ' =======                              ',   &
+                 ' ======================'
+              WRITE(numout,*) ' we stop. verify the FILE'
+              WRITE(numout,*) ' or rerun with the value  0 for the'
+              WRITE(numout,*) ' control of time PARAMETER   nrstdt'
+              WRITE(numout,*) ' '
+          ENDIF
+          STOP 'trc_rst'
+      ENDIF
+
+      ! 1.3 Control of the sheme
+
+      IF (iarak0 /= iarak1) THEN
+          IF(lwp) THEN
+              WRITE(numout,*) ' ===>>>> : problem with the',    &
+                 ' passive tracer restart file'
+              WRITE(numout,*) ' =======                              ',   &
+                 ' ==========================='
+              WRITE(numout,*) ' we stop. verify the FILE'
+              WRITE(numout,*) ' before field required IF 1=',iarak0
+              WRITE(numout,*) ' before field present in file IF 1=',    &
+                 iarak1
+              WRITE(numout,*) ' '
+          ENDIF
+          STOP 'trc_rst'
+      ENDIF
+
+
+      ! 1.4 READ prognostic variables
+
+      DO jn=1,jptra
+        CALL read3(inum,trn(1,1,1,jn), jn + 1 )
+      END DO
+
+      DO jn=1,jptra
+        CALL read3(inum,trb(1,1,1,jn), jptra + jn + 1 )
+      END DO
+
+#if defined key_trc_hamocc3
+      CALL read2(inum,sedcal(:,:),jpk,2*jptra+2)
+      CALL read2(inum,sedsil(:,:),jpk,2*jptra+3)
+      CALL read2(inum,sedpoc(:,:),jpk,2*jptra+4)
+#elif defined key_trc_npzd || defined key_trc_lobster1
+      CALL read2(inum,sedpoc(:,:),jpk,2*jptra+2)
+#elif defined key_trc_pisces
+
+      CALL read2(inum,xksi(:,:),jpk,2*jptra+2)
+      xksimax(:,:)=xksi(:,:)
+
+      CALL read2(inum,sedcal(:,:),jpk,2*jptra+3)
+      CALL read2(inum,sedsil(:,:),jpk,2*jptra+4)
+      CALL read2(inum,sedpoc(:,:),jpk,2*jptra+5)
+#endif
+
+#if defined key_trc_hamocc3 || defined key_trc_pisces
+
+
+    !!  Initialization of chemical variables of the carbon cycle
+    !!  --------------------------------------------------------
+
+        DO jk = 1,jpk
+          DO jj = 1,jpj
+            DO ji = 1,jpi
+              caralk = trn(ji,jj,jk,jptal)-       &
+              &        borat(ji,jj,jk)/(1.+1.E-8/(rtrn+akb3(ji,jj,jk)))
+              co3(ji,jj,jk)=(caralk-trn(ji,jj,jk,jpdic))*tmask(ji,jj,jk)   &
+              &        +(1.-tmask(ji,jj,jk))*.5e-3
+              bicarb = (2.*trn(ji,jj,jk,jpdic)-caralk)
+              hi(ji,jj,jk) = (ak23(ji,jj,jk)*bicarb/co3(ji,jj,jk))     &
+              &  *tmask(ji,jj,jk)+(1.-tmask(ji,jj,jk))*1.e-9
+              h2co3(ji,jj) = 1.e-5
+            ENDDO
+          ENDDO
+        ENDDO
+#endif
+
+      CLOSE( inum )
+
+   END SUBROUTINE trc_rst
+
+SUBROUTINE trc_wri(kt)
+   !! ==================================================================================
+   !!
+   !!                       ROUTINE trc_wri
+   !!                     ******************
+   !!
+   !!========================================================================================!
+     !! * Arguments
+      !! -----------
+      INTEGER, INTENT( in ) :: kt
+
+      !! * Local declarations
+      INTEGER :: jn
+      INTEGER :: ino0,it0,iarak0
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_wri : write restart.trc.output direct access file'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~'
+         ibloc = 4096
+         ilglo = ibloc*((jpiglo*jpjglo*jpbyt-1 )/ibloc+1)
+         CALL ctlopn( nutwrs,'restart.trc.output', 'UNKNOWN','UNFORMATTED','DIRECT', ilglo, numout, lwp, 1 )
+      ENDIF
+
+      IF( MOD( kt, nstock ) == 0 .OR. kt == nitend ) THEN
+
+         ! 0. Initializations
+         ! ------------------
+
+          IF(lwp) THEN
+              WRITE(numout,*) ' '
+              WRITE(numout,*)       &
+              &  ' trcwri: restart OUTPUT done in nutwrs = ',nutwrs    &
+              &  ,' at it= ',kt,' date= ',ndastp
+              WRITE(numout,*) ' -------'
+          ENDIF
+
+          ino0 =no
+          it0  =kt
+
+#if defined key_trc_cen2
+          iarak0=1
+#else
+          iarak0=0
+#endif
+
+         ! 1. Write in nutwrs
+         ! ------------------
+
+         IF(lwp) WRITE(nutwrs,REC=1)   &                 ! first record
+            ino0, it0, iarak0
+
+          DO jn=1,jptra
+            CALL write3(nutwrs,trn(1,1,1,jn), jn + 1 )
+          END DO
+
+          DO jn=1,jptra
+            CALL write3(nutwrs,trb(1,1,1,jn), jptra + jn + 1 )
+          END DO
+
+#if defined key_trc_hamocc3
+             CALL write2(nutwrs,sedcal,jpk,2*jptra+2)
+             CALL write2(nutwrs,sedsil,jpk,2*jptra+3)
+             CALL write2(nutwrs,sedpoc,jpk,2*jptra+4)
+#elif defined key_trc_npzd || defined key_trc_lobster1
+             CALL write2(nutwrs,sedpoc,jpk,2*jptra+2)
+#elif defined key_trc_pisces
+             CALL write2(nutwrs,xksi,jpk,2*jptra+2)
+
+             CALL write2(nutwrs,sedcal,jpk,2*jptra+3)
+             CALL write2(nutwrs,sedsil,jpk,2*jptra+4)
+             CALL write2(nutwrs,sedpoc,jpk,2*jptra+5)
+#endif
+      ENDIF
+
+   END SUBROUTINE trc_wri
Index: trunk/NEMO/TOP_SRC/trcsms.F90
===================================================================
--- trunk/NEMO/TOP_SRC/trcsms.F90	(revision 268)
+++ trunk/NEMO/TOP_SRC/trcsms.F90	(revision 268)
@@ -0,0 +1,166 @@
+MODULE trcsms
+   !!===========================================================================================
+   !!
+   !!                       *** MODULE trcsms ***
+   !!
+   !!  Time  loop of opa for passive tracer
+   !!
+   !!===========================================================================================
+
+      !! * Modules used
+      !! ==============
+      USE oce_trc
+      USE trc
+
+      IMPLICIT NONE
+      PRIVATE
+
+   !! * Accessibility
+   PUBLIC trc_sms
+
+#if defined key_passivetrc
+
+CONTAINS
+
+SUBROUTINE trc_sms( kt )
+   !!===========================================================================================
+   !!
+   !!                       ROUTINE trcsms
+   !!                     *****************
+   !!
+   !!  PURPOSE :
+   !!  ---------
+   !!          time loop of opa for passive tracer
+   !!
+   !!   METHOD :
+   !!   -------
+   !!      compute the well/spring evolution
+   !!
+   !!   INPUT :
+   !!   -----
+   !!      argument
+   !!              ktask           : task identificator
+   !!              kt              : time step
+   !!      COMMON
+   !!            all the COMMON defined in opa
+   !!
+   !!
+   !!   OUTPUT :			: no
+   !!   ------
+   !!
+   !!   WORKSPACE :
+   !!   ---------
+   !!
+   !!   EXTERNAL :
+   !!   --------
+   !!      trcbio, trcsed, trcopt for NPZD or LOBSTER1 models
+   !!
+   !!      h3cprg for HAMOC3 and P3ZD models
+   !!
+   !!
+   !!   History:
+   !!   --------
+   !!      original  : 96-11
+   !!      additions : 99-07 (M. Levy)
+   !!                  04-00 (O. Aumont, M.A. Foujols) HAMOCC3 and P3ZD
+   !!                  12-00 (O. Aumont, E. Kestenare) add trcexp for instantaneous export 
+   !!   05-03 (O. Aumont and A. El Moussaoui) F90
+   !! -------------------------------------------------------------------------------------
+
+   !! * Arguments
+   !! -----------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+
+   !! this ROUTINE is called only every ndttrc time step
+   !! --------------------------------------------------
+
+      IF ( MOD(kt,ndttrc) /= 0) RETURN
+
+   !! this first routines are parallelized on vertical slab
+   !! ------------------------------------------------------
+
+#if defined key_trc_npzd || defined key_trc_lobster1
+
+   !! tracers: optical model
+   !! ----------------------
+
+       CALL trcopt( kt)
+
+   !! tracers: biological model
+   !! -------------------------
+
+       CALL trcbio( kt)
+
+   !! tracers: sedimentation model
+   !! ----------------------------
+
+       CALL trcsed(kt)
+       CALL trcexp
+
+#elif defined key_trc_hamocc3
+
+   !! h3cprg: main PROGRAM for HAMOCC3 or P3ZD models
+   !! -----------------------------------------------
+       CALL h3cprg(kt)
+
+#elif defined key_trc_pisces
+
+   !! p4zprg: main PROGRAM for PISCES 
+   !! -------------------------------
+       CALL p4zprg(kt)
+#else
+
+    !! SMS to DO
+
+#if defined key_cfc
+
+   !! CFC's code taken from K. Rodgers
+
+   !! This part is still experimental
+   !! -------------------------------
+
+       CALL trcfreons(kt)
+
+#elif defined key_gosac
+
+   !! C14 tracer modeled according to the OCMIP protocol
+   !! This part has not been really tested in this configuration
+
+   !! Compute the alkalinity
+
+          CALL alkal(kt)
+
+   !! Compute the radioactive decay
+
+          CALL decay
+
+   !! Tracers: surface flux
+
+          CALL dicgasflux(kt)
+
+#endif
+
+#endif
+
+#if defined key_trc_age
+
+   !! Age Tracer 
+   
+          CALL trcage(kt)
+#endif
+
+END SUBROUTINE trc_sms
+
+#else
+
+SUBROUTINE trc_sms( kt )
+
+! no passive tracers
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_sms: You should not have seen this print! error?', kt
+END SUBROUTINE trc_sms
+
+#endif 
+
+
+END MODULE  trcsms
