Index: trunk/NEMOGCM/NEMO/TOP_SRC/C14b/par_c14b.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/C14b/par_c14b.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/C14b/par_c14b.F90	(revision 2715)
@@ -5,8 +5,4 @@
    !!======================================================================
    !! History :   2.0  !  2008-12  (C. Ethe, G. Madec)  revised architecture
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
    USE par_lobster, ONLY : jp_lobster      !: number of tracers in LOBSTER
@@ -55,6 +51,6 @@
 
    ! Starting/ending C14 do-loop indices (N.B. no C14 : jp_c14b0 > jp_c14b1 the do-loop are never done)
-   INTEGER, PUBLIC, PARAMETER ::   jp_c14b0     = jp_lb + 1                !: First index of C14 tracer
-   INTEGER, PUBLIC, PARAMETER ::   jp_c14b1     = jp_lb + jp_c14b          !: Last  index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b0     = jp_lb     + 1            !: First index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b1     = jp_lb     + jp_c14b      !: Last  index of C14 tracer
    INTEGER, PUBLIC, PARAMETER ::   jp_c14b0_2d  = jp_lb_2d  + 1            !: First index of C14 tracer
    INTEGER, PUBLIC, PARAMETER ::   jp_c14b1_2d  = jp_lb_2d  + jp_c14b_2d   !: Last  index of C14 tracer
@@ -64,4 +60,8 @@
    INTEGER, PUBLIC, PARAMETER ::   jp_c14b1_trd = jp_lb_trd + jp_c14b_trd  !: Last  index of C14 tracer
 
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!======================================================================
 END MODULE par_c14b
Index: trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcini_c14b.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcini_c14b.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcini_c14b.F90	(revision 2715)
@@ -4,6 +4,6 @@
    !! TOP :   initialisation of the C14 bomb tracer
    !!======================================================================
-   !! History : Original ! 2005-10  (Z. Lachkar) 
-   !!               2.0  ! 2007-12  (C. Ethe ) 
+   !! History :  1.0  ! 2005-10  (Z. Lachkar) Original code
+   !!            2.0  ! 2007-12  (C. Ethe) 
    !!----------------------------------------------------------------------
 #if defined key_c14b
@@ -17,5 +17,4 @@
    USE trc             ! TOP variables
    USE trcsms_c14b     ! C14 sms trends
-   USE in_out_manager  ! I/O manager
 
    IMPLICIT NONE
@@ -24,26 +23,21 @@
    PUBLIC   trc_ini_c14b   ! called by trcini.F90 module
 
-   INTEGER  ::   &     ! With respect to data file !!
-     jpybeg = 1765 , & !: starting year for C14
-     jpyend = 2002     !: ending year for C14
-
-   INTEGER  ::   &   
-      nrec   ,  & ! number of year in CO2 Concentrations file
-      nmaxrec 
-
-   INTEGER  ::   inum1, inum2               ! unit number
-
-   REAL(wp) ::     &
-     ys40 = -40. ,    &             ! 40 degrees south
-     ys20 = -20. ,    &             ! 20 degrees south
-     yn20 =  20. ,    &             ! 20 degrees north
-     yn40 =  40.                    ! 40 degrees north
-
-   !!---------------------------------------------------------------------
+   !                             ! With respect to data file !!
+   INTEGER  ::   jpybeg = 1765   ! starting year for C14
+   INTEGER  ::   jpyend = 2002   ! ending year for C14
+   INTEGER  ::   nrec            ! number of year in CO2 Concentrations file
+   INTEGER  ::   nmaxrec 
+   INTEGER  ::   inum1, inum2    ! unit number
+
+   REAL(wp) ::   ys40 = -40.     ! 40 degrees south
+   REAL(wp) ::   ys20 = -20.     ! 20 degrees south
+   REAL(wp) ::   yn20 =  20.     ! 20 degrees north
+   REAL(wp) ::   yn40 =  40.     ! 40 degrees north
+
+   !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -59,6 +53,8 @@
       !!----------------------------------------------------------------------
 
-      !  Control consitency
-      CALL trc_ctl_c14b
+      !                     ! Allocate C14b arrays
+      IF( trc_sms_c14b_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trc_ini_c14b : unable to allocate C14b arrays' )
+
+      CALL trc_ctl_c14b     !  Control consitency
 
       IF(lwp) WRITE(numout,*) ''
@@ -69,5 +65,5 @@
       ! Initialization of boundaries conditions
       ! --------------------------------------- 
-      qtr_c14(:,:) = 0.e0
+      qtr_c14(:,:) = 0._wp
       
       ! Initialization of qint in case of  no restart 
@@ -78,6 +74,6 @@
             WRITE(numout,*) 'Initialization de qint ; No restart : qint equal zero '
          ENDIF
-         trn     (:,:,:,jpc14) = 0.e0
-         qint_c14(:,:        ) = 0.e0
+         trn     (:,:,:,jpc14) = 0._wp
+         qint_c14(:,:        ) = 0._wp
       ENDIF
 
@@ -156,13 +152,13 @@
                  fareaz(ji,jj,3) = 0.
             ENDIF
-          END DO
-        END DO
-
+         END DO
+      END DO
       !
       IF(lwp) WRITE(numout,*) 'Initialization of C14 bomb tracer done'
       IF(lwp) WRITE(numout,*) ' '
-
+      !
    END SUBROUTINE trc_ini_c14b
-   
+
+
    SUBROUTINE trc_ctl_c14b
       !!----------------------------------------------------------------------
@@ -179,11 +175,11 @@
       ! Check number of tracers
       ! -----------------------   
-      IF( jp_c14b > 1) CALL ctl_stop( ' Change jp_c14b to be equal 1 in par_c14b.F90' )
+      IF( jp_c14b > 1)   CALL ctl_stop( ' Change jp_c14b to be equal 1 in par_c14b.F90' )
 
       ! Check tracer names
       ! ------------------
-      IF ( ctrcnm(jpc14) /= 'C14B' ) THEN
-           ctrcnm(jpc14)  = 'C14B'
-           ctrcnl(jpc14)  = 'Bomb C14 concentration'
+      IF( ctrcnm(jpc14) /= 'C14B' ) THEN
+          ctrcnm(jpc14)  = 'C14B'
+          ctrcnl(jpc14)  = 'Bomb C14 concentration'
       ENDIF
 
@@ -197,5 +193,5 @@
       ! ------------------
       IF( ctrcun(jpc14) /= 'ration' ) THEN
-          ctrcun(jpc14) = 'ration'
+          ctrcun(jpc14)  = 'ration'
           IF(lwp) THEN
              CALL ctl_warn( ' we force tracer unit' )
@@ -206,4 +202,5 @@
       !
    END SUBROUTINE trc_ctl_c14b
+   
 #else
    !!----------------------------------------------------------------------
Index: trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcnam_c14b.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcnam_c14b.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcnam_c14b.F90	(revision 2715)
@@ -16,5 +16,4 @@
    USE trc             ! TOP variables
    USE trcsms_c14b     ! C14b specific variable
-   USE in_out_manager  ! I/O manager
 
    IMPLICIT NONE
Index: trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcrst_c14b.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcrst_c14b.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcrst_c14b.F90	(revision 2715)
@@ -17,5 +17,4 @@
    USE trc             ! TOP variables
    USE trcsms_c14b          ! c14b sms trends
-   USE in_out_manager  ! I/O manager
    USE iom
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcsms_c14b.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcsms_c14b.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/C14b/trcsms_c14b.F90	(revision 2715)
@@ -4,7 +4,8 @@
    !! TOP : Bomb C14 main module
    !!======================================================================
-   !! History     -   ! 1994-05 ( J. Orr ) origial code
+   !! History     -   ! 1994-05 ( J. Orr ) original code
    !!            1.0  ! 2006-02 ( J.M. Molines )  Free form + modularity
    !!            2.0  ! 2008-12 ( C. Ethe ) reorganisation
+   !!            4.0  ! 2011-02 ( A.R. Porter, STFC Daresbury ) Dynamic memory
    !!----------------------------------------------------------------------
 #if defined key_c14b
@@ -12,20 +13,19 @@
    !!   'key_c14b'                                         Bomb C14 tracer
    !!----------------------------------------------------------------------
-   !!   trc_sms_c14b  :  compute and add C14 suface forcing to C14 trends
-   !!----------------------------------------------------------------------
-   USE oce_trc      ! Ocean variables
-   USE par_trc      ! TOP parameters
-   USE trc          ! TOP variables
+   !!   trc_sms_c14b :  compute and add C14 suface forcing to C14 trends
+   !!----------------------------------------------------------------------
+   USE oce_trc       ! Ocean variables
+   USE par_trc       ! TOP parameters
+   USE trc           ! TOP variables
    USE trdmod_oce
    USE trdmod_trc
-   USE iom
+   USE iom           ! I/O library
 
    IMPLICIT NONE
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC   trc_sms_c14b       ! called in ???    
-
-   !! * Module variables
+   PUBLIC   trc_sms_c14b       ! called in trcsms.F90
+   PUBLIC   trc_sms_c14b_alloc ! called in trcini_c14b.F90
+
    INTEGER , PUBLIC, PARAMETER ::   jpmaxrec  = 240           ! temporal parameter 
    INTEGER , PUBLIC, PARAMETER ::   jpmaxrec2 = 2 * jpmaxrec  ! 
@@ -37,104 +37,91 @@
    INTEGER , PUBLIC    ::   nyear_beg        ! initial year (aa) 
 
-   REAL(wp), PUBLIC, DIMENSION(jpmaxrec,jpzon) ::  bomb   !: C14 atm data (3 zones)
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj ,jpzon) ::  fareaz !: Spatial Interpolation Factors
-   REAL(wp), PUBLIC, DIMENSION(jpmaxrec2)      ::  spco2  !: Atmospheric CO2
+   REAL(wp), PUBLIC,                    DIMENSION(jpmaxrec,jpzon) ::   bomb       !: C14 atm data (3 zones)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)          ::   fareaz     !: Spatial Interpolation Factors
+   REAL(wp), PUBLIC,                    DIMENSION(jpmaxrec2)      ::   spco2      !: Atmospheric CO2
   
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   qtr_c14      !: flux at surface
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   qint_c14     !: cumulative flux
-
-   REAL(wp) :: xlambda, xdecay, xaccum       ! C14 decay coef.  
-
-   REAL(wp) ::   xconv1 = 1.0          ! conversion from to 
-   REAL(wp) ::   xconv2 = 0.01/3600.   ! conversion from cm/h to m/s: 
-   REAL(wp) ::   xconv3 = 1.0e+3       ! conversion from mol/l/atm to mol/m3/atm
-
-  !! * Substitutions
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)            ::   qtr_c14    !: flux at surface
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)            ::   qint_c14   !: cumulative flux
+
+   REAL(wp) ::   xlambda, xdecay, xaccum       ! C14 decay coef.  
+   REAL(wp) ::   xconv1 = 1._wp                ! conversion from to 
+   REAL(wp) ::   xconv2 = 0.01_wp / 3600._wp   ! conversion from cm/h to m/s: 
+   REAL(wp) ::   xconv3 = 1.e+3_wp             ! conversion from mol/l/atm to mol/m3/atm
+
+   !! * Substitutions
 #  include "top_substitute.h90"
 
-  !!----------------------------------------------------------------------
-  !!  TOP 1.0 , LOCEAN-IPSL (2005) 
-  !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/SMS/trcc14bomb.F90,v 1.2 2005/11/14 16:42:43 opalod Exp $ 
-  !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
-  !!----------------------------------------------------------------------
-
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/SMS/trcc14bomb.F90,v 1.2 2005/11/14 16:42:43 opalod Exp $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
-  SUBROUTINE trc_sms_c14b( kt )
-     !!----------------------------------------------------------------------
-     !!                  ***  ROUTINE trc_sms_c14b  ***
-     !!
-     !! ** Purpose :   Compute the surface boundary contition on C14bomb
-     !!      passive tracer associated with air-mer fluxes and add it to 
-     !!      the general trend of tracers equations.
-     !!
-     !! ** Original comments from J. Orr :
-     !!
-     !!      Calculates the input of Bomb C-14 to the surface layer of OPA
-     !!
-     !!      James Orr, LMCE, 28 October 1992
-     !!
-     !!      Initial approach mimics that of Toggweiler, Dixon, & Bryan (1989)
-     !!      (hereafter referred to as TDB) with constant gas exchange,
-     !!      although in this case, a perturbation approach is used for
-     !!      bomb-C14 so that both the ocean and atmosphere begin at zero.
-     !!      This saves tremendous amounts of computer time since no
-     !!      equilibrum run is first required (i.e., for natural C-14).
-     !!      Note: Many sensitivity tests can be run with this approach and
-     !!            one never has to make a run for natural C-14; otherwise,
-     !!            a run for natural C-14 must be run each time that one
-     !!            changes a model parameter!
-     !!
-     !!
-     !!      19 August 1993: Modified to consider Atmospheric C-14 fom IPCC.
-     !!      That is, the IPCC has provided a C-14 atmospheric record (courtesy
-     !!      of Martin Heimann) for model calibration.  This model spans from
-     !!      preindustrial times to present, in a format different than that
-     !!      given by TDB.  It must be converted to the ORR C-14 units used
-     !!      here, although in this case, the perturbation includes not only
-     !!      bomb C-14 but changes due to the Suess effect.
-     !!
-     !!----------------------------------------------------------------------
-     !! * Arguments
-     INTEGER, INTENT( in ) ::   kt    ! ocean time-step index
-
-     !! * Local declarations
-     INTEGER ::  &
-       ji, jj, jk, jz
-
-     INTEGER ::   &
-       iyear_beg,              &
-       iyear_beg1, iyear_end1, &
-       imonth1, im1, im2,      &
-       iyear_beg2, iyear_end2, &
-       imonth2, in1, in2
-         
-     REAL(wp), DIMENSION(jpi,jpj) ::  & 
-       zatmbc14
-
-     REAL(wp), DIMENSION(jpzon)   ::  &
-       zonbc14              !: time interp atm C14
-
-     REAL(wp) ::     &
-       zpco2at              !: time interp atm C02
-
-     REAL(wp) ::     &      !: dummy variables
-       zt, ztp, zsk, &
-       zsol ,        &      !: solubility
-       zsch ,        &      !: schmidt number
-       zv2  ,        &      !: wind speed ( square)
-       zpv  ,        &      !: piston velocity 
-       zdemi, ztra
-#if defined key_diatrc  && defined key_iomput
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zw3d
-#endif
-      !!----------------------------------------------------------------------
-
-      IF( kt == nit000 )  THEN
-         ! Computation of decay coeffcient
-         zdemi   = 5730.
+   SUBROUTINE trc_sms_c14b( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_sms_c14b  ***
+      !!
+      !! ** Purpose :   Compute the surface boundary contition on C14bomb
+      !!      passive tracer associated with air-mer fluxes and add it to 
+      !!      the general trend of tracers equations.
+      !!
+      !! ** Original comments from J. Orr :
+      !!
+      !!      Calculates the input of Bomb C-14 to the surface layer of OPA
+      !!
+      !!      James Orr, LMCE, 28 October 1992
+      !!
+      !!      Initial approach mimics that of Toggweiler, Dixon, & Bryan (1989)
+      !!      (hereafter referred to as TDB) with constant gas exchange,
+      !!      although in this case, a perturbation approach is used for
+      !!      bomb-C14 so that both the ocean and atmosphere begin at zero.
+      !!      This saves tremendous amounts of computer time since no
+      !!      equilibrum run is first required (i.e., for natural C-14).
+      !!      Note: Many sensitivity tests can be run with this approach and
+      !!            one never has to make a run for natural C-14; otherwise,
+      !!            a run for natural C-14 must be run each time that one
+      !!            changes a model parameter!
+      !!
+      !!
+      !!      19 August 1993: Modified to consider Atmospheric C-14 fom IPCC.
+      !!      That is, the IPCC has provided a C-14 atmospheric record (courtesy
+      !!      of Martin Heimann) for model calibration.  This model spans from
+      !!      preindustrial times to present, in a format different than that
+      !!      given by TDB.  It must be converted to the ORR C-14 units used
+      !!      here, although in this case, the perturbation includes not only
+      !!      bomb C-14 but changes due to the Suess effect.
+      !!
+      !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zatmbc14 => wrk_2d_1
+      USE wrk_nemo, ONLY:   zw3d     => wrk_3d_1
+      !
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !
+      INTEGER :: ji, jj, jk, jz     ! dummy loop indices 
+      INTEGER :: iyear_beg , iyear_beg1, iyear_end1 
+      INTEGER :: iyear_beg2, iyear_end2 
+      INTEGER :: imonth1, im1, in1 
+      INTEGER :: imonth2, im2, in2 
+      REAL(wp), DIMENSION(jpzon) :: zonbc14       !: time interp atm C14 
+      REAL(wp)                   :: zpco2at       !: time interp atm C02 
+      REAL(wp) :: zt, ztp, zsk      ! dummy variables
+      REAL(wp) :: zsol              ! solubility
+      REAL(wp) :: zsch              ! schmidt number
+      REAL(wp) :: zv2               ! wind speed ( square)
+      REAL(wp) :: zpv               ! piston velocity 
+      REAL(wp) :: zdemi, ztra
+      !!----------------------------------------------------------------------
+
+      IF( wrk_in_use(2, 1) .OR. wrk_in_use(3, 1) ) THEN
+         CALL ctl_stop('trc_sms_c14b : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
+
+      IF( kt == nit000 )  THEN         ! Computation of decay coeffcient
+         zdemi   = 5730._wp
          xlambda = LOG(2.) / zdemi / ( nyear_len(1) * rday )
          xdecay  = EXP( - xlambda * rdt )
-         xaccum  = 1.0 -  xdecay
+         xaccum  = 1._wp -  xdecay
       ENDIF
 
@@ -206,11 +193,7 @@
       !  (zonmean), computes area-weighted mean to give the atmospheric C-14
       !  ----------------------------------------------------------------
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            zatmbc14(ji,jj) =   zonbc14(1) * fareaz(ji,jj,1)  &
-                 &           +  zonbc14(2) * fareaz(ji,jj,2)  &
-                 &           +  zonbc14(3) * fareaz(ji,jj,3)
-         END DO
-      END DO
+      zatmbc14(:,:) = zonbc14(1) * fareaz(:,:,1)   &
+         &          + zonbc14(2) * fareaz(:,:,2)   &
+         &          + zonbc14(3) * fareaz(:,:,3)
       
       ! time interpolation of CO2 concentrations to it time step  
@@ -218,5 +201,5 @@
            &     + spco2(iyear_end2) * FLOAT( in2 ) ) / 6.
 
-      IF (lwp) THEN
+      IF(lwp) THEN
           WRITE(numout, *) 'time : ', kt, ' CO2 year begin/end :',iyear_beg2,'/',iyear_end2,   &
           &                ' CO2 concen : ',zpco2at 
@@ -238,7 +221,7 @@
                zsol = EXP( -60.2409 + 93.4517 / ztp  + 23.3585 * LOG( ztp ) + zsk * tsn(ji,jj,1,jp_sal) )
                ! convert solubilities [mol/(l * atm)] -> [mol/(m^3 * ppm)]
-               zsol = zsol * 1.0e-03
+               zsol = zsol * 1.e-03
             ELSE
-               zsol = 0.
+               zsol = 0._wp
             ENDIF
 
@@ -307,18 +290,32 @@
       CALL iom_put( "fdecay" , zw3d )
 #endif
-      IF( l_trdtrc ) THEN
-         CALL trd_mod_trc( tra(:,:,:,jpc14), jpc14, jptra_trd_sms, kt )   ! save trends
-      END IF
-
-    END SUBROUTINE trc_sms_c14b
+      IF( l_trdtrc )   CALL trd_mod_trc( tra(:,:,:,jpc14), jpc14, jptra_trd_sms, kt )   ! save trends
+
+      IF( wrk_not_released(2, 1) .OR.   &
+          wrk_not_released(3, 1) )   CALL ctl_stop('trc_sms_c14b : failed to release workspace arrays')
+      !
+   END SUBROUTINE trc_sms_c14b
+
+
+   INTEGER FUNCTION trc_sms_c14b_alloc()
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_sms_c14b_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( fareaz  (jpi,jpj ,jpzon) ,     &
+         &      qtr_c14 (jpi,jpj)        ,     &
+         &      qint_c14(jpi,jpj)        , STAT=trc_sms_c14b_alloc )
+         !
+      IF( trc_sms_c14b_alloc /= 0 )   CALL ctl_warn('trc_sms_c14b_alloc: failed to allocate arrays')
+      !
+   END FUNCTION trc_sms_c14b_alloc
 
 #else
-    !!----------------------------------------------------------------------
-    !!   Default option                                         Dummy module
-    !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Dummy module
+   !!----------------------------------------------------------------------
 CONTAINS
-  SUBROUTINE trc_sms_c14b( kt )       ! Empty routine
-    WRITE(*,*) 'trc_freons: You should not have seen this print! error?', kt
-  END SUBROUTINE trc_sms_c14b
+   SUBROUTINE trc_sms_c14b( kt )       ! Empty routine
+      WRITE(*,*) 'trc_freons: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_sms_c14b
 #endif
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcini_cfc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcini_cfc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcini_cfc.F90	(revision 2715)
@@ -15,6 +15,5 @@
    USE par_trc         ! TOP parameters
    USE trc             ! TOP variables
-   USE trcsms_cfc          ! CFC sms trends
-   USE in_out_manager  ! I/O manager
+   USE trcsms_cfc      ! CFC sms trends
 
    IMPLICIT NONE
@@ -34,5 +33,4 @@
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -45,6 +43,6 @@
       !! ** Method  : - Read the namcfc namelist and check the parameter values
       !!----------------------------------------------------------------------
-      INTEGER  ::   ji, jj, jn, jl, jm, js
-      REAL(wp) ::   zyy  ,  zyd
+      INTEGER  ::  ji, jj, jn, jl, jm, js
+      REAL(wp) ::  zyy, zyd
       !!----------------------------------------------------------------------
 
@@ -53,13 +51,16 @@
       IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~'
 
+      !                                ! Allocate CFC arrays
+      IF( trc_sms_cfc_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trc_ini_cfc: unable to allocate CFC arrays' )
+
 
       ! Initialization of boundaries conditions
       ! --------------------------------------- 
-      xphem (:,:)    = 0.e0
-      p_cfc(:,:,:)   = 0.e0
+      xphem (:,:)    = 0._wp
+      p_cfc(:,:,:)   = 0._wp
       
       ! Initialization of qint in case of  no restart 
       !----------------------------------------------
-      qtr_cfc(:,:,:) = 0.e0
+      qtr_cfc(:,:,:) = 0._wp
       IF( .NOT. ln_rsttr ) THEN    
          IF(lwp) THEN
@@ -67,8 +68,8 @@
             WRITE(numout,*) 'Initialization de qint ; No restart : qint equal zero '
          ENDIF
-         qint_cfc(:,:,:) = 0.e0
+         qint_cfc(:,:,:) = 0._wp
          DO jl = 1, jp_cfc
             jn = jp_cfc0 + jl - 1
-            trn     (:,:,:,jn) = 0.e0
+            trn(:,:,:,jn) = 0._wp
          END DO
       ENDIF
@@ -116,6 +117,5 @@
          WRITE(numout,*) ' Year   p11HN    p11HS    p12HN    p12HS '
          DO jn = 30, 100
-            WRITE(numout, '( 1I4, 4F9.2)')   &
-               &         jn, p_cfc(jn,1,1), p_cfc(jn,2,1), p_cfc(jn,1,2), p_cfc(jn,2,2)
+            WRITE(numout, '( 1I4, 4F9.2)') jn, p_cfc(jn,1,1), p_cfc(jn,2,1), p_cfc(jn,1,2), p_cfc(jn,2,2)
          END DO
       ENDIF
@@ -135,8 +135,7 @@
       END DO
       !
-
       IF(lwp) WRITE(numout,*) 'Initialization of CFC tracers done'
       IF(lwp) WRITE(numout,*) ' '
-
+      !
    END SUBROUTINE trc_ini_cfc
    
Index: trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcnam_cfc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcnam_cfc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcnam_cfc.F90	(revision 2715)
@@ -16,5 +16,4 @@
    USE trc             ! TOP variables
    USE trcsms_cfc      ! CFC specific variable
-   USE in_out_manager  ! I/O manager
 
    IMPLICIT NONE
Index: trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcrst_cfc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcrst_cfc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcrst_cfc.F90	(revision 2715)
@@ -17,5 +17,4 @@
    USE trc             ! TOP variables
    USE trcsms_cfc          ! CFC sms trends
-   USE in_out_manager  ! I/O manager
    USE iom
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcsms_cfc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcsms_cfc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/CFC/trcsms_cfc.F90	(revision 2715)
@@ -4,7 +4,7 @@
    !! TOP : CFC main model
    !!======================================================================
-   !! History :    -   !  1999-10  (JC. Dutay)  original code
-   !!             1.0  !  2004-03 (C. Ethe) free form + modularity
-   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  reorganisation
+   !! History :  OPA  !  1999-10  (JC. Dutay)  original code
+   !!  NEMO      1.0  !  2004-03  (C. Ethe) free form + modularity
+   !!            2.0  !  2007-12  (C. Ethe, G. Madec)  reorganisation
    !!----------------------------------------------------------------------
 #if defined key_cfc
@@ -12,18 +12,19 @@
    !!   'key_cfc'                                               CFC tracers
    !!----------------------------------------------------------------------
-   !!   trc_sms_cfc     :  compute and add CFC suface forcing to CFC trends
-   !!   trc_cfc_cst :  sets constants for CFC surface forcing computation
-   !!----------------------------------------------------------------------
-   USE oce_trc      ! Ocean variables
-   USE par_trc      ! TOP parameters
-   USE trc          ! TOP variables
+   !!   trc_sms_cfc  :  compute and add CFC suface forcing to CFC trends
+   !!   trc_cfc_cst  :  sets constants for CFC surface forcing computation
+   !!----------------------------------------------------------------------
+   USE oce_trc       ! Ocean variables
+   USE par_trc       ! TOP parameters
+   USE trc           ! TOP variables
    USE trdmod_oce
    USE trdmod_trc
-   USE iom
+   USE iom           ! I/O library
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   trc_sms_cfc       ! called in ???    
+   PUBLIC   trc_sms_cfc         ! called in ???    
+   PUBLIC   trc_sms_cfc_alloc   ! called in trcini_cfc.F90
 
    INTEGER , PUBLIC, PARAMETER ::   jpyear = 150   ! temporal parameter 
@@ -34,8 +35,8 @@
    INTEGER , PUBLIC    ::   npyear         ! Number of years read in CFC1112 file
    
-   REAL(wp), PUBLIC, DIMENSION(jpyear,jphem, 2    ) ::   p_cfc    ! partial hemispheric pressure for CFC          
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)              ::   xphem    ! spatial interpolation factor for patm
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj     ,jp_cfc) ::   qtr_cfc  ! flux at surface
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj     ,jp_cfc) ::   qint_cfc ! cumulative flux 
+   REAL(wp), PUBLIC, DIMENSION(jpyear,jphem, 2    )      ::   p_cfc    ! partial hemispheric pressure for CFC
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   xphem    ! spatial interpolation factor for patm
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qtr_cfc  ! flux at surface
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qint_cfc ! cumulative flux 
 
    REAL(wp), DIMENSION(4,2) ::   soa   ! coefficient for solubility of CFC [mol/l/atm]
