Index: /trunk/NEMO/OPA_SRC/OBC/obc_oce.F90
===================================================================
--- /trunk/NEMO/OPA_SRC/OBC/obc_oce.F90	(revision 352)
+++ /trunk/NEMO/OPA_SRC/OBC/obc_oce.F90	(revision 353)
@@ -11,4 +11,13 @@
    !!  8.0   01/91   (CLIPPER)  Original code 
    !!  8.5   06/02   (C. Talandier)  modules
+   !!        06/04   (F. Durand) ORCA2_ZIND config
+   !!        06/04   (F. Durand) Dimensions of arrays vsdta, tsdta, ssdta,
+   !!                vndta, tndta, sndta, uwdta, twdta, swdta, uedta, tedta, sedta
+   !!                are defined to the actual dimensions of the OBs i.e. 
+   !!		     (jpisd:jpisf,jpk,jptobc) for the South OB
+   !! 		     (jpind:jpinf,jpk,jptobc) for the North OB 
+   !!		     (jpjwd:jpjwf,jpk,jptobc) for the West OB
+   !! 		     (jpjed:jpjef,jpk,jptobc) for the East OB
+   !!                 
    !!----------------------------------------------------------------------
    !! * Modules used
@@ -34,6 +43,6 @@
       nobc_dta = 0  ,      & !:  = 0 use the initial state as obc data
       !                      !   = 1 read obc data in obcxxx.dta files
-      nmoisold      ,      & !: number of the last read month on the OBC
-      nbef, naft             !: index of the aftera and before fields on the OBC 
+
+   LOGICAL ::  ln_obc_clim = .true.  !:  obc data files are climatological
 
    REAL(wp) ::             & !!: open boundary namelist (namobc)
@@ -116,5 +125,5 @@
       !                   ! in the obcdyn.F90 routine
 
-   REAL(wp), DIMENSION(jpjglo,jpk,1) ::   &  !:
+   REAL(wp), DIMENSION(jpjed:jpjef,jpk,jptobc) ::   &  !:
       uedta, tedta, sedta !: array used for interpolating monthly data on the east boundary
 
@@ -167,5 +176,5 @@
       !                   !  in the obcdyn.F90 routine
 
-   REAL(wp), DIMENSION(jpjglo,jpk,1) ::   &  !:
+   REAL(wp), DIMENSION(jpjwd:jpjwf,jpk,jptobc) ::   &  !:
       uwdta, twdta, swdta !: array used for interpolating monthly data on the west boundary
 
@@ -219,5 +228,5 @@
       !                   !  in yhe obcdyn.F90 routine
 
-   REAL(wp), DIMENSION(jpiglo,jpk,1) ::   &  !:
+   REAL(wp), DIMENSION(jpind:jpinf,jpk,jptobc) ::   &  !:
       vndta, tndta, sndta !: array used for interpolating monthly data on the north boundary
 
@@ -270,5 +279,5 @@
       !                   !  in the obcdyn.F90 routine
 
-   REAL(wp), DIMENSION(jpiglo,jpk,1) ::    &    !:
+   REAL(wp), DIMENSION(jpisd:jpisf,jpk,jptobc) ::    &    !:
       vsdta, tsdta, ssdta   !: array used for interpolating monthly data on the south boundary
 
Index: /trunk/NEMO/OPA_SRC/OBC/obc_par.F90
===================================================================
--- /trunk/NEMO/OPA_SRC/OBC/obc_par.F90	(revision 352)
+++ /trunk/NEMO/OPA_SRC/OBC/obc_par.F90	(revision 353)
@@ -11,4 +11,7 @@
    !!  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
@@ -34,4 +37,6 @@
    !! open boundary parameter
    !!---------------------------------------------------------------------
+   INTEGER, PARAMETER ::     &  !: time dimension of the BCS fields on input
+      jptobc  =	      2 
    !! * EAST open boundary
    LOGICAL, PARAMETER ::     &  !:
Index: /trunk/NEMO/OPA_SRC/OBC/obc_par_EEL_R5.h90
===================================================================
--- /trunk/NEMO/OPA_SRC/OBC/obc_par_EEL_R5.h90	(revision 352)
+++ /trunk/NEMO/OPA_SRC/OBC/obc_par_EEL_R5.h90	(revision 353)
@@ -9,4 +9,6 @@
    !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
    !!----------------------------------------------------------------------
+   INTEGER, PARAMETER ::     &  !: time dimension for the BCS fields on input
+      jptobc  =	      2 
 
    !! * EAST open boundary
Index: /trunk/NEMO/OPA_SRC/OBC/obc_vectopt_loop_substitute.h90
===================================================================
--- /trunk/NEMO/OPA_SRC/OBC/obc_vectopt_loop_substitute.h90	(revision 352)
+++ /trunk/NEMO/OPA_SRC/OBC/obc_vectopt_loop_substitute.h90	(revision 353)
@@ -10,5 +10,5 @@
    !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
    !!----------------------------------------------------------------------
-#if defined key_vectopt_loop && defined key_obc
+#if defined key_vectopt_loop && defined key_obc && ! defined key_mpp_mpi && ! defined key_mpp_shmem
 #  define fs_niw0  jpiwob 
 #  define fs_niw1  jpiwob
Index: /trunk/NEMO/OPA_SRC/OBC/obcdta.F90
===================================================================
--- /trunk/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 352)
+++ /trunk/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 353)
@@ -19,6 +19,7 @@
    USE daymod          ! calendar
    USE in_out_manager  ! I/O logical units
-   USE lib_mpp         ! distribued memory computing
+   USE lib_mpp         ! distributed memory computing
    USE dynspg_rl       ! 
+   USE ioipsl
 
 
@@ -30,106 +31,215 @@
    PRIVATE
 
-   !! * Accessibility
-   PUBLIC obc_dta                         ! routines called by step.F90
+!! * Accessibility
+   PUBLIC obc_dta        ! routines called by step.F90
+
+   !! * Shared module variables
+   INTEGER ::   &
+      nlecto =  0,    &  ! switch for the first read
+      ntobc1      ,   &  ! first record used
+      ntobc2             ! second record used
    
    !! * Substitutions
 #  include "obc_vectopt_loop_substitute.h90"
    !!---------------------------------------------------------------------------------
-   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
-   !! $Header$ 
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!   OPA 9.0 , LODYC-IPSL  (2003)
    !!---------------------------------------------------------------------------------
 
 CONTAINS
 
