Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 2682)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 2683)
@@ -43,5 +43,4 @@
 
    PUBLIC   dom_zgr        ! called by dom_init.F90
-   PUBLIC   dom_zgr_alloc  ! called by nemo_alloc in nemogcm.F90
 
    !                                       !!* Namelist namzgr_sco *
@@ -72,5 +71,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.3.1 , NEMO Consortium (2011)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -78,22 +77,18 @@
 CONTAINS       
 
-   FUNCTION dom_zgr_alloc()
-      !!----------------------------------------------------------------------
-      !!                ***  FUNCTION dom_zgr_alloc  ***
-      !!----------------------------------------------------------------------
-      INTEGER :: dom_zgr_alloc
-      !!----------------------------------------------------------------------
-
-      ALLOCATE(gsigw3(jpi,jpj,jpk),  gsigt3(jpi,jpj,jpk),   &
-               esigt3(jpi,jpj,jpk),  esigw3(jpi,jpj,jpk),   &
-               esigtu3(jpi,jpj,jpk), esigtv3(jpi,jpj,jpk),  &
-               esigtf3(jpi,jpj,jpk), esigwu3(jpi,jpj,jpk),  &
-               esigwv3(jpi,jpj,jpk), Stat=dom_zgr_alloc)
-
-      IF(dom_zgr_alloc /= 0)THEN
-         CALL ctl_warn('dom_zgr_alloc: failed to allocate arrays.')
-      END IF
-
-   END FUNCTION dom_zgr_alloc
+   INTEGER FUNCTION dom_zgr_sco_alloc()
+      !!----------------------------------------------------------------------
+      !!                ***  FUNCTION dom_zgr_sco_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( gsigw3 (jpi,jpj,jpk) , gsigt3 (jpi,jpj,jpk) ,     &
+         &      esigt3 (jpi,jpj,jpk) , esigw3 (jpi,jpj,jpk) ,     &
+         &      esigtu3(jpi,jpj,jpk) , esigtv3(jpi,jpj,jpk) ,     &
+         &      esigtf3(jpi,jpj,jpk) , esigwu3(jpi,jpj,jpk) ,     &
+         &      esigwv3(jpi,jpj,jpk)                        , STAT=dom_zgr_sco_alloc )
+         !
+      IF( lk_mpp                 )   CALL mpp_sum ( dom_zgr_sco_alloc )
+      IF( dom_zgr_sco_alloc /= 0 )   CALL ctl_warn('dom_zgr_sco_alloc: failed to allocate arrays.')
+      !
+   END FUNCTION dom_zgr_sco_alloc
 
 
@@ -619,6 +614,6 @@
       !!              - update bathy : meter bathymetry (in meters)
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zbathy => wrk_2d_1
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zbathy => wrk_2d_1
       !!
       INTEGER ::   ji, jj, jl                    ! dummy loop indices