@@ -54,7 +55,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -75,10 +75,12 @@
       !!                CFC concentration in pico-mol/m3
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt    ! ocean time-step index
-      !!
-      INTEGER ::   ji, jj, jn, jl, jm, js
-      INTEGER ::   iyear_beg, iyear_end
-      INTEGER ::   im1, im2
-
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   ztrcfc => wrk_3d_1        ! use for CFC sms trend
+      !
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jn, jl, jm, js
+      INTEGER  ::   iyear_beg, iyear_end
+      INTEGER  ::   im1, im2
       REAL(wp) ::   ztap, zdtap        
       REAL(wp) ::   zt1, zt2, zt3, zv2
@@ -88,8 +90,10 @@
       REAL(wp) ::   zca_cfc   ! concentration at equilibrium
       REAL(wp) ::   zak_cfc   ! transfert coefficients
-
-      REAL(wp), DIMENSION(jphem,jp_cfc)   ::   zpatm       ! atmospheric function
-      REAL(wp), DIMENSION(jpi,jpj,jpk)    ::   ztrcfc      ! use for CFC sms trend
-      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jphem,jp_cfc) ::   zpatm   ! atmospheric function
+      !!----------------------------------------------------------------------
+      !
+      IF( wrk_in_use(3, 1) ) THEN
+         CALL ctl_stop('trc_sms_cfc: requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 )   CALL trc_cfc_cst
@@ -175,10 +179,10 @@
 #if defined key_diatrc 
       ! Save diagnostics , just for CFC11
-# if ! defined key_iomput
+# if  defined key_iomput
+      CALL iom_put( "qtrCFC11"  , qtr_cfc (:,:,1) )
+      CALL iom_put( "qintCFC11" , qint_cfc(:,:,1) )
+# else
       trc2d(:,:,jp_cfc0_2d    ) = qtr_cfc (:,:,1)
       trc2d(:,:,jp_cfc0_2d + 1) = qint_cfc(:,:,1)
-# else
-      CALL iom_put( "qtrCFC11"  , qtr_cfc (:,:,1) )
-      CALL iom_put( "qintCFC11" , qint_cfc(:,:,1) )
 # endif
 #endif
@@ -190,6 +194,9 @@
           END DO
       END IF
-
+      !
+      IF( wrk_not_released(3, 1) )   CALL ctl_stop('trc_sms_cfc: failed to release workspace array')
+      !
    END SUBROUTINE trc_sms_cfc
+
 
    SUBROUTINE trc_cfc_cst
@@ -200,45 +207,57 @@
       !!---------------------------------------------------------------------
 
-
-        ! coefficient for CFC11 
-        !----------------------
-
-        ! Solubility
-        soa(1,1) = -229.9261 
-        soa(2,1) =  319.6552
-        soa(3,1) =  119.4471
-        soa(4,1) =  -1.39165
-
-        sob(1,1) =  -0.142382
-        sob(2,1) =   0.091459
-        sob(3,1) =  -0.0157274
-
-        ! Schmidt number 
-        sca(1,1) = 3501.8
-        sca(2,1) = -210.31
-        sca(3,1) =  6.1851
-        sca(4,1) = -0.07513
-
-        ! coefficient for CFC12 
-        !----------------------
-
-        ! Solubility
-        soa(1,2) = -218.0971
-        soa(2,2) =  298.9702
-        soa(3,2) =  113.8049
-        soa(4,2) =  -1.39165
-
-        sob(1,2) =  -0.143566
-        sob(2,2) =   0.091015
-        sob(3,2) =  -0.0153924
-
-        ! schmidt number 
-        sca(1,2) =  3845.4 
-        sca(2,2) =  -228.95
-        sca(3,2) =  6.1908 
-        sca(4,2) =  -0.067430
+      ! coefficient for CFC11 
+      !----------------------
+
+      ! Solubility
+      soa(1,1) = -229.9261 
+      soa(2,1) =  319.6552
+      soa(3,1) =  119.4471
+      soa(4,1) =  -1.39165
+
+      sob(1,1) =  -0.142382
+      sob(2,1) =   0.091459
+      sob(3,1) =  -0.0157274
+
+      ! Schmidt number 
+      sca(1,1) = 3501.8
+      sca(2,1) = -210.31
+      sca(3,1) =  6.1851
+      sca(4,1) = -0.07513
+
+      ! coefficient for CFC12 
+      !----------------------
+
+      ! Solubility
+      soa(1,2) = -218.0971
+      soa(2,2) =  298.9702
+      soa(3,2) =  113.8049
+      soa(4,2) =  -1.39165
+
+      sob(1,2) =  -0.143566
+      sob(2,2) =   0.091015
+      sob(3,2) =  -0.0153924
+
+      ! schmidt number 
+      sca(1,2) =  3845.4 
+      sca(2,2) =  -228.95
+      sca(3,2) =  6.1908 
+      sca(4,2) =  -0.067430
 
    END SUBROUTINE trc_cfc_cst
-   
+
+
+   INTEGER FUNCTION trc_sms_cfc_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_sms_cfc_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( xphem   (jpi,jpj)        ,     &
+         &      qtr_cfc (jpi,jpj,jp_cfc) ,     &
+         &      qint_cfc(jpi,jpj,jp_cfc) , STAT=trc_sms_cfc_alloc )
+         !
+      IF( trc_sms_cfc_alloc /= 0 ) CALL ctl_warn('trc_sms_cfc_alloc : failed to allocate arrays.')
+      !
+   END FUNCTION trc_sms_cfc_alloc
+
 #else
    !!----------------------------------------------------------------------
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90	(revision 2715)
@@ -4,27 +4,23 @@
    !! TOP :   LOBSTER 1 Source Minus Sink variables
    !!----------------------------------------------------------------------
-   !! History :    -   !  1999-09 (M. Levy)  original code
-   !!              -   !  2000-12 (O. Aumont, E. Kestenare) add sediment 
-   !!             1.0  !  2005-10 (C. Ethe) F90
-   !!             1.0  !  2005-03  (A-S Kremeur) add fphylab, fzoolab, fdetlab, fdbod
-   !!              -   !  2005-06  (A-S Kremeur) add sedpocb, sedpocn, sedpoca
-   !!             2.0  !  2007-04  (C. Deltel, G. Madec) Free form and modules
+   !! History :  OPA  !  1999-09  (M. Levy)  original code
+   !!             -   !  2000-12  (O. Aumont, E. Kestenare) add sediment 
+   !!   NEMO     1.0  !  2005-10  (C. Ethe) F90
+   !!             -   !  2005-03  (A-S Kremeur) add fphylab, fzoolab, fdetlab, fdbod
+   !!             -   !  2005-06  (A-S Kremeur) add sedpocb, sedpocn, sedpoca
+   !!            2.0  !  2007-04  (C. Deltel, G. Madec) Free form and modules
    !!----------------------------------------------------------------------
-
 #if defined key_lobster
    !!----------------------------------------------------------------------
    !!   'key_lobster'                                         LOBSTER model
    !!----------------------------------------------------------------------
-   USE par_oce
-   USE par_trc
+   USE par_oce    ! ocean parameters
+   USE par_trc    ! passive tracer parameters
+   USE lib_mpp    ! MPP library
 
    IMPLICIT NONE
    PUBLIC
 
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
+   PUBLIC   sms_lobster_alloc   ! called in trcini_lobster.F90
 
    !!  biological parameters
@@ -76,19 +72,19 @@
    REAL(wp) ::   fdbod    !: zooplankton mortality fraction that goes to detritus
 
-   REAL(wp), DIMENSION(jpk,jp_lobster) ::   remdmp   !: depth dependant damping coefficient of passive tracers 
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   remdmp   !: depth dependant damping coefficient of passive tracers 
    
    !! Optical parameters                                
    !! ------------------                                
-   REAL(wp) ::   xkr0       !: water coefficient absorption in red      (NAMELIST)
-   REAL(wp) ::   xkg0       !: water coefficient absorption in green    (NAMELIST)
-   REAL(wp) ::   xkrp       !: pigment coefficient absorption in red    (NAMELIST)
-   REAL(wp) ::   xkgp       !: pigment coefficient absorption in green  (NAMELIST)
-   REAL(wp) ::   xlr        !: exposant for pigment absorption in red   (NAMELIST)
-   REAL(wp) ::   xlg        !: exposant for pigment absorption in green (NAMELIST)
-   REAL(wp) ::   rpig       !: chla/chla+phea ratio                     (NAMELIST)
+   REAL(wp) ::   xkr0     !: water coefficient absorption in red      (NAMELIST)
+   REAL(wp) ::   xkg0     !: water coefficient absorption in green    (NAMELIST)
+   REAL(wp) ::   xkrp     !: pigment coefficient absorption in red    (NAMELIST)
+   REAL(wp) ::   xkgp     !: pigment coefficient absorption in green  (NAMELIST)
+   REAL(wp) ::   xlr      !: exposant for pigment absorption in red   (NAMELIST)
+   REAL(wp) ::   xlg      !: exposant for pigment absorption in green (NAMELIST)
+   REAL(wp) ::   rpig     !: chla/chla+phea ratio                     (NAMELIST)
                                                         
-   INTEGER , DIMENSION(jpi,jpj)     ::   neln    !: number of levels in the euphotic layer
-   REAL(wp), DIMENSION(jpi,jpj)     ::   xze     !: euphotic layer depth
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xpar    !: par (photosynthetic available radiation)
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   neln   !: number of levels in the euphotic layer
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   xze    !: euphotic layer depth
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xpar   !: par (photosynthetic available radiation)
 
    !! Sediment parameters                               
@@ -98,13 +94,40 @@
    REAL(wp) ::   areacot      !: ???
                                                         
-   REAL(wp), DIMENSION(jpi,jpj)     ::   dminl   !: fraction of sinking POC released in sediments
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   dmin3   !: fraction of sinking POC released at each level
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   dminl     !: fraction of sinking POC released in sediments
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   dmin3     !: fraction of sinking POC released at each level
                                                         
-   REAL(wp), DIMENSION(jpi,jpj) ::   sedpocb     !: mass of POC in sediments
-   REAL(wp), DIMENSION(jpi,jpj) ::   sedpocn     !: mass of POC in sediments
-   REAL(wp), DIMENSION(jpi,jpj) ::   sedpoca     !: mass of POC in sediments
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   sedpocb   !: mass of POC in sediments
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   sedpocn   !: mass of POC in sediments
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   sedpoca   !: mass of POC in sediments
                                                         
-   REAL(wp), DIMENSION(jpi,jpj) ::   fbod        !: rapid sinking particles
-   REAL(wp), DIMENSION(jpi,jpj) ::   cmask       !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   fbod      !: rapid sinking particles
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   cmask     !: ???
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   INTEGER FUNCTION sms_lobster_alloc()
+      !!----------------------------------------------------------------------
+      !!        *** ROUTINE sms_lobster_alloc ***
+      !!----------------------------------------------------------------------
+      !
+      ALLOCATE(                                                                   &
+         !*  Biological parameters
+         &      remdmp(jpk,jp_lobster)                                      ,     &
+         !*  Optical parameters
+         &      neln   (jpi,jpj) , xze    (jpi,jpj)     , xpar(jpi,jpj,jpk) ,     &
+         !*  Sediment parameters
+         &      dminl  (jpi,jpj) , dmin3  (jpi,jpj,jpk)                     ,     &
+         &      sedpocb(jpi,jpj) , sedpocn(jpi,jpj)     , sedpoca(jpi,jpj)  ,     &
+         &      fbod   (jpi,jpj) , cmask  (jpi,jpj)                         , STAT=sms_lobster_alloc ) 
+         !
+      IF( lk_mpp                 )   CALL mpp_sum ( sms_lobster_alloc )
+      IF( sms_lobster_alloc /= 0 )   CALL ctl_warn('sms_lobster_alloc: failed to allocate arrays')
+      !
+   END FUNCTION sms_lobster_alloc
 
 #else
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcbio.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcbio.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcbio.F90	(revision 2715)
@@ -60,4 +60,7 @@
       !!              for passive tracers are saved for futher diagnostics.
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use,  wrk_not_released
+      USE wrk_nemo, ONLY: wrk_3d_2, wrk_4d_1
+      !!
       INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
       !!
@@ -75,10 +78,20 @@
 #endif
 #if defined key_diatrc && defined key_iomput
-      REAL(wp), DIMENSION(jpi,jpj,17)     :: zw2d
-      REAL(wp), DIMENSION(jpi,jpj,jpk,3) :: zw3d
+      REAL(wp), POINTER,   DIMENSION(:,:,:) :: zw2d
+      REAL(wp), POINTER, DIMENSION(:,:,:,:) :: zw3d
 #endif
       REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   ztrbio
       CHARACTER (len=25) :: charout
       !!---------------------------------------------------------------------
+
+#if defined key_diatrc && defined key_iomput
+      IF( ( wrk_in_use(3, 2) ) .OR. ( wrk_in_use(4, 1) ) ) THEN
+         CALL ctl_stop('trc_bio : requested workspace arrays unavailable.')
+         RETURN
+      END IF
+      ! Set-up pointers into sub-arrays of workspaces
+      zw2d => wrk_3d_2(:,:,1:17)
+      zw3d => wrk_4d_1(:,:,:,1:3)
+#endif
 
       IF( kt == nit000 ) THEN
@@ -90,11 +103,12 @@
       fbod(:,:) = 0.e0
 #if defined key_diatrc && ! defined key_iomput
+#  if defined key_iomput
+      zw2d  (:,:,:) = 0.e0
+      zw3d(:,:,:,:) = 0.e0
+#  else
       DO jl = jp_lob0_2d, jp_lob1_2d
          trc2d(:,:,jl) = 0.e0
       END DO 
-#endif
-#if defined key_diatrc && defined key_iomput
-      zw2d(:,:,:) = 0.e0
-      zw3d(:,:,:,:) = 0.e0
+#  endif
 #endif
 
@@ -485,5 +499,10 @@
          CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
       ENDIF
-
+      !
+#if defined key_diatrc && defined key_iomput
+      IF( ( wrk_not_released(3, 2) ) .OR. ( wrk_not_released(4, 1) ) )  &
+        &   CALL ctl_stop('trc_bio : failed to release workspace arrays.')
+#endif
+      !
    END SUBROUTINE trc_bio
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcexp.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcexp.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcexp.F90	(revision 2715)
@@ -101,5 +101,5 @@
             sedpoca(ji,jj) = ( zwork + dminl(ji,jj) * fbod(ji,jj)   &
                &           - sedlam * sedpocn(ji,jj) - sedlostpoc * sedpocn(ji,jj) ) * rdt
-            zgeolpoc = zgeolpoc + sedlostpoc * sedpocn(ji,jj) * e1t(ji,jj) * e2t(ji,jj)
+            zgeolpoc = zgeolpoc + sedlostpoc * sedpocn(ji,jj) * e1e2t(ji,jj)
          END DO
       END DO
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90	(revision 2715)
@@ -4,7 +4,7 @@
    !! TOP :   initialisation of the LOBSTER biological model
    !!======================================================================
-   !! History :    -   !  1999-09  (M. Levy) Original code
+   !! History :   OPA  !  1999-09  (M. Levy) Original code
    !!              -   !  2000-12  (0. Aumont, E. Kestenare) add sediment 
-   !!             1.0  !  2004-03  (C. Ethe) Modularity
+   !!   NEMO      1.0  !  2004-03  (C. Ethe) Modularity
    !!              -   !  2005-03  (O. Aumont, A. El Moussaoui) F90
    !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) from trcini.lobster1.h90
@@ -21,6 +21,4 @@
    USE trc
    USE lbclnk 
-   USE lib_mpp 
-   USE lib_fortran 
 
    IMPLICIT NONE
@@ -33,7 +31,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -43,13 +40,14 @@
       !! ** purpose :   specific initialisation for LOBSTER bio-model
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zrro => wrk_2d_1 , zdm0 => wrk_3d_1
+      !!
       INTEGER  ::   ji, jj, jk, jn
       REAL(wp) ::   ztest, zfluo, zfluu
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zrro
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdm0
       !!----------------------------------------------------------------------
-
-      !  Control consitency
-      CALL trc_ctl_lobster
-
+      !
+      IF(  wrk_in_use(2, 1)  .OR.  wrk_in_use(3, 1)  )  THEN
+         CALL ctl_stop('trc_ini_lobster: requested workspace arrays unavailable')   ;  RETURN
+      ENDIF
 
       IF(lwp) WRITE(numout,*)
@@ -57,8 +55,13 @@
       IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~~'
 
+      !                                ! Allocate LOBSTER arrays
+      IF( sms_lobster_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trc_ini_lobster: unable to allocate LOBSTER arrays' )
+
+
+
       ! initialization of fields for optical model
       ! --------------------------------------------
-      xze (:,:)   = 5.e0
-      xpar(:,:,:) = 0.e0
+      xze (:,:)   = 5._wp
+      xpar(:,:,:) = 0._wp
 
       ! initialization for passive tracer remineralisation-damping  array
@@ -70,7 +73,6 @@
 
       IF(lwp) THEN
-         WRITE(numout,*) ' '
-         WRITE(numout,*) ' trcini: compute remineralisation-damping  '
-         WRITE(numout,*) '         arrays for tracers'
+         WRITE(numout,*)
+         WRITE(numout,*) ' trcini: compute remineralisation-damping arrays for tracers'
       ENDIF
 
@@ -82,19 +84,19 @@
       ! ------------------------------------------------------------
 
-      zdm0   = 0.e0
-      zrro = 1.e0
-      DO jk = jpkb,jpkm1
-         DO jj =1, jpj
-            DO ji =1, jpi
+      zdm0 = 0._wp
+      zrro = 1._wp
+      DO jk = jpkb, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
                zfluo = ( fsdepw(ji,jj,jk  ) / fsdepw(ji,jj,jpkb) )**xhr 
                zfluu = ( fsdepw(ji,jj,jk+1) / fsdepw(ji,jj,jpkb) )**xhr
-               IF( zfluo.GT.1. )   zfluo = 1.e0
+               IF( zfluo.GT.1. )   zfluo = 1._wp
                zdm0(ji,jj,jk) = zfluo - zfluu
-               IF( jk <= jpkb-1 )   zdm0(ji,jj,jk) = 0.e0
+               IF( jk <= jpkb-1 )   zdm0(ji,jj,jk) = 0._wp
                zrro(ji,jj) = zrro(ji,jj) - zdm0(ji,jj,jk)
             END DO
          END DO
       END DO
-
+      !
       zdm0(:,:,jpk) = zrro(:,:)
 
@@ -103,12 +105,12 @@
       ! contains total fraction, which has passed to the upper layers)
       ! ----------------------------------------------------------------------
-      dminl = 0.
-      dmin3 = zdm0
+      dminl(:,:)   = 0._wp
+      dmin3(:,:,:) = zdm0
       DO jk = 1, jpk
          DO jj = 1, jpj
             DO ji = 1, jpi
-               IF( tmask(ji,jj,jk) == 0. ) THEN
+               IF( tmask(ji,jj,jk) == 0._wp ) THEN
                   dminl(ji,jj) = dminl(ji,jj) + dmin3(ji,jj,jk)
-                  dmin3(ji,jj,jk) = 0.e0
+                  dmin3(ji,jj,jk) = 0._wp
                ENDIF
             END DO
@@ -118,5 +120,5 @@
       DO jj = 1, jpj
          DO ji = 1, jpi
-            IF( tmask(ji,jj,1) == 0 )   dmin3(ji,jj,1) = 0.e0
+            IF( tmask(ji,jj,1) == 0 )   dmin3(ji,jj,1) = 0._wp
          END DO
       END DO
@@ -124,11 +126,11 @@
       ! Coastal mask 
       ! ------------   
-      cmask(:,:) = 0.e0
+      cmask(:,:) = 0._wp
       DO ji = 2, jpi-1
          DO jj = 2, jpj-1
-            if (tmask(ji,jj,1) == 1) then
+            IF( tmask(ji,jj,1) == 1._wp ) THEN
                ztest=tmask(ji+1,jj,1)*tmask(ji-1,jj,1)*tmask(ji,jj+1,1)*tmask(ji,jj-1,1)
