Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv.F90	(revision 3155)
@@ -25,4 +25,5 @@
    USE prtctl          ! Print control
    USE iom             ! I/O library
+   USE wrk_nemo_2      ! work arrays
 
    IMPLICIT NONE
@@ -53,17 +54,12 @@
       !!             - wslpi, wslpj : i- and j-slopes of neutral surfaces at w-points. 
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:   zn  => wrk_2d_1 , zah   => wrk_2d_2   ! 2D workspace
-      USE wrk_nemo, ONLY:   zhw => wrk_2d_3 , zross => wrk_2d_4
-      !
       INTEGER, INTENT(in) ::   kt   ! ocean time-step inedx
       !
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   zfw, ze3w, zn2, zf20, zaht, zaht_min      ! temporary scalars
+      REAL(wp), DIMENSION(:,:), POINTER ::   zn, zah, zhw, zross   ! 2D workspace
       !!----------------------------------------------------------------------
       
-      IF( wrk_in_use(2, 1,2,3,4) ) THEN
-         CALL ctl_stop('ldf_eiv: requested workspace arrays are unavailable.')   ;   RETURN
-      ENDIF
+      CALL wrk_alloc( jpi,jpj, zn, zah, zhw, zross )
 
       IF( kt == nit000 ) THEN
@@ -243,5 +239,5 @@
       CALL iom_put( "aht2d_eiv", aeiw )   ! EIV lateral eddy diffusivity
       !  
-      IF( wrk_not_released(2, 1,2,3,4) )   CALL ctl_stop('ldf_eiv: failed to release workspace arrays')
+      CALL wrk_dealloc( jpi,jpj, zn, zah, zhw, zross )
       !
    END SUBROUTINE ldf_eiv
Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 3155)
@@ -31,4 +31,5 @@
    USE in_out_manager  ! I/O manager
    USE prtctl          ! Print control
+   USE wrk_nemo_2      ! work arrays
 
    IMPLICIT NONE
@@ -56,10 +57,4 @@
 
    REAL(wp) ::   repsln = 1.e-25_wp       ! tiny value used as minium of di(rho), dj(rho) and dk(rho)
-
-   ! Workspace arrays for ldf_slp_grif. These could be replaced by several 3D and 2D workspace
-   ! arrays from the wrk_nemo module with a bit of code re-writing. The 4D workspace
-   ! arrays can't be used here because of the zero-indexing of some of the ranks. ARPDBG.
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   zdzrho , zdyrho, zdxrho     ! Horizontal and vertical density gradients
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   zti_mlb, ztj_mlb            ! for Griffies operator only
 
    !! * Substitutions
@@ -74,19 +69,4 @@
    !!----------------------------------------------------------------------
 CONTAINS
-
-   INTEGER FUNCTION ldf_slp_alloc()
-      !!----------------------------------------------------------------------
-      !!              ***  FUNCTION ldf_slp_alloc  ***
-      !!----------------------------------------------------------------------
-      !
-      ALLOCATE( zdxrho (jpi,jpj,jpk,0:1) , zti_mlb(jpi,jpj,0:1,0:1) ,     &
-         &      zdyrho (jpi,jpj,jpk,0:1) , ztj_mlb(jpi,jpj,0:1,0:1) ,     &
-         &      zdzrho (jpi,jpj,jpk,0:1)                            , STAT=ldf_slp_alloc )
-         !
-      IF( lk_mpp             )   CALL mpp_sum ( ldf_slp_alloc )
-      IF( ldf_slp_alloc /= 0 )   CALL ctl_warn('ldf_slp_alloc : failed to allocate arrays.')
-      !
-   END FUNCTION ldf_slp_alloc
-
 
    SUBROUTINE ldf_slp( kt, prd, pn2 )
@@ -115,8 +95,6 @@
       !!               of now neutral surfaces at u-, w- and v- w-points, resp.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
       USE oce     , ONLY:   zwz => ua       , zww => va   ! (ua,va) used as workspace
       USE oce     , ONLY:   tsa                           ! (tsa) used as workspace
-      USE wrk_nemo, ONLY:   zdzr => wrk_3d_1              ! 3D workspace
       !!
       INTEGER , INTENT(in)                   ::   kt    ! ocean time-step index
@@ -131,10 +109,8 @@
       REAL(wp) ::   zcj, zfj, zav, zbv, zaj, zbj   !   -      -
       REAL(wp) ::   zck, zfk,      zbw             !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zgru, zgrv