@@ -626,8 +621,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1))THEN
-         CALL ctl_stop('zgr_bat_ctl: ERROR: requested workspace array unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1) ) THEN
+         CALL ctl_stop('zgr_bat_ctl: requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       IF(lwp) WRITE(numout,*)
@@ -733,8 +727,5 @@
       ENDIF
       !
-      IF(wrk_not_released(2, 1))THEN
-         CALL ctl_stop('zgr_bat_ctl: ERROR: failed to release workspace array.')
-         RETURN
-      END IF
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('zgr_bat_ctl: failed to release workspace array')
       !
    END SUBROUTINE zgr_bat_ctl
@@ -753,14 +744,13 @@
       !!                                     (min value = 1 over land)
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zmbk => wrk_2d_1
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zmbk => wrk_2d_1
       !!
       INTEGER ::   ji, jj   ! dummy loop indices
       !!----------------------------------------------------------------------
       !
-      IF( wrk_in_use(2, 1))THEN
-         CALL ctl_stop('zgr_bot_level: ERROR - requested 2D workspace unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1) ) THEN
+         CALL ctl_stop('zgr_bot_level: requested 2D workspace unavailable')   ;   RETURN
+      ENDIF
       !
       IF(lwp) WRITE(numout,*)
@@ -780,8 +770,5 @@
       zmbk(:,:) = REAL( mbkv(:,:), wp )   ;   CALL lbc_lnk(zmbk,'V',1.)   ;   mbkv  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
       !
-      IF( wrk_not_released(2, 1))THEN
-         CALL ctl_stop('zgr_bot_level: ERROR - failed to release workspace array.')
-         RETURN
-      END IF
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('zgr_bot_level: failed to release workspace array')
       !
    END SUBROUTINE zgr_bot_level
@@ -860,6 +847,6 @@
       !!  Reference :   Pacanowsky & Gnanadesikan 1997, Mon. Wea. Rev., 126, 3248-3270.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zprt => wrk_3d_1
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zprt => wrk_3d_1
       !!
       INTEGER  ::   ji, jj, jk       ! dummy loop indices
@@ -873,8 +860,7 @@
       !!---------------------------------------------------------------------
       ! 
-      IF( wrk_in_use(3, 1))THEN
-         CALL ctl_stop('zgr_zps: ERROR - requested workspace unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(3, 1) ) THEN
+         CALL ctl_stop('zgr_zps: requested workspace unavailable.')   ;   RETURN
+      ENDIF
 
       IF(lwp) WRITE(numout,*)
@@ -884,5 +870,4 @@
 
       ll_print = .FALSE.                   ! Local variable for debugging
-!!    ll_print = .TRUE.
       
       IF(lwp .AND. ll_print) THEN          ! control print of the ocean depth
@@ -1068,8 +1053,5 @@
       ENDIF  
       !
-      IF( wrk_not_released(3, 1))THEN
-         CALL ctl_stop('zgr_zps: ERROR - failed to release workspace.')
-         RETURN
-      END IF
+      IF( wrk_not_released(3, 1) )   CALL ctl_stop('zgr_zps: failed to release workspace')
       !
    END SUBROUTINE zgr_zps
@@ -1159,24 +1141,23 @@
       !! Reference : Madec, Lott, Delecluse and Crepon, 1996. JPO, 26, 1393-1408.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zenv => wrk_2d_1, ztmp => wrk_2d_2, zmsk => wrk_2d_3, &
-                          zri => wrk_2d_4, zrj => wrk_2d_5, zhbat => wrk_2d_6
-      !!
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zenv => wrk_2d_1 , ztmp => wrk_2d_2 , zmsk  => wrk_2d_3
+      USE wrk_nemo, ONLY:   zri  => wrk_2d_4 , zrj  => wrk_2d_5 , zhbat => wrk_2d_6
+      !
       INTEGER  ::   ji, jj, jk, jl           ! dummy loop argument
       INTEGER  ::   iip1, ijp1, iim1, ijm1   ! temporary integers
       REAL(wp) ::   zcoeft, zcoefw, zrmax, ztaper   ! temporary scalars
-      !!
+      !
       NAMELIST/namzgr_sco/ rn_sbot_max, rn_sbot_min, rn_theta, rn_thetb, rn_rmax, ln_s_sigma, rn_bb, rn_hc
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3,4,5,6))THEN
-         CALL ctl_stop('zgr_sco: ERROR - requested workspace arrays unavailable')
-         RETURN
-      END IF
-
-      REWIND( numnam )                        ! Read Namelist namzgr_sco : sigma-stretching parameters
+      IF( wrk_in_use(2, 1,2,3,4,5,6) ) THEN
+         CALL ctl_stop('zgr_sco: ERROR - requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
+
+      REWIND( numnam )                       ! Read Namelist namzgr_sco : sigma-stretching parameters
       READ  ( numnam, namzgr_sco )
 
-      IF(lwp) THEN                            ! control print
+      IF(lwp) THEN                           ! control print
          WRITE(numout,*)
          WRITE(numout,*) 'dom:zgr_sco : s-coordinate or hybrid z-s-coordinate'
@@ -1194,4 +1175,7 @@
       ENDIF
 
+      !                                      ! allocate sco arrays
+      IF( dom_zgr_sco_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'dom:zgr_sco : unable to allocate arrays' )
+
       gsigw3  = 0._wp   ;   gsigt3  = 0._wp   ;   gsi3w3  = 0._wp
       esigt3  = 0._wp   ;   esigw3  = 0._wp 
@@ -1209,7 +1193,5 @@
       DO jj = 1, jpj
          DO ji = 1, jpi
-           IF( bathy(ji,jj) > 0._wp ) THEN
-              bathy(ji,jj) = MAX( rn_sbot_min, bathy(ji,jj) )
-           ENDIF
+           IF( bathy(ji,jj) > 0._wp )   bathy(ji,jj) = MAX( rn_sbot_min, bathy(ji,jj) )
          END DO
       END DO
@@ -1616,10 +1598,7 @@
 !!gm bug    #endif
       !
-      IF(wrk_not_released(2, 1,2,3,4,5,6))THEN
-         CALL ctl_stop('zgr_sco: ERROR - failed to release workspace arrays')
-      END IF
+      IF( wrk_not_released(2, 1,2,3,4,5,6) )   CALL ctl_stop('dom:zgr_sco: failed to release workspace arrays')
       !
    END SUBROUTINE zgr_sco
-
 
    !!======================================================================