-               IF (ztest == 0) cmask(ji,jj) = 1.
-            endif
+               IF( ztest == 0 )   cmask(ji,jj) = 1._wp
+            ENDIF
          END DO
       END DO
@@ -138,5 +140,5 @@
       ! Coastal surface
       ! ---------------
-      areacot = glob_sum( e1t(:,:) * e2t(:,:) * cmask(:,:) )
+      areacot = glob_sum( e1e2t(:,:) * cmask(:,:) )
 
       ! Initialization of tracer concentration in case of  no restart 
@@ -220,5 +222,6 @@
          trn(:,:,30,jp_lob_no3) = 20.01 * tmask(:,:,30)
 
-# elif defined key_gyre
+
+# elif defined key_gyre || defined key_orca_r2
          ! LOBSTER initialisation for GYRE
          ! ----------------------
@@ -245,76 +248,14 @@
 
       !  initialize the POC in sediments
-      sedpocb(:,:) = 0.e0
-      sedpocn(:,:) = 0.e0
-      sedpoca(:,:) = 0.e0
-
-
+      sedpocb(:,:) = 0._wp
+      sedpocn(:,:) = 0._wp
+      sedpoca(:,:) = 0._wp
+      !
       IF(lwp) WRITE(numout,*) 'Initialization of LOBSTER tracers done'
-      IF(lwp) WRITE(numout,*) ' '
-
-
+      !
+      IF(  wrk_not_released(2, 1)  .OR.   &
+           wrk_not_released(3, 1)   )   CALL ctl_stop('trc_ini_lobster: failed to release workspace arrays')
+      !
    END SUBROUTINE trc_ini_lobster
-
-   SUBROUTINE trc_ctl_lobster
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE trc_ctl_lobster  ***
-      !!
-      !! ** Purpose :   control the cpp options, namelist and files 
-      !!----------------------------------------------------------------------
-      INTEGER :: jl, jn
-
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) ' use LOBSTER biological model '
-
-      ! Check number of tracers
-      ! -----------------------
-      IF( jp_lobster /= 6 ) CALL ctl_stop( ' LOBSTER has 6 passive tracers. Change jp_lobster in par_lobster.F90' )
-
-      ! Check tracer names
-      ! ------------------
-      IF(   ctrcnm(jp_lob_det) /= 'DET' .OR. ctrcnm(jp_lob_zoo) /= 'ZOO' .OR.   &
-         &  ctrcnm(jp_lob_phy) /= 'PHY' .OR. ctrcnm(jp_lob_no3) /= 'NO3' .OR.   &
-         &  ctrcnm(jp_lob_nh4) /= 'NH4' .OR. ctrcnm(jp_lob_dom) /= 'DOM' .OR.   &
-         &  ctrcnl(jp_lob_det) /= 'Detritus'                        .OR.   &
-         &  ctrcnl(jp_lob_zoo) /= 'Zooplankton concentration'       .OR.   &
-         &  ctrcnl(jp_lob_phy) /= 'Phytoplankton concentration'     .OR.   &
-         &  ctrcnl(jp_lob_no3) /= 'Nitrate concentration'           .OR.   &
-         &  ctrcnl(jp_lob_nh4) /= 'Ammonium concentration'          .OR.   &
-         &  ctrcnl(jp_lob_dom) /= 'Dissolved organic matter' ) THEN
-         ctrcnm(jp_lob_det)='DET'
-         ctrcnl(jp_lob_det)='Detritus'
-         ctrcnm(jp_lob_zoo)='ZOO'
-         ctrcnl(jp_lob_zoo)='Zooplankton concentration'
-         ctrcnm(jp_lob_phy)='PHY'
-         ctrcnl(jp_lob_phy)='Phytoplankton concentration'
-         ctrcnm(jp_lob_no3)='NO3'
-         ctrcnl(jp_lob_no3)='Nitrate concentration'
-         ctrcnm(jp_lob_nh4)='NH4'
-         ctrcnl(jp_lob_nh4)='Ammonium concentration'
-         ctrcnm(jp_lob_dom)='DOM'
-         ctrcnl(jp_lob_dom)='Dissolved organic matter'
-         IF(lwp) THEN
-            CALL ctl_warn( ' We force tracer names ' )
-            DO jl = 1, jp_lobster
-               jn = jp_lob0 + jl - 1
-               WRITE(numout,*) ' tracer nb: ',jn,' name = ',ctrcnm(jn), ctrcnl(jn)
-            END DO
-            WRITE(numout,*) ' '
-         ENDIF
-      ENDIF
-
-      ! Check tracer units
-      DO jl = 1, jp_lobster
-         jn = jp_lob0 + jl - 1
-         IF( ctrcun(jn) /= 'mmole-N/m3') THEN
-            ctrcun(jn) = 'mmole-N/m3'
-            IF(lwp) THEN
-               CALL ctl_warn( ' We force tracer units ' )
-               WRITE(numout,*) ' tracer  ',ctrcnm(jn), 'UNIT= ',ctrcun(jn)
-            ENDIF
-         ENDIF
-      END DO
-
-   END SUBROUTINE trc_ctl_lobster
 
 #else
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcnam_lobster.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcnam_lobster.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcnam_lobster.F90	(revision 2715)
@@ -10,11 +10,10 @@
    !!   'key_lobster'   :                                 LOBSTER bio-model
    !!----------------------------------------------------------------------
-   !! trc_nam_lobster      : LOBSTER model namelist read
-   !!----------------------------------------------------------------------
-   USE oce_trc         ! Ocean variables
-   USE par_trc         ! TOP parameters
-   USE trc             ! TOP variables
-   USE sms_lobster     ! sms trends
-   USE in_out_manager  ! I/O manager
+   !! trc_nam_lobster   : LOBSTER model namelist read
+   !!----------------------------------------------------------------------
+   USE oce_trc          ! Ocean variables
+   USE par_trc          ! TOP parameters
+   USE trc              ! TOP variables
+   USE sms_lobster      ! sms trends
 
    IMPLICIT NONE
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcopt.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcopt.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcopt.F90	(revision 2715)
@@ -52,4 +52,10 @@
       !!                xze    ???
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: zpar100 => wrk_2d_1, & ! irradiance at euphotic layer depth
+                          zpar0m  => wrk_2d_2    ! irradiance just below the surface
+      USE wrk_nemo, ONLY: zparr => wrk_3d_2, &   ! red and green compound of par
+                          zparg => wrk_3d_3
+      !!
       INTEGER, INTENT( in ) ::   kt   ! index of the time stepping
       !!
@@ -59,9 +65,10 @@
       REAL(wp) ::   zkr, zkg            ! total absorption coefficient in red and green
       REAL(wp) ::   zcoef               ! temporary scalar
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zpar100         ! irradiance at euphotic layer depth
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zpar0m          ! irradiance just below the surface
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zparr, zparg    ! red and green compound of par
 
       !!---------------------------------------------------------------------
+
+      IF( ( wrk_in_use(2, 1,2)) .OR. ( wrk_in_use(3, 2,3)) )THEN
+         CALL ctl_stop('trc_opt : requested workspace arrays unavailable')   ;   RETURN
+      END IF
 
       IF( kt == nit000 ) THEN
@@ -130,4 +137,7 @@
       ENDIF
       !
+      IF( wrk_not_released(2, 1,2)  .OR.  wrk_not_released(3, 2,3)  )   &
+          CALL ctl_stop('trc_opt : failed to release workspace arrays')
+      !
    END SUBROUTINE trc_opt
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90	(revision 2715)
@@ -18,5 +18,4 @@
    USE trcsms_lobster          ! lobster sms trends
    USE sms_lobster          ! lobster sms trends
-   USE in_out_manager  ! I/O manager
    USE iom
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsed.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsed.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsed.F90	(revision 2715)
@@ -56,15 +56,21 @@
       !!              trend of passive tracers is saved for futher diagnostics.
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: zwork => wrk_3d_2
+      USE wrk_nemo, ONLY: zw2d  => wrk_2d_1 ! only used (if defined 
+                                            ! key_diatrc && defined key_iomput)
+      !!
       INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
       !!
       INTEGER  ::   ji, jj, jk, jl
       REAL(wp) ::   ztra
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwork
-#if defined key_diatrc && defined key_iomput
-      REAL(wp), DIMENSION(jpi,jpj) ::  zw2d
-#endif
       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrbio
       CHARACTER (len=25) :: charout
       !!---------------------------------------------------------------------
+
+      IF( ( wrk_in_use(3,2)) .OR. ( wrk_in_use(2,1)) ) THEN
+         CALL ctl_stop('trc_sed : requested workspace arrays unavailable.')
+         RETURN
+      END IF
 
       IF( kt == nit000 ) THEN
@@ -144,4 +150,7 @@
       ENDIF
 
+      IF( ( wrk_not_released(3, 2) ) .OR. ( wrk_not_released(2, 1) ) )  &
+       &         CALL ctl_stop('trc_sed : failed to release workspace arrays.')
+
    END SUBROUTINE trc_sed
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90	(revision 2715)
@@ -13,5 +13,5 @@
    !!   trcsms_lobster        :  Time loop of passive tracers sms
    !!----------------------------------------------------------------------
-   USE oce_trc         !
+   USE oce_trc          !
    USE trc
    USE trcbio
@@ -32,7 +32,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -45,9 +44,15 @@
       !!
       !! ** Method  : - ???
-      !! -------------------------------------------------------------------------------------
+      !! --------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: ztrlob => wrk_3d_1   ! used for lobster sms trends
+      !!
       INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
       INTEGER :: jn
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrlob   ! used for lobster sms trends
-      !!
+      !! --------------------------------------------------------------------
+
+      IF( wrk_in_use(3, 1) ) THEN
+         CALL ctl_stop('trc_sms_lobster : requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       CALL trc_opt( kt )      ! optical model
@@ -65,4 +70,6 @@
       IF( lk_trdmld_trc )  CALL trd_mld_bio( kt )   ! trends: Mixed-layer
 
+      IF( wrk_not_released(3, 1) )   CALL ctl_stop('trc_sms_lobster : failed to release workspace array.')
+      !
    END SUBROUTINE trc_sms_lobster
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90	(revision 2715)
@@ -24,7 +24,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -38,6 +37,8 @@
       !!----------------------------------------------------------------------
 
-      !  Control consitency
-      CALL trc_ctl_my_trc
+      !                       ! Allocate MY_TRC arrays
+      IF( sms_lobster_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trc_ini_my_trc: unable to allocate MY_TRC arrays' )
+
+      CALL trc_ctl_my_trc     ! Control consitency
 
       IF(lwp) WRITE(numout,*)
@@ -46,8 +47,8 @@
       
       IF( .NOT. ln_rsttr ) trn(:,:,:,jp_myt0:jp_myt1) = 0.
-
       !
    END SUBROUTINE trc_ini_my_trc
-   
+
+
    SUBROUTINE trc_ctl_my_trc
       !!----------------------------------------------------------------------
@@ -56,18 +57,17 @@
       !! ** Purpose :   control the cpp options, namelist and files 
       !!----------------------------------------------------------------------
-
       INTEGER :: jl, jn
-
+      !!----------------------------------------------------------------------
+      !
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) ' use COLOR tracer '
-
+      !
       DO jl = 1, jp_my_trc
          jn = jp_myt0 + jl - 1
-         WRITE(ctrcnm(jn),'(a,i2.2)') 'CLR',jn
+         WRITE( ctrcnm(jn),'(a,i2.2)' ) 'CLR', jn
          ctrcnl(jn)='Color concentration'
          ctrcun(jn)='N/A'
       END DO
-
-
+      !
    END SUBROUTINE trc_ctl_my_trc
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90	(revision 2715)
@@ -10,5 +10,6 @@
    !!   'key_my_trc'                                               CFC tracers
    !!----------------------------------------------------------------------
-   !! trc_sms_my_trc   : MY_TRC model main routine 
+   !! trc_sms_my_trc       : MY_TRC model main routine 
+   !! trc_sms_my_trc_alloc : allocate arrays specific to MY_TRC sms
    !!----------------------------------------------------------------------
    USE par_trc         ! TOP parameters
@@ -21,12 +22,14 @@
    PRIVATE
 
-   PUBLIC   trc_sms_my_trc   ! called by trcsms.F90 module
+   PUBLIC   trc_sms_my_trc       ! called by trcsms.F90 module
+   PUBLIC   trc_sms_my_trc_alloc ! called by trcini_my_trc.F90 module
 
+   ! Defined HERE the arrays specific to MY_TRC sms and ALLOCATE them in trc_sms_my_trc_alloc
+   
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -39,8 +42,10 @@
       !! ** Method  : - 
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) :: kt   ! ocean time-step index
-      REAL(wp), DIMENSION(jpi,jpj,jpk)    ::   ztrmyt 
-      INTEGER :: jn
-
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   ztrmyt => wrk_3d_1   ! used for lobster sms trends
+      !
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      INTEGER ::   jn   ! dummy loop index
+      !!----------------------------------------------------------------------
 
       IF(lwp) WRITE(numout,*)
@@ -49,17 +54,16 @@
 
       WHERE( (glamt <= 170) .AND. (glamt >= 160) .AND. (gphit <= -74) .AND. (gphit >=-75.6) )
-        trn(:,:,1,jpmyt1) = 1.
-        trb(:,:,1,jpmyt1) = 1.
-        tra(:,:,1,jpmyt1) = 0.
+        trn(:,:,1,jpmyt1) = 1._wp
+        trb(:,:,1,jpmyt1) = 1._wp
+        tra(:,:,1,jpmyt1) = 0._wp
       END WHERE
 
       WHERE( ((glamt <= -165) .OR. (glamt >= 160)) .AND. (gphit <= -76) .AND. (gphit >=-80)) 
-        trn(:,:,1,jpmyt2) = 1.
-        trb(:,:,1,jpmyt2) = 1.
-        tra(:,:,1,jpmyt2) = 0.
+        trn(:,:,1,jpmyt2) = 1._wp
+        trb(:,:,1,jpmyt2) = 1._wp
+        tra(:,:,1,jpmyt2) = 0._wp
       END WHERE
 
-      ! Save the trends in the ixed layer
-      IF( l_trdtrc ) THEN
+      IF( l_trdtrc ) THEN      ! Save the trends in the ixed layer
           DO jn = jp_myt0, jp_myt1
             ztrmyt(:,:,:) = tra(:,:,:,jn)
@@ -69,5 +73,20 @@
       !
    END SUBROUTINE trc_sms_my_trc
-   
+
+
+   INTEGER FUNCTION trc_sms_my_trc_alloc()
+      !!----------------------------------------------------------------------
+      !!              ***  ROUTINE trc_sms_my_trc_alloc  ***
+      !!----------------------------------------------------------------------
+      !
+      ! ALLOCATE here the arrays specific to MY_TRC
+      ! ALLOCATE( tab(...) , STAT=trc_sms_my_trc_alloc )
+      trc_sms_my_trc_alloc = 0      ! set to zero if no array to be allocated
+      !
+      IF( trc_sms_my_trc_alloc /= 0 ) CALL ctl_warn('trc_sms_my_trc_alloc : failed to allocate arrays')
+      !
+   END FUNCTION trc_sms_my_trc_alloc
+
+
 #else
    !!----------------------------------------------------------------------
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zbio.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zbio.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zbio.F90	(revision 2715)
@@ -32,9 +32,4 @@
 
    PUBLIC  p4z_bio    
-
-   !! * Shared module variables
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !:
-      xnegtr            ! Array used to indicate negative tracer values
-
 
    !!* Substitution
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zche.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zche.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zche.F90	(revision 2715)
@@ -4,8 +4,8 @@
    !! TOP :   PISCES Sea water chemistry computed following OCMIP protocol
    !!======================================================================
-   !! History :    -   !  1988     (E. Maier-Reimer)  Original code
+   !! History :   OPA  !  1988     (E. Maier-Reimer)  Original code
    !!              -   !  1998     (O. Aumont)  addition
    !!              -   !  1999     (C. Le Quere)  modification
-   !!             1.0  !  2004     (O. Aumont)  modification
+   !!   NEMO      1.0  !  2004     (O. Aumont)  modification
    !!              -   !  2006     (R. Gangsto)  modification
    !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
@@ -15,61 +15,52 @@
    !!   'key_pisces'                                       PISCES bio-model
    !!----------------------------------------------------------------------
-   !!   p4z_che        :  Sea water chemistry computed following OCMIP protocol
-   !!----------------------------------------------------------------------
-   USE oce_trc         !
-   USE trc         !
-   USE sms_pisces      ! 
+   !!   p4z_che      :  Sea water chemistry computed following OCMIP protocol
+   !!----------------------------------------------------------------------
+   USE oce_trc       !
+   USE trc           !
+   USE sms_pisces    ! 
+   USE lib_mpp       ! MPP library
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   p4z_che  
-
-   !! * Shared module variables
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
-      sio3eq, fekeq           !: chemistry of Fe and Si
-
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,2)   ::   &   !:
-      chemc                   !: Solubilities of O2 and CO2
-
-   !! * Module variables
-
-   REAL(wp) :: &
-      salchl = 1./1.80655 ! conversion factor for salinity --> chlorinity (Wooster et al. 1969)
-
-   REAL(wp) :: &            ! coeff. for apparent solubility equilibrium 
-      akcc1 = -171.9065 , &    ! Millero et al. 1995 from Mucci 1983
-      akcc2 = -0.077993 , &  
-      akcc3 = 2839.319  , &  
-      akcc4 = 71.595    , &  
-      akcc5 = -0.77712  , &  
-      akcc6 = 0.0028426 , &  
-      akcc7 = 178.34    , &  
-      akcc8 = -0.07711  , &  
-      akcc9 = 0.0041249
-
-   REAL(wp) :: &             ! universal gas constants
-      rgas = 83.143, &
-      oxyco = 1./22.4144
-
-   REAL(wp) :: &             ! borat constants
-      bor1 = 0.00023, &
-      bor2 = 1./10.82
-
-   REAL(wp) :: &              !
-      ca0 = -162.8301  , &
-      ca1 = 218.2968   , &
-      ca2 = 90.9241    , &
-      ca3 = -1.47696   , &
-      ca4 = 0.025695   , &
-      ca5 = -0.025225  , &
-      ca6 = 0.0049867
-
-   REAL(wp) :: &              ! coeff. for 1. dissoc. of carbonic acid (Edmond and Gieskes, 1970)   
-      c10 = -3670.7   , &
-      c11 = 62.008    , &
-      c12 = -9.7944   , &
-      c13 = 0.0118    , &
-      c14 = -0.000116
+   PUBLIC   p4z_che         !
+   PUBLIC   p4z_che_alloc   !
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sio3eq   ! chemistry of Si
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   fekeq    ! chemistry of Fe
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   chemc    ! Solubilities of O2 and CO2
+
+   REAL(wp) ::   salchl = 1._wp / 1.80655_wp ! conversion factor for salinity --> chlorinity (Wooster et al. 1969)
+
+   REAL(wp) ::   akcc1 = -171.9065_wp      ! coeff. for apparent solubility equilibrium
+   REAL(wp) ::   akcc2 =   -0.077993_wp    ! Millero et al. 1995 from Mucci 1983
+   REAL(wp) ::   akcc3 = 2839.319_wp       !
+   REAL(wp) ::   akcc4 =   71.595_wp       !
+   REAL(wp) ::   akcc5 =   -0.77712_wp     !
+   REAL(wp) ::   akcc6 =    0.0028426_wp   !
+   REAL(wp) ::   akcc7 =  178.34_wp        !
+   REAL(wp) ::   akcc8 =   -0.07711_wp     !
+   REAL(wp) ::   akcc9 =    0.0041249_wp   !
+
+   REAL(wp) ::   rgas  = 83.143_wp         ! universal gas constants
+   REAL(wp) ::   oxyco = 1._wp / 22.4144_wp
+
+   REAL(wp) ::   bor1 = 0.00023_wp         ! borat constants
+   REAL(wp) ::   bor2 = 1._wp / 10.82_wp
+
+   REAL(wp) ::   ca0 = -162.8301_wp
+   REAL(wp) ::   ca1 =  218.2968_wp
+   REAL(wp) ::   ca2 =   90.9241_wp
+   REAL(wp) ::   ca3 =   -1.47696_wp
+   REAL(wp) ::   ca4 =    0.025695_wp
+   REAL(wp) ::   ca5 =   -0.025225_wp
+   REAL(wp) ::   ca6 =    0.0049867_wp
+
+   REAL(wp) ::   c10 = -3670.7_wp        ! coeff. for 1. dissoc. of carbonic acid (Edmond and Gieskes, 1970)   
+   REAL(wp) ::   c11 =    62.008_wp     
+   REAL(wp) ::   c12 =    -9.7944_wp    
+   REAL(wp) ::   c13 =     0.0118_wp     
+   REAL(wp) ::   c14 =    -0.000116_wp
 
    REAL(wp) :: &              ! coeff. for 2. dissoc. of carbonic acid (Millero, 1995)   
@@ -133,5 +124,5 @@
       ox2 = 23.8439    , &
       ox3 = -0.034892  , &
-      ox4 = 0.015568   , &
+      ox4 =  0.015568  , &
       ox5 = -0.0019387 
 
@@ -151,7 +142,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -179,5 +169,4 @@
 !CDIR NOVERRCHK
          DO ji = 1, jpi
-
             !                             ! SET ABSOLUTE TEMPERATURE
             ztkel = tsn(ji,jj,1,jp_tem) + 273.16
@@ -324,4 +313,15 @@
    END SUBROUTINE p4z_che
 
+
+   INTEGER FUNCTION p4z_che_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_che_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( sio3eq(jpi,jpj,jpk) , fekeq(jpi,jpj,jpk) , chemc (jpi,jpj,2), STAT=p4z_che_alloc )
+      !
+      IF( p4z_che_alloc /= 0 )   CALL ctl_warn('p4z_che_alloc : failed to allocate arrays.')
+      !
+   END FUNCTION p4z_che_alloc
+
 #else
    !!======================================================================
@@ -330,5 +330,5 @@
 CONTAINS
    SUBROUTINE p4z_che( kt )                   ! Empty routine
-      INTEGER, INTENT( in ) ::   kt
+      INTEGER, INTENT(in) ::   kt
       WRITE(*,*) 'p4z_che: You should not have seen this print! error?', kt
    END SUBROUTINE p4z_che
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zflx.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zflx.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zflx.F90	(revision 2715)
@@ -27,6 +27,4 @@
    USE sbc_oce , ONLY :  atm_co2
 #endif
-   USE lib_mpp
-   USE lib_fortran
 
    IMPLICIT NONE
@@ -35,13 +33,15 @@
    PUBLIC   p4z_flx  
    PUBLIC   p4z_flx_init  
-
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  oce_co2            !: ocean carbon flux 
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  satmco2            !: atmospheric pco2
-   REAL(wp)                             ::  t_oce_co2_flx      !: Total ocean carbon flux 
-   REAL(wp)                             ::  t_atm_co2_flx      !: global mean of atmospheric pco2
-   REAL(wp)                             ::  area               !: ocean surface
-   REAL(wp)                             ::  atcco2 = 278.      !: pre-industrial atmospheric [co2] (ppm) 	
-   REAL(wp)                             ::  atcox  = 0.20946   !:
-   REAL(wp)                             ::  xconv  = 0.01/3600 !: coefficients for conversion 
+   PUBLIC   p4z_flx_alloc  
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: oce_co2   !: ocean carbon flux 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: satmco2   !: atmospheric pco2 
+
+   REAL(wp) ::  t_oce_co2_flx               !: Total ocean carbon flux 
+   REAL(wp) ::  t_atm_co2_flx               !: global mean of atmospheric pco2
+   REAL(wp) ::  area                        !: ocean surface
+   REAL(wp) ::  atcco2 = 278._wp            !: pre-industrial atmospheric [co2] (ppm) 	
+   REAL(wp) ::  atcox  = 0.20946_wp         !:
+   REAL(wp) ::  xconv  = 0.01_wp / 3600._wp !: coefficients for conversion 
 
    !!* Substitution
