Index: trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsed.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsed.F90	(revision 2773)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsed.F90	(revision 2774)
@@ -370,17 +370,20 @@
       !!
       !!----------------------------------------------------------------------
-
+      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY: zriverdoc => wrk_2d_1, zriver => wrk_2d_2, zndepo => wrk_2d_3
+      USE wrk_nemo, ONLY: zcmask => wrk_3d_2
+      !
       INTEGER :: ji, jj, jk, jm
       INTEGER :: numriv, numbath, numdep
-
-
       REAL(wp) ::   zcoef
       REAL(wp) ::   expide, denitide,zmaskt
-      REAL(wp) , DIMENSION (jpi,jpj)     ::   riverdoc, river, ndepo
-      REAL(wp) , DIMENSION (jpi,jpj,jpk) ::   cmask
-
+      !
       NAMELIST/nampissed/ ln_dustfer, ln_river, ln_ndepo, ln_sedinput, sedfeinput, dustsolub
-
-
+      !!----------------------------------------------------------------------
+
+      IF( ( wrk_in_use(2, 1,2,3) ) .OR. ( wrk_in_use(3, 2) ) ) THEN
+         CALL ctl_stop('p4z_sed_init: requested workspace arrays unavailable')  ;  RETURN
+      END IF
+      !
       REWIND( numnat )                     ! read numnat
       READ  ( numnat, nampissed )
@@ -419,10 +422,10 @@
          IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          CALL iom_open ( 'river.orca.nc', numriv )
-         CALL iom_get  ( numriv, jpdom_data, 'riverdic', river   (:,:), jpyr )
-         CALL iom_get  ( numriv, jpdom_data, 'riverdoc', riverdoc(:,:), jpyr )
+         CALL iom_get  ( numriv, jpdom_data, 'riverdic', zriver   (:,:), jpyr )
+         CALL iom_get  ( numriv, jpdom_data, 'riverdoc', zriverdoc(:,:), jpyr )
          CALL iom_close( numriv )
       ELSE
-         river   (:,:) = 0.e0
-         riverdoc(:,:) = 0.e0
+         zriver   (:,:) = 0.e0
+         zriverdoc(:,:) = 0.e0
       endif
 
@@ -433,8 +436,8 @@
          IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          CALL iom_open ( 'ndeposition.orca.nc', numdep )
-         CALL iom_get  ( numdep, jpdom_data, 'ndep', ndepo(:,:), jpyr )
+         CALL iom_get  ( numdep, jpdom_data, 'ndep', zndepo(:,:), jpyr )
          CALL iom_close( numdep )
       ELSE
-         ndepo(:,:) = 0.e0
+         zndepo(:,:) = 0.e0
       ENDIF
 
@@ -446,5 +449,5 @@
          IF(lwp) WRITE(numout,*) '       from bathy.orca.nc file '
          CALL iom_open ( 'bathy.orca.nc', numbath )
-         CALL iom_get  ( numbath, jpdom_data, 'bathy', cmask(:,:,:), jpyr )
+         CALL iom_get  ( numbath, jpdom_data, 'bathy', zcmask(:,:,:), jpyr )
          CALL iom_close( numbath )
          !
@@ -455,5 +458,5 @@
                      zmaskt = tmask(ji+1,jj,jk) * tmask(ji-1,jj,jk) * tmask(ji,jj+1,jk)    &
                         &                       * tmask(ji,jj-1,jk) * tmask(ji,jj,jk+1)
-                     IF( zmaskt == 0. )   cmask(ji,jj,jk ) = MAX( 0.1, cmask(ji,jj,jk) ) 
+                     IF( zmaskt == 0. )   zcmask(ji,jj,jk ) = MAX( 0.1, zcmask(ji,jj,jk) ) 
                   ENDIF
                END DO
@@ -465,13 +468,13 @@
                   expide   = MIN( 8.,( fsdept(ji,jj,jk) / 500. )**(-1.5) )
                   denitide = -0.9543 + 0.7662 * LOG( expide ) - 0.235 * LOG( expide )**2
-                  cmask(ji,jj,jk) = cmask(ji,jj,jk) * MIN( 1., EXP( denitide ) / 0.5 )
+                  zcmask(ji,jj,jk) = zcmask(ji,jj,jk) * MIN( 1., EXP( denitide ) / 0.5 )
                END DO
             END DO
          END DO
       ELSE
-         cmask(:,:,:) = 0.e0
+         zcmask(:,:,:) = 0.e0
       ENDIF
 
-      CALL lbc_lnk( cmask , 'T', 1. )      ! Lateral boundary conditions on cmask   (sign unchanged)
+      CALL lbc_lnk( zcmask , 'T', 1. )      ! Lateral boundary conditions on zcmask   (sign unchanged)
 
 
@@ -496,7 +499,7 @@
          DO ji = 1, jpi
             zcoef = ryyss * e1e2t(ji,jj)  * fse3t(ji,jj,1) * tmask(ji,jj,1) 
-            cotdep(ji,jj) =  river(ji,jj)                  *1E9 / ( 12. * zcoef + rtrn )
-            rivinp(ji,jj) = (river(ji,jj)+riverdoc(ji,jj)) *1E9 / ( 31.6* zcoef + rtrn )
-            nitdep(ji,jj) = 7.6 * ndepo(ji,jj)                  / ( 14E6*ryyss*fse3t(ji,jj,1) + rtrn )
+            cotdep(ji,jj) =  zriver(ji,jj)                  *1E9 / ( 12. * zcoef + rtrn )
+            rivinp(ji,jj) = (zriver(ji,jj)+zriverdoc(ji,jj)) *1E9 / ( 31.6* zcoef + rtrn )
+            nitdep(ji,jj) = 7.6 * zndepo(ji,jj)                  / ( 14E6*ryyss*fse3t(ji,jj,1) + rtrn )
          END DO
       END DO
@@ -512,8 +515,10 @@
       ! -------------------------
       DO jk = 1, jpkm1
-         ironsed(:,:,jk) = sedfeinput * cmask(:,:,jk) / ( fse3t(:,:,jk) * rday )
+         ironsed(:,:,jk) = sedfeinput * zcmask(:,:,jk) / ( fse3t(:,:,jk) * rday )
       END DO
       CALL lbc_lnk( ironsed , 'T', 1. )      ! Lateral boundary conditions on ( ironsed )   (sign unchanged)
 
+      IF( ( wrk_not_released(2, 1,2,3) ) .OR. ( wrk_not_released(3, 2) ) )   &
+        &         CALL ctl_stop('p4z_sed_init: failed to release workspace arrays')
 
    END SUBROUTINE p4z_sed_init