-   SUBROUTINE obc_dta( kt )
-      !!---------------------------------------------------------------------------
-      !!                      ***  SUBROUTINE obc_dta  ***
-      !!                    
-      !! ** Purpose :   Find the climatological  boundary arrays for the specified date, 
-      !!      Originally this routine interpolated between monthly fields
-      !!      of a climatology.
-      !!      When using hydrological section data, we have only on snapshot
-      !!      and do not need to interpolate.
-      !!
-      !! ** Method  :   Determine the current month from kdat, and interpolate for
-      !!      the current day.
+   SUBROUTINE obc_dta (kt)
+      !!--------------------------------------------------------------------
+      !!              ***  SUBROUTINE obc_dta  ***
+      !!                   
+      !! ** Purpose :
+      !!   Find the climatological boundary arrays for the specified date,
+      !!   The boundary arrays are netcdf files. Three possible cases:
+      !!   - one time frame only in the file (time dimension = 1).
+      !!     in that case the boundary data does not change in time.
+      !!   - many time frames. In that case,  if we have 12 frames
+      !!     we assume monthly fields.
+      !!     Else, we assume that time_counter is in seconds
+      !!     since the beginning of either the current year or a reference
+      !!     year given in the namelist.
+      !!     (no check is done so far but one would have to check the "unit"
+      !!     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
+      !!--------------------------------------------------------------------
       !! * Arguments
       INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
-
+      
       !! * Local declarations
-      INTEGER ::   ji, jj, jk, ii, ij        ! dummy loop indices
-      INTEGER ::   inum = 11                 ! temporary logical unit
-      INTEGER ::   imois, iman, imoisp1
+      INTEGER ::   ji, jj, jk, ii, ij   ! dummy loop indices
+      INTEGER ::   itimo, iman, imois
       INTEGER ::   i15
-      INTEGER ::   irecl, irec, ios
-      INTEGER, PARAMETER ::    &
-               jpmois = 1,     &
-               jpf    = 3
       REAL(wp) ::   zxy
-      CHARACTER (len=4 ) ::   clversion
-      CHARACTER (len=80) ::   clcom
-      !!---------------------------------------------------------------------
-
-
-      IF( lk_dynspg_rl )   CALL obc_dta_psi( kt )     ! update bsf data at open boundaries
-
-
-      ! 0. Initialization of date
-      !    imois is the index (1 to 12) of the first month to be used in the 
-      !    interpolation. ndastp is the date (integer format yymmdd) calculated 
-      !    in routine day.F starting from ndate0 given in namelist.
-      ! -----------------------------------------------------------------------
-
-      iman  = jpmois
-      i15 = nday/16
-      imois = nmonth + i15 - 1
-      IF( imois == 0 )   imois = iman
-      imoisp1 = MOD( imois + 1, iman )
-      IF( imoisp1 == 0 ) imoisp1 = iman 
-      ! ... zxy is the weight of the after field
-      zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
-      IF( zxy > 1.01 .OR. zxy < 0. ) THEN
-         IF(lwp) WRITE(numout,*)'           '
-         IF(lwp) WRITE(numout,*)'obc_dta: Pbm with the the weight of the after field zxy '
-         IF(lwp) WRITE(numout,*)'~~~~~~~~~~~'
-         nstop = nstop + 1
-      END IF
-
-      ! 1.   First call:
-      ! ----------------
-
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)'           '
-         IF(lwp) WRITE(numout,*)'obcdta: initial step in obc_dta'
-         IF(lwp) WRITE(numout,*)'~~~~~~  months ',imois,' and', imoisp1,' read'
-
-         ! 1.1  Tangential velocities set to zero
-         ! --------------------------------------
-         IF( lp_obc_east  )   vfoe(:,1:jpkm1) = 0.e0
-         IF( lp_obc_west  )   vfow(:,1:jpkm1) = 0.e0
-         IF( lp_obc_south )   ufos(:,1:jpkm1) = 0.e0
-         IF( lp_obc_north )   ufon(:,1:jpkm1) = 0.e0
-
-         ! 1.2 Set the Normal velocity and tracers data for the EAST OBC
-         ! -------------------------------------------------------------
-
-         IF( lp_obc_east ) THEN
-
+      !! * Ajouts FD
+      INTEGER ::  iyrel              ! number of years since 1992
+      INTEGER ::  isrel              ! number of seconds since 1/1/1992
+      INTEGER, SAVE ::  itobce, itobcw,  & ! number of time steps in OBC files
+                        itobcs, itobcn,  & !    "       "       "       "
+                        itobc
+      INTEGER ::  ikprint        ! frequency for printouts.
+      INTEGER :: fid_e, fid_w, fid_n, fid_s, fid  ! file identifiers
+      LOGICAL :: l_exv
+      INTEGER, DIMENSION(flio_max_dims) ::    &
+            f_d  ,             & ! dimensions lenght
+            start,             & ! starting index read
+            count                ! number of indices to be read
+      ! time_counter variable of BCs
+      REAL(wp),DIMENSION(:),ALLOCATABLE :: ztcobc
+     
+      CHARACTER(LEN=25) :: f_name,v_name
+      !!--------------------------------------------------------------------
+
+      IF( lk_dynspg_rl )  THEN
+         CALL obc_dta_psi (kt)     ! update bsf data at open boundaries
+         IF( nobc_dta == 1 .AND. kt == nit000 )   THEN
+            IF(lwp) WRITE(numout,*) ' time-variable psi boundary data not allowed yet'
+            STOP
+         ENDIF
+      ENDIF
+      
+      CALL ipslnlf (new_number=numout)
+     
+      ! 1.   First call: check time frames available in files.
+      ! -------------------------------------------------------
+
+      IF( kt == nit000 )   THEN
+      
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*)     'obc_dta : find boundary data'
+         IF(lwp) WRITE(numout,*)     '~~~~~~~'
+             
+         IF( nobc_dta == 0 )   THEN
+            IF(lwp) WRITE(numout,*)  '  OBC data taken from initial conditions.'
+            ntobc1 = 1
+            ntobc2 = 1
+         ELSE    
+            IF(lwp) WRITE(numout,*)  '  OBC data taken from netcdf files.'
+            IF(lwp) WRITE(numout,*)  '  climatology (T/F):',ln_obc_clim
+            ! check the number of time steps in the files.
+            itobce =0 ; itobcw = 0; itobcn = 0; itobcs = 0
+            v_name = 'time_counter'
+            IF( lp_obc_east )   THEN
+               CALL flioopfd ('obceast_TS.nc',fid_e)
+               CALL flioinqv (fid_e,TRIM(v_name),l_exv,len_dims=f_d) 
+               IF( l_exv )   THEN
+                  itobce = f_d(1)
+               ELSE
+                  WRITE(numout,*) ' Variable ',TRIM(v_name),' not found in file ','obceast_TS.nc'
+               ENDIF
+            ENDIF
+            IF( lp_obc_west )   THEN
+               CALL flioopfd ('obcwest_TS.nc',fid_w)
+               CALL flioinqv (fid_w,TRIM(v_name),l_exv,len_dims=f_d) 
+               IF( l_exv )   THEN
+                  itobcw = f_d(1)
+               ELSE
+                  WRITE(numout,*) ' Variable ',TRIM(v_name),' not found in file ','obcwest_TS.nc'
+               ENDIF
+            ENDIF
+            IF( lp_obc_north )   THEN
+               CALL flioopfd ('obcnorth_TS.nc',fid_n)
+               CALL flioinqv (fid_n,TRIM(v_name),l_exv,len_dims=f_d) 
+               IF( l_exv )   THEN
+                  itobcn = f_d(1)
+               ELSE
+                  WRITE(numout,*) ' Variable ',TRIM(v_name),' not found in file ','obcnorth_TS.nc'
+               ENDIF
+            ENDIF
+            IF( lp_obc_south )   THEN
+               CALL flioopfd ('obcsouth_TS.nc',fid_s)
+               CALL flioinqv (fid_s,TRIM(v_name),l_exv,len_dims=f_d) 
+               IF( l_exv )   THEN
+                  itobcs = f_d(1)
+               ELSE
+                  WRITE(numout,*) ' Variable ',TRIM(v_name),' not found in file ','obcsouth_TS.nc'
+               ENDIF
+            ENDIF
+
+            itobc = MAX(itobce,itobcw,itobcn,itobcs)
+            nstop = 0
+            IF( lp_obc_east  .AND. itobce /= itobc ) nstop = nstop+1 
+            IF( lp_obc_west  .AND. itobcw /= itobc ) nstop = nstop+1      
+            IF( lp_obc_north .AND. itobcn /= itobc ) nstop = nstop+1
+            IF( lp_obc_south .AND. itobcs /= itobc ) nstop = nstop+1 
+            IF( nstop /= 0 )  THEN
+               IF( lwp )   THEN
+                  WRITE(numout,*) ' obcdta : all files must have the same number of time steps'
+                  WRITE(numout,*) ' east, west, north, south: ', itobce, itobcw, itobcn, itobcs
+               ENDIF
+               STOP
+            ENDIF
+            IF( itobc == 1 )   THEN
+               IF( lwp ) WRITE(numout,*) ' obcdta found one time step only in the OBC files'
+            ELSE
+               ALLOCATE (ztcobc(itobc))
+               l_exv = .TRUE.
+               IF( lp_obc_east )   THEN
+                  IF( l_exv )   THEN
+                     CALL fliogetv (fid_e,TRIM(v_name),ztcobc)
+                     l_exv = .FALSE.
+                  ENDIF
+                  CALL flioclo (fid_e)
+               ENDIF
+               IF( lp_obc_west )   THEN
+                 IF( l_exv )   THEN
+                    CALL fliogetv (fid_w,TRIM(v_name),ztcobc)
+                    l_exv = .FALSE.
+                 ENDIF
+                 CALL flioclo (fid_w)
+               ENDIF
+               IF( lp_obc_north )   THEN
+                 IF( l_exv )   THEN
+                    CALL fliogetv (fid_n,TRIM(v_name),ztcobc)
+                    l_exv = .FALSE.
+                 ENDIF
+                 CALL flioclo (fid_n)
+               ENDIF
+               IF( lp_obc_south )   THEN
+                 IF( l_exv )   THEN
+                    CALL fliogetv (fid_s,TRIM(v_name),ztcobc)
+                    l_exv = .FALSE.
+                 ENDIF
+                 CALL flioclo (fid_s)
+               ENDIF
+               IF( lwp ) WRITE(numout,*) ' obcdta found', itobc,' time steps in the OBC files'
+               IF( .NOT. ln_obc_clim .AND. itobc == 12 )   THEN
+                  IF ( lwp ) WRITE(numout,*) '  WARNING: With monthly data we assume climatology'
+                  ln_obc_clim = .true.
+               ENDIF
+            ENDIF
+         ENDIF
+      
+       ! 1.1  Tangential velocities set to zero
+       ! --------------------------------------
+         IF( lp_obc_east  ) vfoe = 0.0
+         IF( lp_obc_west  ) vfow = 0.0
+         IF( lp_obc_south ) ufos = 0.0
+         IF( lp_obc_north ) ufon = 0.0
+      
+       ! 1.2  Data temperature, salinity, normal velocities set to zero
+       !                        or initial conditions if nobc_dta == 0
+       ! --------------------------------------------------------------
+
+         IF( lp_obc_east )   THEN
             ! initialisation to zero