-      !!----------------------------------------------------------------------
-
-      IF( wrk_in_use(3, 1) ) THEN
-         CALL ctl_stop('ldf_slp: requested workspace arrays are unavailable')   ;   RETURN
-      ENDIF
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zgru, zgrv, zdzr
+      !!----------------------------------------------------------------------
+
+      CALL wrk_alloc( jpi,jpj,jpk, zdzr )
       !
       zgru => tsa(:,:,:,1)
@@ -386,5 +362,5 @@
       ENDIF
       !
-      IF( wrk_not_released(3, 1) )  CALL ctl_stop('ldf_slp: failed to release workspace arrays.')
+      CALL wrk_dealloc( jpi,jpj,jpk, zdzr )
       !
    END SUBROUTINE ldf_slp
@@ -405,7 +381,5 @@
       !!             - wslp2              squared slope of neutral surfaces at w-points.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
       USE oce     , ONLY:   zalbet  => ua       ! use ua as workspace
-      USE wrk_nemo, ONLY:   z1_mlbw => wrk_2d_1
       !!
       INTEGER, INTENT( in ) ::   kt             ! ocean time-step index
@@ -420,9 +394,12 @@
       REAL(wp) ::   zdzrho_raw
       REAL(wp) ::   zbeta0
-      !!----------------------------------------------------------------------
-
-      IF( wrk_in_use(4, 1,2,3) .OR. wrk_in_use(3, 2,3) .OR. wrk_in_use(2, 1) ) THEN
-         CALL ctl_stop('ldf_slp_grif: ERROR: requested workspace arrays are unavailable.')   ;   RETURN
-      END IF
+      REAL(wp), POINTER, DIMENSION(:,:)     ::   z1_mlbw
+      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   zdxrho , zdyrho, zdzrho     ! Horizontal and vertical density gradients
+      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   zti_mlb, ztj_mlb            ! for Griffies operator only
+      !!----------------------------------------------------------------------
+      
+      CALL wrk_alloc( jpi,jpj, z1_mlbw )
+      CALL wrk_alloc( jpi,jpj,jpk,2, zdxrho , zdyrho, zdzrho,              klstart = 0  )
+      CALL wrk_alloc( jpi,jpj,  2,2, zti_mlb, ztj_mlb,        kkstart = 0, klstart = 0  )
       !
       !--------------------------------!
@@ -616,7 +593,7 @@
       CALL lbc_lnk( wslp2, 'W', 1. )      ! lateral boundary confition on wslp2 only   ==>>> gm : necessary ? to be checked
       !
-      IF( wrk_not_released(4, 1,2,3) .OR.   &
-          wrk_not_released(3, 2,3  ) .OR.   &
-          wrk_not_released(2, 1    )        )   CALL ctl_stop('ldf_slp_grif: ERROR: failed to release workspace arrays.')
+      CALL wrk_dealloc( jpi,jpj, z1_mlbw )
+      CALL wrk_dealloc( jpi,jpj,jpk,2, zdxrho , zdyrho, zdzrho,              klstart = 0  )
+      CALL wrk_dealloc( jpi,jpj,  2,2, zti_mlb, ztj_mlb,        kkstart = 0, klstart = 0  )
       !
    END SUBROUTINE ldf_slp_grif
@@ -768,5 +745,4 @@
          ALLOCATE( triadi  (jpi,jpj,jpk,0:1,0:1) , triadj  (jpi,jpj,jpk,0:1,0:1)                      , STAT=ierr )
          IF( ierr > 0             )   CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate Griffies operator slope' )
-         IF( ldf_slp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate workspace arrays' )
          !
          IF( ln_dynldf_iso )   CALL ctl_stop( 'ldf_slp_init: Griffies operator on momentum not supported' )
Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 3155)
@@ -21,5 +21,6 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE prtctl          ! Print control
-   USE lib_mpp            ! MPP library
+   USE lib_mpp         ! MPP library
+   USE wrk_nemo_2      ! work arrays
 
    IMPLICIT NONE
@@ -91,8 +92,4 @@
       !! References :   Merryfield et al., JPO, 29, 1124-1142, 1999.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:   zmsks  => wrk_2d_1 , zmskf  => wrk_2d_2 , zmskd1 => wrk_2d_3   ! 2D workspace