@@ -50,7 +50,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -63,16 +62,21 @@
       !! ** Method  : - ???
       !!---------------------------------------------------------------------
-      INTEGER, INTENT(in) :: kt
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zkgco2 => wrk_2d_1 , zkgo2 => wrk_2d_2 , zh2co3 => wrk_2d_3 
+      USE wrk_nemo, ONLY:   zoflx  => wrk_2d_4 , zkg   => wrk_2d_5
+      USE wrk_nemo, ONLY:   zdpco2 => wrk_2d_6 , zdpo2 => wrk_2d_7
+      !
+      INTEGER, INTENT(in) ::   kt   !
+      !
       INTEGER  ::   ji, jj, jrorr
       REAL(wp) ::   ztc, ztc2, ztc3, zws, zkgwan
       REAL(wp) ::   zfld, zflu, zfld16, zflu16, zfact
       REAL(wp) ::   zph, zah2, zbot, zdic, zalk, zsch_o2, zalka, zsch_co2
-      REAL(wp), DIMENSION(jpi,jpj) ::   zkgco2, zkgo2, zh2co3
-#if defined key_diatrc && defined key_iomput
-      REAL(wp), DIMENSION(jpi,jpj) ::  zoflx, zkg, zdpco2, zdpo2
-#endif
       CHARACTER (len=25) :: charout
-
       !!---------------------------------------------------------------------
+
+      IF( wrk_in_use(2, 1,2,3,4,5,6,7) ) THEN
+         CALL ctl_stop('p4z_flx: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       ! SURFACE CHEMISTRY (PCO2 AND [H+] IN
@@ -149,6 +153,5 @@
             zfld = satmco2(ji,jj) * tmask(ji,jj,1) * chemc(ji,jj,1) * zkgco2(ji,jj)
             zflu = zh2co3(ji,jj) * tmask(ji,jj,1) * zkgco2(ji,jj)
-            oce_co2(ji,jj) = ( zfld - zflu ) * rfact &
-               &             * e1t(ji,jj) * e2t(ji,jj) * tmask(ji,jj,1) * 1000.
+            oce_co2(ji,jj) = ( zfld - zflu ) * rfact * e1e2t(ji,jj) * tmask(ji,jj,1) * 1000.
             ! compute the trend
             tra(ji,jj,1,jpdic) = tra(ji,jj,1,jpdic) + ( zfld - zflu ) / fse3t(ji,jj,1)
@@ -162,5 +165,5 @@
             ! Save diagnostics
 #  if ! defined key_iomput
-            zfact = 1. / ( e1t(ji,jj) * e2t(ji,jj) ) / rfact
+            zfact = 1. / e1e2t(ji,jj) / rfact
             trc2d(ji,jj,jp_pcs0_2d    ) = oce_co2(ji,jj) * zfact
             trc2d(ji,jj,jp_pcs0_2d + 1) = ( zfld16 - zflu16 ) * 1000. * tmask(ji,jj,1)
@@ -180,5 +183,5 @@
       t_oce_co2_flx = t_oce_co2_flx + glob_sum( oce_co2(:,:) )                     ! Cumulative Total Flux of Carbon
       IF( kt == nitend ) THEN
-         t_atm_co2_flx = glob_sum( satmco2(:,:) * e1t(:,:) * e2t(:,:) )            ! Total atmospheric pCO2
+         t_atm_co2_flx = glob_sum( satmco2(:,:) * e1e2t(:,:) )            ! Total atmospheric pCO2
          !
          t_oce_co2_flx = (-1.) * t_oce_co2_flx  * 12. / 1.e15                      ! Conversion in PgC ; negative for out of the ocean
@@ -203,5 +206,5 @@
 
 # if defined key_diatrc && defined key_iomput
-      CALL iom_put( "Cflx" , oce_co2(:,:) / ( e1t(:,:) * e2t(:,:) ) / rfact  )
+      CALL iom_put( "Cflx" , oce_co2(:,:) / e1e2t(:,:) / rfact ) 
       CALL iom_put( "Oflx" , zoflx  )
       CALL iom_put( "Kg"   , zkg    )
@@ -209,9 +212,11 @@
       CALL iom_put( "Dpo2" , zdpo2  )
 #endif
-
+      !
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7) )   CALL ctl_stop('p4z_flx: failed to release workspace arrays')
+      !
    END SUBROUTINE p4z_flx
 
+
    SUBROUTINE p4z_flx_init
-
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE p4z_flx_init  ***
@@ -222,12 +227,11 @@
       !!      called at the first timestep (nit000)
       !! ** input   :   Namelist nampisext
-      !!
-      !!----------------------------------------------------------------------
-
+      !!----------------------------------------------------------------------
       NAMELIST/nampisext/ atcco2
-
+      !!----------------------------------------------------------------------
+      !
       REWIND( numnat )                     ! read numnat
       READ  ( numnat, nampisext )
-
+      !
       IF(lwp) THEN                         ! control print
          WRITE(numout,*) ' '
@@ -236,16 +240,25 @@
          WRITE(numout,*) '    Atmospheric pCO2      atcco2      =', atcco2
       ENDIF
-
-      ! interior global domain surface
-      area = glob_sum( e1t(:,:) * e2t(:,:) )  
-
-      ! Initialization of Flux of Carbon
-      oce_co2(:,:)  = 0._wp
+      !
+      area = glob_sum( e1e2t(:,:) )        ! interior global domain surface
+      !
+      oce_co2(:,:)  = 0._wp                ! Initialization of Flux of Carbon
       t_atm_co2_flx = 0._wp
-      ! Initialisation of atmospheric pco2
-      satmco2(:,:)  = atcco2
+      !
+      satmco2(:,:)  = atcco2      ! Initialisation of atmospheric pco2
       t_oce_co2_flx = 0._wp
-
+      !
    END SUBROUTINE p4z_flx_init
+
+
+   INTEGER FUNCTION p4z_flx_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_flx_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( oce_co2(jpi,jpj), satmco2(jpi,jpj), STAT=p4z_flx_alloc )
+      !
+      IF( p4z_flx_alloc /= 0 )   CALL ctl_warn('p4z_flx_alloc : failed to allocate arrays')
+      !
+   END FUNCTION p4z_flx_alloc
 
 #else
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zint.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zint.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zint.F90	(revision 2715)
@@ -21,20 +21,16 @@
 
    PUBLIC   p4z_int  
+   PUBLIC   p4z_int_alloc
 
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
-      tgfunc,            &  !:  Temp. dependancy of various biological rates
-      tgfunc2               !:  Temp. dependancy of mesozooplankton rates 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   tgfunc    !: Temp. dependancy of various biological rates
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   tgfunc2   !: Temp. dependancy of mesozooplankton rates
 
-   !! * Module variables
-   REAL(wp) :: &
-      xksilim = 16.5E-6        ! Half-saturation constant for the computation of the Si half-saturation constant
-
+   REAL(wp) ::   xksilim = 16.5e-6_wp   ! Half-saturation constant for the Si half-saturation constant computation
 
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -47,5 +43,4 @@
       !! ** Method  : - ???
       !!---------------------------------------------------------------------
-      !!
       INTEGER  ::   ji, jj
       REAL(wp) ::   zdum
@@ -54,5 +49,4 @@
       ! Computation of phyto and zoo metabolic rate
       ! -------------------------------------------
-
       tgfunc (:,:,:) = EXP( 0.063913 * tsn(:,:,:,jp_tem) )
       tgfunc2(:,:,:) = EXP( 0.07608  * tsn(:,:,:,jp_tem) )
@@ -61,5 +55,4 @@
       ! constant for silica uptake
       ! ---------------------------------------------------
-
       DO ji = 1, jpi
          DO jj = 1, jpj
@@ -68,11 +61,22 @@
          END DO
       END DO
-
+      !
       IF( nday_year == nyear_len(1) ) THEN
          xksi    = xksimax
-         xksimax = 0.e0
+         xksimax = 0._wp
       ENDIF
       !
    END SUBROUTINE p4z_int
+
+
+   INTEGER FUNCTION p4z_int_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_int_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( tgfunc(jpi,jpj,jpk), tgfunc2(jpi,jpj,jpk), STAT=p4z_int_alloc )
+      !
+      IF( p4z_int_alloc /= 0 )   CALL ctl_warn('p4z_int_alloc : failed to allocate arrays.')
+      !
+   END FUNCTION p4z_int_alloc
 
 #else
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zlys.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zlys.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zlys.F90	(revision 2715)
@@ -31,14 +31,11 @@
 
    !! * Shared module variables
-   REAL(wp), PUBLIC ::   &
-     kdca = 0.327e3_wp   ,  &  !:
-     nca  = 1.0_wp             !:
+   REAL(wp), PUBLIC :: kdca = 0.327e3_wp  !: diss. rate constant calcite
+   REAL(wp), PUBLIC :: nca  = 1.0_wp      !: order of reaction for calcite dissolution
 
    !! * Module variables
-   REAL(wp) :: &
-      calcon = 1.03E-2        ! mean calcite concentration [Ca2+] in sea water [mole/kg solution]
-
-   INTEGER ::               &
-     rmtss                    !: number of seconds per month
+   REAL(wp) :: calcon = 1.03E-2           !: mean calcite concentration [Ca2+] in sea water [mole/kg solution]
+ 
+   INTEGER  :: rmtss                      !: number of seconds per month 
 
    !!----------------------------------------------------------------------
@@ -60,4 +57,7 @@
       !! ** Method  : - ???
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: zco3 => wrk_3d_2, zcaldiss => wrk_3d_3 
+      !
       INTEGER, INTENT(in) ::   kt ! ocean time step
       INTEGER  ::   ji, jj, jk, jn
@@ -65,14 +65,15 @@
       REAL(wp) ::   zdispot, zfact, zalka
       REAL(wp) ::   zomegaca, zexcess, zexcess0
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zco3
 #if defined key_diatrc && defined key_iomput
       REAL(wp) ::   zrfact2
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zcaldiss
 #endif
       CHARACTER (len=25) :: charout
       !!---------------------------------------------------------------------
 
+      IF(  wrk_in_use(3, 2,3) ) THEN
+         CALL ctl_stop('p4z_lys: requested workspace arrays unavailable')  ;  RETURN
+      END IF
+
       zco3(:,:,:) = 0.
-
 # if defined key_diatrc && defined key_iomput
       zcaldiss(:,:,:) = 0.
@@ -186,4 +187,6 @@
        ENDIF
 
+      IF( wrk_not_released(3, 2,3) ) CALL ctl_stop('p4z_lys: failed to release workspace arrays')
+      !
    END SUBROUTINE p4z_lys
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zopt.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zopt.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zopt.F90	(revision 2715)
@@ -6,5 +6,5 @@
    !! History :   1.0  !  2004     (O. Aumont) Original code
    !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
-   !!             3.2  !  2009-04  (C. Ethe, G. Madec)  optimisaion
+   !!             3.2  !  2009-04  (C. Ethe, G. Madec)  optimisation
    !!----------------------------------------------------------------------
 #if defined  key_pisces
@@ -24,12 +24,13 @@
    PUBLIC   p4z_opt        ! called in p4zbio.F90 module
    PUBLIC   p4z_opt_init   ! called in trcsms_pisces.F90 module
-
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   etot, enano, ediat   !: PAR for phyto, nano and diat 
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   emoy                 !: averaged PAR in the mixed layer
-
-   INTEGER  ::  nksrp   ! levels below which the light cannot penetrate ( depth larger than 391 m)
-   REAL(wp) ::  parlux = 0.43 / 3.e0
-
-   REAL(wp), DIMENSION(3,61), PUBLIC ::   xkrgb  !: tabulated attenuation coefficients for RGB absorption
+   PUBLIC   p4z_opt_alloc
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: etot, enano, ediat   !: PAR for phyto, nano and diat 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: emoy                 !: averaged PAR in the mixed layer
+
+   INTEGER  ::   nksrp   ! levels below which the light cannot penetrate ( depth larger than 391 m)
+   REAL(wp) ::   parlux = 0.43_wp / 3._wp
+
+   REAL(wp), DIMENSION(3,61), PUBLIC ::   xkrgb   !: tabulated attenuation coefficients for RGB absorption
    
    !!* Substitution
@@ -38,7 +39,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -52,20 +52,27 @@
       !! ** Method  : - ???
       !!---------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zdepmoy => wrk_2d_1 , zetmp => wrk_2d_2
+      USE wrk_nemo, ONLY:   zekg    => wrk_3d_2 , zekr  => wrk_3d_3 , zekb => wrk_3d_4
+      USE wrk_nemo, ONLY:   ze0     => wrk_3d_5 , ze1   => wrk_3d_6
+      USE wrk_nemo, ONLY:   ze2     => wrk_3d_7 , ze3   => wrk_3d_8
+      !
+      INTEGER, INTENT(in) ::   kt, jnt   ! ocean time step
+      !
       INTEGER  ::   ji, jj, jk
       INTEGER  ::   irgb
       REAL(wp) ::   zchl, zxsi0r
       REAL(wp) ::   zc0 , zc1 , zc2, zc3
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zdepmoy, zetmp
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zekg, zekr, zekb
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ze1 , ze2 , ze3, ze0
       !!---------------------------------------------------------------------
 
+      IF(  wrk_in_use(2, 1,2)   .OR.   wrk_in_use(3, 2,3,4,5,6,7,8)   ) THEN
+         CALL ctl_stop('p4z_opt: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       !     Initialisation of variables used to compute PAR
       !     -----------------------------------------------
-      ze1 (:,:,jpk) = 0.e0
-      ze2 (:,:,jpk) = 0.e0
-      ze3 (:,:,jpk) = 0.e0
+      ze1 (:,:,jpk) = 0._wp
+      ze2 (:,:,jpk) = 0._wp
+      ze3 (:,:,jpk) = 0._wp
 
       !                                        !* attenuation coef. function of Chlorophyll and wavelength (Red-Green-Blue)
@@ -203,6 +210,5 @@
 !CDIR NOVERRCHK
             DO ji = 1, jpi
-               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) &
-       &           emoy(ji,jj,jk) = zetmp(ji,jj) / ( zdepmoy(ji,jj) + rtrn )
+               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) )   emoy(ji,jj,jk) = zetmp(ji,jj) / ( zdepmoy(ji,jj) + rtrn )
             END DO
          END DO
@@ -223,5 +229,9 @@
 #endif
       !
+      IF(  wrk_not_released(2, 1,2)           .OR.   &
+           wrk_not_released(3, 2,3,4,5,6,7,8)   )   CALL ctl_stop('p4z_opt: failed to release workspace arrays')
+      !
    END SUBROUTINE p4z_opt
+
 
    SUBROUTINE p4z_opt_init
@@ -230,19 +240,30 @@
       !!
       !! ** Purpose :   Initialization of tabulated attenuation coef
-      !!
-      !!
-      !!----------------------------------------------------------------------
-
+      !!----------------------------------------------------------------------
+      !
       CALL trc_oce_rgb( xkrgb )                  ! tabulated attenuation coefficients
-!!      CALL trc_oce_rgb_read( xkrgb )               ! tabulated attenuation coefficients
       nksrp = trc_oce_ext_lev( r_si2, 0.33e2 )     ! max level of light extinction (Blue Chl=0.01)
+      !
       IF(lwp) WRITE(numout,*) '        level of light extinction = ', nksrp, ' ref depth = ', gdepw_0(nksrp+1), ' m'
       !
-                         etot (:,:,:) = 0.e0
-                         enano(:,:,:) = 0.e0
-                         ediat(:,:,:) = 0.e0
-      IF( ln_qsr_bio )   etot3(:,:,:) = 0.e0
+                         etot (:,:,:) = 0._wp
+                         enano(:,:,:) = 0._wp
+                         ediat(:,:,:) = 0._wp
+      IF( ln_qsr_bio )   etot3(:,:,:) = 0._wp
       ! 
    END SUBROUTINE p4z_opt_init
+
+
+   INTEGER FUNCTION p4z_opt_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_opt_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( etot (jpi,jpj,jpk) , enano(jpi,jpj,jpk) ,     &
+         &      ediat(jpi,jpj,jpk) , emoy (jpi,jpj,jpk) , STAT=p4z_opt_alloc )
+         !
+      IF( p4z_opt_alloc /= 0 ) CALL ctl_warn('p4z_opt_alloc : failed to allocate arrays.')
+      !
+   END FUNCTION p4z_opt_alloc
+
 #else
    !!----------------------------------------------------------------------
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zprod.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zprod.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zprod.F90	(revision 2715)
@@ -22,7 +22,4 @@
    USE iom
 
-   USE lib_mpp
-   USE lib_fortran
-
    IMPLICIT NONE
    PRIVATE
@@ -30,6 +27,6 @@
    PUBLIC   p4z_prod         ! called in p4zbio.F90
    PUBLIC   p4z_prod_init    ! called in trcsms_pisces.F90
-
-   !! * Shared module variables
+   PUBLIC   p4z_prod_alloc
+
    REAL(wp), PUBLIC ::   &
      pislope   = 3.0_wp          ,  &  !:
@@ -43,5 +40,5 @@
      grosip    = 0.151_wp
 
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk)  ::  prmax 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   prmax   !:
    
    REAL(wp) ::   &
@@ -56,7 +53,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -70,5 +66,15 @@
       !! ** Method  : - ???
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zmixnano   => wrk_2d_1  , zmixdiat    => wrk_2d_2  , zstrn  => wrk_2d_3
+      USE wrk_nemo, ONLY:   zpislopead => wrk_3d_2  , zpislopead2 => wrk_3d_3
+      USE wrk_nemo, ONLY:   zprdia     => wrk_3d_4  , zprbio      => wrk_3d_5  , zysopt => wrk_3d_6
+      USE wrk_nemo, ONLY:   zprorca    => wrk_3d_7  , zprorcad    => wrk_3d_8
+      USE wrk_nemo, ONLY:   zprofed    => wrk_3d_9  , zprofen     => wrk_3d_10
+      USE wrk_nemo, ONLY:   zprochln   => wrk_3d_11 , zprochld    => wrk_3d_12
+      USE wrk_nemo, ONLY:   zpronew    => wrk_3d_13 , zpronewd    => wrk_3d_14
+      !
       INTEGER, INTENT(in) :: kt, jnt
+      !
       INTEGER  ::   ji, jj, jk
       REAL(wp) ::   zsilfac, zfact
@@ -81,27 +87,25 @@
       REAL(wp) ::   zrfact2
 #endif
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zmixnano   , zmixdiat, zstrn
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zpislopead , zpislopead2
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zprdia     , zprbio, zysopt
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zprorca    , zprorcad, zprofed
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zprofen   , zprochln, zprochld
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zpronew    , zpronewd
       CHARACTER (len=25) :: charout
       !!---------------------------------------------------------------------
 
