Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 2607)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 2608)
@@ -590,4 +590,7 @@
      USE trcdta,       ONLY: trc_dta_alloc
 #endif
+#if   defined key_top && ( defined key_trdmld_trc   ||   defined key_esopa )
+     USE trdmld_trc,   ONLY: trd_mld_trc_alloc
+#endif
      ! ...end of TOP-related alloc routines
 
@@ -762,4 +765,7 @@
 #if  defined key_top  &&  defined key_dtatrc
      ierr = ierr + trc_dta_alloc()
+#endif
+#if   defined key_top && ( defined key_trdmld_trc   ||   defined key_esopa )
+     ierr = ierr + trd_mld_trc_alloc()
 #endif
      ! ...end of TOP-related alloc routines
Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 2607)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 2608)
@@ -74,11 +74,18 @@
       !! ** Method  : - Update the tracer with the advection term following nadv
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_use, wrk_release
+      USE wrk_nemo, ONLY: zun => wrk_3d_1, zvn => wrk_3d_2, &
+                          zwn => wrk_3d_3   ! 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
       !!----------------------------------------------------------------------
+
+      IF(.NOT. wrk_use(3, 1,2,3))THEN
+         CALL ctl_stop('trc_adv : requested workspace arrays unavailable.')
+         RETURN
+      END IF
 
       IF( kt == nit000 )   CALL trc_adv_ctl          ! initialisation & control of options
@@ -141,4 +148,8 @@
          WRITE(charout, FMT="('adv ')")  ;  CALL prt_ctl_trc_info(charout)
                                             CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
+      END IF
+      !
+      IF(.NOT. wrk_release(3, 1,2,3))THEN
+         CALL ctl_stop('trc_adv : failed to release workspace arrays.')
       END IF
       !
Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 2607)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 2608)
@@ -60,4 +60,6 @@
       !!
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_use, wrk_release
+      USE wrk_nemo, zemps => wrk_2d_1
       !! * Arguments
       INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
@@ -66,8 +68,12 @@
       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(.NOT. wrk_use(2, 1))THEN
+         CALL ctl_stop('trc_sbc: requested workspace array unavailable.')
+         RETURN
+      END IF
 
       IF( kt == nit000 ) THEN
@@ -120,4 +126,8 @@
       ENDIF
 
+      IF(.NOT. wrk_release(2, 1))THEN
+         CALL ctl_stop('trc_sbc: failed to release workspace array.')
+      END IF
+
    END SUBROUTINE trc_sbc
 
Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 2607)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 2608)
@@ -39,4 +39,5 @@
 
    PUBLIC trd_mld_trc
+   PUBLIC trd_mld_trc_alloc
    PUBLIC trd_mld_bio
    PUBLIC trd_mld_trc_init
@@ -58,4 +59,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"
@@ -67,4 +75,24 @@
 
 CONTAINS
+
+   FUNCTION trd_mld_trc_alloc
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld_trc_alloc  ***
+      !!----------------------------------------------------------------------
+      INTEGER :: trd_mld_trc_alloc
+      !!----------------------------------------------------------------------
+
+      ALLOCATE(ztmltrd2(jpi,jpj,jpltrd_trc,jptra), &
+#if defined key_lobster
+               ztmltrdbio2(jpi,jpj,jpdiabio)     , &
+#endif
+               Stat=trd_mld_trc_alloc)
+
+      IF(trd_mld_trc_alloc/=0)THEN
+         CALL ctl_warn('trd_mld_trc_alloc : failed to allocate arrays.')
+      END IF
+
+   END FUNCTION trd_mld_trc_alloc
+
 
    SUBROUTINE trd_mld_trc_zint( ptrc_trdmld, ktrd, ctype, kjn )
@@ -88,10 +116,17 @@
       !!            surface and the control surface is called "mixed-layer"
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_use, wrk_release
+      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(.NOT. wrk_use(2, 1))THEN
+         CALL ctl_stop('trd_mld_trc_zint : requested workspace array unavailable.')
+         RETURN
+      END IF
 
       ! I. Definition of control surface and integration weights
@@ -178,4 +213,8 @@
       END SELECT
 
+      IF(.NOT. wrk_release(2, 1))THEN
+         CALL ctl_stop('trd_mld_trc_zint : failed to release workspace array.')
+      END IF
+
     END SUBROUTINE trd_mld_trc_zint
     
@@ -198,4 +237,7 @@
       !!            surface and the control surface is called "mixed-layer"
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_use, wrk_release
+      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
@@ -203,6 +245,10 @@
       !! local variables
       INTEGER ::   ji, jj, jk, isum
-      REAL(wp), DIMENSION(jpi,jpj) ::  zvlmsk
-      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+
+      IF(.NOT. wrk_use(2, 1))THEN
+         CALL ctl_stop('trd_mld_bio_zint : requested workspace array unavailable.')
+         RETURN
+      END IF
 
       ! I. Definition of control surface and integration weights
@@ -286,4 +332,7 @@
       END DO
 
+      IF(.NOT. wrk_release(2, 1))THEN
+         CALL ctl_stop('trd_mld_bio_zint : failed to release workspace array.')
+      END IF
 #endif
 
@@ -338,19 +387,23 @@
       !!       - See NEMO documentation (in preparation)
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY: wrk_use, wrk_release
+      USE wrk_nemo, wrk_3d_1, wrk_3d_2, wrk_3d_3, wrk_3d_4, &
+                    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
@@ -360,4 +413,20 @@
 #endif
       !!----------------------------------------------------------------------
+
+      IF(.NOT. wrk_use(3, 1,2,3,4,5,6,7,8,9))THEN
+         CALL ctl_stop('trd_mld_trc : requested workspace arrays unavailable.')
+         RETURN
+      END IF
+      ! 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 " )
@@ -847,4 +916,8 @@
       IF( lrst_trc )   CALL trd_mld_trc_rst_write( kt )  ! this must be after the array swap above (III.3)
 
+      IF(.NOT. wrk_release(3, 1,2,3,4,5,6,7,8,9))THEN
+         CALL ctl_stop('trd_mld_trc : failed to release workspace arrays.')
+      END IF
+      !
    END SUBROUTINE trd_mld_trc
 
@@ -900,5 +973,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