-      USE wrk_nemo, ONLY:   zmskd2 => wrk_2d_4 , zmskd3 => wrk_2d_5                        !  -      -
-      !
       INTEGER, INTENT(in) ::   kt   ! ocean time-step indexocean time step
       !
@@ -101,9 +98,8 @@
       REAL(wp) ::   zavft, zavfs    !    -         -
       REAL(wp) ::   zavdt, zavds    !    -         -
-      !!----------------------------------------------------------------------
-
-      IF( wrk_in_use(2, 1,2,3,4,5) ) THEN
-         CALL ctl_stop('zdf_ddm: Requested workspace arrays already in use')   ;   RETURN
-      ENDIF
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zmsks, zmskf, zmskd1, zmskd2, zmskd3
+      !!----------------------------------------------------------------------
+
+      CALL wrk_alloc( jpi,jpj, zmsks, zmskf, zmskd1, zmskd2, zmskd3 )
 
       !                                                ! ===============
@@ -197,5 +193,5 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 1,2,3,4,5) )   CALL ctl_stop('zdf_ddm: Release of workspace arrays failed')
+      CALL wrk_dealloc( jpi,jpj, zmsks, zmskf, zmskd1, zmskd2, zmskd3 )
       !
    END SUBROUTINE zdf_ddm
Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90	(revision 3155)
@@ -26,4 +26,5 @@
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp        ! MPP manager
+   USE wrk_nemo_2     ! work arrays
    USE prtctl         ! Print control
    USE in_out_manager ! I/O manager
@@ -134,13 +135,4 @@
       USE oce     , ONLY: z_elem_a  =>   ua   ! use ua as workspace
       USE oce     , ONLY: z_elem_b  =>   va   ! use va as workspace
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zdep      => wrk_2d_1
-      USE wrk_nemo, ONLY: zflxs     => wrk_2d_2     ! Turbulence fluxed induced by internal waves 
-      USE wrk_nemo, ONLY: zhsro     => wrk_2d_3     ! Surface roughness (surface waves)
-      USE wrk_nemo, ONLY: eb        => wrk_3d_1   ! tke at time before
-      USE wrk_nemo, ONLY: mxlb      => wrk_3d_2   ! mixing length at time before
-      USE wrk_nemo, ONLY: shear     => wrk_3d_3   ! vertical shear
-      USE wrk_nemo, ONLY: eps       => wrk_3d_4   ! dissipation rate
-      USE wrk_nemo, ONLY: zwall_psi => wrk_3d_5   ! Wall function use in the wb case (ln_sigpsi.AND.ln_crban=T)
       !
       INTEGER, INTENT(in) ::   kt ! ocean time step
@@ -151,10 +143,17 @@
       REAL(wp) ::   prod, buoy, diss, zdiss, sm         !   -      -
       REAL(wp) ::   gh, gm, shr, dif, zsqen, zav        !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: z_elem_c, psi
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zdep
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zflxs       ! Turbulence fluxed induced by internal waves 
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zhsro       ! Surface roughness (surface waves)
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   eb          ! tke at time before
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   mxlb        ! mixing length at time before
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   shear       ! vertical shear
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   eps         ! dissipation rate
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zwall_psi   ! Wall function use in the wb case (ln_sigpsi.AND.ln_crban=T)
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   z_elem_c, psi
       !!--------------------------------------------------------------------
 
-      IF(  wrk_in_use(2, 1,2,3)  .OR.  wrk_in_use(3, 1,2,3,4,5)  ) THEN
-         CALL ctl_stop('zdf_gls: requested workspace arrays unavailable.')   ;   RETURN
-      END IF
+      CALL wrk_alloc( jpi,jpj, zdep, zflxs, zhsro )
+      CALL wrk_alloc( jpi,jpj,jpk, eb, mxlb, shear, eps, zwall_psi )
       !
       z_elem_c  => tsa(:,:,:,1)
@@ -265,5 +264,6 @@
                IF( ln_sigpsi ) THEN
                   zsigpsi = MIN( 1._wp, zesh2 / eps(ji,jj,jk) )     ! 0. <= zsigpsi <= 1.
