Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obc_oce.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obc_oce.F90	(revision 2646)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obc_oce.F90	(revision 2647)
@@ -4,21 +4,18 @@
    !! Open Boundary Cond. :   define related variables
    !!==============================================================================
+   !! history :  OPA  ! 1991-01 (CLIPPER)  Original code 
+   !!   NEMO     1.0  ! 2002-02 (C. Talandier)  modules, F90
+   !!----------------------------------------------------------------------
+#if defined key_obc
    !!----------------------------------------------------------------------
    !!   'key_obc' :                                 Open Boundary Condition
    !!----------------------------------------------------------------------
-   !! history :
-   !!  8.0   01/91   (CLIPPER)  Original code 
-   !!  8.5   06/02   (C. Talandier)  modules
-   !!        06/04   (F. Durand) ORCA2_ZIND config
-   !!                 
-   !!----------------------------------------------------------------------
-   !! * Modules used
    USE par_oce         ! ocean parameters
    USE obc_par         ! open boundary condition parameters
 
-#if defined key_obc
-
    IMPLICIT NONE
    PUBLIC
+   
+   PUBLIC   obc_oce_alloc   ! called by obcini.F90 module
 
    !!----------------------------------------------------------------------
@@ -26,5 +23,5 @@
    !!----------------------------------------------------------------------
    !
-   !                                  !!* Namelist namobc: open boundary condition *
+   !                                            !!* Namelist namobc: open boundary condition *
    INTEGER           ::   nn_obcdta   = 0        !:  = 0 use the initial state as obc data
    !                                             !   = 1 read obc data in obcxxx.dta files
@@ -63,9 +60,8 @@
    !!General variables for open boundaries:
    !!--------------------------------------
-   LOGICAL ::              &  !:
-      lfbceast, lfbcwest,  &  !: logical flag for a fixed East and West open boundaries       
-      lfbcnorth, lfbcsouth    !: logical flag for a fixed North and South open boundaries       
-      !                       !  These logical flags are set to 'true' if damping time 
-      !                       !  scale are set to 0 in the namelist, for both inflow and outflow).
+   LOGICAL ::   lfbceast, lfbcwest      !: logical flag for a fixed East and West open boundaries       
+   LOGICAL ::   lfbcnorth, lfbcsouth    !: logical flag for a fixed North and South open boundaries       
+   !                                    !  These logical flags are set to 'true' if damping time 
+   !                                    !  scale are set to 0 in the namelist, for both inflow and outflow).
 
    REAL(wp), PUBLIC ::   obcsurftot       !: Total lateral surface of open boundaries