-      zprorca (:,:,:) = 0.0
-      zprorcad(:,:,:) = 0.0
-      zprofed(:,:,:) = 0.0
-      zprofen(:,:,:) = 0.0
-      zprochln(:,:,:) = 0.0
-      zprochld(:,:,:) = 0.0
-      zpronew (:,:,:) = 0.0
-      zpronewd(:,:,:) = 0.0
-      zprdia  (:,:,:) = 0.0
-      zprbio  (:,:,:) = 0.0
-      zysopt  (:,:,:) = 0.0
+      IF( wrk_in_use(2, 1,2,3)                             .OR.  &
+          wrk_in_use(3, 2,3,4,5,6,7,8,9,10,11,12,13,14)  ) THEN
+          CALL ctl_stop('p4z_prod: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
+
+      zprorca (:,:,:) = 0._wp
+      zprorcad(:,:,:) = 0._wp
+      zprofed (:,:,:) = 0._wp
+      zprofen (:,:,:) = 0._wp
+      zprochln(:,:,:) = 0._wp
+      zprochld(:,:,:) = 0._wp
+      zpronew (:,:,:) = 0._wp
+      zpronewd(:,:,:) = 0._wp
+      zprdia  (:,:,:) = 0._wp
+      zprbio  (:,:,:) = 0._wp
+      zysopt  (:,:,:) = 0._wp
 
       ! Computation of the optimal production
-
 # if defined key_degrad
       prmax(:,:,:) = rday1 * tgfunc(:,:,:) * facvol(:,:,:)
@@ -111,9 +115,9 @@
 
       ! compute the day length depending on latitude and the day
-      zrum = FLOAT( nday_year - 80 ) / REAL(nyear_len(1), wp)
-      zcodel = ASIN(  SIN( zrum * rpi * 2. ) * SIN( rad * 23.5 )  )
+      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.
+      zstrn(:,:) = 0._wp
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -187,5 +191,4 @@
                   zsilfac = MIN( 6.4,zsilfac * zsilfac2)
                   zysopt(ji,jj,jk) = grosip * zlim1 * zsilfac
-
               ENDIF
             END DO
@@ -357,14 +360,18 @@
 #endif
 
-       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+      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
-
+      ENDIF
+
+      IF(  wrk_not_released(2, 1,2,3)                          .OR.  &
+           wrk_not_released(3, 2,3,4,5,6,7,8,9,10,11,12,13,14)   )   &
+           CALL ctl_stop('p4z_prod: failed to release workspace arrays')
+      !
    END SUBROUTINE p4z_prod
 
+
    SUBROUTINE p4z_prod_init
-
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE p4z_prod_init  ***
@@ -376,9 +383,8 @@
       !!
       !! ** input   :   Namelist nampisprod
-      !!
       !!----------------------------------------------------------------------
-
       NAMELIST/nampisprod/ pislope, pislope2, excret, excret2, chlcnm, chlcdm,   &
          &              fecnm, fecdm, grosip
+      !!----------------------------------------------------------------------
 
       REWIND( numnat )                     ! read numnat
@@ -399,13 +405,22 @@
          WRITE(numout,*) '    Minimum Fe/C in diatoms                   fecdm     =', fecdm
       ENDIF
-
+      !
       rday1     = 0.6 / rday 
       texcret   = 1.0 - excret
       texcret2  = 1.0 - excret2
       tpp       = 0.
-
+      !
    END SUBROUTINE p4z_prod_init
 
 
+   INTEGER FUNCTION p4z_prod_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_prod_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( prmax(jpi,jpj,jpk), STAT=p4z_prod_alloc )
+      !
+      IF( p4z_prod_alloc /= 0 ) CALL ctl_warn('p4z_prod_alloc : failed to allocate arrays.')
+      !
+   END FUNCTION p4z_prod_alloc
 
 #else
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zrem.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zrem.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zrem.F90	(revision 2715)
@@ -29,6 +29,6 @@
    PUBLIC   p4z_rem         ! called in p4zbio.F90
    PUBLIC   p4z_rem_init    ! called in trcsms_pisces.F90
-
-   !! * Shared module variables
+   PUBLIC   p4z_rem_alloc
+
    REAL(wp), PUBLIC ::   &
      xremik  = 0.3_wp      ,  & !:
@@ -39,6 +39,5 @@
      oxymin  = 1.e-6_wp         !:
 
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::    & !:
-     &                   denitr                     !: denitrification array
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   denitr   !: denitrification array
 
 
@@ -48,7 +47,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -61,5 +59,10 @@
       !! ** Method  : - ???
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   ztempbac => wrk_2d_1
+      USE wrk_nemo, ONLY:   zdepbac  => wrk_3d_2 , zfesatur => wrk_3d_2 , zolimi => wrk_3d_4
+      !
       INTEGER, INTENT(in) ::   kt ! ocean time step
+      !
       INTEGER  ::   ji, jj, jk
       REAL(wp) ::   zremip, zremik , zlam1b
@@ -72,21 +75,20 @@
 #endif
       REAL(wp) ::   zlamfac, zonitr, zstep
-      REAL(wp), DIMENSION(jpi,jpj)     ::   ztempbac
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdepbac, zfesatur, zolimi
       CHARACTER (len=25) :: charout
-
       !!---------------------------------------------------------------------
 
+      IF(  wrk_in_use(2, 1)  .OR.  wrk_in_use(3, 2,3,4)  ) THEN
+         CALL ctl_stop('p4z_rem: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
        ! Initialisation of temprary arrys
-       zdepbac (:,:,:) = 0.0
-       zfesatur(:,:,:) = 0.0
-       zolimi  (:,:,:) = 0.0
-       ztempbac(:,:)   = 0.0
+       zdepbac (:,:,:) = 0._wp
+       zfesatur(:,:,:) = 0._wp
+       zolimi  (:,:,:) = 0._wp
+       ztempbac(:,:)   = 0._wp
 
       !  Computation of the mean phytoplankton concentration as
       !  a crude estimate of the bacterial biomass
       !   --------------------------------------------------
-
       DO jk = 1, jpkm1
          DO jj = 1, jpj
@@ -362,18 +364,17 @@
                tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + zscave * zdenom2
 #endif
-
-            END DO
-         END DO
-      END DO
-      !
-
-       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+            END DO
+         END DO
+      END DO
+      !
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
          WRITE(charout, FMT="('rem5')")
          CALL prt_ctl_trc_info(charout)
          CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
-       ENDIF
-
-       !     Update the arrays TRA which contain the biological sources and sinks
-       !     --------------------------------------------------------------------
+      ENDIF
+
+      !     Update the arrays TRA which contain the biological sources and sinks
+      !     --------------------------------------------------------------------
 
       DO jk = 1, jpkm1
@@ -385,16 +386,19 @@
          tra(:,:,jk,jpdic) = tra(:,:,jk,jpdic) + zolimi(:,:,jk) + denitr(:,:,jk)
          tra(:,:,jk,jptal) = tra(:,:,jk,jptal) + denitr(:,:,jk) * rno3 * rdenit
-     END DO
-
-       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+      END DO
+
+      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
-
+      ENDIF
+      !
+      IF(  wrk_not_released(2, 1)     .OR.   &
+           wrk_not_released(3, 2,3,4)  )   CALL ctl_stop('p4z_rem: failed to release workspace arrays')
+      !
    END SUBROUTINE p4z_rem
 
+
    SUBROUTINE p4z_rem_init
-
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE p4z_rem_init  ***
@@ -408,6 +412,6 @@
       !!
       !!----------------------------------------------------------------------
-
       NAMELIST/nampisrem/ xremik, xremip, nitrif, xsirem, xlam1, oxymin
+      !!----------------------------------------------------------------------
 
       REWIND( numnat )                     ! read numnat
@@ -425,9 +429,20 @@
          WRITE(numout,*) '    halk saturation constant for anoxia       oxymin    =', oxymin
       ENDIF
-
-      nitrfac(:,:,:) = 0.0
-      denitr (:,:,:) = 0.0  
-
+      !
+      nitrfac(:,:,:) = 0._wp
+      denitr (:,:,:) = 0._wp
+      !
    END SUBROUTINE p4z_rem_init
+
+
+   INTEGER FUNCTION p4z_rem_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_rem_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( denitr(jpi,jpj,jpk), STAT=p4z_rem_alloc )
+      !
+      IF( p4z_rem_alloc /= 0 )   CALL ctl_warn('p4z_rem_alloc: failed to allocate arrays')
+      !
+   END FUNCTION p4z_rem_alloc
 
 #else
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsed.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsed.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsed.F90	(revision 2715)
@@ -18,6 +18,4 @@
    USE oce_trc         !
    USE sms_pisces
-   USE lib_mpp
-   USE lib_fortran
    USE prtctl_trc
    USE p4zbio
@@ -27,5 +25,4 @@
    USE p4zrem
    USE p4zlim
-   USE lbclnk
    USE iom
 
@@ -36,32 +33,34 @@
    PUBLIC   p4z_sed   
    PUBLIC   p4z_sed_init   
+   PUBLIC   p4z_sed_alloc
 
    !! * Shared module variables
-   LOGICAL, PUBLIC ::    &
-     ln_dustfer  = .FALSE.      ,  &  !:
-     ln_river    = .FALSE.      ,  &  !:
-     ln_ndepo    = .FALSE.      ,  &  !:
-     ln_sedinput = .FALSE.            !:
-
-   REAL(wp), PUBLIC ::   &
-     sedfeinput = 1.E-9_wp   ,  &  !:
-     dustsolub  = 0.014_wp         !:
+   LOGICAL, PUBLIC :: ln_dustfer  = .FALSE.    !: boolean for dust input from the atmosphere
+   LOGICAL, PUBLIC :: ln_river    = .FALSE.    !: boolean for river input of nutrients
+   LOGICAL, PUBLIC :: ln_ndepo    = .FALSE.    !: boolean for atmospheric deposition of N
+   LOGICAL, PUBLIC :: ln_sedinput = .FALSE.    !: boolean for Fe input from sediments
+
+   REAL(wp), PUBLIC :: sedfeinput = 1.E-9_wp   !: Coastal release of Iron
+   REAL(wp), PUBLIC :: dustsolub  = 0.014_wp   !: Solubility of the dust
 
    !! * Module variables
-   REAL(wp) :: ryyss               !: number of seconds per year 
-   REAL(wp) :: ryyss1              !: inverse of ryyss
-   REAL(wp) :: rmtss               !: number of seconds per month
-   REAL(wp) :: rday1               !: inverse of rday
-
-   INTEGER , PARAMETER :: &
-        jpmth = 12, jpyr = 1
-   INTEGER ::                   &
-      numdust,                  &  !: logical unit for surface fluxes data
-      nflx1 , nflx2,            &  !: first and second record used
-      nflx11, nflx12      ! ???
-   REAL(wp), DIMENSION(jpi,jpj,jpmth) ::  dustmo    !: set of dust fields
-   REAL(wp), DIMENSION(jpi,jpj)      ::  rivinp, cotdep, nitdep, dust 
-   REAL(wp), DIMENSION(jpi,jpj)      ::  e1e2t
-   REAL(wp), DIMENSION(jpi,jpj,jpk)  ::  ironsed 
+   REAL(wp) :: ryyss                  !: number of seconds per year 
+   REAL(wp) :: ryyss1                 !: inverse of ryyss
+   REAL(wp) :: rmtss                  !: number of seconds per month
+   REAL(wp) :: rday1                  !: inverse of rday
+
+   INTEGER , PARAMETER :: jpmth = 12  !: number of months per year
+   INTEGER , PARAMETER :: jpyr  = 1   !: one year
+
+   INTEGER ::  numdust                !: logical unit for surface fluxes data
+   INTEGER ::  nflx1 , nflx2          !: first and second record used
+   INTEGER ::  nflx11, nflx12
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: dustmo    !: set of dust fields
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:) :: dust      !: dust fields
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:) :: rivinp, cotdep    !: river input fields
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:) :: nitdep    !: atmospheric N deposition 
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ironsed   !: Coastal supply of iron
+
    REAL(wp) :: sumdepsi, rivalkinput, rivpo4input, nitdepinput
 
@@ -76,4 +75,5 @@
 CONTAINS
 
+
    SUBROUTINE p4z_sed( kt, jnt )
       !!---------------------------------------------------------------------
@@ -86,4 +86,8 @@
       !! ** Method  : - ???
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: zsidep => wrk_2d_1, zwork => wrk_2d_2, zwork1 => wrk_2d_3
+      USE wrk_nemo, ONLY: znitrpot => wrk_3d_2, zirondep => wrk_3d_3
+      !
       INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
       INTEGER  ::   ji, jj, jk, ikt
@@ -94,9 +98,10 @@
       REAL(wp) ::   zdenitot, znitrpottot, zlim, zfact
       REAL(wp) ::   zwsbio3, zwsbio4, zwscal
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zsidep
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zwork, zwork1
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znitrpot, zirondep
       CHARACTER (len=25) :: charout
       !!---------------------------------------------------------------------
+
+      IF( ( wrk_in_use(2, 1,2,3) ) .OR. ( wrk_in_use(3, 2,3) ) ) THEN
+         CALL ctl_stop('p4z_sed: requested workspace arrays unavailable')  ;  RETURN
+      END IF
 
       IF( jnt == 1  .AND.  ln_dustfer  )  CALL p4z_sbc( kt )
@@ -288,4 +293,7 @@
        ENDIF
 
+      IF( ( wrk_not_released(2, 1,2,3) ) .OR. ( wrk_not_released(3, 2,3) ) )   &
+        &         CALL ctl_stop('p4z_sed: failed to release workspace arrays')
+
    END SUBROUTINE p4z_sed
 
@@ -474,5 +482,4 @@
       ryyss1 = 1. / ryyss
       !                                    ! ocean surface cell
-      e1e2t(:,:) = e1t(:,:) * e2t(:,:)
 
       ! total atmospheric supply of Si
@@ -512,4 +519,16 @@
    END SUBROUTINE p4z_sed_init
 
+   INTEGER FUNCTION p4z_sed_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_sed_alloc  ***
+      !!----------------------------------------------------------------------
+
+      ALLOCATE( dustmo(jpi,jpj,jpmth), dust(jpi,jpj)       ,     &
+        &       rivinp(jpi,jpj)      , cotdep(jpi,jpj)     ,     &
+        &       nitdep(jpi,jpj)      , ironsed(jpi,jpj,jpk), STAT=p4z_sed_alloc )  
+
+      IF( p4z_sed_alloc /= 0 ) CALL ctl_warn('p4z_sed_alloc : failed to allocate arrays.')
+
+   END FUNCTION p4z_sed_alloc
 #else
    !!======================================================================
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsink.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsink.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsink.F90	(revision 2715)
@@ -21,48 +21,39 @@
    PUBLIC   p4z_sink         ! called in p4zbio.F90
    PUBLIC   p4z_sink_init    ! called in trcsms_pisces.F90
-
-   !! * Shared module variables
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
-     wsbio3, wsbio4,      &    !: POC and GOC sinking speeds
-     wscal                     !: Calcite and BSi sinking speeds
-
-   !! * Module variables
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
-     sinking, sinking2,   &    !: POC sinking fluxes (different meanings depending on the parameterization
-     sinkcal, sinksil,    &    !: CaCO3 and BSi sinking fluxes
-     sinkfer                   !: Small BFe sinking flux
-
-   INTEGER  :: &
-      iksed  = 10              !
+   PUBLIC   p4z_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 
+   !                                                          !  (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    = 250.  ,  &   !: Sinking factor
-      xkr_stick    = 0.2   ,  &   !: Stickiness
-      xkr_nnano    = 2.337 ,  &   !: Nbr of cell in nano size class
-      xkr_ndiat    = 3.718 ,  &   !: Nbr of cell in diatoms size class
-      xkr_nmeso    = 7.147 ,  &   !: Nbr of cell in mesozoo  size class
-      xkr_naggr    = 9.877        !: Nbr of cell in aggregates  size class
-
-   REAL(wp)          ::       &   
-      xkr_frac
-
-   REAL(wp), PUBLIC ::        &
-      xkr_dnano            ,  &   !: Size of particles in nano pool
-      xkr_ddiat            ,  &   !: Size of particles in diatoms pool
-      xkr_dmeso            ,  &   !: Size of particles in mesozoo pool
-      xkr_daggr            ,  &   !: Size of particles in aggregates pool
-      xkr_wsbio_min        ,  &   !: min vertical particle speed
-      xkr_wsbio_max               !: max vertical particle speed
-
-   REAL(wp), PUBLIC, DIMENSION(jpk) ::   &   !:
-      xnumm                       !:     maximum number of particles in aggregates
-
-#endif
-
-#if ! defined key_kriest
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &   !:
-     sinkfer2                  !: Big Fe sinking flux
-#endif 
+   REAL(wp) ::  xkr_sfact    = 250.     !: Sinking factor
+   REAL(wp) ::  xkr_stick    = 0.2      !: Stickiness
+   REAL(wp) ::  xkr_nnano    = 2.337    !: Nbr of cell in nano size class
+   REAL(wp) ::  xkr_ndiat    = 3.718    !: Nbr of cell in diatoms size class
+   REAL(wp) ::  xkr_nmeso    = 7.147    !: Nbr of cell in mesozoo  size class
+   REAL(wp) ::  xkr_naggr    = 9.877    !: 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_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
@@ -71,10 +62,12 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
 #if defined key_kriest
+   !!----------------------------------------------------------------------
+   !!   'key_kriest'                                                    ???
+   !!----------------------------------------------------------------------
 
    SUBROUTINE p4z_sink ( kt, jnt )
@@ -87,6 +80,9 @@
       !! ** Method  : - ???
       !!---------------------------------------------------------------------
-
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   znum3d => wrk_3d_2
+      !
       INTEGER, INTENT(in) :: kt, jnt
+      !
       INTEGER  :: ji, jj, jk
       REAL(wp) :: zagg1, zagg2, zagg3, zagg4, zagg5, zaggsi, zaggsh
@@ -99,19 +95,21 @@
       INTEGER  :: ik1
 #endif
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znum3d
       CHARACTER (len=25) :: charout
-
-      !!---------------------------------------------------------------------
-
+      !!---------------------------------------------------------------------
+      !
+      IF( wrk_in_use(3, 2 ) ) THEN
+         CALL ctl_stop('p4z_sink: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
+      
       !     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
-     !     -----------------------------------------------------------------
+      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
@@ -131,7 +129,7 @@
                   zdiv1 = zeps - zval3
                   wsbio3(ji,jj,jk) = xkr_wsbio_min * ( zeps - zval1 ) / zdiv    &
-     &                             - xkr_wsbio_max *   zgm * xkr_eta  / 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
+                     &             - xkr_wsbio_max *   zfm * xkr_eta  / zdiv1
                   IF( znum == 1.1)   wsbio3(ji,jj,jk) = wsbio4(ji,jj,jk)
                ENDIF
@@ -140,5 +138,5 @@
       END DO
 
-      wscal(:,:,:) = MAX( wsbio3(:,:,:), 50. )
+      wscal(:,:,:) = MAX( wsbio3(:,:,:), 50._wp )
 
       !   INITIALIZE TO ZERO ALL THE SINKING ARRAYS
@@ -305,11 +303,14 @@
 #endif
       !
-       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+      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
-
+      ENDIF
+      !
+      IF( wrk_not_released(3, 2 ) )   CALL ctl_stop('p4z_sink: failed to release workspace arrays')
+      !
    END SUBROUTINE p4z_sink
+
 
    SUBROUTINE p4z_sink_init
@@ -324,5 +325,4 @@
       !!
       !! ** input   :   Namelist nampiskrs
-      !!
       !!----------------------------------------------------------------------
       INTEGER  ::   jk, jn, kiter
@@ -330,9 +330,9 @@
       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_nmeso, xkr_naggr
-
       !!----------------------------------------------------------------------
+      !
       REWIND( numnat )                     ! read nampiskrs
       READ  ( numnat, nampiskrs )
@@ -347,25 +347,25 @@
          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
-     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_dmeso = 1. / ( xkr_massp * xkr_nmeso )
-     xkr_daggr = 1. / ( xkr_massp * 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
+      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_dmeso = 1. / ( xkr_massp * xkr_nmeso )
+      xkr_daggr = 1. / ( xkr_massp * xkr_naggr )
 
       !!---------------------------------------------------------------------
@@ -379,7 +379,7 @@
       WRITE(numout,*)'    kriest : Compute maximum number of particles in aggregates'
 
-      xacc     =  0.001
+      xacc     =  0.001_wp
       kiter    = 50
-      zmin     =  1.10
+      zmin     =  1.10_wp
       zmax     = xkr_mass_max / xkr_mass_min
       xkr_frac = zmax
@@ -402,47 +402,43 @@
             &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
             & - wmax
-iflag:  DO jn = 1, kiter
-           IF( zwl == 0.e0 ) THEN
-              znummax = zl
-           ELSE IF ( zwr == 0.e0 ) 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
-        WRITE(numout,*) '       jk = ', jk, ' wmax = ', wmax,' xnum max = ', xnumm(jk)
-
-     END DO
-
+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
+         WRITE(numout,*) '       jk = ', jk, ' wmax = ', wmax,' xnum max = ', xnumm(jk)
+         !
+      END DO
+      !
   END SUBROUTINE p4z_sink_init
 
@@ -476,5 +472,5 @@
          DO jj = 1, jpj
             DO ji=1,jpi
-               zfact = MAX( 0., fsdepw(ji,jj,jk+1) - hmld(ji,jj) ) / 4000.
+               zfact = MAX( 0., fsdepw(ji,jj,jk+1) - hmld(ji,jj) ) / 4000._wp
                wsbio4(ji,jj,jk) = wsbio2 + ( 200.- wsbio2 ) * zfact
             END DO
@@ -584,11 +580,12 @@
 #endif
       !
-       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+      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
-
+      ENDIF
+      !
    END SUBROUTINE p4z_sink
+
 
    SUBROUTINE p4z_sink_init
@@ -611,4 +608,7 @@
       !!      transport term, i.e.  div(u*tra).
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: ztraz => wrk_3d_2, zakz => wrk_3d_3, zwsink2 => wrk_3d_4
+      !
       INTEGER , INTENT(in   )                         ::   jp_tra    ! tracer index index      
       REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpk) ::   pwsink    ! sinking speed
@@ -617,8 +617,10 @@
       INTEGER  ::   ji, jj, jk, jn
       REAL(wp) ::   zigma,zew,zign, zflx, zstep
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  ztraz, zakz
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zwsink2
-      !!---------------------------------------------------------------------
-
+      !!---------------------------------------------------------------------
+
+      IF(  wrk_in_use(3, 2,3,4 ) ) THEN
+         CALL ctl_stop('p4z_sink2: requested workspace arrays unavailable')
+         RETURN
+      END IF
 
       zstep = rfact2 / 2.
@@ -701,10 +703,30 @@
       END DO
 
-      trn(:,:,:,jp_tra) = trb(:,:,:,jp_tra)
-      psinkflx(:,:,:)   = 2. * psinkflx(:,:,:)
-
+      trn     (:,:,:,jp_tra) = trb(:,:,:,jp_tra)
+      psinkflx(:,:,:)        = 2. * psinkflx(:,:,:)
+      !
+      IF( wrk_not_released(3, 2,3,4) )   CALL ctl_stop('p4z_sink2: failed to release workspace arrays')
       !
    END SUBROUTINE p4z_sink2
 
+
+   INTEGER FUNCTION p4z_sink_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_sink_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( wsbio3 (jpi,jpj,jpk) , wsbio4  (jpi,jpj,jpk) , wscal(jpi,jpj,jpk) ,     &
+         &      sinking(jpi,jpj,jpk) , sinking2(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=p4z_sink_alloc )                
+         !
+      IF( p4z_sink_alloc /= 0 ) CALL ctl_warn('p4z_sink_alloc : failed to allocate arrays.')
+      !
+   END FUNCTION p4z_sink_alloc
+   
 #else
    !!======================================================================
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/sms_pisces.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/sms_pisces.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/sms_pisces.F90	(revision 2715)
@@ -7,5 +7,4 @@
    !!             3.2  !  2009-04 (C. Ethe & NEMO team) style
    !!----------------------------------------------------------------------
-
 #if defined key_pisces
    !!----------------------------------------------------------------------
@@ -38,42 +37,44 @@
    !!* Damping 
    LOGICAL  ::   ln_pisdmp         !: relaxation or not of nutrients to a mean value
-                                   !: when initialize from a restart file 
    LOGICAL  ::   ln_pisclo         !: Restoring or not of nutrients to initial value
                                    !: on close seas
 
    !!*  Biological fluxes for light
-   INTEGER , DIMENSION(jpi,jpj)     ::   neln       !: number of T-levels + 1 in the euphotic layer
-   REAL(wp), DIMENSION(jpi,jpj)     ::   heup       !: euphotic layer depth
+   INTEGER , ALLOCATABLE, SAVE,   DIMENSION(:,:)  ::  neln       !: number of T-levels + 1 in the euphotic layer
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:)  ::  heup       !: euphotic layer depth
 
    !!*  Biological fluxes for primary production
-   REAL(wp), DIMENSION(jpi,jpj)     ::   xksi       !: ???
-   REAL(wp), DIMENSION(jpi,jpj)     ::   xksimax    !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xnanono3   !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xdiatno3   !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xnanonh4   !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xdiatnh4   !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xlimphy    !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xlimdia    !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   concdfe    !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   concnfe    !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:)  ::   xksi       !: ???
+   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:)  ::   xksimax    !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xnanono3   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xdiatno3   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xnanonh4   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xdiatnh4   !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimphy    !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   xlimdia    !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   concdfe    !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  ::   concnfe    !: ???
 
    !!*  SMS for the organic matter
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xfracal    !: ??
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   nitrfac    !: ??
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xlimbac    !: ??
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xdiss      !: ??
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xfracal    !: ??
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   nitrfac    !: ??
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xlimbac    !: ??
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xdiss      !: ??
 #if defined key_diatrc
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   prodcal    !: Calcite production
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   grazing    !: Total zooplankton grazing
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   prodcal    !: Calcite production
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   grazing    !: Total zooplankton grazing
 #endif
 
    !!* Variable for chemistry of the CO2 cycle
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   akb3       !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ak13       !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ak23       !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   aksp       !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   akw3       !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   borat      !: ???
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   hi         !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   akb3       !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ak13       !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ak23       !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   aksp       !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   akw3       !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   borat      !: ???
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   hi         !: ???
+
+   !!* Array used to indicate negative tracer values
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xnegtr     !: ???
 
 #if defined key_kriest
@@ -85,4 +86,51 @@
 #endif
 
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   INTEGER FUNCTION sms_pisces_alloc()
+      !!----------------------------------------------------------------------
+      !!        *** ROUTINE sms_pisces_alloc ***
+      !!----------------------------------------------------------------------
+      USE lib_mpp , ONLY: ctl_warn
+      INTEGER ::   ierr(5)        ! Local variables
+      !!----------------------------------------------------------------------
+      ierr(:) = 0
+      !
+      !*  Biological fluxes for light
+      ALLOCATE( neln(jpi,jpj), heup(jpi,jpj),                           STAT=ierr(1) )
+      !
+      !*  Biological fluxes for primary production
+      ALLOCATE( xksimax(jpi,jpj)     , xksi(jpi,jpj)        ,               &
+         &      xnanono3(jpi,jpj,jpk), xdiatno3(jpi,jpj,jpk),               &
+         &      xnanonh4(jpi,jpj,jpk), xdiatnh4(jpi,jpj,jpk),               &
+         &      xlimphy (jpi,jpj,jpk), xlimdia (jpi,jpj,jpk),               &
+         &      concdfe (jpi,jpj,jpk), concnfe (jpi,jpj,jpk),           STAT=ierr(2) ) 
+         !
+      !*  SMS for the organic matter
+      ALLOCATE( xfracal (jpi,jpj,jpk), nitrfac (jpi,jpj,jpk),               &
+#if defined key_diatrc
+         &      prodcal(jpi,jpj,jpk) , grazing(jpi,jpj,jpk) ,               &
+#endif 
+         &      xlimbac (jpi,jpj,jpk), xdiss(jpi,jpj,jpk)   ,           STAT=ierr(3) )  
+         !
+      !* Variable for chemistry of the CO2 cycle
+      ALLOCATE( akb3(jpi,jpj,jpk), ak13(jpi,jpj,jpk) ,                      &
+         &      ak23(jpi,jpj,jpk), aksp(jpi,jpj,jpk) ,                      &
+         &      akw3(jpi,jpj,jpk), borat(jpi,jpj,jpk), hi(jpi,jpj,jpk), STAT=ierr(4) )
+         !
+      !* Array used to indicate negative tracer values  
+      ALLOCATE( xnegtr(jpi,jpj,jpk),                                    STAT=ierr(5) )
+      !
+      sms_pisces_alloc = MAXVAL( ierr )
+      !
+      IF( sms_pisces_alloc /= 0 )   CALL ctl_warn('sms_pisces_alloc: failed to allocate arrays') 
+      !
+   END FUNCTION sms_pisces_alloc
+
 #else
    !!----------------------------------------------------------------------   
@@ -91,8 +139,4 @@
 #endif
    
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!======================================================================   
 END MODULE sms_pisces    
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 2715)
@@ -21,5 +21,11 @@
    USE oce_trc         ! ocean variables
    USE p4zche 