-                  zwall_psi(ji,jj,jk) = rsc_psi / (  zsigpsi * rsc_psi + (1._wp-zsigpsi) * rsc_psi0 / MAX( zwall(ji,jj,jk), 1._wp )  )
+                  zwall_psi(ji,jj,jk) = rsc_psi /   & 
+                     &     (  zsigpsi * rsc_psi + (1._wp-zsigpsi) * rsc_psi0 / MAX( zwall(ji,jj,jk), 1._wp )  )
                ELSE
                   zwall_psi(ji,jj,jk) = 1._wp
@@ -886,6 +886,6 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 1,2,3)     .OR. &
-          wrk_not_released(3, 1,2,3,4,5)  )   CALL ctl_stop('zdf_gls: failed to release workspace arrays')
+      CALL wrk_dealloc( jpi,jpj, zdep, zflxs, zhsro )
+      CALL wrk_dealloc( jpi,jpj,jpk, eb, mxlb, shear, eps, zwall_psi )
       !
    END SUBROUTINE zdf_gls
Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 3155)
@@ -29,4 +29,5 @@
    USE in_out_manager  ! I/O manager
    USE lib_mpp         ! MPP library
+   USE wrk_nemo_2      ! work arrays
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE prtctl          ! Print control
@@ -208,22 +209,4 @@
       USE oce     , zviscos => ua   ! temp. array for viscosities use ua as workspace
       USE oce     , zdiffut => va   ! temp. array for diffusivities use sa as workspace
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, wrk_in_use_xz, wrk_not_released_xz
-      USE wrk_nemo, ONLY: zBo    => wrk_2d_1, &  ! Surface buoyancy forcing,
-                          zBosol => wrk_2d_2, &  ! friction velocity
-                          zustar => wrk_2d_3
-      USE wrk_nemo, ONLY: zmask  => wrk_2d_4
-!gm      USE wrk_nemo, ONLY: wrk_2d_5, wrk_2d_6, wrk_2d_7, wrk_2d_8, wrk_2d_9, &
-      USE wrk_nemo, ONLY:           wrk_2d_6, wrk_2d_7, wrk_2d_8, wrk_2d_9, &
-                          wrk_2d_10,wrk_2d_11
-      USE wrk_nemo, ONLY: wrk_1d_1,  wrk_1d_2,  wrk_1d_3,  wrk_1d_4,  &
-                          wrk_1d_5,  wrk_1d_6,  wrk_1d_7,  wrk_1d_8,  &
-                          wrk_1d_9,  wrk_1d_10, wrk_1d_11, wrk_1d_12, &
-                          wrk_1d_13, wrk_1d_14
-      USE wrk_nemo, ONLY: zblcm => wrk_xz_1, &   ! Boundary layer 
-                          zblct => wrk_xz_2      !  diffusivities/viscosities
-#if defined key_zdfddm
-      USE wrk_nemo, ONLY: zdiffus => wrk_3d_1
-      USE wrk_nemo, ONLY: zblcs   => wrk_xz_3
-#endif
       !!
       INTEGER, INTENT( in  ) ::   kt   ! ocean time step
@@ -250,6 +233,5 @@
       REAL(wp) ::   zflag, ztemp, zrn2, zdep21, zdep32, zdep43
       REAL(wp) ::   zdku2, zdkv2, ze3sqr, zsh2, zri, zfri          ! Interior richardson mixing
-!gm      REAL(wp), POINTER, DIMENSION(:,:) ::   zmoek                 ! Moning-Obukov limitation
-      REAL(wp), DIMENSION(jpi,0:2) ::   zmoek                 ! Moning-Obukov limitation
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zmoek                 ! Moning-Obukov limitation
       REAL(wp), POINTER, DIMENSION(:)   ::   zmoa, zekman                
       REAL(wp)                          ::   zmob, zek
@@ -266,37 +248,24 @@
       REAL(wp), POINTER, DIMENSION(:)   ::   za2s, za3s, zkmps
       REAL(wp) ::                            zkm1s
-#endif
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zblcs
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zdiffus
+#endif
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zBo, zBosol, zustar         ! Surface buoyancy forcing, friction velocity
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zmask, zblcm, zblct
       !!--------------------------------------------------------------------
      