@@ -97,5 +93,5 @@
       !                   ! in the obcdyn.F90 routine
 
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sshfoe_b      !: east boundary ssh correction averaged over the barotropic loop
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sshfoe_b   !: east boundary ssh correction averaged over the barotropic loop
       !                                            !  (if Flather's algoritm applied at open boundary)
 
@@ -224,24 +220,17 @@
    REAL(wp), ALLOCATABLE, SAVE,     DIMENSION(:,:) ::   usmsk, vsmsk, tsmsk  !: 2D mask for the South OB
 
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option :                                       Empty module
-   !!----------------------------------------------------------------------
-#endif
-
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!======================================================================
-#if defined key_obc
+   !!----------------------------------------------------------------------
 CONTAINS
 
-   FUNCTION obc_oce_alloc()
-     IMPLICIT none
-
-     INTEGER :: obc_oce_alloc     
-
-     ALLOCATE(                                                               &
+   INTEGER FUNCTION obc_oce_alloc()
+      !!----------------------------------------------------------------------
+      !!               ***  FUNCTION obc_oce_alloc  ***
+      !!----------------------------------------------------------------------
+
+      ALLOCATE(                                                               &
               !! East open boundary
               obctmsk(jpi,jpj), obcumask(jpi,jpj), obcvmask(jpi,jpj),        &
@@ -283,8 +272,14 @@
               usmsk(jpi,jpk), vsmsk(jpi,jpk), tsmsk(jpi,jpk),                &
               !!
-              Stat=obc_oce_alloc )
-
+              STAT=obc_oce_alloc )
+      !
    END FUNCTION obc_oce_alloc
-#endif ! Defined key_obc
-
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty module                          No OBC
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
 END MODULE obc_oce
Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obc_par.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obc_par.F90	(revision 2646)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obc_par.F90	(revision 2647)
@@ -4,25 +4,17 @@
    !! Open Boundary Cond. :   define related parameters
    !!==============================================================================
+   !! history :  OPA  ! 1991-01 (CLIPPER)  Original code 
+   !!   NEMO     1.0  ! 2002-04   (C. Talandier)  modules
+   !!             -   ! 2004/06   (F. Durand) jptobc is defined as a parameter
+   !!----------------------------------------------------------------------
 #if defined key_obc
    !!----------------------------------------------------------------------
    !!   'key_obc' :                                 Open Boundary Condition
    !!----------------------------------------------------------------------
-   !! history :
-   !!  8.0   01/91   (CLIPPER)  Original code 
-   !!  9.0   06/02   (C. Talandier)  modules
-   !!        06/04   (F. Durand) ORCA_R2_ZIND config
-   !!        06/04   (F. Durand) jptobc is defined as a parameter, 
-   !!	     	     in order to allow time-dependent OBCs fields on input
-   !!----------------------------------------------------------------------
-   !! * Modules used
    USE par_oce         ! ocean parameters
 
    IMPLICIT NONE
    PUBLIC
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
+
 #if ! defined key_agrif
    LOGICAL, PUBLIC, PARAMETER ::   lk_obc = .TRUE.     !: Ocean Boundary Condition flag
@@ -47,10 +39,9 @@
    !! open boundary parameter
    !!---------------------------------------------------------------------
-   INTEGER, PARAMETER ::     &  !: time dimension of the BCS fields on input
-      jptobc  =	      2 
+   INTEGER, PARAMETER ::   jptobc      =  2        !: time dimension of the BCS fields on input
+   
    !! * EAST open boundary
-   LOGICAL, PARAMETER ::     &  !:
-      lp_obc_east = .FALSE.     !: to active or not the East open boundary
-     INTEGER   &
+   LOGICAL, PARAMETER ::   lp_obc_east = .FALSE.   !: to active or not the East open boundary
+   INTEGER   &
 #if !defined key_agrif
      , PARAMETER   & 
@@ -64,7 +55,6 @@
 
    !! * WEST open boundary
-   LOGICAL, PARAMETER ::     &  !:
-      lp_obc_west = .FALSE.     !: to active or not the West open boundary
-     INTEGER   &
+   LOGICAL, PARAMETER ::   lp_obc_west = .FALSE.   !: to active or not the West open boundary
+   INTEGER   &
 #if !defined key_agrif
      , PARAMETER   & 
@@ -78,6 +68,5 @@
 
    !! * NORTH open boundary
-   LOGICAL, PARAMETER ::     &  !:
-      lp_obc_north = .FALSE.    !: to active or not the North open boundary
+   LOGICAL, PARAMETER ::   lp_obc_north = .FALSE.   !: to active or not the North open boundary
      INTEGER   &
 #if !defined key_agrif
@@ -92,6 +81,5 @@
 
    !! * SOUTH open boundary
-   LOGICAL, PARAMETER ::     &  !:
-      lp_obc_south = .FALSE.    !: to active or not the South open boundary
+   LOGICAL, PARAMETER ::   lp_obc_south = .FALSE.   !: to active or not the South open boundary
      INTEGER   &
 #if !defined key_agrif
@@ -105,6 +93,5 @@
       jpisfm1 =  jpisf-1        !: last  ocean point         "                 "
    
-   INTEGER, PARAMETER ::     &  !:
-      jpnic = 2700              !: maximum number of isolated coastlines points 
+   INTEGER, PARAMETER ::   jpnic = 2700   !: maximum number of isolated coastlines points 
 
 # endif
@@ -117,4 +104,8 @@
 #endif
 
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!======================================================================
 END MODULE obc_par
Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 2646)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 2647)
@@ -4,4 +4,9 @@
    !! Open boundary data : read the data for the open boundaries.
    !!==============================================================================
