Index: /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist
===================================================================
--- /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 2820)
+++ /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 2821)
@@ -560,17 +560,28 @@
 /
 !-----------------------------------------------------------------------
-&namdyn        !   offline dynamics read in files                       ("key_offline")
-!-----------------------------------------------------------------------
-    ndtadyn   =  73        ! number of period in the file for one year
-    ndtatot   =  73        ! total number of period in the file
-    nsptint   =  1         ! indicator for time interpolation
-    lperdyn   = .true.     ! periodicity of the unique file (T)
-                           ! F  (default)   computed with Blanke' scheme
-    cfile_grid_T = 'dyna_grid_T.nc' ! name of grid_T file
-    cfile_grid_U = 'dyna_grid_U.nc' ! name of grid_U file
-    cfile_grid_V = 'dyna_grid_V.nc' ! name of grid_V file
-    cfile_grid_W = 'dyna_grid_W.nc' ! name of grid_W file
-/
-
+&namdta_dyn        !   offline dynamics read in files                ("key_offline")
+!-----------------------------------------------------------------------
+!            !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation !
+!            !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  !
+   sn_tem  = 'dyna_grid_T' ,    120            , 'votemper' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_sal  = 'dyna_grid_T' ,    120            , 'vosaline' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_mld  = 'dyna_grid_T' ,    120            , 'somixhgt' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_emp  = 'dyna_grid_T' ,    120            , 'sowaflcd' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_ice  = 'dyna_grid_T' ,    120            , 'soicecov' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_qsr  = 'dyna_grid_T' ,    120            , 'soshfldo' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_wnd  = 'dyna_grid_T' ,    120            , 'sowindsp' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_uwd  = 'dyna_grid_U' ,    120            , 'vozocrtx' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_vwd  = 'dyna_grid_V' ,    120            , 'vomecrty' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_wwd  = 'dyna_grid_W' ,    120            , 'vovecrtz' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_avt  = 'dyna_grid_W' ,    120            , 'voddmavs' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_ubl  = 'dyna_grid_U' ,    120            , 'sobblcox' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_vbl  = 'dyna_grid_V' ,    120            , 'sobblcoy' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+   sn_eiw  = 'dyna_grid_W' ,    120            , 'soleaeiw' ,  .true.    , .true. ,   'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the dynamical files
+   ln_degrad   =  .false.  !  flag for degradation -                requires ("key_degrad")
+   ln_dynwzv   =  .true.   !  computation of vertical velocity instead of using the one read in file
+   ln_dynbbl   =  .true.   !  bbl coef are in files, so read them - requires ("key_trabbl")
+/
 !!======================================================================
 !!             Tracers & Dynamics vertical physics namelists
Index: /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/dommsk.F90
===================================================================
--- /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/dommsk.F90	(revision 2820)
+++ /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/dommsk.F90	(revision 2821)
@@ -19,6 +19,4 @@
 
    PUBLIC   dom_msk    ! routine called by inidom.F90
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   facvol   !: volume for degraded regions
 
    !! * Substitutions
@@ -56,8 +54,4 @@
       END IF
       !
-#if defined key_degrad
-      IF( dom_msk_alloc() /= 0 )   CALL ctl_stop('STOP','dom_msk: unable to allocate arrays')
-#endif
-
       ! Interior domain mask (used for global sum)
       ! --------------------
@@ -104,15 +98,4 @@
       !
    END SUBROUTINE dom_msk
-
-
-   INTEGER FUNCTION dom_msk_alloc()
-      !!---------------------------------------------------------------------
-      !!                 ***  FUNCTION dom_msk_alloc  ***
-      !!---------------------------------------------------------------------
-      ALLOCATE( facvol(jpi,jpj,jpk) , STAT=dom_msk_alloc )
-      IF( dom_msk_alloc /= 0 )   CALL ctl_warn('dom_msk_alloc : failed to allocate facvol array')
-      !
-   END FUNCTION dom_msk_alloc
-
    !!======================================================================
 END MODULE dommsk
Index: /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/domrea.F90
===================================================================
--- /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/domrea.F90	(revision 2820)
+++ /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/domrea.F90	(revision 2821)
@@ -16,4 +16,5 @@
    USE dommsk          ! domain: masks
    USE lbclnk          ! lateral boundary condition - MPP exchanges
+   USE trc_oce
    USE lib_mpp 
    USE in_out_manager
Index: /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90
===================================================================
--- /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90	(revision 2820)
+++ /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90	(revision 2821)
@@ -11,10 +11,10 @@
    !!              -   ! 2005-12 (C. Ethe) Adapted for DEGINT
    !!             3.0  ! 2007-06 (C. Ethe) use of iom module
-   !!              -   ! 2007-09  (C. Ethe)  add swap_dyn_data
    !!             3.3  ! 2010-11 (C. Ethe) Full reorganization of the off-line: phasing with the on-line
+   !!             3.4  ! 2011-05 (C. Ethe) Use of fldread
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
-   !!   dta_dyn_init : initialization, namelist read, and parameters control
+   !!   dta_dyn_init : initialization, namelist read, and SAVEs control
    !!   dta_dyn      : Interpolation of the fields
    !!----------------------------------------------------------------------
@@ -24,4 +24,5 @@
    USE zdf_oce         ! ocean vertical physics: variables
    USE sbc_oce         ! surface module: variables
+   USE trc_oce         ! share ocean/biogeo variables
    USE phycst          ! physical constants
    USE trabbl          ! active tracer: bottom boundary layer
@@ -36,5 +37,6 @@
    USE iom             ! I/O library
    USE lib_mpp         ! distributed memory computing library
-   USE prtctl          !  print control
+   USE prtctl          ! print control
+   USE fldread         ! read input fields 
 
    IMPLICIT NONE
@@ -44,53 +46,44 @@
    PUBLIC   dta_dyn        ! called by step.F90
 
-   LOGICAL, PUBLIC ::   lperdyn = .TRUE.   !: boolean for periodic fields or not
-   LOGICAL, PUBLIC ::   lfirdyn = .TRUE.   !: boolean for the first call or not
-
-   INTEGER, PUBLIC ::   ndtadyn = 73       !: Number of dat in one year
-   INTEGER, PUBLIC ::   ndtatot = 73       !: Number of data in the input field
-   INTEGER, PUBLIC ::   nsptint = 1        !: type of spatial interpolation
-
-   CHARACTER(len=45) ::   cfile_grid_T = 'dyna_grid_T.nc'   ! name of the grid_T file
-   CHARACTER(len=45) ::   cfile_grid_U = 'dyna_grid_U.nc'   ! name of the grid_U file
-   CHARACTER(len=45) ::   cfile_grid_V = 'dyna_grid_V.nc'   ! name of the grid_V file
-   CHARACTER(len=45) ::   cfile_grid_W = 'dyna_grid_W.nc'   ! name of the grid_W file
-   
-   REAL(wp) ::   rnspdta    ! number of time step per 2 consecutives data
-   REAL(wp) ::   rnspdta2   ! rnspdta * 0.5
-
-   INTEGER ::   ndyn1, ndyn2    !
-   INTEGER ::   nlecoff = 0     ! switch for the first read
-   INTEGER ::   numfl_t, numfl_u, numfl_v, numfl_w
-
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: tdta       ! temperature at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: sdta       ! salinity at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: udta       ! zonal velocity at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: vdta       ! meridional velocity at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: wdta       ! vertical velocity at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: avtdta     ! vertical diffusivity coefficient
-
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:) :: hmlddta    ! mixed layer depth at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:) :: wspddta    ! wind speed at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:) :: frlddta    ! sea-ice fraction at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:) :: empdta     ! E-P at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:) :: qsrdta     ! short wave heat flux at two consecutive times
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:) :: bblxdta    ! bbl diffusive coef. in the x direction at 2 consecutive times 
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:) :: bblydta    ! bbl diffusive coef. in the y direction at 2 consecutive times 
-   LOGICAL :: l_offbbl
-#if defined key_ldfslp && ! defined key_c1d
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: uslpdta    ! zonal isopycnal slopes
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: vslpdta    ! meridional isopycnal slopes
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: wslpidta   ! zonal diapycnal slopes
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: wslpjdta   ! meridional diapycnal slopes
-#endif
-#if ! defined key_degrad &&  defined key_traldf_c2d && defined key_traldf_eiv 
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:,:) :: aeiwdta    ! G&M coefficient
-#endif
-#if defined key_degrad
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: ahtudta, ahtvdta, ahtwdta   ! Lateral diffusivity
-# if defined key_traldf_eiv
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: aeiudta, aeivdta, aeiwdta   ! G&M coefficient
-# endif
-#endif
+   CHARACTER(len=100) ::   cn_dir     = './'    !: Root directory for location of ssr files
+   LOGICAL            ::   ln_dynwzv  = .true.  !: vertical velocity read in a file (T) or computed from u/v (F)
+   LOGICAL            ::   ln_dynbbl  = .true.  !: bbl coef read in a file (T) or computed (F)
+   LOGICAL            ::   ln_degrad  = .false. !: degradation option enabled or not 
+
+   INTEGER  , PARAMETER ::   jpfld = 19     ! maximum number of files to read
+   INTEGER  , SAVE      ::   jf_tem         ! index of temperature
+   INTEGER  , SAVE      ::   jf_sal         ! index of salinity
+   INTEGER  , SAVE      ::   jf_uwd         ! index of u-wind
+   INTEGER  , SAVE      ::   jf_vwd         ! index of v-wind
+   INTEGER  , SAVE      ::   jf_wwd         ! index of w-wind
+   INTEGER  , SAVE      ::   jf_avt         ! index of Kz
+   INTEGER  , SAVE      ::   jf_mld         ! index of mixed layer deptht
+   INTEGER  , SAVE      ::   jf_emp         ! index of water flux
+   INTEGER  , SAVE      ::   jf_qsr         ! index of solar radiation
+   INTEGER  , SAVE      ::   jf_wnd         ! index of wind speed
+   INTEGER  , SAVE      ::   jf_ice         ! index of sea ice cover
+   INTEGER  , SAVE      ::   jf_ubl         ! index of u-bbl coef
+   INTEGER  , SAVE      ::   jf_vbl         ! index of v-bbl coef
+   INTEGER  , SAVE      ::   jf_ahu         ! index of u-diffusivity coef
+   INTEGER  , SAVE      ::   jf_ahv         ! index of v-diffusivity coef 
+   INTEGER  , SAVE      ::   jf_ahw         ! index of w-diffusivity coef
+   INTEGER  , SAVE      ::   jf_eiu         ! index of u-eiv
+   INTEGER  , SAVE      ::   jf_eiv         ! index of v-eiv
+   INTEGER  , SAVE      ::   jf_eiw         ! index of w-eiv
+
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_dyn  ! structure of input fields (file informations, fields read)
+   !                                               ! 
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: wdta       ! vertical velocity at 2 time step
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:  ) :: wnow       ! vertical velocity at 2 time step
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: uslpdta    ! zonal isopycnal slopes
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: vslpdta    ! meridional isopycnal slopes
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: wslpidta   ! zonal diapycnal slopes
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: wslpjdta   ! meridional diapycnal slopes
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:)   :: uslpnow    ! zonal isopycnal slopes
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:)   :: vslpnow    ! meridional isopycnal slopes
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:)   :: wslpinow   ! zonal diapycnal slopes
+   REAL(wp) , ALLOCATABLE, SAVE, DIMENSION(:,:,:)   :: wslpjnow   ! meridional diapycnal slopes
+
+   INTEGER :: nrecprev_tem , nrecprev_uwd
 
    !! * Substitutions
