Index: branches/2013/dev_LOCEAN_2013/NEMOGCM/NEMO/OPA_SRC/CRS/crsdomwri.F90
===================================================================
--- branches/2013/dev_LOCEAN_2013/NEMOGCM/NEMO/OPA_SRC/CRS/crsdomwri.F90	(revision 4154)
+++ branches/2013/dev_LOCEAN_2013/NEMOGCM/NEMO/OPA_SRC/CRS/crsdomwri.F90	(revision 4187)
@@ -6,5 +6,5 @@
    !!            8.1  ! 1999-11  (M. Imbard)  NetCDF FORMAT with IOIPSL
    !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90 and several file
-   !!            3.0  ! 2008-01  (S. Masson) add dom_uniq
+   !!            3.0  ! 2008-01  (S. Masson) add dom_uniq_crs
    !!            4.0  ! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
    !!                 ! 2012-06  (J. Simeon, C. Calone, C Ethe )  Reduced and modified for coarse grid
@@ -24,4 +24,5 @@
    USE crsdom         ! coarse grid domain
    USE crslbclnk       ! crs mediator to lbclnk
+   USE wrk_nemo        ! Working array
 
 
@@ -64,14 +65,14 @@
       INTEGER           ::   ji, jj, jk   ! dummy loop indices
       !                                   !  workspaces
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:  ) :: zprt, zprw 
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zdepu, zdepv
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:  ) :: ze3tp, ze3wp
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zprt, zprw 
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zdepu, zdepv
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: ze3tp, ze3wp
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('crs_dom_wri')
       !
-      ALLOCATE( zprt  (jpi_crs,jpj_crs)   , zprw(jpi_crs,jpj_crs) )
-      ALLOCATE( zdepu(jpi_crs,jpj_crs,jpk), zdepv(jpi_crs,jpj_crs,jpk) )
-      ALLOCATE( ze3tp(jpi_crs,jpj_crs)    , ze3wp(jpi_crs,jpj_crs) )
+      CALL wrk_alloc( jpi_crs, jpj_crs,      zprt , zprw  )
+      CALL wrk_alloc( jpi_crs, jpj_crs,      ze3tp, ze3wp )
+      CALL wrk_alloc( jpi_crs, jpj_crs, jpk, zdepu, zdepv )
 
       ze3tp(:,:) = 0.0
@@ -155,17 +156,13 @@
       ENDIF
       
- !     CALL iom_rstput( 0, 0, inum2, 'tpol', pv_r2d=tpol_crs, ktype = jp_i1 )  
- !     CALL iom_rstput( 0, 0, inum2, 'fpol', pv_r2d=fpol_crs, ktype = jp_i1 )  
-
-      !!!
       CALL iom_rstput( 0, 0, inum2, 'tmaskutil', tmask_i_crs, ktype = jp_i1 )
                                    !    ! unique point mask
-      CALL dom_uniq( zprw, 'U' )
+      CALL dom_uniq_crs( zprw, 'U' )
       zprt = umask_crs(:,:,1) * zprw
       CALL iom_rstput( 0, 0, inum2, 'umaskutil', zprt, ktype = jp_i1 )  
-      CALL dom_uniq( zprw, 'V' )
+      CALL dom_uniq_crs( zprw, 'V' )
       zprt = vmask_crs(:,:,1) * zprw
       CALL iom_rstput( 0, 0, inum2, 'vmaskutil', zprt, ktype = jp_i1 )  
-      CALL dom_uniq( zprw, 'F' )
+      CALL dom_uniq_crs( zprw, 'F' )
       zprt = fmask_crs(:,:,1) * zprw
       CALL iom_rstput( 0, 0, inum2, 'fmaskutil', zprt, ktype = jp_i1 )  
@@ -296,8 +293,7 @@
       END SELECT
       !
-      !
-      DEALLOCATE( zprt  , zprw )
-      DEALLOCATE( zdepu , zdepv )
-      DEALLOCATE( ze3tp , ze3wp )
+      CALL wrk_dealloc( jpi_crs, jpj_crs,      zprt , zprw  )
+      CALL wrk_dealloc( jpi_crs, jpj_crs,      ze3tp, ze3wp )
+      CALL wrk_dealloc( jpi_crs, jpj_crs, jpk, zdepu, zdepv )
       !
       IF( nn_timing == 1 )  CALL timing_stop('crs_dom_wri')
@@ -307,7 +303,7 @@
 
 
-   SUBROUTINE dom_uniq( puniq, cdgrd )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE crs_dom_uniq  ***
+   SUBROUTINE dom_uniq_crs( puniq, cdgrd )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE crs_dom_uniq_crs  ***
       !!                   
       !! ** Purpose :   identify unique point of a grid (TUVF)
@@ -323,12 +319,10 @@
       INTEGER  ::  ji       ! dummy loop indices
       LOGICAL, DIMENSION(SIZE(puniq,1),SIZE(puniq,2),1) ::  lldbl  ! store whether each point is unique or not
-!      REAL(wp), POINTER, DIMENSION(:,:) :: ztstref
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: ztstref
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('crs_dom_uniq')
-      !
-!      CALL wrk_alloc( jpi_crs, jpj_crs, ztstref )
-      ALLOCATE( ztstref(jpi_crs,jpj_crs) )
+      REAL(wp), POINTER, DIMENSION(:,:) :: ztstref
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('crs_dom_uniq_crs')
+      !
+      CALL wrk_alloc( jpi_crs, jpj_crs, ztstref )
       !
       ! build an array with different values for each element 
@@ -346,12 +340,10 @@
       puniq(nldi_crs:nlei_crs,nldj_crs:nlej_crs) = REAL( COUNT( lldbl(nldi_crs:nlei_crs,nldj_crs:nlej_crs,:), dim = 3 ) , wp )
       !
-!      CALL wrk_dealloc( jpi_crs, jpj_crs, ztstref )
-
-      DEALLOCATE( ztstref )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('crs_dom_uniq')
-      !
-      
-   END SUBROUTINE dom_uniq
+      CALL wrk_dealloc( jpi_crs, jpj_crs, ztstref )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('crs_dom_uniq_crs')
+      !
+      
+   END SUBROUTINE dom_uniq_crs
 
    !!======================================================================