-      IF( wrk_in_use(1, 1,2,3,4,5,6,7,8,9,10,11,12,13,14) .OR.   &
-          wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10,11)          .OR.   &
-          wrk_in_use(3, 1)                                .OR. &
-          wrk_in_use_xz(1,2,3)                              ) THEN
-         CALL ctl_stop('zdf_kpp : requested workspace arrays unavailable.')   ;   RETURN
-      ENDIF
-      ! Set-up pointers to 2D spaces
-!gm      zmoek(1:jpi,0:2) => wrk_2d_5(1:jpi,1:3)
-      zdepw => wrk_2d_6(:,1:4)
-      zdift => wrk_2d_7(:,1:4)
-      zvisc => wrk_2d_8(:,1:4)
-      zdept => wrk_2d_9(:,1:3)
-      zriblk => wrk_2d_10(:,1:2)
-      ! 1D spaces
-      zmoa   => wrk_1d_1(1:jpi)
-      zekman => wrk_1d_2(1:jpi)
-      zhmax  => wrk_1d_3(1:jpi)
-      zria   => wrk_1d_4(1:jpi)
-      zhbl   => wrk_1d_5(1:jpi)
-      za2m   => wrk_1d_6(1:jpi)
-      za3m   => wrk_1d_7(1:jpi)
-      zkmpm  => wrk_1d_8(1:jpi)
-      za2t   => wrk_1d_9(1:jpi)
-      za3t   => wrk_1d_10(1:jpi)
-      zkmpt  => wrk_1d_11(1:jpi)
+      CALL wrk_alloc( jpi, zmoa, zekman, zhmax, zria, zhbl )
+      CALL wrk_alloc( jpi, za2m, za3m, zkmpm, za2t, za3t, zkmpt )
+      CALL wrk_alloc( jpi,2, zriblk )
+      CALL wrk_alloc( jpi,3, zmoek, kjstart = 0 )
+      CALL wrk_alloc( jpi,3, zdept )
+      CALL wrk_alloc( jpi,4, zdepw, zdift, zvisc )
+      CALL wrk_alloc( jpi,jpj, zBo, zBosol, zustar )
+      CALL wrk_alloc( jpi,jpk, zmask, zblcm, zblct, zblcs )
 #if defined key_zdfddm
-      zdifs => wrk_2d_11(:,1:4)
-      za2s  => wrk_1d_12(1:jpi)
-      za3s  => wrk_1d_13(1:jpi)
-      zkmps => wrk_1d_14(1:jpi)
+      CALL wrk_alloc( jpi,4, zdifs )
+      CALL wrk_alloc( jpi, zmoa, za2s, za3s, zkmps )
+      CALL wrk_alloc( jpi,jpk, zblcs )
+      CALL wrk_alloc( jpi,jpi,jpk, zdiffus )
 #endif
 
@@ -1230,8 +1199,18 @@
          ENDIF
 
-      IF( wrk_not_released(1, 1,2,3,4,5,6,7,8,9,10,11,12,13,14) .OR. &
-          wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10,11)          .OR. &
-          wrk_not_released(3, 1)                                .OR. &
-          wrk_not_released_xz(1,2,3)  )   CALL ctl_stop('zdf_kpp : failed to release workspace arrays')
+      CALL wrk_dealloc( jpi, zmoa, zekman, zhmax, zria, zhbl )
+      CALL wrk_dealloc( jpi, za2m, za3m, zkmpm, za2t, za3t, zkmpt )
+      CALL wrk_dealloc( jpi,2, zriblk )
+      CALL wrk_dealloc( jpi,3, zmoek, kjstart = 0 )
+      CALL wrk_dealloc( jpi,3, zdept )
+      CALL wrk_dealloc( jpi,4, zdepw, zdift, zvisc )
+      CALL wrk_dealloc( jpi,jpj, zBo, zBosol, zustar )
+      CALL wrk_dealloc( jpi,jpk, zmask, zblcm, zblct, zblcs )
+#if defined key_zdfddm
+      CALL wrk_dealloc( jpi,4, zdifs )
+      CALL wrk_dealloc( jpi, zmoa, za2s, za3s, zkmps )
+      CALL wrk_dealloc( jpi,jpk, zblcs )
+      CALL wrk_dealloc( jpi,jpi,jpk, zdiffus )
+#endif
       !
    END SUBROUTINE zdf_kpp
Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 3155)
@@ -16,4 +16,5 @@
    USE iom             ! I/O library
    USE lib_mpp         ! MPP library
+   USE wrk_nemo_2      ! work arrays
    USE trc_oce, ONLY : lk_offline ! offline flag
 