+   !! History :  OPA  ! 1998-05 (J.M. Molines) Original code
+   !!            8.5  ! 2002-10 (C. Talandier, A-M. Treguier) Free surface, F90
+   !!   NEMO     1.0  ! 2004-06 (F. Durand, A-M. Treguier) Netcdf BC files on input
+   !!            3.0  ! 2007-2008 (C. Langlais, P. Mathiot, J.M. Molines) high frequency boundaries data
+   !!------------------------------------------------------------------------------
 #if defined key_obc
    !!------------------------------------------------------------------------------
@@ -25,8 +30,7 @@
    PRIVATE
 
-   PUBLIC   obc_dta      ! routines called by step.F90
-   PUBLIC   obc_dta_bt   ! routines called by dynspg_ts.F90
-   PUBLIC   obc_dta_alloc
-   
+   PUBLIC   obc_dta         ! routine  called by step.F90
+   PUBLIC   obc_dta_bt      ! routine  called by dynspg_ts.F90
+   PUBLIC   obc_dta_alloc   ! function called by obcini.F90
 
    REAL(wp),  DIMENSION(2)              ::   zjcnes_obc   ! 
@@ -47,11 +51,10 @@
    CHARACTER (len=40) ::   cl_obc_sTS, cl_obc_sV   !   -       -
 
-# if defined key_dynspg_ts
    ! bt arrays for interpolating time dependent data on the boundaries
    INTEGER ::   nt_m=0, ntobc_m
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtedta, vbtedta, sshedta       ! East
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtwdta, vbtwdta, sshwdta	! West
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtndta, vbtndta, sshndta	! North
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtsdta, vbtsdta, sshsdta	! South
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtedta, vbtedta, sshedta    ! East
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtwdta, vbtwdta, sshwdta	   ! West
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtndta, vbtndta, sshndta	   ! North
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtsdta, vbtsdta, sshsdta	   ! South
    ! arrays used for interpolating time dependent data on the boundaries
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: uedta, vedta, tedta, sedta    ! East
@@ -59,16 +62,5 @@
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: undta, vndta, tndta, sndta    ! North
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: usdta, vsdta, tsdta, ssdta    ! South
-# else
-   ! bt arrays for interpolating time dependent data on the boundaries
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtedta, vbtedta, sshedta        ! East
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtwdta, vbtwdta, sshwdta        ! West
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtndta, vbtndta, sshndta        ! North
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ubtsdta, vbtsdta, sshsdta        ! South
-   ! arrays used for interpolating time dependent data on the boundaries
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: uedta, vedta, tedta, sedta    ! East
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: uwdta, vwdta, twdta, swdta    ! West
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: undta, vndta, tndta, sndta    ! North
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: usdta, vsdta, tsdta, ssdta    ! South
-# endif
+
    ! Masks set to .TRUE. after successful allocation below
    LOGICAL , ALLOCATABLE, SAVE, DIMENSION(:,:)   :: ltemsk, luemsk, lvemsk  ! boolean msks
@@ -87,79 +79,67 @@
 CONTAINS
 
-   FUNCTION obc_dta_alloc()
+   INTEGER FUNCTION obc_dta_alloc()
       !!-------------------------------------------------------------------
       !!                     ***  ROUTINE obc_dta_alloc  ***
-      !!                    
       !!-------------------------------------------------------------------
-      IMPLICIT none
-      INTEGER :: obc_dta_alloc
       INTEGER :: ierr(2)
       !!-------------------------------------------------------------------
-
 # if defined key_dynspg_ts