@@ -108,124 +101,165 @@
       !!                  ***  ROUTINE dta_dyn  ***
       !!
-      !! ** Purpose :   Prepares dynamics and physics fields from an NEMO run
-      !!              for an off-line simulation of passive tracers
-      !!
-      !! ** Method : calculates the position of DATA to read READ DATA 
-      !!             (example month changement) computes slopes IF needed
-      !!             interpolates DATA IF needed
-      !!----------------------------------------------------------------------
+      !! ** Purpose :  Prepares dynamics and physics fields from a NEMO run
+      !!               for an off-line simulation of passive tracers
+      !!
+      !! ** Method : calculates the position of data 
+      !!             - computes slopes if needed
+      !!             - interpolates data if needed
+      !!----------------------------------------------------------------------
+      !
+      USE oce, ONLY:  zts    => tsa 
+      USE oce, ONLY:  zuslp  => ua   , zvslp  => va
+      USE oce, ONLY:  zwslpi => rotb , zwslpj => rotn
+      USE oce, ONLY:  zu     => ub   , zv     => vb,  zw => hdivb
+      !
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      !!
-      INTEGER  ::   iper, iperm1, iswap, izt   ! local integers 
-      REAL(wp) ::   zt, zweigh                 ! local scalars
-      !!----------------------------------------------------------------------
-
-      zt     = ( REAL(kt,wp) + rnspdta2 ) / rnspdta
-      izt    = INT( zt )
-      zweigh = zt - REAL( INT(zt), wp )
-
-      IF( lperdyn ) THEN   ;   iperm1 = MOD( izt, ndtadyn )
-      ELSE                 ;   iperm1 = MOD( izt, ndtatot - 1 ) + 1
-      ENDIF
-
-      iper = iperm1 + 1
-      IF( iperm1 == 0 ) THEN
-          IF( lperdyn ) THEN
-              iperm1 = ndtadyn
-          ELSE 
-              IF( lfirdyn ) THEN 
-                  IF(lwp) WRITE (numout,*) 'dta_dyn:  dynamic file is not periodic with or without interpolation    &
-                     &                                we take the first value for the previous period iperm1 = 0  '
-              END IF
-          END IF 
-      END IF 
-
-      iswap  = 0
-
-      ! 1. First call lfirdyn = true
-      ! ----------------------------
-
-      IF( lfirdyn ) THEN
-         ndyn1 = iperm1         ! store the information of the period read
-         ndyn2 = iper
-         
-         IF(lwp) THEN
-            WRITE (numout,*) ' dynamics data read for the period ndyn1 =', ndyn1,   &
-               &             ' and for the period ndyn2 = ', ndyn2
-            WRITE (numout,*) ' time step is : ', kt
-            WRITE (numout,*) ' we have ndtadyn = ', ndtadyn, ' records in the dynamic file for one year'
-         END IF
-         !
-         CALL dynrea( kt, MAX( 1, iperm1) )           ! data read for the iperm1 period
-         !
-         CALL swap_dyn_data            ! swap from record 2 to 1
-         !
-         iswap = 1        !  indicates swap
-         !
-         CALL dynrea( kt, iper )       ! data read for the iper period
-         !
-         lfirdyn = .FALSE.    ! trace the first call
-      ENDIF
-      !
-      ! And now what we have to do at every time step
-      ! check the validity of the period in memory
-      !
-      IF( iperm1 /= ndyn1 ) THEN 
-         !
-         IF( iperm1 == 0 ) THEN
-            IF(lwp) THEN
-               WRITE (numout,*) ' dynamic file is not periodic with periodic interpolation'
-               WRITE (numout,*) ' we take the last value for the last period '
-               WRITE (numout,*) ' iperm1 = 12,   iper = 13  '
+      !
+      INTEGER  ::   ji, jj     ! dummy loop indices
+      INTEGER  ::   isecsbc    ! number of seconds between Jan. 1st 00h of nit000 year and the middle of time step
+      REAL(wp) ::   ztinta     ! ratio applied to after  records when doing time interpolation
+      REAL(wp) ::   ztintb     ! ratio applied to before records when doing time interpolation
+      INTEGER  ::   iswap_tem, iswap_uwd    ! 
+      !!----------------------------------------------------------------------
+      
+      isecsbc = nsec_year + nsec1jan000 
+      
+      IF( kt /= nit000 ) THEN
+          nrecprev_tem = sf_dyn(jf_tem)%nrec_a(2)
+          nrecprev_uwd = sf_dyn(jf_uwd)%nrec_a(2)
+      ENDIF
+
+      CALL fld_read( kt, 1, sf_dyn )      !==   read data at kt time step   ==!
+
+      ! 
+      IF( lk_ldfslp ) THEN    ! Computes slopes (here avt is used as workspace)                       
+         iswap_tem = 0
+         IF(  kt /= nit000 .AND. ( sf_dyn(jf_tem)%nrec_a(2) - nrecprev_tem ) /= 0 )  iswap_tem = 1
+         IF( ( isecsbc > sf_dyn(jf_tem)%nrec_b(2) .AND. iswap_tem == 1 ) .OR. kt == nit000 )  THEN    ! read/update the after data
+            write(numout,*)
+            write(numout,*) ' Compute new slopes at kt = ', kt
+            IF( sf_dyn(jf_tem)%ln_tint ) THEN                 ! time interpolation of data
+               uslpdta (:,:,:,1) =  uslpdta (:,:,:,2)     ! swap the data
+               vslpdta (:,:,:,1) =  vslpdta (:,:,:,2)  
+               wslpidta(:,:,:,1) =  wslpidta(:,:,:,2) 
+               wslpjdta(:,:,:,1) =  wslpjdta(:,:,:,2) 
+               !
+               zts(:,:,:,jf_tem) = sf_dyn(jf_tem)%fdta(:,:,:,2) * tmask(:,:,:)   ! temperature
+               zts(:,:,:,jf_sal) = sf_dyn(jf_sal)%fdta(:,:,:,2) * tmask(:,:,:)   ! salinity 
+               avt(:,:,:)        = sf_dyn(jf_avt)%fdta(:,:,:,2) * tmask(:,:,:)   ! vertical diffusive coef.
+               CALL dta_dyn_slp( kt, zts, zuslp, zvslp, zwslpi, zwslpj )
+               uslpdta (:,:,:,2) = zuslp (:,:,:) 
+               vslpdta (:,:,:,2) = zvslp (:,:,:) 
+               wslpidta(:,:,:,2) = zwslpi(:,:,:) 
+               wslpjdta(:,:,:,2) = zwslpj(:,:,:) 
+            ELSE
+               zts(:,:,:,jf_tem) = sf_dyn(jf_tem)%fnow(:,:,:) * tmask(:,:,:)
+               zts(:,:,:,jf_sal) = sf_dyn(jf_sal)%fnow(:,:,:) * tmask(:,:,:)
+               avt(:,:,:)        = sf_dyn(jf_avt)%fnow(:,:,:) * tmask(:,:,:)
+               CALL dta_dyn_slp( kt, zts, zuslp, zvslp, zwslpi, zwslpj )
+               uslpnow (:,:,:)   = zuslp (:,:,:) 
+               vslpnow (:,:,:)   = zvslp (:,:,:) 
+               wslpinow(:,:,:)   = zwslpi(:,:,:) 
+               wslpjnow(:,:,:)   = zwslpj(:,:,:) 
             ENDIF