-   USE lib_mpp
+   USE p4zche          ! 
+   USE p4zsink         ! 
+   USE p4zopt          ! 
+   USE p4zprod         !
+   USE p4zrem          ! 
+   USE p4zsed          ! 
+   USE p4zflx          ! 
 
    IMPLICIT NONE
@@ -28,13 +34,11 @@
    PUBLIC   trc_ini_pisces   ! called by trcini.F90 module
 
-   !! * Module variables
-   REAL(wp) :: &
-      sco2   =  2.312e-3         , &
-      alka0  =  2.423e-3         , &
-      oxyg0  =  177.6e-6         , &
-      po4    =  2.174e-6         , &
-      bioma0 =  1.000e-8         , &
-      silic1 =  91.65e-6         , &
-      no3    =  31.04e-6 * 7.6
+   REAL(wp) :: sco2   =  2.312e-3_wp
+   REAL(wp) :: alka0  =  2.423e-3_wp
+   REAL(wp) :: oxyg0  =  177.6e-6_wp 
+   REAL(wp) :: po4    =  2.174e-6_wp 
+   REAL(wp) :: bioma0 =  1.000e-8_wp  
+   REAL(wp) :: silic1 =  91.65e-6_wp  
+   REAL(wp) :: no3    =  31.04e-6_wp * 7.6_wp
 
 #  include "top_substitute.h90"
@@ -42,7 +46,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -53,13 +56,10 @@
       !! ** Purpose :   Initialisation of the PISCES biochemical model
       !!----------------------------------------------------------------------
-
-
-      !  Control consitency
-      CALL trc_ctl_pisces
-
-
+      !
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) ' trc_ini_pisces :   PISCES biochemical model initialisation'
       IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+      CALL pisces_alloc()                          ! Allocate PISCES arrays
 
       !                                            ! Time-step
@@ -126,28 +126,40 @@
       IF(lwp) WRITE(numout,*) 'Initialization of PISCES tracers done'
       IF(lwp) WRITE(numout,*) ' '
-
       !
    END SUBROUTINE trc_ini_pisces
- 
-   SUBROUTINE trc_ctl_pisces
+
+
+   SUBROUTINE pisces_alloc
       !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE trc_ctl_pisces  ***
+      !!                     ***  ROUTINE pisces_alloc  ***
       !!
-      !! ** Purpose :   control the cpp options, namelist and files 
+      !! ** Purpose :   Allocate all the dynamic arrays of PISCES 
       !!----------------------------------------------------------------------
+      USE p4zint , ONLY : p4z_int_alloc      
+      USE p4zsink, ONLY : p4z_sink_alloc      
+      USE p4zopt , ONLY : p4z_opt_alloc           
+      USE p4zprod, ONLY : p4z_prod_alloc         
+      USE p4zrem , ONLY : p4z_rem_alloc           
+      USE p4zsed , ONLY : p4z_sed_alloc          
+      USE p4zflx , ONLY : p4z_flx_alloc
+      !
+      INTEGER :: ierr
+      !!----------------------------------------------------------------------
+      !
+      ierr =         sms_pisces_alloc()          ! Start of PISCES-related alloc routines...
+      ierr = ierr +     p4z_che_alloc()
+      ierr = ierr +     p4z_int_alloc()
+      ierr = ierr +    p4z_sink_alloc()
+      ierr = ierr +     p4z_opt_alloc()
+      ierr = ierr +    p4z_prod_alloc()
+      ierr = ierr +     p4z_rem_alloc()
+      ierr = ierr +     p4z_sed_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' )
+      !
+   END SUBROUTINE pisces_alloc
 
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) ' use PISCES biological model '
-
-   ! Check number of tracers
-   ! -----------------------
-#if  defined key_kriest
-      IF( jp_pisces /= 23) CALL ctl_stop( ' PISCES must have 23 passive tracers. Change jp_pisces in par_pisces.F90' )
-#else
-      IF( jp_pisces /= 24) CALL ctl_stop( ' PISCES must have 24 passive tracers. Change jp_pisces in par_pisces.F90' )
-#endif
-
-   END SUBROUTINE trc_ctl_pisces
-  
 #else
    !!----------------------------------------------------------------------
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcnam_pisces.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcnam_pisces.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcnam_pisces.F90	(revision 2715)
@@ -19,5 +19,4 @@
    USE trc             ! TOP variables
    USE sms_pisces      ! sms trends
-   USE in_out_manager  ! I/O manager
 
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90	(revision 2715)
@@ -18,9 +18,6 @@
    USE trcsms_pisces          ! pisces sms trends
    USE sms_pisces          ! pisces sms variables
-   USE in_out_manager  ! I/O manager
    USE iom
    USE trcdta
-   USE lib_mpp
-   USE lib_fortran
 
    IMPLICIT NONE
@@ -108,12 +105,10 @@
       !! ** purpose  : Relaxation of some tracers
       !!----------------------------------------------------------------------
-      INTEGER  :: ji, jj, jk
-      REAL(wp) ::  &
-         alkmean = 2426. ,  & ! mean value of alkalinity ( Glodap ; for Goyet 2391. )
-         po4mean = 2.165 ,  & ! mean value of phosphates
-         no3mean = 30.90 ,  & ! mean value of nitrate
-         silmean = 91.51      ! mean value of silicate
-
-      REAL(wp) :: zarea, zvol, zalksum, zpo4sum, zno3sum, zsilsum
+      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
 
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90	(revision 2715)
@@ -16,6 +16,4 @@
    USE trc
    USE sms_pisces
-   USE lbclnk
-   USE lib_mpp
    
    USE p4zint          ! 
@@ -65,12 +63,18 @@
       !!              - ...
       !!---------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: ztrpis => wrk_3d_1   ! used for pisces sms trends
+      !
       INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
       !!
       INTEGER ::   jnt, jn
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrpis   ! used for pisces sms trends
       CHARACTER (len=25) :: charout
       !!---------------------------------------------------------------------
 
       IF( kt == nit000 )   CALL trc_sms_pisces_init    ! Initialization (first time-step only)
+
+      IF( wrk_in_use(3,1) )  THEN
+        CALL ctl_stop('trc_sms_pisces : requested workspace array unavailable.')  ;  RETURN
+      ENDIF
 
       IF( ndayflxtr /= nday_year ) THEN      ! New days
@@ -111,4 +115,5 @@
             CALL trd_mod_trc( ztrpis, jn, jptra_trd_sms, kt )   ! save trends
           END DO
+          DEALLOCATE( ztrpis )
       END IF
 
@@ -122,4 +127,6 @@
          !
       ENDIF
+
+      IF( wrk_not_released(3,1) ) CALL ctl_stop('trc_sms_pisces : failed to release workspace array.') 
 
    END SUBROUTINE trc_sms_pisces
Index: trunk/NEMOGCM/NEMO/TOP_SRC/SED/sedini.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/SED/sedini.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/SED/sedini.F90	(revision 2715)
@@ -17,5 +17,4 @@
    USE sedarr
    USE iom
-   USE in_out_manager  ! I/O manager
 
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 2715)
@@ -10,5 +10,4 @@
    !!----------------------------------------------------------------------
    !!   'key_top'                                                TOP models
-   !!----------------------------------------------------------------------
    !!----------------------------------------------------------------------
    !!   trc_adv      : compute ocean tracer advection trend
@@ -26,15 +25,15 @@
    USE traadv_eiv      ! eddy induced velocity     (tra_adv_eiv    routine)
    USE ldftra_oce      ! lateral diffusion coefficient on tracers
-   USE in_out_manager  ! I/O manager
-   USE prtctl_trc          ! Print control
+   USE prtctl_trc      ! Print control
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   trc_adv    ! routine called by step module
+   PUBLIC   trc_adv          ! routine called by step module
+   PUBLIC   trc_adv_alloc    ! routine called by nemogcm module
 
    INTEGER ::   nadv   ! choice of the type of advection scheme
-   REAL(wp), DIMENSION(jpk) ::   r2dt  ! vertical profile time-step, = 2 rdttra
-      !                                ! except at nit000 (=rdttra) if neuler=0
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt  ! vertical profile time-step, = 2 rdttra
+   !                                                    ! except at nit000 (=rdttra) if neuler=0
 
    !! * Substitutions
@@ -46,6 +45,17 @@
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
+
+   INTEGER FUNCTION trc_adv_alloc()
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_adv_alloc  ***
+      !!----------------------------------------------------------------------
+
+      ALLOCATE( r2dt(jpk), STAT=trc_adv_alloc )
+
+      IF( trc_adv_alloc /= 0 ) CALL ctl_warn('trc_adv_alloc : failed to allocate array.')
+
+   END FUNCTION trc_adv_alloc
+
 
    SUBROUTINE trc_adv( kt )
@@ -57,11 +67,16 @@
       !! ** Method  : - Update the tracer with the advection term following nadv
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: zun => wrk_3d_4, zvn => wrk_3d_5, zwn => wrk_3d_6   ! effective velocity
       !!
-      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
-      !
-      INTEGER :: jk 
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zun, zvn, zwn   ! effective velocity
-      CHARACTER (len=22) :: charout
-      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !
+      INTEGER ::   jk 
+      CHARACTER (len=22) ::   charout
+      !!----------------------------------------------------------------------
+      !
+      IF( wrk_in_use(3, 4,5,6) ) THEN
+         CALL ctl_stop('trc_adv : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 )   CALL trc_adv_ctl          ! initialisation & control of options
@@ -80,7 +95,7 @@
       DO jk = 1, jpkm1
          !                                                ! eulerian transport only
-         zun(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
-         zvn(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
-         zwn(:,:,jk) = e1t(:,:) * e2t(:,:)      * wn(:,:,jk)
+         zun(:,:,jk) = e2u  (:,:) * fse3u(:,:,jk) * un(:,:,jk)
+         zvn(:,:,jk) = e1v  (:,:) * fse3v(:,:,jk) * vn(:,:,jk)
+         zwn(:,:,jk) = e1e2t(:,:)                 * wn(:,:,jk)
          !
       END DO
@@ -125,4 +140,6 @@
                                             CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
       END IF
+      !
+      IF( wrk_not_released(3, 4,5,6) ) CALL ctl_stop('trc_adv : failed to release workspace arrays.')
       !
    END SUBROUTINE trc_adv
@@ -171,4 +188,5 @@
       !
    END SUBROUTINE trc_adv_ctl
+   
 #else
    !!----------------------------------------------------------------------
@@ -181,4 +199,5 @@
    END SUBROUTINE trc_adv
 #endif
+
   !!======================================================================
 END MODULE trcadv
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 2715)
@@ -29,8 +29,10 @@
    PRIVATE
 
-   PUBLIC trc_dmp      ! routine called by step.F90
+   PUBLIC trc_dmp            ! routine called by step.F90
+   PUBLIC trc_dmp_alloc      ! routine called by nemogcm.F90
 
    LOGICAL , PUBLIC, PARAMETER ::   lk_trcdmp = .TRUE.   !: internal damping flag
-   !                             !!* Namelist namtrc_dmp : passive tracer newtonian damping *
+
+   !                                !!* Namelist namtrc_dmp : passive tracer newtonian damping *
    INTEGER  ::   nn_hdmp_tr =   -1   ! = 0/-1/'latitude' for damping over passive tracer
    INTEGER  ::   nn_zdmp_tr =    0   ! = 0/1/2 flag for damping in the mixed layer
@@ -40,5 +42,5 @@
    INTEGER  ::   nn_file_tr =    2   ! = 1 create a damping.coeff NetCDF file 
 
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   restotr   ! restoring coeff. on tracers (s-1)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   restotr   ! restoring coeff. on tracers (s-1)
 
    !! * Substitutions
@@ -47,8 +49,18 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcdmp.F90,v 1.11 2006/09/01 14:03:49 opalod Exp $ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
+
+   INTEGER FUNCTION trc_dmp_alloc()
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_dmp_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( restotr(jpi,jpj,jpk) , STAT=trc_dmp_alloc )
+      !
+      IF( trc_dmp_alloc /= 0 )   CALL ctl_warn('trc_dmp_alloc: failed to allocate array')
+      !
+   END FUNCTION trc_dmp_alloc
+
 
    SUBROUTINE trc_dmp( kt )
@@ -161,5 +173,5 @@
       !!
       !! ** Method  :   read the nammbf namelist and check the parameters
-      !!      called by trc_dmp at the first timestep (nit000)
+      !!              called by trc_dmp at the first timestep (nit000)
       !!----------------------------------------------------------------------
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90	(revision 2715)
@@ -27,7 +27,4 @@
    USE trdtra
    USE prtctl_trc      ! Print control
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! distribued memory computing library
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
 
    IMPLICIT NONE
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90	(revision 2715)
@@ -3,5 +3,4 @@
    !!                       ***  MODULE  trcnxt  ***
    !! Ocean passive tracers:  time stepping on passives tracers
-   !!======================================================================
    !!======================================================================
    !! History :  7.0  !  1991-11  (G. Madec)  Original code
@@ -27,5 +26,4 @@
    !!   trc_nxt     : time stepping on passive tracers
    !!----------------------------------------------------------------------
-   !! * Modules used
    USE oce_trc         ! ocean dynamics and tracers variables
    USE trc             ! ocean passive tracers variables
@@ -43,15 +41,26 @@
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC trc_nxt          ! routine called by step.F90
+   PUBLIC   trc_nxt          ! routine called by step.F90
+   PUBLIC   trc_nxt_alloc    ! routine called by nemogcm.F90
 
-  REAL(wp), DIMENSION(jpk) ::   r2dt
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt
+
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
+CONTAINS
 
-CONTAINS
+   INTEGER FUNCTION trc_nxt_alloc()
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_nxt_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( r2dt(jpk), STAT=trc_nxt_alloc )
+      !
+      IF( trc_nxt_alloc /= 0 )   CALL ctl_warn('trc_nxt_alloc : failed to allocate array')
+      !
+   END FUNCTION trc_nxt_alloc
+
 
    SUBROUTINE trc_nxt( kt )
@@ -79,7 +88,6 @@
       !! ** Action  : - update trb, trn
       !!----------------------------------------------------------------------
-      !! * Arguments
       INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
-      !! * Local declarations
+      !
       INTEGER  ::   jk, jn   ! dummy loop indices
       REAL(wp) ::   zfact            ! temporary scalar
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcrad.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcrad.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcrad.F90	(revision 2715)
@@ -17,5 +17,4 @@
    USE trdmod_oce
    USE trdtra
-   USE lib_mpp
    USE prtctl_trc          ! Print control for debbuging
 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 2715)
@@ -16,8 +16,7 @@
    !!   trc_sbc      : update the tracer trend at ocean surface
    !!----------------------------------------------------------------------
-   !! * Modules used
-   USE oce_trc             ! ocean dynamics and active tracers variables
-   USE trc                 ! ocean  passive tracers variables
-   USE prtctl_trc          ! Print control for debbuging
+   USE oce_trc         ! ocean dynamics and active tracers variables
+   USE trc             ! ocean  passive tracers variables
+   USE prtctl_trc      ! Print control for debbuging
    USE trdmod_oce
    USE trdtra
@@ -26,6 +25,5 @@
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC trc_sbc              ! routine called by step.F90
+   PUBLIC   trc_sbc   ! routine called by step.F90
 
    !! * Substitutions
@@ -34,7 +32,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -60,14 +57,18 @@
       !!
       !!----------------------------------------------------------------------
-      !! * Arguments
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zemps  => wrk_2d_1
+      USE wrk_nemo, ONLY:   ztrtrd => wrk_3d_1
+      !
       INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
-
-      !! * Local declarations
+      !
       INTEGER  ::   ji, jj, jn           ! dummy loop indices
       REAL(wp) ::   zsrau, zse3t   ! temporary scalars
-      REAL(wp), DIMENSION(jpi,jpj) ::   zemps  ! surface freshwater flux
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
       CHARACTER (len=22) :: charout
       !!----------------------------------------------------------------------
+
+      IF( wrk_in_use(2, 1) .OR.  wrk_in_use(3, 1) ) THEN
+         CALL ctl_stop('trc_sbc: requested workspace array unavailable.')   ;   RETURN
+      END IF
 
       IF( kt == nit000 ) THEN
@@ -77,6 +78,4 @@
       ENDIF
 
-
-      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
 
       IF( lk_offline ) THEN          ! emps in dynamical files contains emps - rnf
@@ -113,10 +112,11 @@
       END DO                                                     ! tracer loop
       !                                                          ! ===========
-      IF( l_trdtrc ) DEALLOCATE( ztrtrd )
-
       IF( ln_ctl )   THEN
          WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_trc_info(charout)
                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
       ENDIF
+
+      IF( wrk_not_released(2, 1) .OR. wrk_not_released(3, 1) )   &
+      &       CALL ctl_stop('trc_sbc: failed to release workspace array.')
 
    END SUBROUTINE trc_sbc
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90	(revision 2715)
@@ -11,5 +11,4 @@
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
    !!   trc_ldf     : update the tracer trend with the lateral diffusion
    !!       ldf_ctl : initialization, namelist read, and parameters control
@@ -20,19 +19,18 @@
    USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
    USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
-   USE prtctl_trc      ! Print control
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE trdmod_oce
    USE trdtra
+   USE prtctl_trc      ! Print control
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   trc_zdf    ! called by step.F90 
+   PUBLIC   trc_zdf          ! called by step.F90 
+   PUBLIC   trc_zdf_alloc    ! called by nemogcm.F90 
 
    INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
       !                                ! defined from ln_zdf...  namlist logicals)
-   REAL(wp), DIMENSION(jpk) ::  r2dt   ! vertical profile time-step, = 2 rdttra
-      !                                ! except at nit000 (=rdttra) if neuler=0
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::  r2dt   ! vertical profile time-step, = 2 rdttra
+      !                                                 ! except at nit000 (=rdttra) if neuler=0
 
    !! * Substitutions
@@ -43,9 +41,19 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
    
+   INTEGER FUNCTION trc_zdf_alloc()
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_zdf_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( r2dt(jpk) , STAT=trc_zdf_alloc )
+      !
+      IF( trc_zdf_alloc /= 0 )   CALL ctl_warn('trc_zdf_alloc : failed to allocate array.')
+      !
+   END FUNCTION trc_zdf_alloc
+
+
    SUBROUTINE trc_zdf( kt )
       !!----------------------------------------------------------------------
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 2715)
@@ -23,5 +23,5 @@
    USE zdfddm  , ONLY : avs  !: salinity vertical diffusivity coeff. at w-point
 # endif
-   USE trcnam_trp      ! passive tracers transport namelist variables
+   USE trcnam_trp        ! passive tracers transport namelist variables
    USE trdmod_trc_oce    ! definition of main arrays used for trends computations
    USE in_out_manager    ! I/O manager
@@ -30,4 +30,5 @@
    USE ioipsl            ! NetCDF library
    USE lbclnk            ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp           ! MPP library
    USE trdmld_trc_rst    ! restart for diagnosing the ML trends
    USE prtctl            ! print control
@@ -39,4 +40,5 @@
 
    PUBLIC trd_mld_trc
+   PUBLIC trd_mld_trc_alloc
    PUBLIC trd_mld_bio
    PUBLIC trd_mld_trc_init
@@ -46,5 +48,5 @@
    CHARACTER (LEN=40) ::  clhstnam                                ! name of the trends NetCDF file
    INTEGER ::   nmoymltrd
-   INTEGER ::   ndextrd1(jpi*jpj)
+   INTEGER, ALLOCATABLE, SAVE, DIMENSION(:) ::   ndextrd1
    INTEGER, DIMENSION(jptra) ::   nidtrd, nh_t
    INTEGER ::   ndimtrd1                        
@@ -58,4 +60,11 @@
    LOGICAL :: lldebug = .TRUE.
 
+   ! Workspace array for trd_mld_trc() routine. Declared here as is 4D and
+   ! cannot use workspaces in wrk_nemo module.
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::  ztmltrd2   !
+#if defined key_lobster
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  ztmltrdbio2  ! only needed for mean diagnostics in trd_mld_bio()
+#endif
+
    !! * Substitutions
 #  include "top_substitute.h90"
@@ -63,8 +72,23 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Header:  $ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
+
+   INTEGER FUNCTION trd_mld_trc_alloc()
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld_trc_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( ztmltrd2(jpi,jpj,jpltrd_trc,jptra) ,      &
+#if defined key_lobster
+         &      ztmltrdbio2(jpi,jpj,jpdiabio)      ,      &
+#endif
+         &      ndextrd1(jpi*jpj)                  ,  STAT=trd_mld_trc_alloc)
+         !
+      IF( lk_mpp                )   CALL mpp_sum ( trd_mld_trc_alloc )
+      IF( trd_mld_trc_alloc /=0 )   CALL ctl_warn('trd_mld_trc_alloc: failed to allocate arrays')
+      !
+   END FUNCTION trd_mld_trc_alloc
+
 
    SUBROUTINE trd_mld_trc_zint( ptrc_trdmld, ktrd, ctype, kjn )
@@ -88,10 +112,16 @@
       !!            surface and the control surface is called "mixed-layer"
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zvlmsk => wrk_2d_1
+      !!
       INTEGER, INTENT( in ) ::   ktrd, kjn                        ! ocean trend index and passive tracer rank
       CHARACTER(len=2), INTENT( in ) ::  ctype                    ! surface/bottom (2D) or interior (3D) physics
       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::  ptrc_trdmld ! passive tracer trend
       INTEGER ::   ji, jj, jk, isum