@@ -69,18 +70,14 @@
       !! ** Action  :   nmln, hmld, hmlp, hmlpt
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY:   iwrk_in_use, iwrk_not_released
-      USE wrk_nemo, ONLY:   imld => iwrk_2d_1    ! 2D integer workspace
-      !!
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
       !!
       INTEGER  ::   ji, jj, jk          ! dummy loop indices
       INTEGER  ::   iikn, iiki          ! temporary integer within a do loop
+      INTEGER, POINTER, DIMENSION(:,:) ::   imld                ! temporary workspace
       REAL(wp) ::   zrho_c = 0.01_wp    ! density criterion for mixed layer depth
       REAL(wp) ::   zavt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth
       !!----------------------------------------------------------------------
 
-      IF( iwrk_in_use(2, 1) ) THEN
-         CALL ctl_stop('zdf_mxl : requested workspace array unavailable')   ;   RETURN
-      ENDIF
+      CALL wrk_alloc( jpi,jpj, imld )
 
       IF( kt == nit000 ) THEN
@@ -120,5 +117,5 @@
       IF(ln_ctl)   CALL prt_ctl( tab2d_1=REAL(nmln,wp), clinfo1=' nmln : ', tab2d_2=hmlp, clinfo2=' hmlp : ', ovlap=1 )
       !
-      IF( iwrk_not_released(2, 1) )   CALL ctl_stop('zdf_mxl: failed to release workspace array')
+      CALL wrk_dealloc( jpi,jpj, imld )
       !
    END SUBROUTINE zdf_mxl
Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 3155)
@@ -27,4 +27,5 @@
    USE lbclnk                ! ocean lateral boundary condition (or mpp link)
    USE lib_mpp               ! MPP library
+   USE wrk_nemo_2            ! work arrays
    USE eosbn2, ONLY : nn_eos
 
@@ -109,7 +110,4 @@
       !!              PFJ Lermusiaux 2001.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:   zwx => wrk_2d_1         ! 2D workspace
-      USE wrk_nemo, ONLY:   ekm_dep => wrk_2d_2     ! 2D workspace
       USE phycst,   ONLY:   rsmall,rau0
       USE sbc_oce,  ONLY:   taum
@@ -120,9 +118,8 @@
       REAL(wp) ::   zcoef, zdku, zdkv, zri, z05alp, zflageos  ! temporary scalars
       REAL(wp) ::   zrhos, zustar
-      !!----------------------------------------------------------------------
-
-      IF( wrk_in_use(2, 1,2) ) THEN
-         CALL ctl_stop('zdf_ric : requested workspace array unavailable')   ;   RETURN
-      ENDIF
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zwx, ekm_dep  
+      !!----------------------------------------------------------------------
+
+      CALL wrk_alloc( jpi,jpj, zwx, ekm_dep )
       !                                                ! ===============
       DO jk = 2, jpkm1                                 ! Horizontal slab
@@ -224,5 +221,5 @@
       CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )
       !
-      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('zdf_ric: failed to release workspace array')
+      CALL wrk_dealloc( jpi,jpj, zwx, ekm_dep )
       !
    END SUBROUTINE zdf_ric
Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 3155)
@@ -50,4 +50,5 @@
    USE iom            ! I/O manager library
    USE lib_mpp        ! MPP library
+   USE wrk_nemo_2     ! work arrays
 
    IMPLICIT NONE
@@ -190,10 +191,6 @@
       !!                (= Kz dz[Ub] * dz[Un] )
       !! ---------------------------------------------------------------------
-      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
       USE oce     , ONLY:   zdiag => ua          ! (ua,va) used  as workspace
       USE oce     , ONLY:   tsa                  ! (tsa) used  as workspace
-      USE wrk_nemo, ONLY:   imlc  => iwrk_2d_1   ! 2D INTEGER workspace
-      USE wrk_nemo, ONLY:   zhlc  =>  wrk_2d_1   ! 2D REAL workspace
-      USE wrk_nemo, ONLY:   zpelc =>  wrk_3d_1   ! 3D REAL workspace
       !!
       INTEGER  ::   ji, jj, jk                      ! dummy loop arguments
@@ -210,11 +207,12 @@
 !!bfr      REAL(wp) ::   zebot                           !    -         -
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zd_up, zd_lw
+      INTEGER , POINTER, DIMENSION(:,:  ) :: imlc
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zhlc
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zpelc
       !!--------------------------------------------------------------------
       !