-            iperm1 = 12
-            iper   = 13
-         ENDIF
-         !
-         CALL swap_dyn_data         ! We have to prepare a new read of data : swap from record 2 to 1
-         !
-         iswap = 1                  !  indicates swap
-         !
-         CALL dynrea( kt, iper )    ! data read for the iper period
-         !
-         ndyn1 = ndyn2         ! store the information of the period read
-         ndyn2 = iper
-         !
-         IF(lwp) THEN
-            WRITE (numout,*) ' dynamics data read for the period ndyn1 =', ndyn1,   &
-               &             ' and for the period ndyn2 = ', ndyn2
-            WRITE (numout,*) ' time step is : ', kt
-         END IF
-         !
-      END IF
-      !
-      ! Compute the data at the given time step
-      !----------------------------------------     
-
-      IF( nsptint == 0 ) THEN          ! No space interpolation, data are probably correct
-         !                             ! We have to initialize data if we have changed the period         
-         CALL assign_dyn_data
-      ELSEIF( nsptint == 1 ) THEN      ! linear interpolation
-         CALL linear_interp_dyn_data( zweigh )
-      ELSE                             ! other interpolation
-         WRITE (numout,*) ' this kind of interpolation do not exist at the moment : we stop'
-         STOP 'dtadyn'         
-      END IF
-      !
-      CALL eos( tsn, rhd, rhop )       ! In any case, we need rhop
-      !
-#if ! defined key_degrad && defined key_traldf_c2d
-      !                                ! In case of 2D varying coefficients, we need aeiv and aeiu
-      IF( lk_traldf_eiv )   CALL dta_eiv( kt )      ! eddy induced velocity coefficient
-#endif
-      !
-      IF( .NOT. l_offbbl ) THEN       ! Compute bbl coefficients if needed
+         ENDIF
+         IF( sf_dyn(jf_tem)%ln_tint )  THEN
+            ztinta =  REAL( isecsbc - sf_dyn(jf_tem)%nrec_b(2), wp )  &
+               &    / REAL( sf_dyn(jf_tem)%nrec_a(2) - sf_dyn(jf_tem)%nrec_b(2), wp )
+            ztintb =  1. - ztinta
+            uslp (:,:,:) = ztintb * uslpdta (:,:,:,1)  + ztinta * uslpdta (:,:,:,2)  
+            vslp (:,:,:) = ztintb * vslpdta (:,:,:,1)  + ztinta * vslpdta (:,:,:,2)  
+            wslpi(:,:,:) = ztintb * wslpidta(:,:,:,1)  + ztinta * wslpidta(:,:,:,2)  
+            wslpj(:,:,:) = ztintb * wslpjdta(:,:,:,1)  + ztinta * wslpjdta(:,:,:,2)  
+         ELSE
+            uslp (:,:,:) = uslpnow (:,:,:)
+            vslp (:,:,:) = vslpnow (:,:,:)
+            wslpi(:,:,:) = wslpinow(:,:,:)
+            wslpj(:,:,:) = wslpjnow(:,:,:)
+         ENDIF
+      ENDIF
+      !
+      IF( ln_dynwzv )  THEN    ! compute vertical velocity from u/v
+         iswap_uwd = 0
+         IF(  kt /= nit000 .AND. ( sf_dyn(jf_uwd)%nrec_a(2) - nrecprev_uwd ) /= 0 )  iswap_uwd = 1
+         IF( ( isecsbc > sf_dyn(jf_uwd)%nrec_b(2) .AND. iswap_uwd == 1 ) .OR. kt == nit000 )  THEN    ! read/update the after data
+            write(numout,*) ' Compute new vertical velocity at kt = ', kt
+            write(numout,*)
+            IF( sf_dyn(jf_uwd)%ln_tint ) THEN                 ! time interpolation of data
+               wdta(:,:,:,1) =  wdta(:,:,:,2)           ! swap the data
+               zu(:,:,:) = sf_dyn(jf_uwd)%fdta(:,:,:,2)
+               zv(:,:,:) = sf_dyn(jf_vwd)%fdta(:,:,:,2)
+               CALL dta_dyn_wzv( zu, zv, zw )
+               wdta(:,:,:,2) = zw(:,:,:) * tmask(:,:,:)
+            ELSE
+               zu(:,:,:) = sf_dyn(jf_uwd)%fnow(:,:,:) 
+               zv(:,:,:) = sf_dyn(jf_vwd)%fnow(:,:,:)
+               CALL dta_dyn_wzv( zu, zv, zw )
+               wnow(:,:,:)  = zw(:,:,:) * tmask(:,:,:)
+            ENDIF
+         ENDIF
+         IF( sf_dyn(jf_uwd)%ln_tint )  THEN
+            ztinta =  REAL( isecsbc - sf_dyn(jf_uwd)%nrec_b(2), wp )  &
+               &    / REAL( sf_dyn(jf_uwd)%nrec_a(2) - sf_dyn(jf_uwd)%nrec_b(2), wp )
+            ztintb =  1. - ztinta
+            wn(:,:,:) = ztintb * wdta(:,:,:,1)  + ztinta * wdta(:,:,:,2)  
+         ELSE
+            wn(:,:,:) = wnow(:,:,:)
+         ENDIF
+      ENDIF
+      !
+      tsn(:,:,:,jf_tem) = sf_dyn(jf_tem)%fnow(:,:,:) * tmask(:,:,:)    ! temperature
+      tsn(:,:,:,jf_sal) = sf_dyn(jf_sal)%fnow(:,:,:) * tmask(:,:,:)    ! salinity
+      !
+      CALL eos( tsn, rhd, rhop )                                       ! In any case, we need rhop
+      !
+      avt(:,:,:)       = sf_dyn(jf_avt)%fnow(:,:,:) * tmask(:,:,:)    ! vertical diffusive coefficient 
+      un (:,:,:)       = sf_dyn(jf_uwd)%fnow(:,:,:) * umask(:,:,:)    ! u-velocity
+      vn (:,:,:)       = sf_dyn(jf_vwd)%fnow(:,:,:) * vmask(:,:,:)    ! v-velocity 
+      IF( .NOT.ln_dynwzv ) &                                           ! w-velocity read in file 
+         wn (:,:,:)    = sf_dyn(jf_wwd)%fnow(:,:,:) * tmask(:,:,:)    
+      hmld(:,:)        = sf_dyn(jf_mld)%fnow(:,:,1) * tmask(:,:,1)    ! mixed layer depht
+      wndm(:,:)        = sf_dyn(jf_wnd)%fnow(:,:,1) * tmask(:,:,1)    ! wind speed - needed for gas exchange
+      emp (:,:)        = sf_dyn(jf_emp)%fnow(:,:,1) * tmask(:,:,1)    ! E-P
+      emps(:,:)        = emp(:,:) 
+      fr_i(:,:)        = sf_dyn(jf_ice)%fnow(:,:,1) * tmask(:,:,1)     ! Sea-ice fraction
+      qsr (:,:)        = sf_dyn(jf_qsr)%fnow(:,:,1) * tmask(:,:,1)    ! solar radiation
+      !                                                      ! bbl diffusive coef
+#if defined key_trabbl
+      IF( ln_dynbbl ) THEN                                        ! read in a file
+         ahu_bbl(:,:)  = sf_dyn(jf_ubl)%fnow(:,:,1) * umask(:,:,1)
+         ahv_bbl(:,:)  = sf_dyn(jf_vbl)%fnow(:,:,1) * umask(:,:,1)
+      ELSE                                                        ! Compute bbl coefficients if needed
          tsb(:,:,:,:) = tsn(:,:,:,:)
          CALL bbl( kt, 'TRC')
       END IF
-      !
-      IF(ln_ctl) THEN
-         CALL prt_ctl(tab3d_1=tsn(:,:,:,jp_tem), clinfo1=' tn      - : ', mask1=tmask, ovlap=1, kdim=jpk   )
-         CALL prt_ctl(tab3d_1=tsn(:,:,:,jp_sal), clinfo1=' sn      - : ', mask1=tmask, ovlap=1, kdim=jpk   )
+#endif
+#if ! defined key_degrad && defined key_traldf_c2d && defined key_traldf_eiv
+      aeiw(:,:)        = sf_dyn(jf_eiw)%fnow(:,:,1) * tmask(:,:,1)    ! w-eiv
+      !                                                           ! Computes the horizontal values from the vertical value
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            aeiu(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji+1,jj  ) )  ! Average the diffusive coefficient at u- v- points
+            aeiv(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji  ,jj+1) )  ! at u- v- points
+         END DO
+      END DO
+      CALL lbc_lnk( aeiu, 'U', 1. )   ;   CALL lbc_lnk( aeiv, 'V', 1. )    ! lateral boundary condition
+#endif
+      
+#if defined key_degrad
+      !                                          ! degrad option : diffusive and eiv coef are 3D
+      ahtu(:,:,:) = sf_dyn(jf_ahu)%fnow(:,:,:) * umask(:,:,:)
+      ahtv(:,:,:) = sf_dyn(jf_ahv)%fnow(:,:,:) * umask(:,:,:)
+      ahtw(:,:,:) = sf_dyn(jf_ahw)%fnow(:,:,:) * umask(:,:,:)
+#  if defined key_traldf_eiv
+      aeiu(:,:,:) = sf_dyn(jf_eiu)%fnow(:,:,:) * umask(:,:,:)
+      aeiv(:,:,:) = sf_dyn(jf_eiv)%fnow(:,:,:) * umask(:,:,:)
+      aeiw(:,:,:) = sf_dyn(jf_eiw)%fnow(:,:,:) * umask(:,:,:)
+#  endif
+#endif
+      !
+      IF(ln_ctl) THEN                  ! print control
+         CALL prt_ctl(tab3d_1=tsn(:,:,:,jf_tem), clinfo1=' tn      - : ', mask1=tmask, ovlap=1, kdim=jpk   )
+         CALL prt_ctl(tab3d_1=tsn(:,:,:,jf_sal), clinfo1=' sn      - : ', mask1=tmask, ovlap=1, kdim=jpk   )
          CALL prt_ctl(tab3d_1=un               , clinfo1=' un      - : ', mask1=tmask, ovlap=1, kdim=jpk   )
          CALL prt_ctl(tab3d_1=vn               , clinfo1=' vn      - : ', mask1=tmask, ovlap=1, kdim=jpk   )