-      REAL(wp), DIMENSION(jpi,jpj) ::  zvlmsk
-      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+
+      IF( wrk_in_use(2, 1) ) THEN
+         CALL ctl_stop('trd_mld_trc_zint: requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       ! I. Definition of control surface and integration weights
@@ -177,8 +207,11 @@
             tmltrd_trc(:,:,ktrd,kjn) = tmltrd_trc(:,:,ktrd,kjn) + ptrc_trdmld(:,:,1) * wkx_trc(:,:,1)  ! non penetrative
       END SELECT
-
-    END SUBROUTINE trd_mld_trc_zint
-    
-    SUBROUTINE trd_mld_bio_zint( ptrc_trdmld, ktrd )
+      !
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('trd_mld_trc_zint: failed to release workspace array')
+      !
+   END SUBROUTINE trd_mld_trc_zint
+
+
+   SUBROUTINE trd_mld_bio_zint( ptrc_trdmld, ktrd )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE trd_mld_bio_zint  ***
@@ -198,11 +231,17 @@
       !!            surface and the control surface is called "mixed-layer"
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   ktrd          ! bio trend index
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::  ptrc_trdmld ! passive trc trend
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zvlmsk => wrk_2d_1
+      !!
+      INTEGER                         , INTENT(in) ::   ktrd          ! bio trend index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   ptrc_trdmld   ! passive trc trend
 #if defined key_lobster
-      !! local variables
+      !
       INTEGER ::   ji, jj, jk, isum
-      REAL(wp), DIMENSION(jpi,jpj) ::  zvlmsk
-      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+
+      IF( wrk_in_use(2, 1) ) THEN
+         CALL ctl_stop('trd_mld_bio_zint: requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       ! I. Definition of control surface and integration weights
@@ -286,10 +325,11 @@
       END DO
 
-#endif
-
-    END SUBROUTINE trd_mld_bio_zint
-
-
-    SUBROUTINE trd_mld_trc( kt )
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('trd_mld_bio_zint: failed to release workspace array')
+#endif
+      !
+   END SUBROUTINE trd_mld_bio_zint
+
+
+   SUBROUTINE trd_mld_trc( kt )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE trd_mld_trc  ***
@@ -338,20 +378,25 @@
       !!       - See NEMO documentation (in preparation)
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt                               ! ocean time-step index
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   wrk_3d_1, wrk_3d_2, wrk_3d_3, wrk_3d_4
+      USE wrk_nemo, ONLY:   wrk_3d_5, wrk_3d_6, wrk_3d_7, wrk_3d_8, wrk_3d_9
+      !
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !
       INTEGER ::   ji, jj, jk, jl, ik, it, itmod, jn
       REAL(wp) ::   zavt, zfn, zfn2
-      !!
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmltot             ! d(trc)/dt over the anlysis window (incl. Asselin)
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlres             ! residual = dh/dt entrainment term
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlatf             ! for storage only
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlrad             ! for storage only (for trb<0 corr in trcrad)
-      !!
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmltot2            ! -+
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlres2            !  | working arrays to diagnose the trends
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmltrdm2           !  | associated with the time meaned ML
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlatf2            !  | passive tracers
-      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlrad2            !  | (-> for trb<0 corr in trcrad)
-      REAL(wp), DIMENSION(jpi,jpj,jpltrd_trc,jptra) ::  ztmltrd2  ! -+
-      !!
+      !
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmltot             ! d(trc)/dt over the anlysis window (incl. Asselin)
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmlres             ! residual = dh/dt entrainment term
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmlatf             ! for storage only
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmlrad             ! for storage only (for trb<0 corr in trcrad)
+      !
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmltot2            ! -+
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmlres2            !  | working arrays to diagnose the trends
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmltrdm2           !  | associated with the time meaned ML
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmlatf2            !  | passive tracers
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmlrad2            !  | (-> for trb<0 corr in trcrad)
+      !REAL(wp), DIMENSION(jpi,jpj,jpltrd_trc,jptra) ::  ztmltrd2  ! -+
+      !
       CHARACTER (LEN= 5) ::   clvar
 #if defined key_dimgout
@@ -361,5 +406,20 @@
       !!----------------------------------------------------------------------
 
-      IF( nn_dttrc  /= 1  ) CALL ctl_stop( " Be careful, trends diags never validated " )
+      IF( wrk_in_use(3, 1,2,3,4,5,6,7,8,9) ) THEN
+         CALL ctl_stop('trd_mld_trc : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
+      ! Set-up pointers into sub-arrays of workspaces
+      ztmltot   => wrk_3d_1(:,:,1:jptra)
+      ztmlres   => wrk_3d_2(:,:,1:jptra)
+      ztmlatf   => wrk_3d_3(:,:,1:jptra)
+      ztmlrad   => wrk_3d_4(:,:,1:jptra)
+      ztmltot2  => wrk_3d_5(:,:,1:jptra)
+      ztmlres2  => wrk_3d_6(:,:,1:jptra)
+      ztmltrdm2 => wrk_3d_7(:,:,1:jptra)
+      ztmlatf2  => wrk_3d_8(:,:,1:jptra)
+      ztmlrad2  => wrk_3d_9(:,:,1:jptra)
+
+
+      IF( nn_dttrc  /= 1  )   CALL ctl_stop( " Be careful, trends diags never validated " )
 
       ! ======================================================================
@@ -386,5 +446,5 @@
 
          DO jn = 1, jptra
-         ! ... Remove this K_z trend from the iso-neutral diffusion term (if any)
+            ! ... Remove this K_z trend from the iso-neutral diffusion term (if any)
             IF( ln_trdtrc(jn) ) &
                  tmltrd_trc(:,:,jpmld_trc_ldf,jn) = tmltrd_trc(:,:,jpmld_trc_ldf,jn) - tmltrd_trc(:,:,jpmld_trc_zdf,jn)
@@ -847,7 +907,10 @@
       IF( lrst_trc )   CALL trd_mld_trc_rst_write( kt )  ! this must be after the array swap above (III.3)
 
+      IF( wrk_not_released(3, 1,2,3,4,5,6,7,8,9) )   CALL ctl_stop('trd_mld_trc: failed to release workspace arrays')
+      !
    END SUBROUTINE trd_mld_trc
 
-    SUBROUTINE trd_mld_bio( kt )
+
+   SUBROUTINE trd_mld_bio( kt )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE trd_mld  ***
@@ -900,5 +963,4 @@
       INTEGER  ::  jl, it, itmod
       LOGICAL  :: llwarn  = .TRUE., lldebug = .TRUE.
-      REAL(wp), DIMENSION(jpi,jpj,jpdiabio) ::  ztmltrdbio2  ! only needed for mean diagnostics
       REAL(wp) :: zfn, zfn2
 #if defined key_dimgout
@@ -1085,4 +1147,5 @@
    END SUBROUTINE trd_mld_bio
 
+
    REAL FUNCTION sum2d( ztab )
       !!----------------------------------------------------------------------
@@ -1091,6 +1154,7 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT( in ) ::  ztab      
       !!----------------------------------------------------------------------
-      sum2d = SUM(ztab(2:jpi-1,2:jpj-1))
+      sum2d = SUM( ztab(2:jpi-1,2:jpj-1) )
    END FUNCTION sum2d
+
 
    SUBROUTINE trd_mld_trc_init
@@ -1378,17 +1442,13 @@
    !!   Default option :                                       Empty module
    !!----------------------------------------------------------------------
-
 CONTAINS
-
    SUBROUTINE trd_mld_trc( kt )                                   ! Empty routine
       INTEGER, INTENT( in) ::   kt
       WRITE(*,*) 'trd_mld_trc: You should not have seen this print! error?', kt
    END SUBROUTINE trd_mld_trc
-
    SUBROUTINE trd_mld_bio( kt )
       INTEGER, INTENT( in) ::   kt
       WRITE(*,*) 'trd_mld_bio: You should not have seen this print! error?', kt
    END SUBROUTINE trd_mld_bio
-
    SUBROUTINE trd_mld_trc_zint( ptrc_trdmld, ktrd, ctype, kjn )
       INTEGER               , INTENT( in ) ::  ktrd, kjn              ! ocean trend index and passive tracer rank
@@ -1400,5 +1460,4 @@
       WRITE(*,*) '  "      "      : You should not have seen this print! error?', kjn
    END SUBROUTINE trd_mld_trc_zint
-
    SUBROUTINE trd_mld_trc_init                                    ! Empty routine
       WRITE(*,*) 'trd_mld_trc_init: You should not have seen this print! error?'
Index: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc_oce.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc_oce.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc_oce.F90	(revision 2715)
@@ -4,37 +4,31 @@
    !! Ocean trends :   set tracer and momentum trend variables
    !!======================================================================
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/TRD/trdmld_oce.F90,v 1.2 2005/03/27 18:35:23 opalod Exp $ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-#if defined key_top
+#if defined key_top   ||   defined key_esopa
    !!----------------------------------------------------------------------
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
-
-   USE par_oce                        ! ocean parameters
-   USE par_trc                        ! passive tracers parameters
+   USE par_oce       ! ocean parameters
+   USE par_trc       ! passive tracers parameters
 
    IMPLICIT NONE
    PUBLIC
 
-   !!* Namelist namtoptrd:  diagnostics on passive tracers trends
-   INTEGER  ::    nn_trd_trc                 !: time step frequency dynamics and tracers trends
-   INTEGER  ::    nn_ctls_trc                !: control surface type for trends vertical integration
+   !                                         !!* Namelist namtoptrd:  diagnostics on passive tracers trends
+   INTEGER  ::    nn_trd_trc                  !: time step frequency dynamics and tracers trends
+   INTEGER  ::    nn_ctls_trc                 !: control surface type for trends vertical integration
    REAL(wp) ::    rn_ucf_trc                  !: unit conversion factor (for netCDF trends outputs)
-   LOGICAL  ::    ln_trdmld_trc_instant    !: flag to diagnose inst./mean ML trc trends
-   LOGICAL  ::    ln_trdmld_trc_restart    !: flag to restart mixed-layer trc diagnostics
-   CHARACTER(len=50) ::  cn_trdrst_trc_in  !: suffix of pass. tracer restart name (input)
-   CHARACTER(len=50) ::  cn_trdrst_trc_out !: suffix of pass. tracer restart name (output)
-   LOGICAL, DIMENSION (jptra) ::   ln_trdtrc  !: large trends diagnostic to write or not (namelist)
+   LOGICAL  ::    ln_trdmld_trc_instant       !: flag to diagnose inst./mean ML trc trends
+   LOGICAL  ::    ln_trdmld_trc_restart       !: flag to restart mixed-layer trc diagnostics
+   CHARACTER(len=50) ::  cn_trdrst_trc_in     !: suffix of pass. tracer restart name (input)
+   CHARACTER(len=50) ::  cn_trdrst_trc_out    !: suffix of pass. tracer restart name (output)
+   LOGICAL, DIMENSION(jptra) ::   ln_trdtrc   !: large trends diagnostic to write or not (namelist)
 
 # if defined key_trdtrc && defined key_iomput
    LOGICAL, PARAMETER ::   lk_trdtrc = .TRUE. 
-#else
+# else
    LOGICAL, PARAMETER ::   lk_trdtrc = .FALSE.   !: ML trend flag
-#endif
+# endif
 
-#if defined key_trdmld_trc
+# if defined key_trdmld_trc   ||   defined key_esopa
    !!----------------------------------------------------------------------
    !!   'key_trdmld_trc'                     mixed layer trends diagnostics
@@ -60,7 +54,7 @@
    !! Trends diagnostics parameters
    !!---------------------------------------------------------------------
-   INTEGER, PARAMETER ::            &
-      jpltrd_trc = 12,                  & !: number of mixed-layer trends arrays
-      jpktrd_trc = jpk                    !: max level for mixed-layer trends diag.
+   INTEGER, PARAMETER :: jpltrd_trc = 12    !: number of mixed-layer trends arrays
+      
+   INTEGER            :: jpktrd_trc         !: max level for mixed-layer trends diag.
 
    !! Arrays used for diagnosing mixed-layer trends 
@@ -68,15 +62,15 @@
    CHARACTER(LEN=80) :: clname_trc, ctrd_trc(jpltrd_trc+1,2)
 
-   INTEGER, DIMENSION(jpi,jpj) ::   &
+   INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   &
       nmld_trc       , &                            !: mixed layer depth indexes 
       nbol_trc                                   !: mixed-layer depth indexes when read from file
 
-   REAL(wp), DIMENSION(jpi,jpj,jpk) ::  wkx_trc  !:
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  wkx_trc  !:
 
-   REAL(wp), DIMENSION(jpi,jpj) ::  rmld_trc     !: ML depth (m) corresponding to nmld_trc
-   REAL(wp), DIMENSION(jpi,jpj) ::  rmld_sum_trc !: needed to compute the leap-frog time mean of ML depth
-   REAL(wp), DIMENSION(jpi,jpj) ::  rmldbn_trc   !: idem
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  rmld_trc     !: ML depth (m) corresponding to nmld_trc
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  rmld_sum_trc !: needed to compute the leap-frog time mean of ML depth
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  rmldbn_trc   !: idem
 
-   REAL(wp), DIMENSION(jpi,jpj,jptra) ::  &
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &
       tml_trc    ,                        &      !: \ "now" mixed layer temperature/salinity
       tmlb_trc   ,                        &      !: /  and associated "before" fields
@@ -89,5 +83,5 @@
                                                  !:     previous analysis period
                                                  
-   REAL(wp), DIMENSION(jpi,jpj,jptra) ::  &      
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &      
       tmlatfb_trc, tmlatfn_trc ,          &      !: "before" Asselin contrib. at beginning of the averaging
                                                  !:     period (i.e. last contrib. from previous such period)
@@ -98,5 +92,5 @@
       tmlradm_trc                                !: accumulator for the previous trcrad trend
 
-   REAL(wp), DIMENSION(jpi,jpj,jpltrd_trc,jptra) ::  &
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::  &
       tmltrd_trc,                         &      !: \ physical contributions to the total trend (for T/S),
                                                  !: / cumulated over the current analysis window
@@ -105,14 +99,14 @@
       tmltrd_csum_ub_trc                         !: before (prev. analysis period) cumulated sum over the
                                                  !: upper triangle
-   REAL(wp), DIMENSION(jpi,jpj,jptra) ::  &
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &
       tmltrdm_trc                                !: total cumulative trends over the analysis window
 
-#else
+# else
    LOGICAL, PARAMETER ::   lk_trdmld_trc = .FALSE.   !: ML trend flag
-#endif
+# endif
 
-#if defined key_lobster
+# if defined key_lobster
    CHARACTER(LEN=80) :: clname_bio, ctrd_bio(jpdiabio,2)
-   REAL(wp), DIMENSION(jpi,jpj,jpdiabio) ::  &
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &
       tmltrd_bio,                         &      !: \ biological contributions to the total trend ,
                                                  !: / cumulated over the current analysis window
@@ -122,4 +116,58 @@
                                                  !: upper triangle
 #endif
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/TRD/trdmld_oce.F90,v 1.2 2005/03/27 18:35:23 opalod Exp $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   INTEGER FUNCTION trd_mod_trc_oce_alloc()
+      !!----------------------------------------------------------------------
+      !!         *** ROUTINE trd_mod_trc_oce_alloc ***
+      !!----------------------------------------------------------------------
+      USE lib_mpp, ONLY: ctl_warn
+      INTEGER :: ierr(2)
+      !!----------------------------------------------------------------------
+      ierr(:) = 0
+      !
+# if defined key_trdmld_trc
+      ALLOCATE(nmld_trc(jpi,jpj),          nbol_trc(jpi,jpj),           &
+               wkx_trc(jpi,jpj,jpk),       rmld_trc(jpi,jpj),           &
+               rmld_sum_trc(jpi,jpj),      rmldbn_trc(jpi,jpj),         &
+               tml_trc(jpi,jpj,jptra),     tmlb_trc(jpi,jpj,jptra),     &
+               tmlbb_trc(jpi,jpj,jptra),   tmlbn_trc(jpi,jpj,jptra),    &
+               tml_sum_trc(jpi,jpj,jptra), tml_sumb_trc(jpi,jpj,jptra), &
+               tmltrd_atf_sumb_trc(jpi,jpj,jptra),                      &
+               tmltrd_rad_sumb_trc(jpi,jpj,jptra),                      &
+               !
+               tmlatfb_trc(jpi,jpj,jptra), tmlatfn_trc(jpi,jpj,jptra),  &
+               tmlatfm_trc(jpi,jpj,jptra), tmlradb_trc(jpi,jpj,jptra),  &
+               tmlradn_trc(jpi,jpj,jptra), tmlradm_trc(jpi,jpj,jptra),  &
+               !
+               tmltrd_trc(jpi,jpj,jpltrd_trc,jptra)         , &
+               tmltrd_sum_trc(jpi,jpj,jpltrd_trc,jptra)     , &
+               tmltrd_csum_ln_trc(jpi,jpj,jpltrd_trc,jptra) , &
+               tmltrd_csum_ub_trc(jpi,jpj,jpltrd_trc,jptra) , &
+               !
+               tmltrdm_trc(jpi,jpj,jptra)                   , STAT=ierr(1) )
+#endif
+      !
+# if defined key_lobster
+      ALLOCATE( tmltrd_bio        (jpi,jpj,jpdiabio) ,     &
+         &      tmltrd_sum_bio    (jpi,jpj,jpdiabio) ,     &
+         &      tmltrd_csum_ln_bio(jpi,jpj,jpdiabio) ,     &
+         &      tmltrd_csum_ub_bio(jpi,jpj,jpdiabio) , STAT=ierr(2) )
+# endif
+      !
+      trd_mod_trc_oce_alloc = MAXVAL(ierr)
+      !
+      IF( trd_mod_trc_oce_alloc /= 0 )   CALL ctl_warn('trd_mod_trc_oce_alloc: failed to allocate arrays')
+      !
+# if defined key_trdmld_trc
+      jpktrd_trc = jpk      ! Initialise what used to be a parameter - max level for mixed-layer trends diag.
+# endif
+      !
+   END FUNCTION trd_mod_trc_oce_alloc
 
 #else
@@ -129,4 +177,4 @@
 #endif
 
-
+   !!======================================================================
 END MODULE trdmod_trc_oce
Index: trunk/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90	(revision 2715)
@@ -33,5 +33,14 @@
    !* IO manager *
    USE in_out_manager    
-                          
+ 
+   !* MPP library                         
+   USE lib_mpp 
+
+   !* Fortran utilities                         
+   USE lib_fortran
+
+   !* Lateral boundary conditions                         
+   USE lbclnk
+
    !* physical constants *
    USE phycst            
@@ -88,4 +97,5 @@
    USE dom_oce , ONLY :   e1t        =>   e1t        !: horizontal scale factors at t-point (m)  
    USE dom_oce , ONLY :   e2t        =>   e2t        !: horizontal scale factors at t-point (m)   
+   USE dom_oce , ONLY :   e1e2t      =>   e1e2t      !: cell surface at t-point (m2)
    USE dom_oce , ONLY :   e1u        =>   e1u        !: horizontal scale factors at u-point (m)
    USE dom_oce , ONLY :   e2u        =>   e2u        !: horizontal scale factors at u-point (m)
@@ -194,5 +204,4 @@
 
 #endif
-   USE lib_mpp , ONLY :   lk_mpp    =>  lk_mpp        !: Mpp flag
 
    USE dom_oce , ONLY :   nn_cla    =>  nn_cla        !: flag (0/1) for cross land advection 
Index: trunk/NEMOGCM/NEMO/TOP_SRC/prtctl_trc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/prtctl_trc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/prtctl_trc.F90	(revision 2715)
@@ -17,6 +17,4 @@
    USE par_trc          ! TOP parameters
    USE oce_trc          ! ocean space and time domain variables
-   USE in_out_manager   ! I/O manager
-   USE lib_mpp          ! distributed memory computing
 
    IMPLICIT NONE
@@ -69,11 +67,13 @@
       INTEGER                              , INTENT(in), OPTIONAL ::   kdim      ! k- direction for 4D arrays
       !!
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zmask, ztab3d 
       INTEGER  ::   overlap, jn, js, sind, eind, kdir, j_id
       REAL(wp) ::   zsum, zvctl
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask, ztab3d
       CHARACTER (len=20), DIMENSION(jptra) ::   cl
       CHARACTER (len=10) ::   cl2
       !!----------------------------------------------------------------------
 
+      ALLOCATE( zmask (jpi,jpj,jpk) )
+      ALLOCATE( ztab3d(jpi,jpj,jpk) )
       !                                      ! Arrays, scalars initialization 
       overlap       = 0
@@ -150,4 +150,7 @@
          !
       END DO
+      !
+      DEALLOCATE( zmask  )
+      DEALLOCATE( ztab3d )
       !
    END SUBROUTINE prt_ctl_trc
Index: trunk/NEMOGCM/NEMO/TOP_SRC/trc.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 2715)
@@ -19,4 +19,6 @@
    PUBLIC
 
+   PUBLIC   trc_alloc   ! called by nemogcm.F90
+
    !! passive tracers names and units (read in namelist)
    !! --------------------------------------------------
@@ -34,50 +36,48 @@
    !! passive tracers fields (before,now,after)
    !! --------------------------------------------------
-   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk) :: cvol   !: volume correction -degrad option- 
    REAL(wp), PUBLIC ::   trai                          !: initial total tracer
    REAL(wp), PUBLIC ::   areatot                       !: total volume 
-
-   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk,jptra) ::   trn   !: traceur concentration for actual time step
-   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk,jptra) ::   tra   !: traceur concentration for next time step
-   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk,jptra) ::   trb   !: traceur concentration for before time step
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:,:)   ::   cvol   !: volume correction -degrad option- 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:,:,:) ::   trn    !: traceur concentration for now time step
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:,:,:) ::   tra    !: traceur concentration for next time step
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:,:,:) ::   trb    !: traceur concentration for before time step
 
    !! interpolated gradient
    !!--------------------------------------------------  
-   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jptra) ::   gtru   !: horizontal gradient at u-points at bottom ocean level
-   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jptra) ::   gtrv   !: horizontal gradient at v-points at bottom ocean level
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:,:) ::   gtru   !: hor. gradient at u-points at bottom ocean level
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:,:) ::   gtrv   !: hor. gradient at v-points at bottom ocean level
    
    !! passive tracers restart (input and output)
    !! ------------------------------------------  
-   LOGICAL , PUBLIC          ::  ln_rsttr      !: boolean term for restart i/o for passive tracers (namelist)
-   LOGICAL , PUBLIC          ::  lrst_trc      !: logical to control the trc restart write
-   INTEGER , PUBLIC          ::  nn_dttrc      !: frequency of step on passive tracers
-   INTEGER , PUBLIC          ::  nutwrs        !: output FILE for passive tracers restart
-   INTEGER , PUBLIC          ::  nutrst        !: logical unit for restart FILE for passive tracers
-   INTEGER , PUBLIC          ::  nn_rsttr      !: control of the time step ( 0 or 1 ) for pass. tr.
-   CHARACTER(len=50), PUBLIC ::  cn_trcrst_in  !: suffix of pass. tracer restart name (input)
-   CHARACTER(len=50), PUBLIC ::  cn_trcrst_out !: suffix of pass. tracer restart name (output)
+   LOGICAL          , PUBLIC ::  ln_rsttr        !: boolean term for restart i/o for passive tracers (namelist)
+   LOGICAL          , PUBLIC ::  lrst_trc        !: logical to control the trc restart write
+   INTEGER          , PUBLIC ::  nn_dttrc        !: frequency of step on passive tracers
+   INTEGER          , PUBLIC ::  nutwrs          !: output FILE for passive tracers restart
+   INTEGER          , PUBLIC ::  nutrst          !: logical unit for restart FILE for passive tracers
+   INTEGER          , PUBLIC ::  nn_rsttr        !: control of the time step ( 0 or 1 ) for pass. tr.
+   CHARACTER(len=50), PUBLIC ::  cn_trcrst_in    !: suffix of pass. tracer restart name (input)
+   CHARACTER(len=50), PUBLIC ::  cn_trcrst_out   !: suffix of pass. tracer restart name (output)
    
    !! information for outputs
    !! --------------------------------------------------
    INTEGER , PUBLIC ::   nn_writetrc   !: time step frequency for concentration outputs (namelist)
-   REAL(wp), PUBLIC, DIMENSION(jpk) ::   rdttrc        !: vertical profile of passive tracer time step
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   rdttrc        !: vertical profile of passive tracer time step
    
 # if defined key_diatrc && ! defined key_iomput
    !! additional 2D/3D outputs namelist
    !! --------------------------------------------------