-      IF( iwrk_in_use(2, 1) .OR.   &
-           wrk_in_use(2, 1) .OR.   &
-           wrk_in_use(3, 1)   ) THEN
-         CALL ctl_stop('tke_tke: requested workspace arrays unavailable')   ;   RETURN
-      END IF
+      CALL wrk_alloc( jpi,jpj, imlc )    ! integer
+      CALL wrk_alloc( jpi,jpj, zhlc ) 
+      CALL wrk_alloc( jpi,jpj,jpk, zpelc ) 
       !
       zd_up => tsa(:,:,:,1) 
@@ -434,7 +432,7 @@
       CALL lbc_lnk( en, 'W', 1. )      ! Lateral boundary conditions (sign unchanged)
       !
-      IF( iwrk_not_released(2 ,1) .OR.   &
-           wrk_not_released(2, 1) .OR.   &
-           wrk_not_released(3, 1)  )   CALL ctl_stop( 'tke_tke: failed to release workspace arrays' )
+      CALL wrk_dealloc( jpi,jpj, imlc )    ! integer
+      CALL wrk_dealloc( jpi,jpj, zhlc ) 
+      CALL wrk_dealloc( jpi,jpj,jpk, zpelc ) 
       !
    END SUBROUTINE tke_tke
Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90	(revision 3154)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90	(revision 3155)
@@ -25,4 +25,5 @@
    USE iom             ! I/O Manager
    USE lib_mpp         ! MPP library
+   USE wrk_nemo_2      ! work arrays
    USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
 
@@ -104,5 +105,4 @@
       !!----------------------------------------------------------------------
       USE oce, zav_tide  =>   ua    ! use ua as workspace
-      USE wrk_nemo, ONLY: zkz => wrk_2d_1
       !!
       INTEGER, INTENT(in) ::   kt   ! ocean time-step 
@@ -110,9 +110,9 @@
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   ztpc         ! scalar workspace
-      !!----------------------------------------------------------------------
-
-      IF(wrk_in_use(2, 1))THEN
-         CALL ctl_stop('zdf_tmx : requested workspace array unavailable.')   ;   RETURN
-      END IF
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zkz
+      !!----------------------------------------------------------------------
+
+      CALL wrk_alloc( jpi,jpj, zkz )
+
       !                          ! ----------------------- !
       !                          !  Standard tidal mixing  !  (compute zav_tide)
@@ -176,7 +176,5 @@
       IF(ln_ctl)   CALL prt_ctl(tab3d_1=zav_tide , clinfo1=' tmx - av_tide: ', tab3d_2=avt, clinfo2=' avt: ', ovlap=1, kdim=jpk)
       !
-      IF(wrk_not_released(2, 1))THEN
-         CALL ctl_stop('zdf_tmx : failed to release workspace array.')
-      END IF
+      CALL wrk_dealloc( jpi,jpj, zkz )
       !
    END SUBROUTINE zdf_tmx
@@ -203,10 +201,4 @@
       !! References :  Koch-Larrouy et al. 2007, GRL 
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: zkz => wrk_2d_5
-      USE wrk_nemo, ONLY: zsum1 => wrk_2d_2, zsum2 => wrk_2d_3, zsum => wrk_2d_4
-      USE wrk_nemo, ONLY: zempba_3d_1 => wrk_3d_1, zempba_3d_2 => wrk_3d_2
-      USE wrk_nemo, ONLY: zempba_3d   => wrk_3d_3, zdn2dz      => wrk_3d_4
-      USE wrk_nemo, ONLY: zavt_itf    => wrk_3d_5
-      !!
       INTEGER , INTENT(in   )                         ::   kt   ! ocean time-step
       REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pav  ! Tidal mixing coef.
@@ -214,10 +206,14 @@
       INTEGER  ::   ji, jj, jk    ! dummy loop indices
       REAL(wp) ::   zcoef, ztpc   ! temporary scalar