-      ALLOCATE(ubtedta(jpj,0:jptobc), vbtedta(jpj,0:jptobc), &
-               sshedta(jpj,0:jptobc), ubtwdta(jpj,0:jptobc), &
-               vbtwdta(jpj,0:jptobc), sshwdta(jpj,0:jptobc), &
-               ubtndta(jpi,0:jptobc), vbtndta(jpi,0:jptobc), &
-               sshndta(jpi,0:jptobc), ubtsdta(jpi,0:jptobc), &
-               vbtsdta(jpi,0:jptobc), sshsdta(jpi,0:jptobc), &
-               ! arrays used for interpolating time dependent data on the boundaries
-               uedta(jpj,jpk,0:jptobc), vedta(jpj,jpk,0:jptobc), &
-               tedta(jpj,jpk,0:jptobc), sedta(jpj,jpk,0:jptobc), &
-               uwdta(jpj,jpk,0:jptobc), vwdta(jpj,jpk,0:jptobc), &
-               twdta(jpj,jpk,0:jptobc), swdta(jpj,jpk,0:jptobc), &
-               undta(jpi,jpk,0:jptobc), vndta(jpi,jpk,0:jptobc), &
-               tndta(jpi,jpk,0:jptobc), sndta(jpi,jpk,0:jptobc), &
-               usdta(jpi,jpk,0:jptobc), vsdta(jpi,jpk,0:jptobc), &
-               tsdta(jpi,jpk,0:jptobc), ssdta(jpi,jpk,0:jptobc), Stat=ierr(1) )
+      ALLOCATE(   &     ! time-splitting : 0:jptobc
+         ! bt arrays for interpolating time dependent data on the boundaries
+         &      ubtedta  (jpj,0:jptobc) , vbtedta  (jpj,0:jptobc) , sshedta  (jpj,0:jptobc) ,    &
+         &      ubtwdta  (jpj,0:jptobc) , vbtwdta  (jpj,0:jptobc) , sshwdta  (jpj,0:jptobc) ,    &
+         &      ubtndta  (jpi,0:jptobc) , vbtndta  (jpi,0:jptobc) , sshndta  (jpi,0:jptobc) ,    &
+         &      ubtsdta  (jpi,0:jptobc) , vbtsdta  (jpi,0:jptobc) , sshsdta  (jpi,0:jptobc) ,    &
+         ! arrays used for interpolating time dependent data on the boundaries
+         &      uedta(jpj,jpk,0:jptobc) , vedta(jpj,jpk,0:jptobc)                           ,     &
+         &      tedta(jpj,jpk,0:jptobc) , sedta(jpj,jpk,0:jptobc)                           ,     &
+         &      uwdta(jpj,jpk,0:jptobc) , vwdta(jpj,jpk,0:jptobc)                           ,     &
+         &      twdta(jpj,jpk,0:jptobc) , swdta(jpj,jpk,0:jptobc)                           ,     &
+         &      undta(jpi,jpk,0:jptobc) , vndta(jpi,jpk,0:jptobc)                           ,     &
+         &      tndta(jpi,jpk,0:jptobc) , sndta(jpi,jpk,0:jptobc)                           ,     &
+         &      usdta(jpi,jpk,0:jptobc) , vsdta(jpi,jpk,0:jptobc)                           ,     &
+         &      tsdta(jpi,jpk,0:jptobc) , ssdta(jpi,jpk,0:jptobc)                           , STAT=ierr(1) )
 # else
