Index: /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90
===================================================================
--- /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 2817)
+++ /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 2818)
@@ -30,5 +30,6 @@
    USE domvvl          ! variable volume
    USE obc_oce         ! ocean open boundary conditions
-   USE obcdyn          ! open boundary condition for baroclinic velocities
+   USE obcdta          ! ocean open boundary conditions
+   USE obcdyn3d        ! ocean open boundary conditions
    USE obcvol          ! ocean open boundary condition (obc_vol routines)
    USE in_out_manager  ! I/O manager
@@ -154,5 +155,5 @@
       IF( .NOT. lk_dynspg_flt ) THEN
 
-         CALL obc_dyn( kt )
+         CALL obc_dyn3d( kt )
 
 !!$!!gm ERROR - potential BUG: sshn should not be modified at this stage !!   ssh_nxt not alrady called
Index: /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90
===================================================================
--- /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 2817)
+++ /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 2818)
@@ -206,7 +206,13 @@
                ! Update barotropic boundary conditions only
                ! jit is optional argument for fld_read
-               IF( nn_dyn2d(ib_obc) .gt. 0 .and. nn_tides(ib_obc) .ne. 1 ) THEN
-                  jend = jstart + 2
-                  CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), map=nbmap_ptr(jstart:jend), jit=jit )
+               IF( nn_dyn2d(ib_obc) .gt. 0 ) THEN
+                  IF( nn_tides(ib_obc) .eq. 1 ) THEN
+                     dta_obc(ib_obc)%ssh(:) = 0.0
+                     dta_obc(ib_obc)%u2d(:) = 0.0
+                     dta_obc(ib_obc)%v2d(:) = 0.0
+                  ELSE
+                     jend = jstart + 2
+                     CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), map=nbmap_ptr(jstart:jend), jit=jit )
+                  ENDIF
                ENDIF
                IF( nn_tides(ib_obc) .gt. 0 ) THEN
@@ -217,4 +223,9 @@
                   jend = jstart + nb_obc_fld(ib_obc) - 1
                   CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), map=nbmap_ptr(jstart:jend), timeshift=1 )
+               ENDIF
+               IF( nn_tides(ib_obc) .eq. 1 ) THEN
+                  dta_obc(ib_obc)%ssh(:) = 0.0
+                  dta_obc(ib_obc)%u2d(:) = 0.0
+                  dta_obc(ib_obc)%v2d(:) = 0.0
                ENDIF
                IF( nn_tides(ib_obc) .gt. 0 ) THEN
Index: /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcdyn2d.F90
===================================================================
--- /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcdyn2d.F90	(revision 2817)
+++ /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcdyn2d.F90	(revision 2818)
@@ -129,5 +129,4 @@
       TYPE(OBC_INDEX),              INTENT(in) ::   idx  ! OBC indices
       TYPE(OBC_DATA),               INTENT(in) ::   dta  ! OBC external data
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pssh
 
       INTEGER  ::   jb, igrd                         ! dummy loop indices
Index: /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90
===================================================================
--- /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90	(revision 2817)
+++ /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90	(revision 2818)
@@ -51,11 +51,11 @@
       !! ** Input   :  obc_init.nc, input file for unstructured open boundaries
       !!----------------------------------------------------------------------      
-      INTEGER  ::   ib_obc, ii, ij, ik, igrd, ib, ir   ! dummy loop indices
-      INTEGER  ::   icount, icountr, ibr_max, ilen1    ! local integers
-      INTEGER  ::   iw, ie, is, in, inum, id_dummy     !   -       -
-      INTEGER  ::   igrd_start, igrd_end, jpbdta       !   -       -
-      INTEGER, POINTER  ::  nbi, nbj, nbr              ! short cuts
-      REAL   , POINTER  ::  flagu, flagv               !    -   -
-      REAL(wp) ::   zefl, zwfl, znfl, zsfl             ! local scalars
+      INTEGER  ::   ib_obc, ii, ij, ik, igrd, ib, ir       ! dummy loop indices
+      INTEGER  ::   icount, icountr, ibr_max, ilen1, ibm1  ! local integers
+      INTEGER  ::   iw, ie, is, in, inum, id_dummy         !   -       -
+      INTEGER  ::   igrd_start, igrd_end, jpbdta           !   -       -
+      INTEGER, POINTER  ::  nbi, nbj, nbr                  ! short cuts
+      REAL   , POINTER  ::  flagu, flagv                   !    -   -
+      REAL(wp) ::   zefl, zwfl, znfl, zsfl                 ! local scalars
       INTEGER, DIMENSION (2)                ::   kdimsz
       INTEGER, DIMENSION(jpbgrd,jp_obc)       ::   nblendta         ! Length of index arrays 