@@ -242,276 +276,168 @@
 
 
-   INTEGER FUNCTION dta_dyn_alloc()
-      !!---------------------------------------------------------------------
-      !!                 ***  ROUTINE dta_dyn_alloc  ***
-      !!---------------------------------------------------------------------
-
-      ALLOCATE( tdta    (jpi,jpj,jpk,2), sdta    (jpi,jpj,jpk,2),    &
-         &      udta    (jpi,jpj,jpk,2), vdta    (jpi,jpj,jpk,2),    &
-         &      wdta    (jpi,jpj,jpk,2), avtdta  (jpi,jpj,jpk,2),    &
-#if defined key_ldfslp && ! defined key_c1d
-         &      uslpdta (jpi,jpj,jpk,2), vslpdta (jpi,jpj,jpk,2),    &
-         &      wslpidta(jpi,jpj,jpk,2), wslpjdta(jpi,jpj,jpk,2),    &
-#endif
-#if defined key_degrad
-         &      ahtudta (jpi,jpj,jpk,2), ahtvdta (jpi,jpj,jpk,2),    &
-         &      ahtwdta (jpi,jpj,jpk,2),                             &
-# if defined key_traldf_eiv
-         &      aeiudta (jpi,jpj,jpk,2), aeivdta (jpi,jpj,jpk,2),    &
-         &      aeiwdta (jpi,jpj,jpk,2),                             &
-# endif
-#endif
-#if ! defined key_degrad &&  defined key_traldf_c2d && defined key_traldf_eiv
-         &      aeiwdta (jpi,jpj,    2),                             &
-#endif
-         &      hmlddta (jpi,jpj,    2), wspddta (jpi,jpj,    2),    &
-         &      frlddta (jpi,jpj,    2), qsrdta  (jpi,jpj,    2),    &
-         &      empdta  (jpi,jpj,    2),                         STAT=dta_dyn_alloc ) 
-         !
-      IF( dta_dyn_alloc /= 0 )   CALL ctl_warn('dta_dyn_alloc: failed to allocate facvol array')
-      !
-   END FUNCTION dta_dyn_alloc
-
-
-   SUBROUTINE dynrea( kt, kenr )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dynrea  ***
-      !!
-      !! ** Purpose : READ dynamics fiels from OPA9 netcdf output
-      !! 
-      !! ** Method : READ the kenr records of DATA and store in udta(...,2), ....  
-      !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zu      => wrk_3d_3  , zv    => wrk_3d_4 , zw   => wrk_3d_5
-      USE wrk_nemo, ONLY: zt      => wrk_3d_6  , zs    => wrk_3d_7 , zavt => wrk_3d_8  
-      USE wrk_nemo, ONLY: zemp    => wrk_2d_11 , zqsr  => wrk_2d_12, zmld => wrk_2d_13
-      USE wrk_nemo, ONLY: zice    => wrk_2d_14 , zwspd => wrk_2d_15 
-      USE wrk_nemo, ONLY: ztaux   => wrk_2d_16 , ztauy => wrk_2d_17
-      USE wrk_nemo, ONLY: zbblx   => wrk_2d_18 , zbbly => wrk_2d_19
-      USE wrk_nemo, ONLY: zaeiw2d => wrk_2d_10
-      USE wrk_nemo, ONLY: ztsn    => wrk_4d_1
-      !
-      INTEGER, INTENT(in) ::   kt, kenr   ! time index
-      !!
-      INTEGER ::  jkenr
-#if defined key_degrad
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zahtu, zahtv, zahtw   ! Lateral diffusivity
-# if defined key_traldf_eiv
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zaeiu, zaeiv, zaeiw   ! G&M coefficient
-# endif
-#endif
-      !!----------------------------------------------------------------------
-      ! 
-      IF( wrk_in_use(3, 3,4,5,6,7,8) .OR. &
-          wrk_in_use(4, 1)                             .OR. &
-          wrk_in_use(2, 10,11,12,13,14,15,16,17,18,19)               ) THEN
-         CALL ctl_stop('domrea/dta_dyn: requested workspace arrays unavailable')   ;   RETURN
-      ENDIF
-
-#if defined key_degrad
-      ALLOCATE( zahtu(jpi,jpj,jpk), zahtv(jpi,jpj,jpk), zahtw(jpi,jpj,jpk) ) 
-# if defined key_traldf_eiv
-      ALLOCATE( zaeiu(jpi,jpj,jpk), zaeiv(jpi,jpj,jpk), zaeiw(jpi,jpj,jpk) )
-# endif
-#endif
-      
-      ! cas d'un fichier non periodique : on utilise deux fois le premier et
-      ! le dernier champ temporel
-
-      jkenr = kenr
-
+   SUBROUTINE dta_dyn_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dta_dyn_init  ***
+      !!
+      !! ** Purpose :   Initialisation of the dynamical data     
+      !! ** Method  : - read the data namdta_dyn namelist
+      !!
+      !! ** Action  : - read parameters
+      !!----------------------------------------------------------------------
+      INTEGER  :: ierr, ierr0, ierr1, ierr2, ierr3   ! return error code
+      INTEGER  :: ifpr                               ! dummy loop indice
+      INTEGER  :: jfld                               ! dummy loop arguments
+      INTEGER  :: inum, idv, idimv                   ! local integer
+      !!
+      CHARACTER(len=100)            ::  cn_dir   !   Root directory for location of core files
+      TYPE(FLD_N), DIMENSION(jpfld) ::  slf_d    ! array of namelist informations on the fields to read
+      TYPE(FLD_N) :: sn_tem, sn_sal, sn_mld, sn_emp, sn_ice, sn_qsr, sn_wnd  ! informations about the fields to be read
+      TYPE(FLD_N) :: sn_uwd, sn_vwd, sn_wwd, sn_avt, sn_ubl, sn_vbl          !   "                                 "
+      TYPE(FLD_N) :: sn_ahu, sn_ahv, sn_ahw, sn_eiu, sn_eiv, sn_eiw          !   "                                 "
+      !
+      NAMELIST/namdta_dyn/cn_dir, ln_dynwzv, ln_dynbbl, ln_degrad,    &
+         &                sn_tem, sn_sal, sn_mld, sn_emp, sn_ice, sn_qsr, sn_wnd,  &
+         &                sn_uwd, sn_vwd, sn_wwd, sn_avt, sn_ubl, sn_vbl,          &
+         &                sn_ahu, sn_ahv, sn_ahw, sn_eiu, sn_eiv, sn_eiw
+
+      !!----------------------------------------------------------------------
+      !                                   ! ============
+      !                                   !   Namelist
+      !                                   ! ============
+      ! (NB: frequency positive => hours, negative => months)
+      !                !   file      ! frequency !  variable  ! time intep !  clim  ! 'yearly' or ! weights  ! rotation   !
+      !                !   name      !  (hours)  !   name     !   (T/F)    !  (T/F) !  'monthly'  ! filename ! pairs      !
+      sn_tem  = FLD_N( 'dyna_grid_T' ,    120    , 'votemper' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_sal  = FLD_N( 'dyna_grid_T' ,    120    , 'vosaline' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_mld  = FLD_N( 'dyna_grid_T' ,    120    , 'somixght' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_emp  = FLD_N( 'dyna_grid_T' ,    120    , 'sowaflcd' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_ice  = FLD_N( 'dyna_grid_T' ,    120    , 'soicecov' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_qsr  = FLD_N( 'dyna_grid_T' ,    120    , 'soshfldo' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_wnd  = FLD_N( 'dyna_grid_T' ,    120    , 'sowindsp' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_uwd  = FLD_N( 'dyna_grid_U' ,    120    , 'vozocrtx' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_vwd  = FLD_N( 'dyna_grid_V' ,    120    , 'vomecrty' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_wwd  = FLD_N( 'dyna_grid_W' ,    120    , 'vovecrtz' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_avt  = FLD_N( 'dyna_grid_W' ,    120    , 'votkeavt' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_ubl  = FLD_N( 'dyna_grid_U' ,    120    , 'sobblcox' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_vbl  = FLD_N( 'dyna_grid_V' ,    120    , 'sobblcoy' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_ahu  = FLD_N( 'dyna_grid_U' ,    120    , 'vozoahtu' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_ahv  = FLD_N( 'dyna_grid_V' ,    120    , 'vomeahtv' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_ahw  = FLD_N( 'dyna_grid_W' ,    120    , 'voveahtz' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_eiu  = FLD_N( 'dyna_grid_U' ,    120    , 'vozoaeiu' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_eiv  = FLD_N( 'dyna_grid_V' ,    120    , 'vomeaeiv' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_eiw  = FLD_N( 'dyna_grid_W' ,    120    , 'voveaeiw' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+      !
+      REWIND( numnam )                          ! read in namlist namdta_dyn
+      READ  ( numnam, namdta_dyn )
+      !                                         ! store namelist information in an array
+      !                                         ! Control print
       IF(lwp) THEN
          WRITE(numout,*)
-         WRITE(numout,*) 'Dynrea : read dynamical fields, kenr = ', jkenr
-         WRITE(numout,*) '~~~~~~~'
-#if defined key_degrad
-         WRITE(numout,*) ' Degraded fields'
-#endif
+         WRITE(numout,*) 'dta_dyn : offline dynamics '
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '   Namelist namdta_dyn'
+         WRITE(numout,*) '      vertical velocity read from file (T) or computed (F) ln_dynwzv  = ', ln_dynwzv
+         WRITE(numout,*) '      bbl coef read from file (T) or computed (F)          ln_dynbbl  = ', ln_dynbbl
+         WRITE(numout,*) '      degradation option enabled (T) or not (F)            ln_degrad  = ', ln_degrad
          WRITE(numout,*)
       ENDIF
-
-
-      IF( kt == nit000 .AND. nlecoff == 0 ) THEN
-         nlecoff = 1
-         CALL  iom_open ( cfile_grid_T, numfl_t )
-         CALL  iom_open ( cfile_grid_U, numfl_u )
-         CALL  iom_open ( cfile_grid_V, numfl_v )
-         CALL  iom_open ( cfile_grid_W, numfl_w )
-      ENDIF
-
-      ! file grid-T
-      !---------------
-      CALL iom_get( numfl_t, jpdom_data, 'votemper', zt   (:,:,:), jkenr )
-      CALL iom_get( numfl_t, jpdom_data, 'vosaline', zs   (:,:,:), jkenr )
-      CALL iom_get( numfl_t, jpdom_data, 'somixhgt', zmld (:,:  ), jkenr )
-      CALL iom_get( numfl_t, jpdom_data, 'sowaflcd', zemp (:,:  ), jkenr )
-      CALL iom_get( numfl_t, jpdom_data, 'soshfldo', zqsr (:,:  ), jkenr )
-      CALL iom_get( numfl_t, jpdom_data, 'soicecov', zice (:,:  ), jkenr )
-      IF( iom_varid( numfl_t, 'sowindsp', ldstop = .FALSE. ) > 0 ) THEN 
-         CALL iom_get( numfl_t, jpdom_data, 'sowindsp', zwspd(:,:), jkenr ) 
+      ! 
+      IF( ln_degrad .AND. .NOT.lk_degrad ) THEN
+         CALL ctl_warn( 'dta_dyn_init: degradation option requires key_degrad activated ; force ln_degrad to false' )
+         ln_degrad = .FALSE.
+      ENDIF
+      IF( ln_dynbbl .AND. .NOT.lk_trabbl ) THEN
+         CALL ctl_warn( 'dta_dyn_init: bbl option requires key_trabbl activated ; force ln_dynbbl to false' )
+         ln_dynbbl = .FALSE.
+      ENDIF
+
+      jf_tem = 1   ;   jf_sal = 2   ;  jf_mld = 3   ;  jf_emp = 4   ;   jf_ice = 5   ;   jf_qsr = 6 
+      jf_wnd = 7   ;   jf_uwd = 8   ;  jf_vwd = 9   ;  jf_wwd = 10  ;   jf_avt = 11  ;   jfld  = 11
+      !
+      slf_d(jf_tem) = sn_tem   ;   slf_d(jf_sal) = sn_sal   ;   slf_d(jf_mld) = sn_mld
+      slf_d(jf_emp) = sn_emp   ;   slf_d(jf_ice) = sn_ice   ;   slf_d(jf_qsr) = sn_qsr
+      slf_d(jf_wnd) = sn_wnd   ;   slf_d(jf_uwd) = sn_uwd   ;   slf_d(jf_vwd) = sn_vwd
+      slf_d(jf_wwd) = sn_wwd   ;   slf_d(jf_avt) = sn_avt 
+      !
+      IF( .NOT.ln_degrad ) THEN     ! no degrad option
+         IF( lk_traldf_eiv .AND. ln_dynbbl ) THEN        ! eiv & bbl
+                 jf_ubl  = 12      ;         jf_vbl  = 13      ;         jf_eiw  = 14   ;   jfld = 14
+           slf_d(jf_ubl) = sn_ubl  ;   slf_d(jf_vbl) = sn_vbl  ;   slf_d(jf_eiw) = sn_eiw
+         ENDIF
+         IF( .NOT.lk_traldf_eiv .AND. ln_dynbbl ) THEN   ! no eiv & bbl
+                 jf_ubl  = 12      ;         jf_vbl  = 13      ;   jfld = 13
+           slf_d(jf_ubl) = sn_ubl  ;   slf_d(jf_vbl) = sn_vbl
+         ENDIF
+         IF( lk_traldf_eiv .AND. .NOT.ln_dynbbl ) THEN   ! eiv & no bbl
+           jf_eiw = 12   ;   jfld = 12   ;   slf_d(jf_eiw) = sn_eiw
+         ENDIF
       ELSE
-         CALL iom_get( numfl_u, jpdom_data, 'sozotaux', ztaux(:,:), jkenr )
-         CALL iom_get( numfl_v, jpdom_data, 'sometauy', ztauy(:,:), jkenr )
-         CALL tau2wnd( ztaux, ztauy, zwspd )
-      ENDIF
-      ! files grid-U / grid_V
-      CALL iom_get( numfl_u, jpdom_data, 'vozocrtx', zu   (:,:,:), jkenr )
-      CALL iom_get( numfl_v, jpdom_data, 'vomecrty', zv   (:,:,:), jkenr )
-#if defined key_trabbl
-      IF( .NOT. lk_c1d .AND. nn_bbl_ldf == 1 ) THEN
-         IF( iom_varid( numfl_u, 'ahu_bbl', ldstop = .FALSE. ) > 0  .AND. &
-         &   iom_varid( numfl_v, 'ahv_bbl', ldstop = .FALSE. ) > 0 ) THEN
-             CALL iom_get( numfl_u, jpdom_data, 'ahu_bbl', zbblx(:,:), jkenr )
-             CALL iom_get( numfl_v, jpdom_data, 'ahv_bbl', zbbly(:,:), jkenr )
-             l_offbbl = .TRUE.
-         ENDIF
-      ENDIF
-#endif 
-
-      ! file grid-W
-      ! CALL iom_get ( numfl_w, jpdom_data, 'vovecrtz', zw   (:,:,:), jkenr )
-      ! Computation of vertical velocity using horizontal divergence
-      CALL wzv( zu, zv, zw )
-
-      IF( iom_varid( numfl_w, 'voddmavs', ldstop = .FALSE. ) > 0 ) THEN          ! avs exist: it is used
-         CALL iom_get( numfl_w, jpdom_data, 'voddmavs', zavt (:,:,:), jkenr )
-      ELSE                                                                       ! no avs: use avt
-         CALL iom_get( numfl_w, jpdom_data, 'votkeavt', zavt (:,:,:), jkenr )
-      ENDIF
-
-#if ! defined key_degrad && defined key_traldf_c2d && defined key_traldf_eiv 
-      CALL iom_get( numfl_w, jpdom_data, 'soleaeiw', zaeiw2d(:,: ), jkenr )
-#endif
-
-#if defined key_degrad
-      CALL iom_get( numfl_u, jpdom_data, 'vozoahtu', zahtu(:,:,:), jkenr )
-      CALL iom_get( numfl_v, jpdom_data, 'vomeahtv', zahtv(:,:,:), jkenr )
-      CALL iom_get( numfl_w, jpdom_data, 'voveahtw', zahtw(:,:,:), jkenr )
-#  if defined key_traldf_eiv
-      CALL iom_get( numfl_u, jpdom_data, 'vozoaeiu', zaeiu(:,:,:), jkenr )
-      CALL iom_get( numfl_v, jpdom_data, 'vomeaeiv', zaeiv(:,:,:), jkenr )
-      CALL iom_get( numfl_w, jpdom_data, 'voveaeiw', zaeiw(:,:,:), jkenr )
-#  endif
-#endif
-
-      udta  (:,:,:,2) = zu  (:,:,:) * umask(:,:,:)
-      vdta  (:,:,:,2) = zv  (:,:,:) * vmask(:,:,:) 
-      wdta  (:,:,:,2) = zw  (:,:,:) * tmask(:,:,:)
-      tdta  (:,:,:,2) = zt  (:,:,:) * tmask(:,:,:)
-      sdta  (:,:,:,2) = zs  (:,:,:) * tmask(:,:,:)
-      avtdta(:,:,:,2) = zavt(:,:,:) * tmask(:,:,:)
-
-#if defined key_ldfslp && ! defined key_c1d
-      ! Computes slopes (here tsn and avt are used as workspace)
-      ztsn (:,:,:,jp_tem) = tdta  (:,:,:,2)
-      ztsn (:,:,:,jp_sal) = sdta  (:,:,:,2)
-      avt(:,:,:)          = avtdta(:,:,:,2)
-      
-      CALL eos( ztsn, rhd, rhop )   ! Time-filtered in situ density 
-      CALL bn2( ztsn, rn2 )         ! before Brunt-Vaisala frequency
-      IF( ln_zps )   &
-         &   CALL zps_hde( kt, jpts, ztsn, gtsu, gtsv,  &  ! Partial steps: before Horizontal DErivative
-         &                           rhd, gru , grv   )    ! of t, s, rd at the bottom ocean level
-      CALL zdf_mxl( kt )           ! mixed layer depth
-      CALL ldf_slp( kt, rhd, rn2 )
-         
-      uslpdta (:,:,:,2) = uslp (:,:,:)
-      vslpdta (:,:,:,2) = vslp (:,:,:)
-      wslpidta(:,:,:,2) = wslpi(:,:,:)
-      wslpjdta(:,:,:,2) = wslpj(:,:,:)
-#endif
-
-#if ! defined key_degrad && defined key_traldf_c2d && defined key_traldf_eiv
-      aeiwdta(:,:,2)  = zaeiw2d(:,:) * tmask(:,:,1)
-#endif
-
-#if defined key_degrad
-        ahtudta(:,:,:,2) = zahtu(:,:,:) * umask(:,:,:)
-        ahtvdta(:,:,:,2) = zahtv(:,:,:) * vmask(:,:,:)
-        ahtwdta(:,:,:,2) = zahtw(:,:,:) * tmask(:,:,:)
-#  if defined key_traldf_eiv
-        aeiudta(:,:,:,2) = zaeiu(:,:,:) * umask(:,:,:)
-        aeivdta(:,:,:,2) = zaeiv(:,:,:) * vmask(:,:,:)
-        aeiwdta(:,:,:,2) = zaeiw(:,:,:) * tmask(:,:,:)
-#  endif
-#endif
-
-      ! fluxes 
-      !
-      wspddta(:,:,2)  = zwspd(:,:) * tmask(:,:,1)
-      frlddta(:,:,2)  = zice (:,:) * tmask(:,:,1)
-      empdta (:,:,2)  = zemp (:,:) * tmask(:,:,1)
-      qsrdta (:,:,2)  = zqsr (:,:) * tmask(:,:,1)
-      hmlddta(:,:,2)  = zmld (:,:) * tmask(:,:,1)
-
-#if defined key_trabbl
-      IF( l_offbbl ) THEN 
-         bblxdta(:,:,2) = zbblx(:,:)  * umask(:,:,1)
-         bblydta(:,:,2) = zbbly(:,:)  * vmask(:,:,1)
-      ENDIF
-#endif
-      
-      IF( kt == nitend ) THEN
-         CALL iom_close ( numfl_t )
-         CALL iom_close ( numfl_u )
-         CALL iom_close ( numfl_v )
-         CALL iom_close ( numfl_w )
-      ENDIF
-      !      
-      IF( wrk_not_released(3, 3,4,5,6,7,8) .OR. &
-          wrk_not_released(4, 1                            ) .OR. &
-          wrk_not_released(2, 10,11,12,13,14,15,16,17,18,19)                ) THEN
-         CALL ctl_stop('domrea/dta_dyn: failed to release workspace arrays')
-      END IF
-#if defined key_degrad
-      DEALLOCATE( zahtu )   ;   DEALLOCATE( zahtv )   ;   DEALLOCATE( zahtw )
-# if defined key_traldf_eiv
-      DEALLOCATE( zaeiu )   ;   DEALLOCATE( zaeiv )   ;   DEALLOCATE( zaeiw )
-# endif
-#endif
-      !
-   END SUBROUTINE dynrea
-
-
-   SUBROUTINE dta_dyn_init
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dta_dyn_init  ***
-      !!
-      !! ** Purpose :   initializations of parameters for the interpolation
-      !!
-      !! ** Method :
-      !!----------------------------------------------------------------------
-      REAL(wp) :: znspyr   !: number of time step per year
-      !
-      NAMELIST/namdyn/ ndtadyn, ndtatot, nsptint, lperdyn,  &
-         &             cfile_grid_T, cfile_grid_U, cfile_grid_V, cfile_grid_W
-      !!----------------------------------------------------------------------
-      !
-      IF( dta_dyn_alloc() /= 0 )  CALL ctl_stop( 'STOP', 'dta_dyn_alloc: unable to allocate standard ocean arrays' )
-      !
-      REWIND( numnam )              ! Read Namelist namdyn : Lateral physics on tracers
-      READ  ( numnam, namdyn )
-      !
-      IF(lwp) THEN                  ! control print
-         WRITE(numout,*)
-         WRITE(numout,*) 'namdyn : offline dynamical selection'
-         WRITE(numout,*) '~~~~~~~'
-         WRITE(numout,*) '  Namelist namdyn : set parameters for the lecture of the dynamical fields'
-         WRITE(numout,*) 
-         WRITE(numout,*) ' number of elements in the FILE for a year  ndtadyn = ' , ndtadyn
-         WRITE(numout,*) ' total number of elements in the FILE       ndtatot = ' , ndtatot
-         WRITE(numout,*) ' type of interpolation                      nsptint = ' , nsptint
-         WRITE(numout,*) ' loop on the same FILE                      lperdyn = ' , lperdyn
-         WRITE(numout,*) '  '
-         WRITE(numout,*) ' name of grid_T file                   cfile_grid_T = ', TRIM(cfile_grid_T)    
-         WRITE(numout,*) ' name of grid_U file                   cfile_grid_U = ', TRIM(cfile_grid_U) 
-         WRITE(numout,*) ' name of grid_V file                   cfile_grid_V = ', TRIM(cfile_grid_V) 
-         WRITE(numout,*) ' name of grid_W file                   cfile_grid_W = ', TRIM(cfile_grid_W)      
-         WRITE(numout,*) ' '
-      ENDIF
-      !
-      znspyr   = nyear_len(1) * rday / rdt  
-      rnspdta  = znspyr / REAL( ndtadyn, wp )
-      rnspdta2 = rnspdta * 0.5 
+              jf_ahu  = 12      ;         jf_ahv  = 13      ;         jf_ahw  = 14   ;   jfld = 14
+        slf_d(jf_ahu) = sn_ahu  ;   slf_d(jf_ahv) = sn_ahv  ;   slf_d(jf_ahw) = sn_ahw
+        IF( lk_traldf_eiv .AND. ln_dynbbl ) THEN         ! eiv & bbl
+                 jf_ubl  = 15      ;         jf_vbl  = 16      
+           slf_d(jf_ubl) = sn_ubl  ;   slf_d(jf_vbl) = sn_vbl  
+                 jf_eiu  = 17      ;         jf_eiv  = 18      ;          jf_eiw  = 19   ;   jfld = 19
+           slf_d(jf_eiu) = sn_eiu  ;   slf_d(jf_eiv) = sn_eiv  ;    slf_d(jf_eiw) = sn_eiw
+        ENDIF
+        IF( .NOT.lk_traldf_eiv .AND. ln_dynbbl ) THEN    ! no eiv & bbl
+                 jf_ubl  = 15      ;         jf_vbl  = 16      ;   jfld = 16
+           slf_d(jf_ubl) = sn_ubl  ;   slf_d(jf_vbl) = sn_vbl
+        ENDIF
+        IF( lk_traldf_eiv .AND. .NOT.ln_dynbbl ) THEN    ! eiv & no bbl
+                 jf_eiu  = 15      ;         jf_eiv  = 16      ;         jf_eiw  = 17   ;   jfld = 17
+           slf_d(jf_eiu) = sn_eiu  ;   slf_d(jf_eiv) = sn_eiv  ;   slf_d(jf_eiw) = sn_eiw
+        ENDIF
+      ENDIF
+  
+      ALLOCATE( sf_dyn(jfld), STAT=ierr )         ! set sf structure
+      IF( ierr > 0 ) THEN
+         CALL ctl_stop( 'dta_dyn: unable to allocate sf structure' )   ;   RETURN
+      ENDIF
+      ! Open file for each variable to get his number of dimension
+      DO ifpr = 1, jfld
+         CALL iom_open( slf_d(ifpr)%clname, inum )
+         idv   = iom_varid( inum , slf_d(ifpr)%clvar )  ! id of the variable sdjf%clvar
+         idimv = iom_file ( inum )%ndims(idv)             ! number of dimension for variable sdjf%clvar
+         IF( inum /= 0 )   CALL iom_close( inum )       ! close file if already open
+         IF( idimv == 3 ) THEN    ! 2D variable
+                                      ALLOCATE( sf_dyn(ifpr)%fnow(jpi,jpj,1)    , STAT=ierr0 )
+            IF( slf_d(ifpr)%ln_tint ) ALLOCATE( sf_dyn(ifpr)%fdta(jpi,jpj,1,2)  , STAT=ierr1 )
+         ELSE                     ! 3D variable
+                                      ALLOCATE( sf_dyn(ifpr)%fnow(jpi,jpj,jpk)  , STAT=ierr0 )
+            IF( slf_d(ifpr)%ln_tint ) ALLOCATE( sf_dyn(ifpr)%fdta(jpi,jpj,jpk,2), STAT=ierr1 )
+         ENDIF
+         IF( ierr0 + ierr1 > 0 ) THEN
+            CALL ctl_stop( 'dta_dyn_init : unable to allocate sf_dyn array structure' )   ;   RETURN
+         ENDIF
+      END DO
+      !                                         ! fill sf with slf_i and control print
+      CALL fld_fill( sf_dyn, slf_d, cn_dir, 'dta_dyn_init', 'Data in file', 'namdta_dyn' )
+      !
+      IF( lk_ldfslp ) THEN                  ! slopes 
+         IF( sf_dyn(jf_tem)%ln_tint ) THEN      ! time interpolation
+            ALLOCATE( uslpdta (jpi,jpj,jpk,2), vslpdta (jpi,jpj,jpk,2),    &
+            &         wslpidta(jpi,jpj,jpk,2), wslpjdta(jpi,jpj,jpk,2), STAT=ierr2 )
+         ELSE
+            ALLOCATE( uslpnow (jpi,jpj,jpk)  , vslpnow (jpi,jpj,jpk)  ,    &
+            &         wslpinow(jpi,jpj,jpk)  , wslpjnow(jpi,jpj,jpk)  , STAT=ierr2 )
+         ENDIF 
+         IF( ierr2 > 0 ) THEN
+            CALL ctl_stop( 'dta_dyn_init : unable to allocate slope arrays' )   ;   RETURN
+         ENDIF
+      ENDIF
+      IF( ln_dynwzv ) THEN                  ! slopes 
+         IF( sf_dyn(jf_uwd)%ln_tint ) THEN      ! time interpolation
+            ALLOCATE( wdta(jpi,jpj,jpk,2), STAT=ierr3 )
+         ELSE
+            ALLOCATE( wnow(jpi,jpj,jpk)  , STAT=ierr3 )
+         ENDIF 
+         IF( ierr3 > 0 ) THEN
+            CALL ctl_stop( 'dta_dyn_init : unable to allocate wdta arrays' )   ;   RETURN
+         ENDIF
+      ENDIF
+      !
+      nrecprev_tem = 0
+      nrecprev_uwd = 0
       !
       CALL dta_dyn( nit000 )
@@ -519,6 +445,5 @@
    END SUBROUTINE dta_dyn_init
 
-
-   SUBROUTINE wzv( pu, pv, pw )
+   SUBROUTINE dta_dyn_wzv( pu, pv, pw )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE wzv  ***
@@ -534,14 +459,15 @@
       !!        The boundary conditions are w=0 at the bottom (no flux).
       !!----------------------------------------------------------------------
+      USE oce, ONLY:  zhdiv => hdivn
+      !
       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pu, pv    !:  horizontal velocities
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) :: pw        !:  verticla velocity
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) :: pw        !:  vertical velocity
       !!
       INTEGER  ::  ji, jj, jk
       REAL(wp) ::  zu, zu1, zv, zv1, zet
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zhdiv     !:  horizontal divergence
       !!----------------------------------------------------------------------
       !
       ! Computation of vertical velocity using horizontal divergence
-      zhdiv(:,:,:) = 0.
+      zhdiv(:,:,:) = 0._wp
       DO jk = 1, jpkm1
          DO jj = 2, jpjm1
@@ -564,234 +490,38 @@
       END DO
       !
-   END SUBROUTINE wzv
-
-
-   SUBROUTINE dta_eiv( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dta_eiv  ***
-      !!
-      !! ** Purpose :   Compute the eddy induced velocity coefficient from the
-      !!      growth rate of baroclinic instability.
-      !!
-      !! ** Method : Specific to the offline model. Computes the horizontal
-      !!             values from the vertical value
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt     ! ocean time-step inedx
-      !!
-      INTEGER ::   ji, jj           ! dummy loop indices
-      !!----------------------------------------------------------------------
-      !
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'dta_eiv : eddy induced velocity coefficients'
-         IF(lwp) WRITE(numout,*) '~~~~~~~'
-      ENDIF
-      !
-#if defined key_ldfeiv
-      ! Average the diffusive coefficient at u- v- points
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            aeiu(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji+1,jj  ) )
-            aeiv(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji  ,jj+1) )
-         END DO
-      END DO
-      CALL lbc_lnk( aeiu, 'U', 1. )   ;   CALL lbc_lnk( aeiv, 'V', 1. )    ! lateral boundary condition
+   END SUBROUTINE dta_dyn_wzv
+
+   SUBROUTINE dta_dyn_slp( kt, pts, puslp, pvslp, pwslpi, pwslpj )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE dta_dyn_slp  ***
+      !!
+      !! ** Purpose : Computation of slope
+      !!
+      !!---------------------------------------------------------------------
+      INTEGER ,                              INTENT(in ) :: kt       ! time step
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in ) :: pts      ! temperature/salinity
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(out) :: puslp    ! zonal isopycnal slopes
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(out) :: pvslp    ! meridional isopycnal slopes
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(out) :: pwslpi   ! zonal diapycnal slopes
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(out) :: pwslpj   ! meridional diapycnal slopes
+      !! 
+#if defined key_ldfslp && ! defined key_c1d
+      CALL eos( pts, rhd, rhop )   ! Time-filtered in situ density 
+      CALL bn2( pts, rn2 )         ! before Brunt-Vaisala frequency
+      IF( ln_zps )   &
+         &  CALL zps_hde( kt, jpts, pts, gtsu, gtsv, rhd, gru, grv )  ! Partial steps: before Horizontal DErivative
+         !                                                            ! of t, s, rd at the bottom ocean level
+      CALL zdf_mxl( kt )            ! mixed layer depth
+      CALL ldf_slp( kt, rhd, rn2 )  ! slopes
+      puslp (:,:,:) = uslp (:,:,:) 
+      pvslp (:,:,:) = vslp (:,:,:) 
+      pwslpi(:,:,:) = wslpi(:,:,:) 
+      pwslpj(:,:,:) = wslpj(:,:,:) 
+#else
+      WRITE(*,*) 'dta_dyn_slp: You should not have seen this print! error?', &
+        &        kt, pts(1,1,1,1),puslp(1,1,1), pvslp(1,1,1), pwslpi(1,1,1), pwslpj(1,1,1)
 #endif
       !
-   END SUBROUTINE dta_eiv
-
-
-   SUBROUTINE tau2wnd( ptaux, ptauy, pwspd )
-      !!---------------------------------------------------------------------
-      !!                    ***  ROUTINE sbc_tau2wnd  ***
-      !!
-      !! ** Purpose : Estimation of wind speed as a function of wind stress
-      !!
-      !! ** Method  : |tau|=rhoa*Cd*|U|^2
-      !!---------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   ptaux, ptauy   ! wind stress in i-j direction resp.
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pwspd          ! wind speed
-      !! 
-      REAL(wp) ::   zrhoa  = 1.22_wp       ! Air density kg/m3
-      REAL(wp) ::   zcdrag = 1.5e-3_wp     ! drag coefficient
-      REAL(wp) ::   ztx, zty, ztau, zcoef  ! temporary variables
-      INTEGER  ::   ji, jj                 ! dummy indices
-      !!---------------------------------------------------------------------
-      zcoef = 1. / ( zrhoa * zcdrag )
-!CDIR NOVERRCHK
-      DO jj = 2, jpjm1
-!CDIR NOVERRCHK
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            ztx = ptaux(ji,jj) * umask(ji,jj,1) + ptaux(ji-1,jj  ) * umask(ji-1,jj  ,1)
-            zty = ptauy(ji,jj) * vmask(ji,jj,1) + ptauy(ji  ,jj-1) * vmask(ji  ,jj-1,1)
-            ztau = 0.5 * SQRT( ztx * ztx + zty * zty )
-            pwspd(ji,jj) = SQRT ( ztau * zcoef ) * tmask(ji,jj,1)
-         END DO
-      END DO
-      CALL lbc_lnk( pwspd(:,:), 'T', 1. )
-      !
-   END SUBROUTINE tau2wnd
-
-
-   SUBROUTINE swap_dyn_data
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE swap_dyn_data  ***
-      !!
-      !! ** Purpose :   swap array data
-      !!----------------------------------------------------------------------
-      !
-      ! swap from record 2 to 1
-      tdta   (:,:,:,1) = tdta   (:,:,:,2)
-      sdta   (:,:,:,1) = sdta   (:,:,:,2)
-      avtdta (:,:,:,1) = avtdta (:,:,:,2)
-      udta   (:,:,:,1) = udta   (:,:,:,2)
-      vdta   (:,:,:,1) = vdta   (:,:,:,2)
-      wdta   (:,:,:,1) = wdta   (:,:,:,2)
-#if defined key_ldfslp && ! defined key_c1d
-      uslpdta (:,:,:,1) = uslpdta (:,:,:,2)
-      vslpdta (:,:,:,1) = vslpdta (:,:,:,2)
-      wslpidta(:,:,:,1) = wslpidta(:,:,:,2)
-      wslpjdta(:,:,:,1) = wslpjdta(:,:,:,2)
-#endif
-      hmlddta(:,:,1) = hmlddta(:,:,2) 
-      wspddta(:,:,1) = wspddta(:,:,2) 
-      frlddta(:,:,1) = frlddta(:,:,2) 
-      empdta (:,:,1) = empdta (:,:,2) 
-      qsrdta (:,:,1) = qsrdta (:,:,2) 
-      IF( l_offbbl ) THEN
-         bblxdta(:,:,1) = bblxdta(:,:,2)
-         bblydta(:,:,1) = bblydta(:,:,2) 
-      ENDIF
-
-#if ! defined key_degrad && defined key_traldf_c2d && defined key_traldf_eiv
-      aeiwdta(:,:,1) = aeiwdta(:,:,2)
-#endif
-
-#if defined key_degrad
-      ahtudta(:,:,:,1) = ahtudta(:,:,:,2)
-      ahtvdta(:,:,:,1) = ahtvdta(:,:,:,2)
-      ahtwdta(:,:,:,1) = ahtwdta(:,:,:,2)
-#  if defined key_traldf_eiv
-      aeiudta(:,:,:,1) = aeiudta(:,:,:,2)
-      aeivdta(:,:,:,1) = aeivdta(:,:,:,2)
-      aeiwdta(:,:,:,1) = aeiwdta(:,:,:,2)
-#  endif
-#endif
-      !
-   END SUBROUTINE swap_dyn_data
-
-
-   SUBROUTINE assign_dyn_data
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE assign_dyn_data  ***
-      !!
-      !! ** Purpose :   Assign dynamical data to the data that have been read
-      !!                without time interpolation
-      !!
-      !!----------------------------------------------------------------------
-      
-      tsn(:,:,:,jp_tem) = tdta  (:,:,:,2)
-      tsn(:,:,:,jp_sal) = sdta  (:,:,:,2)
-      avt(:,:,:)        = avtdta(:,:,:,2)
-      
-      un (:,:,:) = udta  (:,:,:,2) 
-      vn (:,:,:) = vdta  (:,:,:,2)
-      wn (:,:,:) = wdta  (:,:,:,2)
-      
-#if defined key_ldfslp && ! defined key_c1d
-      uslp (:,:,:) = uslpdta (:,:,:,2) 
-      vslp (:,:,:) = vslpdta (:,:,:,2) 
-      wslpi(:,:,:) = wslpidta(:,:,:,2) 
-      wslpj(:,:,:) = wslpjdta(:,:,:,2) 
-#endif
-
-      hmld(:,:) = hmlddta(:,:,2) 
-      wndm(:,:) = wspddta(:,:,2) 
-      fr_i(:,:) = frlddta(:,:,2) 
-      emp (:,:) = empdta (:,:,2) 
-      emps(:,:) = emp(:,:) 
-      qsr (:,:) = qsrdta (:,:,2) 
-#if defined key_trabbl
-      IF( l_offbbl ) THEN
-         ahu_bbl(:,:) = bblxdta(:,:,2)
-         ahv_bbl(:,:) = bblydta(:,:,2) 
-      ENDIF
-#endif
-#if ! defined key_degrad && defined key_traldf_c2d && defined key_traldf_eiv
-      aeiw(:,:) = aeiwdta(:,:,2)
-#endif
-      
-#if defined key_degrad
-      ahtu(:,:,:) = ahtudta(:,:,:,2)
-      ahtv(:,:,:) = ahtvdta(:,:,:,2)
-      ahtw(:,:,:) = ahtwdta(:,:,:,2)
-#  if defined key_traldf_eiv
-      aeiu(:,:,:) = aeiudta(:,:,:,2)
-      aeiv(:,:,:) = aeivdta(:,:,:,2)
-      aeiw(:,:,:) = aeiwdta(:,:,:,2)
-#  endif
-#endif
-      !
-   END SUBROUTINE assign_dyn_data
-
-
-   SUBROUTINE linear_interp_dyn_data( pweigh )
-      !!----------------------------------------------------------------------
-      !!               ***  ROUTINE linear_interp_dyn_data  ***
-      !!
-      !! ** Purpose :   linear interpolation of data
-      !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in) ::   pweigh   ! weigh
-      !!
-      REAL(wp) :: zweighm1
-      !!----------------------------------------------------------------------
-
-      zweighm1 = 1. - pweigh
-      
-      tsn(:,:,:,jp_tem) = zweighm1 * tdta  (:,:,:,1) + pweigh * tdta  (:,:,:,2)
-      tsn(:,:,:,jp_sal) = zweighm1 * sdta  (:,:,:,1) + pweigh * sdta  (:,:,:,2)
-      avt(:,:,:)        = zweighm1 * avtdta(:,:,:,1) + pweigh * avtdta(:,:,:,2)
-      
-      un (:,:,:) = zweighm1 * udta  (:,:,:,1) + pweigh * udta  (:,:,:,2) 
-      vn (:,:,:) = zweighm1 * vdta  (:,:,:,1) + pweigh * vdta  (:,:,:,2)
-      wn (:,:,:) = zweighm1 * wdta  (:,:,:,1) + pweigh * wdta  (:,:,:,2)
-      
-#if defined key_ldfslp && ! defined key_c1d
-      uslp (:,:,:) = zweighm1 * uslpdta (:,:,:,1) + pweigh * uslpdta (:,:,:,2) 
-      vslp (:,:,:) = zweighm1 * vslpdta (:,:,:,1) + pweigh * vslpdta (:,:,:,2) 
-      wslpi(:,:,:) = zweighm1 * wslpidta(:,:,:,1) + pweigh * wslpidta(:,:,:,2) 
-      wslpj(:,:,:) = zweighm1 * wslpjdta(:,:,:,1) + pweigh * wslpjdta(:,:,:,2) 
-#endif
-
-      hmld(:,:) = zweighm1 * hmlddta(:,:,1) + pweigh  * hmlddta(:,:,2) 
-      wndm(:,:) = zweighm1 * wspddta(:,:,1) + pweigh  * wspddta(:,:,2) 
-      fr_i(:,:) = zweighm1 * frlddta(:,:,1) + pweigh  * frlddta(:,:,2) 
-      emp (:,:) = zweighm1 * empdta (:,:,1) + pweigh  * empdta (:,:,2) 
-      emps(:,:) = emp(:,:) 
-      qsr (:,:) = zweighm1 * qsrdta (:,:,1) + pweigh  * qsrdta (:,:,2) 
-#if defined key_trabbl
-      IF( l_offbbl ) THEN
-         ahu_bbl(:,:) = zweighm1 * bblxdta(:,:,1) +  pweigh  * bblxdta(:,:,2)
-         ahv_bbl(:,:) = zweighm1 * bblydta(:,:,1) +  pweigh  * bblydta(:,:,2)
-      ENDIF
-#endif
-
-#if ! defined key_degrad && defined key_traldf_c2d && defined key_traldf_eiv 
-      aeiw(:,:) = zweighm1 * aeiwdta(:,:,1) + pweigh * aeiwdta(:,:,2)
-#endif
-      
-#if defined key_degrad
-      ahtu(:,:,:) = zweighm1 * ahtudta(:,:,:,1) + pweigh * ahtudta(:,:,:,2)
-      ahtv(:,:,:) = zweighm1 * ahtvdta(:,:,:,1) + pweigh * ahtvdta(:,:,:,2)
-      ahtw(:,:,:) = zweighm1 * ahtwdta(:,:,:,1) + pweigh * ahtwdta(:,:,:,2)
-#  if defined key_traldf_eiv
-      aeiu(:,:,:) = zweighm1 * aeiudta(:,:,:,1) + pweigh * aeiudta(:,:,:,2)
-      aeiv(:,:,:) = zweighm1 * aeivdta(:,:,:,1) + pweigh * aeivdta(:,:,:,2)
-      aeiw(:,:,:) = zweighm1 * aeiwdta(:,:,:,1) + pweigh * aeiwdta(:,:,:,2)
-#  endif
-#endif
-      !      
-   END SUBROUTINE linear_interp_dyn_data
-
+   END SUBROUTINE dta_dyn_slp
    !!======================================================================
 END MODULE dtadyn
Index: /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OPA_SRC/trc_oce.F90
===================================================================
--- /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OPA_SRC/trc_oce.F90	(revision 2820)
+++ /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/OPA_SRC/trc_oce.F90	(revision 2821)
@@ -25,4 +25,5 @@
    REAL(wp), PUBLIC                                      ::   r_si2   !: largest depth of extinction (blue & 0.01 mg.m-3)  (RGB)
    REAL(wp), PUBLIC, SAVE, ALLOCATABLE, DIMENSION(:,:,:) ::   etot3   !: light absortion coefficient
+   REAL(wp), PUBLIC, SAVE, ALLOCATABLE, DIMENSION(:,:,:) ::   facvol   !: volume for degraded regions
 
 #if defined key_top && defined key_pisces
@@ -48,4 +49,15 @@
    !!----------------------------------------------------------------------
    LOGICAL, PUBLIC, PARAMETER ::   lk_offline = .FALSE.   !: offline flag
+#endif
+#if defined key_degrad
+   !!----------------------------------------------------------------------
+   !!   'key_degrad'                                     Degradation mode          
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_degrad = .TRUE.   !: degradation flag
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                   NO  Degradation mode          
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_degrad = .FALSE.   !: degradation flag
 #endif
 
@@ -63,5 +75,10 @@
       !!                  ***  trc_oce_alloc  ***
       !!----------------------------------------------------------------------
-      ALLOCATE( etot3(jpi,jpj,jpk)   , STAT= trc_oce_alloc )
+      INTEGER ::   ierr(2)        ! Local variables
+      !!----------------------------------------------------------------------
+      ierr(:) = 0
+                     ALLOCATE( etot3 (jpi,jpj,jpk), STAT=ierr(1) )
+      IF( lk_degrad) ALLOCATE( facvol(jpi,jpj,jpk), STAT=ierr(2) )
+      trc_oce_alloc  = MAXVAL( ierr )
       !
       IF( trc_oce_alloc /= 0 )   CALL ctl_warn('trc_oce_alloc: failed to allocate etot3 array')
Index: /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90
===================================================================
--- /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90	(revision 2820)
+++ /branches/2011/dev_r2787_LOCEAN_offline_fldread/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90	(revision 2821)
@@ -198,8 +198,4 @@
    USE oce , ONLY :   gru     =>    gru     !:
    USE oce , ONLY :   grv     =>    grv     !: 
-# if defined key_degrad
-   USE dommsk , ONLY :   facvol     =>   facvol     !: volume factor for degradation
-# endif
-
 #endif
 