-               ! bt arrays for interpolating time dependent data on the boundaries
-      ALLOCATE(ubtedta(jpj,jptobc), vbtedta(jpj,jptobc), sshedta(jpj,jptobc), &
-               ubtwdta(jpj,jptobc), vbtwdta(jpj,jptobc), sshwdta(jpj,jptobc), &
-               ubtndta(jpi,jptobc), vbtndta(jpi,jptobc), sshndta(jpi,jptobc), &
-               ubtsdta(jpi,jptobc), vbtsdta(jpi,jptobc), sshsdta(jpi,jptobc), &
-               ! arrays used for interpolating time dependent data on the boundaries
-               uedta(jpj,jpk,jptobc), vedta(jpj,jpk,jptobc),  &
-               tedta(jpj,jpk,jptobc), sedta(jpj,jpk,jptobc),  &
-               uwdta(jpj,jpk,jptobc), vwdta(jpj,jpk,jptobc),  &
-               twdta(jpj,jpk,jptobc), swdta(jpj,jpk,jptobc),  &
-               undta(jpi,jpk,jptobc), vndta(jpi,jpk,jptobc),  &
-               tndta(jpi,jpk,jptobc), sndta(jpi,jpk,jptobc),  &
-               usdta(jpi,jpk,jptobc), vsdta(jpi,jpk,jptobc),  &
-               tsdta(jpi,jpk,jptobc), ssdta(jpi,jpk,jptobc), Stat=ierr(1) )
+      ALLOCATE(   &     ! no time splitting : 1:jptobc
+         ! bt arrays for interpolating time dependent data on the boundaries
+         &      ubtedta  (jpj,jptobc) , vbtedta  (jpj,jptobc) , sshedta  (jpj,jptobc)  ,     &
+         &      ubtwdta  (jpj,jptobc) , vbtwdta  (jpj,jptobc) , sshwdta  (jpj,jptobc)  ,     &
+         &      ubtndta  (jpi,jptobc) , vbtndta  (jpi,jptobc) , sshndta  (jpi,jptobc)  ,     &
+         &      ubtsdta  (jpi,jptobc) , vbtsdta  (jpi,jptobc) , sshsdta  (jpi,jptobc)  ,     &
+         ! arrays used for interpolating time dependent data on the boundaries
+         &      uedta(jpj,jpk,jptobc) , vedta(jpj,jpk,jptobc)                          ,     &
+         &      tedta(jpj,jpk,jptobc) , sedta(jpj,jpk,jptobc)                          ,     &
+         &      uwdta(jpj,jpk,jptobc) , vwdta(jpj,jpk,jptobc)                          ,     &
+         &      twdta(jpj,jpk,jptobc) , swdta(jpj,jpk,jptobc)                          ,     &
+         &      undta(jpi,jpk,jptobc) , vndta(jpi,jpk,jptobc)                          ,     &
+         &      tndta(jpi,jpk,jptobc) , sndta(jpi,jpk,jptobc)                          ,     &
+         &      usdta(jpi,jpk,jptobc) , vsdta(jpi,jpk,jptobc)                          ,     &
+         &      tsdta(jpi,jpk,jptobc) , ssdta(jpi,jpk,jptobc)                          , STAT=ierr(1) )
 # endif
 