@@ -302,4 +302,12 @@
             idx_obc(ib_obc)%nblenrim(igrd) = 0
             DO ib = 1, nblendta(igrd,ib_obc)
+               ! check that data is in correct order in file
+               ibm1 = MAX(1,ib-1)
+               IF(lwp) THEN         ! Since all procs read global data only need to do this check on one proc...
+                  IF( nbrdta(ib,igrd,ib_obc) < nbrdta(ibm1,igrd,ib_obc) ) THEN
+                     CALL ctl_stop('obc_init : ERROR : boundary data in file must be defined in order of distance from edge nbr.', &
+                                   'A utility for re-ordering boundary coordinates and data files exists in CDFTOOLS')
+                  ENDIF    
+               ENDIF
                ! check if point is in local domain
                IF(  nbidta(ib,igrd,ib_obc) >= iw .AND. nbidta(ib,igrd,ib_obc) <= ie .AND.   &
Index: /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 2817)
+++ /branches/2011/UKMO_MERCATOR_obc_bdy_merge/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 2818)
@@ -131,8 +131,16 @@
       LOGICAL  ::   llnxtmth   ! open next month file?
       LOGICAL  ::   llstop     ! stop is the file does not exist
+      LOGICAL  ::   ll_firstcall ! true if this is the first call to fld_read for this set of fields
       REAL(wp) ::   ztinta     ! ratio applied to after  records when doing time interpolation
       REAL(wp) ::   ztintb     ! ratio applied to before records when doing time interpolation
       CHARACTER(LEN=1000) ::   clfmt   ! write format
       !!---------------------------------------------------------------------
+      ll_firstcall = .false.
+      IF( PRESENT(jit) ) THEN
+         IF(kt == nit000 .and. jit == 1) ll_firstcall = .true.
+      ELSE
+         IF(kt == nit000) ll_firstcall = .true.
+      ENDIF
+
       ! Note that shifting time to be centrered in the middle of sbc time step impacts only nsec_* variables of the calendar 
       IF( present(jit) ) THEN 
@@ -146,5 +154,5 @@
       imf = SIZE( sd )
       !
-      IF( kt == nit000 ) THEN                      ! initialization
+      IF( ll_firstcall ) THEN                      ! initialization
          IF( PRESENT(map) ) THEN
             DO jf = 1, imf 
@@ -165,5 +173,5 @@
          DO jf = 1, imf                            ! ---   loop over field   --- !
             
-            IF( isecsbc > sd(jf)%nrec_a(2) .OR. kt == nit000 ) THEN  ! read/update the after data?
+            IF( isecsbc > sd(jf)%nrec_a(2) .OR. ll_firstcall ) THEN  ! read/update the after data?
 
                IF( sd(jf)%ln_tint ) THEN                             ! swap before record field and informations
@@ -173,5 +181,9 @@
                ENDIF
 
-               CALL fld_rec( kn_fsbc, sd(jf) )                       ! update record informations
+               IF( PRESENT(jit) ) THEN
+                  CALL fld_rec( kn_fsbc, sd(jf), jit=jit )              ! update record informations
+               ELSE
+                  CALL fld_rec( kn_fsbc, sd(jf) )                       ! update record informations
+               ENDIF
 
                ! do we have to change the year/month/week/day of the forcing field?? 