-            sedta(:,:,1) = 0.e0
-            tedta(:,:,1) = 0.e0
-            uedta(:,:,1) = 0.e0
-            !                                         ! ================== !
-            IF( nobc_dta == 0 )   THEN                ! initial state used
-               !                                      ! ================== !
-               DO ji = fs_nie0, fs_nie1 ! Vector opt.
+            sedta(:,:,:) = 0.e0
+            tedta(:,:,:) = 0.e0
+            uedta(:,:,:) = 0.e0
+            !                                    ! ================== !
+            IF( nobc_dta == 0 )   THEN           ! initial state used
+               !                                 ! ================== !
+               !  Fills sedta, tedta, uedta (global arrays)
+               !  Remark: this works for njzoom = 1.
+               !          Should the definition of ij include njzoom?
+               DO ji = nie0, nie1
                   DO jk = 1, jpkm1
-                     DO jj = 1, jpj
+                     DO jj = nje0p1, nje1m1
                         ij = jj -1 + njmpp
                         sedta(ij,jk,1) = sn(ji,jj,jk)*tmask(ji,jj,jk)
@@ -139,94 +249,21 @@
                   END DO
                END DO
-               
-               DO jk = 1, jpkm1
-                  DO jj = 1, jpj
-                     ij = jj -1 + njmpp
-                     sfoe(jj,jk) =  sedta(ij,jk,1)*temsk(jj,jk)  
-                     tfoe(jj,jk) =  tedta(ij,jk,1)*temsk(jj,jk)    
-                     ufoe(jj,jk) =  uedta(ij,jk,1)*uemsk(jj,jk)  
-                  END DO
-               END DO
-               !                                      ! =================== !
-            ELSE                                      ! read in obceast.dta
-               !                                      ! =================== !
-               OPEN(UNIT   = inum,       &
-                    IOSTAT = ios,          &
-                    FILE   ='obceast.dta', &
-                    FORM   ='UNFORMATTED', &
-                    ACCESS ='DIRECT',      &
-                    RECL   = 4096 )
-               IF( ios > 0 ) THEN
-                  IF(lwp) WRITE(numout,*) 'obc_dta: Pbm to OPEN the obceast.dta file '
-                  IF(lwp) WRITE(numout,*) '~~~~~~~'
-                  nstop = nstop + 1
-               END IF
-               READ(inum,REC=1) clversion,clcom,irecl
-               CLOSE(inum)
-               IF(lwp) WRITE(numout,*)'       '
-               IF(lwp) WRITE(numout,*)'        opening obceast.dta  with irecl=',irecl
-               OPEN(UNIT   = inum,       &
-                    IOSTAT = ios,          &
-                    FILE   ='obceast.dta', &
-                    FORM   ='UNFORMATTED', &
-                    ACCESS ='DIRECT',      &
-                    RECL   = irecl )
-               IF( ios > 0 ) THEN
-                  IF(lwp) WRITE(numout,*) 'obc_dta: Pbm to OPEN the obceast.dta file '
-                  IF(lwp) WRITE(numout,*) '~~~~~~~'
-                  nstop = nstop + 1
-               END IF
-   
-               ! ... Read datafile and set temperature, salinity and normal velocity
-               ! ... initialise the sedta, tedta arrays
-               ! ... index 1 refer to before, 2 to after
-
-               DO jk = 1, jpkm1
-                  irec = 2 +  (jk -1)* jpf
-                  READ(inum,REC=irec  )((sedta(jj,jk,1),ji=1,1),jj=jpjed, jpjef)
-                  READ(inum,REC=irec+1)((tedta(jj,jk,1),ji=1,1),jj=jpjed, jpjef)
-                  READ(inum,REC=irec+2)((uedta(jj,jk,1),ji=1,1),jj=jpjed, jpjef)
-                  ! ... set climatological temperature and salinity at the boundary
-                  ! ... do not interpolate between months : impose values of climatology
-                  DO jj = 1, jpj
-                     ij = jj -1 + njmpp
-                     sfoe(jj,jk) = sedta(ij,jk,1)*temsk(jj,jk)
-                     tfoe(jj,jk) = tedta(ij,jk,1)*temsk(jj,jk)
-                  END DO
-               END DO
-               CLOSE(inum)
-
-# if ! defined key_dynspg_fsc
-               ! ... Rigid lid case: make sure uedta is baroclinic velocity
-               ! ... In rigid lid case uedta needs to be the baroclinic component.
-
-               CALL obc_cli( uedta, uclie, fs_nie0, fs_nie1, 0, jpj, njmpp )  
-
-# endif
-               ! ... Set normal velocity (on nie0, nie1 <=> jpieob)
-               DO jk = 1, jpkm1
-                  DO jj = 1, jpj
-                     ij = jj -1 + njmpp
-                     ufoe(jj,jk) =  uedta(ij,jk,1)*uemsk(jj,jk)
-                  END DO
-               END DO
-            ENDIF
-         ENDIF
-
-         ! 1.3 Set the Normal velocity and tracers data for the WEST OBC
-         ! -------------------------------------------------------------
-
-         IF( lp_obc_west ) THEN
-
+            ENDIF
+         ENDIF
+
+         IF( lp_obc_west )   THEN
             ! initialisation to zero
-            swdta(:,:,1) = 0.e0
-            twdta(:,:,1) = 0.e0
-            uwdta(:,:,1) = 0.e0
-            !                                         ! ================== !
-            IF( nobc_dta == 0 )   THEN                ! initial state used
-               !                                      ! ================== !
-               DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            swdta(:,:,:) = 0.e0
+            twdta(:,:,:) = 0.e0
+            uwdta(:,:,:) = 0.e0
+            !                                    ! ================== !
+            IF( nobc_dta == 0 )   THEN           ! initial state used !
+               !                                 ! ================== !
+               !  Fills swdta, twdta, uwdta (global arrays)
+               !  Remark: this works for njzoom = 1. 
+               !          Should the definition of ij include njzoom?
+               DO ji = niw0, niw1
                   DO jk = 1, jpkm1
-                     DO jj = 1, jpj
+                     DO jj = njw0p1, njw1m1
                         ij = jj -1 + njmpp
                         swdta(ij,jk,1) = sn(ji,jj,jk)*tmask(ji,jj,jk)
@@ -236,275 +273,327 @@
                   END DO
                END DO
-   
-               DO jk = 1, jpkm1
-                  DO jj = 1, jpj
-                     ij = jj -1 + njmpp
-                     sfow(jj,jk) = swdta(ij,jk,1)*twmsk(jj,jk)
-                     tfow(jj,jk) = twdta(ij,jk,1)*twmsk(jj,jk)
-                     ufow(jj,jk) = uwdta(ij,jk,1)*uwmsk(jj,jk)
+            ENDIF
+         ENDIF
+
+         IF( lp_obc_north)   THEN
+            ! initialisation to zero
+            sndta(:,:,:) = 0.e0
+            tndta(:,:,:) = 0.e0
+            vndta(:,:,:) = 0.e0
+            !                                    ! ================== !
+            IF( nobc_dta == 0 )   THEN           ! initial state used
+               !                                 ! ================== !
+               !  Fills sndta, tndta, vndta (global arrays)
+               !  Remark: this works for njzoom = 1. 
+               !          Should the definition of ij include njzoom?
+               DO jj = njn0, njn1
+                  DO jk = 1, jpkm1
+                     DO ji = nin0p1, nin1m1
+                        ii = ji -1 + nimpp
+                        sndta(ii,jk,1) = sn(ji,jj,jk)*tmask(ji,jj,jk)
+                        tndta(ii,jk,1) = tn(ji,jj,jk)*tmask(ji,jj,jk)
+                        vndta(ii,jk,1) = vn(ji,jj,jk)*vmask(ji,jj,jk)
+                     END DO
                   END DO
                END DO