-      ALLOCATE(uedta(jpj,jpk,jptobc), vedta(jpj,jpk,jptobc), &
-               tedta(jpj,jpk,jptobc), sedta(jpj,jpk,jptobc), &
-               uwdta(jpj,jpk,jptobc), vwdta(jpj,jpk,jptobc), &
-               twdta(jpj,jpk,jptobc), swdta(jpj,jpk,jptobc), &
-               undta(jpj,jpk,jptobc), vndta(jpj,jpk,jptobc), &
-               tndta(jpj,jpk,jptobc), sndta(jpj,jpk,jptobc), &
-               usdta(jpj,jpk,jptobc), vsdta(jpj,jpk,jptobc), &
-               tsdta(jpj,jpk,jptobc), ssdta(jpj,jpk,jptobc), &
-               ltemsk(jpj,jpk), luemsk(jpj,jpk), lvemsk(jpj,jpk), &
-               ltwmsk(jpj,jpk), luwmsk(jpj,jpk), lvwmsk(jpj,jpk), &
-               ltnmsk(jpj,jpk), lunmsk(jpj,jpk), lvnmsk(jpj,jpk), &
-               ltsmsk(jpj,jpk), lusmsk(jpj,jpk), lvsmsk(jpj,jpk), &
-               Stat=ierr(2))
-
-      obc_dta_alloc = MAXVAL(ierr)
-
-      IF(obc_dta_alloc == 0)THEN
-         ! Initialise mask values following successful allocation
-         ltemsk(:,:)=.TRUE.
-         luemsk(:,:)=.TRUE.
-         lvemsk(:,:)=.TRUE.
-         ltwmsk(:,:)=.TRUE.
-         luwmsk(:,:)=.TRUE.
-         lvwmsk(:,:)=.TRUE.
-         ltnmsk(:,:)=.TRUE.
-         lunmsk(:,:)=.TRUE.
-         lvnmsk(:,:)=.TRUE.
-         ltsmsk(:,:)=.TRUE.
-         lusmsk(:,:)=.TRUE.
-         lvsmsk(:,:)=.TRUE.
+      ALLOCATE( uedta(jpj,jpk,jptobc) , vedta(jpj,jpk,jptobc)       ,     &
+         &      tedta(jpj,jpk,jptobc) , sedta(jpj,jpk,jptobc)       ,     &
+         &      uwdta(jpj,jpk,jptobc) , vwdta(jpj,jpk,jptobc)       ,     &
+         &      twdta(jpj,jpk,jptobc) , swdta(jpj,jpk,jptobc)       ,     &
+         &      undta(jpj,jpk,jptobc) , vndta(jpj,jpk,jptobc)       ,     &
+         &      tndta(jpj,jpk,jptobc) , sndta(jpj,jpk,jptobc)       ,     &
+         &      usdta(jpj,jpk,jptobc) , vsdta(jpj,jpk,jptobc)       ,     &
+         &      tsdta(jpj,jpk,jptobc) , ssdta(jpj,jpk,jptobc)       ,     &
+         &      ltemsk(jpj,jpk) , luemsk(jpj,jpk) , lvemsk(jpj,jpk) ,     &
+         &      ltwmsk(jpj,jpk) , luwmsk(jpj,jpk) , lvwmsk(jpj,jpk) ,     &
+         &      ltnmsk(jpj,jpk) , lunmsk(jpj,jpk) , lvnmsk(jpj,jpk) ,     &
+         &      ltsmsk(jpj,jpk) , lusmsk(jpj,jpk) , lvsmsk(jpj,jpk) , STAT=ierr(2) )
+
+      obc_dta_alloc = MAXVAL( ierr )
+      IF( lk_mpp )   CALL mpp_sum( obc_dta_alloc )
+
+      IF( obc_dta_alloc == 0 )  THEN         ! Initialise mask values following successful allocation
+         !      east            !          west            !          north           !          south           !
+         ltemsk(:,:) = .TRUE.   ;   ltwmsk(:,:) = .TRUE.   ;   ltnmsk(:,:) = .TRUE.   ;   ltsmsk(:,:) = .TRUE.
+         luemsk(:,:) = .TRUE.   ;   luwmsk(:,:) = .TRUE.   ;   lunmsk(:,:) = .TRUE.   ;   lusmsk(:,:) = .TRUE.
+         lvemsk(:,:) = .TRUE.   ;   lvwmsk(:,:) = .TRUE.   ;   lvnmsk(:,:) = .TRUE.   ;   lvsmsk(:,:) = .TRUE.
       END IF
-
+      !
    END FUNCTION obc_dta_alloc
 
@@ -181,20 +161,10 @@
       !!                 attribute of variable time_counter).
       !!
-      !!
-      !! History :
-      !!        !  98-05 (J.M. Molines) Original code
-      !!   8.5  !  02-10 (C. Talandier, A-M. Treguier) Free surface, F90
-      !!
-      !!   9.0  !  04-06 (F. Durand, A-M. Treguier) Netcdf BC files on input
-      !!        !  2007-2008 (C. Langlais, P. Mathiot, J.M. Molines) high frequency boundaries data
       !!---------------------------------------------------------------------------
-      !! * Arguments
       INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
-
-      !! * Local declarations
+      !
       INTEGER, SAVE :: immfile, iyyfile                     !
       INTEGER :: nt              !  record indices (incrementation)
       REAL(wp) ::   zsec, zxy, znum, zden ! time interpolation weight
-
       !!---------------------------------------------------------------------------
 