@@ -256,10 +268,4 @@
                ! temporal interpolation weights
                ztinta =  REAL( isecsbc - sd(jf)%nrec_b(2), wp ) / REAL( sd(jf)%nrec_a(2) - sd(jf)%nrec_b(2), wp )
-               IF( PRESENT(map) ) THEN 
-                  IF(lwp) WRITE(numout,*) '============================================'
-                  IF(lwp) WRITE(numout,*) 'Output from fld_read(map) on timestep ',kt
-                  IF(lwp) WRITE(numout,*) '============================================'
-                  IF(lwp) WRITE(numout,*) 'sd(jf)%nrec_b(2), sd(jf)%nrec_a(2), isecsbc, ztinta, ztintb : ',sd(jf)%nrec_b(2),sd(jf)%nrec_a(2),isecsbc,ztinta,ztintb
-               ENDIF
                ztintb =  1. - ztinta
 !CDIR COLLAPSE
@@ -433,5 +439,5 @@
 
 
-   SUBROUTINE fld_rec( kn_fsbc, sdjf, ldbefore )
+   SUBROUTINE fld_rec( kn_fsbc, sdjf, ldbefore, jit )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_rec  ***
@@ -447,4 +453,5 @@
       TYPE(FLD), INTENT(inout)           ::   sdjf      ! input field related variables
       LOGICAL  , INTENT(in   ), OPTIONAL ::   ldbefore  ! sent back before record values (default = .FALSE.)
+      INTEGER  , INTENT(in   ), OPTIONAL ::   jit       ! index of barotropic subcycle
                                                         ! used only if sdjf%ln_tint = .TRUE.
       !!
@@ -480,4 +487,5 @@
             !                            
             ztmp = REAL( nday, wp ) / REAL( nyear_len(1), wp ) + 0.5
+            IF( PRESENT(jit) ) ztmp = ztmp + jit*rdt/REAL(nn_baro,wp)
             sdjf%nrec_a(1) = 1 + INT( ztmp ) - COUNT((/llbefore/))
             ! swap at the middle of the year
@@ -508,4 +516,5 @@
             !                            
             ztmp = REAL( nday, wp ) / REAL( nmonth_len(nmonth), wp ) + 0.5
+            IF( PRESENT(jit) ) ztmp = ztmp + jit*rdt/REAL(nn_baro,wp)
             imth = nmonth + INT( ztmp ) - COUNT((/llbefore/))
             IF( sdjf%cltype == 'monthly' ) THEN   ;   sdjf%nrec_a(1) = 1 + INT( ztmp ) - COUNT((/llbefore/))
@@ -535,4 +544,5 @@
          ztmp = ztmp + 0.5 * REAL(kn_fsbc - 1, wp) * rdttra(1)   ! shift time to be centrered in the middle of sbc time step
          ztmp = ztmp + 0.01 * rdttra(1)                          ! add 0.01 time step to avoid truncation error 
+         IF( PRESENT(jit) ) ztmp = ztmp + jit*rdt/REAL(nn_baro,wp)
          IF( sdjf%ln_tint ) THEN                ! time interpolation, shift by 1/2 record
             !
@@ -687,5 +697,5 @@
       !!----------------------------------------------------------------------
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: utmp => wrk_2d_4, vtmp => wrk_2d_5      ! 2D workspace
+      USE wrk_nemo, ONLY: utmp => wrk_2d_24, vtmp => wrk_2d_25      ! 2D workspace
       !!
       INTEGER  , INTENT(in   )               ::   kt        ! ocean time step
@@ -699,5 +709,5 @@
       !!---------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 4,5) ) THEN
+      IF(wrk_in_use(2, 24,25) ) THEN
          CALL ctl_stop('fld_rot: ERROR: requested workspace arrays are unavailable.')   ;   RETURN
       END IF
@@ -736,5 +746,5 @@
        END DO
       !
-      IF(wrk_not_released(2, 4,5) )    CALL ctl_stop('fld_rot: ERROR: failed to release workspace arrays.')
+      IF(wrk_not_released(2, 24,25) )    CALL ctl_stop('fld_rot: ERROR: failed to release workspace arrays.')
       !
    END SUBROUTINE fld_rot
