Index: trunk/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90
===================================================================
--- trunk/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 2528)
+++ trunk/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 2715)
@@ -34,9 +34,12 @@
    PRIVATE
 
-   PUBLIC   dom_msk    ! routine called by inidom.F90
+   PUBLIC   dom_msk         ! routine called by inidom.F90
+   PUBLIC   dom_msk_alloc   ! routine called by nemogcm.F90
 
    !                            !!* Namelist namlbc : lateral boundary condition *
    REAL(wp) ::   rn_shlat = 2.   ! type of lateral boundary condition on velocity
-   
+
+   INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  icoord ! Workspace for dom_msk_nsa()
+
    !! * Substitutions
 #  include "vectopt_loop_substitute.h90"
@@ -48,4 +51,17 @@
 CONTAINS
    
+   INTEGER FUNCTION dom_msk_alloc()
+      !!---------------------------------------------------------------------
+      !!                 ***  FUNCTION dom_msk_alloc  ***
+      !!---------------------------------------------------------------------
+      dom_msk_alloc = 0
+#if defined key_noslip_accurate
+      ALLOCATE(icoord(jpi*jpj*jpk,3), STAT=dom_msk_alloc)
+#endif
+      IF( dom_msk_alloc /= 0 )   CALL ctl_warn('dom_msk_alloc: failed to allocate icoord array')
+      !
+   END FUNCTION dom_msk_alloc
+
+
    SUBROUTINE dom_msk
       !!---------------------------------------------------------------------
@@ -109,13 +125,19 @@
       !!               tmask_i  : interior ocean mask
       !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
+      USE wrk_nemo, ONLY:   zwf  =>  wrk_2d_1      ! 2D real    workspace
+      USE wrk_nemo, ONLY:   imsk => iwrk_2d_1      ! 2D integer workspace
+      !
       INTEGER  ::   ji, jj, jk      ! dummy loop indices
-      INTEGER  ::   iif, iil, ii0, ii1, ii
-      INTEGER  ::   ijf, ijl, ij0, ij1
-      INTEGER , DIMENSION(jpi,jpj) ::  imsk
-      REAL(wp), DIMENSION(jpi,jpj) ::   zwf
+      INTEGER  ::   iif, iil, ii0, ii1, ii   ! local integers
+      INTEGER  ::   ijf, ijl, ij0, ij1       !   -       -
       !!
       NAMELIST/namlbc/ rn_shlat
       !!---------------------------------------------------------------------
       
+      IF( wrk_in_use(2, 1) .OR. iwrk_in_use(2, 1) ) THEN
+         CALL ctl_stop('dom_msk: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
+
       REWIND( numnam )              ! Namelist namlbc : lateral momentum boundary condition
       READ  ( numnam, namlbc )
@@ -414,4 +436,7 @@
       ENDIF
       !
+      IF( wrk_not_released(2, 1)  .OR.   &
+         iwrk_not_released(2, 1)  )   CALL ctl_stop('dom_msk: failed to release workspace arrays')
+      !
    END SUBROUTINE dom_msk
 
@@ -431,15 +456,13 @@
       !! ** Action :
       !!----------------------------------------------------------------------
-      INTEGER  :: ji, jj, jk, jl      ! dummy loop indices
+      INTEGER  ::   ji, jj, jk, jl      ! dummy loop indices
       INTEGER  ::   ine, inw, ins, inn, itest, ierror, iind, ijnd
       REAL(wp) ::   zaa
-      INTEGER, DIMENSION(jpi*jpj*jpk,3) ::  icoord
       !!---------------------------------------------------------------------
-      
-
-      IF(lwp)WRITE(numout,*)
-      IF(lwp)WRITE(numout,*) 'dom_msk_nsa : noslip accurate boundary condition'
-      IF(lwp)WRITE(numout,*) '~~~~~~~~~~~   using Schchepetkin and O Brian scheme'
-      IF( lk_mpp ) CALL ctl_stop( ' mpp version is not yet implemented' )
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dom_msk_nsa : noslip accurate boundary condition'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   using Schchepetkin and O Brian scheme'
+      IF( lk_mpp )   CALL ctl_stop( ' mpp version is not yet implemented' )
 
       ! mask for second order calculation of vorticity
@@ -596,5 +619,5 @@
          CALL ctl_stop( 'We stop...' )
       ENDIF
-
+      !
    END SUBROUTINE dom_msk_nsa
 