-   INTEGER , PUBLIC                               ::   nn_writedia   !: frequency of additional arrays outputs(namelist)
-   CHARACTER(len= 8), PUBLIC, DIMENSION (jpdia2d) ::   ctrc2d      !: 2d output field name
-   CHARACTER(len= 8), PUBLIC, DIMENSION (jpdia2d) ::   ctrc2u      !: 2d output field unit   
-   CHARACTER(len= 8), PUBLIC, DIMENSION (jpdia3d) ::   ctrc3d      !: 3d output field name
-   CHARACTER(len= 8), PUBLIC, DIMENSION (jpdia3d) ::   ctrc3u      !: 3d output field unit
-   CHARACTER(len=80), PUBLIC, DIMENSION (jpdia2d) ::   ctrc2l      !: 2d output field long name
-   CHARACTER(len=80), PUBLIC, DIMENSION (jpdia3d) ::   ctrc3l      !: 3d output field long name
+   INTEGER         , PUBLIC                      ::   nn_writedia   !: frequency of additional arrays outputs(namelist)
+   CHARACTER(len= 8), PUBLIC, DIMENSION(jpdia2d) ::   ctrc2d      !: 2d output field name
+   CHARACTER(len= 8), PUBLIC, DIMENSION(jpdia2d) ::   ctrc2u      !: 2d output field unit   
+   CHARACTER(len= 8), PUBLIC, DIMENSION(jpdia3d) ::   ctrc3d      !: 3d output field name
+   CHARACTER(len= 8), PUBLIC, DIMENSION(jpdia3d) ::   ctrc3u      !: 3d output field unit
+   CHARACTER(len=80), PUBLIC, DIMENSION(jpdia2d) ::   ctrc2l      !: 2d output field long name
+   CHARACTER(len=80), PUBLIC, DIMENSION(jpdia3d) ::   ctrc3l      !: 3d output field long name
 
-   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,    jpdia2d) ::   trc2d    !:  additional 2d outputs  
-   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk,jpdia3d) ::   trc3d    !:  additional 3d outputs  
-   
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,  :) ::   trc2d    !:  additional 2d outputs  
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   trc3d    !:  additional 3d outputs  
 # endif
 
-#if defined key_diabio || defined key_trdmld_trc
+# if defined key_diabio || defined key_trdmld_trc
    !                                                              !!*  namtop_XXX namelist *
    INTEGER , PUBLIC                               ::   nn_writebio   !: time step frequency for biological outputs 
@@ -85,9 +85,9 @@
    CHARACTER(len=20), PUBLIC, DIMENSION(jpdiabio) ::   ctrbiu      !: biological trends unit   
    CHARACTER(len=80), PUBLIC, DIMENSION(jpdiabio) ::   ctrbil      !: biological trends long name
-#endif
+# endif
 # if defined key_diabio
    !! Biological trends
    !! -----------------
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk,jpdiabio) :: trbio   !: biological trends
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   trbio   !: biological trends
 # endif
 
@@ -99,4 +99,35 @@
 # endif
 
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3.1 , NEMO Consortium (2010)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   INTEGER FUNCTION trc_alloc()
+      !!-------------------------------------------------------------------
+      !!                    *** ROUTINE trc_alloc ***
+      !!-------------------------------------------------------------------
+      USE lib_mpp, ONLY: ctl_warn
+      !!-------------------------------------------------------------------
+      !
+      ALLOCATE( cvol(jpi,jpj,jpk      ) ,                           &
+         &      trn (jpi,jpj,jpk,jptra) ,                           &
+         &      tra (jpi,jpj,jpk,jptra) ,                           &
+         &      trb (jpi,jpj,jpk,jptra) ,                           &
+         &      gtru(jpi,jpj    ,jptra) , gtrv(jpi,jpj,jptra) ,     &
+# if defined key_diatrc && ! defined key_iomput
+         &      trc2d(jpi,jpj,jpdia2d), trc3d(jpi,jpj,jpk,jpdia3d), &
+# endif
+# if defined key_diabio
+         &      trbio(jpi,jpj,jpk,jpdiabio),                        &
+#endif
+               rdttrc(jpk) ,  STAT=trc_alloc )      
+
+      IF( trc_alloc /= 0 )   CALL ctl_warn('trc_alloc: failed to allocate arrays')
+      !
+   END FUNCTION trc_alloc
+
 #else
    !!----------------------------------------------------------------------
@@ -105,8 +136,4 @@
 #endif
 
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!======================================================================
 END MODULE trc
Index: trunk/NEMOGCM/NEMO/TOP_SRC/trcdia.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/trcdia.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/trcdia.F90	(revision 2715)
@@ -25,6 +25,4 @@
    USE par_trc
    USE dianam    ! build name of file (routine)
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp
    USE ioipsl
 
@@ -32,5 +30,6 @@
    PRIVATE
 
-   PUBLIC   trc_dia   ! called by XXX module 
+   PUBLIC   trc_dia        ! called by XXX module 
+   PUBLIC   trc_dia_alloc  ! called by nemogcm.F90
 
    INTEGER  ::   nit5      !: id for tracer output file
@@ -40,6 +39,6 @@
    INTEGER  ::   ndimt51   !: number of ocean points in index array
    REAL(wp) ::   zjulian   !: ????   not DOCTOR !
-   INTEGER , DIMENSION (jpij*jpk) ::   ndext50   !: integer arrays for ocean 3D index
-   INTEGER , DIMENSION (jpij)     ::   ndext51   !: integer arrays for ocean surface index
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION (:) ::   ndext50   !: integer arrays for ocean 3D index
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION (:) ::   ndext51   !: integer arrays for ocean surface index
 # if defined key_diatrc
    INTEGER  ::   nitd      !: id for additional array output file
@@ -58,5 +57,5 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -68,6 +67,7 @@
       !! ** Purpose :   output passive tracers fields 
       !!---------------------------------------------------------------------
-      INTEGER, INTENT( in ) :: kt
-      INTEGER               :: kindic
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step
+      !
+      INTEGER ::   kindic   ! local integer
       !!---------------------------------------------------------------------
       !
@@ -95,7 +95,7 @@
       !!        IF kindic >0, output of fields before the time step loop
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
-      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
-      !!
+      INTEGER, INTENT(in) ::   kt       ! ocean time-step
+      INTEGER, INTENT(in) ::   kindic   ! indicator of abnormal termination
+      !
       INTEGER ::   jn
       LOGICAL ::   ll_print = .FALSE.
@@ -183,7 +183,7 @@
          DO jn = 1, jptra
             IF( lutsav(jn) ) THEN
-               cltra  = ctrcnm(jn)   ! short title for tracer
-               cltral = ctrcnl(jn)   ! long title for tracer
-               cltrau = ctrcun(jn)   ! UNIT for tracer
+               cltra  = TRIM( ctrcnm(jn) )   ! short title for tracer
+               cltral = TRIM( ctrcnl(jn) )   ! long title for tracer
+               cltrau = TRIM( ctrcun(jn) )   ! UNIT for tracer
                CALL histdef( nit5, cltra, cltral, cltrau, jpi, jpj, nhorit5,  &
                   &          ipk, 1, ipk,  ndepit5, 32, clop, zsto, zout ) 
@@ -208,5 +208,5 @@
 
       DO jn = 1, jptra
-         cltra = ctrcnm(jn)      ! short title for tracer
+         cltra  = TRIM( ctrcnm(jn) )   ! short title for tracer
          IF( lutsav(jn) ) CALL histwrite( nit5, cltra, it, trn(:,:,:,jn), ndimt50, ndext50 )
       END DO
@@ -216,5 +216,4 @@
       IF( kt == nitend .OR. kindic < 0 )   CALL histclo( nit5 )
       !
-
    END SUBROUTINE trcdit_wr
 
@@ -237,6 +236,6 @@
       !!        IF kindic >0, output of fields before the time step loop
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
-      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
+      INTEGER, INTENT(in) ::   kt       ! ocean time-step
+      INTEGER, INTENT(in) ::   kindic   ! indicator of abnormal termination
       !!
       LOGICAL ::   ll_print = .FALSE.
@@ -308,7 +307,7 @@
          ! more 3D horizontal arrays
          DO jl = 1, jpdia3d
-            cltra  = ctrc3d(jl)   ! short title for 3D diagnostic
-            cltral = ctrc3l(jl)   ! long title for 3D diagnostic
-            cltrau = ctrc3u(jl)   ! UNIT for 3D diagnostic
+            cltra  = TRIM( ctrc3d(jl) )   ! short title for 3D diagnostic
+            cltral = TRIM( ctrc3l(jl) )  ! long title for 3D diagnostic
+            cltrau = TRIM( ctrc3u(jl) )  ! UNIT for 3D diagnostic
             CALL histdef( nitd, cltra, cltral, cltrau, jpi, jpj, nhoritd,   &
                &          ipk, 1, ipk,  ndepitd, 32, clop, zsto, zout )
@@ -317,7 +316,7 @@
          ! more 2D horizontal arrays
          DO jl = 1, jpdia2d
-            cltra  = ctrc2d(jl)    ! short title for 2D diagnostic
-            cltral = ctrc2l(jl)   ! long title for 2D diagnostic
-            cltrau = ctrc2u(jl)   ! UNIT for 2D diagnostic
+            cltra  = TRIM( ctrc2d(jl) )   ! short title for 2D diagnostic
+            cltral = TRIM( ctrc2l(jl) )  ! long title for 2D diagnostic
+            cltrau = TRIM( ctrc2u(jl) )  ! UNIT for 2D diagnostic
             CALL histdef( nitd, cltra, cltral, cltrau, jpi, jpj, nhoritd,  &
                &          1, 1, 1,  -99, 32, clop, zsto, zout )
@@ -345,5 +344,5 @@
       ! more 3D horizontal arrays
       DO jl = 1, jpdia3d
-         cltra = ctrc3d(jl)   ! short title for 3D diagnostic
+         cltra  = TRIM( ctrc3d(jl) )   ! short title for 3D diagnostic
          CALL histwrite( nitd, cltra, it, trc3d(:,:,:,jl), ndimt50 ,ndext50)
       END DO
@@ -351,5 +350,5 @@
       ! more 2D horizontal arrays
       DO jl = 1, jpdia2d
-         cltra = ctrc2d(jl)   ! short title for 2D diagnostic
+         cltra  = TRIM( ctrc2d(jl) )   ! short title for 2D diagnostic
          CALL histwrite(nitd, cltra, it, trc2d(:,:,jl), ndimt51  ,ndext51)
       END DO
@@ -364,5 +363,5 @@
 # else
    SUBROUTINE trcdii_wr( kt, kindic )                      ! Dummy routine
-      INTEGER, INTENT ( in ) :: kt, kindic
+      INTEGER, INTENT (in) :: kt, kindic
    END SUBROUTINE trcdii_wr
 # endif
@@ -400,5 +399,4 @@
       ! Initialisation
       ! --------------
-
       
       ! local variable for debugging
@@ -451,7 +449,7 @@
          ! biological trends
          DO jl = 1, jpdiabio
-            cltra  = ctrbio(jl)   ! short title for biological diagnostic
-            cltral = ctrbil(jl)   ! long title for biological diagnostic
-            cltrau = ctrbiu(jl)   ! UNIT for biological diagnostic
+            cltra  = TRIM( ctrbio(jl) )   ! short title for biological diagnostic
+            cltral = TRIM( ctrbil(jl) )  ! long title for biological diagnostic
+            cltrau = TRIM( ctrbiu(jl) )  ! UNIT for biological diagnostic
             CALL histdef( nitb, cltra, cltral, cltrau, jpi, jpj, nhoritb,  &
                &         ipk, 1, ipk,  ndepitb, 32, clop, zsto, zout)
@@ -477,5 +475,5 @@
 
       DO jl = 1, jpdiabio
-         cltra = ctrbio(jl)  ! short title for biological diagnostic
+         cltra  = TRIM( ctrbio(jl) )   ! short title for biological diagnostic
          CALL histwrite(nitb, cltra, it, trbio(:,:,:,jl), ndimt50,ndext50)
       END DO
@@ -485,5 +483,4 @@
       IF( kt == nitend .OR. kindic < 0 )   CALL histclo( nitb )
       !
-
    END SUBROUTINE trcdib_wr
 
@@ -496,4 +493,13 @@
 # endif 
 
+   INTEGER FUNCTION trc_dia_alloc()
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_dia_alloc  ***
+      !!---------------------------------------------------------------------
+      ALLOCATE( ndext50(jpij*jpk), ndext51(jpij), STAT=trc_dia_alloc )
+      !
+      IF( trc_dia_alloc /= 0 )   CALL ctl_warn('trc_dia_alloc : failed to allocate arrays')
+      !
+   END FUNCTION trc_dia_alloc
 #else
    !!----------------------------------------------------------------------
Index: trunk/NEMOGCM/NEMO/TOP_SRC/trcdta.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/trcdta.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/trcdta.F90	(revision 2715)
@@ -23,13 +23,14 @@
    PRIVATE
 
-   PUBLIC trc_dta   ! called in trcini.F90 and trcdmp.F90
+   PUBLIC   trc_dta         ! called in trcini.F90 and trcdmp.F90
+   PUBLIC   trc_dta_alloc   ! called in nemogcm.F90
 
    LOGICAL , PUBLIC, PARAMETER ::   lk_dtatrc = .TRUE.   !: temperature data flag
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk,jptra) ::   trdta   !: tracer data at given time-step
-
-   REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,2) ::   tracdta            ! tracer data at two consecutive times
-   INTEGER , DIMENSION(jptra) ::   nlectr      !: switch for reading once
-   INTEGER , DIMENSION(jptra) ::   ntrc1       !: number of first month when reading 12 monthly value
-   INTEGER , DIMENSION(jptra) ::   ntrc2       !: number of second month when reading 12 monthly value
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   trdta   !: tracer data at given time-step
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:,:) ::   tracdta       ! tracer data at two consecutive times
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:) ::   nlectr      !: switch for reading once
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:) ::   ntrc1       !: number of 1st month when reading 12 monthly value
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:) ::   ntrc2       !: number of 2nd month when reading 12 monthly value
 
    !! * Substitutions
@@ -38,5 +39,5 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -55,5 +56,5 @@
       !!      two monthly values.
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt     ! ocean time-step
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
       !!
       CHARACTER (len=39) ::   clname(jptra)
@@ -198,4 +199,17 @@
    END SUBROUTINE trc_dta
 
+
+   INTEGER FUNCTION trc_dta_alloc()
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_dta_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( trdta  (jpi,jpj,jpk,jptra  ) ,                    &
+         &      tracdta(jpi,jpj,jpk,jptra,2) ,                    &
+         &      nlectr(jptra) , ntrc1(jptra) , ntrc2(jptra) , STAT=trc_dta_alloc)
+         !
+      IF( trc_dta_alloc /= 0 )   CALL ctl_warn('trc_dta_alloc : failed to allocate arrays')
+      !
+   END FUNCTION trc_dta_alloc
+
 #else
    !!----------------------------------------------------------------------
Index: trunk/NEMOGCM/NEMO/TOP_SRC/trcini.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/trcini.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/trcini.F90	(revision 2715)
@@ -4,8 +4,8 @@
    !! TOP :   Manage the passive tracer initialization
    !!======================================================================
-   !! History :    -   !  1991-03  ()  original code
-   !!             1.0  !  2005-03 (O. Aumont, A. El Moussaoui) F90
-   !!              -   !  2005-10 (C. Ethe) print control
-   !!             2.0  !  2005-10 (C. Ethe, G. Madec) revised architecture
+   !! History :   -   ! 1991-03 (O. Marti)  original code
+   !!            1.0  ! 2005-03 (O. Aumont, A. El Moussaoui) F90
+   !!            2.0  ! 2005-10 (C. Ethe, G. Madec) revised architecture
+   !!            4.0  ! 2011-01 (A. R. Porter, STFC Daresbury) dynamical allocation
    !!----------------------------------------------------------------------
 #if defined key_top
@@ -13,6 +13,6 @@
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
-   !!   trc_init :   Initialization for passive tracer
+   !!   trc_init  :   Initialization for passive tracer
+   !!   top_alloc :   allocate the TOP arrays
    !!----------------------------------------------------------------------
    USE oce_trc
@@ -26,12 +26,7 @@
    USE trcini_my_trc   ! MY_TRC   initialisation
    USE trcdta   
-#if defined key_offline
    USE daymod
-#endif
    USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
-   USE in_out_manager  ! I/O manager
    USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
-   USE lib_mpp         ! distributed memory computing library
-   USE lib_fortran     ! 
    
    IMPLICIT NONE
@@ -42,5 +37,9 @@
     !! * Substitutions
 #  include "domzgr_substitute.h90"
-  
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
    
@@ -59,5 +58,4 @@
       INTEGER ::   jk, jn    ! dummy loop indices
       CHARACTER (len=25) :: charout
-
       !!---------------------------------------------------------------------
 
@@ -66,10 +64,12 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~'
 
-      !                 ! masked grid volume
+      CALL top_alloc()              ! allocate TOP arrays
+
+      !                             ! masked grid volume
       DO jk = 1, jpk
          cvol(:,:,jk) = e1t(:,:) * e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk) 
       END DO
 
-      ! total volume of the ocean
+      !                             ! total volume of the ocean
 #if ! defined key_degrad
       areatot = glob_sum( cvol(:,:,:) )
@@ -78,16 +78,18 @@
 #endif
 
-                                  CALL trc_nam      ! read passive tracers namelists
-
-      ! restart for passive tracer (input)
+      CALL trc_nam                  ! read passive tracers namelists
+
+      !                             ! restart for passive tracer (input)
       IF( ln_rsttr ) THEN
          IF(lwp) WRITE(numout,*) '       read a restart file for passive tracer : ', cn_trcrst_in
          IF(lwp) WRITE(numout,*) ' '
       ELSE
-         IF(lwp) WRITE(numout,*)
-         DO jn = 1, jptra
-            IF( lwp .AND. lutini(jn) )  &                  ! open input FILE only IF lutini(jn) is true
-            &  WRITE(numout,*) '        read an initial file  for passive tracer number :', jn, ' traceur : ', ctrcnm(jn) 
-         END DO
+         IF( lwp .AND. lk_dtatrc ) THEN
+            DO jn = 1, jptra
+               IF( lutini(jn) )  &                  ! open input FILE only IF lutini(jn) is true
+                  &  WRITE(numout,*) ' read an initial file for passive tracer number :', jn, ' traceur : ', ctrcnm(jn) 
+             END DO
+          ENDIF
+          IF( lwp ) WRITE(numout,*)
       ENDIF
 
@@ -138,12 +140,12 @@
       ENDIF
  
-      tra(:,:,:,:) = 0.
+      tra(:,:,:,:) = 0._wp
       
       IF( ln_zps .AND. .NOT. lk_c1d )   &              ! Partial steps: before horizontal gradient of passive
-      &                     CALL zps_hde( nit000, jptra, trn, gtru, gtrv )       ! tracers at the bottom ocean level
-
-
-      !                 ! Computation content of all tracers
-      trai = 0.e0
+        &    CALL zps_hde( nit000, jptra, trn, gtru, gtrv )       ! tracers at the bottom ocean level
+
+
+      !           
+      trai = 0._wp         ! Computation content of all tracers
       DO jn = 1, jptra
 #if ! defined key_degrad
@@ -154,22 +156,72 @@
       END DO      
 
-      !                 ! control print
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
-      IF(lwp) WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
-      IF(lwp) WRITE(numout,*) '          *** Total inital content of all tracers  = ', trai
-      IF(lwp) WRITE(numout,*)
-
-      IF( ln_ctl )   CALL prt_ctl_trc_init      ! control print
-      !
-
-      IF(ln_ctl) THEN      ! print mean trends (used for debugging)
+      IF(lwp) THEN               ! control print
+         WRITE(numout,*)
+         WRITE(numout,*)
+         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
+         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
+         WRITE(numout,*) '          *** Total inital content of all tracers  = ', trai
+         WRITE(numout,*)
+      ENDIF
+
+      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
+         CALL prt_ctl_trc_init
          WRITE(charout, FMT="('ini ')")
          CALL prt_ctl_trc_info( charout )
          CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
       ENDIF
-
+      !
    END SUBROUTINE trc_init
+
+
+   SUBROUTINE top_alloc
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE top_alloc  ***
+      !!
+      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !!----------------------------------------------------------------------
+      USE trcadv        , ONLY:   trc_adv_alloc          ! TOP-related alloc routines...
+      USE trc           , ONLY:   trc_alloc
+      USE trcnxt        , ONLY:   trc_nxt_alloc
+      USE trczdf        , ONLY:   trc_zdf_alloc
+      USE trdmod_trc_oce, ONLY:   trd_mod_trc_oce_alloc
+#if ! defined key_iomput
+      USE trcdia        , ONLY:   trc_dia_alloc
+#endif
+#if defined key_trcdmp 
+      USE trcdmp        , ONLY:   trc_dmp_alloc
+#endif
+#if defined key_dtatrc
+      USE trcdta        , ONLY:   trc_dta_alloc
+#endif
+#if defined key_trdmld_trc   ||   defined key_esopa
+      USE trdmld_trc    , ONLY:   trd_mld_trc_alloc
+#endif
+      !
+      INTEGER :: ierr
+      !!----------------------------------------------------------------------
+      !
+      ierr =        trc_adv_alloc()          ! Start of TOP-related alloc routines...
+      ierr = ierr + trc_alloc    ()
+      ierr = ierr + trc_nxt_alloc()
+      ierr = ierr + trc_zdf_alloc()
+      ierr = ierr + trd_mod_trc_oce_alloc()
+#if ! defined key_iomput
+      ierr = ierr + trc_dia_alloc()
+#endif
+#if defined key_trcdmp 
+      ierr = ierr + trc_dmp_alloc()
+#endif
+#if defined key_dtatrc
+      ierr = ierr + trc_dta_alloc()
+#endif
+#if defined key_trdmld_trc   ||   defined key_esopa
+      ierr = ierr + trd_mld_trc_alloc()
+#endif
+      !
+      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
+      !
+   END SUBROUTINE top_alloc
 
 #else
@@ -182,8 +234,4 @@
 #endif
 
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!======================================================================
 END MODULE trcini
Index: trunk/NEMOGCM/NEMO/TOP_SRC/trcnam.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/trcnam.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/trcnam.F90	(revision 2715)
@@ -26,5 +26,4 @@
    USE trcnam_c14b       ! C14 SMS namelist
    USE trcnam_my_trc     ! MY_TRC SMS namelist
-   USE in_out_manager    ! I/O manager
    USE trdmod_trc_oce
 
@@ -103,9 +102,9 @@
 
       DO jn = 1, jptra
-         ctrcnm(jn) = sn_tracer(jn)%clsname
-         ctrcnl(jn) = sn_tracer(jn)%cllname
-         ctrcun(jn) = sn_tracer(jn)%clunit
-         lutini(jn) = sn_tracer(jn)%llinit
-         lutsav(jn) = sn_tracer(jn)%llsave
+         ctrcnm(jn) = TRIM( sn_tracer(jn)%clsname )
+         ctrcnl(jn) = TRIM( sn_tracer(jn)%cllname )
+         ctrcun(jn) = TRIM( sn_tracer(jn)%clunit  )
+         lutini(jn) =       sn_tracer(jn)%llinit 
+         lutsav(jn) =       sn_tracer(jn)%llsave
       END DO
 
@@ -121,7 +120,7 @@
          DO jn = 1, jptra
             WRITE(numout,*) '   tracer nb             : ', jn 
-            WRITE(numout,*) '   short name            : ', TRIM(ctrcnm(jn))
-            WRITE(numout,*) '   long name             : ', TRIM(ctrcnl(jn))
-            WRITE(numout,*) '   unit                  : ', TRIM(ctrcun(jn))
+            WRITE(numout,*) '   short name            : ', ctrcnm(jn)
+            WRITE(numout,*) '   long name             : ', ctrcnl(jn)
+            WRITE(numout,*) '   unit                  : ', ctrcun(jn)
             WRITE(numout,*) '   initial value in FILE : ', lutini(jn) 
             WRITE(numout,*) ' '
Index: trunk/NEMOGCM/NEMO/TOP_SRC/trcrst.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/trcrst.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/trcrst.F90	(revision 2715)
@@ -26,6 +26,4 @@
    USE trc
    USE trcnam_trp
-   USE lib_mpp
-   USE lib_fortran
    USE iom
    USE trcrst_cfc      ! CFC      
Index: trunk/NEMOGCM/NEMO/TOP_SRC/trcsms.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/trcsms.F90	(revision 2568)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/trcsms.F90	(revision 2715)
@@ -30,7 +30,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