-      !!----------------------------------------------------------------------
-      !
-      IF( wrk_in_use(2, 2,3,4,5) .OR. wrk_in_use(3, 1,2,3,4,5) )THEN
-         CALL ctl_stop('tmx_itf : requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      REAL(wp), DIMENSION(:,:)  , POINTER ::   zkz                        ! 2D workspace
+      REAL(wp), DIMENSION(:,:)  , POINTER ::   zsum1 , zsum2 , zsum       !  -      -
+      REAL(wp), DIMENSION(:,:,:), POINTER ::   zempba_3d_1, zempba_3d_2   ! 3D workspace
+      REAL(wp), DIMENSION(:,:,:), POINTER ::   zempba_3d  , zdn2dz        !  -      -
+      REAL(wp), DIMENSION(:,:,:), POINTER ::   zavt_itf                   !  -      -
+      !!----------------------------------------------------------------------
+      !
+      CALL wrk_alloc( jpi,jpj, zkz, zsum1 , zsum2 , zsum )
+      CALL wrk_alloc( jpi,jpj,jpk, zempba_3d_1, zempba_3d_2, zempba_3d, zdn2dz, zavt_itf )
+
       !                             ! compute the form function using N2 at each time step
       zempba_3d_1(:,:,jpk) = 0.e0
@@ -304,8 +300,6 @@
       END DO
       !
-      IF( wrk_not_released(2, 2,3,4,5) .OR. &
-          wrk_not_released(3, 1,2,3,4,5) )THEN
-         CALL ctl_stop('tmx_itf : failed to release workspace arrays.')
-      END IF
+      CALL wrk_dealloc( jpi,jpj, zkz, zsum1 , zsum2 , zsum )
+      CALL wrk_dealloc( jpi,jpj,jpk, zempba_3d_1, zempba_3d_2, zempba_3d, zdn2dz, zavt_itf )
       !
    END SUBROUTINE tmx_itf
@@ -348,22 +342,20 @@
       !!----------------------------------------------------------------------
       USE oce     ,         zav_tide =>  ua         ! ua used as workspace
-      USE wrk_nemo, ONLY:   zem2     =>  wrk_2d_1   ! read M2 and 
-      USE wrk_nemo, ONLY:   zek1     =>  wrk_2d_2   ! K1 tidal energy
-      USE wrk_nemo, ONLY:   zkz      =>  wrk_2d_3   ! total M2, K1 and S2 tidal energy
-      USE wrk_nemo, ONLY:   zfact    =>  wrk_2d_4   ! used for vertical structure function
-      USE wrk_nemo, ONLY:   zhdep    =>  wrk_2d_5   ! Ocean depth 
-      USE wrk_nemo, ONLY:   zpc      =>  wrk_3d_1   ! power consumption
       !!
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       INTEGER  ::   inum         ! local integer
       REAL(wp) ::   ztpc, ze_z   ! local scalars
+      REAL(wp), DIMENSION(:,:)  , POINTER ::  zem2, zek1   ! read M2 and K1 tidal energy
+      REAL(wp), DIMENSION(:,:)  , POINTER ::  zkz          ! total M2, K1 and S2 tidal energy
+      REAL(wp), DIMENSION(:,:)  , POINTER ::  zfact        ! used for vertical structure function
+      REAL(wp), DIMENSION(:,:)  , POINTER ::  zhdep        ! Ocean depth 
+      REAL(wp), DIMENSION(:,:,:), POINTER ::  zpc      ! power consumption
       !!
       NAMELIST/namzdf_tmx/ rn_htmx, rn_n2min, rn_tfe, rn_me, ln_tmx_itf, rn_tfe_itf
       !!----------------------------------------------------------------------
 
-      IF( wrk_in_use(2, 1,2,3,4,5)  .OR.  wrk_in_use(3, 1)  ) THEN
-         CALL ctl_stop('zdf_tmx_init : requested workspace arrays unavailable.')   ;   RETURN
-      END IF
-
+      CALL wrk_alloc( jpi,jpj, zem2, zek1, zkz, zfact, zhdep )
+      CALL wrk_alloc( jpi,jpj,jpk, zpc )
+      
       REWIND( numnam )               ! Read Namelist namtmx : Tidal Mixing
       READ  ( numnam, namzdf_tmx )
@@ -526,6 +518,6 @@
       ENDIF
       !
-      IF(wrk_not_released(2, 1,2,3,4,5) .OR.   &
-         wrk_not_released(3, 1)          )   CALL ctl_stop( 'zdf_tmx_init : failed to release workspace arrays' )
+      CALL wrk_dealloc( jpi,jpj, zem2, zek1, zkz, zfact, zhdep )
+      CALL wrk_dealloc( jpi,jpj,jpk, zpc )
       !
    END SUBROUTINE zdf_tmx_init