-               !                                      ! =================== !
-            ELSE                                      ! read in obceast.dta
-               !                                      ! =================== !
-               OPEN(UNIT   = inum,      &
-                 IOSTAT = ios,          &
-                 FILE   ='obcwest.dta', &
-                 FORM   ='UNFORMATTED', &
-                 ACCESS ='DIRECT',      &
-                 RECL   = 4096 )
-               IF( ios > 0 ) THEN
-                  IF(lwp) WRITE(numout,*) 'obc_dta: Pbm to OPEN the obcwest.dta file '
-                  IF(lwp) WRITE(numout,*) '~~~~~~~'
-                  nstop = nstop + 1
-               END IF
-               READ(inum,REC=1) clversion, clcom,irecl
-               CLOSE(inum)
-               IF(lwp) WRITE(numout,*)'       '
-               IF(lwp) WRITE(numout,*)'         opening obcwest.dta  with irecl=',irecl
-               OPEN(UNIT   = inum,      &
-                 IOSTAT = ios,          &
-                 FILE   ='obcwest.dta', &
-                 FORM   ='UNFORMATTED', &
-                 ACCESS ='DIRECT',      &
-                 RECL   = irecl )
-               IF( ios > 0 ) THEN
-                  IF(lwp) WRITE(numout,*) 'obc_dta: Pbm to OPEN the obcwest.dta file '
-                  IF(lwp) WRITE(numout,*) '~~~~~~~'
-                  nstop = nstop + 1
-               END IF
-
-               ! ... Read datafile and set temperature, salinity and normal velocity
-               ! ... initialise the swdta, twdta arrays
-               ! ... index 1 refer to before, 2 to after
-               DO jk = 1, jpkm1
-                  irec = 2 +  (jk -1)* jpf
-                  READ(inum,REC=irec  )((swdta(jj,jk,1),ji=1,1),jj=jpjwd, jpjwf)
-                  READ(inum,REC=irec+1)((twdta(jj,jk,1),ji=1,1),jj=jpjwd, jpjwf)
-                  READ(inum,REC=irec+2)((uwdta(jj,jk,1),ji=1,1),jj=jpjwd, jpjwf)
-                  DO jj = 1, jpj
-                     ij = jj -1 + njmpp
-                     sfow(jj,jk) = swdta(ij,jk,1)*twmsk(jj,jk)
-                     tfow(jj,jk) = twdta(ij,jk,1)*twmsk(jj,jk)
+            ENDIF
+         ENDIF
+
+         IF( lp_obc_south )   THEN
+            ! initialisation to zero
+            ssdta(:,:,:) = 0.e0
+            tsdta(:,:,:) = 0.e0
+            vsdta(:,:,:) = 0.e0
+            !                                    ! ================== !
+            IF( nobc_dta == 0 )   THEN           ! initial state used
+               !                                 ! ================== !
+               !  Fills ssdta, tsdta, vsdta (global arrays)
+               !  Remark: this works for njzoom = 1. 
+               !          Should the definition of ij include njzoom?
+               DO jj = njs0, njs1
+                  DO jk = 1, jpkm1
+                     DO ji = nis0p1, nis1m1
+                        ii = ji -1 + nimpp
+                        ssdta(ii,jk,1) = sn(ji,jj,jk)*tmask(ji,jj,jk)
+                        tsdta(ii,jk,1) = tn(ji,jj,jk)*tmask(ji,jj,jk)
+                        vsdta(ii,jk,1) = vn(ji,jj,jk)*vmask(ji,jj,jk)
+                     END DO
                   END DO
                END DO
-               CLOSE(inum)
-
-#if ! defined key_dynspg_fsc
-               ! ... Rigid lid case: make sure uwdta is baroclinic velocity
-               ! ... In rigid lid case uwdta needs to be the baroclinic component.
-
-               CALL obc_cli( uwdta, ucliw, fs_niw0, fs_niw1, 0, jpj, njmpp )  
-
-# endif
-               ! ... Set normal velocity (on niw0, niw1 <=> jpiwob)
-               DO jk = 1, jpkm1
-                   DO jj = 1, jpj
-                      ij = jj -1 + njmpp
-                      ufow(jj,jk) = uwdta(ij,jk,1)*uwmsk(jj,jk)
-                   END DO
-               END DO
-            ENDIF
-         ENDIF
-
-         ! 1.4 Set the Normal velocity and tracers data for the NORTH OBC
-         ! ---------------------------------------------------------------
-
-         IF( lp_obc_north ) THEN
-
-            ! initialisation to zero
-            sndta(:,:,1) = 0.e0
-            tndta(:,:,1) = 0.e0
-            vndta(:,:,1) = 0.e0
-
-            OPEN(UNIT   = inum,          &
-                 IOSTAT = ios,           &
-                 FILE   ='obcnorth.dta', &
-                 FORM   ='UNFORMATTED',  &
-                 ACCESS ='DIRECT',       &
-                 RECL   = 4096 )
-            IF( ios > 0 ) THEN
-               IF(lwp) WRITE(numout,*) 'obc_dta: Pbm to OPEN the obcnorth.dta file '
-               IF(lwp) WRITE(numout,*) '~~~~~~~'
-               nstop = nstop + 1
-            END IF
-            READ(inum,REC=1) clversion,clcom,irecl
-            CLOSE(inum)
-            IF(lwp) WRITE(numout,*)'       '
-            IF(lwp) WRITE(numout,*)'        opening obcnorth.dta  with irecl=',irecl
-            OPEN(UNIT   = inum,        &
-                 IOSTAT = ios,           &
-                 FILE   ='obcnorth.dta', & 
-                 FORM   ='UNFORMATTED',  &
-                 ACCESS ='DIRECT',       &
-                 RECL   = irecl )
-            IF( ios > 0 ) THEN
-               IF(lwp) WRITE(numout,*) 'obc_dta: Pbm to OPEN the obcnorth.dta file '
-               IF(lwp) WRITE(numout,*) '~~~~~~~'
-               nstop = nstop + 1
-            END IF
-
-            ! ... Read datafile and set temperature and salinity
-            ! ... initialise the sndta, tndta  arrays
-            ! ... index 1 refer to before, 2 to after
-            DO jk = 1, jpkm1
-               irec = 2 +  (jk -1)* jpf
-               READ(inum,REC=irec  )((sndta(jj,jk,1),ji=1,1),jj=jpind, jpinf)
-               READ(inum,REC=irec+1)((tndta(jj,jk,1),ji=1,1),jj=jpind, jpinf)
-               READ(inum,REC=irec+2)((vndta(jj,jk,1),ji=1,1),jj=jpind, jpinf)
-               ! ... do not interpolate: impose values of climatology
-               DO ji = 1, jpi
-                  ii = ji -1 + nimpp
-                  sfon(ji,jk) = sndta(ii,jk,1)*tnmsk(ji,jk)
-                  tfon(ji,jk) = tndta(ii,jk,1)*tnmsk(ji,jk)
-               END DO
-            END DO
-            CLOSE(inum)
-
-# if ! defined key_dynspg_fsc
-            ! ... Rigid lid case: make sure vndta is baroclinic velocity
-            !     In rigid lid case vndta needs to be the baroclinic component.
-            !     substract the barotropic velocity component (zvnbtpe)
-            !     from the total one (vndta).
-
-            CALL obc_cli( vndta, vclin, fs_njn0, fs_njn1, 1, jpi, nimpp )  
-# endif
-            ! ... Set normal velocity (on njn0, njn1 <=> jpjnob)
-            DO jk = 1, jpkm1
-               DO ji = 1, jpi
-                  ii = ji -1 + nimpp
-                  vfon(ji,jk) =  vndta(ii,jk,1)*vnmsk(ji,jk)
-               END DO
-            END DO
-
-         END IF
-
-         ! 1.5 Set the Normal velocity and tracers data for the SOUTH OBC
-         ! ---------------------------------------------------------------
-
-         IF( lp_obc_south ) THEN
-
-            ! initialisation to zero
-            ssdta(:,:,1) = 0.e0
-            tsdta(:,:,1) = 0.e0
-            vsdta(:,:,1) = 0.e0
-
-            OPEN(UNIT   = inum,        &
-                 IOSTAT = ios,           &
-                 FILE   ='obcsouth.dta', &
-                 FORM   ='UNFORMATTED',  &
-                 ACCESS ='DIRECT',       &
-                 RECL   = 4096 )
-            IF( ios > 0 ) THEN
-               IF(lwp) WRITE(numout,*) 'obc_dta: Pbm to OPEN the obcsouth.dta file '
-               IF(lwp) WRITE(numout,*) '~~~~~~~'
-               nstop = nstop + 1
-            END IF
-            READ(inum,REC=1) clversion,clcom,irecl
-            CLOSE(inum)
-            IF(lwp) WRITE(numout,*)'       '
-            IF(lwp) WRITE(numout,*)'        opening obcsouth.dta  with irecl=',irecl
-            OPEN(UNIT   = inum,        &
-                 IOSTAT = ios,           &
-                 FILE   ='obcsouth.dta', &
-                 FORM   ='UNFORMATTED',  &
-                 ACCESS ='DIRECT',       &
-                 RECL   = irecl )
-            IF( ios > 0 ) THEN
-               IF(lwp) WRITE(numout,*) 'obc_dta: Pbm to OPEN the obcsouth.dta file '
-               IF(lwp) WRITE(numout,*) '~~~~~~~'
-               nstop = nstop + 1
-            END IF
-
+            ENDIF
+         ENDIF
+
+      ENDIF        !       end if kt == nit000
+      
+      ! 2.  Initialize the time we are at.
+      !     Does this every time the routine is called,
+      !     excepted when nobc_dta = 0
+      !---------------------------------------------------------------------
+      IF( nobc_dta == 0 )   THEN
+         itimo = 1
+         zxy   = 0
+      ELSE
+         IF( itobc == 1 )   THEN
+            itimo = 1
+         ELSE IF( itobc == 12 )   THEN      !   BC are monthly   
+            ! we assume we have climatology in that case
+            iman  = 12
+            i15   = nday / 16
+            imois = nmonth + i15 - 1
+            IF( imois == 0 )   imois = iman
+            itimo = imois   
+         ELSE
+            IF(lwp) WRITE(numout,*) 'data other than constant or monthly not written yet'
+            STOP
+         ENDIF
+      ENDIF
+      
+      ! 2.1 Read two records in the file if necessary
+      ! ---------------------------------------------
+      IF( ( nobc_dta == 1 ) .AND. ( ( kt == nit000 .AND. nlecto == 0 ) .OR. itimo  /= ntobc1 ) )   THEN
+         nlecto = 1
+      
+         ! Calendar computation
+         IF( itobc == 1 )   THEN            !  BC are constant in time
+            ntobc1 = 1
+            ntobc2 = 1  
+         ELSE IF( itobc == 12 )   THEN      !   BC are monthly   
+            ntobc1 = itimo         ! first file record used
+            ntobc2 = ntobc1 + 1    ! last  file record used
+            ntobc1 = MOD( ntobc1, iman )
+            IF( ntobc1 == 0 )   ntobc1 = iman
+            ntobc2 = MOD( ntobc2, iman )
+            IF( ntobc2 == 0 )   ntobc2 = iman
+            IF( lwp )   THEN
+               WRITE(numout,*) ' read monthly obc first record file used ntobc1 ', ntobc1
+               WRITE(numout,*) ' read monthly obc last  record file used ntobc2 ', ntobc2
+            ENDIF
+         ELSE
+            !!!!!!!!!!!!!ATTENTION el: A verifier en fction de la convention choisie pour
+            !!!!!!!!!!!!! le codage de nyear, pour les runs interannuels !!!!!!!!!!!!!!
+            !!!  attention if ln_obc_clim is true, go back to jan 1st after december 31st
+            iyrel=nyear-1991
+            IF( ( iyrel < 1 ) .OR. ( iyrel > 13 ) )   THEN
+               IF( lwp ) WRITE(numout,*) 'Pb OBCDTA : iyrel'
+               STOP
+            ENDIF
+            ! Compute nb of seconds from 1/1/1992 00:00 :
+            isrel=(365*(iyrel-1)+nday_year)*86400
+            IF( lwp )   THEN
+               WRITE(numout,*)'Nbre de secondes ecoulees depuis le 1/1/1992:'
+               WRITE(numout,*) isrel
+            ENDIF
+      
+            !  need to calculate here ntobc1 and ntobc2, the two time steps to be read
+      
+         ENDIF
+                               ! ======================= !
+                               !  BCs read               !
+         !                     ! ======================= !
+         IF( lp_obc_east )   THEN
             ! ... Read datafile and set temperature, salinity and normal velocity
