Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90	(revision 5266)
@@ -12,5 +12,5 @@
    !!                  !  2011-02  (J. Simeon, J.Orr ) update O2 solubility constants
    !!----------------------------------------------------------------------
-#if defined key_pisces
+#if defined key_pisces || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                       PISCES bio-model
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zfechem.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zfechem.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zfechem.F90	(revision 5266)
@@ -6,5 +6,5 @@
    !! History :   3.5  !  2012-07 (O. Aumont, A. Tagliabue, C. Ethe) Original code
    !!----------------------------------------------------------------------
-#if defined key_pisces
+#if defined key_pisces || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_top'       and                                      TOP models
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90	(revision 5266)
@@ -11,5 +11,5 @@
    !!                  !  2011-02  (J. Simeon, J. Orr) Include total atm P correction 
    !!----------------------------------------------------------------------
-#if defined key_pisces
+#if defined key_pisces || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                       PISCES bio-model
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zint.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zint.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zint.F90	(revision 5266)
@@ -7,5 +7,5 @@
    !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
    !!----------------------------------------------------------------------
-#if defined key_pisces
+#if defined key_pisces || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                       PISCES bio-model
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90	(revision 5266)
@@ -12,5 +12,5 @@
    !!             3.4  !  2011-06  (O. Aumont, C. Ethe) Improvment of calcite dissolution
    !!----------------------------------------------------------------------
-#if defined key_pisces
+#if defined key_pisces || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                       PISCES bio-model
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90	(revision 5266)
@@ -9,5 +9,5 @@
    !!             3.4  !  2011-06  (O. Aumont, C. Ethe) Improve light availability of nano & diat
    !!----------------------------------------------------------------------
-#if defined  key_pisces
+#if defined  key_pisces || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                       PISCES bio-model
@@ -41,5 +41,8 @@
    REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:) :: par_varsw    !: PAR fraction of shortwave
 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: enano, ediat   !: PAR for phyto, nano and diat 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: enano, ediat   !: PAR for nano and diat 
+#if defined key_pisces_quota
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: epico          !: PAR for pico
+#endif
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: emoy           !: averaged PAR in the mixed layer
 
@@ -74,4 +77,7 @@
       REAL(wp) ::   zc0 , zc1 , zc2, zc3, z1_dep
       REAL(wp), POINTER, DIMENSION(:,:  ) :: zdepmoy, zetmp, zetmp1, zetmp2
+#if defined key_pisces_quota
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zetmp3
+#endif
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zekg, zekr, zekb, ze0, ze1, ze2, ze3
       !!---------------------------------------------------------------------
@@ -82,4 +88,7 @@
       CALL wrk_alloc( jpi, jpj,      zdepmoy, zetmp, zetmp1, zetmp2 ) 
       CALL wrk_alloc( jpi, jpj, jpk, zekg, zekr, zekb, ze0, ze1, ze2, ze3 )
+#if defined key_pisces_quota
+      CALL wrk_alloc( jpi, jpj,      zetmp3 )
+#endif
 
       IF( jnt == 1 .AND. ln_varpar ) CALL p4z_optsbc( kt )
@@ -97,5 +106,9 @@
 !CDIR NOVERRCHK
             DO ji = 1, jpi
+#if defined key_pisces_quota
+               zchl = ( trn(ji,jj,jk,jpnch) + trn(ji,jj,jk,jpdch) + trn(ji,jj,jk,jppch) + rtrn ) * 1.e6
+#else
                zchl = ( trn(ji,jj,jk,jpnch) + trn(ji,jj,jk,jpdch) + rtrn ) * 1.e6
+#endif
                zchl = MIN(  10. , MAX( 0.05, zchl )  )
                irgb = NINT( 41 + 20.* LOG10( zchl ) + rtrn )
@@ -132,4 +145,7 @@
             enano(ji,jj,1) = ( 2.1 * zc1 + 0.42 * zc2 + 0.4 * zc3 )
             ediat(ji,jj,1) = ( 1.6 * zc1 + 0.69 * zc2 + 0.7 * zc3 )
+#if defined key_pisces_quota
+            epico(ji,jj,1) = ( 2.1 * zc1 + 0.42 * zc2 + 0.4 * zc3 )
+#endif
          END DO
       END DO
@@ -150,8 +166,11 @@
                enano(ji,jj,jk) = ( 2.1 * zc1 + 0.42 * zc2 + 0.4 * zc3 )
                ediat(ji,jj,jk) = ( 1.6 * zc1 + 0.69 * zc2 + 0.7 * zc3 )
+#if defined key_pisces_quota
+               epico(ji,jj,jk) = ( 2.1 * zc1 + 0.42 * zc2 + 0.4 * zc3 )
+#endif
             END DO
          END DO
       END DO
-
+ 
       IF( ln_qsr_bio ) THEN                    !* heat flux accros w-level (used in the dynamics)
          !                                     !  ------------------------
@@ -219,4 +238,7 @@
       zetmp1 (:,:)   = 0.e0
       zetmp2 (:,:)   = 0.e0
+#if defined key_pisces_quota
+      zetmp3 (:,:)   = 0.e0
+#endif
 
       DO jk = 1, nksrp
@@ -229,4 +251,7 @@
                   zetmp1 (ji,jj) = zetmp1 (ji,jj) + enano(ji,jj,jk) * fse3t(ji,jj,jk)
                   zetmp2 (ji,jj) = zetmp2 (ji,jj) + ediat(ji,jj,jk) * fse3t(ji,jj,jk)
+#if defined key_pisces_quota
+                  zetmp3 (ji,jj) = zetmp3 (ji,jj) + epico(ji,jj,jk) * fse3t(ji,jj,jk)
+#endif
                   zdepmoy(ji,jj) = zdepmoy(ji,jj) + fse3t(ji,jj,jk)
                ENDIF
@@ -247,4 +272,7 @@
                   enano(ji,jj,jk) = zetmp1(ji,jj) * z1_dep
                   ediat(ji,jj,jk) = zetmp2(ji,jj) * z1_dep
+#if defined key_pisces_quota
+                  epico(ji,jj,jk) = zetmp3(ji,jj) * z1_dep
+#endif
                ENDIF
             END DO
@@ -268,4 +296,7 @@
       CALL wrk_dealloc( jpi, jpj,      zdepmoy, zetmp, zetmp1, zetmp2 )
       CALL wrk_dealloc( jpi, jpj, jpk, zekg, zekr, zekb, ze0, ze1, ze2, ze3 )
+#if defined key_pisces_quota
+      CALL wrk_dealloc( jpi, jpj,      zetmp3 )
+#endif
       !
       IF( nn_timing == 1 )  CALL timing_stop('p4z_opt')
@@ -376,4 +407,7 @@
                          etot (:,:,:) = 0._wp
                          enano(:,:,:) = 0._wp
+#if defined key_pisces_quota
+                         epico(:,:,:) = 0._wp
+#endif
                          ediat(:,:,:) = 0._wp
       IF( ln_qsr_bio )   etot3(:,:,:) = 0._wp
@@ -388,5 +422,11 @@
       !!                     ***  ROUTINE p4z_opt_alloc  ***
       !!----------------------------------------------------------------------
-      ALLOCATE( enano(jpi,jpj,jpk), ediat(jpi,jpj,jpk), emoy (jpi,jpj,jpk), STAT=p4z_opt_alloc ) 
+#if defined key_pisces_quota
+     ALLOCATE( enano(jpi,jpj,jpk), ediat(jpi,jpj,jpk), emoy (jpi,jpj,jpk), epico(jpi,jpj,jpk),   &
+      &         STAT=p4z_opt_alloc )
+#else
+      ALLOCATE( enano(jpi,jpj,jpk), ediat(jpi,jpj,jpk), emoy (jpi,jpj,jpk),   &
+      &         STAT=p4z_opt_alloc ) 
+#endif
          !
       IF( p4z_opt_alloc /= 0 ) CALL ctl_warn('p4z_opt_alloc : failed to allocate arrays.')
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90	(revision 5266)
@@ -6,5 +6,5 @@
    !! History :   3.5  !  2012-07 (O. Aumont, C. Ethe) Original code
    !!----------------------------------------------------------------------