@@ -302,20 +272,12 @@
 
 
-   SUBROUTINE obc_dta_ini (kt)
+   SUBROUTINE obc_dta_ini( kt )
       !!-----------------------------------------------------------------------------
       !!                       ***  SUBROUTINE obc_dta_ini  ***
       !!
-      !! ** Purpose :
-      !!      When obc_dta first call, realize some data initialization
-      !!
-      !! ** Method :
-      !!
-      !! History :
-      !!   9.0  ! 07-10 (J.M. Molines )
+      !! ** Purpose :   When obc_dta first call, realize some data initialization
       !!----------------------------------------------------------------------------
-      !! * Argument
       INTEGER, INTENT(in)  :: kt      ! ocean time-step index
-
-      !! * Local declarations
+      !
       INTEGER ::   ji, jj   ! dummy loop indices
       INTEGER, SAVE :: immfile, iyyfile                     !
@@ -596,12 +558,9 @@
       !!                Data at the boundary must be in m2/s 
       !!
-      !! History :
-      !!   9.0  !  05-11 (V. garnier) Original code
+      !! History :  9.0  !  05-11 (V. garnier) Original code
       !!---------------------------------------------------------------------------
-      !! * Arguments
       INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
       INTEGER, INTENT( in ) ::   kbt         ! barotropic ocean time-step index
-
-      !! * Local declarations
+      !
       INTEGER ::   ji, jj  ! dummy loop indices
       INTEGER ::   i15
@@ -609,5 +568,4 @@
       REAL(wp) ::  zxy
       INTEGER ::   isrel           ! number of seconds since 1/1/1992
-
       !!---------------------------------------------------------------------------
 
@@ -1171,4 +1129,5 @@
    END SUBROUTINE obc_read
 
+
    INTEGER FUNCTION nrecbef()
       !!-----------------------------------------------------------------------
@@ -1202,5 +1161,5 @@
       END FUNCTION nrecbef
 
-      !!==============================================================================
+
       SUBROUTINE obc_depth_average(nt_x)
          !!-----------------------------------------------------------------------
@@ -1287,3 +1246,4 @@
       END SUBROUTINE obc_dta
 #endif
+   !!==============================================================================
    END MODULE obcdta
Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90	(revision 2646)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90	(revision 2647)
@@ -18,7 +18,8 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE phycst          ! physical constants
-   USE obc_oce         ! ocean open boundary conditions
-   USE lib_mpp         ! for mpp_sum
+   USE obc_oce         ! open boundary condition: ocean
+   USE obcdta          ! open boundary condition: data
    USE in_out_manager  ! I/O units
+   USE lib_mpp         ! MPP library
    USE dynspg_oce      ! flag lk_dynspg_flt
 
@@ -33,7 +34,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
    
@@ -81,6 +81,8 @@
       rdpnob   = rn_dpnob
       volemp   = rn_volemp
-      
-
+
+      !                              ! allocate obc arrays
+      IF( obc_oce_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'obc_init : unable to allocate obc_oce arrays' )
+      IF( obc_dta_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'obc_init : unable to allocate obc_dta arrays' )
 
       ! By security we set rdpxin and rdpxob respectively to 1. and 15. if the corresponding OBC is not activated
Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 2646)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 2647)
@@ -470,9 +470,4 @@
      USE trc_oce,      ONLY: trc_oce_alloc
 
-#if defined key_obc
-     USE obcdta ,      ONLY: obc_dta_alloc
-     USE obc_oce,      ONLY: obc_oce_alloc
-#endif
-
       USE wrk_nemo,    ONLY: wrk_alloc
 
@@ -491,11 +486,5 @@
       ierr = ierr + trc_oce_alloc   ()          ! shared TRC / TRA arrays
 
-
-#if defined key_obc
-      ierr = ierr + obc_dta_alloc()
-      ierr = ierr + obc_oce_alloc()
-#endif
-
-      ierr = ierr + wrk_alloc(numout, lwp)
+      ierr = ierr + wrk_alloc(numout, lwp)      ! workspace
 
       IF( lk_mpp    )   CALL mpp_sum( ierr )