-            ! ... initialise the ssdta, tsdta  arrays
-            ! ... index 1 refer to before, 2 to after
-            DO jk = 1, jpkm1
-               irec = 2 +  (jk -1)* jpf
-               READ(inum,REC=irec  )((ssdta(jj,jk,1),ji=1,1),jj=jpisd, jpisf)
-               READ(inum,REC=irec+1)((tsdta(jj,jk,1),ji=1,1),jj=jpisd, jpisf)
-               READ(inum,REC=irec+2)((vsdta(jj,jk,1),ji=1,1),jj=jpisd, jpisf)
-               ! ... do not interpolate: impose values of climatology
-               DO ji = 1, jpi
-                  ii = ji -1 + nimpp
-                  sfos(ji,jk) = ssdta(ii,jk,1)*tsmsk(ji,jk)
-                  tfos(ji,jk) = tsdta(ii,jk,1)*tsmsk(ji,jk)
-               END DO
-            END DO
-            CLOSE(inum)  
-
-# if ! defined key_dynspg_fsc
-            ! ... Rigid lid case: make sure vsdta is baroclinic velocity
-            ! ... In rigid lid case vsdta needs to be the baroclinic component.
-            ! ... substract the barotropic velocity component (zvsbtpe)
-            ! ... from the total one (vsdta).
-
-            CALL obc_cli( vsdta, vclis, fs_njs0, fs_njs1, 1, jpi, nimpp )  
-# endif
-            ! ... Set normal velocity (on njs0, njs1 <=> jpjsob)
-            DO jk = 1, jpkm1
-               DO ji = 1, jpi
-                  ii = ji -1 + nimpp
-                  vfos(ji,jk) =  vsdta(ii,jk,1)*vsmsk(ji,jk)
-               END DO
-            END DO
-
-         END IF
-
-      ELSE 
-
-      ! 2.   CALL  not the first step ...
-      !      do not read but interpolate between months.
-      !      here no interpolation is done but the code is kept as a reminder
-      ! ----------------------------------------------------------------------
-
-      IF( lp_obc_east ) THEN
+            ! ... initialise the sedta, tedta, uedta arrays
+            CALL flioopfd ('obceast_TS.nc',fid_e)
+            CALL obc_dta_gv (fid_e,'y','vosaline',sedta(:,:,1),jpjef-jpjed+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_e,'y','vosaline',sedta(:,:,2),jpjef-jpjed+1,jpk,ntobc2)
+            CALL obc_dta_gv (fid_e,'y','votemper',tedta(:,:,1),jpjef-jpjed+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_e,'y','votemper',tedta(:,:,2),jpjef-jpjed+1,jpk,ntobc2)
+            CALL flioclo (fid_e)
+
+            CALL flioopfd ('obceast_U.nc',fid_e)
+            CALL obc_dta_gv (fid_e,'y','vozocrtx',uedta(:,:,1),jpjef-jpjed+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_e,'y','vozocrtx',uedta(:,:,2),jpjef-jpjed+1,jpk,ntobc2)
+            CALL flioclo (fid_e)
+            !  Usually printout is done only once at kt = nit000,
+            !  unless nprint (namelist) > 1      
+            IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 ) )   THEN
+               WRITE(numout,*)
+               WRITE(numout,*) ' Read East OBC data records ', ntobc1, ntobc2
+               ikprint = (jpjef-jpjed+1)/20 +1
+               WRITE(numout,*) ' Temperature record 1 - printout every 3 level'
+               CALL prihre( tedta(:,:,1),jpjef-jpjed+1,jpk,1,jpjef-jpjed+1,ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+               WRITE(numout,*)
+               WRITE(numout,*) ' Salinity  record 1 - printout every 3 level'
+               CALL prihre( sedta(:,:,1), jpjef-jpjed+1, jpk, 1, jpjef-jpjed+1, ikprint, &
+                  &        jpk, 1, -3, 1., numout )
+               WRITE(numout,*)
+               WRITE(numout,*) ' Normal velocity U  record 1  - printout every 3 level'
+               CALL prihre( uedta(:,:,1), jpjef-jpjed+1, jpk, 1, jpjef-jpjed+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+            ENDIF
+         ENDIF
+
+         IF( lp_obc_west )   THEN
+            ! ... Read datafile and set temperature, salinity and normal velocity
+            ! ... initialise the swdta, twdta, uwdta arrays
+            CALL flioopfd ('obcwest_TS.nc',fid_w)
+            CALL obc_dta_gv (fid_w,'y','vosaline',swdta(:,:,1),jpjwf-jpjwd+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_w,'y','vosaline',swdta(:,:,2),jpjwf-jpjwd+1,jpk,ntobc2)
+            CALL obc_dta_gv (fid_w,'y','votemper',twdta(:,:,1),jpjwf-jpjwd+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_w,'y','votemper',twdta(:,:,2),jpjwf-jpjwd+1,jpk,ntobc2)
+            CALL flioclo (fid_w)
+
+            CALL flioopfd ('obcwest_U.nc',fid_w)
+            CALL obc_dta_gv (fid_w,'y','vozocrtx',uwdta(:,:,1),jpjwf-jpjwd+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_w,'y','vozocrtx',uwdta(:,:,2),jpjwf-jpjwd+1,jpk,ntobc2)
+            CALL flioclo (fid_w)
+
+            IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 ) )   THEN
+               WRITE(numout,*)
+               WRITE(numout,*) ' Read West OBC data records ', ntobc1, ntobc2
+               ikprint = (jpjwf-jpjwd+1)/20 +1
+               WRITE(numout,*) ' Temperature  record 1 - printout every 3 level'
+               CALL prihre( twdta(:,:,1), jpjwf-jpjwd+1, jpk, 1, jpjwf-jpjwd+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+               WRITE(numout,*)
+               WRITE(numout,*) ' Salinity  record 1 - printout every 3 level'
+               CALL prihre( swdta(:,:,1), jpjwf-jpjwd+1, jpk, 1, jpjwf-jpjwd+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+               WRITE(numout,*)
+               WRITE(numout,*) ' Normal velocity U  record 1  - printout every 3 level'
+               CALL prihre( uwdta(:,:,1), jpjwf-jpjwd+1, jpk, 1, jpjwf-jpjwd+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+            ENDIF
+         ENDIF
+
+         IF( lp_obc_north )   THEN      
+            CALL flioopfd ('obcnorth_TS.nc',fid_n)
+            CALL obc_dta_gv (fid_n,'x','vosaline',sndta(:,:,1),jpinf-jpind+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_n,'x','vosaline',sndta(:,:,2),jpinf-jpind+1,jpk,ntobc2)
+            CALL obc_dta_gv (fid_n,'x','votemper',tndta(:,:,1),jpinf-jpind+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_n,'x','votemper',tndta(:,:,2),jpinf-jpind+1,jpk,ntobc2)
+            CALL flioclo (fid_n)
+
+            CALL flioopfd ('obcnorth_V.nc',fid_n)
+            CALL obc_dta_gv (fid_n,'x','vomecrty',vndta(:,:,1),jpinf-jpind+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_n,'x','vomecrty',vndta(:,:,2),jpinf-jpind+1,jpk,ntobc2)
+            CALL flioclo (fid_n)
+
+            IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 ) )   THEN
+               WRITE(numout,*)
+               WRITE(numout,*) ' Read North OBC data records ', ntobc1, ntobc2
+               ikprint = (jpinf-jpind+1)/20 +1
+               WRITE(numout,*) ' Temperature  record 1 - printout every 3 level'
+               CALL prihre( tndta(:,:,1), jpinf-jpind+1, jpk, 1, jpinf-jpind+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+               WRITE(numout,*)
+               WRITE(numout,*) ' Salinity  record 1 - printout every 3 level'
+               CALL prihre( sndta(:,:,1), jpinf-jpind+1, jpk, 1, jpinf-jpind+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+               WRITE(numout,*)
+               WRITE(numout,*) ' Normal velocity V  record 1  - printout every 3 level'
+               CALL prihre( vndta(:,:,1), jpinf-jpind+1, jpk, 1, jpinf-jpind+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+            ENDIF
+         ENDIF
+
+         IF( lp_obc_south )   THEN      
+            CALL flioopfd ('obcsouth_TS.nc',fid_s)
+            CALL obc_dta_gv (fid_s,'x','vosaline',ssdta(:,:,1),jpisf-jpisd+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_s,'x','vosaline',ssdta(:,:,2),jpisf-jpisd+1,jpk,ntobc2)
+            CALL obc_dta_gv (fid_s,'x','votemper',tsdta(:,:,1),jpisf-jpisd+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_s,'x','votemper',tsdta(:,:,2),jpisf-jpisd+1,jpk,ntobc2)
+            CALL flioclo (fid_s)
+
+            CALL flioopfd ('obcsouth_V.nc',fid_s)
+            CALL obc_dta_gv (fid_s,'x','vomecrty',vsdta(:,:,1),jpisf-jpisd+1,jpk,ntobc1)
+            CALL obc_dta_gv (fid_s,'x','vomecrty',vsdta(:,:,2),jpisf-jpisd+1,jpk,ntobc2)
+            CALL flioclo (fid_s)
+
+            IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 ) )   THEN
+               WRITE(numout,*)
+               WRITE(numout,*) ' Read South OBC data records ', ntobc1, ntobc2
+               ikprint = (jpisf-jpisd+1)/20 +1
+               WRITE(numout,*) ' Temperature  record 1 - printout every 3 level'
+               CALL prihre( tsdta(:,:,1), jpisf-jpisd+1, jpk, 1, jpisf-jpisd+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+               WRITE(numout,*)
+               WRITE(numout,*) ' Salinity  record 1 - printout every 3 level'
+               CALL prihre( ssdta(:,:,1), jpisf-jpisd+1, jpk, 1, jpisf-jpisd+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+               WRITE(numout,*)
+               WRITE(numout,*) ' Normal velocity V  record 1  - printout every 3 level'
+               CALL prihre( vsdta(:,:,1), jpisf-jpisd+1, jpk, 1, jpisf-jpisd+1, ikprint, &
+                  &         jpk, 1, -3, 1., numout )
+            ENDIF
+         ENDIF
+      
+      ENDIF        !      end of the test on the condition to read or not the files 
+      
+      ! 3.  Call at every time step :
+      !     Linear interpolation of BCs to current time step 
+      ! ----------------------------------------------------
+
+      IF( itobc == 1 .OR. nobc_dta == 0 )   THEN 
+         zxy = 0.
+      ELSE IF( itobc == 12 )   THEN         
+         zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
+      ELSE
+         zxy = (ztcobc(ntobc1)-FLOAT(isrel))/(ztcobc(ntobc1)-ztcobc(ntobc2))
+      ENDIF
+      
+      IF( lp_obc_east )   THEN
+         !  fills sfoe, tfoe, ufoe (local to each processor)
          DO jk = 1, jpkm1
-            DO jj = 1, jpj
+            DO jj = nje0p1, nje1m1
                ij = jj -1 + njmpp
-               sfoe(jj,jk) =  sedta(ij,jk,1)*temsk(jj,jk)
-               tfoe(jj,jk) =  tedta(ij,jk,1)*temsk(jj,jk)
-               ufoe(jj,jk) =  uedta(ij,jk,1)*uemsk(jj,jk)
+               sfoe(jj,jk) =  ( zxy * sedta(ij,jk,2) + &
+                  &           (1.-zxy) * sedta(ij,jk,1) ) * temsk(jj,jk)
+               tfoe(jj,jk) =  ( zxy * tedta(ij,jk,2) + &
+                  &           (1.-zxy) * tedta(ij,jk,1) ) * temsk(jj,jk)
+               ufoe(jj,jk) =  ( zxy * uedta(ij,jk,2) + &
+                  &           (1.-zxy) * uedta(ij,jk,1) ) * uemsk(jj,jk)
             END DO
          END DO
-      END IF
-
-      IF( lp_obc_west ) THEN
+      ENDIF
+      
+      IF( lp_obc_west )   THEN
+         !  fills sfow, tfow, ufow (local to each processor)
          DO jk = 1, jpkm1
-            DO jj = 1, jpj
+            DO jj = njw0p1, njw1m1
                ij = jj -1 + njmpp
-               sfow(jj,jk) =  swdta(ij,jk,1)*twmsk(jj,jk)
-               tfow(jj,jk) =  twdta(ij,jk,1)*twmsk(jj,jk)
-               ufow(jj,jk) =  uwdta(ij,jk,1)*uwmsk(jj,jk)
+               sfow(jj,jk) =  ( zxy * swdta(ij,jk,2) + &
+                  &           (1.-zxy) * swdta(ij,jk,1) ) * twmsk(jj,jk)
+               tfow(jj,jk) =  ( zxy * twdta(ij,jk,2) + &
+                  &           (1.-zxy) * twdta(ij,jk,1) ) * twmsk(jj,jk)
+               ufow(jj,jk) =  ( zxy * uwdta(ij,jk,2) + &
+                  &           (1.-zxy) * uwdta(ij,jk,1) ) * uwmsk(jj,jk)
             END DO
          END DO
-      END IF
-
-      IF( lp_obc_north ) THEN 
+      ENDIF
+      
+      IF( lp_obc_north )   THEN
+         !  fills sfon, tfon, vfon (local to each processor)
          DO jk = 1, jpkm1
-            DO ji = 1, jpi
+            DO ji = nin0p1, nin1m1
                ii = ji -1 + nimpp
-               sfon(ji,jk) =  sndta(ii,jk,1)*tnmsk(ji,jk)
-               tfon(ji,jk) =  tndta(ii,jk,1)*tnmsk(ji,jk)
-               vfon(ji,jk) =  vndta(ii,jk,1)*vnmsk(ji,jk)
+               sfon(ji,jk) =  ( zxy * sndta(ii,jk,2) + &
+                  &           (1.-zxy) * sndta(ii,jk,1) ) * tnmsk(ji,jk)
+               tfon(ji,jk) =  ( zxy * tndta(ii,jk,2) + &
+                  &           (1.-zxy) * tndta(ii,jk,1) ) * tnmsk(ji,jk)
+               vfon(ji,jk) =  ( zxy * vndta(ii,jk,2) + &
+                  &           (1.-zxy) * vndta(ii,jk,1) ) * vnmsk(ji,jk)
             END DO
          END DO
-      END IF
-
-      IF( lp_obc_south ) THEN 
+      ENDIF
+      
+      IF( lp_obc_south )   THEN
+         !  fills sfos, tfos, vfos (local to each processor)
          DO jk = 1, jpkm1
-            DO ji = 1, jpi
-               ii = ji -1 + nimpp
-               sfos(ji,jk) =  ssdta(ii,jk,1)*tsmsk(ji,jk)
-               tfos(ji,jk) =  tsdta(ii,jk,1)*tsmsk(ji,jk)
-               vfos(ji,jk) =  vsdta(ii,jk,1)*vsmsk(ji,jk)
-            END DO
-         END DO
-      END IF
-
-      END IF
-
+           DO ji = nis0p1, nis1m1
+              ii = ji -1 + nimpp
+              sfos(ji,jk) = ( zxy * ssdta(ii,jk,2) + &
+                 &          (1.-zxy) * ssdta(ii,jk,1) ) * tsmsk(ji,jk)
+              tfos(ji,jk) = ( zxy * tsdta(ii,jk,2) + &
+                 &          (1.-zxy) * tsdta(ii,jk,1) ) * tsmsk(ji,jk)
+              vfos(ji,jk) = ( zxy * vsdta(ii,jk,2) + &
+                 &          (1.-zxy) * vsdta(ii,jk,1) ) * vsmsk(ji,jk)
+           END DO
+         END DO             
+      ENDIF
+      
    END SUBROUTINE obc_dta
-
+      
 # if defined key_dynspg_fsc
    !!-----------------------------------------------------------------------------
@@ -565,11 +654,11 @@
       zsver1 =  bsfic0(1)
       zsver2 =  zsver1
-      IF( kt <= kbsfstart ) THEN
+      IF( kt <= kbsfstart )   THEN
          zcoef = float(kt)/float(kbsfstart)
       ELSE
-         zcoef = 1.e0
+         zcoef = 1.
       END IF
       bsfic(1) = zsver1*zcoef
-      IF( lwp .AND. ( kt <= kbsfstart ) ) THEN
+      IF( lwp .AND. ( kt <= kbsfstart ) )   THEN
          IF(lwp) WRITE(numout,*)'            '
          IF(lwp) WRITE(numout,*)'obcdta: spinup phase in obc_dta_psi routine'
@@ -584,5 +673,5 @@
       ! ----------------------------------------------------------------------------
 
-      IF( ( neuler == 0 ) .AND. ( kt == nit000 ) ) THEN
+      IF( ( neuler == 0 ) .AND. ( kt == nit000 ) )   THEN
          z2dtr = 1./rdt
       ELSE
@@ -593,7 +682,7 @@
       ! ... However, bsfb(ii,ij) is constant along the same coastlines
       ! ... ---> can be improved using an extra array for storing bsficb (before)
-      IF( nbobc > 1 ) THEN
+      IF( nbobc > 1 )   THEN
          DO jnic = 1,nbobc - 1
-            gcbic(jnic) = 0.e0
+            gcbic(jnic) = 0.
             ip=mnic(0,jnic)
             DO jip = 1,ip
@@ -601,5 +690,5 @@
                ij = mjic(jip,0,jnic) 
                IF( ii >= nldi+ nimpp - 1 .AND. ii <= nlei+ nimpp - 1 .AND. &
-                   ij >= nldj+ njmpp - 1 .AND. ij <= nlej+ njmpp - 1 ) THEN
+                   ij >= nldj+ njmpp - 1 .AND. ij <= nlej+ njmpp - 1 )   THEN
                   iii=ii-nimpp+1
                   ijj=ij-njmpp+1
@@ -615,7 +704,7 @@
       ! ----------------------------------------------------------------
 
-      IF( lp_obc_east ) THEN
-
-         IF( kt == nit000 .OR. kt <= kbsfstart ) THEN
+      IF( lpeastobc )   THEN
+
+         IF( kt == nit000 .OR. kt <= kbsfstart )   THEN
             OPEN(inum,file='obceastbsf.dta')
             READ(inum,*)
@@ -633,5 +722,5 @@
       END IF
 
-      IF( lp_obc_west ) THEN
+      IF( lpwestobc)   THEN
 
          IF( kt == nit000 .OR. kt <= kbsfstart ) then
@@ -646,12 +735,12 @@
          END IF
          DO jj=jpjwd, jpjwfm1
-            bfow(jj) = bfow(jj) * zcoef
+            bfow(jj)=bfow(jj)*zcoef
          END DO
 
       END IF
 
-      IF( lp_obc_south ) THEN
-
-         IF( kt == nit000 .OR. kt <= kbsfstart ) THEN
+      IF( lpsouthobc)   THEN
+
+         IF( kt == nit000.OR.kt <= kbsfstart )   THEN
             OPEN(inum,file='obcsouthbsf.dta')
             READ(inum,*)
@@ -669,6 +758,6 @@
       END IF
 
-      IF( lp_obc_north ) THEN
-         IF( kt == nit000 .OR. kt <= kbsfstart ) THEN
+      IF( lpnorthobc)   THEN
+         IF( kt == nit000.OR.kt <= kbsfstart )   THEN
             OPEN(inum,file='obcnorthbsf.dta')
             READ(inum,*)
@@ -690,15 +779,82 @@
 # endif
 
+   SUBROUTINE obc_dta_gv (ifid,cldim,clobc,pdta,kobcij,kobck,ktobc)
+      !!-----------------------------------------------------------------------------
+      !!                       ***  SUBROUTINE obc_dta_gv  ***
+      !!
+      !! ** Purpose :   Read a OBC forcing field from netcdf file 
+      !!                Input file are supposed to be 3D e.g.
+      !!                - for a South or North OB : longitude x depth x time
+      !!		- for a West or East OB : latitude x depth x time
+      !!
+      !! History :
+      !!        !  04-06 (A.-M. Treguier, F. Durand) Original code
+      !!        !  05-02 (J. Bellier, C. Talandier) use fliocom CALL
+      !!----------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT(IN) ::   &
+         ifid,                 & ! netcdf file name identifier
+         kobcij,               & ! Horizontal (i or j) dimension of the array
+         kobck,                & ! vertical dimension
+         ktobc                   ! starting time index read
+      CHARACTER(LEN=*), INTENT(IN)    ::   &
+         cldim,                & ! dimension along which is the open boundary ('x' or 'y')
+         clobc                   ! name of the netcdf variable read
+      REAL, DIMENSION(kobcij,kobck,1), INTENT(OUT) ::   &
+         pdta                    ! 3D array of OBC forcing field
+      
+      !! * Local declarations
+      INTEGER ::   indim
+      LOGICAL ::   l_exv
+      INTEGER,DIMENSION(4) ::   f_d, istart, icount
+      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   v_tmp_4
+      !----------------------------------------------------------------------
+
+      CALL flioinqv (ifid,TRIM(clobc),l_exv,nb_dims=indim,len_dims=f_d) 
+      IF( l_exv )   THEN
+         ! checks the number of dimensions
+         IF( indim == 3 )   THEN
+            istart(1:3) = (/ 1, 1, ktobc /)
+            icount(1:3) = (/ kobcij, kobck, 1 /)
+            CALL fliogetv (ifid,TRIM(clobc),pdta,start=istart(1:3),count=icount(1:3))
+         ELSE IF( indim == 4 )   THEN
+            istart(1:4) = (/ 1, 1, 1, ktobc /)
+            IF( TRIM(cldim) == 'y' )   THEN
+               icount(1:4) = (/ 1, kobcij, kobck, 1 /)
+            ELSE
+               icount(1:4) = (/ kobcij, 1, kobck, 1 /)
+            ENDIF
+            ALLOCATE (v_tmp_4(icount(1),icount(2),icount(3),icount(4)))
+            CALL fliogetv (ifid,TRIM(clobc),v_tmp_4,start=istart(1:4),count=icount(1:4))
+            IF( TRIM(cldim) == 'y' )   THEN
+               pdta(1:kobcij,1:kobck,1:1) = v_tmp_4(1,1:kobcij,1:kobck,1:1)
+            ELSE
+               pdta(1:kobcij,1:kobck,1:1) = v_tmp_4(1:kobcij,1,1:kobck,1:1)
+            ENDIF
+            DEALLOCATE (v_tmp_4)
+         ELSE
+            IF( lwp )   THEN
+               WRITE(numout,*) ' Problem in OBC file for ',TRIM(clobc),' :'
+               WRITE(numout,*) ' number of dimensions (not 3 or 4) =',indim
+            ENDIF
+            STOP
+         ENDIF
+      ELSE
+         WRITE(numout,*) ' Variable ',TRIM(clobc),' not found'
+      ENDIF
+      
+   END SUBROUTINE obc_dta_gv
+
 #else
-   !!------------------------------------------------------------------------------
-   !!   default option:           Dummy module          NO Open Boundary Conditions
-   !!------------------------------------------------------------------------------
+   !!--------------------------------------------------------------------
+   !!  default option  :  Dummy module    NO Open Boundary Conditions
+   !!--------------------------------------------------------------------
 CONTAINS
    SUBROUTINE obc_dta( kt )             ! Dummy routine
-      INTEGER, INTENT (in) :: kt
-      WRITE(*,*) 'obc_dta: You should not have seen this print! error?', kt
+     INTEGER, INTENT (in) :: kt
+     WRITE(*,*) 'obc_dta: You should not have seen this print! error?', kt
    END SUBROUTINE obc_dta
 #endif
 
-   !!==============================================================================
+   !!=====================================================================
 END MODULE obcdta
Index: /trunk/NEMO/OPA_SRC/OBC/obcini.F90
===================================================================
--- /trunk/NEMO/OPA_SRC/OBC/obcini.F90	(revision 352)
+++ /trunk/NEMO/OPA_SRC/OBC/obcini.F90	(revision 353)
@@ -61,5 +61,5 @@
 
       !! * Local declarations
-      INTEGER  ::   ji, jj, istop
+      INTEGER  ::   ji, jj, istop , inumfbc
       INTEGER, DIMENSION(4) ::   icorner
       REAL(wp) ::   zbsic1, zbsic2, zbsic3
@@ -69,5 +69,5 @@
          &             rdpeob, rdpwob, rdpnob, rdpsob,   &
          &             zbsic1, zbsic2, zbsic3,           &
-         &             nbic, volemp, nobc_dta
+         &             nbic, volemp, nobc_dta, ln_obc_clim
       !!----------------------------------------------------------------------
 
@@ -134,4 +134,5 @@
       IF(lwp) WRITE(numout,*) '         data in file (=1) or     nobc_dta = ', nobc_dta
       IF(lwp) WRITE(numout,*) '         initial state used (=0)             '
+      IF(lwp) WRITE(numout,*) '         climatology (true) or not:', ln_obc_clim
       IF( lwp.AND.lp_obc_east ) THEN
          WRITE(numout,*) '         East open boundary :'
@@ -179,4 +180,5 @@
       lfbcnorth = .FALSE.
       lfbcsouth = .FALSE.
+      inumfbc = 0
       ! ... look for Fixed Boundaries (rdp = 0 )
       ! ... When specified, lbcxxx flags are set to TRUE and rdpxxx are set to
@@ -187,4 +189,5 @@
          rdpein = 1e-3
          rdpeob = 1e-3
+         inumfbc = inumfbc+1
       END IF
       IF( lp_obc_west .AND. ( rdpwin == 0 .AND. rdpwob == 0 ) )  THEN
@@ -192,4 +195,5 @@
          rdpwin = 1e-3
          rdpwob = 1e-3
+         inumfbc = inumfbc+1
       END IF
       IF( lp_obc_north .AND. ( rdpnin == 0 .AND. rdpnob == 0 ) )  THEN
@@ -197,4 +201,5 @@
          rdpnin = 1e-3
          rdpnob = 1e-3
+         inumfbc = inumfbc+1
       END IF
       IF( lp_obc_south .AND. ( rdpsin == 0 .AND. rdpsob == 0 ) )  THEN
@@ -202,4 +207,5 @@
          rdpsin = 1e-3
          rdpsob = 1e-3
+         inumfbc = inumfbc+1
       END IF
 
@@ -682,7 +688,8 @@
       ! 6. Initialization of open boundary variables (u, v, bsf, t, s)
       ! --------------------------------------------------------------
+      !   only if at least one boundary is  radiative 
 
       ! ... Restart from restart.obc
-      IF( ln_rstart ) THEN
+      IF ( inumfbc < nbobc .AND.  ln_rstart ) THEN
          CALL obc_rst_lec
       ELSE
@@ -730,18 +737,4 @@
             ENDIF
          ELSE
-            IF( tmask(jpieob+1,jpjed  ,1) /= 0. .OR.    &
-                tmask(jpieob+1,jpjed+1,1) /= 1.         ) THEN
-               IF(lwp) WRITE(numout,cform_err)
-               IF(lwp) WRITE(numout,*) '           starting point is not a land T-point.'
-               IF(lwp) WRITE(numout,*) '      or   starting point + 1 is not a ocean T-point.'
-               istop = istop + 1
-            END IF
-            IF( tmask(jpieob+1,jpjef  ,1) /= 0. .OR.  &
-                tmask(jpieob+1,jpjef-1,1) /= 1.       ) THEN
-               IF(lwp) WRITE(numout,cform_err)
-               IF(lwp) WRITE(numout,*) '           ending point is not a land T-point.'
-               IF(lwp) WRITE(numout,*) '        or ending point - 1 is not a ocean T-point.'
-               istop = istop + 1
-            END IF
 
             ! ... stop if  e r r o r (s)   detected
@@ -773,18 +766,4 @@
             ENDIF
          ELSE
-            IF( tmask(jpiwob,jpjwd  ,1) /= 0. .OR.    &
-                tmask(jpiwob,jpjwd+1,1) /= 1.         ) THEN
-               IF(lwp) WRITE(numout,cform_err)
-               IF(lwp) WRITE(numout,*) '           starting point is not a land T-point.'
-               IF(lwp) WRITE(numout,*) '      or   starting point + 1 is not a ocean T-point.'
-               istop = istop + 1
-            END IF
-            IF ( tmask(jpieob+1,jpjef  ,1) /= 0. .OR.  &
-                 tmask(jpieob+1,jpjef-1,1) /= 1.       ) THEN
-                IF(lwp) WRITE(numout,cform_err)
-                IF(lwp) WRITE(numout,*) '           ending point is not a land T-point.'
-                IF(lwp) WRITE(numout,*) '        or ending point - 1 is not a ocean T-point.'
-                istop = istop + 1
-            END IF
    
             ! ... stop if  e r r o r (s)   detected
@@ -816,18 +795,4 @@
             ENDIF
          ELSE
-            IF( tmask(jpind  , jpjnob+1,1) /= 0. .OR.    &
-                tmask(jpind+1, jpjnob+1,1) /= 1.         ) THEN
-               IF(lwp) WRITE(numout,cform_err)
-               IF(lwp) WRITE(numout,*) '           starting point is not a land T-point.'
-               IF(lwp) WRITE(numout,*) '      or   starting point + 1 is not a ocean T-point.'
-               istop = istop + 1
-            END IF
-            IF( tmask(jpinf  ,jpjnob+1,1) /= 0. .OR.  &
-                tmask(jpinf-1,jpjnob+1,1) /= 1.       ) THEN
-               IF(lwp) WRITE(numout,cform_err)
-               IF(lwp) WRITE(numout,*) '           ending point is not a land T-point.'
-               IF(lwp) WRITE(numout,*) '        or ending point - 1 is not a ocean T-point.'
-               istop = istop + 1
-            END IF
    
             ! ... stop if  e r r o r (s)   detected
@@ -859,18 +824,4 @@
             ENDIF
          ELSE
-            IF( tmask(jpisd  , jpjsob,1) /= 0. .OR.    &
-                tmask(jpisd+1, jpjsob,1) /= 1.         ) THEN
-               IF(lwp) WRITE(numout,cform_err)
-               IF(lwp) WRITE(numout,*) '           starting point is not a land T-point.'
-               IF(lwp) WRITE(numout,*) '      or   starting point + 1 is not a ocean T-point.'
-               istop = istop + 1
-            END IF
-            IF( tmask(jpisf  ,jpjsob,1) /= 0. .OR.  &
-                tmask(jpisf-1,jpjsob,1) /= 1.       ) THEN
-               IF(lwp) WRITE(numout,cform_err)
-               IF(lwp) WRITE(numout,*) '           ending point is not a land T-point.'
-               IF(lwp) WRITE(numout,*) '        or ending point - 1 is not a ocean T-point.'
-               istop = istop + 1
-            END IF
    
             ! ... stop if  e r r o r (s)   detected