-#if defined key_pisces
+#if defined key_pisces || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                       PISCES bio-model
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zbio.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zbio.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zbio.F90	(revision 5266)
@@ -0,0 +1,162 @@
+MODULE p5zbio
+   !!======================================================================
+   !!                         ***  MODULE p5zbio  ***
+   !! TOP :   PISCES bio-model
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_pisces_quota'     PISCES bio-model with variable stoichiometry
+   !!----------------------------------------------------------------------
+   !!   p5z_bio        :   computes the interactions between the different
+   !!                      compartments of PISCES
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE p5zsink         !  vertical flux of particulate matter due to sinking
+   USE p4zopt          !  optical model
+   USE p5zlim          !  Co-limitations of differents nutrients
+   USE p5zprod         !  Growth rate of the 2 phyto groups
+   USE p5zmort         !  Mortality terms for phytoplankton
+   USE p5zmicro        !  Sources and sinks of microzooplankton
+   USE p5zmeso         !  Sources and sinks of mesozooplankton
+   USE p5zrem          !  Remineralisation of organic matter
+   USE p4zfechem
+   USE prtctl_trc      !  print control for debugging
+   USE iom             !  I/O manager
+  
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC  p5z_bio    
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zbio.F90 3160 2011-11-20 14:27:18Z cetlod $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p5z_bio ( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_bio  ***
+      !!
+      !! ** Purpose :   Ecosystem model in the whole ocean: computes the
+      !!              different interactions between the different compartments
+      !!              of PISCES
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt, jnt
+      INTEGER  ::  ji, jj, jk, jn
+      REAL(wp) ::  ztra
+#if defined key_kriest
+      REAL(wp) ::  zcoef1, zcoef2
+#endif
+      CHARACTER (len=25) :: charout
+
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_bio')
+      !
+      !     ASSIGN THE SHEAR RATE THAT IS USED FOR AGGREGATION
+      !     OF PHYTOPLANKTON AND DETRITUS
+
+      xdiss(:,:,:) = 1.
+!!gm the use of nmld should be better here?
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( fsdepw(ji,jj,jk+1) > hmld(ji,jj) )   xdiss(ji,jj,jk) = 0.01
+            END DO 
+         END DO
+      END DO
+
+      CALL p4z_opt  ( kt, jnt )     ! Optic: PAR in the water column
+      CALL p5z_sink ( kt, jnt )     ! vertical flux of particulate organic matter
+      DO jk = 1, jpk
+        DO jj = 1, jpj
+          DO ji = 1, jpi
+            IF (mig(ji) == 72 .and. mjg(jj) == 74 .and. jk == 5) THEN
+            DO jn = 1, jptra
+            write(0,*) 'plante ',trn(ji,jj,jk,jn)*1E6
+            END DO
+            ENDIF
+          END DO
+        END DO
+      END DO
+      CALL p4z_fechem(kt, jnt )     ! Iron chemistry/scavenging
+      CALL p5z_lim  ( kt, jnt )     ! co-limitations by the various nutrients
+      CALL p5z_prod ( kt, jnt )     ! phytoplankton growth rate over the global ocean. 
+      !                             ! (for each element : C, Si, Fe, Chl )
+      CALL p5z_mort ( kt      )     ! phytoplankton mortality
+      !                             ! zooplankton sources/sinks routines 
+      CALL p5z_micro( kt, jnt )           ! microzooplankton
+      CALL p5z_meso ( kt, jnt )           ! mesozooplankton
+      CALL p5z_rem  ( kt, jnt )     ! remineralization terms of organic matter+scavenging of Fe
+      !                             ! test if tracers concentrations fall below 0.
+      xnegtr(:,:,:) = 1.e0
+      DO jn = jp_pcs0, jp_pcs1
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( ( trn(ji,jj,jk,jn) + tra(ji,jj,jk,jn) ) < 0.e0 ) THEN
+                     ztra             = ABS( trn(ji,jj,jk,jn) ) / ( ABS( tra(ji,jj,jk,jn) ) + rtrn )
+
+                     xnegtr(ji,jj,jk) = MIN( xnegtr(ji,jj,jk),  ztra )
+                  ENDIF
+              END DO
+            END DO
+         END DO
+      END DO
+      !                                ! where at least 1 tracer concentration becomes negative
+      !                                ! 
+      DO jn = jp_pcs0, jp_pcs1
+         trn(:,:,:,jn) = trn(:,:,:,jn) + xnegtr(:,:,:) * tra(:,:,:,jn) * tmask(:,:,:)
+      END DO
+
+      DO jn = jp_pcs0, jp_pcs1
+        CALL lbc_lnk( trn(:,:,:,jn), 'T', 1. )
+      END DO
+
+      tra(:,:,:,:) = 0.e0
+
+#if defined key_kriest
+      ! 
+      zcoef1 = 1.e0 / xkr_massp 
+      zcoef2 = 1.e0 / xkr_massp / 1.1
+      DO jk = 1,jpkm1
+         trn(:,:,jk,jpnum) = MAX(  trn(:,:,jk,jpnum), trn(:,:,jk,jppoc) * zcoef1 / xnumm(jk)  )
+         trn(:,:,jk,jpnum) = MIN(  trn(:,:,jk,jpnum), trn(:,:,jk,jppoc) * zcoef2              )
+      END DO
+#endif
+
+      !
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('bio ')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_bio')
+      !
+   END SUBROUTINE p5z_bio
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_bio                         ! Empty routine
+   END SUBROUTINE p5z_bio
+#endif 
+
+   !!======================================================================
+END MODULE  p5zbio
+
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zlim.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zlim.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zlim.F90	(revision 5266)
@@ -0,0 +1,494 @@
+MODULE p5zlim
+   !!======================================================================
+   !!                         ***  MODULE p5zlim  ***
+   !! TOP :   PISCES with variable stoichiometry 
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!             3.4  !  2011-04  (O. Aumont, C. Ethe) Limitation for iron modelled in quota 
+   !!             3.6  !  2015-04  (O. Aumont) variable stoichiometry
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_pisces_quota'            PISCES bio-model with variable stoichiometry
+   !!----------------------------------------------------------------------
+   !!   p5z_lim        :   Compute the nutrients limitation terms 
+   !!   p5z_lim_init   :   Read the namelist 
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Shared ocean-passive tracers variables
+   USE trc             ! Tracers defined
+   USE sms_pisces      ! PISCES variables
+   USE p4zopt          ! Optical
+   USE iom             !  I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC p5z_lim    
+   PUBLIC p5z_lim_init    
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::  concnno3    !:  NO3, PO4 half saturation   
+   REAL(wp), PUBLIC ::  concpno3    !:  NO3, PO4 half saturation   
+   REAL(wp), PUBLIC ::  concdno3    !:  Phosphate half saturation for diatoms  
+   REAL(wp), PUBLIC ::  concnnh4    !:  NH4 half saturation for phyto  
+   REAL(wp), PUBLIC ::  concpnh4    !:  NH4 half saturation for phyto  
+   REAL(wp), PUBLIC ::  concdnh4    !:  NH4 half saturation for diatoms
+   REAL(wp), PUBLIC ::  concnpo4    !:  NH4 half saturation for diatoms
+   REAL(wp), PUBLIC ::  concppo4    !:  NH4 half saturation for diatoms
+   REAL(wp), PUBLIC ::  concdpo4    !:  NH4 half saturation for diatoms
+   REAL(wp), PUBLIC ::  concnfer    !:  Iron half saturation for nanophyto 
+   REAL(wp), PUBLIC ::  concpfer    !:  Iron half saturation for nanophyto 
+   REAL(wp), PUBLIC ::  concdfer    !:  Iron half saturation for diatoms  
+   REAL(wp), PUBLIC ::  concbno3    !:  NO3 half saturation  for bacteria 
+   REAL(wp), PUBLIC ::  concbnh4    !:  NH4 half saturation for bacteria
+   REAL(wp), PUBLIC ::  concbpo4    !:  PO4 half saturation for bacteria
+   REAL(wp), PUBLIC ::  xsizedia    !:  Minimum size criteria for diatoms
+   REAL(wp), PUBLIC ::  xsizepic    !:  Minimum size criteria for diatoms
+   REAL(wp), PUBLIC ::  xsizephy    !:  Minimum size criteria for nanophyto
+   REAL(wp), PUBLIC ::  xsizern     !:  Size ratio for nanophytoplankton
+   REAL(wp), PUBLIC ::  xsizerp     !:  Size ratio for nanophytoplankton
+   REAL(wp), PUBLIC ::  xsizerd     !:  Size ratio for diatoms
+   REAL(wp), PUBLIC ::  xksi1       !:  half saturation constant for Si uptake 
+   REAL(wp), PUBLIC ::  xksi2       !:  half saturation constant for Si/C 
+   REAL(wp), PUBLIC ::  xkdoc       !:  2nd half-sat. of DOC remineralization  
+   REAL(wp), PUBLIC ::  concbfe     !:  Fe half saturation for bacteria 
+   REAL(wp), PUBLIC ::  qfnopt      !:  optimal Fe quota for nanophyto
+   REAL(wp), PUBLIC ::  qfpopt      !:  optimal Fe quota for nanophyto
+   REAL(wp), PUBLIC ::  qfdopt      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  caco3r      !:  mean rainratio 
+   REAL(wp), PUBLIC ::  qnnmin      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qnnmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qpnmin      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qpnmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qnpmin      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qnpmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qppmin      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qppmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qndmin      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qndmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qpdmin      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qpdmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qfnmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qfpmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  qfdmax      !:  optimal Fe quota for diatoms
+   REAL(wp), PUBLIC ::  zpsinh4
+   REAL(wp), PUBLIC ::  zpsino3
+   REAL(wp), PUBLIC ::  zpsiuptk
+
+   ! Coefficient for iron limitation
+   REAL(wp) ::  xcoef1   = 0.00167  / 55.85
+   REAL(wp) ::  xcoef2   = 1.21E-5 * 14. / 55.85 / 7.625 * 0.5 * 1.5
+   REAL(wp) ::  xcoef3   = 1.15E-4 * 14. / 55.85 / 7.625 * 0.5 
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zlim.F90 3160 2011-11-20 14:27:18Z cetlod $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p5z_lim( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_lim  ***
+      !!
+      !! ** Purpose :   Compute the co-limitations by the various nutrients
+      !!              for the various phytoplankton species
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      !
+      INTEGER, INTENT(in)  :: kt, jnt
+      !
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zlim1, zlim2, zlim3, zlim4, zno3, zferlim
+      REAL(wp) ::   z1_trndia, z1_trnpic, z1_trnphy, ztem1, ztem2, zetot1
+      REAL(wp) ::   zratio, zration, zratiof, znutlim, zfalim
+      REAL(wp) ::   zconc1d, zconc1dnh4, zconc0n, zconc0nnh4, zconc0npo4, zconc0dpo4
+      REAL(wp) ::   zconc0p, zconc0pnh4, zconc0ppo4, zconcpfe, zconcnfe, zconcdfe
+      REAL(wp) ::   fanano, fananop, fananof, fadiat, fadiatp, fadiatf
+      REAL(wp) ::   fapico, fapicop, fapicof
+      REAL(wp) ::   zrpho, zrass, zcoef, zfuptk, zratchl
+      REAL(wp) ::   zfvn, zfvp, zfvf, zsizen, zsizep, zsized, znanochl, zpicochl, zdiatchl
+      REAL(wp) ::   zqfemn, zqfemp, zqfemd, zbactno3, zbactnh4
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_lim')
+      !
+      zratchl = 6.0
+      !
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ! 
+               ! Tuning of the iron concentration to a minimum level that is set to the detection limit
+               !-------------------------------------
+               zno3    = trn(ji,jj,jk,jpno3) / 40.e-6
+               zferlim = MAX( 3e-11 * zno3 * zno3, 5e-12 )
+               zferlim = MIN( zferlim, 7e-11 )
+               trn(ji,jj,jk,jpfer) = MAX( trn(ji,jj,jk,jpfer), zferlim )
+
+               ! Computation of the mean relative size of each community
+               ! -------------------------------------------------------
+               z1_trnphy   = 1. / ( trn(ji,jj,jk,jpphy) + rtrn )
+               z1_trnpic   = 1. / ( trn(ji,jj,jk,jppic) + rtrn )
+               z1_trndia   = 1. / ( trn(ji,jj,jk,jpdia) + rtrn )
+               znanochl = trn(ji,jj,jk,jpnch) * z1_trnphy
+               zpicochl = trn(ji,jj,jk,jppch) * z1_trnpic
+               zdiatchl = trn(ji,jj,jk,jpdch) * z1_trndia
+
+               ! Computation of a variable Ks for iron on diatoms taking into account
+               ! that increasing biomass is made of generally bigger cells
+               !------------------------------------------------
+               zsized            = sized(ji,jj,jk)**0.81
+               zconcdfe          = concdfer * zsized
+               zconc1d           = concdno3 * zsized
+               zconc1dnh4        = concdnh4 * zsized
+               zconc0dpo4        = concdpo4 * zsized
+
+               zsizep            = 1.
+               zconcpfe          = concpfer * zsizep
+               zconc0p           = concpno3 * zsizep
+               zconc0pnh4        = concpnh4 * zsizep
+               zconc0ppo4        = concppo4 * zsizep
+
+               zsizen            = 1.
+               zconcnfe          = concnfer * zsizen
+               zconc0n           = concnno3 * zsizen
+               zconc0nnh4        = concnnh4 * zsizen
+               zconc0npo4        = concnpo4 * zsizen
+
+               ! Allometric variations of the minimum and maximum quotas
+               ! From Talmy et al. (2014) and Maranon et al. (2013)
+               ! -------------------------------------------------------
+               xqnnmin(ji,jj,jk) = qnnmin
+               xqnnmax(ji,jj,jk) = qnnmax
+               xqndmin(ji,jj,jk) = qndmin * sized(ji,jj,jk)**(-0.27) 
+               xqndmax(ji,jj,jk) = qndmax
+               xqnpmin(ji,jj,jk) = qnpmin
+               xqnpmax(ji,jj,jk) = qnpmax
+
+               ! Computation of the optimal allocation parameters
+               ! Based on the different papers by Pahlow et al., and Smith et al.
+               ! -----------------------------------------------------------------
+               znutlim = MAX( trn(ji,jj,jk,jpnh4) / zconc0nnh4,    &
+                 &         trn(ji,jj,jk,jpno3) / zconc0n)
+               fanano = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               znutlim = trn(ji,jj,jk,jppo4) / zconc0npo4
+               fananop = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               znutlim = biron(ji,jj,jk) / zconcnfe
+               fananof = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               znutlim = MAX( trn(ji,jj,jk,jpnh4) / zconc0pnh4,    &
+                 &         trn(ji,jj,jk,jpno3) / zconc0p)
+               fapico = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               znutlim = trn(ji,jj,jk,jppo4) / zconc0ppo4
+               fapicop = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               znutlim = biron(ji,jj,jk) / zconcpfe
+               fapicof = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               znutlim = MAX( trn(ji,jj,jk,jpnh4) / zconc1dnh4,    &
+                 &         trn(ji,jj,jk,jpno3) / zconc1d )
+               fadiat = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               znutlim = trn(ji,jj,jk,jppo4) / zconc0dpo4
+               fadiatp = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               znutlim = biron(ji,jj,jk) / zconcdfe
+               fadiatf = MAX(0.01, MIN(0.99, 1. / ( SQRT(znutlim) + 1.) ) )
+               !
+               ! Michaelis-Menten Limitation term for nutrients Small bacteria
+               ! -------------------------------------------------------------
+               zbactnh4 = trn(ji,jj,jk,jpnh4) / ( concbnh4 + trn(ji,jj,jk,jpnh4) )
+               zbactno3 = trn(ji,jj,jk,jpno3) / ( concbno3 + trn(ji,jj,jk,jpno3) ) * (1. - zbactnh4)
+               !
+               zlim1    = zbactno3 + zbactnh4
+               zlim2    = trn(ji,jj,jk,jppo4) / ( trn(ji,jj,jk,jppo4) + concbpo4)
+               zlim3    = biron(ji,jj,jk) / ( concbfe + biron(ji,jj,jk) )
+               zlim4    = trn(ji,jj,jk,jpdoc) / ( xkdoc   + trn(ji,jj,jk,jpdoc) )
+               xlimbacl(ji,jj,jk) = MIN( zlim1, zlim2, zlim3 )
+               xlimbac (ji,jj,jk) = xlimbacl(ji,jj,jk) * zlim4
+               !
+               ! Michaelis-Menten Limitation term for nutrients Small flagellates
+               ! -----------------------------------------------
+               zfalim = (1.-fanano) / fanano
+               xnanonh4(ji,jj,jk) = (1. - fanano) * trn(ji,jj,jk,jpnh4) / ( zfalim * zconc0nnh4 + trn(ji,jj,jk,jpnh4) )
+               xnanono3(ji,jj,jk) = (1. - fanano) * trn(ji,jj,jk,jpno3) / ( zfalim * zconc0n + trn(ji,jj,jk,jpno3) )  &
+               &                    * (1. - xnanonh4(ji,jj,jk))
+               !
+               zfalim = (1.-fananop) / fananop
+               xnanopo4(ji,jj,jk) = (1. - fananop) * trn(ji,jj,jk,jppo4) / ( trn(ji,jj,jk,jppo4) + zfalim * zconc0npo4 )
+               xnanodop(ji,jj,jk) = trn(ji,jj,jk,jpdop) / ( trn(ji,jj,jk,jpdop) + xkdoc )   &
+               &                    * ( 1.0 - xnanopo4(ji,jj,jk) )
+               !
+               zfalim = (1.-fananof) / fananof
+               xnanofer(ji,jj,jk) = (1. - fananof) * biron(ji,jj,jk) / ( biron(ji,jj,jk) + zfalim * zconcnfe )
+               !
+               zratiof   = trn(ji,jj,jk,jpnfe) * z1_trnphy
+               zqfemn = xcoef1 * znanochl + xcoef2 + xcoef3 * xnanono3(ji,jj,jk)
+               !
+               zration = trn(ji,jj,jk,jpnph) * z1_trnphy
+               fvnuptk(ji,jj,jk) = 1. / zpsiuptk * rno3 * 2. * xqnnmin(ji,jj,jk) / (zration + rtrn)  &
+               &                   * MAX(0., (1. - zratchl * znanochl / 12. ) )
+               !
+               zlim1    = max(0., (zration - 2. * xqnnmin(ji,jj,jk) )  &
+               &          / (xqnnmax(ji,jj,jk) - 2. * xqnnmin(ji,jj,jk) ) ) * xqnnmax(ji,jj,jk)  &
+               &          / (zration + rtrn)
+               zlim3    = MAX( 0.,( zratiof - zqfemn ) / qfnopt ) 
+               xlimnfe(ji,jj,jk) = MIN( 1., zlim3 )
+               xlimphy(ji,jj,jk) = MIN( 1., zlim1, zlim3 )
+               !
+               ! Michaelis-Menten Limitation term for nutrients picophytoplankton
+               ! ----------------------------------------------------------------
+               zfalim = (1.-fapico) / fapico 
+               xpiconh4(ji,jj,jk) = (1. - fapico) * trn(ji,jj,jk,jpnh4) / ( zfalim * zconc0pnh4 + trn(ji,jj,jk,jpnh4) )
+               xpicono3(ji,jj,jk) = (1. - fapico) * trn(ji,jj,jk,jpno3) / ( zfalim * zconc0p + trn(ji,jj,jk,jpno3) )  &
+               &                    * (1. - xpiconh4(ji,jj,jk))
+               !
+               zfalim = (1.-fapicop) / fapicop 
+               xpicopo4(ji,jj,jk) = (1. - fapicop) * trn(ji,jj,jk,jppo4) / ( trn(ji,jj,jk,jppo4) + zfalim * zconc0ppo4 )
+               xpicodop(ji,jj,jk) = trn(ji,jj,jk,jpdop) / ( trn(ji,jj,jk,jpdop) + xkdoc )   &
+               &                    * ( 1.0 - xpicopo4(ji,jj,jk) )
+               !
+               zfalim = (1.-fapicof) / fapicof
+               xpicofer(ji,jj,jk) = (1. - fapicof) * biron(ji,jj,jk) / ( biron(ji,jj,jk) + zfalim * zconcpfe )
+               !
+               zratiof   = trn(ji,jj,jk,jppfe) * z1_trnpic
+               zqfemp = xcoef1 * zpicochl + xcoef2 + xcoef3 * xpicono3(ji,jj,jk)
+               !
+               zration   = trn(ji,jj,jk,jpnpi) * z1_trnpic
+               fvpuptk(ji,jj,jk) = 1. / zpsiuptk * rno3 * 2. * xqnpmin(ji,jj,jk) / (zration + rtrn)  &
+               &                   * MAX(0., (1. - zratchl * zpicochl / 12. ) ) 
+               !
+               zlim1    = max(0., (zration - 2. * xqnpmin(ji,jj,jk) )  &
+               &          / (xqnpmax(ji,jj,jk) - 2. * xqnpmin(ji,jj,jk) ) ) * xqnpmax(ji,jj,jk)  &
+               &          / (zration + rtrn)
+               zlim3    = MAX( 0.,( zratiof - zqfemp ) / qfpopt )
+               xlimpfe(ji,jj,jk) = MIN( 1., zlim3 )
+               xlimpic(ji,jj,jk) = MIN( 1., zlim1, zlim3 )
+               !
+               !   Michaelis-Menten Limitation term for nutrients Diatoms
+               !   ------------------------------------------------------
+               zfalim = (1.-fadiat) / fadiat 
+               xdiatnh4(ji,jj,jk) = (1. - fadiat) * trn(ji,jj,jk,jpnh4) / ( zfalim * zconc1dnh4 + trn(ji,jj,jk,jpnh4) )
+               xdiatno3(ji,jj,jk) = (1. - fadiat) * trn(ji,jj,jk,jpno3) / ( zfalim * zconc1d + trn(ji,jj,jk,jpno3) )  &
+               &                    * (1. - xdiatnh4(ji,jj,jk))
+               !
+               zfalim = (1.-fadiatp) / fadiatp
+               xdiatpo4(ji,jj,jk) = (1. - fadiatp) * trn(ji,jj,jk,jppo4) / ( trn(ji,jj,jk,jppo4) + zfalim * zconc0dpo4 )
+               xdiatdop(ji,jj,jk) = trn(ji,jj,jk,jpdop) / ( trn(ji,jj,jk,jpdop) + xkdoc )  &
+               &                    * ( 1.0 - xdiatpo4(ji,jj,jk) )
+               !
+               zfalim = (1.-fadiatf) / fadiatf
+               xdiatfer(ji,jj,jk) = (1. - fadiatf) * biron(ji,jj,jk) / ( biron(ji,jj,jk) + zfalim * zconcdfe )
+               !
+               zratiof   = trn(ji,jj,jk,jpdfe) * z1_trndia
+               zqfemd = xcoef1 * zdiatchl + xcoef2 + xcoef3 * xdiatno3(ji,jj,jk)
+               !
+               zration   = trn(ji,jj,jk,jpndi) * z1_trndia
+               fvduptk(ji,jj,jk) = 1. / zpsiuptk * rno3 * 2. * xqndmin(ji,jj,jk) / (zration + rtrn)   &
+               &                   * MAX(0., (1. - zratchl * zdiatchl / 12. ) ) 
+               !
+               zlim1    = max(0., (zration - 2. * xqndmin(ji,jj,jk) )    &
+               &          / (xqndmax(ji,jj,jk) - 2. * xqndmin(ji,jj,jk) ) )   &
+               &          * xqndmax(ji,jj,jk) / (zration + rtrn)
+               zlim3    = trn(ji,jj,jk,jpsil) / ( trn(ji,jj,jk,jpsil) + xksi(ji,jj) )
+               zlim4    = MAX( 0., ( zratiof - zqfemd ) / qfdopt )
+               xlimdfe(ji,jj,jk) = MIN( 1., zlim4 )
+               xlimdia(ji,jj,jk) = MIN( 1., zlim1, zlim3, zlim4 )
+               xlimsi(ji,jj,jk)  = MIN( zlim1, zlim4 )
+            END DO
+         END DO
+      END DO
+      !
+      ! Compute the phosphorus quota values. It is based on Litchmann et al., 2004 and Daines et al, 2013.
+      ! The relative contribution of three fonctional pools are computed: light harvesting apparatus, 
+      ! nutrient uptake pool and assembly machinery. DNA is assumed to represent 1% of the dry mass of 
+      ! phytoplankton (see Daines et al., 2013). 
+      ! --------------------------------------------------------------------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ! Size estimation of nanophytoplankton
+               ! ------------------------------------
+               zfvn = 2. * fvnuptk(ji,jj,jk)
+               sizen(ji,jj,jk) = MAX(1., MIN(xsizern, 1.0 / ( MAX(rtrn, zfvn) ) ) )
+
+               ! N/P ratio of nanophytoplankton
+               ! ------------------------------
+               zfuptk = 0.23 * zfvn
+               zrpho = 2.24 * trn(ji,jj,jk,jpnch) / ( trn(ji,jj,jk,jpnph) * rno3 * 15. + rtrn )
+               zrass = 1. - 0.2 - zrpho - zfuptk
+               xqpnmax(ji,jj,jk) = ( zfuptk + zrpho ) * 0.0128 * 16. + zrass * 1./ 7.2 * 16.
+               xqpnmax(ji,jj,jk) = xqpnmax(ji,jj,jk) * trn(ji,jj,jk,jpnph) / ( trn(ji,jj,jk,jpphy) + rtrn ) + 0.13
+               xqpnmin(ji,jj,jk) = 0.13 + 0.23 * 0.0128 * 16.
+
+               ! Size estimation of picophytoplankton
+               ! ------------------------------------
+               zfvn = 2. * fvpuptk(ji,jj,jk)
+               sizep(ji,jj,jk) = MAX(1., MIN(xsizerp, 1.0 / ( MAX(rtrn, zfvn) ) ) )
+
+               ! N/P ratio of picophytoplankton
+               ! ------------------------------
+               zfuptk = 0.35 * zfvn
+               zrpho = 2.24 * trn(ji,jj,jk,jppch) / ( trn(ji,jj,jk,jpnpi) * rno3 * 15. + rtrn )
+               zrass = 1. - 0.4 - zrpho - zfuptk
+               xqppmax(ji,jj,jk) =  (zrpho + zfuptk) * 0.0128 * 16. + zrass * 1./ 9. * 16.
+               xqppmax(ji,jj,jk) = xqppmax(ji,jj,jk) * trn(ji,jj,jk,jpnpi) / ( trn(ji,jj,jk,jppic) + rtrn ) + 0.13
+               xqppmin(ji,jj,jk) = 0.13
+
+               ! Size estimation of diatoms
+               ! --------------------------
+               zfvn = 2. * fvduptk(ji,jj,jk)
+               sized(ji,jj,jk) = MAX(1., MIN(xsizerd, 1.0 / ( MAX(rtrn, zfvn) ) ) )
+               zcoef = trn(ji,jj,jk,jpdia) - MIN(xsizedia, trn(ji,jj,jk,jpdia) )
+               sized(ji,jj,jk) = 1. + xsizerd * zcoef *1E6 / ( 1. + zcoef * 1E6 )
+
+               ! N/P ratio of diatoms
+               ! --------------------
+               zfuptk = 0.2 * zfvn
+               zrpho = 2.24 * trn(ji,jj,jk,jpdch) / ( trn(ji,jj,jk,jpndi) * rno3 * 15. + rtrn )
+               zrass = 1. - 0.2 - zrpho - zfuptk
+               xqpdmax(ji,jj,jk) = ( zfuptk + zrpho ) * 0.0128 * 16. + zrass * 1./ 7.2 * 16.
+               xqpdmax(ji,jj,jk) = xqpdmax(ji,jj,jk) * trn(ji,jj,jk,jpndi) / ( trn(ji,jj,jk,jpdia) + rtrn ) + 0.13
+               xqpdmin(ji,jj,jk) = 0.13 + 0.2 * 0.0128 * 16.
+            END DO
+         END DO
+      END DO
+
+      ! Compute the fraction of nanophytoplankton that is made of calcifiers
+      ! --------------------------------------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztem1  = MAX( 0., tsn(ji,jj,jk,jp_tem) )
+               ztem2  = tsn(ji,jj,jk,jp_tem) - 10.
+               zetot1 = MAX( 0., etot(ji,jj,jk) - 1.) / ( 4. + etot(ji,jj,jk) ) * 20. / ( 20. + etot(ji,jj,jk) ) 
+
+               xfracal(ji,jj,jk) = caco3r * ztem1 / ( 2. + ztem1 ) * (1. + trn(ji,jj,jk,jpphy) / ( 5E-7    &
+                  &                       + trn(ji,jj,jk,jpphy) ) ) * zetot1 * ( 1. + EXP(-ztem2 * ztem2 / 25. ) )  &
+                  &                       * MIN( 1., 50. / ( hmld(ji,jj) + rtrn ) )
+               xfracal(ji,jj,jk) = MAX( 0.05, MIN( 0.8 , xfracal(ji,jj,jk) ) )
+            END DO
+         END DO
+      END DO
+      !
+      IF( ln_diatrc .AND. lk_iomput .AND. jnt == nrdttrc ) THEN        ! save output diagnostics
+        !
+        CALL iom_put( "xfracal", xfracal(:,:,:) * tmask(:,:,:) )  ! euphotic layer deptht
+        CALL iom_put( "LNnut"  , xlimphy(:,:,:) * tmask(:,:,:) )  ! Nutrient limitation term
+        CALL iom_put( "LPnut"  , xlimpic(:,:,:) * tmask(:,:,:) )  ! Nutrient limitation term
+        CALL iom_put( "LDnut"  , xlimdia(:,:,:) * tmask(:,:,:) )  ! Nutrient limitation term
+        CALL iom_put( "LNFe"   , xlimnfe(:,:,:) * tmask(:,:,:) )  ! Iron limitation term
+        CALL iom_put( "LPFe"   , xlimpfe(:,:,:) * tmask(:,:,:) )  ! Iron limitation term
+        CALL iom_put( "LDFe"   , xlimdfe(:,:,:) * tmask(:,:,:) )  ! Iron limitation term
+        CALL iom_put( "SIZEN"  , sizen(:,:,:) * tmask(:,:,:) )  ! Iron
+        CALL iom_put( "SIZEP"  , sizep(:,:,:) * tmask(:,:,:) )  ! Iron
+        CALL iom_put( "SIZED"  , sized(:,:,:) * tmask(:,:,:) )  ! Iron
+        !
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_lim')
+      !
+   END SUBROUTINE p5z_lim
+
+   SUBROUTINE p5z_lim_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_lim_init  ***
+      !!
+      !! ** Purpose :   Initialization of nutrient limitation parameters
+      !!
+      !! ** Method  :   Read the nampislim namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampislim
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampislim/ concnno3, concpno3, concdno3, concnnh4, concpnh4, concdnh4,  &
+         &                concnfer, concpfer, concdfer, concbfe, concnpo4, concppo4,   &
+         &                concdpo4, concbno3, concbnh4, concbpo4,   &
+         &                xsizedia, xsizepic, xsizephy, xsizern, xsizerp, xsizerd,     &
+         &                xksi1, xksi2, xkdoc, qfnopt, qfpopt, qfdopt, caco3r,   &
+         &                qnnmin, qnnmax, qpnmin, qpnmax, qnpmin, qnpmax, qppmin,      &
+         &                qppmax, qndmin, qndmax, qpdmin, qpdmax, qfnmax, qfpmax, qfdmax 
+
+      INTEGER :: ios                 ! Local integer output status for namelist read
+
+      REWIND( numnatp_ref )              ! Namelist nampislim in reference namelist : Pisces nutrient limitation parameters
+      READ  ( numnatp_ref, nampislim, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampislim in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampislim in configuration namelist : Pisces nutrient limitation parameters 
+      READ  ( numnatp_cfg, nampislim, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampislim in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampislim )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for nutrient limitations, nampislim'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    mean rainratio                           caco3r    = ', caco3r
+         WRITE(numout,*) '    NO3 half saturation of nanophyto         concnno3  = ', concnno3
+         WRITE(numout,*) '    NO3 half saturation of picophyto         concpno3  = ', concpno3
+         WRITE(numout,*) '    NO3 half saturation of diatoms           concdno3  = ', concdno3
+         WRITE(numout,*) '    NH4 half saturation for phyto            concnnh4  = ', concnnh4
+         WRITE(numout,*) '    NH4 half saturation for pico             concpnh4  = ', concpnh4
+         WRITE(numout,*) '    NH4 half saturation for diatoms          concdnh4  = ', concdnh4
+         WRITE(numout,*) '    PO4 half saturation for phyto            concnpo4  = ', concnpo4
+         WRITE(numout,*) '    PO4 half saturation for pico             concppo4  = ', concppo4
+         WRITE(numout,*) '    PO4 half saturation for diatoms          concdpo4  = ', concdpo4
+         WRITE(numout,*) '    half saturation constant for Si uptake   xksi1     = ', xksi1
+         WRITE(numout,*) '    half saturation constant for Si/C        xksi2     = ', xksi2
+         WRITE(numout,*) '    half-sat. of DOC remineralization        xkdoc     = ', xkdoc
+         WRITE(numout,*) '    Iron half saturation for nanophyto       concnfer  = ', concnfer
+         WRITE(numout,*) '    Iron half saturation for picophyto       concpfer  = ', concpfer
+         WRITE(numout,*) '    Iron half saturation for diatoms         concdfer  = ', concdfer
+         WRITE(numout,*) '    size ratio for nanophytoplankton         xsizern   = ', xsizern
+         WRITE(numout,*) '    size ratio for picophytoplankton         xsizerp   = ', xsizerp
+         WRITE(numout,*) '    size ratio for diatoms                   xsizerd   = ', xsizerd
+         WRITE(numout,*) '    NO3 half saturation of bacteria          concbno3  = ', concbno3
+         WRITE(numout,*) '    NH4 half saturation for bacteria         concbnh4  = ', concbnh4
+         WRITE(numout,*) '    Minimum size criteria for diatoms        xsizedia  = ', xsizedia
+         WRITE(numout,*) '    Minimum size criteria for picophyto      xsizepic  = ', xsizepic
+         WRITE(numout,*) '    Minimum size criteria for nanophyto      xsizephy  = ', xsizephy
+         WRITE(numout,*) '    Fe half saturation for bacteria          concbfe   = ', concbfe
+         WRITE(numout,*) '    optimal Fe quota for nano.               qfnopt    = ', qfnopt
+         WRITE(numout,*) '    optimal Fe quota for pico.               qfpopt    = ', qfpopt
+         WRITE(numout,*) '    Optimal Fe quota for diatoms             qfdopt    = ', qfdopt
+         WRITE(numout,*) '    Minimal N quota for nano                 qnnmin    = ', qnnmin
+         WRITE(numout,*) '    Maximal N quota for nano                 qnnmax    = ', qnnmax
+         WRITE(numout,*) '    Minimal P quota for nano                 qpnmin    = ', qpnmin
+         WRITE(numout,*) '    Maximal P quota for nano                 qpnmax    = ', qpnmax
+         WRITE(numout,*) '    Minimal N quota for pico                 qnpmin    = ', qnpmin
+         WRITE(numout,*) '    Maximal N quota for pico                 qnpmax    = ', qnpmax
+         WRITE(numout,*) '    Minimal P quota for pico                 qppmin    = ', qppmin
+         WRITE(numout,*) '    Maximal P quota for pico                 qppmax    = ', qppmax
+         WRITE(numout,*) '    Minimal N quota for diatoms              qndmin    = ', qndmin
+         WRITE(numout,*) '    Maximal N quota for diatoms              qndmax    = ', qndmax
+         WRITE(numout,*) '    Minimal P quota for diatoms              qpdmin    = ', qpdmin
+         WRITE(numout,*) '    Maximal P quota for diatoms              qpdmax    = ', qpdmax
+         WRITE(numout,*) '    Minimal P quota for nanophyto.           qfnmax    = ', qfnmax
+         WRITE(numout,*) '    Minimal P quota for picophyto.           qfpmax    = ', qfpmax
+         WRITE(numout,*) '    Maximal P quota for diatoms              qfdmax    = ', qfdmax
+
+      ENDIF
+
+      zpsino3 = 2.3 * rno3
+      zpsinh4 = 1.8 * rno3
+!      zpsino3 = 1.1 * rno3
+!      zpsinh4 = 0.6 * rno3
+      zpsiuptk = 2.3 * rno3
+
+   END SUBROUTINE p5z_lim_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_lim                   ! Empty routine
+   END SUBROUTINE p5z_lim
+#endif 
+
+   !!======================================================================
+END MODULE  p5zlim
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmeso.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmeso.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmeso.F90	(revision 5266)
@@ -0,0 +1,447 @@
+MODULE p5zmeso
+   !!======================================================================
+   !!                         ***  MODULE p5zmeso  ***
+   !! TOP :   PISCES Compute the sources/sinks for mesozooplankton
+   !!======================================================================
+   !! History :   1.0  !  2002     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!             3.4  !  2011-06  (O. Aumont, C. Ethe) Quota model for iron
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_pisces_quota'                                 PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p5z_meso       :   Compute the sources/sinks for mesozooplankton
+   !!   p5z_meso_init  :   Initialization of the parameters for mesozooplankton
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE p5zsink         !  vertical flux of particulate matter due to sinking
+   USE p4zint          !  interpolation and computation of various fields
+   USE p5zprod         !  production
+   USE p5zlim
+   USE prtctl_trc      !  print control for debugging
+   USE iom             !  I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p5z_meso              ! called in p5zbio.F90
+   PUBLIC   p5z_meso_init         ! called in trcsms_pisces.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::  part2        !: part of calcite not dissolved in mesozoo guts
+   REAL(wp), PUBLIC ::  xpref2c      !: mesozoo preference for POC 
+   REAL(wp), PUBLIC ::  xpref2p      !: mesozoo preference for nanophyto
+   REAL(wp), PUBLIC ::  xpref2z      !: mesozoo preference for zooplankton
+   REAL(wp), PUBLIC ::  xpref2d      !: mesozoo preference for Diatoms 
+   REAL(wp), PUBLIC ::  xpref2m      !: mesozoo preference for mesozoo
+   REAL(wp), PUBLIC ::  xthresh2zoo  !: zoo feeding threshold for mesozooplankton 
+   REAL(wp), PUBLIC ::  xthresh2dia  !: diatoms feeding threshold for mesozooplankton 
+   REAL(wp), PUBLIC ::  xthresh2phy  !: nanophyto feeding threshold for mesozooplankton 
+   REAL(wp), PUBLIC ::  xthresh2poc  !: poc feeding threshold for mesozooplankton 
+   REAL(wp), PUBLIC ::  xthresh2mes  !: mesozoo feeding threshold for mesozooplankton 
+   REAL(wp), PUBLIC ::  xthresh2     !: feeding threshold for mesozooplankton 
+   REAL(wp), PUBLIC ::  resrat2      !: exsudation rate of mesozooplankton
+   REAL(wp), PUBLIC ::  mzrat2       !: microzooplankton mortality rate 
+   REAL(wp), PUBLIC ::  grazrat2     !: maximal mesozoo grazing rate
+   REAL(wp), PUBLIC ::  xkgraz2      !: non assimilated fraction of P by mesozoo 
+   REAL(wp), PUBLIC ::  unass2c       !: Efficicency of mesozoo growth 
+   REAL(wp), PUBLIC ::  unass2n       !: Efficicency of mesozoo growth 
+   REAL(wp), PUBLIC ::  unass2p       !: Efficicency of mesozoo growth 
+   REAL(wp), PUBLIC ::  epsher2      !: half sturation constant for grazing 2
+   REAL(wp), PUBLIC ::  grazflux     !: mesozoo flux feeding rate
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zmeso.F90 3160 2011-11-20 14:27:18Z cetlod $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p5z_meso( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_meso  ***
+      !!
+      !! ** Purpose :   Compute the sources/sinks for mesozooplankton
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zcompadi, zcompaph, zcompapoc, zcompaz, zcompam, zcompames
+      REAL(wp) :: zgraze2, zdenom, zfact, zstep, zfood, zfoodlim, zproport
+      REAL(wp) :: zmortzgoc, zfracc, zfracn, zfracp, zfracfe, zratio, zratio2
+      REAL(wp) :: zepsherf, zepshert, zepsherv, zrespirc, zrespirn, zrespirp, zbasresb, zbasresi
+      REAL(wp) :: zgraztotc, zgraztotn, zgraztotp, zgraztotf
+      REAL(wp) :: zexcess, zgradoc, zgradon, zgradop
+      REAL(wp) :: zgrapoc, zgrapon, zgrapop, zgrapof, zprcaca, zmortz
+      REAL(wp) :: zgrarem, zgraren, zgrarep, zgrafer
+      REAL(wp) :: zbeta, zrespz, ztortz, zgrasratp, zgrasratn, zgrasratf
+      REAL(wp) :: ztmp1, ztmp2, ztmp3, ztmp4, ztmp5, ztmptot
+#if defined key_kriest
+      REAL znumpoc
+#endif
+      REAL(wp) :: zgrazdc, zgrazz, zgrazm, zgrazpof, zgrazcal
+      REAL(wp) :: zgraznc, zgrazpoc, zgrazpon, zgrazpop, zgraznf, zgrazdf
+      REAL(wp) :: zgraznp, zgraznn, zgrazdn, zgrazdp
+      REAL(wp) :: zgrazfffp, zgrazfffg, zgrazffep, zgrazffeg
+      REAL(wp) :: zgrazffnp, zgrazffng, zgrazffpp, zgrazffpg
+      CHARACTER (len=25) :: charout
+      REAL(wp) :: zrfact2
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zgrazing
+
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_meso')
+      !
+      IF( ln_diatrc .AND. lk_iomput ) THEN
+         CALL wrk_alloc( jpi, jpj, jpk, zgrazing )
+         zgrazing(:,:,:) = 0._wp
+      ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zcompam   = MAX( ( trn(ji,jj,jk,jpmes) - 1.e-9 ), 0.e0 )
+# if defined key_degrad
+               zstep     = xstep * facvol(ji,jj,jk)
+# else
+               zstep     = xstep
+# endif
+               zfact     = zstep * tgfunc2(ji,jj,jk) * zcompam
+
+               !   Michaelis-Menten mortality rates of mesozooplankton
+               !   ---------------------------------------------------
+               zrespz   = resrat2 * zfact * ( trn(ji,jj,jk,jpmes) / ( xkmort + trn(ji,jj,jk,jpmes) )  &
+               &          + 3. * nitrfac(ji,jj,jk) )
+
+               !   Zooplankton mortality. A square function has been selected with
+               !   no real reason except that it seems to be more stable and may mimic predation
+               !   ---------------------------------------------------------------
+               ztortz   = mzrat2 * 1.e6 * zfact * trn(ji,jj,jk,jpmes)
+
+               !   Computation of the abundance of the preys
+               !   A threshold can be specified in the namelist
+               !   --------------------------------------------
+               zcompadi  = MAX( ( trn(ji,jj,jk,jpdia) - xthresh2dia ), 0.e0 )
+               zcompaz   = MAX( ( trn(ji,jj,jk,jpzoo) - xthresh2zoo ), 0.e0 )
+               zcompaph  = MAX( ( trn(ji,jj,jk,jpphy) - xthresh2phy ), 0.e0 )
+               zcompapoc = MAX( ( trn(ji,jj,jk,jppoc) - xthresh2poc ), 0.e0 )
+               zcompames = MAX( ( trn(ji,jj,jk,jpmes) - xthresh2mes ), 0.e0 )
+
+               !   Mesozooplankton grazing
+               !   ------------------------
+               zfood     = xpref2d * zcompadi + xpref2z * zcompaz + xpref2p * zcompaph + xpref2c * zcompapoc   &
+               &           + xpref2c * zcompapoc + xpref2m * zcompames 
+               zfoodlim  = MAX( 0., zfood - MIN( 0.5 * zfood, xthresh2 ) )
+               zdenom    = zfoodlim / ( xkgraz2 + zfoodlim )
+               zgraze2   = grazrat2 * zstep * tgfunc2(ji,jj,jk) * trn(ji,jj,jk,jpmes) 
+
+               !   An active switching parameterization is used here.
+               !   We don't use the KTW parameterization proposed by 
+               !   Vallina et al. because it tends to produce to steady biomass
+               !   composition and the variance of Chl is too low as it grazes
+               !   too strongly on winning organisms. Thus, instead of a square
+               !   a 1.5 power value is used which decreases the pressure on the
+               !   most abundant species
+               !   ------------------------------------------------------------  
+               ztmp1 = xpref2p * zcompaph**1.5
+               ztmp2 = xpref2m * zcompames**1.5
+               ztmp3 = xpref2c * zcompapoc**1.5
+               ztmp4 = xpref2d * zcompadi**1.5
+               ztmp5 = xpref2z * zcompaz**1.5
+               ztmptot = ztmp1 + ztmp2 + ztmp3 + ztmp4 + ztmp5 + rtrn
+               ztmp1 = ztmp1 / ztmptot
+               ztmp2 = ztmp2 / ztmptot
+               ztmp3 = ztmp3 / ztmptot
+               ztmp4 = ztmp4 / ztmptot
+               ztmp5 = ztmp5 / ztmptot
+
+               !   Mesozooplankton regular grazing on the different preys
+               !   ------------------------------------------------------
+               zgrazdc   = zgraze2 * ztmp4 * zdenom
+               zgrazdn   = zgrazdc * trn(ji,jj,jk,jpndi) / ( trn(ji,jj,jk,jpdia) + rtrn)
+               zgrazdp   = zgrazdc * trn(ji,jj,jk,jppdi) / ( trn(ji,jj,jk,jpdia) + rtrn)
+               zgrazdf   = zgrazdc * trn(ji,jj,jk,jpdfe) / ( trn(ji,jj,jk,jpdia) + rtrn)
+               zgrazz    = zgraze2 * ztmp5 * zdenom
+               zgrazm    = zgraze2 * ztmp2 * zdenom
+               zgraznc   = zgraze2 * ztmp1 * zdenom
+               zgraznn   = zgraznc * trn(ji,jj,jk,jpnph) / ( trn(ji,jj,jk,jpphy) + rtrn)
+               zgraznp   = zgraznc * trn(ji,jj,jk,jppph) / ( trn(ji,jj,jk,jpphy) + rtrn)
+               zgraznf   = zgraznc * trn(ji,jj,jk,jpnfe) / ( trn(ji,jj,jk,jpphy) + rtrn)
+               zgrazpoc  = zgraze2 * ztmp3 * zdenom
+               zgrazpon  = zgrazpoc * trn(ji,jj,jk,jppon) / ( trn(ji,jj,jk,jppoc) + rtrn)
+               zgrazpop  = zgrazpoc * trn(ji,jj,jk,jppop) / ( trn(ji,jj,jk,jppoc) + rtrn)
+               zgrazpof  = zgrazpoc * trn(ji,jj,jk,jpsfe) / ( trn(ji,jj,jk,jppoc) + rtrn)
+
+               !   Mesozooplankton flux feeding on GOC
+               !   ----------------------------------
+# if ! defined key_kriest
+               zgrazffeg = grazflux  * zstep * wsbio4(ji,jj,jk)      &
+               &           * tgfunc2(ji,jj,jk) * trn(ji,jj,jk,jpgoc) * trn(ji,jj,jk,jpmes)
+               zgrazfffg = zgrazffeg * trn(ji,jj,jk,jpbfe) / (trn(ji,jj,jk,jpgoc) + rtrn)
+               zgrazffng = zgrazffeg * trn(ji,jj,jk,jpgon) / (trn(ji,jj,jk,jpgoc) + rtrn)
+               zgrazffpg = zgrazffeg * trn(ji,jj,jk,jpgop) / (trn(ji,jj,jk,jpgoc) + rtrn)
+# endif
+               zgrazffep = grazflux  * zstep *  wsbio3(ji,jj,jk)     &
+               &           * tgfunc2(ji,jj,jk) * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jpmes)
+               zgrazfffp = zgrazffep * trn(ji,jj,jk,jpsfe) / (trn(ji,jj,jk,jppoc) + rtrn)
+               zgrazffnp = zgrazffep * trn(ji,jj,jk,jppon) / (trn(ji,jj,jk,jppoc) + rtrn)
+               zgrazffpp = zgrazffep * trn(ji,jj,jk,jppop) / (trn(ji,jj,jk,jppoc) + rtrn)
+               !
+# if ! defined key_kriest
+               zgraztotc  = zgrazdc + zgrazz + zgraznc + zgrazm + zgrazpoc + zgrazffep + zgrazffeg
+
+               !   Compute the proportion of filter feeders
+               !   ----------------------------------------  
+               zproport  = (zgrazffep + zgrazffeg)/(rtrn + zgraztotc)
+
+               !   Compute fractionation of aggregates. It is assumed that 
+               !   diatoms based aggregates are more prone to fractionation
+               !   since they are more porous (marine snow instead of fecal pellets)
+               !   ----------------------------------------------------------------
+               zratio    = trn(ji,jj,jk,jpgsi) / ( trn(ji,jj,jk,jpgoc) + rtrn )
+               zratio2   = zratio * zratio
+               zfracc    = zproport * grazflux  * zstep * wsbio4(ji,jj,jk)      &
+               &          * trn(ji,jj,jk,jpgoc) * trn(ji,jj,jk,jpmes)          &
+               &          * ( 0.2 + 3.8 * zratio2 / ( 1.**2 + zratio2 ) )
+               zfracfe   = zfracc * trn(ji,jj,jk,jpbfe) / (trn(ji,jj,jk,jpgoc) + rtrn)
+               zfracn    = zfracc * trn(ji,jj,jk,jpgon) / (trn(ji,jj,jk,jpgoc) + rtrn)
+               zfracp    = zfracc * trn(ji,jj,jk,jpgop) / (trn(ji,jj,jk,jpgoc) + rtrn)
+
+               zgrazffep = zproport * zgrazffep   ;   zgrazffeg = zproport * zgrazffeg
+               zgrazfffp = zproport * zgrazfffp   ;   zgrazfffg = zproport * zgrazfffg
+               zgrazffnp = zproport * zgrazffnp   ;   zgrazffng = zproport * zgrazffng
+               zgrazffpp = zproport * zgrazffpp   ;   zgrazffpg = zproport * zgrazffpg
+
+               zgraztotc  = zgrazdc + zgrazz + zgraznc + zgrazm + zgrazpoc + zgrazffep + zgrazffeg
+               zgraztotf  = zgrazdf + zgraznf + ( zgrazz + zgrazm ) * ferat3 + zgrazpof &
+               &            + zgrazfffp + zgrazfffg
+               zgraztotn  = zgrazdn + (zgrazm + zgrazz) * no3rat3 + zgraznn + zgrazpon  &
+               &            + zgrazffnp + zgrazffng
+               zgraztotp  = zgrazdp + (zgrazz + zgrazm) * po4rat3 + zgraznp + zgrazpop  &
+               &            + zgrazffpp + zgrazffpg
+
+# else
+               zgraztotc  = zgrazdc + zgrazz + zgrazm + zgraznc + zgrazpoc + zgrazffep
+
+               !   Compute the proportion of filter feeders
+               !   ----------------------------------------
+               zproport  = zgrazffep / ( zgraztotc + rtrn )
+               zgrazffep = zproport * zgrazffep   ;   zgrazfffp = zproport * zgrazfffp
+               zgrazffnp = zproport * zgrazffnp   ;   zgrazffpp = zproport * zgrazffpp
+               zgraztotc = zgrazdc + zgrazz + zgrazm + zgraznc + zgrazpoc + zgrazffep
+               zgraztotf = zgrazdf + zgraznf + (zgrazz + zgrazm) * ferat3 + zgrazpof + zgrazfffp
+               zgraztotn = zgrazdn + (zgrazz + zgrazm) * no3rat3 + zgraznn + zgrazpon + zgrazffnp
+               zgraztotp = zgrazdp + (zgrazz + zgrazm) * po4rat3 + zgraznp + zgrazpop + zgrazffpp
+# endif
+
+               ! Total grazing ( grazing by microzoo is already computed in p5zmicro )
+               IF( ln_diatrc .AND. lk_iomput )  zgrazing(ji,jj,jk) = zgraztotc
+
+               !   Stoichiometruc ratios of the food ingested by zooplanton 
+               !   --------------------------------------------------------
+               zgrasratf  =  (zgraztotf + rtrn) / ( zgraztotc + rtrn )
+               zgrasratn  =  (zgraztotn + rtrn) / ( zgraztotc + rtrn )
+               zgrasratp  =  (zgraztotp + rtrn) / ( zgraztotc + rtrn )
+
+               !   Growth efficiency is made a function of the quality 
+               !   and the quantity of the preys
+               !   ---------------------------------------------------
+               zepshert  = MIN( 1., zgrasratn/ no3rat3, zgrasratp/ po4rat3, zgrasratf / ferat3)
+               zbeta = 1./ (epsher2 - 0.2)
+               zepsherf = 0.2 + 1./ (zbeta + 0.04 * 12. * zfood *1E6 )
+               zepsherv  = zepsherf * zepshert
+
+               !   Respiration of mesozooplankton
+               !   Excess carbon in the food is used preferentially
+               !   ----------------  ------------------------------
+               zexcess  = zgraztotc * zepsherf * (1.0 - zepshert)  
+               zbasresb = MAX(0., zrespz - zexcess)
+               zbasresi = zexcess + MIN(0., zrespz - zexcess)
+               zrespirc = 0.2 * zepsherv * zgraztotc + zbasresb
+
+               !   Voiding of the excessive elements as organic matter
+               !   --------------------------------------------------------
+               zgradoc = (1. - unass2c - zepsherv) * zgraztotc - zbasresi
+               zgradon = (1. - unass2n) * zgraztotn - zepsherv * no3rat3 * zgraztotc
+               zgradop = (1. - unass2p) * zgraztotp - zepsherv * po4rat3 * zgraztotc
+               zgrafer = (1. - unass2c) * zgraztotf - zepsherv * ferat3 * zgraztotc
+               ztmp1   = ( 1. - epsher2 - unass2c ) /( 1. - 0.8 * epsher2 ) * ztortz
+               zgradoc = zgradoc + ztmp1
+               zgradon = zgradon + no3rat3 * ztmp1
+               zgradop = zgradop + po4rat3 * ztmp1
+               zgrafer = zgrafer + ferat3  * ztmp1
+               zgrarem = 0.2 * epsher2 /( 1. - 0.8 * epsher2 ) * ztortz
+               zgraren = no3rat3 * zgrarem
+               zgrarep = po4rat3 * zgrarem
+               zgrafer = zgrafer + ferat3 * zgrarem
+
+               !   Defecation as a result of non assimilated products
+               !   --------------------------------------------------
+               zgrapoc  = zgraztotc * unass2c + unass2c / ( 1. - 0.8 * epsher2 ) * ztortz
+               zgrapon  = zgraztotn * unass2n + no3rat3 * unass2c / ( 1. - 0.8 * epsher2 ) * ztortz
+               zgrapop  = zgraztotp * unass2p + po4rat3 * unass2c / ( 1. - 0.8 * epsher2 ) * ztortz
+               zgrapof  = zgraztotf * unass2c + ferat3  * unass2c / ( 1. - 0.8 * epsher2 ) * ztortz
+
+               !   Update the arrays TRA which contain the biological sources and
+               !   sinks
+               !   --------------------------------------------------------------
+               zrespirn  = zrespirc * no3rat3
+               zrespirp  = zrespirc * po4rat3
+               zgrafer   = zgrafer + zrespirc * ferat3
+
+               tra(ji,jj,jk,jppo4) = tra(ji,jj,jk,jppo4) + zgrarep + zrespirp
+               tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) + zgraren + zrespirn
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + zgradoc
+               tra(ji,jj,jk,jpdon) = tra(ji,jj,jk,jpdon) + zgradon
+               tra(ji,jj,jk,jpdop) = tra(ji,jj,jk,jpdop) + zgradop
+               tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) - o2ut * (zgraren + zrespirn)
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) + zgrafer
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) + zrespirc
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) + rno3 * (zgraren + zrespirn)
+               tra(ji,jj,jk,jpmes) = tra(ji,jj,jk,jpmes) + zepsherv * zgraztotc - zrespirc   &
+               &                     - ztortz - zgrazm
+               tra(ji,jj,jk,jpdia) = tra(ji,jj,jk,jpdia) - zgrazdc
+               tra(ji,jj,jk,jpndi) = tra(ji,jj,jk,jpndi) - zgrazdn
+               tra(ji,jj,jk,jppdi) = tra(ji,jj,jk,jppdi) - zgrazdp
+               tra(ji,jj,jk,jpdfe) = tra(ji,jj,jk,jpdfe) - zgrazdf
+               tra(ji,jj,jk,jpzoo) = tra(ji,jj,jk,jpzoo) - zgrazz
+               tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) - zgraznc
+               tra(ji,jj,jk,jpnph) = tra(ji,jj,jk,jpnph) - zgraznn
+               tra(ji,jj,jk,jppph) = tra(ji,jj,jk,jppph) - zgraznp
+               tra(ji,jj,jk,jpnfe) = tra(ji,jj,jk,jpnfe) - zgraznf
+               tra(ji,jj,jk,jpnch) = tra(ji,jj,jk,jpnch) - zgraznc * trn(ji,jj,jk,jpnch) / ( trn(ji,jj,jk,jpphy) + rtrn )
+               tra(ji,jj,jk,jpdch) = tra(ji,jj,jk,jpdch) - zgrazdc * trn(ji,jj,jk,jpdch) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               tra(ji,jj,jk,jpdsi) = tra(ji,jj,jk,jpdsi) - zgrazdc * trn(ji,jj,jk,jpdsi) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               tra(ji,jj,jk,jpgsi) = tra(ji,jj,jk,jpgsi) + zgrazdc * trn(ji,jj,jk,jpdsi) / ( trn(ji,jj,jk,jpdia) + rtrn )
+
+#if defined key_kriest
+               znumpoc = trn(ji,jj,jk,jpnum) / ( trn(ji,jj,jk,jppoc) + rtrn )
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) - zgrazpoc - zgrazffep + zgrapoc
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) - zgrazpon - zgrazffnp + zgrapon
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) - zgrazpop - zgrazffpp + zgrapop
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) - zgrazpoc * znumpoc + zgrapoc * xkr_dmeso      &
+               &   - zgrazffep * znumpoc * wsbio4(ji,jj,jk) / ( wsbio3(ji,jj,jk) + rtrn )
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) - zgrazfffp - zgrazpof    &
+               &   + zgrapof
+               zgrazcal = zgrazffep * ( 1. - part2 ) * trn(ji,jj,jk,jpcal) / ( trn(ji,jj,jk,jppoc) + rtrn )
+#else
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) - zgrazpoc - zgrazffep + zfracc
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) - zgrazpon - zgrazffnp + zfracn
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) - zgrazpop - zgrazffpp + zfracp
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) - zgrazffeg + zgrapoc - zfracc
+               tra(ji,jj,jk,jpgon) = tra(ji,jj,jk,jpgon) - zgrazffng + zgrapon - zfracn
+               tra(ji,jj,jk,jpgop) = tra(ji,jj,jk,jpgop) - zgrazffpg + zgrapop - zfracp
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) - zgrazpof - zgrazfffp + zfracfe
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) - zgrazfffg + zgrapof - zfracfe
+               zgrazcal = zgrazffeg * ( 1. - part2 ) * trn(ji,jj,jk,jpcal) / ( trn(ji,jj,jk,jpgoc) + rtrn )
+#endif
+               !  calcite production
+               !  ------------------
+               zprcaca = xfracal(ji,jj,jk) * zgraznc
+               prodcal(ji,jj,jk) = prodcal(ji,jj,jk) + zprcaca  ! prodcal=prodcal(nanophy)+prodcal(microzoo)+prodcal(mesozoo)
+               zprcaca = part2 * zprcaca
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) + zgrazcal - zprcaca
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) + 2. * ( zgrazcal + zprcaca )
+               tra(ji,jj,jk,jpcal) = tra(ji,jj,jk,jpcal) - zgrazcal + zprcaca
+            END DO
+         END DO
+      END DO
+      !
+      IF( ln_diatrc .AND. lk_iomput .AND. jnt == nrdttrc ) THEN
+         zrfact2 = 1.e3 * rfact2r
+         CALL iom_put( "GRAZ2", zgrazing(:,:,:) * zrfact2 * tmask(:,:,:) )  ! Total grazing of phyto by zooplankton
+         CALL iom_put( "PCAL" , prodcal(:,:,:)  * zrfact2 * tmask(:,:,:) )  ! Calcite production
+      ENDIF
+      !
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+        WRITE(charout, FMT="('meso')")
+        CALL prt_ctl_trc_info(charout)
+        CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      IF( ln_diatrc .AND. lk_iomput )  CALL wrk_dealloc( jpi, jpj, jpk, zgrazing )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_meso')
+      !
+   END SUBROUTINE p5z_meso
+
+   SUBROUTINE p5z_meso_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_meso_init  ***
+      !!
+      !! ** Purpose :   Initialization of mesozooplankton parameters
+      !!
+      !! ** Method  :   Read the nampismes namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampismes
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampismes/ part2, grazrat2, resrat2, mzrat2, xpref2c, xpref2p, xpref2z, xpref2m,   &
+         &                xpref2d, xthresh2dia, xthresh2phy, xthresh2zoo, xthresh2poc, &
+         &                xthresh2mes, xthresh2, xkgraz2, epsher2, unass2c, &
+      &                   unass2n, unass2p, grazflux
+
+      INTEGER :: ios                 ! Local integer output status for namelist read
+
+      REWIND( numnatp_ref )              ! Namelist nampismes in reference namelist : Pisces mesozooplankton
+      READ  ( numnatp_ref, nampismes, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampismes in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampismes in configuration namelist : Pisces mesozooplankton
+      READ  ( numnatp_cfg, nampismes, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampismes in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampismes )
+
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' ' 
+         WRITE(numout,*) ' Namelist parameters for mesozooplankton, nampismes'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    part of calcite not dissolved in mesozoo guts  part2        =', part2
+         WRITE(numout,*) '    mesozoo preference for nano.                   xpref2p      =', xpref2p
+         WRITE(numout,*) '    mesozoo preference for diatoms                 xpref2d      =', xpref2d
+         WRITE(numout,*) '    mesozoo preference for zoo                     xpref2z      =', xpref2z
+         WRITE(numout,*) '    mesozoo preference for mesozoo                 xpref2m      =', xpref2m
+         WRITE(numout,*) '    mesozoo preference for poc                     xpref2c      =', xpref2c
+         WRITE(numout,*) '    microzoo feeding threshold  for mesozoo        xthresh2zoo  =', xthresh2zoo
+         WRITE(numout,*) '    diatoms feeding threshold  for mesozoo         xthresh2dia  =', xthresh2dia
+         WRITE(numout,*) '    nanophyto feeding threshold for mesozoo        xthresh2phy  =', xthresh2phy
+         WRITE(numout,*) '    poc feeding threshold for mesozoo              xthresh2poc  =', xthresh2poc
+         WRITE(numout,*) '    mesozoo feeding threshold for mesozoo          xthresh2mes  =', xthresh2mes
+         WRITE(numout,*) '    feeding threshold for mesozooplankton          xthresh2     =', xthresh2
+         WRITE(numout,*) '    exsudation rate of mesozooplankton             resrat2      =', resrat2
+         WRITE(numout,*) '    mesozooplankton mortality rate                 mzrat2       =', mzrat2
+         WRITE(numout,*) '    maximal mesozoo grazing rate                   grazrat2     =', grazrat2
+         WRITE(numout,*) '    mesozoo flux feeding rate                      grazflux     =', grazflux
+         WRITE(numout,*) '    C egested fraction of food by mesozoo          unass2c       =', unass2c
+         WRITE(numout,*) '    C egested fraction of food by mesozoo          unass2n       =', unass2n
+         WRITE(numout,*) '    C egested fraction of food by mesozoo          unass2p       =', unass2p
+         WRITE(numout,*) '    Efficicency of Mesozoo growth                  epsher2      =', epsher2
+         WRITE(numout,*) '    half sturation constant for grazing 2          xkgraz2      =', xkgraz2
+      ENDIF
+
+
+   END SUBROUTINE p5z_meso_init
+
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_meso                    ! Empty routine
+   END SUBROUTINE p5z_meso
+#endif 
+
+   !!======================================================================
+END MODULE  p5zmeso
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmicro.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmicro.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmicro.F90	(revision 5266)
@@ -0,0 +1,360 @@
+MODULE p5zmicro
+   !!======================================================================
+   !!                         ***  MODULE p5zmicro  ***
+   !! TOP :   PISCES Compute the sources/sinks for microzooplankton
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!             3.4  !  2011-06  (O. Aumont, C. Ethe) Quota model for iron
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_pisces_quota'                                 PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p5z_micro       :   Compute the sources/sinks for microzooplankton
+   !!   p5z_micro_init  :   Initialize and read the appropriate namelist
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE p5zlim          !  Co-limitations
+   USE p5zsink         !  vertical flux of particulate matter due to sinking
+   USE p4zint          !  interpolation and computation of various fields
+   USE p5zprod         !  production
+   USE iom             !  I/O manager
+   USE prtctl_trc      !  print control for debugging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p5z_micro         ! called in p5zbio.F90
+   PUBLIC   p5z_micro_init    ! called in trcsms_pisces.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::  part        !: part of calcite not dissolved in microzoo guts
+   REAL(wp), PUBLIC ::  xprefc     !: microzoo preference for POC 
+   REAL(wp), PUBLIC ::  xprefn     !: microzoo preference for nanophyto
+   REAL(wp), PUBLIC ::  xprefp     !: microzoo preference for picophyto
+   REAL(wp), PUBLIC ::  xprefd     !: microzoo preference for diatoms
+   REAL(wp), PUBLIC ::  xprefz     !: microzoo preference for microzoo
+   REAL(wp), PUBLIC ::  xthreshdia  !: diatoms feeding threshold for microzooplankton 
+   REAL(wp), PUBLIC ::  xthreshpic  !: picophyto feeding threshold for microzooplankton 
+   REAL(wp), PUBLIC ::  xthreshphy  !: nanophyto threshold for microzooplankton 
+   REAL(wp), PUBLIC ::  xthreshzoo  !: microzoo threshold for microzooplankton 
+   REAL(wp), PUBLIC ::  xthreshpoc  !: poc threshold for microzooplankton 
+   REAL(wp), PUBLIC ::  xthresh     !: feeding threshold for microzooplankton 
+   REAL(wp), PUBLIC ::  resrat      !: exsudation rate of microzooplankton
+   REAL(wp), PUBLIC ::  mzrat       !: microzooplankton mortality rate 
+   REAL(wp), PUBLIC ::  grazrat     !: maximal microzoo grazing rate
+   REAL(wp), PUBLIC ::  xkgraz      !: non assimilated fraction of P by microzoo 
+   REAL(wp), PUBLIC ::  unassc      !: Efficicency of microzoo growth 
+   REAL(wp), PUBLIC ::  unassn      !: Efficicency of microzoo growth 
+   REAL(wp), PUBLIC ::  unassp      !: Efficicency of microzoo growth 
+   REAL(wp), PUBLIC ::  epsher      !: half sturation constant for grazing 1 
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zmicro.F90 3160 2011-11-20 14:27:18Z cetlod $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p5z_micro( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_micro  ***
+      !!
+      !! ** Purpose :   Compute the sources/sinks for microzooplankton
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::  kt  ! ocean time step
+      INTEGER, INTENT(in) ::  jnt 
+      !
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zcompadi, zcompaz , zcompaph, zcompapoc, zcompapon, zcompapop
+      REAL(wp) :: zcompapi, zgraze  , zdenom, zfact, zstep, zfood, zfoodlim
+      REAL(wp) :: ztmp1, ztmp2, ztmp3, ztmp4, ztmp5, ztmptot
+      REAL(wp) :: zepsherf, zepshert, zepsherv, zrespirc, zrespirn, zrespirp, zbasresb, zbasresi
+      REAL(wp) :: zgraztotc, zgraztotn, zgraztotp, zgraztotf
+      REAL(wp) :: zexcess, zgradoc, zgradon, zgradop, zgrafer
+      REAL(wp) :: zgrapoc, zgrapon, zgrapop, zgrapof, zprcaca, zmortz
+      REAL(wp) :: zrespz, ztortz, zgrasratf, zgrasratn, zgrasratp
+      REAL(wp) :: zgraznc, zgraznn, zgraznp, zgrazpoc, zgrazpon, zgrazpop, zgrazpof
+      REAL(wp) :: zgrazdc, zgrazdn, zgrazdp, zgrazdf, zgraznf, zgrazz
+      REAL(wp) :: zgrazpc, zgrazpn, zgrazpp, zgrazpf, zbeta, zrfact2
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zgrazing
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_micro')
+      !
+      IF( ln_diatrc .AND. lk_iomput )  CALL wrk_alloc( jpi, jpj, jpk, zgrazing )
+      !
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zcompaz = MAX( ( trn(ji,jj,jk,jpzoo) - 1.e-9 ), 0.e0 )
+               zstep   = xstep
+# if defined key_degrad
+               zstep = zstep * facvol(ji,jj,jk)
+# endif
+               zfact   = zstep * tgfunc2(ji,jj,jk) * zcompaz
+
+               !   Michaelis-Menten mortality rates of microzooplankton
+               !   -----------------------------------------------------
+               zrespz = resrat * zfact * ( trn(ji,jj,jk,jpzoo) / ( xkmort + trn(ji,jj,jk,jpzoo) )  &
+               &        + 3. * nitrfac(ji,jj,jk) )
+
+               !   Zooplankton mortality. A square function has been selected with
+               !   no real reason except that it seems to be more stable and may mimic predation.
+               !   ------------------------------------------------------------------------------
+               ztortz = mzrat * 1.e6 * zfact * trn(ji,jj,jk,jpzoo)
+
+               !   Computation of the abundance of the preys
+               !   A threshold can be specified in the namelist
+               !   --------------------------------------------
+               zcompadi  = MIN( MAX( ( trn(ji,jj,jk,jpdia) - xthreshdia ), 0.e0 ), xsizedia )
+               zcompaph  = MAX( ( trn(ji,jj,jk,jpphy) - xthreshphy ), 0.e0 )
+               zcompaz   = MAX( ( trn(ji,jj,jk,jpzoo) - xthreshzoo ), 0.e0 )
+               zcompapi  = MAX( ( trn(ji,jj,jk,jppic) - xthreshpic ), 0.e0 )
+               zcompapoc = MAX( ( trn(ji,jj,jk,jppoc) - xthreshpoc ), 0.e0 )
+               
+               !   Microzooplankton grazing
+               !   ------------------------
+               zfood     = xprefn * zcompaph + xprefc * zcompapoc + xprefd * zcompadi   &
+               &           + xprefz * zcompaz + xprefp * zcompapi
+               zfoodlim  = MAX( 0. , zfood - min(xthresh,0.5*zfood) )
+               zdenom    = zfoodlim / ( xkgraz + zfoodlim )
+               zgraze    = grazrat * zstep * tgfunc2(ji,jj,jk) * trn(ji,jj,jk,jpzoo) 
+
+               !   An active switching parameterization is used here.
+               !   We don't use the KTW parameterization proposed by 
+               !   Vallina et al. because it tends to produce to steady biomass
+               !   composition and the variance of Chl is too low as it grazes
+               !   too strongly on winning organisms. Thus, instead of a square
+               !   a 1.5 power value is used which decreases the pressure on the
+               !   most abundant species
+               !   ------------------------------------------------------------  
+               ztmp1 = xprefn * zcompaph**1.5
+               ztmp2 = xprefp * zcompapi**1.5
+               ztmp3 = xprefc * zcompapoc**1.5
+               ztmp4 = xprefd * zcompadi**1.5
+               ztmp5 = xprefz * zcompaz**1.5
+               ztmptot = ztmp1 + ztmp2 + ztmp3 + ztmp4 + ztmp5 + rtrn
+               ztmp1 = ztmp1 / ztmptot
+               ztmp2 = ztmp2 / ztmptot
+               ztmp3 = ztmp3 / ztmptot
+               ztmp4 = ztmp4 / ztmptot
+               ztmp5 = ztmp5 / ztmptot
+
+               !   Microzooplankton regular grazing on the different preys
+               !   -------------------------------------------------------
+               zgraznc   = zgraze  * ztmp1  * zdenom
+               zgraznn   = zgraznc * trn(ji,jj,jk,jpnph) / (trn(ji,jj,jk,jpphy) + rtrn)
+               zgraznp   = zgraznc * trn(ji,jj,jk,jppph) / (trn(ji,jj,jk,jpphy) + rtrn)
+               zgraznf   = zgraznc * trn(ji,jj,jk,jpnfe) / (trn(ji,jj,jk,jpphy) + rtrn)
+               zgrazpc   = zgraze  * ztmp2  * zdenom
+               zgrazpn   = zgrazpc * trn(ji,jj,jk,jpnpi) / (trn(ji,jj,jk,jppic) + rtrn)
+               zgrazpp   = zgrazpc * trn(ji,jj,jk,jpppi) / (trn(ji,jj,jk,jppic) + rtrn)
+               zgrazpf   = zgrazpc * trn(ji,jj,jk,jppfe) / (trn(ji,jj,jk,jppic) + rtrn)
+               zgrazz    = zgraze  * ztmp5   * zdenom
+               zgrazpoc  = zgraze  * ztmp3   * zdenom
+               zgrazpon  = zgrazpoc * trn(ji,jj,jk,jppon) / ( trn(ji,jj,jk,jppoc) + rtrn )
+               zgrazpop  = zgrazpoc * trn(ji,jj,jk,jppop) / ( trn(ji,jj,jk,jppoc) + rtrn )
+               zgrazdc   = zgraze  * ztmp4  * zdenom
+               zgrazdn   = zgrazdc * trn(ji,jj,jk,jpndi) / (trn(ji,jj,jk,jpdia) + rtrn)
+               zgrazdp   = zgrazdc * trn(ji,jj,jk,jppdi) / (trn(ji,jj,jk,jpdia) + rtrn)
+               zgrazdf   = zgrazdc * trn(ji,jj,jk,jpdfe) / (trn(ji,jj,jk,jpdia) + rtrn)
+               zgrazpof  = zgrazpoc* trn(ji,jj,jk,jpsfe) / (trn(ji,jj,jk,jppoc) + rtrn)
+               !
+               zgraztotc = zgraznc + zgrazpoc + zgrazdc + zgrazz + zgrazpc
+               zgraztotn = zgraznn + zgrazpn + zgrazpon + zgrazdn + zgrazz * no3rat3
+               zgraztotp = zgraznp + zgrazpp + zgrazpop + zgrazdp + zgrazz * po4rat3
+               zgraztotf = zgraznf + zgrazpf + zgrazpof + zgrazdf + zgrazz * ferat3
+               !
+               ! Grazing by microzooplankton
+               IF( ln_diatrc .AND. lk_iomput )  zgrazing(ji,jj,jk) = zgraztotc
+
+               !   Stoichiometruc ratios of the food ingested by zooplanton 
+               !   --------------------------------------------------------
+               zgrasratf =  (zgraztotf + rtrn) / ( zgraztotc + rtrn )
+               zgrasratn =  (zgraztotn + rtrn) / ( zgraztotc + rtrn )
+               zgrasratp =  (zgraztotp + rtrn) / ( zgraztotc + rtrn )
+
+               !   Growth efficiency is made a function of the quality 
+               !   and the quantity of the preys
+               !   ---------------------------------------------------
+               zepshert  = MIN( 1., zgrasratn/ no3rat3, zgrasratp/ po4rat3, zgrasratf / ferat3)
+               zbeta = 1./ (epsher - 0.2)
+               zepsherf = 0.2 + 1./ (zbeta + 0.04 * 12. * zfood * 1E6 )
+               zepsherv  = zepsherf * zepshert
+
+               !   Respiration of microzooplankton
+               !   Excess carbon in the food is used preferentially
+               !   ------------------------------------------------
+               zexcess  = zgraztotc * zepsherf * (1.0 - zepshert) 
+               zbasresb = MAX(0., zrespz - zexcess)
+               zbasresi = zexcess + MIN(0., zrespz - zexcess)  
+               zrespirc = 0.2 * zepsherv * zgraztotc + zbasresb
+
+               !   Voiding of the excessive elements as DOM
+               !   ----------------------------------------
+               zgradoc   = (1. - unassc - zepsherv) * zgraztotc - zbasresi  
+               zgradon   = (1. - unassn) * zgraztotn - zepsherv * no3rat3 * zgraztotc
+               zgradop   = (1. - unassp) * zgraztotp - zepsherv * po4rat3 * zgraztotc
+               zgrafer   = (1. - unassc) * zgraztotf - zepsherv * ferat3 * zgraztotc
+
+               !   Defecation as a result of non assimilated products
+               !   --------------------------------------------------
+               zgrapoc   = zgraztotc * unassc
+               zgrapon   = zgraztotn * unassn
+               zgrapop   = zgraztotp * unassp
+               zgrapof   = zgraztotf * unassc
+
+               !   Update of the TRA arrays
+               !   ------------------------
+               zrespirn  = zrespirc * no3rat3
+               zrespirp  = zrespirc * po4rat3
+               zgrafer   = zgrafer + zrespirc * ferat3
+
+               tra(ji,jj,jk,jppo4) = tra(ji,jj,jk,jppo4) + zrespirp
+               tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) + zrespirn
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + zgradoc
+               tra(ji,jj,jk,jpdon) = tra(ji,jj,jk,jpdon) + zgradon
+               tra(ji,jj,jk,jpdop) = tra(ji,jj,jk,jpdop) + zgradop
+               tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) - o2ut * zrespirc
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) + zgrafer
+               tra(ji,jj,jk,jpzoo) = tra(ji,jj,jk,jpzoo) + zepsherv * zgraztotc - zrespirc   &
+               &                     - ztortz - zgrazz
+               tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) - zgraznc
+               tra(ji,jj,jk,jpnph) = tra(ji,jj,jk,jpnph) - zgraznn
+               tra(ji,jj,jk,jppph) = tra(ji,jj,jk,jppph) - zgraznp
+               tra(ji,jj,jk,jppic) = tra(ji,jj,jk,jppic) - zgrazpc
+               tra(ji,jj,jk,jpnpi) = tra(ji,jj,jk,jpnpi) - zgrazpn
+               tra(ji,jj,jk,jpppi) = tra(ji,jj,jk,jpppi) - zgrazpp
+               tra(ji,jj,jk,jpdia) = tra(ji,jj,jk,jpdia) - zgrazdc
+               tra(ji,jj,jk,jpndi) = tra(ji,jj,jk,jpndi) - zgrazdn
+               tra(ji,jj,jk,jppdi) = tra(ji,jj,jk,jppdi) - zgrazdp
+               tra(ji,jj,jk,jpnch) = tra(ji,jj,jk,jpnch) - zgraznc * trn(ji,jj,jk,jpnch)/(trn(ji,jj,jk,jpphy)+rtrn)
+               tra(ji,jj,jk,jppch) = tra(ji,jj,jk,jppch) - zgrazpc * trn(ji,jj,jk,jppch)/(trn(ji,jj,jk,jppic)+rtrn)
+               tra(ji,jj,jk,jpdch) = tra(ji,jj,jk,jpdch) - zgrazdc * trn(ji,jj,jk,jpdch)/(trn(ji,jj,jk,jpdia)+rtrn)
+               tra(ji,jj,jk,jpdsi) = tra(ji,jj,jk,jpdsi) - zgrazdc * trn(ji,jj,jk,jpdsi)/(trn(ji,jj,jk,jpdia)+rtrn)
+               tra(ji,jj,jk,jpgsi) = tra(ji,jj,jk,jpgsi) + zgrazdc * trn(ji,jj,jk,jpdsi)/(trn(ji,jj,jk,jpdia)+rtrn)
+               tra(ji,jj,jk,jpnfe) = tra(ji,jj,jk,jpnfe) - zgraznf
+               tra(ji,jj,jk,jppfe) = tra(ji,jj,jk,jppfe) - zgrazpf
+               tra(ji,jj,jk,jpdfe) = tra(ji,jj,jk,jpdfe) - zgrazdf
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + ztortz + zgrapoc - zgrazpoc 
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) + no3rat3 * ztortz + zgrapon - zgrazpon
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) + po4rat3 * ztortz + zgrapop - zgrazpop
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + ferat3 * ztortz  + zgrapof - zgrazpof
+#if defined key_kriest
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + zgrapoc * xkr_dmicro
+#endif
+               !
+               ! calcite production
+               zprcaca = xfracal(ji,jj,jk) * zgraznc
+               prodcal(ji,jj,jk) = prodcal(ji,jj,jk) + zprcaca  ! prodcal=prodcal(nanophy)+prodcal(microzoo)+prodcal(mesozoo)
+               !
+               zprcaca = part * zprcaca
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) + zrespirc - zprcaca
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) - 2. * zprcaca
+               tra(ji,jj,jk,jpcal) = tra(ji,jj,jk,jpcal) + rno3 * zrespirn + zprcaca
+#if defined key_kriest
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + ztortz * xkr_dmicro &
+                                                         - zgrazpoc * trn(ji,jj,jk,jpnum) / ( trn(ji,jj,jk,jppoc) + rtrn )
+#endif
+            END DO
+         END DO
+      END DO
+      !
+      IF( ln_diatrc .AND. lk_iomput .AND. jnt == nrdttrc ) THEN
+         zrfact2 = 1.e3 * rfact2r
+         CALL iom_put( "GRAZ1" , zgrazing(:,:,:) * zrfact2 * tmask(:,:,:) )  ! Total grazing of phyto by zooplankton
+      ENDIF
+      !
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('micro')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      IF( ln_diatrc .AND. lk_iomput )  CALL wrk_dealloc( jpi, jpj, jpk, zgrazing )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_micro')
+      !
+   END SUBROUTINE p5z_micro
+
+
+   SUBROUTINE p5z_micro_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_micro_init  ***
+      !!
+      !! ** Purpose :   Initialization of microzooplankton parameters
+      !!
+      !! ** Method  :   Read the nampiszoo namelist and check the parameters
+      !!                called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampiszoo
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampiszoo/ part, grazrat, resrat, mzrat, xprefc, xprefn, &
+         &                xprefp, xprefd, xprefz, xthreshdia, xthreshphy, &
+         &                xthreshpic, xthreshpoc, xthreshzoo, xthresh, xkgraz, &
+         &                epsher, unassc, unassn, unassp
+
+      INTEGER :: ios                 ! Local integer output status for namelist read
+
+      REWIND( numnatp_ref )              ! Namelist nampiszoo in reference namelist : Pisces microzooplankton
+      READ  ( numnatp_ref, nampiszoo, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampiszoo in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampiszoo in configuration namelist : Pisces microzooplankton
+      READ  ( numnatp_cfg, nampiszoo, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampiszoo in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampiszoo )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for microzooplankton, nampiszoo'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    part of calcite not dissolved in microzoo guts  part        =', part
+         WRITE(numout,*) '    microzoo preference for POC                     xprefc     =', xprefc
+         WRITE(numout,*) '    microzoo preference for nano                    xprefn     =', xprefn
+         WRITE(numout,*) '    microzoo preference for pico                    xprefp     =', xprefp
+         WRITE(numout,*) '    microzoo preference for diatoms                 xprefd     =', xprefd
+         WRITE(numout,*) '    microzoo preference for microzoo                xprefz     =', xprefz
+         WRITE(numout,*) '    diatoms feeding threshold  for microzoo         xthreshdia  =', xthreshdia
+         WRITE(numout,*) '    nanophyto feeding threshold for microzoo        xthreshphy  =', xthreshphy
+         WRITE(numout,*) '    picophyto feeding threshold for microzoo        xthreshpic  =', xthreshpic
+         WRITE(numout,*) '    poc feeding threshold for microzoo              xthreshpoc  =', xthreshpoc
+         WRITE(numout,*) '    microzoo feeding threshold for microzoo         xthreshzoo  =', xthreshzoo
+         WRITE(numout,*) '    feeding threshold for microzooplankton          xthresh     =', xthresh
+         WRITE(numout,*) '    exsudation rate of microzooplankton             resrat      =', resrat
+         WRITE(numout,*) '    microzooplankton mortality rate                 mzrat       =', mzrat
+         WRITE(numout,*) '    maximal microzoo grazing rate                   grazrat     =', grazrat
+         WRITE(numout,*) '    C egested fraction of fodd by microzoo          unassc      =', unassc
+         WRITE(numout,*) '    N egested fraction of fodd by microzoo          unassn      =', unassn
+         WRITE(numout,*) '    P egested fraction of fodd by microzoo          unassp      =', unassp
+         WRITE(numout,*) '    Efficicency of microzoo growth                  epsher      =', epsher
+         WRITE(numout,*) '    half sturation constant for grazing 1           xkgraz      =', xkgraz
+      ENDIF
+
+   END SUBROUTINE p5z_micro_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_micro                    ! Empty routine
+   END SUBROUTINE p5z_micro
+#endif 
+
+   !!======================================================================
+END MODULE  p5zmicro
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmort.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmort.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zmort.F90	(revision 5266)
@@ -0,0 +1,359 @@
+MODULE p5zmort
+   !!======================================================================
+   !!                         ***  MODULE p5zmort  ***
+   !! TOP :   PISCES Compute the mortality terms for phytoplankton
+   !!======================================================================
+   !! History :   1.0  !  2002     (O. Aumont)  Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_pisces_quota'                                 PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p5z_mort       :   Compute the mortality terms for phytoplankton
+   !!   p5z_mort_init  :   Initialize the mortality params for phytoplankton
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE p5zsink         !  vertical flux of particulate matter due to sinking
+   USE p5zprod         !  Primary productivity 
+   USE prtctl_trc      !  print control for debugging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p5z_mort    
+   PUBLIC   p5z_mort_init    
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC :: wchl    !:
+   REAL(wp), PUBLIC :: wchlp   !:
+   REAL(wp), PUBLIC :: wchld   !:
+   REAL(wp), PUBLIC :: wchldm  !:
+   REAL(wp), PUBLIC :: mprat   !:
+   REAL(wp), PUBLIC :: mpratp  !:
+   REAL(wp), PUBLIC :: mprat2  !:
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zmort.F90 3160 2011-11-20 14:27:18Z cetlod $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p5z_mort( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_mort  ***
+      !!
+      !! ** Purpose :   Calls the different subroutine to initialize and compute
+      !!                the different phytoplankton mortality terms
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt ! ocean time step
+      !!---------------------------------------------------------------------
+
+      CALL p5z_nano            ! nanophytoplankton
+      CALL p5z_pico            ! picophytoplankton
+      CALL p5z_diat            ! diatoms
+
+   END SUBROUTINE p5z_mort
+
+
+   SUBROUTINE p5z_nano
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_nano  ***
+      !!
+      !! ** Purpose :   Compute the mortality terms for nanophytoplankton
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zcompaph
+      REAL(wp) :: zfactfe, zfactch, zfactn, zfactp, zprcaca
+      REAL(wp) :: ztortp , zrespp , zmortp , zstep
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_nano')
+      !
+      prodcal(:,:,:) = 0.  !: calcite production variable set to zero
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zcompaph = MAX( ( trn(ji,jj,jk,jpphy) - 1e-8 ), 0.e0 )
+               zstep    = xstep
+# if defined key_degrad
+               zstep    = zstep * facvol(ji,jj,jk)
+# endif
+               !   Squared mortality of Phyto similar to a sedimentation term during
+               !   blooms (Doney et al. 1996)
+               !   -----------------------------------------------------------------
+               zrespp = wchl * 1.e6 * zstep * xdiss(ji,jj,jk) * zcompaph * trn(ji,jj,jk,jpphy)
+
+               !   Phytoplankton linear mortality
+               !   ------------------------------
+               ztortp = mprat * xstep  * zcompaph
+               zmortp = zrespp + ztortp
+
+               !   Update the arrays TRA which contains the biological sources and sinks
+
+               zfactn  = trn(ji,jj,jk,jpnph)/(trn(ji,jj,jk,jpphy)+rtrn)
+               zfactp  = trn(ji,jj,jk,jppph)/(trn(ji,jj,jk,jpphy)+rtrn)
+               zfactfe = trn(ji,jj,jk,jpnfe)/(trn(ji,jj,jk,jpphy)+rtrn)
+               zfactch = trn(ji,jj,jk,jpnch)/(trn(ji,jj,jk,jpphy)+rtrn)
+               tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) - zmortp
+               tra(ji,jj,jk,jpnph) = tra(ji,jj,jk,jpnph) - zmortp * zfactn
+               tra(ji,jj,jk,jppph) = tra(ji,jj,jk,jppph) - zmortp * zfactp
+               tra(ji,jj,jk,jpnch) = tra(ji,jj,jk,jpnch) - zmortp * zfactch
+               tra(ji,jj,jk,jpnfe) = tra(ji,jj,jk,jpnfe) - zmortp * zfactfe
+               zprcaca = xfracal(ji,jj,jk) * zmortp
+               !
+               prodcal(ji,jj,jk) = prodcal(ji,jj,jk) + zprcaca  ! prodcal=prodcal(nanophy)+prodcal(microzoo)+prodcal(mesozoo)
+               !
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) - zprcaca
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) - 2. * zprcaca
+               tra(ji,jj,jk,jpcal) = tra(ji,jj,jk,jpcal) + zprcaca
+#if defined key_kriest
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zmortp
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) + zmortp * zfactn
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) + zmortp * zfactp
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + ztortp * xkr_dnano + zrespp * xkr_ddiat
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zmortp * zfactfe
+#else
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zmortp
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) + zmortp * zfactn
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) + zmortp * zfactp
+
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zmortp * zfactfe
+#endif
+            END DO
+         END DO
+      END DO
+      !
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('nano')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_nano')
+      !
+   END SUBROUTINE p5z_nano
+
+   SUBROUTINE p5z_pico
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_pico  ***
+      !!
+      !! ** Purpose :   Compute the mortality terms for picophytoplankton
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zcompaph
+      REAL(wp) :: zfactfe, zfactch, zfactn, zfactp
+      REAL(wp) :: ztortp , zrespp , zmortp , zstep
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_pico')
+      !
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zcompaph = MAX( ( trn(ji,jj,jk,jppic) - 1e-8 ), 0.e0 )
+               zstep    = xstep
+# if defined key_degrad
+               zstep    = zstep * facvol(ji,jj,jk)
+# endif
+               !  Squared mortality of Phyto similar to a sedimentation term during
+               !  blooms (Doney et al. 1996)
+               !  -----------------------------------------------------------------
+               zrespp = wchlp * 1.e6 * zstep * xdiss(ji,jj,jk) * zcompaph * trn(ji,jj,jk,jppic)
+
+               !     Phytoplankton mortality 
+               ztortp = mpratp * xstep  * zcompaph
+               zmortp = zrespp + ztortp
+
+               !   Update the arrays TRA which contains the biological sources and sinks
+
+               zfactn = trn(ji,jj,jk,jpnpi)/(trn(ji,jj,jk,jppic)+rtrn)
+               zfactp = trn(ji,jj,jk,jpppi)/(trn(ji,jj,jk,jppic)+rtrn)
+               zfactfe = trn(ji,jj,jk,jppfe)/(trn(ji,jj,jk,jppic)+rtrn)
+               zfactch = trn(ji,jj,jk,jppch)/(trn(ji,jj,jk,jppic)+rtrn)
+               tra(ji,jj,jk,jppic) = tra(ji,jj,jk,jppic) - zmortp
+               tra(ji,jj,jk,jpnpi) = tra(ji,jj,jk,jpnpi) - zmortp * zfactn
+               tra(ji,jj,jk,jpppi) = tra(ji,jj,jk,jpppi) - zmortp * zfactp
+               tra(ji,jj,jk,jppch) = tra(ji,jj,jk,jppch) - zmortp * zfactch
+               tra(ji,jj,jk,jppfe) = tra(ji,jj,jk,jppfe) - zmortp * zfactfe
+#if defined key_kriest
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zmortp
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) + zmortp * zfactn
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) + zmortp * zfactp
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + ztortp * xkr_dnano + zrespp * xkr_ddiat
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zmortp * zfactfe
+#else
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + zmortp
+               tra(ji,jj,jk,jpdon) = tra(ji,jj,jk,jpdon) + zmortp * zfactn
+               tra(ji,jj,jk,jpdop) = tra(ji,jj,jk,jpdop) + zmortp * zfactp
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) + zmortp * zfactfe
+#endif
+            END DO
+         END DO
+      END DO
+      !
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('pico')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_pico')
+      !
+   END SUBROUTINE p5z_pico
+
+
+   SUBROUTINE p5z_diat
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_diat  ***
+      !!
+      !! ** Purpose :   Compute the mortality terms for diatoms
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER  ::  ji, jj, jk
+      REAL(wp) ::  zfactfe,zfactsi,zfactch, zfactn, zfactp, zcompadi
+      REAL(wp) ::  zrespp2, ztortp2, zmortp2, zstep
+      REAL(wp) ::  zlim2, zlim1
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_diat')
+      !
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zcompadi = MAX( ( trn(ji,jj,jk,jpdia) - 1E-8), 0. )
+
+               !   Aggregation term for diatoms is increased in case of nutrient
+               !   stress as observed in reality. The stressed cells become more
+               !   sticky and coagulate to sink quickly out of the euphotic zone
+               !   -------------------------------------------------------------
+               zstep   = xstep
+# if defined key_degrad
+               zstep = zstep * facvol(ji,jj,jk)
+# endif
+               !  Phytoplankton squared mortality
+               !  -------------------------------
+               zlim2   = xlimdia(ji,jj,jk) * xlimdia(ji,jj,jk)
+               zlim1   = 0.25 * ( 1. - zlim2 ) / ( 0.25 + zlim2 ) 
+               zrespp2 = 1.e6 * zstep * (  wchld + wchldm * zlim1 ) * xdiss(ji,jj,jk) * zcompadi * trn(ji,jj,jk,jpdia)
+
+               !  Phytoplankton linear mortality 
+               !  ------------------------------
+               ztortp2 = mprat2 * xstep  * zcompadi
+               zmortp2 = zrespp2 + ztortp2
+
+               !   Update the arrays tra which contains the biological sources and sinks
+               !   ---------------------------------------------------------------------
+               zfactn  = trn(ji,jj,jk,jpndi) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               zfactp  = trn(ji,jj,jk,jppdi) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               zfactch = trn(ji,jj,jk,jpdch) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               zfactfe = trn(ji,jj,jk,jpdfe) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               zfactsi = trn(ji,jj,jk,jpdsi) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               tra(ji,jj,jk,jpdia) = tra(ji,jj,jk,jpdia) - zmortp2 
+               tra(ji,jj,jk,jpndi) = tra(ji,jj,jk,jpndi) - zmortp2 * zfactn
+               tra(ji,jj,jk,jppdi) = tra(ji,jj,jk,jppdi) - zmortp2 * zfactp
+               tra(ji,jj,jk,jpdch) = tra(ji,jj,jk,jpdch) - zmortp2 * zfactch
+               tra(ji,jj,jk,jpdfe) = tra(ji,jj,jk,jpdfe) - zmortp2 * zfactfe
+               tra(ji,jj,jk,jpdsi) = tra(ji,jj,jk,jpdsi) - zmortp2 * zfactsi
+               tra(ji,jj,jk,jpgsi) = tra(ji,jj,jk,jpgsi) + zmortp2 * zfactsi
+#if defined key_kriest
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zmortp2  
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) + zmortp2 * zfactn
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) + zmortp2 * zfactp
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + ztortp2 * xkr_ddiat + zrespp2 * xkr_daggr
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zmortp2 * zfactfe
+#else
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) + zrespp2 + 0.5 * ztortp2
+               tra(ji,jj,jk,jpgon) = tra(ji,jj,jk,jpgon) + (zrespp2 + 0.5 * ztortp2) * zfactn
+               tra(ji,jj,jk,jpgop) = tra(ji,jj,jk,jpgop) + (zrespp2 + 0.5 * ztortp2) * zfactp
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + (zrespp2 + 0.5 * ztortp2) * zfactfe
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + 0.5 * ztortp2
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) + 0.5 * ztortp2 * zfactn
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) + 0.5 * ztortp2 * zfactp
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + 0.5 * ztortp2 * zfactfe
+#endif
+            END DO
+         END DO
+      END DO
+      !
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('diat')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_diat')
+      !
+   END SUBROUTINE p5z_diat
+
+   SUBROUTINE p5z_mort_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_mort_init  ***
+      !!
+      !! ** Purpose :   Initialization of phytoplankton parameters
+      !!
+      !! ** Method  :   Read the nampismort namelist and check the parameters
+      !!      called at the first timestep
+      !!
+      !! ** input   :   Namelist nampismort
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampismort/ wchl, wchlp, wchld, wchldm, mprat, mpratp, mprat2
+      INTEGER :: ios                 ! Local integer output status for namelist read
+
+      REWIND( numnatp_ref )              ! Namelist nampismort in reference namelist : Pisces phytoplankton
+      READ  ( numnatp_ref, nampismort, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampismort in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampismort in configuration namelist : Pisces phytoplankton
+      READ  ( numnatp_cfg, nampismort, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampismort in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampismort )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for phytoplankton mortality, nampismort'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    quadratic mortality of phytoplankton      wchl      =', wchl
+         WRITE(numout,*) '    quadratic mortality of picophyto.         wchlp     =', wchlp
+         WRITE(numout,*) '    maximum quadratic mortality of diatoms    wchld     =', wchld
+         WRITE(numout,*) '    maximum quadratic mortality of diatoms    wchldm    =', wchldm
+         WRITE(numout,*) '    phytoplankton mortality rate              mprat     =', mprat
+         WRITE(numout,*) '    picophyto. mortality rate                 mpratp    =', mpratp
+         WRITE(numout,*) '    Diatoms mortality rate                    mprat2    =', mprat2
+      ENDIF
+
+   END SUBROUTINE p5z_mort_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_mort                    ! Empty routine
+   END SUBROUTINE p5z_mort
+#endif 
+
+   !!======================================================================
+END MODULE  p5zmort
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zprod.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zprod.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zprod.F90	(revision 5266)
@@ -0,0 +1,627 @@
+MODULE p5zprod
+   !!======================================================================
+   !!                         ***  MODULE p5zprod  ***
+   !! TOP :  Growth Rate of the two phytoplanktons groups 
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!             3.4  !  2011-05  (O. Aumont, C. Ethe) New parameterization of light limitation
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_pisces_quota'     PISCES bio-model with variable stoichiometry
+   !!----------------------------------------------------------------------
+   !!   p5z_prod       :   Compute the growth Rate of the two phytoplanktons groups
+   !!   p5z_prod_init  :   Initialization of the parameters for growth
+   !!   p5z_prod_alloc :   Allocate variables for growth
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE p4zopt          !  optical model
+   USE p5zlim          !  Co-limitations of differents nutrients
+   USE prtctl_trc      !  print control for debugging
+   USE iom             !  I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p5z_prod         ! called in p5zbio.F90
+   PUBLIC   p5z_prod_init    ! called in trcsms_pisces.F90
+   PUBLIC   p5z_prod_alloc
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::  pislope         !:
+   REAL(wp), PUBLIC ::  pislopep        !:
+   REAL(wp), PUBLIC ::  pislope2        !:
+   REAL(wp), PUBLIC ::  xadap           !:
+   REAL(wp), PUBLIC ::  excret          !:
+   REAL(wp), PUBLIC ::  excretp         !:
+   REAL(wp), PUBLIC ::  excret2         !:
+   REAL(wp), PUBLIC ::  bresp           !:
+   REAL(wp), PUBLIC ::  chlcpm          !:
+   REAL(wp), PUBLIC ::  chlcnm          !:
+   REAL(wp), PUBLIC ::  chlcdm          !:
+   REAL(wp), PUBLIC ::  chlcmin         !:
+   REAL(wp), PUBLIC ::  grosip          !:
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   prmaxn   !: optimal production = f(temperature)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   prmaxp   !: optimal production = f(temperature)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   prmaxd   !: optimal production = f(temperature)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   zdaylen
+   
+   REAL(wp) :: r1_rday                !: 1 / rday
+   REAL(wp) :: texcret                !: 1 - excret 
+   REAL(wp) :: texcretp               !: 1 - excretp 
+   REAL(wp) :: texcret2               !: 1 - excret2        
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zprod.F90 3160 2011-11-20 14:27:18Z cetlod $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE p5z_prod( kt , jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_prod  ***
+      !!
+      !! ** Purpose :   Compute the phytoplankton production depending on
+      !!              light, temperature and nutrient availability
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      !
+      INTEGER, INTENT(in) :: kt, jnt
+      !
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zsilfac, znanotot, zpicotot, zdiattot, zconctemp, zconctemp2
+      REAL(wp) ::   zration, zratiop, zratiof, zmax, zmax2, zsilim, ztn, zadap
+      REAL(wp) ::   zpronmax, zpropmax, zprofmax, zrat
+      REAL(wp) ::   zlim, zsilfac2, zsiborn, zprod, zprontot, zproptot, zprodtot
+      REAL(wp) ::   zmxltst, zmxlday, zprnutmax
+      REAL(wp) ::   zpislopen, zpislopep, zpislope2n, zpsichl
+      REAL(wp) ::   zrum, zcodel, zargu, zval, thetannm, thetanpm, thetandm
+      REAL(wp) ::   zrfact2
+      CHARACTER (len=25) :: charout
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zmixnano, zmixpico, zmixdiat, zstrn
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zpislopead, zpislopeadp, zpislopead2
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zprbio, zprpic, zprdia, zysopt
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zprchln, zprchlp, zprchld
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zprorcan, zprorcap, zprorcad 
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zprofed, zprofep, zprofen
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zprochln, zprochlp, zprochld
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zpronew, zpronewp, zpronewd
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zproreg, zproregp, zproregd
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zpropo4, zpropo4p, zpropo4d
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zprodopn, zprodopp, zprodopd
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zrespn, zrespp, zrespd, zprnut
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zcroissn, zcroissp, zcroissd
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_prod')
+      !
+      !  Allocate temporary workspace
+      CALL wrk_alloc( jpi, jpj,      zmixnano, zmixpico, zmixdiat, zstrn )
+      CALL wrk_alloc( jpi, jpj, jpk, zpislopead, zpislopeadp, zpislopead2, zysopt ) 
+      CALL wrk_alloc( jpi, jpj, jpk, zprdia, zprpic, zprbio, zprorcan, zprorcap, zprorcad )
+      CALL wrk_alloc( jpi, jpj, jpk, zprofed, zprofep, zprofen, zprochln, zprochlp, zprochld )
+      CALL wrk_alloc( jpi, jpj, jpk, zpronew, zpronewp, zpronewd, zproreg, zproregp, zproregd )
+      CALL wrk_alloc( jpi, jpj, jpk, zpropo4, zpropo4p, zpropo4d, zrespn, zrespp, zrespd, zprnut )
+      CALL wrk_alloc( jpi, jpj, jpk, zprchln, zprchlp, zprchld, zprodopn, zprodopp, zprodopd )
+      CALL wrk_alloc( jpi, jpj, jpk, zcroissp, zcroissn, zcroissd )
+      !
+      zprorcan(:,:,:) = 0._wp
+      zprorcap(:,:,:) = 0._wp
+      zprorcad(:,:,:) = 0._wp
+      zprofed (:,:,:) = 0._wp
+      zprofep (:,:,:) = 0._wp
+      zprofen (:,:,:) = 0._wp
+      zprochln(:,:,:) = 0._wp
+      zprochlp(:,:,:) = 0._wp
+      zprochld(:,:,:) = 0._wp
+      zpronew (:,:,:) = 0._wp
+      zpronewp(:,:,:) = 0._wp
+      zpronewd(:,:,:) = 0._wp
+      zproreg (:,:,:) = 0._wp
+      zproregp(:,:,:) = 0._wp
+      zproregd(:,:,:) = 0._wp
+      zpropo4 (:,:,:) = 0._wp
+      zpropo4p(:,:,:) = 0._wp
+      zpropo4d(:,:,:) = 0._wp
+      zprdia  (:,:,:) = 0._wp
+      zprpic  (:,:,:) = 0._wp
+      zprbio  (:,:,:) = 0._wp
+      zysopt  (:,:,:) = 0._wp
+      zrespn   (:,:,:) = 0._wp
+      zrespp   (:,:,:) = 0._wp
+      zrespd   (:,:,:) = 0._wp
+
+      ! Computation of the optimal production
+      zpsichl = 0.
+      thetannm = 0.25
+      thetanpm = 0.25
+      thetandm = 0.35
+
+      prmaxn(:,:,:) = ( 0.8_wp * (1. + zpsino3 * qnpmax + zpsichl ) ) * r1_rday * tgfunc(:,:,:)
+      prmaxp(:,:,:) = 0.6 / 0.8 * prmaxn(:,:,:) 
+      prmaxd(:,:,:) = 0.8 / 0.8 * prmaxn(:,:,:) 
+      zprnut(:,:,:) = 0.8_wp * r1_rday * tgfunc(:,:,:)
+
+      IF( lk_degrad )  THEN
+         prmaxn(:,:,:) = prmaxn(:,:,:) * facvol(:,:,:) 
+         prmaxp(:,:,:) = prmaxp(:,:,:) * facvol(:,:,:)
+         prmaxd(:,:,:) = prmaxd(:,:,:) * facvol(:,:,:)
+      ENDIF
+
+      ! compute the day length depending on latitude and the day
+      zrum = REAL( nday_year - 80, wp ) / REAL( nyear_len(1), wp )
+      zcodel = ASIN(  SIN( zrum * rpi * 2._wp ) * SIN( rad * 23.5_wp )  )
+
+      ! day length in hours
+      zstrn(:,:) = 0.
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zargu = TAN( zcodel ) * TAN( gphit(ji,jj) * rad )
+            zargu = MAX( -1., MIN(  1., zargu ) )
+            zstrn(ji,jj) = MAX( 0.0, 24. - 2. * ACOS( zargu ) / rad / 15. )
+         END DO
+      END DO
+
+         ! Impact of the day duration on phytoplankton growth
+      DO jk = 1, jpkm1
+         DO jj = 1 ,jpj
+            DO ji = 1, jpi
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                  zval = MAX( 1., zstrn(ji,jj) )
+                  zval = 1.5 * zval / (12. + zval)
+                  zprbio(ji,jj,jk) = prmaxn(ji,jj,jk) * zval
+                  zprpic(ji,jj,jk) = prmaxp(ji,jj,jk) * zval
+                  zprdia(ji,jj,jk) = prmaxd(ji,jj,jk) * zval
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! Maximum light intensity
+      zdaylen(:,:) = MAX(1., zstrn(:,:)) / 24.
+      WHERE( zstrn(:,:) < 1.e0 ) zstrn(:,:) = 24.
+      zstrn(:,:) = 24. / zstrn(:,:)
+
+      DO jk = 1, jpkm1
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+                  ! Computation of the P-I slope for nanos and diatoms
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                  ztn         = MAX( 0., tsn(ji,jj,jk,jp_tem) - 15. )
+                  zadap       = xadap * ztn / ( 2.+ ztn )
+                  znanotot    = enano(ji,jj,jk) * zstrn(ji,jj)
+                  zpicotot    = epico(ji,jj,jk) * zstrn(ji,jj)
+                  zdiattot    = ediat(ji,jj,jk) * zstrn(ji,jj)
+                  !
+                  zpislopead (ji,jj,jk) = pislope * trn(ji,jj,jk,jpnch)    &
+                  &                       /( trn(ji,jj,jk,jpphy) * 12. + rtrn)
+                  zpislopeadp(ji,jj,jk) = pislopep * ( 1. + zadap * EXP( -0.5 * zpicotot ) )   &
+                  &                       * trn(ji,jj,jk,jppch) /( trn(ji,jj,jk,jppic) * 12. + rtrn)
+                  zpislopead2(ji,jj,jk) = pislope2 * trn(ji,jj,jk,jpdch)    &
+                     &                    /( trn(ji,jj,jk,jpdia) * 12. + rtrn)
+                  zpislopen   = zpislopead (ji,jj,jk) / ( prmaxn(ji,jj,jk) * rday * xlimphy(ji,jj,jk) + rtrn )
+                  zpislopep   = zpislopeadp(ji,jj,jk) / ( prmaxp(ji,jj,jk) * rday * xlimpic(ji,jj,jk) + rtrn )
+                  zpislope2n  = zpislopead2(ji,jj,jk) / ( prmaxd(ji,jj,jk) * rday * xlimdia(ji,jj,jk) + rtrn )
+
+                  ! Computation of production function for Carbon
+                  !  ---------------------------------------------
+                  zprbio(ji,jj,jk) = zprbio(ji,jj,jk) * ( 1.- EXP( -zpislopen  * znanotot )  )
+                  zprpic(ji,jj,jk) = zprpic(ji,jj,jk) * ( 1.- EXP( -zpislopep  * zpicotot )  )
+                  zprdia(ji,jj,jk) = zprdia(ji,jj,jk) * ( 1.- EXP( -zpislope2n * zdiattot )  )
+
+                  ! Computation of production function for Chlorophyll
+                  !  -------------------------------------------------
+                  zprchln(ji,jj,jk) = prmaxn(ji,jj,jk) * ( 1.- EXP( -zpislopen  * enano(ji,jj,jk) )  )
+                  zprchlp(ji,jj,jk) = prmaxp(ji,jj,jk) * ( 1.- EXP( -zpislopep  * epico(ji,jj,jk) )  )
+                  zprchld(ji,jj,jk) = prmaxd(ji,jj,jk) * ( 1.- EXP( -zpislope2n * ediat(ji,jj,jk) )  )
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+              IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                  !    Si/C of diatoms
+                  !    ------------------------
+                  !    Si/C increases with iron stress and silicate availability
+                  !    Si/C is arbitrariliy increased for very high Si concentrations
+                  !    to mimic the very high ratios observed in the Southern Ocean (silpot2)
+                  zlim  = trn(ji,jj,jk,jpsil) / ( trn(ji,jj,jk,jpsil) + xksi1 )
+                  zsilim = MIN( zprdia(ji,jj,jk) / ( prmaxd(ji,jj,jk) + rtrn ), xlimsi(ji,jj,jk) )
+                  zsilfac = 4.4 * EXP( -4.23 * zsilim ) * MAX( 0.e0, MIN( 1., 2.2 * ( zlim - 0.5 ) )  ) + 1.e0
+                  zsiborn = trn(ji,jj,jk,jpsil) * trn(ji,jj,jk,jpsil) * trn(ji,jj,jk,jpsil)
+                  IF (gphit(ji,jj) < -30 ) THEN
+                    zsilfac2 = 1. + 2. * zsiborn / ( zsiborn + xksi2**3 )
+                  ELSE
+                    zsilfac2 = 1. +      zsiborn / ( zsiborn + xksi2**3 )
+                  ENDIF
+                  zysopt(ji,jj,jk) = grosip * zlim * zsilfac * zsilfac2
+              ENDIF
+            END DO
+         END DO
+      END DO
+
+      !  Computation of the limitation term due to a mixed layer deeper than the euphotic depth
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zmxltst = MAX( 0.e0, hmld(ji,jj) - heup(ji,jj) )
+            zmxlday = zmxltst * zmxltst * r1_rday
+            zmixnano(ji,jj) = 1. - zmxlday / ( 2. + zmxlday )
+            zmixpico(ji,jj) = 1. - zmxlday / ( 2. + zmxlday )
+            zmixdiat(ji,jj) = 1. - zmxlday / ( 4. + zmxlday )
+         END DO
+      END DO
+ 
+      !  Mixed-layer effect on production                                                                               
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
+                  zprbio(ji,jj,jk)  = zprbio(ji,jj,jk) * zmixnano(ji,jj)
+                  zprpic(ji,jj,jk)  = zprpic(ji,jj,jk) * zmixpico(ji,jj)
+                  zprdia(ji,jj,jk)  = zprdia(ji,jj,jk) * zmixdiat(ji,jj)
+                  zprchln(ji,jj,jk) = zprchln(ji,jj,jk) * zmixnano(ji,jj)
+                  zprchlp(ji,jj,jk) = zprchlp(ji,jj,jk) * zmixpico(ji,jj)
+                  zprchld(ji,jj,jk) = zprchld(ji,jj,jk) * zmixdiat(ji,jj)
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! Computation of the various production terms of nanophytoplankton 
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                  !  production terms for nanophyto.
+                  zprorcan(ji,jj,jk) = zprbio(ji,jj,jk)  * xlimphy(ji,jj,jk) * trn(ji,jj,jk,jpphy) * rfact2
+                  !
+                  zrespn(ji,jj,jk) = zprorcan(ji,jj,jk) * zpsichl
+                  zration = trn(ji,jj,jk,jpnph) / ( trn(ji,jj,jk,jpphy) + rtrn )
+                  zratiop = trn(ji,jj,jk,jppph) / ( trn(ji,jj,jk,jpphy) + rtrn )
+                  zratiof = trn(ji,jj,jk,jpnfe) / ( trn(ji,jj,jk,jpphy) + rtrn )
+                  zprnutmax = zprnut(ji,jj,jk) * fvnuptk(ji,jj,jk) / rno3 * trn(ji,jj,jk,jpphy) * rfact2
+                  ! Uptake of nitrogen
+                  zrat = MIN( 1., zration / (xqnnmax(ji,jj,jk) + rtrn) ) 
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05))
+                  zpronmax = zprnutmax * zmax * MAX(0., MIN(1., ( zratiop - xqpnmin(ji,jj,jk) )   &
+                  &          / ( xqpnmax(ji,jj,jk) - xqpnmin(ji,jj,jk) ), xlimnfe(ji,jj,jk) ) )
+                  zpronew(ji,jj,jk) = zpronmax * zdaylen(ji,jj) * xnanono3(ji,jj,jk)
+                  zproreg(ji,jj,jk) = zpronmax * xnanonh4(ji,jj,jk)
+                  ! Uptake of phosphorus
+                  zrat = MIN( 1., zratiop / (xqpnmax(ji,jj,jk) + rtrn) )
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05))
+                  zpropmax = zprnutmax * zmax * xlimnfe(ji,jj,jk)
+                  zpropo4(ji,jj,jk) = zpropmax * xnanopo4(ji,jj,jk)
+                  zprodopn(ji,jj,jk) = zpropmax * xnanodop(ji,jj,jk)
+                  ! Uptake of iron
+                  zrat = MIN( 1., zratiof / qfnmax )
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05))
+                  zprofmax = zprnutmax * qfnmax * zmax
+                  zprofen(ji,jj,jk) = zprofmax * xnanofer(ji,jj,jk) * ( 4. - 4.5 * xlimnfe(ji,jj,jk)    &
+                  &          / ( xlimnfe(ji,jj,jk) + 0.2 ) ) * (1. + 0.8 * xnanono3(ji,jj,jk) / ( rtrn  &
+                  &          + xnanono3(ji,jj,jk) + xnanonh4(ji,jj,jk) ) * (1. - xnanofer(ji,jj,jk) ) )
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! Computation of the various production terms of picophytoplankton 
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                  !  production terms for picophyto.
+                  zprorcap(ji,jj,jk) = zprpic(ji,jj,jk)  * xlimpic(ji,jj,jk) * trn(ji,jj,jk,jppic) * rfact2
+                  !
+                  zrespp(ji,jj,jk) = zprorcap(ji,jj,jk) * zpsichl
+                  zration = trn(ji,jj,jk,jpnpi) / ( trn(ji,jj,jk,jppic) + rtrn )
+                  zratiop = trn(ji,jj,jk,jpppi) / ( trn(ji,jj,jk,jppic) + rtrn )
+                  zratiof = trn(ji,jj,jk,jppfe) / ( trn(ji,jj,jk,jppic) + rtrn )
+                  zprnutmax = zprnut(ji,jj,jk) * fvpuptk(ji,jj,jk) / rno3 * trn(ji,jj,jk,jppic) * rfact2
+                  ! Uptake of nitrogen
+                  zrat = MIN( 1., zration / (xqnpmax(ji,jj,jk) + rtrn) )
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05))
+                  zpronmax = zprnutmax * zmax * MAX(0., MIN(1., ( zratiop - xqppmin(ji,jj,jk) )   &
+                  &          / ( xqppmax(ji,jj,jk) - xqppmin(ji,jj,jk) ), xlimpfe(ji,jj,jk) ) )
+                  zpronewp(ji,jj,jk) = zpronmax * zdaylen(ji,jj) * xpicono3(ji,jj,jk) 
+                  zproregp(ji,jj,jk) = zpronmax * xpiconh4(ji,jj,jk)
+                  ! Uptake of phosphorus
+                  zrat = MIN( 1., zratiop / (xqppmax(ji,jj,jk) + rtrn) )
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05))
+                  zpropmax = zprnutmax * zmax * xlimpfe(ji,jj,jk)
+                  zpropo4p(ji,jj,jk) = zpropmax * xpicopo4(ji,jj,jk)
+                  zprodopp(ji,jj,jk) = zpropmax * xpicodop(ji,jj,jk)
+                  ! Uptake of iron
+                  zrat = MIN( 1., zratiof / qfpmax )
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05))
+                  zprofmax = zprnutmax * qfpmax * zmax
+                  zprofep(ji,jj,jk) = zprofmax * xpicofer(ji,jj,jk) * ( 4. - 4.5 * xlimpfe(ji,jj,jk)   &
+                  &          / ( xlimpfe(ji,jj,jk) + 0.2 ) ) * (1. + 0.8 * xpicono3(ji,jj,jk) / ( rtrn   &
+                  &          + xpicono3(ji,jj,jk) + xpiconh4(ji,jj,jk) ) * (1. - xpicofer(ji,jj,jk) ) )
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! Computation of the various production terms of diatoms
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                  !  production terms for diatomees
+                  zprorcad(ji,jj,jk) = zprdia(ji,jj,jk) * xlimdia(ji,jj,jk) * trn(ji,jj,jk,jpdia) * rfact2
+                  ! Computation of the respiration term according to pahlow 
+                  ! & oschlies (2013)
+                  zrespd(ji,jj,jk) = zprorcad(ji,jj,jk) * zpsichl
+                  !
+                  zration = trn(ji,jj,jk,jpndi) / ( trn(ji,jj,jk,jpdia) + rtrn )
+                  zratiop = trn(ji,jj,jk,jppdi) / ( trn(ji,jj,jk,jpdia) + rtrn )
+                  zratiof = trn(ji,jj,jk,jpdfe) / ( trn(ji,jj,jk,jpdia) + rtrn )
+                  zprnutmax = zprnut(ji,jj,jk) * fvduptk(ji,jj,jk) / rno3 * trn(ji,jj,jk,jpdia) * rfact2
+                  ! Uptake of nitrogen
+                  zrat = MIN( 1., zration / (xqndmax(ji,jj,jk) + rtrn) )
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05)) 
+                  zpronmax = zprnutmax * zmax * MAX(0., MIN(1., ( zratiop - xqpdmin(ji,jj,jk) )   &
+                  &          / ( xqpdmax(ji,jj,jk) - xqpdmin(ji,jj,jk) ), xlimdfe(ji,jj,jk) ) )
+                  zpronewd(ji,jj,jk) = zpronmax * zdaylen(ji,jj) * xdiatno3(ji,jj,jk)
+                  zproregd(ji,jj,jk) = zpronmax * xdiatnh4(ji,jj,jk)
+                  ! Uptake of phosphorus
+                  zrat = MIN( 1., zratiop / (xqpdmax(ji,jj,jk) + rtrn) )
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05)) 
+                  zpropmax = zprnutmax * zmax * xlimdfe(ji,jj,jk)
+                  zpropo4d(ji,jj,jk) = zpropmax * xdiatpo4(ji,jj,jk)
+                  zprodopd(ji,jj,jk) = zpropmax * xdiatdop(ji,jj,jk)
+                  ! Uptake of iron
+                  zrat = MIN( 1., zratiof / qfdmax )
+                  zmax = MAX(0., MIN(1., (1. - zrat)/ (1.05 - zrat) * 1.05))
+                  zprofmax = zprnutmax * qfdmax * zmax
+                  zprofed(ji,jj,jk) = zprofmax * xdiatfer(ji,jj,jk) * ( 4. - 4.5 * xlimdfe(ji,jj,jk)     &
+                  &          / ( xlimdfe(ji,jj,jk) + 0.2 ) ) * (1. + 0.8 * xdiatno3(ji,jj,jk) / ( rtrn   &
+                  &          + xdiatno3(ji,jj,jk) + xdiatnh4(ji,jj,jk) ) * (1. - xdiatfer(ji,jj,jk) ) )
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                     !  production terms for nanophyto. ( chlorophyll )
+                  zprod = rday * (zpronew(ji,jj,jk) + zproreg(ji,jj,jk)) * zprchln(ji,jj,jk) * xlimphy(ji,jj,jk)
+                  zprochln(ji,jj,jk) = thetannm * zprod / ( zpislopead(ji,jj,jk) * enano(ji,jj,jk) +rtrn )
+                  zprochln(ji,jj,jk) = MAX(zprochln(ji,jj,jk), chlcmin * 12. * zprorcan (ji,jj,jk) )
+                     !  production terms for picophyto. ( chlorophyll )
+                  zprod = rday * (zpronewp(ji,jj,jk) + zproregp(ji,jj,jk)) * zprchlp(ji,jj,jk) * xlimpic(ji,jj,jk)
+                  zprochlp(ji,jj,jk) = thetanpm * zprod / ( zpislopeadp(ji,jj,jk) * epico(ji,jj,jk) +rtrn )
+                  zprochlp(ji,jj,jk) = MAX(zprochlp(ji,jj,jk), chlcmin * 12. * zprorcap(ji,jj,jk) )
+                  !  production terms for diatomees ( chlorophyll )
+                  zprod = rday * (zpronewd(ji,jj,jk) + zproregd(ji,jj,jk)) * zprchld(ji,jj,jk) * xlimdia(ji,jj,jk)
+                  zprochld(ji,jj,jk) = thetandm * zprod / ( zpislopead2(ji,jj,jk) * ediat(ji,jj,jk) +rtrn )
+                  zprochld(ji,jj,jk) = MAX(zprochld(ji,jj,jk), chlcmin * 12. * zprorcad(ji,jj,jk) )
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      !   Update the arrays TRA which contain the biological sources and sinks
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+           DO ji =1 ,jpi
+              zprontot = zpronew(ji,jj,jk) + zproreg(ji,jj,jk)
+              zproptot = zpronewp(ji,jj,jk) + zproregp(ji,jj,jk)
+              zprodtot = zpronewd(ji,jj,jk) + zproregd(ji,jj,jk)
+              tra(ji,jj,jk,jppo4) = tra(ji,jj,jk,jppo4) - zpropo4(ji,jj,jk) - zpropo4d(ji,jj,jk)  &
+              &                     - zpropo4p(ji,jj,jk)
+              tra(ji,jj,jk,jpno3) = tra(ji,jj,jk,jpno3) - zpronew(ji,jj,jk) - zpronewd(ji,jj,jk)  &
+              &                     - zpronewp(ji,jj,jk)
+              tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) - zproreg(ji,jj,jk) - zproregd(ji,jj,jk)  &
+              &                     - zproregp(ji,jj,jk)
+              tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) + zprorcan(ji,jj,jk) * texcret     &
+                 &                  - zpsino3 * zpronew(ji,jj,jk) - zpsinh4 * zproreg(ji,jj,jk)   &
+                 &                  - zrespn(ji,jj,jk) 
+              zcroissn(ji,jj,jk) = tra(ji,jj,jk,jpphy) / rfact2/ (trn(ji,jj,jk,jpphy) + rtrn)
+              tra(ji,jj,jk,jpnph) = tra(ji,jj,jk,jpnph) + zprontot * texcret
+              tra(ji,jj,jk,jppph) = tra(ji,jj,jk,jppph) + zpropo4(ji,jj,jk) * texcret   &
+              &                     + zprodopn(ji,jj,jk) * texcret
+              tra(ji,jj,jk,jpnch) = tra(ji,jj,jk,jpnch) + zprochln(ji,jj,jk) * texcret
+              tra(ji,jj,jk,jpnfe) = tra(ji,jj,jk,jpnfe) + zprofen(ji,jj,jk) * texcret
+              tra(ji,jj,jk,jppic) = tra(ji,jj,jk,jppic) + zprorcap(ji,jj,jk) * texcretp     &
+                 &                  - zpsino3 * zpronewp(ji,jj,jk) - zpsinh4 * zproregp(ji,jj,jk)   &
+                 &                  - zrespp(ji,jj,jk) 
+              zcroissp(ji,jj,jk) = tra(ji,jj,jk,jppic) / rfact2/ (trn(ji,jj,jk,jppic) + rtrn)
+              tra(ji,jj,jk,jpnpi) = tra(ji,jj,jk,jpnpi) + zproptot * texcretp
+              tra(ji,jj,jk,jpppi) = tra(ji,jj,jk,jpppi) + zpropo4p(ji,jj,jk) * texcretp   &
+              &                     + zprodopp(ji,jj,jk) * texcretp
+              tra(ji,jj,jk,jppch) = tra(ji,jj,jk,jppch) + zprochlp(ji,jj,jk) * texcretp
+              tra(ji,jj,jk,jppfe) = tra(ji,jj,jk,jppfe) + zprofep(ji,jj,jk) * texcretp
+              tra(ji,jj,jk,jpdia) = tra(ji,jj,jk,jpdia) + zprorcad(ji,jj,jk) * texcret2   &
+                 &                  - zpsino3 * zpronewd(ji,jj,jk) - zpsinh4 * zproregd(ji,jj,jk)   &
+                 &                  - zrespd(ji,jj,jk) 
+              zcroissd(ji,jj,jk) = tra(ji,jj,jk,jpdia) / rfact2 / (trn(ji,jj,jk,jpdia) + rtrn)
+              tra(ji,jj,jk,jpndi) = tra(ji,jj,jk,jpndi) + zprodtot * texcret2
+              tra(ji,jj,jk,jppdi) = tra(ji,jj,jk,jppdi) + zpropo4d(ji,jj,jk) * texcret2   &
+              &                     + zprodopd(ji,jj,jk) * texcret2
+              tra(ji,jj,jk,jpdch) = tra(ji,jj,jk,jpdch) + zprochld(ji,jj,jk) * texcret2
+              tra(ji,jj,jk,jpdfe) = tra(ji,jj,jk,jpdfe) + zprofed(ji,jj,jk) * texcret2
+              tra(ji,jj,jk,jpdsi) = tra(ji,jj,jk,jpdsi) + zprorcad(ji,jj,jk) * zysopt(ji,jj,jk) * texcret2
+              tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + excret2 * zprorcad(ji,jj,jk) + excret * zprorcan(ji,jj,jk)  &
+              &                     + excretp * zprorcap(ji,jj,jk)
+              tra(ji,jj,jk,jpdon) = tra(ji,jj,jk,jpdon) + excret2 * zprodtot + excret * zprontot   &
+              &                     + excretp * zproptot
+              tra(ji,jj,jk,jpdop) = tra(ji,jj,jk,jpdop) + excret2 * zpropo4d(ji,jj,jk) + excret * zpropo4(ji,jj,jk)   &
+              &    - texcret * zprodopn(ji,jj,jk) - texcret2 * zprodopd(ji,jj,jk) + excretp * zpropo4p(ji,jj,jk)     &
+              &    - texcretp * zprodopp(ji,jj,jk)
+              tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) + o2ut * ( zproreg(ji,jj,jk) + zproregd(ji,jj,jk)   &
+                 &                + zproregp(ji,jj,jk) ) + ( o2ut + o2nit ) * ( zpronew(ji,jj,jk)           &
+                 &                + zpronewd(ji,jj,jk) + zpronewp(ji,jj,jk) )   &
+                 &                - o2ut * ( zrespn(ji,jj,jk) + zrespp(ji,jj,jk) + zrespd(ji,jj,jk) )
+              tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) - texcret * zprofen(ji,jj,jk) - texcret2 * zprofed(ji,jj,jk)  &
+              &                     - texcretp * zprofep(ji,jj,jk)
+              tra(ji,jj,jk,jpsil) = tra(ji,jj,jk,jpsil) - texcret2 * zprorcad(ji,jj,jk) * zysopt(ji,jj,jk)
+              tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) - zprorcan(ji,jj,jk) - zprorcad(ji,jj,jk) - zprorcap(ji,jj,jk)  &
+              &                     + zpsino3 * zpronew(ji,jj,jk) + zpsinh4 * zproreg(ji,jj,jk)   &
+              &                     + zpsino3 * zpronewp(ji,jj,jk) + zpsinh4 * zproregp(ji,jj,jk)   &
+              &                     + zpsino3 * zpronewd(ji,jj,jk) + zpsinh4 * zproregd(ji,jj,jk)  &
+              &                     + zrespn(ji,jj,jk) + zrespd(ji,jj,jk) + zrespp(ji,jj,jk) 
+              tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) + rno3 * ( zpronew(ji,jj,jk) + zpronewd(ji,jj,jk)  &
+              &                     + zpronewp(ji,jj,jk) ) - rno3 * ( zproreg(ji,jj,jk) + zproregd(ji,jj,jk)     &
+              &                     + zproregp(ji,jj,jk) ) 
+          END DO
+        END DO
+     END DO
+
+     ! Total primary production per year
+     tpp = tpp + glob_sum( ( zprorcan(:,:,:) + zprorcad(:,:,:) + zprorcap(:,:,:) ) * cvol(:,:,:) )
+
+     IF( ln_diatrc ) THEN
+         !
+         zrfact2 = 1.e3 * rfact2r  ! conversion from mol/L/timestep into mol/m3/s
+         IF( lk_iomput ) THEN
+           IF( jnt == nrdttrc ) THEN
+              CALL iom_put( "PPPHY"  , zprorcan(:,:,:) * zrfact2 * tmask(:,:,:) )  ! primary production by nanophyto
+              CALL iom_put( "PPPHYP" , zprorcap(:,:,:) * zrfact2 * tmask(:,:,:) )  ! primary production by nanophyto
+              CALL iom_put( "PPPHY2" , zprorcad(:,:,:) * zrfact2 * tmask(:,:,:) )  ! primary production by diatom
+              CALL iom_put( "PPNEWN" , zpronew (:,:,:) * zrfact2 * tmask(:,:,:) )  ! new primary production by nanophyto
+              CALL iom_put( "PPNEWP" , zpronewp(:,:,:) * zrfact2 * tmask(:,:,:) )  ! new primary production by nanophyto
+              CALL iom_put( "PPNEWD" , zpronewd(:,:,:) * zrfact2 * tmask(:,:,:) )  ! new primary production by diatom
+              CALL iom_put( "PBSi"   , zprorcad(:,:,:) * zrfact2 * tmask(:,:,:) * zysopt(:,:,:) ) ! biogenic silica production
+              CALL iom_put( "PFeD"   , zprofed (:,:,:) * zrfact2 * tmask(:,:,:) )  ! biogenic iron production by diatom
+              CALL iom_put( "PFeP"   , zprofep (:,:,:) * zrfact2 * tmask(:,:,:) )  ! biogenic iron production by diatom
+              CALL iom_put( "PFeN"   , zprofen (:,:,:) * zrfact2 * tmask(:,:,:) )  ! biogenic iron production by nanophyto
+              CALL iom_put( "Mumax"  , prmaxn(:,:,:) * tmask(:,:,:) )  ! Maximum growth rate
+              CALL iom_put( "MuN"    , zprbio(:,:,:) * xlimphy(:,:,:) * tmask(:,:,:) )  ! Realized growth rate for nanophyto
+              CALL iom_put( "MuP"    , zprpic(:,:,:) * xlimpic(:,:,:) * tmask(:,:,:) )  ! Realized growth rate for nanophyto
+              CALL iom_put( "MuD"    , zprdia(:,:,:) * xlimdia(:,:,:) * tmask(:,:,:) )  ! Realized growth rate for diatoms
+              CALL iom_put( "MunetN"    , zcroissn(:,:,:) * tmask(:,:,:) )  ! Realized growth rate for nanophyto
+              CALL iom_put( "MunetP"    , zcroissp(:,:,:) * tmask(:,:,:) )  ! Realized growth rate for nanophyto
+              CALL iom_put( "MunetD"    , zcroissd(:,:,:) * tmask(:,:,:) )  ! Realized growth rate for diatoms
+              CALL iom_put( "LNlight", zprbio (:,:,:) / (prmaxn(:,:,:) + rtrn) * tmask(:,:,:) )  ! light limitation term
+              CALL iom_put( "LPlight", zprpic (:,:,:) / (prmaxp(:,:,:) + rtrn) * tmask(:,:,:) )  ! light limitation term
+              CALL iom_put( "LDlight", zprdia (:,:,:) / (prmaxd(:,:,:) + rtrn) * tmask(:,:,:) )  ! light limitation term
+           ENDIF
+         ELSE
+              trc3d(:,:,:,jp_pcs0_3d + 4)  = zprorcan(:,:,:) * zrfact2 * tmask(:,:,:)
+              trc3d(:,:,:,jp_pcs0_3d + 5)  = zprorcad(:,:,:) * zrfact2 * tmask(:,:,:)
+              trc3d(:,:,:,jp_pcs0_3d + 6)  = zpronew (:,:,:) * zrfact2 * tmask(:,:,:)
+              trc3d(:,:,:,jp_pcs0_3d + 7)  = zpronewd(:,:,:) * zrfact2 * tmask(:,:,:)
+              trc3d(:,:,:,jp_pcs0_3d + 8)  = zprorcad(:,:,:) * zrfact2 * tmask(:,:,:) * zysopt(:,:,:)
+              trc3d(:,:,:,jp_pcs0_3d + 9)  = zprofed (:,:,:) * zrfact2 * tmask(:,:,:)
+#  if ! defined key_kriest
+              trc3d(:,:,:,jp_pcs0_3d + 10) = zprofen (:,:,:) * zrfact2 * tmask(:,:,:)
+#  endif
+         ENDIF
+         !
+      ENDIF
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('prod')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi, jpj,      zmixnano, zmixpico, zmixdiat, zstrn )
+      CALL wrk_dealloc( jpi, jpj, jpk, zpislopead, zpislopeadp, zpislopead2, zysopt )                           
+      CALL wrk_dealloc( jpi, jpj, jpk, zprdia, zprpic, zprbio, zprorcan, zprorcap, zprorcad )
+      CALL wrk_dealloc( jpi, jpj, jpk, zprofed, zprofep, zprofen, zprochln, zprochlp, zprochld ) 
+      CALL wrk_dealloc( jpi, jpj, jpk, zpronew, zpronewp, zpronewd, zproreg, zproregp, zproregd )
+      CALL wrk_dealloc( jpi, jpj, jpk, zpropo4, zpropo4p, zpropo4d, zrespn, zrespp, zrespd, zprnut )
+      CALL wrk_dealloc( jpi, jpj, jpk, zprchln, zprchlp, zprchld, zprodopn, zprodopp, zprodopd )
+      CALL wrk_dealloc( jpi, jpj, jpk, zcroissp, zcroissn, zcroissd )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_prod')
+      !
+   END SUBROUTINE p5z_prod
+
+
+   SUBROUTINE p5z_prod_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_prod_init  ***
+      !!
+      !! ** Purpose :   Initialization of phytoplankton production parameters
+      !!
+      !! ** Method  :   Read the nampisprod namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampisprod
+      !!----------------------------------------------------------------------
+      !
+      NAMELIST/nampisprod/ pislope, pislopep, pislope2, xadap, bresp, excret, excretp, excret2,  &
+         &                 chlcnm, chlcpm, chlcdm, chlcmin, grosip
+
+      INTEGER :: ios                 ! Local integer output status for namelist read
+      !!----------------------------------------------------------------------
+
+      REWIND( numnatp_ref )              ! Namelist nampisprod in reference namelist : Pisces phytoplankton production
+      READ  ( numnatp_ref, nampisprod, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisprod in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampisprod in configuration namelist : Pisces phytoplankton production
+      READ  ( numnatp_cfg, nampisprod, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisprod in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampisprod )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for phytoplankton growth, nampisprod'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    mean Si/C ratio                           grosip       =', grosip
+         WRITE(numout,*) '    P-I slope                                 pislope      =', pislope
+         WRITE(numout,*) '    Acclimation factor to low light           xadap       =', xadap
+         WRITE(numout,*) '    excretion ratio of nanophytoplankton      excret       =', excret
+         WRITE(numout,*) '    excretion ratio of picophytoplankton      excretp      =', excretp
+         WRITE(numout,*) '    excretion ratio of diatoms                excret2      =', excret2
+         WRITE(numout,*) '    basal respiration in phytoplankton        bresp        =', bresp
+         WRITE(numout,*) '    Maximum Chl/C in phytoplankton            chlcmin      =', chlcmin
+         WRITE(numout,*) '    P-I slope  for diatoms                    pislope2     =', pislope2
+         WRITE(numout,*) '    P-I slope  for picophytoplankton          pislopep     =', pislopep
+         WRITE(numout,*) '    Minimum Chl/C in nanophytoplankton        chlcnm       =', chlcnm
+         WRITE(numout,*) '    Minimum Chl/C in picophytoplankton        chlcpm       =', chlcpm
+         WRITE(numout,*) '    Minimum Chl/C in diatoms                  chlcdm       =', chlcdm
+      ENDIF
+      !
+      r1_rday   = 1._wp / rday 
+      texcret   = 1._wp - excret
+      texcretp  = 1._wp - excretp
+      texcret2  = 1._wp - excret2
+      tpp       = 0._wp
+      !
+   END SUBROUTINE p5z_prod_init
+
+
+   INTEGER FUNCTION p5z_prod_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_prod_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( prmaxn(jpi,jpj,jpk), prmaxp(jpi,jpj,jpk), prmaxd(jpi,jpj,jpk),  &
+      &          zdaylen(jpi,jpj), STAT = p5z_prod_alloc )
+      !
+      IF( p5z_prod_alloc /= 0 ) CALL ctl_warn('p5z_prod_alloc : failed to allocate arrays.')
+      !
+   END FUNCTION p5z_prod_alloc
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_prod                    ! Empty routine
+   END SUBROUTINE p5z_prod
+#endif 
+
+   !!======================================================================
+END MODULE  p5zprod
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zrem.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zrem.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zrem.F90	(revision 5266)
@@ -0,0 +1,434 @@
+MODULE p5zrem
+   !!======================================================================
+   !!                         ***  MODULE p5zrem  ***
+   !! TOP :   PISCES Compute remineralization/dissolution of organic compounds
+   !!=========================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!             3.4  !  2011-06  (O. Aumont, C. Ethe) Quota model for iron
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_top'       and                                      TOP models
+   !!   'key_pisces_quota'     PISCES bio-model with variable stoichiometry
+   !!----------------------------------------------------------------------
+   !!   p5z_rem       :  Compute remineralization/dissolution of organic compounds
+   !!   p5z_rem_init  :  Initialisation of parameters for remineralisation
+   !!   p5z_rem_alloc :  Allocate remineralisation variables
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE p4zopt          !  optical model
+   USE p4zche          !  chemical model
+   USE p5zprod         !  Growth rate of the 2 phyto groups
+   USE p5zmeso         !  Sources and sinks of mesozooplankton
+   USE p4zint          !  interpolation and computation of various fields
+   USE p5zlim
+   USE prtctl_trc      !  print control for debugging
+   USE iom             !  I/O manager
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p5z_rem         ! called in p4zbio.F90
+   PUBLIC   p5z_rem_init    ! called in trcsms_pisces.F90
+   PUBLIC   p5z_rem_alloc
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::  xremikc    !: remineralisation rate of POC 
+   REAL(wp), PUBLIC ::  xremikn    !: remineralisation rate of POC 
+   REAL(wp), PUBLIC ::  xremikp    !: remineralisation rate of POC 
+   REAL(wp), PUBLIC ::  xremipc    !: remineralisation rate of DOC
+   REAL(wp), PUBLIC ::  xremipn    !: remineralisation rate of DOC
+   REAL(wp), PUBLIC ::  xremipp    !: remineralisation rate of DOC
+   REAL(wp), PUBLIC ::  nitrif     !: NH4 nitrification rate 
+   REAL(wp), PUBLIC ::  xsirem     !: remineralisation rate of POC 
+   REAL(wp), PUBLIC ::  xsiremlab  !: fast remineralisation rate of POC 
+   REAL(wp), PUBLIC ::  xsilab     !: fraction of labile biogenic silica 
+   REAL(wp), PUBLIC ::  oxymin     !: halk saturation constant for anoxia 
+
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   denitrc     !: denitrification array
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zrem.F90 3160 2011-11-20 14:27:18Z cetlod $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE p5z_rem( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_rem  ***
+      !!
+      !! ** Purpose :   Compute remineralization/scavenging of organic compounds
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      !
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      !
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zremip, zremik, zremikc, zremikn, zremikp, zsiremin 
+      REAL(wp) ::   zsatur, zsatur2, znusil, znusil2, zdep, zdepmin, zfactdep
+      REAL(wp) ::   zbactfer, zopoc, zopon, zopop, zopoc2, zopon2, zopop2, zofer, zolimit
+      REAL(wp) ::   zosil, ztem, zdenitnh4, zolimic, zolimin, zolimip, zdenitrn, zdenitrp
+#if ! defined key_kriest
+      REAL(wp) ::   zofer2
+#endif
+      REAL(wp) ::   zonitr, zstep, zrfact2
+      CHARACTER (len=25) :: charout
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: ztempbac 
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zdepbac, zwork1, zdepprod
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_rem')
+      !
+      ! Allocate temporary workspace
+      CALL wrk_alloc( jpi, jpj,      ztempbac                  )
+      CALL wrk_alloc( jpi, jpj, jpk, zdepbac, zdepprod, zwork1 )
+
+      ! Initialisation of temprary arrys
+      zdepprod(:,:,:) = 1._wp
+      ztempbac(:,:)   = 0._wp
+
+      ! Computation of the mean phytoplankton concentration as
+      ! a crude estimate of the bacterial biomass
+      ! this parameterization has been deduced from a model version
+      ! that was modeling explicitely bacteria
+      ! -------------------------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zdep = MAX( hmld(ji,jj), heup(ji,jj) )
+               IF( fsdept(ji,jj,jk) < zdep ) THEN
+                  zdepbac(ji,jj,jk) = MIN( 0.7 * ( trn(ji,jj,jk,jpzoo) + 2.* trn(ji,jj,jk,jpmes) ), 4.e-6 )
+                  ztempbac(ji,jj)   = zdepbac(ji,jj,jk)
+               ELSE
+                  zdepmin = MIN( 1., zdep / fsdept(ji,jj,jk) )
+                  zdepbac (ji,jj,jk) = zdepmin**0.683 * ztempbac(ji,jj)
+                  zdepprod(ji,jj,jk) = zdepmin**0.273
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ! denitrification factor computed from O2 levels
+               ! ----------------------------------------------
+               nitrfac(ji,jj,jk) = MAX(  0.e0, 0.4 * ( 6.e-6  - trn(ji,jj,jk,jpoxy) )    &
+                  &                                / ( oxymin + trn(ji,jj,jk,jpoxy) )  )
+               nitrfac(ji,jj,jk) = MIN( 1., nitrfac(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zstep   = xstep
+# if defined key_degrad
+               zstep = zstep * facvol(ji,jj,jk)
+# endif
+               ! DOC ammonification. Depends on depth, phytoplankton biomass
+               ! and a limitation term which is supposed to be a parameterization
+               ! of the bacterial activity. 
+               ! -----------------------------------------------------------------
+               zremik = zstep / 1.e-6 * MAX(0.02, xlimbac(ji,jj,jk) ) * zdepbac(ji,jj,jk) 
+               zremik = MAX( zremik, 2.74e-4 * xstep / xremikc )
+
+               zremikc = xremikc * zremik
+               zremikn = xremikn * zremik * 1.0 / (5.6*rno3)
+               zremikp = xremikp * zremik * 1.0 / (75.0*po4r)
+
+               ! Ammonification in oxic waters with oxygen consumption
+               ! -----------------------------------------------------
+               zolimit = zremikc * ( 1.- nitrfac(ji,jj,jk) ) * trn(ji,jj,jk,jpdoc) 
+               zolimic = MAX( 0.e0, MIN( ( trn(ji,jj,jk,jpoxy) - rtrn ) / o2ut, zolimit ) ) 
+               zwork1(ji,jj,jk) = zolimic
+               zolimin = zolimic * trn(ji,jj,jk,jpdon) / ( trn(ji,jj,jk,jpdoc) + rtrn )
+               zolimip = zolimic * trn(ji,jj,jk,jpdop) / ( trn(ji,jj,jk,jpdoc) + rtrn ) 
+
+               ! Ammonification in suboxic waters with denitrification
+               ! -------------------------------------------------------
+               zolimit = zremikc * nitrfac(ji,jj,jk) * trn(ji,jj,jk,jpdoc)
+               denitrc(ji,jj,jk)  = MIN(  ( trn(ji,jj,jk,jpno3) - rtrn ) / rdenit, zolimit )
+               denitrc (ji,jj,jk) = MAX( 0.e0, denitrc (ji,jj,jk) )
+               zdenitrn  = denitrc(ji,jj,jk) * trn(ji,jj,jk,jpdon) / ( trn(ji,jj,jk,jpdoc) + rtrn )
+               zdenitrp  = denitrc(ji,jj,jk) * trn(ji,jj,jk,jpdop) / ( trn(ji,jj,jk,jpdoc) + rtrn )
+
+               ! Update of trends TRA
+               ! -------------------- 
+               tra(ji,jj,jk,jppo4) = tra(ji,jj,jk,jppo4) + zolimip + zdenitrp
+               tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) + zolimin + zdenitrn
+               tra(ji,jj,jk,jpno3) = tra(ji,jj,jk,jpno3) - denitrc(ji,jj,jk) * rdenit
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) - zolimic - denitrc(ji,jj,jk)
+               tra(ji,jj,jk,jpdon) = tra(ji,jj,jk,jpdon) - zolimin - zdenitrn
+               tra(ji,jj,jk,jpdop) = tra(ji,jj,jk,jpdop) - zolimip - zdenitrp
+               tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) - zolimic * o2ut
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) + zolimic + denitrc(ji,jj,jk)
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) + rno3 * ( zolimin + ( rdenit + 1.) * zdenitrn )
+
+            END DO
+         END DO
+      END DO
+
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zstep   = xstep
+# if defined key_degrad
+               zstep = zstep * facvol(ji,jj,jk)
+# endif
+               ! NH4 nitrification to NO3. Ceased for oxygen concentrations
+               ! below 2 umol/L. Inhibited at strong light 
+               ! ----------------------------------------------------------
+               zonitr   = nitrif * zstep * trn(ji,jj,jk,jpnh4) * (0.2 + 0.8 / ( 1.+ emoy(ji,jj,jk) ) ) &
+               &          * ( 1.- nitrfac(ji,jj,jk) ) 
+               zdenitnh4 = nitrif * zstep * trn(ji,jj,jk,jpnh4) * nitrfac(ji,jj,jk) 
+
+               ! Update of the tracers trends
+               ! ----------------------------
+               tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) - zonitr - zdenitnh4
+               tra(ji,jj,jk,jpno3) = tra(ji,jj,jk,jpno3) + zonitr - rdenita * zdenitnh4
+               tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) - o2nit * zonitr
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) - 2 * rno3 * zonitr + rno3 * ( rdenita - 1. ) * zdenitnh4
+            END DO
+         END DO
+      END DO
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+        WRITE(charout, FMT="('rem1')")
+        CALL prt_ctl_trc_info(charout)
+        CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               ! Bacterial uptake of iron. No iron is available in DOC. So
+               ! Bacteries are obliged to take up iron from the water. Some
+               ! studies (especially at Papa) have shown this uptake to be significant
+               ! ----------------------------------------------------------
+               zbactfer = ferat3 *  rfact2 * prmaxp(ji,jj,jk) * xlimbacl(ji,jj,jk)             &
+                  &              * biron(ji,jj,jk) / ( 2E-10 + biron(ji,jj,jk) )    &
+                  &              * zdepprod(ji,jj,jk) * zdepbac(ji,jj,jk)
+#if defined key_kriest
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) - zbactfer*0.05
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zbactfer*0.05
+#else
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) - zbactfer*0.16
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zbactfer*0.12
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + zbactfer*0.04
+#endif
+            END DO
+         END DO
+      END DO
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+        WRITE(charout, FMT="('rem2')")
+        CALL prt_ctl_trc_info(charout)
+        CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zstep   = xstep
+# if defined key_degrad
+               zstep = zstep * facvol(ji,jj,jk)
+# endif
+               ! POC disaggregation by turbulence and bacterial activity. 
+               ! --------------------------------------------------------
+               zremip = zstep * tgfunc(ji,jj,jk) * ( 1.- 0.55 * nitrfac(ji,jj,jk) ) 
+
+               ! POC disaggregation rate is reduced in anoxic zone as shown by
+               ! sediment traps data. In oxic area, the exponent of the martin s
+               ! law is around -0.87. In anoxic zone, it is around -0.35. This
+               ! means a disaggregation constant about 0.5 the value in oxic zones
+               ! -----------------------------------------------------------------
+               zopoc  = xremipc * zremip * trn(ji,jj,jk,jppoc)
+               zopon  = xremipn * zremip * trn(ji,jj,jk,jppon)
+               zopop  = xremipp * zremip * trn(ji,jj,jk,jppop)
+               zofer  = xremipn * zremip * trn(ji,jj,jk,jpsfe)
+#if ! defined key_kriest
+               zopoc2 = xremipc * zremip * trn(ji,jj,jk,jpgoc)
+               zopon2 = xremipn * zremip * trn(ji,jj,jk,jpgon)
+               zopop2 = xremipp * zremip * trn(ji,jj,jk,jpgop)
+               zofer2 = xremipn * zremip * trn(ji,jj,jk,jpbfe)
+#else
+               zopoc2 = xremipc * zremip * trn(ji,jj,jk,jpnum)
+#endif
+
+               ! Update the appropriate tracers trends
+               ! -------------------------------------
+#if defined key_kriest
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) - zopoc
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) - zopon
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) - zopop
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) - zofer
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + zopoc
+               tra(ji,jj,jk,jpdon) = tra(ji,jj,jk,jpdon) + zopon
+               tra(ji,jj,jk,jpdop) = tra(ji,jj,jk,jpdop) + zopop
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) + zofer
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) - zopoc2
+#else
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) - zopoc + zopoc2
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) - zopon + zopon2
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) - zopop + zopop2
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) - zofer + zofer2
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + zopoc 
+               tra(ji,jj,jk,jpdon) = tra(ji,jj,jk,jpdon) + zopon 
+               tra(ji,jj,jk,jpdop) = tra(ji,jj,jk,jpdop) + zopop 
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) + zofer 
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) - zopoc2
+               tra(ji,jj,jk,jpgon) = tra(ji,jj,jk,jpgon) - zopon2
+               tra(ji,jj,jk,jpgop) = tra(ji,jj,jk,jpgop) - zopop2
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) - zofer2
+#endif
+            END DO
+         END DO
+      END DO
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+        WRITE(charout, FMT="('rem3')")
+        CALL prt_ctl_trc_info(charout)
+        CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zstep   = xstep
+# if defined key_degrad
+               zstep = zstep * facvol(ji,jj,jk)
+# endif
+               ! Remineralization rate of BSi depedant on T and saturation
+               ! ---------------------------------------------------------
+               zsatur   = ( sio3eq(ji,jj,jk) - trn(ji,jj,jk,jpsil) ) / ( sio3eq(ji,jj,jk) + rtrn )
+               zsatur   = MAX( rtrn, zsatur )
+               zsatur2  = ( 1. + tsn(ji,jj,jk,jp_tem) / 400.)**37
+               znusil   = 0.225  * ( 1. + tsn(ji,jj,jk,jp_tem) / 15.) * zsatur + 0.775 * zsatur2 * zsatur**9.25
+               znusil2  = 0.225  * ( 1. + tsn(ji,jj,1,jp_tem) / 15.) + 0.775 * zsatur2
+
+               ! Two classes of BSi are considered : a labile fraction and 
+               ! a more refractory one. The ratio between both fractions is
+               ! constant and specified in the namelist.
+               ! ----------------------------------------------------------
+               zdep     = MAX( hmld(ji,jj), heup(ji,jj) ) 
+               zdep     = MAX( 0., fsdept(ji,jj,jk) - zdep )
+               ztem     = MAX( tsn(ji,jj,1,jp_tem), 0. )
+               zfactdep = xsilab * EXP(-( xsiremlab - xsirem ) * znusil2 * zdep / wsbio2 ) * ztem / ( ztem + 10. )
+               zsiremin = ( xsiremlab * zfactdep + xsirem * ( 1. - zfactdep ) ) * zstep * znusil
+               zosil    = zsiremin * trn(ji,jj,jk,jpgsi)
+               !
+               tra(ji,jj,jk,jpgsi) = tra(ji,jj,jk,jpgsi) - zosil
+               tra(ji,jj,jk,jpsil) = tra(ji,jj,jk,jpsil) + zosil
+               !
+            END DO
+         END DO
+      END DO
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rem4')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+      IF( ln_diatrc .AND. lk_iomput .AND. jnt == nrdttrc ) THEN
+          zrfact2 = 1.e3 * rfact2r
+          CALL iom_put( "REMIN" , zwork1(:,:,:) * tmask(:,:,:) * zrfact2 )  ! Remineralisation rate
+          CALL iom_put( "DENIT" , denitrc(:,:,:) * rdenit * rno3 * tmask(:,:,:) * zrfact2  )  ! Denitrification
+      ENDIF
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rem6')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi, jpj,      ztempbac                  )
+      CALL wrk_dealloc( jpi, jpj, jpk, zdepbac, zdepprod, zwork1 )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_rem')
+      !
+   END SUBROUTINE p5z_rem
+
+
+   SUBROUTINE p5z_rem_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_rem_init  ***
+      !!
+      !! ** Purpose :   Initialization of remineralization parameters
+      !!
+      !! ** Method  :   Read the nampisrem namelist and check the parameters
+      !!      called at the first timestep
+      !!
+      !! ** input   :   Namelist nampisrem
+      !!
+      !!----------------------------------------------------------------------
+      NAMELIST/nampisrem/ xremikc, xremikn, xremikp, xremipc, xremipn, xremipp,   &
+      &                   nitrif, xsirem, xsiremlab, xsilab, oxymin
+      INTEGER :: ios                 ! Local integer output status for namelist read
+
+      REWIND( numnatp_ref )              ! Namelist nampisrem in reference namelist : Pisces remineralization
+      READ  ( numnatp_ref, nampisrem, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisrem in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampisrem in configuration namelist : Pisces remineralization
+      READ  ( numnatp_cfg, nampisrem, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisrem in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampisrem )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for remineralization, nampisrem'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    remineralisation rate of POC              xremipc   =', xremipc
+         WRITE(numout,*) '    remineralisation rate of PON              xremipn   =', xremipn
+         WRITE(numout,*) '    remineralisation rate of POP              xremipp   =', xremipp
+         WRITE(numout,*) '    remineralization rate of DOC              xremikc   =', xremikc
+         WRITE(numout,*) '    remineralization rate of DON              xremikn   =', xremikn
+         WRITE(numout,*) '    remineralization rate of DOP              xremikp   =', xremikp
+         WRITE(numout,*) '    remineralization rate of Si               xsirem    =', xsirem
+         WRITE(numout,*) '    fast remineralization rate of Si          xsiremlab =', xsiremlab
+         WRITE(numout,*) '    fraction of labile biogenic silica        xsilab    =', xsilab
+         WRITE(numout,*) '    NH4 nitrification rate                    nitrif    =', nitrif
+         WRITE(numout,*) '    halk saturation constant for anoxia       oxymin    =', oxymin
+      ENDIF
+      !
+      nitrfac (:,:,:) = 0._wp
+      denitrc (:,:,:) = 0._wp
+      !
+   END SUBROUTINE p5z_rem_init
+
+
+   INTEGER FUNCTION p5z_rem_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_rem_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( denitrc(jpi,jpj,jpk), STAT=p5z_rem_alloc )
+      !
+      IF( p5z_rem_alloc /= 0 )   CALL ctl_warn('p5z_rem_alloc: failed to allocate arrays')
+      !
+   END FUNCTION p5z_rem_alloc
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_rem                    ! Empty routine
+   END SUBROUTINE p5z_rem
+#endif 
+
+   !!======================================================================
+END MODULE p5zrem
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsed.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsed.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsed.F90	(revision 5266)
@@ -0,0 +1,477 @@
+MODULE p5zsed
+   !!======================================================================
+   !!                         ***  MODULE p5zsed  ***
+   !! TOP :   PISCES Compute loss of organic matter in the sediments
+   !!======================================================================
+   !! History :   1.0  !  2004-03 (O. Aumont) Original code
+   !!             2.0  !  2007-12 (C. Ethe, G. Madec)  F90
+   !!             3.4  !  2011-06 (C. Ethe) USE of fldread
+   !!             3.5  !  2012-07 (O. Aumont) improvment of river input of nutrients 
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_pisces_quota'     PISCES bio-model with variable stoichiometry
+   !!----------------------------------------------------------------------
+   !!   p5z_sed        :  Compute loss of organic matter in the sediments
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE p5zsink         !  vertical flux of particulate matter due to sinking
+   USE p4zopt          !  optical model
+   USE p5zlim          !  Co-limitations of differents nutrients
+   USE p5zrem          !  Remineralisation of organic matter
+   USE p4zsbc          !  External source of nutrients 
+   USE p4zint          !  interpolation and computation of various fields
+   USE iom             !  I/O manager
+   USE prtctl_trc      !  print control for debugging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p5z_sed   
+
+   !! * Module variables
+   REAL(wp) :: ryyss                    !: number of seconds per year 
+   REAL(wp) :: r1_ryyss                 !: inverse of ryyss
+   REAL(wp) :: r1_rday                  !: inverse of rday
+
+   INTEGER ::  numnit  
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Header:$ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE p5z_sed( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_sed  **
+      !!
+      !! ** Purpose :   Compute loss of organic matter in the sediments. This
+      !!              is by no way a sediment model. The loss is simply 
+      !!              computed to balance the inout from rivers and dust
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      !
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      INTEGER  ::   ji, jj, jk, ikt
+#if ! defined key_sed
+      REAL(wp) ::   zsumsedsi, zsumsedpo4, zsumsedcal
+      REAL(wp) ::   zrivalk, zrivsil, zrivno3
+#endif
+      REAL(wp) ::  zwflux, zfminus, zfplus
+      REAL(wp) ::  zlim, zfact, zfactcal
+      REAL(wp) ::  zo2, zno3, zflx, zpdenit, z1pdenit, zdenitt, zolimit
+      REAL(wp) ::  zsiloss, zcaloss, zws3, zws4, zwsc, zdep
+      REAL(wp) ::  zwstpoc, zwstpon, zwstpop
+      REAL(wp) ::  ztrfer, ztrdp, zwdust, zlight, zmudia, ztemp
+      REAL(wp) ::  zrdenittot, zsdenittot, znitrpottot, xdiano3, xdianh4
+      !
+      CHARACTER (len=25) :: charout
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zpdep, zsidep, zwork1, zwork2, zwork3, zwork4
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zdenit2d, zironice, zbureff
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zwsbio3, zwsbio4, zwscal
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrpo4, ztrdop, znitrpot, zirondep, zsoufer
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_sed')
+      !
+      IF( kt == nittrc000 .AND. jnt == 1 )  THEN
+         ryyss    = nyear_len(1) * rday    ! number of seconds per year and per month
+         r1_rday  = 1. / rday
+         r1_ryyss = 1. / ryyss
+         IF( ln_check_mass .AND. lwp)  &
+           &  CALL ctl_opn( numnit, 'nitrogen.budget', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
+      ENDIF
+      !
+      ! Allocate temporary workspace
+      CALL wrk_alloc( jpi, jpj, zdenit2d, zwork1, zwork2, zwork3, zwork4, zbureff )
+      CALL wrk_alloc( jpi, jpj, zwsbio3, zwsbio4, zwscal )
+      CALL wrk_alloc( jpi, jpj, jpk, ztrpo4, ztrdop, znitrpot, zsoufer )
+
+      zdenit2d(:,:) = 0.e0
+      zbureff (:,:) = 0.e0
+      zwork1  (:,:) = 0.e0
+      zwork2  (:,:) = 0.e0
+      zwork3  (:,:) = 0.e0
+      zwork4  (:,:) = 0.e0
+
+      ! Iron input/uptake due to sea ice : Crude parameterization based on Lancelot et al.
+      ! ----------------------------------------------------
+      IF( ln_ironice ) THEN  
+         !                                              
+         CALL wrk_alloc( jpi, jpj, zironice )
+         !                                              
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zdep    = rfact2 / fse3t(ji,jj,1)
+               zwflux  = fmmflx(ji,jj) / 1000._wp
+               zfminus = MIN( 0._wp, -zwflux ) * trn(ji,jj,1,jpfer) * zdep
+               zfplus  = MAX( 0._wp, -zwflux ) * icefeinput * zdep
+               zironice(ji,jj) =  zfplus + zfminus
+            END DO
+         END DO
+         !
+         trn(:,:,1,jpfer) = trn(:,:,1,jpfer) + zironice(:,:) 
+         !                                              
+         IF( ln_diatrc .AND. lk_iomput .AND. jnt == nrdttrc )   &
+            &   CALL iom_put( "Ironice", zironice(:,:) * 1.e+3 * rfact2r * fse3t(:,:,1) * tmask(:,:,1) ) ! iron flux from ice
+         CALL wrk_dealloc( jpi, jpj, zironice )
+         !                                              
+      ENDIF
+
+      ! Add the external input of nutrients from dust deposition
+      ! ----------------------------------------------------------
+      IF( ln_dust ) THEN
+         !                                              
+         CALL wrk_alloc( jpi, jpj,      zpdep, zsidep )
+         CALL wrk_alloc( jpi, jpj, jpk, zirondep      )
+         !                                              ! Iron and Si deposition at the surface
+         IF( ln_solub ) THEN
+            zirondep(:,:,1) = solub(:,:) * dust(:,:) * mfrac * rfact2    &
+            &        / fse3t(:,:,1) / 55.85 + 3.e-10 * r1_ryyss 
+         ELSE
+            zirondep(:,:,1) = dustsolub  * dust(:,:) * mfrac * rfact2    &
+            &        / fse3t(:,:,1) / 55.85 + 3.e-10 * r1_ryyss 
+         ENDIF
+         zsidep(:,:) = 8.8 * 0.075 * dust(:,:) * mfrac * rfact2 / fse3t(:,:,1) / 28.1 
+         zpdep (:,:) = 0.1 * 0.021 * dust(:,:) * mfrac * rfact2 / fse3t(:,:,1) / 31. / po4r 
+         !                                              ! Iron solubilization of particles in the water column
+         !                                              ! dust in kg/m2/s ---> 1/55.85 to put in mol/Fe ;  wdust in m/j
+         zwdust = 0.03 * rday / ( wdust * 55.85 ) / ( 270. * rday )
+         DO jk = 2, jpkm1
+            zirondep(:,:,jk) = dust(:,:) * mfrac * zwdust * rfact2  &
+            &   * EXP( -fsdept(:,:,jk) / 540. )
+         END DO
+         !                                              ! Iron solubilization of particles in the water column
+         trn(:,:,1,jppo4) = trn(:,:,1,jppo4) + zpdep   (:,:)
+         trn(:,:,1,jpsil) = trn(:,:,1,jpsil) + zsidep  (:,:)
+         trn(:,:,:,jpfer) = trn(:,:,:,jpfer) + zirondep(:,:,:) 
+         !                                              
+         IF( ln_diatrc ) THEN
+            zfact = 1.e+3 * rfact2r
+            IF( lk_iomput ) THEN
+               IF( jnt == nrdttrc ) THEN
+                  CALL iom_put( "Irondep", zirondep(:,:,1) * zfact * fse3t(:,:,1) * tmask(:,:,1) ) ! surface downward dust depo of iron
+                  CALL iom_put( "pdust"  , dust(:,:) / ( wdust * rday )  * tmask(:,:,1) ) ! dust concentration at surface
+               ENDIF
+            ELSE
+               trc2d(:,:,jp_pcs0_2d + 11) = zirondep(:,:,1) * zfact * fse3t(:,:,1) * tmask(:,:,1)
+            ENDIF
+         ENDIF
+         CALL wrk_dealloc( jpi, jpj,      zpdep, zsidep )
+         CALL wrk_dealloc( jpi, jpj, jpk, zirondep      )
+         !                                              
+      ENDIF
+     
+      ! Add the external input of nutrients from river
+      ! ----------------------------------------------------------
+      IF( ln_river ) THEN
+         trn(:,:,1,jppo4) = trn(:,:,1,jppo4) + rivdip(:,:) * rfact2
+         trn(:,:,1,jpno3) = trn(:,:,1,jpno3) + rivdin(:,:) * rfact2
+         trn(:,:,1,jpfer) = trn(:,:,1,jpfer) + rivdic(:,:) * 5.e-5 * rfact2
+         trn(:,:,1,jpsil) = trn(:,:,1,jpsil) + rivdsi(:,:) * rfact2
+         trn(:,:,1,jpdic) = trn(:,:,1,jpdic) + rivdic(:,:) * rfact2
+         trn(:,:,1,jptal) = trn(:,:,1,jptal) + ( rivalk(:,:) - rno3 * rivdin(:,:) ) * rfact2
+      ENDIF
+      
+      ! Add the external input of nutrients from nitrogen deposition
+      ! ----------------------------------------------------------
+      IF( ln_ndepo ) THEN
+         trn(:,:,1,jpno3) = trn(:,:,1,jpno3) + nitdep(:,:) * rfact2
+         trn(:,:,1,jptal) = trn(:,:,1,jptal) - rno3 * nitdep(:,:) * rfact2
+      ENDIF
+
+      ! Add the external input of iron from sediment mobilization
+      ! ------------------------------------------------------
+      IF( ln_ironsed ) THEN
+         trn(:,:,:,jpfer) = trn(:,:,:,jpfer) + ironsed(:,:,:) * rfact2
+         !
+         IF( ln_diatrc .AND. lk_iomput .AND. jnt == nrdttrc )   &
+            &   CALL iom_put( "Ironsed", ironsed(:,:,:) * 1.e+3 * tmask(:,:,:) ) ! iron inputs from sediments
+      ENDIF
+
+      ! Add the external input of iron from hydrothermal vents
+      ! ------------------------------------------------------
+      IF( ln_hydrofe ) THEN
+         trn(:,:,:,jpfer) = trn(:,:,:,jpfer) + hydrofe(:,:,:) * rfact2
+         !
+         IF( ln_diatrc .AND. lk_iomput .AND. jnt == nrdttrc )   &
+            &   CALL iom_put( "HYDR", hydrofe(:,:,:) * 1.e+3 * tmask(:,:,:) ) ! hydrothermal iron input
+      ENDIF
+
+
+      ! OA: Warning, the following part is necessary, especially with Kriest
+      ! to avoid CFL problems above the sediments
+      ! --------------------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt  = mbkt(ji,jj)
+            zdep = fse3t(ji,jj,ikt) / xstep
+            zwsbio4(ji,jj) = MIN( 0.99 * zdep, wsbio4(ji,jj,ikt) )
+            zwscal (ji,jj) = MIN( 0.99 * zdep, wscal (ji,jj,ikt) )
+            zwsbio3(ji,jj) = MIN( 0.99 * zdep, wsbio3(ji,jj,ikt) )
+         END DO
+      END DO
+
+#if ! defined key_sed
+      ! Computation of the sediment denitrification proportion: The metamodel from midlleburg (2006) is being used
+      ! Computation of the fraction of organic matter that is permanently buried from Dunne's model
+      ! -------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+           IF( tmask(ji,jj,1) == 1 ) THEN
+              ikt = mbkt(ji,jj)
+# if defined key_kriest
+              zflx =    trn(ji,jj,ikt,jppoc) * zwsbio3(ji,jj)    * 1E3 * 1E6 / 1E4
+# else
+              zflx = (  trn(ji,jj,ikt,jpgoc) * zwsbio4(ji,jj)   &
+                &     + trn(ji,jj,ikt,jppoc) * zwsbio3(ji,jj) )  * 1E3 * 1E6 / 1E4
+#endif
+              zflx  = LOG10( MAX( 1E-3, zflx ) )
+              zo2   = LOG10( MAX( 10. , trn(ji,jj,ikt,jpoxy) * 1E6 ) )
+              zno3  = LOG10( MAX( 1.  , trn(ji,jj,ikt,jpno3) * 1E6 * rno3 ) )
+              zdep  = LOG10( fsdepw(ji,jj,ikt+1) )
+              zdenit2d(ji,jj) = -2.2567 - 1.185 * zflx - 0.221 * zflx**2 - 0.3995 * zno3 * zo2 + 1.25 * zno3    &
+              &                + 0.4721 * zo2 - 0.0996 * zdep + 0.4256 * zflx * zo2
+              zdenit2d(ji,jj) = 10.0**( zdenit2d(ji,jj) )
+              !
+              zflx = (  trn(ji,jj,ikt,jpgoc) * zwsbio4(ji,jj)   &
+                &     + trn(ji,jj,ikt,jppoc) * zwsbio3(ji,jj) ) * 1E6
+              zbureff(ji,jj) = 0.013 + 0.53 * zflx**2 / ( 7.0 + zflx )**2
+           ENDIF
+         END DO
+      END DO 
+
+      ! Loss of biogenic silicon, Caco3 organic carbon in the sediments. 
+      ! First, the total loss is computed.
+      ! The factor for calcite comes from the alkalinity effect
+      ! -------------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( tmask(ji,jj,1) == 1 ) THEN
+               ikt = mbkt(ji,jj) 
+# if defined key_kriest
+               zwork1(ji,jj) = trn(ji,jj,ikt,jpgsi) * zwscal (ji,jj)
+               zwork2(ji,jj) = trn(ji,jj,ikt,jppoc) * zwsbio3(ji,jj)
+# else
+               zwork1(ji,jj) = trn(ji,jj,ikt,jpgsi) * zwsbio4(ji,jj)
+               zwork2(ji,jj) = trn(ji,jj,ikt,jpgoc) * zwsbio4(ji,jj) + trn(ji,jj,ikt,jppoc) * zwsbio3(ji,jj) 
+# endif
+               ! For calcite, burial efficiency is made a function of saturation
+               zfactcal      = MIN( excess(ji,jj,ikt), 0.2 )
+               zfactcal      = MIN( 1., 1.3 * ( 0.2 - zfactcal ) / ( 0.4 - zfactcal ) )
+               zwork3(ji,jj) = trn(ji,jj,ikt,jpcal) * zwscal(ji,jj) * 2.e0 * zfactcal
+            ENDIF
+         END DO
+      END DO
+      zsumsedsi  = glob_sum( zwork1(:,:) * e1e2t(:,:) ) * r1_rday
+      zsumsedpo4 = glob_sum( zwork2(:,:) * e1e2t(:,:) ) * r1_rday
+      zsumsedcal = glob_sum( zwork3(:,:) * e1e2t(:,:) ) * r1_rday
+#endif
+
+      ! This loss is scaled at each bottom grid cell for equilibrating the total budget of silica in the ocean.
+      ! Thus, the amount of silica lost in the sediments equal the supply at the surface (dust+rivers)
+      ! ------------------------------------------------------
+#if ! defined key_sed
+      zrivsil =  MAX(0., 1._wp - ( sumdepsi + rivdsiinput * r1_ryyss ) / ( zsumsedsi + rtrn ) )
+#endif
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt  = mbkt(ji,jj)
+            zdep = xstep / fse3t(ji,jj,ikt)
+            zws4 = zwsbio4(ji,jj) * zdep
+            zwsc = zwscal (ji,jj) * zdep
+# if defined key_kriest
+            zsiloss = trn(ji,jj,ikt,jpgsi) * zws4
+# else
+            zsiloss = trn(ji,jj,ikt,jpgsi) * zwsc
+# endif
+            zcaloss = trn(ji,jj,ikt,jpcal) * zwsc
+            !
+            trn(ji,jj,ikt,jpgsi) = trn(ji,jj,ikt,jpgsi) - zsiloss
+            trn(ji,jj,ikt,jpcal) = trn(ji,jj,ikt,jpcal) - zcaloss
+#if ! defined key_sed
+            trn(ji,jj,ikt,jpsil) = trn(ji,jj,ikt,jpsil) + zsiloss * zrivsil 
+            zfactcal = MIN( excess(ji,jj,ikt), 0.2 )
+            zfactcal = MIN( 1., 1.3 * ( 0.2 - zfactcal ) / ( 0.4 - zfactcal ) )
+            zrivalk  =  1._wp - ( rivalkinput * r1_ryyss ) * zfactcal / ( zsumsedcal + rtrn )
+            trn(ji,jj,ikt,jptal) =  trn(ji,jj,ikt,jptal) + zcaloss * zrivalk * 2.0
+            trn(ji,jj,ikt,jpdic) =  trn(ji,jj,ikt,jpdic) + zcaloss * zrivalk
+#endif
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt     = mbkt(ji,jj)
+            zdep    = xstep / fse3t(ji,jj,ikt)
+            zws4 = zwsbio4(ji,jj) * zdep
+            zws3 = zwsbio3(ji,jj) * zdep
+            zrivno3 = 1. - zbureff(ji,jj)
+# if ! defined key_kriest
+            trn(ji,jj,ikt,jpgoc) = trn(ji,jj,ikt,jpgoc) - trn(ji,jj,ikt,jpgoc) * zws4
+            trn(ji,jj,ikt,jppoc) = trn(ji,jj,ikt,jppoc) - trn(ji,jj,ikt,jppoc) * zws3
+            trn(ji,jj,ikt,jpgon) = trn(ji,jj,ikt,jpgon) - trn(ji,jj,ikt,jpgon) * zws4
+            trn(ji,jj,ikt,jppon) = trn(ji,jj,ikt,jppon) - trn(ji,jj,ikt,jppon) * zws3
+            trn(ji,jj,ikt,jpgop) = trn(ji,jj,ikt,jpgop) - trn(ji,jj,ikt,jpgop) * zws4
+            trn(ji,jj,ikt,jppop) = trn(ji,jj,ikt,jppop) - trn(ji,jj,ikt,jppop) * zws3
+            trn(ji,jj,ikt,jpbfe) = trn(ji,jj,ikt,jpbfe) - trn(ji,jj,ikt,jpbfe) * zws4
+            trn(ji,jj,ikt,jpsfe) = trn(ji,jj,ikt,jpsfe) - trn(ji,jj,ikt,jpsfe) * zws3
+            zwstpoc              =  trn(ji,jj,ikt,jpgoc) * zws4 + trn(ji,jj,ikt,jppoc) * zws3 
+            zwstpop              =  trn(ji,jj,ikt,jpgop) * zws4 + trn(ji,jj,ikt,jppop) * zws3
+            zwstpon              =  trn(ji,jj,ikt,jpgon) * zws4 + trn(ji,jj,ikt,jppon) * zws3
+# else
+            trn(ji,jj,ikt,jpnum) = trn(ji,jj,ikt,jpnum) - trn(ji,jj,ikt,jpnum) * zws4
+            trn(ji,jj,ikt,jppoc) = trn(ji,jj,ikt,jppoc) - trn(ji,jj,ikt,jppoc) * zws3
+            trn(ji,jj,ikt,jppon) = trn(ji,jj,ikt,jppon) - trn(ji,jj,ikt,jppon) * zws3
+            trn(ji,jj,ikt,jppop) = trn(ji,jj,ikt,jppop) - trn(ji,jj,ikt,jppop) * zws3
+            trn(ji,jj,ikt,jpsfe) = trn(ji,jj,ikt,jpsfe) - trn(ji,jj,ikt,jpsfe) * zws3
+            zwstpop = trn(ji,jj,ikt,jppop) * zws3
+            zwstpon = trn(ji,jj,ikt,jppon) * zws3
+            zwstpoc = trn(ji,jj,ikt,jppoc) * zws3 
+# endif
+
+#if ! defined key_sed
+            ! The 0.5 factor in zpdenit and zdenitt is to avoid negative NO3 concentration after both denitrification
+            ! in the sediments and just above the sediments. Not very clever, but simpliest option.
+            zpdenit  = MIN( 0.5 * ( trn(ji,jj,ikt,jpno3) - rtrn ) / rdenit, zdenit2d(ji,jj) * zwstpoc * zrivno3 )
+            z1pdenit = zwstpoc * zrivno3 - zpdenit
+            zolimit = MIN( ( trn(ji,jj,ikt,jpoxy) - rtrn ) / o2ut, z1pdenit * ( 1.- nitrfac(ji,jj,ikt) ) )
+            zdenitt = MIN(  0.5 * ( trn(ji,jj,ikt,jpno3) - rtrn ) / rdenit, z1pdenit * nitrfac(ji,jj,ikt) )
+            trn(ji,jj,ikt,jpdoc) = trn(ji,jj,ikt,jpdoc) + z1pdenit - zolimit - zdenitt
+            trn(ji,jj,ikt,jpdon) = trn(ji,jj,ikt,jpdon) + (z1pdenit - zolimit - zdenitt) * zwstpon / (zwstpoc + rtrn)
+            trn(ji,jj,ikt,jpdop) = trn(ji,jj,ikt,jpdop) + (z1pdenit - zolimit - zdenitt) * zwstpop / (zwstpoc + rtrn)
+            trn(ji,jj,ikt,jppo4) = trn(ji,jj,ikt,jppo4) + (zpdenit + zolimit + zdenitt) * zwstpop / (zwstpoc + rtrn)
+            trn(ji,jj,ikt,jpnh4) = trn(ji,jj,ikt,jpnh4) + (zpdenit + zolimit + zdenitt) * zwstpon / (zwstpoc + rtrn)
+            trn(ji,jj,ikt,jpno3) = trn(ji,jj,ikt,jpno3) - rdenit * (zpdenit + zdenitt)
+            trn(ji,jj,ikt,jpoxy) = trn(ji,jj,ikt,jpoxy) - zolimit * o2ut
+            trn(ji,jj,ikt,jptal) = trn(ji,jj,ikt,jptal) + rno3 * (zolimit + zpdenit + zdenitt ) * zwstpon / (zwstpoc + rtrn)   &
+            &   + rno3 * rdenit * (zpdenit + zdenitt)
+            trn(ji,jj,ikt,jpdic) = trn(ji,jj,ikt,jpdic) + zpdenit + zolimit + zdenitt
+            zwork4(ji,jj) = rdenit * zpdenit * fse3t(ji,jj,ikt)
+#endif
+         END DO
+      END DO
+
+      ! Nitrogen fixation process
+      ! Small source iron from particulate inorganic iron
+      !-----------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !                      ! Potential nitrogen fixation dependant on temperature and iron
+               ztemp = tsn(ji,jj,jk,jp_tem)
+               zmudia = max(0.,-0.001096*ztemp**2 + 0.057*ztemp -0.637) * 7.625
+               !       Potential nitrogen fixation dependant on
+               !       temperature and iron
+               xdianh4 = trn(ji,jj,jk,jpnh4) / ( concnnh4 + trn(ji,jj,jk,jpnh4) )
+               xdiano3 = trn(ji,jj,jk,jpno3) / ( concnno3 + trn(ji,jj,jk,jpno3) ) * (1. - xdianh4)
+               zlim = ( 1.- xdiano3 - xdianh4 )
+               IF( zlim <= 0.1 )   zlim = 0.01
+#if defined key_degrad
+               zfact = zlim * rfact2 * facvol(ji,jj,jk)
+#else
+               zfact = zlim * rfact2
+#endif
+               ztrfer = biron(ji,jj,jk) / ( concfediaz + biron(ji,jj,jk) )
+               ztrpo4(ji,jj,jk) = trn(ji,jj,jk,jppo4) / ( 1E-6 + trn(ji,jj,jk,jppo4) )
+               ztrdop(ji,jj,jk) = trn(ji,jj,jk,jpdop) / ( 1E-6 + trn(ji,jj,jk,jpdop) ) * (1. - ztrpo4(ji,jj,jk))
+               ztrdp = ztrpo4(ji,jj,jk) + ztrdop(ji,jj,jk)
+               zlight =  ( 1.- EXP( -etot(ji,jj,jk) / diazolight ) ) 
+               znitrpot(ji,jj,jk) =  zmudia * r1_rday * zfact * MIN( ztrfer, ztrdp ) * zlight
+               zsoufer(ji,jj,jk) = zlight * 2E-11 / (2E-11 + biron(ji,jj,jk))
+            END DO
+         END DO
+      END DO
+
+      ! Nitrogen change due to nitrogen fixation
+      ! ----------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zfact = znitrpot(ji,jj,jk) * nitrfix
+               trn(ji,jj,jk,jpnh4) = trn(ji,jj,jk,jpnh4) + zfact / 3.0
+               trn(ji,jj,jk,jptal) = trn(ji,jj,jk,jptal) + rno3 * zfact / 3.0
+               trn(ji,jj,jk,jppo4) = trn(ji,jj,jk,jppo4) - 16.0 / 46.0 * zfact * ( 1.0 - 1.0 / 3.0 ) &
+               &                     * ztrpo4(ji,jj,jk) / (ztrpo4(ji,jj,jk) + ztrdop(ji,jj,jk) + rtrn)
+               trn(ji,jj,jk,jpdon) = trn(ji,jj,jk,jpdon) + zfact * 1.0 / 3.0
+               trn(ji,jj,jk,jpdoc) = trn(ji,jj,jk,jpdoc) + zfact * 1.0 / 3.0
+               trn(ji,jj,jk,jpdop) = trn(ji,jj,jk,jpdop) + 16.0 / 46.0 * zfact / 3.0  &
+               &                     - 16.0 / 46.0 * zfact * ztrdop(ji,jj,jk)   &
+               &                     / (ztrpo4(ji,jj,jk) + ztrdop(ji,jj,jk) + rtrn)
+               trn(ji,jj,jk,jppoc) = trn(ji,jj,jk,jppoc) + zfact * 1.0 / 3.0 * 2.0 / 3.0
+               trn(ji,jj,jk,jppon) = trn(ji,jj,jk,jppon) + zfact * 1.0 / 3.0 * 2.0 /3.0
+               trn(ji,jj,jk,jppop) = trn(ji,jj,jk,jppop) + 16.0 / 46.0 * zfact * 1.0 / 3.0 * 2.0 /3.0
+               trn(ji,jj,jk,jpgoc) = trn(ji,jj,jk,jpgoc) + zfact * 1.0 / 3.0 * 1.0 / 3.0
+               trn(ji,jj,jk,jpgon) = trn(ji,jj,jk,jpgon) + zfact * 1.0 / 3.0 * 1.0 /3.0
+               trn(ji,jj,jk,jpgop) = trn(ji,jj,jk,jpgop) + 16.0 / 46.0 * zfact * 1.0 / 3.0 * 1.0 /3.0
+               trn(ji,jj,jk,jpoxy) = trn(ji,jj,jk,jpoxy) + ( o2ut + o2nit ) * zfact * 2.0 / 3.0 + o2nit * zfact / 3.0
+               trn(ji,jj,jk,jpfer) = trn(ji,jj,jk,jpfer) - 30E-6 * zfact * 1.0 / 3.0 
+               trn(ji,jj,jk,jpsfe) = trn(ji,jj,jk,jpsfe) + 30E-6 * zfact * 1.0 / 3.0 * 2.0 / 3.0
+               trn(ji,jj,jk,jpbfe) = trn(ji,jj,jk,jpbfe) + 30E-6 * zfact * 1.0 / 3.0 * 1.0 / 3.0
+               trn(ji,jj,jk,jpfer) = trn(ji,jj,jk,jpfer) + 0.002 * 4E-10 * zsoufer(ji,jj,jk) * rfact2 / rday
+           END DO
+         END DO 
+      END DO
+
+ 
+      IF( ln_check_mass ) THEN
+        ! Global budget of N SMS : denitrification in the water column and in the sediment
+         !                          nitrogen fixation by the diazotrophs
+         ! --------------------------------------------------------------------------------
+         zrdenittot   = glob_sum ( denitrc(:,:,:) * rdenit * xnegtr(:,:,:) * cvol(:,:,:) )
+         zsdenittot   = glob_sum ( zwork4(:,:)   * e1e2t(:,:) )
+         znitrpottot  = glob_sum ( znitrpot(:,:,:) * nitrfix              * cvol(:,:,:) )
+         IF( kt == nitend .AND. jnt == nrdttrc ) THEN
+            zfact = 1.e+3 * rfact2r * rno3 * ryyss * 14. / 1e12
+            IF(lwp) WRITE(numnit,9100) ndastp, znitrpottot * nitrfix * zfact, zrdenittot * zfact , zsdenittot * zfact
+         ENDIF
+       ENDIF
+      !
+      IF( ln_diatrc ) THEN
+         zfact = 1.e+3 * rfact2r
+         IF( lk_iomput ) THEN
+            IF( jnt == nrdttrc ) THEN
+               CALL iom_put( "Nfix"  , znitrpot(:,:,:) * nitrfix * rno3 * zfact * tmask(:,:,:) )  ! nitrogen fixation 
+               CALL iom_put( "Sdenit", zwork4(:,:)               * rno3 * zfact * tmask(:,:,1) )  ! Nitrate reduction in the sediments
+            ENDIF
+         ELSE
+            trc2d(:,:,jp_pcs0_2d + 12) = znitrpot(:,:,1) * nitrfix * zfact * fse3t(:,:,1) * tmask(:,:,1)
+         ENDIF
+      ENDIF
+      !
+      IF(ln_ctl) THEN  ! print mean trends (USEd for debugging)
+         WRITE(charout, fmt="('sed ')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi, jpj, zdenit2d, zwork1, zwork2, zwork3, zwork4, zbureff )
+      CALL wrk_dealloc( jpi, jpj, zwsbio3, zwsbio4, zwscal )
+      CALL wrk_dealloc( jpi, jpj, jpk, ztrpo4, ztrdop, znitrpot, zsoufer )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_sed')
+      !
+ 9100  FORMAT(i8,3f10.5)
+      !
+   END SUBROUTINE p5z_sed
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_sed                         ! Empty routine
+   END SUBROUTINE p5z_sed
+#endif 
+
+   !!======================================================================
+END MODULE  p5zsed
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsink.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsink.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsink.F90	(revision 5266)
@@ -0,0 +1,859 @@
+MODULE p5zsink
+   !!======================================================================
+   !!                         ***  MODULE p5zsink  ***
+   !! TOP :  PISCES  vertical flux of particulate matter due to gravitational sinking
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!             3.4  !  2011-06  (O. Aumont, C. Ethe) Change aggregation formula
+   !!             3.5  !  2012-07  (O. Aumont) Introduce potential time-splitting
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   p5z_sink       :  Compute vertical flux of particulate matter due to gravitational sinking
+   !!   p5z_sink_init  :  Unitialisation of sinking speed parameters
+   !!   p5z_sink_alloc :  Allocate sinking speed variables
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE prtctl_trc      !  print control for debugging
+   USE iom             !  I/O manager
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p5z_sink         ! called in p5zbio.F90
+   PUBLIC   p5z_sink_init    ! called in trcsms_pisces.F90
+   PUBLIC   p5z_sink_alloc
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   wsbio3   !: POC sinking speed 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   wsbio4   !: GOC sinking speed
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   wscal    !: Calcite and BSi sinking speeds
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinking, sinking2  !: POC sinking fluxes 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkingn, sinking2n  !: POC sinking fluxes 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkingp, sinking2p  !: POC sinking fluxes 
+   !                                                          !  (different meanings depending on the parameterization)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkcal, sinksil   !: CaCO3 and BSi sinking fluxes
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkfer            !: Small BFe sinking fluxes
+#if ! defined key_kriest
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkfer2           !: Big iron sinking fluxes
+#endif
+
+   INTEGER  :: iksed  = 10
+
+#if  defined key_kriest
+   REAL(wp) ::  xkr_sfact    !: Sinking factor
+   REAL(wp) ::  xkr_stick    !: Stickiness
+   REAL(wp) ::  xkr_nnano    !: Nbr of cell in nano size class
+   REAL(wp) ::  xkr_ndiat    !: Nbr of cell in diatoms size class
+   REAL(wp) ::  xkr_nmicro   !: Nbr of cell in microzoo size class
+   REAL(wp) ::  xkr_nmeso    !: Nbr of cell in mesozoo  size class
+   REAL(wp) ::  xkr_naggr    !: Nbr of cell in aggregates  size class
+
+   REAL(wp) ::  xkr_frac 
+
+   REAL(wp), PUBLIC ::  xkr_dnano       !: Size of particles in nano pool
+   REAL(wp), PUBLIC ::  xkr_ddiat       !: Size of particles in diatoms pool
+   REAL(wp), PUBLIC ::  xkr_dmicro      !: Size of particles in microzoo pool
+   REAL(wp), PUBLIC ::  xkr_dmeso       !: Size of particles in mesozoo pool
+   REAL(wp), PUBLIC ::  xkr_daggr       !: Size of particles in aggregates pool
+   REAL(wp), PUBLIC ::  xkr_wsbio_min   !: min vertical particle speed
+   REAL(wp), PUBLIC ::  xkr_wsbio_max   !: max vertical particle speed
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   xnumm   !:  maximum number of particles in aggregates
+#endif
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zsink.F90 3160 2011-11-20 14:27:18Z cetlod $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+#if ! defined key_kriest
+   !!----------------------------------------------------------------------
+   !!   'standard sinking parameterisation'                  ???
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE p5z_sink ( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_sink  ***
+      !!
+      !! ** Purpose :   Compute vertical flux of particulate matter due to 
+      !!                gravitational sinking
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt, jnt
+      INTEGER  ::   ji, jj, jk, jit
+      INTEGER  ::   iiter1, iiter2
+      REAL(wp) ::   zaggpoc1, zaggpoc2, zaggpoc3, zaggpoc4
+      REAL(wp) ::   zaggpoc , zaggfe, zaggdoc, zaggdoc2, zaggdoc3
+      REAL(wp) ::   zaggpon , zaggdon, zaggdon2, zaggdon3
+      REAL(wp) ::   zaggpop, zaggdop, zaggdop2, zaggdop3
+      REAL(wp) ::   zaggtmp, zfact, zwsmax, zmax, zstep
+      REAL(wp) ::   zrfact2
+      INTEGER  ::   ik1
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_sink')
+      !
+      !    Sinking speeds of detritus is increased with depth as shown
+      !    by data and from the coagulation theory
+      !    -----------------------------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1,jpi
+               zmax  = MAX( heup(ji,jj), hmld(ji,jj) )
+               zfact = MAX( 0., fsdepw(ji,jj,jk+1) - zmax ) / 5000._wp
+               wsbio4(ji,jj,jk) = wsbio2 + ( 200.- wsbio2 ) * zfact
+            END DO
+         END DO
+      END DO
+
+      ! limit the values of the sinking speeds to avoid numerical instabilities  
+      wsbio3(:,:,:) = wsbio
+      wscal(:,:,:) = wsbio4(:,:,:)
+      !
+      ! OA This is (I hope) a temporary solution for the problem that may 
+      ! OA arise in specific situation where the CFL criterion is broken 
+      ! OA for vertical sedimentation of particles. To avoid this, a time
+      ! OA splitting algorithm has been coded. A specific maximum
+      ! OA iteration number is provided and may be specified in the namelist 
+      ! OA This is to avoid very large iteration number when explicit free
+      ! OA surface is used (for instance). When niter?max is set to 1, 
+      ! OA this computation is skipped. The crude old threshold method is 
+      ! OA then applied. This also happens when niter exceeds nitermax.
+      IF( MAX( niter1max, niter2max ) == 1 ) THEN
+        iiter1 = 1
+        iiter2 = 1
+      ELSE
+        iiter1 = 1
+        iiter2 = 1
+        DO jk = 1, jpkm1
+          DO jj = 1, jpj
+             DO ji = 1, jpi
+                IF( tmask(ji,jj,jk) == 1) THEN
+                   zwsmax =  0.5 * fse3t(ji,jj,jk) / xstep
+                   iiter1 =  MAX( iiter1, INT( wsbio3(ji,jj,jk) / zwsmax ) )
+                   iiter2 =  MAX( iiter2, INT( wsbio4(ji,jj,jk) / zwsmax ) )
+                ENDIF
+             END DO
+          END DO
+        END DO
+        IF( lk_mpp ) THEN
+           CALL mpp_max( iiter1 )
+           CALL mpp_max( iiter2 )
+        ENDIF
+        iiter1 = MIN( iiter1, niter1max )
+        iiter2 = MIN( iiter2, niter2max )
+      ENDIF
+
+      DO jk = 1,jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tmask(ji,jj,jk) == 1 ) THEN
+                 zwsmax = 0.5 * fse3t(ji,jj,jk) / xstep
+                 wsbio3(ji,jj,jk) = MIN( wsbio3(ji,jj,jk), zwsmax * FLOAT( iiter1 ) )
+                 wsbio4(ji,jj,jk) = MIN( wsbio4(ji,jj,jk), zwsmax * FLOAT( iiter2 ) )
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      !  Initializa to zero all the sinking arrays 
+      !   -----------------------------------------
+      sinking (:,:,:) = 0.e0
+      sinking2(:,:,:) = 0.e0
+      sinkingn (:,:,:) = 0.e0
+      sinking2n(:,:,:) = 0.e0
+      sinkingp (:,:,:) = 0.e0
+      sinking2p(:,:,:) = 0.e0
+      sinkcal (:,:,:) = 0.e0
+      sinkfer (:,:,:) = 0.e0
+      sinksil (:,:,:) = 0.e0
+      sinkfer2(:,:,:) = 0.e0
+
+      !   Compute the sedimentation term using p4zsink2 for all the sinking particles
+      !   -----------------------------------------------------
+      DO jit = 1, iiter1
+        CALL p4z_sink2( wsbio3, sinking , jppoc, iiter1 )
+        CALL p4z_sink2( wsbio3, sinkingn , jppon, iiter1 )
+        CALL p4z_sink2( wsbio3, sinkingp , jppop, iiter1 )
+        CALL p4z_sink2( wsbio3, sinkfer , jpsfe, iiter1 )
+      END DO
+
+      DO jit = 1, iiter2
+        CALL p4z_sink2( wsbio4, sinking2, jpgoc, iiter2 )
+        CALL p4z_sink2( wsbio4, sinking2n, jpgon, iiter2 )
+        CALL p4z_sink2( wsbio4, sinking2p, jpgop, iiter2 )
+        CALL p4z_sink2( wsbio4, sinkfer2, jpbfe, iiter2 )
+        CALL p4z_sink2( wscal , sinksil , jpgsi, iiter2 )
+        CALL p4z_sink2( wscal , sinkcal , jpcal, iiter2 )
+      END DO
+
+      !  Exchange between organic matter compartments due to coagulation/disaggregation
+      !  ---------------------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !
+               zstep = xstep 
+# if defined key_degrad
+               zstep = zstep * facvol(ji,jj,jk)
+# endif
+               zfact = zstep * xdiss(ji,jj,jk)
+               !  Part I : Coagulation dependent on turbulence
+               zaggtmp = 25.9  * zfact * trn(ji,jj,jk,jppoc)
+               zaggpoc1 = zaggtmp * trn(ji,jj,jk,jppoc)
+               zaggtmp = 4452. * zfact * trn(ji,jj,jk,jpgoc)
+               zaggpoc2 = zaggtmp * trn(ji,jj,jk,jppoc)
+
+               ! Part II : Differential settling
+
+               !  Aggregation of small into large particles
+               zaggtmp =  47.1 * zstep * trn(ji,jj,jk,jpgoc)
+               zaggpoc3 = zaggtmp * trn(ji,jj,jk,jppoc)
+               zaggtmp =  3.3  * zstep * trn(ji,jj,jk,jppoc)
+               zaggpoc4 = zaggtmp * trn(ji,jj,jk,jppoc)
+
+               zaggpoc   = zaggpoc1 + zaggpoc2 + zaggpoc3 + zaggpoc4
+               zaggpon = zaggpoc * trn(ji,jj,jk,jppon) / ( trn(ji,jj,jk,jppoc) + rtrn)
+               zaggpop = zaggpoc * trn(ji,jj,jk,jppop) / ( trn(ji,jj,jk,jppoc) + rtrn)
+               zaggfe = zaggpoc * trn(ji,jj,jk,jpsfe) / ( trn(ji,jj,jk,jppoc)  + rtrn )
+
+               ! Aggregation of DOC to POC : 
+               ! 1st term is shear aggregation of DOC-DOC
+               ! 2nd term is shear aggregation of DOC-POC
+               ! 3rd term is differential settling of DOC-POC
+               zaggtmp = ( ( 0.369 * 0.3 * trn(ji,jj,jk,jpdoc) + 102.4 * trn(ji,jj,jk,jppoc) ) * zfact       &
+               &            + 2.4 * zstep * trn(ji,jj,jk,jppoc) )
+               zaggdoc  = zaggtmp * 0.3 * trn(ji,jj,jk,jpdoc)
+               zaggdon  = zaggtmp * 0.3 * trn(ji,jj,jk,jpdon)
+               zaggdop  = zaggtmp * 0.3 * trn(ji,jj,jk,jpdop)
+
+               ! transfer of DOC to GOC : 
+               ! 1st term is shear aggregation
+               ! 2nd term is differential settling 
+               zaggtmp = ( 3.53E3 * zfact + 0.1 * zstep ) * trn(ji,jj,jk,jpgoc)
+               zaggdoc2 = zaggtmp * 0.3 * trn(ji,jj,jk,jpdoc)
+               zaggdon2 = zaggtmp * 0.3 * trn(ji,jj,jk,jpdon)
+               zaggdop2 = zaggtmp * 0.3 * trn(ji,jj,jk,jpdop)
+
+               ! tranfer of DOC to POC due to brownian motion
+               zaggtmp = ( 5095. * trn(ji,jj,jk,jppoc) + 114. * 0.3 * trn(ji,jj,jk,jpdoc) ) *zstep
+               zaggdoc3 =  zaggtmp * 0.3 * trn(ji,jj,jk,jpdoc)
+               zaggdon3 =  zaggtmp * 0.3 * trn(ji,jj,jk,jpdon)
+               zaggdop3 =  zaggtmp * 0.3 * trn(ji,jj,jk,jpdop)
+
+               !  Update the trends
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) - zaggpoc + zaggdoc + zaggdoc3
+               tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) - zaggpon + zaggdon + zaggdon3
+               tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) - zaggpop + zaggdop + zaggdop3
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) + zaggpoc + zaggdoc2
+               tra(ji,jj,jk,jpgon) = tra(ji,jj,jk,jpgon) + zaggpon + zaggdon2
+               tra(ji,jj,jk,jpgop) = tra(ji,jj,jk,jpgop) + zaggpop + zaggdop2
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) - zaggfe
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + zaggfe
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) - zaggdoc - zaggdoc2 - zaggdoc3
+               tra(ji,jj,jk,jpdon) = tra(ji,jj,jk,jpdon) - zaggdon - zaggdon2 - zaggdon3
+               tra(ji,jj,jk,jpdop) = tra(ji,jj,jk,jpdop) - zaggdop - zaggdop2 - zaggdop3
+               !
+            END DO
+         END DO
+      END DO
+
+     ! Total primary production per year
+     t_oce_co2_exp = t_oce_co2_exp + glob_sum( ( sinking(:,:,iksed+1) + sinking2(:,:,iksed+1) ) * e1e2t(:,:) * tmask(:,:,1) )
+     !
+     IF( ln_diatrc ) THEN
+         zrfact2 = 1.e3 * rfact2r
+         ik1  = iksed + 1
+         IF( lk_iomput ) THEN
+           IF( jnt == nrdttrc ) THEN
+              CALL iom_put( "EPC100"  , ( sinking(:,:,ik1) + sinking2(:,:,ik1) ) * zrfact2 * tmask(:,:,1) ) ! Export of carbon at 100m
+              CALL iom_put( "EPFE100" , ( sinkfer(:,:,ik1) + sinkfer2(:,:,ik1) ) * zrfact2 * tmask(:,:,1) ) ! Export of iron at 100m
+              CALL iom_put( "EPCAL100",   sinkcal(:,:,ik1)                       * zrfact2 * tmask(:,:,1) ) ! Export of calcite  at 100m
+              CALL iom_put( "EPSI100" ,   sinksil(:,:,ik1)                       * zrfact2 * tmask(:,:,1) ) ! Export of biogenic silica at 100m
+           ENDIF
+         ELSE
+           trc2d(:,:,jp_pcs0_2d + 4) = sinking (:,:,ik1) * zrfact2 * tmask(:,:,1)
+           trc2d(:,:,jp_pcs0_2d + 5) = sinking2(:,:,ik1) * zrfact2 * tmask(:,:,1)
+           trc2d(:,:,jp_pcs0_2d + 6) = sinkfer (:,:,ik1) * zrfact2 * tmask(:,:,1)
+           trc2d(:,:,jp_pcs0_2d + 7) = sinkfer2(:,:,ik1) * zrfact2 * tmask(:,:,1)
+           trc2d(:,:,jp_pcs0_2d + 8) = sinksil (:,:,ik1) * zrfact2 * tmask(:,:,1)
+           trc2d(:,:,jp_pcs0_2d + 9) = sinkcal (:,:,ik1) * zrfact2 * tmask(:,:,1)
+         ENDIF
+      ENDIF
+      !
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('sink')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_sink')
+      !
+   END SUBROUTINE p5z_sink
+
+   SUBROUTINE p5z_sink_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_sink_init  ***
+      !!----------------------------------------------------------------------
+
+      t_oce_co2_exp = 0._wp
+      !
+   END SUBROUTINE p5z_sink_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   'Kriest sinking parameterisation'        key_kriest          ???
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE p5z_sink ( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                ***  ROUTINE p5z_sink  ***
+      !!
+      !! ** Purpose :   Compute vertical flux of particulate matter due to
+      !!              gravitational sinking - Kriest parameterization
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      !
+      INTEGER, INTENT(in) :: kt, jnt
+      !
+      INTEGER  :: ji, jj, jk, jit, niter1, niter2
+      REAL(wp) :: zagg1, zagg2, zagg3, zagg4, zagg5, zfract, zaggsi, zaggsh
+      REAL(wp) :: zagg , zaggdoc, zaggdoc1, znumdoc
+      REAL(wp) :: znum , zeps, zfm, zgm, zsm, zfactn, zfactp
+      REAL(wp) :: zdiv , zdiv1, zdiv2, zdiv3, zdiv4, zdiv5
+      REAL(wp) :: zval1, zval2, zval3, zval4
+      REAL(wp) :: zrfact2
+      INTEGER  :: ik1
+      CHARACTER (len=25) :: charout
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: znum3d 
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_sink')
+      !
+      CALL wrk_alloc( jpi, jpj, jpk, znum3d )
+      !
+      !     Initialisation of variables used to compute Sinking Speed
+      !     ---------------------------------------------------------
+
+      znum3d(:,:,:) = 0.e0
+      zval1 = 1. + xkr_zeta
+      zval2 = 1. + xkr_zeta + xkr_eta
+      zval3 = 1. + xkr_eta
+
+      !     Computation of the vertical sinking speed : Kriest et Evans, 2000
+      !     -----------------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tmask(ji,jj,jk) /= 0.e0 ) THEN
+                  znum = trn(ji,jj,jk,jppoc) / ( trn(ji,jj,jk,jpnum) + rtrn ) / xkr_massp
+                  ! -------------- To avoid sinking speed over 50 m/day -------
+                  znum  = MIN( xnumm(jk), znum )
+                  znum  = MAX( 1.1      , znum )
+                  znum3d(ji,jj,jk) = znum
+                  !------------------------------------------------------------
+                  zeps  = ( zval1 * znum - 1. )/ ( znum - 1. )
+                  zfm   = xkr_frac**( 1. - zeps )
+                  zgm   = xkr_frac**( zval1 - zeps )
+                  zdiv  = MAX( 1.e-4, ABS( zeps - zval2 ) ) * SIGN( 1., ( zeps - zval2 ) )
+                  zdiv1 = zeps - zval3
+                  wsbio3(ji,jj,jk) = xkr_wsbio_min * ( zeps - zval1 ) / zdiv    &
+                     &             - xkr_wsbio_max *   zgm * xkr_eta  / zdiv
+                  wsbio4(ji,jj,jk) = xkr_wsbio_min *   ( zeps-1. )    / zdiv1   &
+                     &             - xkr_wsbio_max *   zfm * xkr_eta  / zdiv1
+                  IF( znum == 1.1)   wsbio3(ji,jj,jk) = wsbio4(ji,jj,jk)
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      wscal(:,:,:) = MAX( wsbio3(:,:,:), 30._wp )
+
+      !   INITIALIZE TO ZERO ALL THE SINKING ARRAYS
+      !   -----------------------------------------
+
+      sinking (:,:,:) = 0.e0
+      sinkingn(:,:,:) = 0.e0
+      sinkingp(:,:,:) = 0.e0
+      sinking2(:,:,:) = 0.e0
+      sinkcal (:,:,:) = 0.e0
+      sinkfer (:,:,:) = 0.e0
+      sinksil (:,:,:) = 0.e0
+
+     !   Compute the sedimentation term using p4zsink2 for all the sinking particles
+     !   -----------------------------------------------------
+
+      niter1 = niter1max
+      niter2 = niter2max
+
+      DO jit = 1, niter1
+        CALL p4z_sink2( wsbio3, sinking , jppoc, niter1 )
+        CALL p4z_sink2( wsbio3, sinkingn, jppon, niter1 )
+        CALL p4z_sink2( wsbio3, sinkingp, jppop, niter1 )
+        CALL p4z_sink2( wsbio3, sinkfer , jpsfe, niter1 )
+        CALL p4z_sink2( wscal , sinksil , jpgsi, niter1 )
+        CALL p4z_sink2( wscal , sinkcal , jpcal, niter1 )
+      END DO
+
+      DO jit = 1, niter2
+        CALL p4z_sink2( wsbio4, sinking2, jpnum, niter2 )
+      END DO
+
+     !  Exchange between organic matter compartments due to coagulation/disaggregation
+     !  ---------------------------------------------------
+
+      zval1 = 1. + xkr_zeta
+      zval2 = 1. + xkr_eta
+      zval3 = 3. + xkr_eta
+      zval4 = 4. + xkr_eta
+
+      DO jk = 1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               IF( tmask(ji,jj,jk) /= 0.e0 ) THEN
+
+                  znum = trn(ji,jj,jk,jppoc)/(trn(ji,jj,jk,jpnum)+rtrn) / xkr_massp
+                  !-------------- To avoid sinking speed over 50 m/day -------
+                  znum  = min(xnumm(jk),znum)
+                  znum  = MAX( 1.1,znum)
+                  !------------------------------------------------------------
+                  zeps  = ( zval1 * znum - 1.) / ( znum - 1.)
+                  zdiv  = MAX( 1.e-4, ABS( zeps - zval3) ) * SIGN( 1., zeps - zval3 )
+                  zdiv1 = MAX( 1.e-4, ABS( zeps - 4.   ) ) * SIGN( 1., zeps - 4.    )
+                  zdiv2 = zeps - 2.
+                  zdiv3 = zeps - 3.
+                  zdiv4 = zeps - zval2
+                  zdiv5 = 2.* zeps - zval4
+                  zfm   = xkr_frac**( 1.- zeps )
+                  zsm   = xkr_frac**xkr_eta
+
+                  !    Part I : Coagulation dependant on turbulence
+                  !    ----------------------------------------------
+                  zagg1 =  0.163  * trn(ji,jj,jk,jpnum)**2                                 &
+                     &            * 2.*( (zfm-1.)*(zfm*xkr_mass_max**3-xkr_mass_min**3)    &
+                     &            * (zeps-1)/zdiv1 + 3.*(zfm*xkr_mass_max-xkr_mass_min)    &
+                     &            * (zfm*xkr_mass_max**2-xkr_mass_min**2)                  &
+                     &            * (zeps-1.)**2/(zdiv2*zdiv3)) 
+                  zagg2 =  2*0.163*trn(ji,jj,jk,jpnum)**2*zfm                        &
+                     &            * ((xkr_mass_max**3+3.*(xkr_mass_max**2            &
+                     &            * xkr_mass_min*(zeps-1.)/zdiv2                     &
+                     &            + xkr_mass_max*xkr_mass_min**2*(zeps-1.)/zdiv3)    &
+                     &            + xkr_mass_min**3*(zeps-1)/zdiv1)                  &
+                     &            - zfm*xkr_mass_max**3*(1.+3.*((zeps-1.)            &
+                     &            / (zeps-2.)+(zeps-1.)/zdiv3)+(zeps-1.)/zdiv1))    
+
+                  zagg3 =  0.163*trn(ji,jj,jk,jpnum)**2*zfm**2*8. * xkr_mass_max**3  
+                  
+                 !    Aggregation of small into large particles
+                 !    Part II : Differential settling
+                 !    ----------------------------------------------
+                  zagg4 =  2.*3.141*0.125*trn(ji,jj,jk,jpnum)**2*                       &
+                     &                 xkr_wsbio_min*(zeps-1.)**2                         &
+                     &                 *(xkr_mass_min**2*((1.-zsm*zfm)/(zdiv3*zdiv4)      &
+                     &                 -(1.-zfm)/(zdiv*(zeps-1.)))-                       &
+                     &                 ((zfm*zfm*xkr_mass_max**2*zsm-xkr_mass_min**2)     &
+                     &                 *xkr_eta)/(zdiv*zdiv3*zdiv5) )   
+
+                  zagg5 =   2.*3.141*0.125*trn(ji,jj,jk,jpnum)**2                         &
+                     &                 *(zeps-1.)*zfm*xkr_wsbio_min                        &
+                     &                 *(zsm*(xkr_mass_min**2-zfm*xkr_mass_max**2)         &
+                     &                 /zdiv3-(xkr_mass_min**2-zfm*zsm*xkr_mass_max**2)    &
+                     &                 /zdiv)  
+
+                  !
+                  !     Fractionnation by swimming organisms
+                  !     ------------------------------------
+                  zfract = 2.*3.141*0.125*trn(ji,jj,jk,jpmes)*12./0.12/0.06**3*trn(ji,jj,jk,jpnum)  &
+                    &      * (0.01/xkr_mass_min)**(1.-zeps)*0.1**2  &
+                    &      * 10000.*xstep
+
+                  !     Aggregation of DOC to small particles
+                  !     --------------------------------------
+                  zaggdoc = 0.83 * trn(ji,jj,jk,jpdoc) * xstep * xdiss(ji,jj,jk) * trn(ji,jj,jk,jpdoc)   &
+                     &        + 0.005 * 231. * trn(ji,jj,jk,jpdoc) * xstep * trn(ji,jj,jk,jpdoc)
+                  zaggdoc1 = 271. * trn(ji,jj,jk,jppoc) * xstep * xdiss(ji,jj,jk) * trn(ji,jj,jk,jpdoc)  &
+                     &  + 0.02 * 16706. * trn(ji,jj,jk,jppoc) * xstep * trn(ji,jj,jk,jpdoc)
+
+# if defined key_degrad
+                   zagg1   = zagg1   * facvol(ji,jj,jk)                 
+                   zagg2   = zagg2   * facvol(ji,jj,jk)                 
+                   zagg3   = zagg3   * facvol(ji,jj,jk)                 
+                   zagg4   = zagg4   * facvol(ji,jj,jk)                 
+                   zagg5   = zagg5   * facvol(ji,jj,jk)                 
+                   zaggdoc = zaggdoc * facvol(ji,jj,jk)                 
+                   zaggdoc1 = zaggdoc1 * facvol(ji,jj,jk)
+# endif
+                  zaggsh = ( zagg1 + zagg2 + zagg3 ) * rfact2 * xdiss(ji,jj,jk) / 1000.
+                  zaggsi = ( zagg4 + zagg5 ) * xstep / 10.
+                  zagg = 0.5 * xkr_stick * ( zaggsh + zaggsi )
+                  !
+                  znumdoc = trn(ji,jj,jk,jpnum) / ( trn(ji,jj,jk,jppoc) + rtrn )
+                  tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zaggdoc + zaggdoc1
+                  zfactn  = trn(ji,jj,jk,jpdon) / ( trn(ji,jj,jk,jpdoc) + rtrn )
+                  tra(ji,jj,jk,jppon) = tra(ji,jj,jk,jppon) + ( zaggdoc + zaggdoc1 ) * zfactn
+                  zfactp  = trn(ji,jj,jk,jpdop) / ( trn(ji,jj,jk,jpdoc) + rtrn )
+                  tra(ji,jj,jk,jppop) = tra(ji,jj,jk,jppop) + ( zaggdoc + zaggdoc1 ) * zfactp
+                  tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + zfract + zaggdoc / xkr_massp - zagg
+                  tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) - zaggdoc - zaggdoc1
+
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+     ! Total primary production per year
+     t_oce_co2_exp = t_oce_co2_exp + glob_sum( ( sinking(:,:,:) ) * cvol(:,:,:) )
+     !
+      IF( ln_diatrc ) THEN
+         !
+         ik1 = iksed + 1
+         zrfact2 = 1.e3 * rfact2r
+         IF( jnt == nrdttrc ) THEN
+           CALL iom_put( "POCFlx"  , sinking (:,:,:)      * zrfact2 * tmask(:,:,:) )  ! POC export
+           CALL iom_put( "NumFlx"  , sinking2 (:,:,:)     * zrfact2 * tmask(:,:,:) )  ! Num export
+           CALL iom_put( "SiFlx"   , sinksil (:,:,:)      * zrfact2 * tmask(:,:,:) )  ! Silica export
+           CALL iom_put( "CaCO3Flx", sinkcal (:,:,:)      * zrfact2 * tmask(:,:,:) )  ! Calcite export
+           CALL iom_put( "xnum"    , znum3d  (:,:,:)                * tmask(:,:,:) )  ! Number of particles in aggregats
+           CALL iom_put( "W1"      , wsbio3  (:,:,:)                * tmask(:,:,:) )  ! sinking speed of POC
+           CALL iom_put( "W2"      , wsbio4  (:,:,:)                * tmask(:,:,:) )  ! sinking speed of aggregats
+         ENDIF
+# if ! defined key_iomput
+         trc2d(:,:  ,jp_pcs0_2d + 4)  = sinking (:,:,ik1)    * zrfact2 * tmask(:,:,1)
+         trc2d(:,:  ,jp_pcs0_2d + 5)  = sinking2(:,:,ik1)    * zrfact2 * tmask(:,:,1)
+         trc2d(:,:  ,jp_pcs0_2d + 6)  = sinkfer (:,:,ik1)    * zrfact2 * tmask(:,:,1)
+         trc2d(:,:  ,jp_pcs0_2d + 7)  = sinksil (:,:,ik1)    * zrfact2 * tmask(:,:,1)
+         trc2d(:,:  ,jp_pcs0_2d + 8)  = sinkcal (:,:,ik1)    * zrfact2 * tmask(:,:,1)
+         trc3d(:,:,:,jp_pcs0_3d + 11) = sinking (:,:,:)      * zrfact2 * tmask(:,:,:)
+         trc3d(:,:,:,jp_pcs0_3d + 12) = sinking2(:,:,:)      * zrfact2 * tmask(:,:,:)
+         trc3d(:,:,:,jp_pcs0_3d + 13) = sinksil (:,:,:)      * zrfact2 * tmask(:,:,:)
+         trc3d(:,:,:,jp_pcs0_3d + 14) = sinkcal (:,:,:)      * zrfact2 * tmask(:,:,:)
+         trc3d(:,:,:,jp_pcs0_3d + 15) = znum3d  (:,:,:)                * tmask(:,:,:)
+         trc3d(:,:,:,jp_pcs0_3d + 16) = wsbio3  (:,:,:)                * tmask(:,:,:)
+         trc3d(:,:,:,jp_pcs0_3d + 17) = wsbio4  (:,:,:)                * tmask(:,:,:)
+# endif
+        !
+      ENDIF
+      !
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('sink')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi, jpj, jpk, znum3d )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_sink')
+      !
+   END SUBROUTINE p5z_sink
+
+
+   SUBROUTINE p5z_sink_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_sink_init  ***
+      !!
+      !! ** Purpose :   Initialization of sinking parameters
+      !!                Kriest parameterization only
+      !!
+      !! ** Method  :   Read the nampiskrs namelist and check the parameters
+      !!      called at the first timestep 
+      !!
+      !! ** input   :   Namelist nampiskrs
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jk, jn, kiter
+      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      REAL(wp) ::   znum, zdiv
+      REAL(wp) ::   zws, zwr, zwl,wmax, znummax
+      REAL(wp) ::   zmin, zmax, zl, zr, xacc
+      !
+      NAMELIST/nampiskrs/ xkr_sfact, xkr_stick ,  &
+         &                xkr_nnano, xkr_ndiat, xkr_nmicro, xkr_nmeso, xkr_naggr
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_sink_init')
+      !
+
+      REWIND( numnatp_ref )              ! Namelist nampiskrs in reference namelist : Pisces sinking Kriest
+      READ  ( numnatp_ref, nampiskrs, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampiskrs in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampiskrs in configuration namelist : Pisces sinking Kriest
+      READ  ( numnatp_cfg, nampiskrs, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampiskrs in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampiskrs )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : nampiskrs'
+         WRITE(numout,*) '    Sinking factor                           xkr_sfact    = ', xkr_sfact
+         WRITE(numout,*) '    Stickiness                               xkr_stick    = ', xkr_stick
+         WRITE(numout,*) '    Nbr of cell in nano size class           xkr_nnano    = ', xkr_nnano
+         WRITE(numout,*) '    Nbr of cell in diatoms size class        xkr_ndiat    = ', xkr_ndiat
+         WRITE(numout,*) '    Nbr of cell in microzoo size class       xkr_nmicro   = ', xkr_nmicro
+         WRITE(numout,*) '    Nbr of cell in mesozoo size class        xkr_nmeso    = ', xkr_nmeso
+         WRITE(numout,*) '    Nbr of cell in aggregates size class     xkr_naggr    = ', xkr_naggr
+      ENDIF
+
+
+      ! max and min vertical particle speed
+      xkr_wsbio_min = xkr_sfact * xkr_mass_min**xkr_eta
+      xkr_wsbio_max = xkr_sfact * xkr_mass_max**xkr_eta
+      IF (lwp) WRITE(numout,*) ' max and min vertical particle speed ', xkr_wsbio_min, xkr_wsbio_max
+
+      !
+      !    effect of the sizes of the different living pools on particle numbers
+      !    nano = 2um-20um -> mean size=6.32 um -> ws=2.596 -> xnum=xnnano=2.337
+      !    diat and microzoo = 10um-200um -> 44.7 -> 8.732 -> xnum=xndiat=3.718
+      !    mesozoo = 200um-2mm -> 632.45 -> 45.14 -> xnum=xnmeso=7.147
+      !    aggregates = 200um-10mm -> 1414 -> 74.34 -> xnum=xnaggr=9.877
+      !    doc aggregates = 1um
+      ! ----------------------------------------------------------
+
+      xkr_dnano = 1. / ( xkr_massp * xkr_nnano )
+      xkr_ddiat = 1. / ( xkr_massp * xkr_ndiat )
+      xkr_dmicro = 1. / ( xkr_massp * xkr_nmicro )
+      xkr_dmeso = 1. / ( xkr_massp * xkr_nmeso )
+      xkr_daggr = 1. / ( xkr_massp * xkr_naggr )
+
+      !!---------------------------------------------------------------------
+      !!    'key_kriest'                                                  ???
+      !!---------------------------------------------------------------------
+      !  COMPUTATION OF THE VERTICAL PROFILE OF MAXIMUM SINKING SPEED
+      !  Search of the maximum number of particles in aggregates for each k-level.
+      !  Bissection Method
+      !--------------------------------------------------------------------
+      IF (lwp) THEN
+        WRITE(numout,*)
+        WRITE(numout,*)'    kriest : Compute maximum number of particles in aggregates'
+      ENDIF
+
+      xacc     =  0.001_wp
+      kiter    = 50
+      zmin     =  1.10_wp
+      zmax     = xkr_mass_max / xkr_mass_min
+      xkr_frac = zmax
+
+      DO jk = 1,jpk
+         zl = zmin
+         zr = zmax
+         wmax = 0.5 * fse3t(1,1,jk) * rday * float(niter1max) / rfact2
+         zdiv = xkr_zeta + xkr_eta - xkr_eta * zl
+         znum = zl - 1.
+         zwl =  xkr_wsbio_min * xkr_zeta / zdiv &
+            & - ( xkr_wsbio_max * xkr_eta * znum * &
+            &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+            & - wmax
+
+         zdiv = xkr_zeta + xkr_eta - xkr_eta * zr
+         znum = zr - 1.
+         zwr =  xkr_wsbio_min * xkr_zeta / zdiv &
+            & - ( xkr_wsbio_max * xkr_eta * znum * &
+            &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+            & - wmax
+iflag:   DO jn = 1, kiter
+            IF    ( zwl == 0._wp ) THEN   ;   znummax = zl
+            ELSEIF( zwr == 0._wp ) THEN   ;   znummax = zr
+            ELSE
+               znummax = ( zr + zl ) / 2.
+               zdiv = xkr_zeta + xkr_eta - xkr_eta * znummax
+               znum = znummax - 1.
+               zws =  xkr_wsbio_min * xkr_zeta / zdiv &
+                  & - ( xkr_wsbio_max * xkr_eta * znum * &
+                  &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+                  & - wmax
+               IF( zws * zwl < 0. ) THEN   ;   zr = znummax
+               ELSE                        ;   zl = znummax
+               ENDIF
+               zdiv = xkr_zeta + xkr_eta - xkr_eta * zl
+               znum = zl - 1.
+               zwl =  xkr_wsbio_min * xkr_zeta / zdiv &
+                  & - ( xkr_wsbio_max * xkr_eta * znum * &
+                  &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+                  & - wmax
+
+               zdiv = xkr_zeta + xkr_eta - xkr_eta * zr
+               znum = zr - 1.
+               zwr =  xkr_wsbio_min * xkr_zeta / zdiv &
+                  & - ( xkr_wsbio_max * xkr_eta * znum * &
+                  &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+                  & - wmax
+               !
+               IF ( ABS ( zws )  <= xacc ) EXIT iflag
+               !
+            ENDIF
+            !
+         END DO iflag
+
+         xnumm(jk) = znummax
+         IF (lwp) WRITE(numout,*) '       jk = ', jk, ' wmax = ', wmax,' xnum max = ', xnumm(jk)
+         !
+      END DO
+      !
+      t_oce_co2_exp = 0._wp
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_sink_init')
+      !
+  END SUBROUTINE p5z_sink_init
+
+#endif
+
+   SUBROUTINE p4z_sink2( pwsink, psinkflx, jp_tra, kiter )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_sink2  ***
+      !!
+      !! ** Purpose :   Compute the sedimentation terms for the various sinking
+      !!     particles. The scheme used to compute the trends is based
+      !!     on MUSCL.
+      !!
+      !! ** Method  : - this ROUTINE compute not exactly the advection but the
+      !!      transport term, i.e.  div(u*tra).
+      !!---------------------------------------------------------------------
+      !
+      INTEGER , INTENT(in   )                         ::   jp_tra    ! tracer index index      
+      INTEGER , INTENT(in   )                         ::   kiter     ! number of iterations for time-splitting 
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpk) ::   pwsink    ! sinking speed
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   psinkflx  ! sinking fluxe
+      !!
+      INTEGER  ::   ji, jj, jk, jn
+      REAL(wp) ::   zigma,zew,zign, zflx, zstep
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: ztraz, zakz, zwsink2, ztrb 
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p4z_sink2')
+      !
+      ! Allocate temporary workspace
+      CALL wrk_alloc( jpi, jpj, jpk, ztraz, zakz, zwsink2, ztrb )
+
+      zstep = rfact2 / FLOAT( kiter ) / 2.
+
+      ztraz(:,:,:) = 0.e0
+      zakz (:,:,:) = 0.e0
+      ztrb (:,:,:) = trn(:,:,:,jp_tra)
+
+      DO jk = 1, jpkm1
+         zwsink2(:,:,jk+1) = -pwsink(:,:,jk) / rday * tmask(:,:,jk+1) 
+      END DO
+      zwsink2(:,:,1) = 0.e0
+      IF( lk_degrad ) THEN
+         zwsink2(:,:,:) = zwsink2(:,:,:) * facvol(:,:,:)
+      ENDIF
+
+
+      ! Vertical advective flux
+      DO jn = 1, 2
+         !  first guess of the slopes interior values
+         DO jk = 2, jpkm1
+            ztraz(:,:,jk) = ( trn(:,:,jk-1,jp_tra) - trn(:,:,jk,jp_tra) ) * tmask(:,:,jk)
+         END DO
+         ztraz(:,:,1  ) = 0.0
+         ztraz(:,:,jpk) = 0.0
+
+         ! slopes
+         DO jk = 2, jpkm1
+            DO jj = 1,jpj
+               DO ji = 1, jpi
+                  zign = 0.25 + SIGN( 0.25, ztraz(ji,jj,jk) * ztraz(ji,jj,jk+1) )
+                  zakz(ji,jj,jk) = ( ztraz(ji,jj,jk) + ztraz(ji,jj,jk+1) ) * zign
+               END DO
+            END DO
+         END DO
+         
+         ! Slopes limitation
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zakz(ji,jj,jk) = SIGN( 1., zakz(ji,jj,jk) ) *        &
+                     &             MIN( ABS( zakz(ji,jj,jk) ), 2. * ABS(ztraz(ji,jj,jk+1)), 2. * ABS(ztraz(ji,jj,jk) ) )
+               END DO
+            END DO
+         END DO
+         
+         ! vertical advective flux
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj      
+               DO ji = 1, jpi    
+                  zigma = zwsink2(ji,jj,jk+1) * zstep / fse3w(ji,jj,jk+1)
+                  zew   = zwsink2(ji,jj,jk+1)
+                  psinkflx(ji,jj,jk+1) = -zew * ( trn(ji,jj,jk,jp_tra) - 0.5 * ( 1 + zigma ) * zakz(ji,jj,jk) ) * zstep
+               END DO
+            END DO
+         END DO
+         !
+         ! Boundary conditions
+         psinkflx(:,:,1  ) = 0.e0
+         psinkflx(:,:,jpk) = 0.e0
+         
+         DO jk=1,jpkm1
+            DO jj = 1,jpj
+               DO ji = 1, jpi
+                  zflx = ( psinkflx(ji,jj,jk) - psinkflx(ji,jj,jk+1) ) / fse3t(ji,jj,jk)
+                  trn(ji,jj,jk,jp_tra) = trn(ji,jj,jk,jp_tra) + zflx
+               END DO
+            END DO
+         END DO
+
+      ENDDO
+
+      DO jk = 1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1, jpi
+               zflx = ( psinkflx(ji,jj,jk) - psinkflx(ji,jj,jk+1) ) / fse3t(ji,jj,jk)
+               ztrb(ji,jj,jk) = ztrb(ji,jj,jk) + 2. * zflx
+            END DO
+         END DO
+      END DO
+
+      trn(:,:,:,jp_tra) = ztrb(:,:,:)
+      psinkflx(:,:,:)   = 2. * psinkflx(:,:,:)
+      !
+      CALL wrk_dealloc( jpi, jpj, jpk, ztraz, zakz, zwsink2, ztrb )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('p4z_sink2')
+      !
+   END SUBROUTINE p4z_sink2
+
+
+   INTEGER FUNCTION p5z_sink_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_sink_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( wsbio3 (jpi,jpj,jpk) , wsbio4  (jpi,jpj,jpk) , wscal(jpi,jpj,jpk) ,     &
+         &      sinking(jpi,jpj,jpk) , sinking2(jpi,jpj,jpk)  ,     &                
+         &      sinkingn(jpi,jpj,jpk) , sinking2n(jpi,jpj,jpk) ,     &
+         &      sinkingp(jpi,jpj,jpk) , sinking2p(jpi,jpj,jpk) ,     &
+
+         &      sinkcal(jpi,jpj,jpk) , sinksil (jpi,jpj,jpk)   ,     &    
+#if defined key_kriest
+         &      xnumm(jpk)                                                        ,     &                
+#else
+         &      sinkfer2(jpi,jpj,jpk)                                             ,     &                
+#endif
+         &      sinkfer(jpi,jpj,jpk)     , STAT=p5z_sink_alloc )                
+         !
+      IF( p5z_sink_alloc /= 0 ) CALL ctl_warn('p5z_sink_alloc : failed to allocate arrays.')
+      !
+   END FUNCTION p5z_sink_alloc
+   
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_sink                    ! Empty routine
+   END SUBROUTINE p5z_sink
+#endif 
+
+   !!======================================================================
+END MODULE  p5zsink
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsms.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsms.F90	(revision 5266)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p5zsms.F90	(revision 5266)
@@ -0,0 +1,485 @@
+MODULE p5zsms
+   !!======================================================================
+   !!                         ***  MODULE p5zsms  ***
+   !! TOP :   PISCES Source Minus Sink manager
+   !!======================================================================
+   !! History :   1.0  !  2004-03 (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces_quota
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p5zsms        :  Time loop of passive tracers sms
+   !!----------------------------------------------------------------------
+   USE oce_trc         !  shared variables between ocean and passive tracers
+   USE trc             !  passive tracers common variables 
+   USE trcdta
+   USE sms_pisces      !  PISCES Source Minus Sink variables
+   USE p5zbio          !  Biological model
+   USE p4zche          !  Chemical model
+   USE p4zlys          !  Calcite saturation
+   USE p4zflx          !  Gas exchange
+   USE p4zsbc          !  External source of nutrients
+   USE p5zsed          !  Sedimentation
+   USE p4zint          !  time interpolation
+   USE iom             !  I/O manager
+   USE trdmod_oce      !  Ocean trends variables
+   USE trdmod_trc      !  TOP trends variables
+   USE sedmodel        !  Sediment model
+   USE prtctl_trc      !  print control for debugging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p5z_sms_init    ! called in p5zsms.F90
+   PUBLIC   p5z_sms    ! called in p5zsms.F90
+
+   REAL(wp) :: alkbudget, no3budget, silbudget, ferbudget
+   INTEGER ::  numco2, numnut  !: logical unit for co2 budget
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id: p4zsms.F90 3320 2012-03-05 16:37:52Z cetlod $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p5z_sms( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p5z_sms  ***
+      !!
+      !! ** Purpose :   Managment of the call to Biological sources and sinks 
+      !!              routines of PISCES bio-model
+      !!
+      !! ** Method  : - at each new day ...
+      !!              - several calls of bio and sed ???
+      !!              - ...
+      !!---------------------------------------------------------------------
+      !
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+      !!
+      INTEGER ::   ji,jj,jk,jnt, jn, jl
+      CHARACTER (len=25) :: charout
+      REAL(wp), POINTER, DIMENSION(:,:,:,:)  :: ztrdpis
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('p5z_sms')
+      !
+      IF( l_trdtrc )  THEN
+         CALL wrk_alloc( jpi, jpj, jpk, jp_pisces, ztrdpis ) 
+         DO jn = 1, jp_pisces
+            jl = jn + jp_pcs0 - 1
+            ztrdpis(:,:,:,jn) = trn(:,:,:,jl)
+         ENDDO
+      ENDIF
+      !
+      IF( kt == nittrc000 ) THEN
+        !
+        CALL p4z_che                              ! initialize the chemical constants
+        !
+        IF( .NOT. ln_rsttr ) THEN  ;   CALL p4z_ph_ini   !  set PH at kt=nit000 
+        ELSE                       ;   CALL p5z_rst( nittrc000, 'READ' )  !* read or initialize all required fields 
+        ENDIF
+        !
+      ENDIF
+      !
+      IF( ln_pisdmp .AND. MOD( kt - nn_dttrc, nn_pisdmp ) == 0 )   CALL p4z_dmp( kt )      ! Relaxation of some tracers
+      !
+      IF( ndayflxtr /= nday_year ) THEN      ! New days
+         !
+         ndayflxtr = nday_year
+
+         IF(lwp) write(numout,*)
+         IF(lwp) write(numout,*) ' New chemical constants and various rates for biogeochemistry at new day : ', nday_year
+         IF(lwp) write(numout,*) '~~~~~~'
+
+         CALL p4z_che              ! computation of chemical constants
+         CALL p4z_int( kt )        ! computation of various rates for biogeochemistry
+         !
+      ENDIF
+
+      IF( ll_sbc ) CALL p4z_sbc( kt )   ! external sources of nutrients 
+
+      DO jnt = 1, nrdttrc          ! Potential time splitting if requested
+         !
+         CALL p5z_bio (kt, jnt)    ! Biology
+         CALL p5z_sed (kt, jnt)    ! Sedimentation
+         !
+         DO jn = jp_pcs0, jp_pcs1
+            trb(:,:,:,jn) = trn(:,:,:,jn)
+         ENDDO
+         !
+      END DO
+
+      IF( l_trdtrc )  THEN
+         DO jn = 1, jp_pisces
+            jl = jn + jp_pcs0 - 1
+            ztrdpis(:,:,:,jn) = ( ztrdpis(:,:,:,jn) - trn(:,:,:,jl) ) * rfact2r
+         ENDDO
+      ENDIF
+
+      CALL p4z_lys( kt )             ! Compute CaCO3 saturation
+      CALL p4z_flx( kt )             ! Compute surface fluxes
+
+      DO jn = jp_pcs0, jp_pcs1
+        CALL lbc_lnk( trn(:,:,:,jn), 'T', 1. )
+        CALL lbc_lnk( trb(:,:,:,jn), 'T', 1. )
+        CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )
+      END DO
+      !
+      IF( lk_sed ) THEN 
+         !
+         CALL sed_model( kt )     !  Main program of Sediment model
+         !
+         DO jn = jp_pcs0, jp_pcs1
+           CALL lbc_lnk( trn(:,:,:,jn), 'T', 1. )
+         END DO
+         !
+      ENDIF
+      !
+      IF( lrst_trc )  CALL p5z_rst( kt, 'WRITE' )  !* Write PISCES informations in restart file 
+      !
+      IF( l_trdtrc ) THEN
+         DO jn = 1, jp_pisces
+            jl = jn + jp_pcs0 - 1
+             ztrdpis(:,:,:,jn) = ztrdpis(:,:,:,jn) + tra(:,:,:,jl)
+             CALL trd_mod_trc( ztrdpis(:,:,:,jn), jn, jptra_trd_sms, kt )   ! save trends
+          END DO
+          CALL wrk_dealloc( jpi, jpj, jpk, jp_pisces, ztrdpis ) 
+      END IF
+      !
+      CALL p5z_chk_mass( kt ) ! Mass conservation checking
+
+      IF ( lwm .AND. kt == nittrc000 ) CALL FLUSH    ( numonp )     ! flush output namelist PISCES
+      IF( nn_timing == 1 )  CALL timing_stop('p5z_sms')
+      !
+      !
+   END SUBROUTINE p5z_sms
+
+   SUBROUTINE p5z_sms_init
+      !!----------------------------------------------------------------------
+      !!                     ***  p5z_sms_init  ***  
+      !!
+      !! ** Purpose :   read PISCES namelist
+      !!
+      !! ** input   :   file 'namelist.trc.s' containing the following
+      !!             namelist: natext, natbio, natsms
+      !!                       natkriest ("key_kriest")
+      !!----------------------------------------------------------------------
+      NAMELIST/nampisbio/ nrdttrc, wsbio, xkmort, ferat3, no3rat3, po4rat3, wsbio2, niter1max, niter2max
+#if defined key_kriest
+      NAMELIST/nampiskrp/ xkr_eta, xkr_zeta, xkr_ncontent, xkr_mass_min, xkr_mass_max
+#endif
+      NAMELIST/nampisdmp/ ln_pisdmp, nn_pisdmp
+      NAMELIST/nampismass/ ln_check_mass
+      INTEGER :: ios                 ! Local integer output status for namelist read
+      !!----------------------------------------------------------------------
+
+      REWIND( numnatp_ref )              ! Namelist nampisbio in reference namelist : Pisces variables
+      READ  ( numnatp_ref, nampisbio, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisbio in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampisbio in configuration namelist : Pisces variables
+      READ  ( numnatp_cfg, nampisbio, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisbio in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampisbio )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' Namelist : nampisbio'
+         WRITE(numout,*) '    frequence pour la biologie                nrdttrc   =', nrdttrc
+         WRITE(numout,*) '    POC sinking speed                         wsbio     =', wsbio
+         WRITE(numout,*) '    half saturation constant for mortality    xkmort    =', xkmort
+         WRITE(numout,*) '    N/C in zooplankton                        no3rat3   =', no3rat3
+         WRITE(numout,*) '    P/C in zooplankton                        po4rat3   =', po4rat3
+         WRITE(numout,*) '    Fe/C in zooplankton                       ferat3    =', ferat3
+         WRITE(numout,*) '    Big particles sinking speed               wsbio2    =', wsbio2
+         WRITE(numout,*) '    Maximum number of iterations for POC      niter1max =', niter1max
+         WRITE(numout,*) '    Maximum number of iterations for GOC      niter2max =', niter2max
+      ENDIF
+
+#if defined key_kriest
+
+      !                               ! nampiskrp : kriest parameters
+      !                               ! -----------------------------
+      REWIND( numnatp_ref )              ! Namelist nampiskrp in reference namelist : Pisces Kriest
+      READ  ( numnatp_ref, nampiskrp, IOSTAT = ios, ERR = 903)
+903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampiskrp in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampiskrp in configuration namelist : Pisces Kriest
+      READ  ( numnatp_cfg, nampiskrp, IOSTAT = ios, ERR = 904 )
+904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampiskrp in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampiskrp )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : nampiskrp'
+         WRITE(numout,*) '    Sinking  exponent                        xkr_eta      = ', xkr_eta
+         WRITE(numout,*) '    N content exponent                       xkr_zeta     = ', xkr_zeta
+         WRITE(numout,*) '    N content factor                         xkr_ncontent = ', xkr_ncontent
+         WRITE(numout,*) '    Minimum mass for Aggregates              xkr_mass_min = ', xkr_mass_min
+         WRITE(numout,*) '    Maximum mass for Aggregates              xkr_mass_max = ', xkr_mass_max
+         WRITE(numout,*)
+     ENDIF
+
+
+     ! Computation of some variables
+     xkr_massp = xkr_ncontent * 7.625 * xkr_mass_min**xkr_zeta
+
+#endif
+
+      REWIND( numnatp_ref )              ! Namelist nampisdmp in reference namelist : Pisces damping
+      READ  ( numnatp_ref, nampisdmp, IOSTAT = ios, ERR = 905)
+905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisdmp in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampisdmp in configuration namelist : Pisces damping
+      READ  ( numnatp_cfg, nampisdmp, IOSTAT = ios, ERR = 906 )
+906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisdmp in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampisdmp )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : nampisdmp'
+         WRITE(numout,*) '    Relaxation of tracer to glodap mean value             ln_pisdmp      =', ln_pisdmp
+         WRITE(numout,*) '    Frequency of Relaxation                               nn_pisdmp      =', nn_pisdmp
+         WRITE(numout,*) ' '
+      ENDIF
+
+      REWIND( numnatp_ref )              ! Namelist nampismass in reference namelist : Pisces mass conservation check
+      READ  ( numnatp_ref, nampismass, IOSTAT = ios, ERR = 907)
+907   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampismass in reference namelist', lwp )
+
+      REWIND( numnatp_cfg )              ! Namelist nampismass in configuration namelist : Pisces mass conservation check 
+      READ  ( numnatp_cfg, nampismass, IOSTAT = ios, ERR = 908 )
+908   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampismass in configuration namelist', lwp )
+      IF(lwm) WRITE ( numonp, nampismass )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameter for mass conservation checking'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    Flag to check mass conservation of NO3/Si/TALK ln_check_mass = ', ln_check_mass
+      ENDIF
+
+   END SUBROUTINE p5z_sms_init
+
+   SUBROUTINE p4z_ph_ini
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE p4z_ini_ph  ***
+      !!
+      !!  ** Purpose : Initialization of chemical variables of the carbon cycle
+      !!---------------------------------------------------------------------
+      INTEGER  ::  ji, jj, jk
+      REAL(wp) ::  zcaralk, zbicarb, zco3
+      REAL(wp) ::  ztmas, ztmas1
+      !!---------------------------------------------------------------------
+
+      ! Set PH from  total alkalinity, borat (???), akb3 (???) and ak23 (???)
+      ! --------------------------------------------------------
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztmas   = tmask(ji,jj,jk)
+               ztmas1  = 1. - tmask(ji,jj,jk)
+               zcaralk = trn(ji,jj,jk,jptal) - borat(ji,jj,jk) / (  1. + 1.E-8 / ( rtrn + akb3(ji,jj,jk) )  )
+               zco3    = ( zcaralk - trn(ji,jj,jk,jpdic) ) * ztmas + 0.5e-3 * ztmas1
+               zbicarb = ( 2. * trn(ji,jj,jk,jpdic) - zcaralk )
+               hi(ji,jj,jk) = ( ak23(ji,jj,jk) * zbicarb / zco3 ) * ztmas + 1.e-9 * ztmas1
+            END DO
+         END DO
+     END DO
+     !
+   END SUBROUTINE p4z_ph_ini
+
+   SUBROUTINE p5z_rst( kt, cdrw )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE p5z_rst  ***
+      !!
+      !!  ** Purpose : Read or write variables in restart file:
+      !!
+      !!  WRITE(READ) mode:
+      !!       kt        : number of time step since the begining of the experiment at the
+      !!                   end of the current(previous) run
+      !!---------------------------------------------------------------------
+      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+      !
+      INTEGER  ::  ji, jj, jk
+      REAL(wp) ::  zcaralk, zbicarb, zco3
+      REAL(wp) ::  ztmas, ztmas1
+      !!---------------------------------------------------------------------
+
+      IF( TRIM(cdrw) == 'READ' ) THEN
+         !
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' p5z_rst : Read specific variables from pisces model '
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+         ! 
+         IF( iom_varid( numrtr, 'PH', ldstop = .FALSE. ) > 0 ) THEN
+            CALL iom_get( numrtr, jpdom_autoglo, 'PH' , hi(:,:,:)  )
+         ELSE
+!            hi(:,:,:) = 1.e-9 
+            CALL p4z_ph_ini
+         ENDIF
+         CALL iom_get( numrtr, jpdom_autoglo, 'Silicalim', xksi(:,:) )
+         IF( iom_varid( numrtr, 'Silicamax', ldstop = .FALSE. ) > 0 ) THEN
+            CALL iom_get( numrtr, jpdom_autoglo, 'Silicamax' , xksimax(:,:)  )
+         ELSE
+            xksimax(:,:) = xksi(:,:)
+         ENDIF
+         IF( iom_varid( numrtr, 'sized', ldstop = .FALSE. ) > 0 ) THEN
+            CALL iom_get( numrtr, jpdom_autoglo, 'sizep' , sized(:,:,:)  )
+            CALL iom_get( numrtr, jpdom_autoglo, 'sizen' , sized(:,:,:)  )
+            CALL iom_get( numrtr, jpdom_autoglo, 'sized' , sized(:,:,:)  )
+         ELSE
+            sizep(:,:,:) = 1.
+            sizen(:,:,:) = 1.
+            sized(:,:,:) = 1.
+         ENDIF
+         !
+      ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
+         IF( kt == nitrst ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'p5z_rst : write pisces restart file  kt =', kt
+            IF(lwp) WRITE(numout,*) '~~~~~~~'
+         ENDIF
+         CALL iom_rstput( kt, nitrst, numrtw, 'PH', hi(:,:,:) )
+         CALL iom_rstput( kt, nitrst, numrtw, 'Silicalim', xksi(:,:) )
+         CALL iom_rstput( kt, nitrst, numrtw, 'Silicamax', xksimax(:,:) )
+         CALL iom_rstput( kt, nitrst, numrtw, 'sizep', sized(:,:,:) )
+         CALL iom_rstput( kt, nitrst, numrtw, 'sizen', sized(:,:,:) )
+         CALL iom_rstput( kt, nitrst, numrtw, 'sized', sized(:,:,:) )
+      ENDIF
+      !
+   END SUBROUTINE p5z_rst
+
+   SUBROUTINE p4z_dmp( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  p4z_dmp  ***
+      !!
+      !! ** purpose  : Relaxation of some tracers
+      !!----------------------------------------------------------------------
+      !
+      INTEGER, INTENT( in )  ::     kt ! time step
+      !
+      REAL(wp) ::  alkmean = 2426.     ! mean value of alkalinity ( Glodap ; for Goyet 2391. )
+      REAL(wp) ::  po4mean = 2.165     ! mean value of phosphates
+      REAL(wp) ::  no3mean = 30.90     ! mean value of nitrate
+      REAL(wp) ::  silmean = 91.51     ! mean value of silicate
+      !
+      REAL(wp) :: zarea, zalksum, zpo4sum, zno3sum, zsilsum
+      !!---------------------------------------------------------------------
+
+
+      IF(lwp)  WRITE(numout,*)
+      IF(lwp)  WRITE(numout,*) ' p4z_dmp : Restoring of nutrients at time-step kt = ', kt
+      IF(lwp)  WRITE(numout,*)
+
+      IF( cp_cfg == "orca" .AND. .NOT. lk_c1d ) THEN      ! ORCA configuration (not 1D) !
+         !                                                    ! --------------------------- !
+         ! set total alkalinity, phosphate, nitrate & silicate
+         zarea          = 1._wp / glob_sum( cvol(:,:,:) ) * 1e6              
+
+         zalksum = glob_sum( trn(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
+         zpo4sum = glob_sum( trn(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
+         zno3sum = glob_sum( trn(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
+         zsilsum = glob_sum( trn(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
+ 
+         IF(lwp) WRITE(numout,*) '       TALK mean : ', zalksum
+         trn(:,:,:,jptal) = trn(:,:,:,jptal) * alkmean / zalksum
+
+         IF(lwp) WRITE(numout,*) '       PO4  mean : ', zpo4sum
+         trn(:,:,:,jppo4) = trn(:,:,:,jppo4) * po4mean / zpo4sum
+
+         IF(lwp) WRITE(numout,*) '       NO3  mean : ', zno3sum
+         trn(:,:,:,jpno3) = trn(:,:,:,jpno3) * no3mean / zno3sum
+
+         IF(lwp) WRITE(numout,*) '       SiO3 mean : ', zsilsum
+         trn(:,:,:,jpsil) = MIN( 400.e-6,trn(:,:,:,jpsil) * silmean / zsilsum )
+         !
+      ENDIF
+
+   END SUBROUTINE p4z_dmp
+
+
+   SUBROUTINE p5z_chk_mass( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p5z_chk_mass  ***
+      !!
+      !! ** Purpose :  Mass conservation check 
+      !!
+      !!---------------------------------------------------------------------
+      !
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+      !!
+      !!---------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN 
+         IF( ln_check_mass .AND. lwp) THEN      !   Open budget file of NO3, ALK, Si, Fer
+            CALL ctl_opn( numco2, 'carbon.budget'  , 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
+            CALL ctl_opn( numnut, 'nutrient.budget', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
+         ENDIF
+      ENDIF
+
+      IF( ln_check_mass .AND. kt == nitend ) THEN      !   Compute the budget of NO3, ALK, Si, Fer
+         no3budget = glob_sum( (   trn(:,:,:,jpno3) + trn(:,:,:,jpnh4)  &
+            &                    + trn(:,:,:,jpnph) + trn(:,:,:,jpndi)  &
+            &                    + (trn(:,:,:,jpzoo) + trn(:,:,:,jpmes)) * no3rat3  &
+            &                    + trn(:,:,:,jppon) + trn(:,:,:,jpnpi) &
+#if ! defined key_kriest
+            &                    + trn(:,:,:,jpgon)                     &
+#endif
+            &                    + trn(:,:,:,jpdon)                     ) * cvol(:,:,:)  ) 
+         ! 
+         silbudget = glob_sum( (   trn(:,:,:,jpsil) + trn(:,:,:,jpgsi)  &
+            &                    + trn(:,:,:,jpdsi)                     ) * cvol(:,:,:)  )
+         ! 
+         alkbudget = glob_sum( (   trn(:,:,:,jpno3) * rno3              &
+            &                    + trn(:,:,:,jptal)                     &
+            &                    + trn(:,:,:,jpcal) * 2.                ) * cvol(:,:,:)  )
+         ! 
+         ferbudget = glob_sum( (   trn(:,:,:,jpfer) + trn(:,:,:,jpnfe)  &
+            &                    + trn(:,:,:,jpdfe) + trn(:,:,:,jppfe)  &
+#if ! defined key_kriest
+            &                    + trn(:,:,:,jpbfe)                     &
+#endif
+            &                    + trn(:,:,:,jpsfe)                     &
+            &                    + trn(:,:,:,jpzoo) * ferat3            &
+            &                    + trn(:,:,:,jpmes) * ferat3            ) * cvol(:,:,:)  )
+         !
+         t_atm_co2_flx  = t_atm_co2_flx / glob_sum( e1e2t(:,:) )
+         t_oce_co2_flx  = t_oce_co2_flx         * 12. / 1.e15 * (-1 )
+         tpp            = tpp           * 1000. * 12. / 1.E15
+         t_oce_co2_exp  = t_oce_co2_exp * 1000. * 12. / 1.E15
+         !
+         no3budget = no3budget / areatot
+         silbudget = silbudget / areatot
+         alkbudget = alkbudget / areatot
+         ferbudget = ferbudget / areatot
+         !
+         IF(lwp) THEN
+            WRITE(numco2,9000) ndastp, t_atm_co2_flx, t_oce_co2_flx, tpp, t_oce_co2_exp
+            WRITE(numnut,9500) ndastp, alkbudget, no3budget, silbudget, ferbudget
+         ENDIF
+         !
+      ENDIF
+       !
+ 9000  FORMAT(i8,f10.5,e18.10,f10.5,f10.5)
+ 9500  FORMAT(i8,4e18.10)     
+       !
+   END SUBROUTINE p5z_chk_mass
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p5z_sms( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'p5z_sms: You should not have seen this print! error?', kt
+   END SUBROUTINE p5z_sms
+#endif 
+
+   !!======================================================================
+END MODULE p5zsms 
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/par_pisces.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/par_pisces.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/par_pisces.F90	(revision 5266)
@@ -17,6 +17,6 @@
    !!   'key_pisces_reduced'   :                                LOBSTER bio-model
    !!---------------------------------------------------------------------
-   LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .TRUE.  !: PISCES flag 
-   LOGICAL, PUBLIC, PARAMETER ::   lk_p4z        = .FALSE. !: p4z flag 
+   INTEGER, PUBLIC, PARAMETER ::   lk_pisces     = .TRUE.  !: PISCES flag 
+   INTEGER, PUBLIC, PARAMETER ::   nn_p4z        =  1      !: p4z flag 
    INTEGER, PUBLIC, PARAMETER ::   jp_pisces     =  6      !: number of passive tracers
    INTEGER, PUBLIC, PARAMETER ::   jp_pisces_2d  =  19     !: additional 2d output 
@@ -41,5 +41,5 @@
    !!---------------------------------------------------------------------
    LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .TRUE.  !: PISCES flag 
-   LOGICAL, PUBLIC, PARAMETER ::   lk_p4z        = .TRUE. !: p4z flag 
+   INTEGER, PUBLIC, PARAMETER ::   nn_p4z        =  2      !: p4z flag 
    LOGICAL, PUBLIC, PARAMETER ::   lk_kriest     = .TRUE.  !: Kriest flag 
    INTEGER, PUBLIC, PARAMETER ::   jp_pisces     =  23     !: number of passive tracers
@@ -80,5 +80,5 @@
    !!---------------------------------------------------------------------
    LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .TRUE.  !: PISCES flag 
-   LOGICAL, PUBLIC, PARAMETER ::   lk_p4z        = .TRUE.  !: p4z flag 
+   INTEGER, PUBLIC, PARAMETER ::   nn_p4z        =  2  !: p4z flag 
    LOGICAL, PUBLIC, PARAMETER ::   lk_kriest     = .FALSE. !: Kriest flag 
    INTEGER, PUBLIC, PARAMETER ::   jp_pisces     = 24      !: number of PISCES passive tracers
@@ -115,4 +115,112 @@
    INTEGER, PUBLIC, PARAMETER ::   jpnh4 = 24    !: Ammonium Concentration
 
+#elif defined key_pisces_quota  &&  defined key_kriest
+   !!---------------------------------------------------------------------
+   !!   'key_pisces' & 'key_kriest'                 PISCES bio-model + ???
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .TRUE.  !: PISCES flag 
+   INTEGER, PUBLIC, PARAMETER ::   nn_p4z        =  3 !: p4z flag 
+   LOGICAL, PUBLIC, PARAMETER ::   lk_kriest     = .TRUE.  !: Kriest flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces     =  36     !: number of passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_2d  =  13     !: additional 2d output 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_3d  =  18     !: additional 3d output 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_trd =   1     !: number of sms trends for PISCES
+
+   ! assign an index in trc arrays for each LOBSTER prognostic variables
+   !    WARNING: be carefull about the order when reading the restart
+        !   !!gm  this warning should be obsolet with IOM
+   INTEGER, PUBLIC, PARAMETER ::   jpdic =  1    !: dissolved inoganic carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jptal =  2    !: total alkalinity 
+   INTEGER, PUBLIC, PARAMETER ::   jpoxy =  3    !: oxygen carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpcal =  4    !: calcite  concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jppo4 =  5    !: phosphate concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jppoc =  6    !: small particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpsil =  7    !: silicate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpphy =  8    !: phytoplancton concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpzoo =  9    !: zooplancton concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdoc = 10    !: dissolved organic carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpdia = 11    !: Diatoms Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpmes = 12    !: Mesozooplankton Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdsi = 13    !: (big) Silicate Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpfer = 14    !: Iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnum = 15    !: Big iron particles Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpsfe = 16    !: number of particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdfe = 17    !: Diatoms iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpgsi = 18    !: Diatoms Silicate Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnfe = 19    !: Nano iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnch = 20    !: Nano Chlorophyll Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdch = 21    !: Diatoms Chlorophyll Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpno3 = 22    !: Nitrates Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnh4 = 23    !: Ammonium Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdon = 24    !: dissolved organic nitrogen concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdop = 25    !: dissolved organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppon = 26    !: small particulate organic nitrogen concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppop = 27    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnph = 28    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppph = 29    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpndi = 30    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppdi = 31    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppic = 32    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnpi = 33    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpppi = 34    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppfe = 35    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppch = 36    !: small particulate organic phosphorus concentration
+
+#elif defined key_pisces_quota
+   !!---------------------------------------------------------------------
+   !!   'key_pisces'   :                         standard PISCES bio-model
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .TRUE.  !: PISCES flag 
+   INTEGER, PUBLIC, PARAMETER ::   nn_p4z        =  3  !: p4z flag 
+   LOGICAL, PUBLIC, PARAMETER ::   lk_kriest     = .FALSE. !: Kriest flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces     = 39      !: number of PISCES passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_2d  = 13      !: additional 2d output 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_3d  = 11      !: additional 3d output 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_trd =  1      !: number of sms trends for PISCES
+
+   ! assign an index in trc arrays for each LOBSTER prognostic variables
+   !    WARNING: be carefull about the order when reading the restart
+        !   !!gm  this warning should be obsolet with IOM
+   INTEGER, PUBLIC, PARAMETER ::   jpdic =  1    !: dissolved inoganic carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jptal =  2    !: total alkalinity 
+   INTEGER, PUBLIC, PARAMETER ::   jpoxy =  3    !: oxygen carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpcal =  4    !: calcite  concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jppo4 =  5    !: phosphate concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jppoc =  6    !: small particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpsil =  7    !: silicate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpphy =  8    !: phytoplancton concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpzoo =  9    !: zooplancton concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdoc = 10    !: dissolved organic carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpdia = 11    !: Diatoms Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpmes = 12    !: Mesozooplankton Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdsi = 13    !: (big) Silicate Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpfer = 14    !: Iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpbfe = 15    !: Big iron particles Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpgoc = 16    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpsfe = 17    !: Small iron particles Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdfe = 18    !: Diatoms iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpgsi = 19    !: Diatoms Silicate Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnfe = 20    !: Nano iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnch = 21    !: Nano Chlorophyll Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdch = 22    !: Diatoms Chlorophyll Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpno3 = 23    !: Nitrates Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnh4 = 24    !: Ammonium Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdon = 25    !: dissolved organic nitrogen concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdop = 26    !: dissolved organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppon = 27    !: small particulate organic nitrogen concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppop = 28    !: small particulate organic phosphorus concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpgon = 29    !: big particulate organic nitrogen concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpgop = 30    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnph = 31    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppph = 32    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpndi = 33    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppdi = 34    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppic = 35    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnpi = 36    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpppi = 37    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppfe = 38    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jppch = 39    !: big particulate organic phosphate concentration
+
+
 #else
    !!---------------------------------------------------------------------
@@ -120,5 +228,5 @@
    !!---------------------------------------------------------------------
    LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .FALSE.  !: PISCES flag 
-   LOGICAL, PUBLIC, PARAMETER ::   lk_p4z        = .FALSE.  !: p4z flag 
+   LOGICAL, PUBLIC, PARAMETER ::   nn_p4z        =  0  !: p4z flag 
    INTEGER, PUBLIC, PARAMETER ::   jp_pisces     =  0       !: No CFC tracers
    INTEGER, PUBLIC, PARAMETER ::   jp_pisces_2d  =  0       !: No CFC additional 2d output arrays 
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/sms_pisces.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/sms_pisces.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/sms_pisces.F90	(revision 5266)
@@ -7,5 +7,5 @@
    !!             3.2  !  2009-04 (C. Ethe & NEMO team) style
    !!----------------------------------------------------------------------
-#if defined key_pisces || defined key_pisces_reduced 
+#if defined key_pisces || defined key_pisces_reduced || defined key_pisces_quota 
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                         PISCES model
@@ -29,5 +29,5 @@
    !                                                       !:  PISCES  : silicon dependant half saturation
 
-#if defined key_pisces 
+#if defined key_pisces || defined key_pisces_quota 
    !!*  Time variables
    INTEGER  ::   nrdttrc           !: ???
@@ -72,11 +72,12 @@
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimphy    !: ???
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimdia    !: ???
+#if ! defined key_pisces_quota
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   concdfe    !: ???
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   concnfe    !: ???
+#endif
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimnfe    !: ???
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimdfe    !: ???
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimsi     !: ???
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   biron      !: bioavailable fraction of iron
-
 
    !!*  SMS for the organic matter
@@ -115,4 +116,45 @@
 
 #endif
+
+# if defined key_pisces_quota
+   !!*  Biological parameters 
+   REAL(wp) ::   no3rat3           !: ???
+   REAL(wp) ::   po4rat3           !: ???
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xpicono3   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xpiconh4   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xpicopo4   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xnanodop   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xpicodop   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xdiatdop   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xnanofer   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xpicofer   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xdiatfer   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimpic    !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimpfe    !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   fvnuptk
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   fvpuptk
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   fvduptk
+
+   !!*  Allometric variations of the quotas
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqnnmin    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqnnmax    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqpnmin    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqpnmax    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqnpmin    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqnpmax    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqppmin    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqppmax    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqndmin    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqndmax    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqpdmin    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:)  ::   xqpdmax    !: ???
+
+   !!*  SMS for the organic matter
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sizen      !: size of diatoms 
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sizep      !: size of diatoms 
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sized      !: size of diatoms 
+
+#endif
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -127,5 +169,9 @@
       !!----------------------------------------------------------------------
       USE lib_mpp , ONLY: ctl_warn
+#if defined key_pisces_quota
+      INTEGER ::   ierr(9)        ! Local variables
+#else
       INTEGER ::   ierr(6)        ! Local variables
+#endif
       !!----------------------------------------------------------------------
       ierr(:) = 0
@@ -133,5 +179,5 @@
       ALLOCATE( etot(jpi,jpj,jpk), neln(jpi,jpj), heup(jpi,jpj), xksi(jpi,jpj), STAT=ierr(1) )
       !
-#if defined key_pisces
+#if defined key_pisces || defined key_pisces_quota
       !*  Biological fluxes for primary production
       ALLOCATE( xksimax(jpi,jpj)     , biron   (jpi,jpj,jpk),       &
@@ -140,11 +186,13 @@
          &      xnanopo4(jpi,jpj,jpk), xdiatpo4(jpi,jpj,jpk),       &
          &      xlimphy (jpi,jpj,jpk), xlimdia (jpi,jpj,jpk),       &
+#if ! defined key_pisces_quota
+         &      concnfe (jpi,jpj,jpk), concdfe (jpi,jpj,jpk),       &
+#endif
          &      xlimnfe (jpi,jpj,jpk), xlimdfe (jpi,jpj,jpk),       &
-         &      xlimsi  (jpi,jpj,jpk), concdfe (jpi,jpj,jpk),       &
-         &      concnfe (jpi,jpj,jpk),                           STAT=ierr(2) ) 
+         &      xlimsi  (jpi,jpj,jpk), STAT=ierr(2) )
          !
       !*  SMS for the organic matter
-      ALLOCATE( xfracal (jpi,jpj,jpk), nitrfac(jpi,jpj,jpk),       &
-         &      xlimbac (jpi,jpj,jpk), xdiss  (jpi,jpj,jpk),       & 
+      ALLOCATE( xfracal (jpi,jpj,jpk), nitrfac (jpi,jpj,jpk),      &
+         &      xlimbac (jpi,jpj,jpk), xdiss   (jpi,jpj,jpk),      & 
          &      xlimbacl(jpi,jpj,jpk), prodcal(jpi,jpj,jpk),     STAT=ierr(3) )
 
@@ -161,4 +209,30 @@
       ALLOCATE( xnegtr(jpi,jpj,jpk)  ,                           STAT=ierr(6) )
 #endif
+
+#if defined key_pisces_quota
+      !*  Biological arrays for phytoplankton growth
+      ALLOCATE( xpicono3(jpi,jpj,jpk), xpiconh4(jpi,jpj,jpk),       &
+         &      xpicopo4(jpi,jpj,jpk), xpicodop(jpi,jpj,jpk),       &
+         &      xnanodop(jpi,jpj,jpk), xdiatdop(jpi,jpj,jpk),       &
+         &      xnanofer(jpi,jpj,jpk), xdiatfer(jpi,jpj,jpk),       &
+         &      xpicofer(jpi,jpj,jpk), xlimpfe (jpi,jpj,jpk),       &
+         &      fvnuptk (jpi,jpj,jpk), fvduptk (jpi,jpj,jpk),       &
+         &      fvpuptk (jpi,jpj,jpk), xlimpic (jpi,jpj,jpk),       &
+         &      STAT=ierr(7) )
+
+      !*  Minimum/maximum quotas of phytoplankton
+      ALLOCATE( xqnnmin (jpi,jpj,jpk), xqnnmax(jpi,jpj,jpk),       &
+         &      xqpnmin (jpi,jpj,jpk), xqpnmax(jpi,jpj,jpk),       &
+         &      xqnpmin (jpi,jpj,jpk), xqnpmax(jpi,jpj,jpk),       &
+         &      xqppmin (jpi,jpj,jpk), xqppmax(jpi,jpj,jpk),       &
+         &      xqndmin (jpi,jpj,jpk), xqndmax(jpi,jpj,jpk),       &
+         &      xqpdmin (jpi,jpj,jpk), xqpdmax(jpi,jpj,jpk),     STAT=ierr(8) )
+         !
+      !*  Size of phytoplankton cells
+      ALLOCATE( sizen   (jpi,jpj,jpk), sizep   (jpi,jpj,jpk),      &
+         &      sized   (jpi,jpj,jpk), STAT=ierr(9) )
+         !
+#endif
+
       !
       sms_pisces_alloc = MAXVAL( ierr )
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 5266)
@@ -11,5 +11,5 @@
    !!             3.5  !  2012-05  (C. Ethe) Merge PISCES-LOBSTER
    !!----------------------------------------------------------------------
-#if defined key_pisces || defined key_pisces_reduced
+#if defined key_pisces || defined key_pisces_reduced || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                       PISCES bio-model
@@ -43,9 +43,167 @@
       !!----------------------------------------------------------------------
 
-      IF( lk_p4z ) THEN  ;   CALL p4z_ini   !  PISCES
-      ELSE               ;   CALL p2z_ini   !  LOBSTER
-      ENDIF
+      SELECT CASE ( nn_p4z )
+      !
+        CASE(1)          ;   CALL p2z_ini   !  LOBSTER
+        CASE(2)          ;   CALL p4z_ini   !  PISCES
+        CASE(3)          ;   CALL p5z_ini   !  PISCES QUOTA
+
+      END SELECT
 
    END SUBROUTINE trc_ini_pisces
+
+   SUBROUTINE p5z_ini
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE p5z_ini ***
+      !!
+      !! ** Purpose :   Initialisation of the PISCES biochemical model
+      !!                with variable stoichiometry
+      !!----------------------------------------------------------------------
+#if defined key_pisces_quota 
+      !
+      USE p5zsms          ! Main P4Z routine
+      USE p4zche          !  Chemical model
+      USE p5zsink         !  vertical flux of particulate matter due to sinking
+      USE p4zopt          !  optical model
+      USE p4zsbc          !  Boundary conditions
+      USE p4zfechem       !  Iron chemistry
+      USE p5zrem          !  Remineralisation of organic matter
+      USE p4zflx          !  Gas exchange
+      USE p5zlim          !  Co-limitations of differents nutrients
+      USE p5zprod         !  Growth rate of the 2 phyto groups
+      USE p5zmicro        !  Sources and sinks of microzooplankton
+      USE p5zmeso         !  Sources and sinks of mesozooplankton
+      USE p5zmort         !  Mortality terms for phytoplankton
+      USE p4zlys          !  Calcite saturation
+      !
+      REAL(wp), SAVE :: sco2   =  2.312e-3_wp
+      REAL(wp), SAVE :: alka0  =  2.423e-3_wp
+      REAL(wp), SAVE :: oxyg0  =  177.6e-6_wp 
+      REAL(wp), SAVE :: po4    =  2.174e-6_wp 
+      REAL(wp), SAVE :: bioma0 =  1.000e-8_wp  
+      REAL(wp), SAVE :: silic1 =  91.65e-6_wp  
+      REAL(wp), SAVE :: no3    =  31.04e-6_wp * 7.625_wp
+      !
+      INTEGER  ::  ji, jj, jk, ierr
+      REAL(wp) ::  zcaralk, zbicarb, zco3
+      REAL(wp) ::  ztmas, ztmas1
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' p5z_ini :   PISCES biochemical model initialisation'
+      IF(lwp) WRITE(numout,*) '             With variable stoichiometry'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+                                                 ! Allocate PISCES arrays
+      ierr =         sms_pisces_alloc()          
+      ierr = ierr +  p4z_che_alloc()
+      ierr = ierr +  p5z_sink_alloc()
+      ierr = ierr +  p4z_opt_alloc()
+      ierr = ierr +  p5z_prod_alloc()
+      ierr = ierr +  p5z_rem_alloc()
+      ierr = ierr +  p4z_flx_alloc()
+      !
+      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'pisces_alloc: unable to allocate PISCES arrays' )
+      !
+      CALL p5z_sms_init       !  Maint routine
+      !                                            ! Time-step
+      rfact   = rdttrc(1)                          ! ---------
+      rfactr  = 1. / rfact
+      rfact2  = rfact / FLOAT( nrdttrc )
+      rfact2r = 1. / rfact2
+
+      IF(lwp) WRITE(numout,*) '    Passive Tracer  time step    rfact  = ', rfact, ' rdt = ', rdttra(1)
+      IF(lwp) write(numout,*) '    PISCES  Biology time step    rfact2 = ', rfact2
+
+      ! Set biological ratios
+      ! ---------------------
+      rno3    =  16._wp / 122._wp
+      po4r    =   1._wp / 122._wp
+      o2nit   =  32._wp / 122._wp
+      rdenit  = 105._wp /  16._wp
+      rdenita =   3._wp /  5._wp
+      o2ut    = 133._wp / 122._wp
+      no3rat3 = no3rat3 / rno3
+      po4rat3 = po4rat3 / po4r
+
+      ! Initialization of tracer concentration in case of  no restart 
+      !--------------------------------------------------------------
+      IF( .NOT. ln_rsttr ) THEN  
+         
+         trn(:,:,:,jpdic) = sco2
+         trn(:,:,:,jpdoc) = bioma0
+         trn(:,:,:,jpdon) = bioma0
+         trn(:,:,:,jpdop) = bioma0
+         trn(:,:,:,jptal) = alka0
+         trn(:,:,:,jpoxy) = oxyg0
+         trn(:,:,:,jpcal) = bioma0
+         trn(:,:,:,jppo4) = po4 / po4r
+         trn(:,:,:,jppoc) = bioma0
+         trn(:,:,:,jppon) = bioma0
+         trn(:,:,:,jppop) = bioma0
+#  if ! defined key_kriest
+         trn(:,:,:,jpgoc) = bioma0
+         trn(:,:,:,jpgon) = bioma0
+         trn(:,:,:,jpgop) = bioma0
+         trn(:,:,:,jpbfe) = bioma0 * 5.e-6
+#  else
+         trn(:,:,:,jpnum) = bioma0 / ( 6. * xkr_massp )
+#  endif
+         trn(:,:,:,jpsil) = silic1
+         trn(:,:,:,jpdsi) = bioma0 * 0.15
+         trn(:,:,:,jpgsi) = bioma0 * 5.e-6
+         trn(:,:,:,jpphy) = bioma0
+         trn(:,:,:,jpnph) = bioma0
+         trn(:,:,:,jppph) = bioma0
+         trn(:,:,:,jppic) = bioma0
+         trn(:,:,:,jpnpi) = bioma0
+         trn(:,:,:,jpppi) = bioma0
+         trn(:,:,:,jpdia) = bioma0
+         trn(:,:,:,jpndi) = bioma0
+         trn(:,:,:,jppdi) = bioma0
+         trn(:,:,:,jpzoo) = bioma0
+         trn(:,:,:,jpmes) = bioma0
+         trn(:,:,:,jpfer) = 0.6E-9
+         trn(:,:,:,jpsfe) = bioma0 * 5.e-6
+         trn(:,:,:,jppfe) = bioma0 * 5.e-6
+         trn(:,:,:,jpdfe) = bioma0 * 5.e-6
+         trn(:,:,:,jpnfe) = bioma0 * 5.e-6
+         trn(:,:,:,jpnch) = bioma0 * 12. / 55.
+         trn(:,:,:,jppch) = bioma0 * 12. / 55.
+         trn(:,:,:,jpdch) = bioma0 * 12. / 55.
+         trn(:,:,:,jpno3) = no3
+         trn(:,:,:,jpnh4) = bioma0
+
+         ! initialize the half saturation constant for silicate
+         ! ----------------------------------------------------
+         xksi(:,:)    = 2.e-6
+         xksimax(:,:) = xksi(:,:)
+      END IF
+
+      ! Time step duration for biology
+      xstep = rfact2 / rday
+
+      CALL p5z_sink_init      !  vertical flux of particulate organic matter
+      CALL p4z_opt_init       !  Optic: PAR in the water column
+      CALL p5z_lim_init       !  co-limitations by the various nutrients
+      CALL p5z_prod_init      !  phytoplankton growth rate over the global ocean.
+      CALL p4z_sbc_init       !  boundary conditions
+      CALL p4z_fechem_init    !  Iron chemistry
+      CALL p5z_rem_init       !  remineralisation
+      CALL p5z_mort_init      !  phytoplankton mortality 
+      CALL p5z_micro_init     !  microzooplankton
+      CALL p5z_meso_init      !  mesozooplankton
+      CALL p4z_lys_init       !  calcite saturation
+      CALL p4z_flx_init       !  gas exchange 
+
+      ndayflxtr = 0
+
+      IF(lwp) WRITE(numout,*) 
+      IF(lwp) WRITE(numout,*) 'Initialization of PISCES tracers done'
+      IF(lwp) WRITE(numout,*) 
+#endif
+      !
+   END SUBROUTINE p5z_ini
 
    SUBROUTINE p4z_ini
@@ -74,8 +232,8 @@
       REAL(wp), SAVE :: sco2   =  2.312e-3_wp
       REAL(wp), SAVE :: alka0  =  2.423e-3_wp
-      REAL(wp), SAVE :: oxyg0  =  177.6e-6_wp 
-      REAL(wp), SAVE :: po4    =  2.174e-6_wp 
-      REAL(wp), SAVE :: bioma0 =  1.000e-8_wp  
-      REAL(wp), SAVE :: silic1 =  91.65e-6_wp  
+      REAL(wp), SAVE :: oxyg0  =  177.6e-6_wp
+      REAL(wp), SAVE :: po4    =  2.174e-6_wp
+      REAL(wp), SAVE :: bioma0 =  1.000e-8_wp
+      REAL(wp), SAVE :: silic1 =  91.65e-6_wp
       REAL(wp), SAVE :: no3    =  31.04e-6_wp * 7.625_wp
       !
@@ -90,5 +248,5 @@
 
                                                  ! Allocate PISCES arrays
-      ierr =         sms_pisces_alloc()          
+      ierr =         sms_pisces_alloc()
       ierr = ierr +  p4z_che_alloc()
       ierr = ierr +  p4z_sink_alloc()
@@ -125,6 +283,6 @@
       ! Initialization of tracer concentration in case of  no restart 
       !--------------------------------------------------------------
-      IF( .NOT. ln_rsttr ) THEN  
-         
+      IF( .NOT. ln_rsttr ) THEN
+
          trn(:,:,:,jpdic) = sco2
          trn(:,:,:,jpdoc) = bioma0
@@ -180,7 +338,7 @@
       ndayflxtr = 0
 
-      IF(lwp) WRITE(numout,*) 
+      IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'Initialization of PISCES tracers done'
-      IF(lwp) WRITE(numout,*) 
+      IF(lwp) WRITE(numout,*)
 #endif
       !
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcnam_pisces.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcnam_pisces.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcnam_pisces.F90	(revision 5266)
@@ -9,5 +9,5 @@
    !!             2.0  !  2007-12  (C. Ethe, G. Madec) from trcnam.pisces.h90
    !!----------------------------------------------------------------------
-#if defined key_pisces || defined key_pisces_reduced
+#if defined key_pisces || defined key_pisces_reduced || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'   :                                   PISCES bio-model
@@ -66,4 +66,6 @@
 #if defined key_pisces
       IF(lwp) WRITE(numout,*) ' trc_nam_pisces : read PISCES namelist'
+#elif defined key_pisces_quota
+      IF(lwp) WRITE(numout,*) ' trc_nam_pisces : read PISCES-QUOTA namelist'
 #else
       IF(lwp) WRITE(numout,*) ' trc_nam_pisces : read LOBSTER namelist'
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90	(revision 5266)
@@ -7,5 +7,5 @@
    !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
    !!----------------------------------------------------------------------
-#if defined key_pisces || defined key_pisces_reduced
+#if defined key_pisces || defined key_pisces_reduced || defined key_pisces_quota
    !!----------------------------------------------------------------------
    !!   'key_pisces'                                       PISCES bio-model
@@ -14,4 +14,5 @@
    !!----------------------------------------------------------------------
    USE par_pisces
+   USE p5zsms
    USE p4zsms
    USE p2zsms
@@ -48,7 +49,11 @@
       !!---------------------------------------------------------------------
       !
-      IF( lk_p4z ) THEN  ;   CALL p4z_sms( kt )   !  PISCES
-      ELSE               ;   CALL p2z_sms( kt )   !  LOBSTER
-      ENDIF
+      SELECT CASE ( nn_p4z )
+
+      CASE(1)       ;        CALL p2z_sms( kt )   !  LOBSTER
+      CASE(2)       ;        CALL p4z_sms( kt )   !  PISCES
+      CASE(3)       ;        CALL p5z_sms( kt )   !  PISCES with variable stoichiometry
+
+      END SELECT
 
       !
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90	(revision 5266)
@@ -6,5 +6,5 @@
    !! History :   1.0  !  2009-05 (C. Ethe)  Original code
    !!----------------------------------------------------------------------
-#if defined key_top && defined key_iomput && ( defined key_pisces || defined key_pisces_reduced )
+#if defined key_top && defined key_iomput && ( defined key_pisces || defined key_pisces_reduced || defined key_pisces_quota)
    !!----------------------------------------------------------------------
    !!   'key_pisces or key_pisces_reduced'                     PISCES model
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 5266)
@@ -133,5 +133,5 @@
          SELECT CASE ( nn_ctls_trc )                                ! choice of the control surface
             CASE ( -2  )   ;   STOP 'trdmld_trc : not ready '     !     -> isopycnal surface (see ???)
-#if defined key_pisces || defined key_pisces_reduced
+#if defined key_pisces || defined key_pisces_reduced || defined key_pisces_quota
             CASE ( -1  )   ;   nmld_trc(:,:) = neln(:,:)          !     -> euphotic layer with light criterion
 #endif
Index: /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/trc.F90
===================================================================
--- /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 5265)
+++ /branches/CNRS/dev_r4826_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 5266)
@@ -183,5 +183,5 @@
       !
       ALLOCATE( trn(jpi,jpj,jpk,jptra), trb(jpi,jpj,jpk,jptra), tra(jpi,jpj,jpk,jptra),       &  
-         &      gtru(jpi,jpj,jpk)     , gtrv(jpi,jpj,jpk)                             ,       &
+         &      gtru(jpi,jpj,jptra)   , gtrv(jpi,jpj,jptra)                           ,       &
          &      cvol(jpi,jpj,jpk)     , rdttrc(jpk)           , trai(jptra)           ,       &
          &      ctrcnm(jptra)         , ctrcln(jptra)         , ctrcun(jptra)         ,       & 
