Index: unk/NEMO/TOP_SRC/trcdit.F90
===================================================================
--- /trunk/NEMO/TOP_SRC/trcdit.F90	(revision 1009)
+++ 	(revision )
@@ -1,747 +1,0 @@
-MODULE trcdit
-   !!======================================================================
-   !!                       *** MODULE trcdit ***
-   !! TOP :   Output of passive tracers
-   !! O.Aumont and A.El Moussaoui 03/05 F90 
-   !!======================================================================
-   !! History :    -   !  1995-01 (M. Levy)  Original code
-   !!              -   !  1998-01 (C. Levy) NETCDF format using ioipsl interface
-   !!              -   !  1999-01 (M.A. Foujols) adapted for passive tracer
-   !!              -   !  1999-09 (M.A. Foujols) split into three parts
-   !!             1.0  !  2005-03 (O. Aumont, A. El Moussaoui) F90
-   !!----------------------------------------------------------------------
-#if defined key_top
-   !!----------------------------------------------------------------------
-   !!   'key_top'                                                TOP models
-   !!----------------------------------------------------------------------
-   !! trcdit_wr   :
-   !! trcdid_wr   :
-   !! trcdii_wr   :
-   !! trcdib_wr   : 
-   !!----------------------------------------------------------------------
-   USE oce_trc
-   USE trc
-   USE dianam    ! build name of file (routine)
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp
-   USE ioipsl
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC trcdit_wr      ! caller in trcdia.F90
-   PUBLIC trcdid_wr      ! caller in trcdia.F90
-   PUBLIC trcdii_wr      ! caller in trcdia.F90
-   PUBLIC trcdib_wr      ! caller in trcdia.F90
-
-   INTEGER  ::   nit5      !: id for tracer output file
-   INTEGER  ::   ndepit5   !: id for depth mesh
-   INTEGER  ::   nhorit5   !: id for horizontal mesh
-   INTEGER  ::   ndimt50   !: number of ocean points in index array
-   INTEGER  ::   ndimt51   !: number of ocean points in index array
-   REAL(wp) ::   zjulian   !: ????   not DOCTOR !
-   INTEGER , DIMENSION (jpij*jpk) ::   ndext50   !: integer arrays for ocean 3D index
-   INTEGER , DIMENSION (jpij)     ::   ndext51   !: integer arrays for ocean surface index
-# if defined key_trc_diaadd
-   INTEGER  ::   nitd      !: id for additional array output file
-   INTEGER  ::   ndepitd   !: id for depth mesh
-   INTEGER  ::   nhoritd   !: id for horizontal mesh
-# endif
-# if defined key_trc_diatrd
-   INTEGER , DIMENSION (jptra) ::   nit6      !: id for additional array output file
-   INTEGER , DIMENSION (jptra) ::   ndepit6   !: id for depth mesh
-   INTEGER , DIMENSION (jptra) ::   nhorit6   !: id for horizontal mesh
-# endif
-# if defined key_trc_diabio
-   INTEGER  ::   ndepitb   !:  id for depth mesh
-   INTEGER  ::   nhoritb   !:  id for horizontal mesh
-# endif
-
-   !! * Substitutions
-#  include "top_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
-   !! $Header:$ 
-   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-CONTAINS
-
-      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
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
-      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
-      !!
-      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
-      !!----------------------------------------------------------------------
-
-      ! Initialisation
-      ! --------------
-
-      ! local variable for debugging
-      ll_print = .FALSE.                  ! change it to true for more control print
-      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 - nittrc000 + 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 == nittrc000 ) 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 :', nittrc000                         &
-            &                 ,' 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 , domain_id=nidom)
-! Vertical grid for tracer : gdept
-         CALL histvert( nit5, 'deptht', 'Vertical T levels', &
-            &            'm', ipk, gdept_0, 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
-            IF( lutsav(jn) ) THEN
-               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) 
-            ENDIF
-         END DO
-
-         ! end netcdf files header
-         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
-
-      ! Start writing the 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
-         IF( lutsav(jn) ) THEN
-            cltra = ctrcnm(jn)      ! short title for tracer
-            CALL histwrite( nit5, cltra, it, trn(:,:,:,jn), ndimt50, ndext50 )
-         ENDIF
-      END DO
-
-      ! synchronise file
-      IF( MOD( kt, nwritetrc ) == 0 .OR. kindic < 0 )   CALL histsync( nit5 )
-
-
-      ! close the file 
-      ! --------------
-      IF( kt == nitend .OR. kindic < 0 )   CALL histclo( nit5 )
-      !
-   END SUBROUTINE trcdit_wr
-
-# if defined key_trc_diatrd
-
-   SUBROUTINE trcdid_wr( kt, kindic )
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE trcdid_wr  ***
-      !!
-      !! ** Purpose :   output of passive tracer : advection-diffusion trends
-      !!
-      !! ** 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
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
-      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
-      !!
-      LOGICAL ::   ll_print = .FALSE.
-      CHARACTER (len=40) ::   clhstnam, clop
-      CHARACTER (len=20) ::   cltra, cltrau
-      CHARACTER (len=80) ::   cltral
-      CHARACTER (len=10) ::   csuff
-      INTEGER  ::   jn, jl
-      INTEGER  ::   iimi, iima, ijmi, ijma, ipk, it
-      REAL(wp) ::   zsto, zout, zdt
-      !!----------------------------------------------------------------------
-
-      ! 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 - nittrc000 + 1
-
-      ! Define the NETCDF files (one per tracer)
-      IF( ll_print ) WRITE(numout,*) 'trcdid kt=', kt, ' kindic ', kindic
-      
-      
-      IF( kt == nittrc000 ) 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) , domain_id=nidom )
-
-               ! Vertical grid for tracer trend - one per each tracer IF needed
-               CALL histvert( nit6(jn), 'deptht', 'Vertical T levels',   &
-                  &           'm', ipk, gdept_0, 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 == 1 ) THEN
-                      ! short and long title for x advection for tracer
-                      WRITE (cltra,'("XAD_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("X advective trend for ",58a)')  &
-                         &      ctrcnl(jn)(1:58)
-                  END IF
-                  IF( jl == 2 ) THEN
-                      ! short and long title for y advection for tracer
-                      WRITE (cltra,'("YAD_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("Y advective trend for ",58a)')  &
-                         &      ctrcnl(jn)(1:58)
-                  END IF
-                  IF( jl == 3 ) THEN
-                      ! short and long title for Z advection for tracer
-                      WRITE (cltra,'("ZAD_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("Z advective trend for ",58a)')  &
-                         &      ctrcnl(jn)(1:58)
-                  END IF
-                  IF( jl == 4 ) THEN
-                      ! short and long title for X diffusion for tracer
-                      WRITE (cltra,'("XDF_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("X diffusion trend for ",58a)')  &
-                         &      ctrcnl(jn)(1:58)
-                  END IF
-                  IF( jl == 5 ) THEN
-                      ! short and long title for Y diffusion for tracer
-                      WRITE (cltra,'("YDF_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("Y diffusion trend for ",58a)')  &
-                         &      ctrcnl(jn)(1:58)
-                  END IF
-                  IF( jl == 6 ) THEN
-                      ! short and long title for Z diffusion for tracer
-                      WRITE (cltra,'("ZDF_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("Z diffusion trend for ",58a)')  &
-                         &      ctrcnl(jn)(1:58)
-                  END IF
-# if defined key_trc_ldfeiv
-                  IF( jl == 7 ) THEN
-                      ! short and long title for x gent velocity for tracer
-                      WRITE (cltra,'("XGV_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("X gent velocity trend for ",53a)')  &
-                         &      ctrcnl(jn)(1:53)
-                  END IF
-                  IF( jl == 8 ) THEN
-                      ! short and long title for y gent velocity for tracer
-                      WRITE (cltra,'("YGV_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("Y gent velocity trend for ",53a)')  &
-                         &      ctrcnl(jn)(1:53)
-                  END IF
-                  IF( jl == 9 ) THEN
-                      ! short and long title for Z gent velocity for tracer
-                      WRITE (cltra,'("ZGV_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("Z gent velocity trend for ",53a)')  &
-                         &      ctrcnl(jn)(1:53)
-                  END IF
-# endif
-# if defined key_trcdmp
-                  IF( jl == jpdiatrc - 1 ) THEN
-                      ! last trends for tracer damping : short and long title
-                      WRITE (cltra,'("TDM_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("Tracer damping trend for ",55a)')  &
-                         &      ctrcnl(jn)(1:55)
-                  END IF
-# endif
-                  IF( jl == jpdiatrc ) THEN
-                      ! last trends for tracer damping : short and long title
-                      WRITE (cltra,'("SBC_",16a)') ctrcnm(jn)
-                      WRITE (cltral,'("Surface boundary flux ",58a)')  &
-                      &      ctrcnl(jn)(1:58)
-                  END IF
-
-                  CALL FLUSH( numout )
-                  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
-
-      ! 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
-               ! short titles 
-               IF( jl == 1)   WRITE (cltra,'("XAD_",16a)') ctrcnm(jn)      ! x advection for tracer
-               IF( jl == 2)   WRITE (cltra,'("YAD_",16a)') ctrcnm(jn)      ! z advection for tracer
-               IF( jl == 3)   WRITE (cltra,'("ZAD_",16a)') ctrcnm(jn)      ! z advection for tracer
-               IF( jl == 4)   WRITE (cltra,'("XDF_",16a)') ctrcnm(jn)      ! x diffusion for tracer
-               IF( jl == 5)   WRITE (cltra,'("YDF_",16a)') ctrcnm(jn)      ! y diffusion for tracer
-               IF( jl == 6)   WRITE (cltra,'("ZDF_",16a)') ctrcnm(jn)      ! z diffusion for tracer
-# if defined key_trcldf_eiv
-               IF( jl == 7)   WRITE (cltra,'("XGV_",16a)') ctrcnm(jn)      ! x gent velocity for tracer
-               IF( jl == 8)   WRITE (cltra,'("YGV_",16a)') ctrcnm(jn)      ! y gent velocity for tracer
-               IF( jl == 9)   WRITE (cltra,'("ZGV_",16a)') ctrcnm(jn)      ! z gent velocity for tracer
-# endif
-# if defined key_trcdmp
-               IF( jl == jpdiatrc - 1 )   WRITE (cltra,'("TDM_",16a)') ctrcnm(jn)      ! damping
-# endif
-               IF( jl == jpdiatrc )   WRITE (cltra,'("SBC_",a)') ctrcnm(jn)      ! surface boundary conditions
-               !
-               CALL histwrite(nit6(jn), cltra, it, trtrd(:,:,:,ikeep(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
-            IF (luttrd(jn))   CALL histsync( nit6(jn) )
-         END DO
-      ENDIF
-
-      ! Closing all files
-      ! -----------------
-      IF( kt == nitend .OR. kindic < 0 ) THEN
-         DO jn = 1, jptra
-            IF( luttrd(jn) )   CALL histclo( nit6(jn) )
-         END DO
-      ENDIF
-      !
-   END SUBROUTINE trcdid_wr
-
-# else
-   SUBROUTINE trcdid_wr( kt, kindic )                      ! Dummy routine
-      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_top && 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 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
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
-      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
-      !!
-      LOGICAL ::   ll_print = .FALSE.
-      CHARACTER (len=40) ::   clhstnam, clop
-      CHARACTER (len=20) ::   cltra, cltrau
-      CHARACTER (len=80) ::   cltral
-      INTEGER  ::   jn
-      INTEGER  ::   iimi, iima, ijmi, ijma, ipk, it
-      REAL(wp) ::   zsto, zout, zdt
-      !!----------------------------------------------------------------------
-
-      ! 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=nwritedia*zdt
-      clop='inst(only(x))'
-#  else
-      zsto=zdt
-      clop='ave(only(x))'
-#  endif
-      zout=nwritedia*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 - nittrc000 + 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 == nittrc000 ) 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 , domain_id=nidom )
-
-         ! Vertical grid for 2d and 3d arrays
-
-         CALL histvert( nitd, 'deptht', 'Vertical T levels',   &
-            &           'm', ipk, gdept_0, 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, nwritedia ) == 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, it, trc2d(:,:,jn), ndimt51    &
-            &   ,ndext51)
-      END DO
-
-      ! synchronise FILE
-      IF( MOD( kt, nwritedia ) == 0 .OR. kindic < 0 )   CALL histsync( nitd )
-
-      ! Closing all files
-      ! -----------------
-      IF( kt == nitend .OR. kindic < 0 )   CALL histclo(nitd)
-      !
-END SUBROUTINE trcdii_wr
-
-# else
-   SUBROUTINE trcdii_wr( kt, kindic )                      ! Dummy routine
-      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_trc_diabio
-
-   SUBROUTINE trcdib_wr( kt, kindic )
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE trcdib_wr  ***
-      !!
-      !! ** Purpose :   output of passive tracer : biological 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
-      !!----------------------------------------------------------------------
-      USE sms
-      !!
-      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
-      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
-      !!
-      LOGICAL ::   ll_print = .FALSE.
-      CHARACTER (len=40) ::   clhstnam, clop
-      CHARACTER (len=20) ::   cltra, cltrau
-      CHARACTER (len=80) ::   cltral
-      INTEGER  ::   ji, jj, jk, jn
-      INTEGER  ::   iimi, iima, ijmi, ijma, ipk, it
-      REAL(wp) ::   zsto, zout, zdt
-      !!----------------------------------------------------------------------
-
-      ! 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
-      iimi = 1      ;      iima = jpi
-      ijmi = 1      ;      ijma = jpj
-      ipk = jpk
-
-      ! define time axis
-      it = kt - nittrc000 + 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 == nittrc000 ) 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 , domain_id=nidom)
-         ! Vertical grid for biological trends
-         CALL histvert(nitb, 'deptht', 'Vertical T levels',  &
-            &    'm', ipk, gdept_0, 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 )
-         !
-      ENDIF
-
-      ! 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, it, trbio(:,:,:,jn), ndimt50,ndext50)
-      END DO
-
-      ! synchronise FILE
-      IF( MOD( kt, nwritebio ) == 0 .OR. kindic < 0 )   CALL histsync( nitb )
-
-      ! Closing all files
-      ! -----------------
-      IF( kt == nitend .OR. kindic < 0 )   CALL histclo( nitb )
-      !
-   END SUBROUTINE trcdib_wr
-
-# else
-   SUBROUTINE trcdib_wr( kt, kindic )                      ! Dummy routine
-      INTEGER, INTENT ( in ) ::   kt, kindic
-      WRITE(*,*) 'trcdib_wr: You should not have seen this print! error?', kt, kindic
-   END SUBROUTINE trcdib_wr
-# endif 
-
-#else
-   !!----------------------------------------------------------------------
-   !!  Dummy module :                                     No passive tracer
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE trcdit_wr( kt, kindic )                      ! Dummy routine
-      INTEGER, INTENT ( in ) ::   kt, kindic
-      WRITE(*,*) 'trcdit_wr: You should not have seen this print! error?', kt, kindic
-   END SUBROUTINE trcdit_wr
-   SUBROUTINE trcdid_wr( kt, kindic )                      ! Dummy routine
-      INTEGER, INTENT ( in ) ::   kt, kindic
-      WRITE(*,*) 'trcdid_wr: You should not have seen this print! error?', kt, kindic
-   END SUBROUTINE trcdid_wr
-   SUBROUTINE trcdii_wr( kt, kindic )                      ! Dummy routine
-      INTEGER, INTENT ( in ) :: kt, kindic
-      WRITE(*,*) 'trcdii_wr: You should not have seen this print! error?', kt, kindic
-   END SUBROUTINE trcdii_wr
-   SUBROUTINE trcdib_wr( kt, kindic )                      ! Dummy routine
-      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
