Index: NEMO/trunk/src/OCE/SBC/fldread.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/fldread.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/fldread.F90	(revision 11536)
@@ -48,5 +48,5 @@
    TYPE, PUBLIC ::   FLD_N      !: Namelist field informations
       CHARACTER(len = 256) ::   clname      ! generic name of the NetCDF flux file
-      REAL(wp)             ::   nfreqh      ! frequency of each flux file
+      REAL(wp)             ::   freqh       ! frequency of each flux file
       CHARACTER(len = 34)  ::   clvar       ! generic name of the variable in the NetCDF flux file
       LOGICAL              ::   ln_tint     ! time interpolation or not (T/F)
@@ -64,5 +64,5 @@
       CHARACTER(len = 256)            ::   clrootname   ! generic name of the NetCDF file
       CHARACTER(len = 256)            ::   clname       ! current name of the NetCDF file
-      REAL(wp)                        ::   nfreqh       ! frequency of each flux file
+      REAL(wp)                        ::   freqh        ! frequency of each flux file
       CHARACTER(len = 34)             ::   clvar        ! generic name of the variable in the NetCDF flux file
       LOGICAL                         ::   ln_tint      ! time interpolation or not (T/F)
@@ -80,12 +80,12 @@
       INTEGER                         ::   nreclast     ! last record to be read in the current file
       CHARACTER(len = 256)            ::   lsmname      ! current name of the NetCDF mask file acting as a key
-      INTEGER                         ::   igrd         ! grid type for bdy data
-      INTEGER                         ::   ibdy         ! bdy set id number
+      !                                                 ! 
+      !                                                 ! Variables related to BDY
+      INTEGER                         ::   igrd         !   grid type for bdy data
+      INTEGER                         ::   ibdy         !   bdy set id number
+      INTEGER, POINTER, DIMENSION(:)  ::   imap         !   Array of integer pointers to 1D arrays
+      LOGICAL                         ::   ltotvel      !   total velocity or not (T/F)
+      LOGICAL                         ::   lzint        !   T if it requires a vertical interpolation
    END TYPE FLD
-
-   TYPE, PUBLIC ::   MAP_POINTER      !: Map from input data file to local domain
-      INTEGER, POINTER, DIMENSION(:)  ::  ptr           ! Array of integer pointers to 1D arrays
-      LOGICAL                         ::  ll_unstruc    ! Unstructured (T) or structured (F) boundary data file
-   END TYPE MAP_POINTER
 
 !$AGRIF_DO_NOT_TREAT
@@ -129,5 +129,5 @@
 CONTAINS
 
-   SUBROUTINE fld_read( kt, kn_fsbc, sd, map, kit, kt_offset, jpk_bdy, fvl )
+   SUBROUTINE fld_read( kt, kn_fsbc, sd, kit, kt_offset )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_read  ***
@@ -144,5 +144,4 @@
       INTEGER  , INTENT(in   )               ::   kn_fsbc   ! sbc computation period (in time step) 
       TYPE(FLD), INTENT(inout), DIMENSION(:) ::   sd        ! input field related variables
-      TYPE(MAP_POINTER),INTENT(in), OPTIONAL, DIMENSION(:) ::   map   ! global-to-local mapping indices
       INTEGER  , INTENT(in   ), OPTIONAL     ::   kit       ! subcycle timestep for timesplitting option
       INTEGER  , INTENT(in   ), OPTIONAL     ::   kt_offset ! provide fields at time other than "now"
@@ -150,6 +149,4 @@
       !                                                     !   kt_offset = +1 => fields at "after"  time level
       !                                                     !   etc.
-      INTEGER  , INTENT(in   ), OPTIONAL     ::   jpk_bdy   ! number of vertical levels in the BDY data
-      LOGICAL  , INTENT(in   ), OPTIONAL     ::   fvl   ! number of vertical levels in the BDY data
       !!
       INTEGER  ::   itmp         ! local variable
@@ -166,5 +163,4 @@
       REAL(wp) ::   ztintb       ! ratio applied to before records when doing time interpolation
       CHARACTER(LEN=1000) ::   clfmt  ! write format
-      TYPE(MAP_POINTER)   ::   imap   ! global-to-local mapping indices
       !!---------------------------------------------------------------------
       ll_firstcall = kt == nit000
@@ -175,6 +171,4 @@
       ENDIF
       IF( PRESENT(kt_offset) )   it_offset = kt_offset
-
-      imap%ptr => NULL()
 
       ! Note that shifting time to be centrered in the middle of sbc time step impacts only nsec_* variables of the calendar 
@@ -188,10 +182,6 @@
       IF( ll_firstcall ) THEN                      ! initialization
          DO jf = 1, imf 
-            IF( PRESENT(map) ) imap = map(jf)
-               IF( PRESENT(jpk_bdy) ) THEN
-                  CALL fld_init( kn_fsbc, sd(jf), imap, jpk_bdy, fvl )  ! read each before field (put them in after as they will be swapped)
-               ELSE
-                  CALL fld_init( kn_fsbc, sd(jf), imap )  ! read each before field (put them in after as they will be swapped)
-               ENDIF
+            IF( TRIM(sd(jf)%clrootname) == 'NOT USED' )   CYCLE
+            CALL fld_init( kn_fsbc, sd(jf) )       ! read each before field (put them in after as they will be swapped)
          END DO
          IF( lwp ) CALL wgt_print()                ! control print
@@ -202,8 +192,8 @@
          !
          DO jf = 1, imf                            ! ---   loop over field   --- !
-            
+
+            IF( TRIM(sd(jf)%clrootname) == 'NOT USED' )   CYCLE
+                      
             IF( isecsbc > sd(jf)%nrec_a(2) .OR. ll_firstcall ) THEN    ! read/update the after data?
-
-               IF( PRESENT(map) )   imap = map(jf)   ! temporary definition of map
 
                sd(jf)%nrec_b(:) = sd(jf)%nrec_a(:)                                  ! swap before record informations
@@ -213,5 +203,5 @@
                CALL fld_rec( kn_fsbc, sd(jf), kt_offset = it_offset, kit = kit )    ! update after record informations
 
-               ! if kn_fsbc*rdt is larger than nfreqh (which is kind of odd),
+               ! if kn_fsbc*rdt is larger than freqh (which is kind of odd),
                ! it is possible that the before value is no more the good one... we have to re-read it
                ! if before is not the last record of the file currently opened and after is the first record to be read
@@ -222,8 +212,8 @@
                   itmp = sd(jf)%nrec_a(1)                       ! temporary storage
                   sd(jf)%nrec_a(1) = sd(jf)%nreclast            ! read the last record of the file currently opened
-                  CALL fld_get( sd(jf), imap )                  ! read after data
+                  CALL fld_get( sd(jf) )                        ! read after data
                   sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2)   ! re-swap before record field
                   sd(jf)%nrec_b(1) = sd(jf)%nrec_a(1)           ! update before record informations
-                  sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%nfreqh * 3600 )  ! assume freq to be in hours in this case
+                  sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%freqh * 3600. )  ! assume freq to be in hours in this case
                   sd(jf)%rotn(1)   = sd(jf)%rotn(2)             ! update before rotate informations
                   sd(jf)%nrec_a(1) = itmp                       ! move back to after record 
@@ -234,5 +224,5 @@
                IF( sd(jf)%ln_tint ) THEN
                   
-                  ! if kn_fsbc*rdt is larger than nfreqh (which is kind of odd),
+                  ! if kn_fsbc*rdt is larger than freqh (which is kind of odd),
                   ! it is possible that the before value is no more the good one... we have to re-read it
                   ! if before record is not just just before the after record...
@@ -240,8 +230,8 @@
                      &                   .AND. sd(jf)%nrec_b(1) /= sd(jf)%nrec_a(1) - 1 ) THEN   
                      sd(jf)%nrec_a(1) = sd(jf)%nrec_a(1) - 1       ! move back to before record
-                     CALL fld_get( sd(jf), imap )                  ! read after data
+                     CALL fld_get( sd(jf) )                        ! read after data
                      sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2)   ! re-swap before record field
                      sd(jf)%nrec_b(1) = sd(jf)%nrec_a(1)           ! update before record informations
-                     sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%nfreqh * 3600 )  ! assume freq to be in hours in this case
+                     sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%freqh * 3600. )  ! assume freq to be in hours in this case
                      sd(jf)%rotn(1)   = sd(jf)%rotn(2)             ! update before rotate informations
                      sd(jf)%nrec_a(1) = sd(jf)%nrec_a(1) + 1       ! move back to after record
@@ -268,5 +258,5 @@
                      ! year/month/week/day, next year/month/week/day file must exist
                      isecend = nsec_year + nsec1jan000 + (nitend - kt) * NINT(rdt)   ! second at the end of the run
-                     llstop = isecend > sd(jf)%nrec_a(2)                                   ! read more than 1 record of next year
+                     llstop = isecend > sd(jf)%nrec_a(2)                             ! read more than 1 record of next year
                      ! we suppose that the date of next file is next day (should be ok even for weekly files...)
                      CALL fld_clopn( sd(jf), nyear  + COUNT((/llnxtyr /))                                           ,         &
@@ -277,5 +267,5 @@
                         CALL ctl_warn('next year/month/week/day file: '//TRIM(sd(jf)%clname)//     &
                            &     ' not present -> back to current year/month/day')
-                        CALL fld_clopn( sd(jf) )       ! back to the current year/month/day
+                        CALL fld_clopn( sd(jf) )               ! back to the current year/month/day
                         sd(jf)%nrec_a(1) = sd(jf)%nreclast     ! force to read the last record in the current year file
                      ENDIF
@@ -285,9 +275,6 @@
                   
                ! read after data
-               IF( PRESENT(jpk_bdy) ) THEN
-                  CALL fld_get( sd(jf), imap, jpk_bdy, fvl)
-               ELSE
-                  CALL fld_get( sd(jf), imap )
-               ENDIF
+               CALL fld_get( sd(jf) )
+               
             ENDIF   ! read new data?
          END DO                                    ! --- end loop over field --- !
@@ -296,4 +283,6 @@
 
          DO jf = 1, imf                            ! ---   loop over field   --- !
+            !
+            IF( TRIM(sd(jf)%clrootname) == 'NOT USED' )   CYCLE
             !
             IF( sd(jf)%ln_tint ) THEN              ! temporal interpolation
@@ -327,5 +316,5 @@
 
 
-   SUBROUTINE fld_init( kn_fsbc, sdjf, map , jpk_bdy, fvl)
+   SUBROUTINE fld_init( kn_fsbc, sdjf )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_init  ***
@@ -336,7 +325,4 @@
       INTEGER  , INTENT(in   ) ::   kn_fsbc      ! sbc computation period (in time step) 
       TYPE(FLD), INTENT(inout) ::   sdjf         ! input field related variables
-      TYPE(MAP_POINTER),INTENT(in) ::   map      ! global-to-local mapping indices
-      INTEGER  , INTENT(in), OPTIONAL :: jpk_bdy ! number of vertical levels in the BDY data
-      LOGICAL  , INTENT(in), OPTIONAL :: fvl     ! number of vertical levels in the BDY data
       !!
       LOGICAL :: llprevyr              ! are we reading previous year  file?
@@ -351,4 +337,5 @@
       CHARACTER(LEN=1000) ::   clfmt   ! write format
       !!---------------------------------------------------------------------
+      !
       llprevyr   = .FALSE.
       llprevmth  = .FALSE.
@@ -365,5 +352,5 @@
          !
          IF( sdjf%nrec_a(1) == 0  ) THEN   ! we redefine record sdjf%nrec_a(1) with the last record of previous year file
-            IF    ( sdjf%nfreqh == -12 ) THEN   ! yearly mean
+            IF    ( NINT(sdjf%freqh) == -12 ) THEN   ! yearly mean
                IF( sdjf%cltype == 'yearly' ) THEN             ! yearly file
                   sdjf%nrec_a(1) = 1                                                       ! force to read the unique record
@@ -372,5 +359,5 @@
                   CALL ctl_stop( "fld_init: yearly mean file must be in a yearly type of file: "//TRIM(sdjf%clrootname) )
                ENDIF
-            ELSEIF( sdjf%nfreqh ==  -1 ) THEN   ! monthly mean
+            ELSEIF( NINT(sdjf%freqh) ==  -1 ) THEN   ! monthly mean
                IF( sdjf%cltype == 'monthly' ) THEN            ! monthly file
                   sdjf%nrec_a(1) = 1                                                       ! force to read the unique record
@@ -381,20 +368,20 @@
                   llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file?
                ENDIF
-            ELSE                                ! higher frequency mean (in hours) 
+            ELSE                                     ! higher frequency mean (in hours) 
                IF    ( sdjf%cltype      == 'monthly' ) THEN   ! monthly file
-                  sdjf%nrec_a(1) = NINT( 24 * nmonth_len(nmonth-1) / sdjf%nfreqh )         ! last record of previous month
+                  sdjf%nrec_a(1) = NINT( 24. * REAL(nmonth_len(nmonth-1),wp) / sdjf%freqh )! last record of previous month
                   llprevmth = .TRUE.                                                       ! use previous month file?
                   llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file?
                ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ! weekly file
                   llprevweek = .TRUE.                                                      ! use previous week  file?
-                  sdjf%nrec_a(1) = NINT( 24 * 7 / sdjf%nfreqh )                            ! last record of previous week
+                  sdjf%nrec_a(1) = NINT( 24. * 7. / sdjf%freqh )                           ! last record of previous week
                   isec_week = NINT(rday) * 7                                               ! add a shift toward previous week
                ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ! daily file
-                  sdjf%nrec_a(1) = NINT( 24 / sdjf%nfreqh )                                ! last record of previous day
+                  sdjf%nrec_a(1) = NINT( 24. / sdjf%freqh )                                ! last record of previous day
                   llprevday = .TRUE.                                                       ! use previous day   file?
                   llprevmth = llprevday .AND. nday   == 1                                  ! use previous month file?
                   llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file?
                ELSE                                           ! yearly file
-                  sdjf%nrec_a(1) = NINT( 24 * nyear_len(0) / sdjf%nfreqh )                 ! last record of previous year 
+                  sdjf%nrec_a(1) = NINT( 24. * REAL(nyear_len(0),wp) / sdjf%freqh )        ! last record of previous year 
                   llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file?
                ENDIF
@@ -433,9 +420,5 @@
          !
          ! read before data in after arrays(as we will swap it later)
-         IF( PRESENT(jpk_bdy) ) THEN
-            CALL fld_get( sdjf, map, jpk_bdy, fvl )
-         ELSE
-            CALL fld_get( sdjf, map )
-         ENDIF
+         CALL fld_get( sdjf )
          !
          clfmt = "('   fld_init : time-interpolation for ', a, ' read previous record = ', i6, ' at time = ', f7.2, ' days')"
@@ -456,5 +439,5 @@
       !!              if sdjf%ln_tint = .FALSE.
       !!                  nrec_a(1): record number
-      !!                  nrec_b(2) and nrec_a(2): time of the beginning and end of the record (for print only)
+      !!                  nrec_b(2) and nrec_a(2): time of the beginning and end of the record
       !!----------------------------------------------------------------------
       INTEGER  , INTENT(in   )           ::   kn_fsbc   ! sbc computation period (in time step) 
@@ -484,14 +467,14 @@
       ELSE                                      ;   it_offset = 0
       ENDIF
-      IF( PRESENT(kt_offset) )   it_offset = kt_offset
+      IF( PRESENT(kt_offset) )      it_offset = kt_offset
       IF( PRESENT(kit) ) THEN   ;   it_offset = ( kit + it_offset ) * NINT( rdt/REAL(nn_baro,wp) )
       ELSE                      ;   it_offset =         it_offset   * NINT(       rdt            )
       ENDIF
       !
-      !                                      ! =========== !
-      IF    ( sdjf%nfreqh == -12 ) THEN      ! yearly mean
-         !                                   ! =========== !
-         !
-         IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record
+      !                                           ! =========== !
+      IF    ( NINT(sdjf%freqh) == -12 ) THEN      ! yearly mean
+         !                                        ! =========== !
+         !
+         IF( sdjf%ln_tint ) THEN                  ! time interpolation, shift by 1/2 record
             !
             !                  INT( ztmp )
@@ -505,6 +488,6 @@
             !       forcing record :    1 
             !                            
-            ztmp = REAL( nsec_year, wp ) / ( REAL( nyear_len(1), wp ) * rday ) + 0.5 &
-           &       + REAL( it_offset, wp ) / ( REAL( nyear_len(1), wp ) * rday )
+            ztmp =  REAL( nsec_year, wp ) / ( REAL( nyear_len(1), wp ) * rday ) + 0.5 &
+               &  + REAL( it_offset, wp ) / ( REAL( nyear_len(1), wp ) * rday )
             sdjf%nrec_a(1) = 1 + INT( ztmp ) - COUNT((/llbefore/))
             ! swap at the middle of the year
@@ -514,5 +497,5 @@
                                     & INT(ztmp) * INT(rday) * nyear_len(1) + INT(ztmp) * NINT( 0.5 * rday) * nyear_len(2) 
             ENDIF
-         ELSE                                    ! no time interpolation
+         ELSE                                     ! no time interpolation
             sdjf%nrec_a(1) = 1
             sdjf%nrec_a(2) = NINT(rday) * nyear_len(1) + nsec1jan000   ! swap at the end    of the year
@@ -520,9 +503,9 @@
          ENDIF
          !
-         !                                   ! ============ !
-      ELSEIF( sdjf%nfreqh ==  -1 ) THEN      ! monthly mean !
-         !                                   ! ============ !
-         !
-         IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record
+         !                                        ! ============ !
+      ELSEIF( NINT(sdjf%freqh) ==  -1 ) THEN      ! monthly mean !
+         !                                        ! ============ !
+         !
+         IF( sdjf%ln_tint ) THEN                  ! time interpolation, shift by 1/2 record
             !
             !                  INT( ztmp )
@@ -536,6 +519,6 @@
             !       forcing record :  nmonth 
             !                            
-            ztmp = REAL( nsec_month, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday ) + 0.5 &
-           &       + REAL( it_offset, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday )
+            ztmp =  REAL( nsec_month, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday ) + 0.5 &
+           &      + REAL(  it_offset, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday )
             imth = nmonth + INT( ztmp ) - COUNT((/llbefore/))
             IF( sdjf%cltype == 'monthly' ) THEN   ;   sdjf%nrec_a(1) = 1 + INT( ztmp ) - COUNT((/llbefore/))
@@ -551,9 +534,9 @@
          ENDIF
          !
-         !                                   ! ================================ !
-      ELSE                                   ! higher frequency mean (in hours)
-         !                                   ! ================================ !
-         !
-         ifreq_sec = NINT( sdjf%nfreqh * 3600 )                                         ! frequency mean (in seconds)
+         !                                        ! ================================ !
+      ELSE                                        ! higher frequency mean (in hours)
+         !                                        ! ================================ !
+         !
+         ifreq_sec = NINT( sdjf%freqh * 3600. )                                         ! frequency mean (in seconds)
          IF( sdjf%cltype(1:4) == 'week' )   isec_week = ksec_week( sdjf%cltype(6:8) )   ! since the first day of the current week
          ! number of second since the beginning of the file
@@ -565,5 +548,5 @@
          ztmp = ztmp + 0.5 * REAL(kn_fsbc - 1, wp) * rdt + REAL( it_offset, wp )        ! centrered in the middle of sbc time step
          ztmp = ztmp + 0.01 * rdt                                                       ! avoid truncation error 
-         IF( sdjf%ln_tint ) THEN                ! time interpolation, shift by 1/2 record
+         IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record
             !
             !          INT( ztmp/ifreq_sec + 0.5 )
@@ -579,5 +562,5 @@
             !                   
             ztmp= ztmp / REAL(ifreq_sec, wp) + 0.5
-         ELSE                                   ! no time interpolation
+         ELSE                                    ! no time interpolation
             !
             !           INT( ztmp/ifreq_sec )
@@ -610,8 +593,10 @@
       ENDIF
       !
+      IF( .NOT. sdjf%ln_tint ) sdjf%nrec_a(2) = sdjf%nrec_a(2) - 1   ! last second belongs to bext record : *----(
+      !
    END SUBROUTINE fld_rec
 
 
-   SUBROUTINE fld_get( sdjf, map, jpk_bdy, fvl )
+   SUBROUTINE fld_get( sdjf )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_get  ***
@@ -620,7 +605,4 @@
       !!----------------------------------------------------------------------
       TYPE(FLD)        , INTENT(inout) ::   sdjf   ! input field related variables
-      TYPE(MAP_POINTER), INTENT(in   ) ::   map    ! global-to-local mapping indices
-      INTEGER  , INTENT(in), OPTIONAL  ::   jpk_bdy ! number of vertical levels in the bdy data
-      LOGICAL  , INTENT(in), OPTIONAL  ::   fvl     ! number of vertical levels in the bdy data
       !
       INTEGER ::   ipk      ! number of vertical levels of sdjf%fdta ( 2D: ipk=1 ; 3D: ipk=jpk )
@@ -634,16 +616,10 @@
       ipk = SIZE( sdjf%fnow, 3 )
       !
-      IF( ASSOCIATED(map%ptr) ) THEN
-         IF( PRESENT(jpk_bdy) ) THEN
-            IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2),                &
-                                                        sdjf%nrec_a(1), map, sdjf%igrd, sdjf%ibdy, jpk_bdy, fvl )
-            ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ),                &
-                                                        sdjf%nrec_a(1), map, sdjf%igrd, sdjf%ibdy, jpk_bdy, fvl )
-            ENDIF
-         ELSE
-            IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1), map )
-            ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1), map )
-            ENDIF
-         ENDIF        
+      IF( ASSOCIATED(sdjf%imap) ) THEN
+         IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1),   &
+            &                                        sdjf%imap, sdjf%igrd, sdjf%ibdy, sdjf%ltotvel, sdjf%lzint )
+         ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1),   &
+            &                                        sdjf%imap, sdjf%igrd, sdjf%ibdy, sdjf%ltotvel, sdjf%lzint )
+         ENDIF
       ELSE IF( LEN(TRIM(sdjf%wgtname)) > 0 ) THEN
          CALL wgt_list( sdjf, iw )
@@ -700,5 +676,6 @@
    END SUBROUTINE fld_get
 
-   SUBROUTINE fld_map( num, clvar, dta, nrec, map, igrd, ibdy, jpk_bdy, fvl )
+   
+   SUBROUTINE fld_map( knum, cdvar, pdta, krec, kmap, kgrd, kbdy, ldtotvel, ldzint )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_map  ***
@@ -707,136 +684,144 @@
       !!                using a general mapping (for open boundaries)
       !!----------------------------------------------------------------------
-
-      USE bdy_oce, ONLY: ln_bdy, idx_bdy, dta_global, dta_global_z, dta_global_dz, dta_global2, dta_global2_z, dta_global2_dz                 ! workspace to read in global data arrays
-
-      INTEGER                   , INTENT(in ) ::   num     ! stream number
-      CHARACTER(LEN=*)          , INTENT(in ) ::   clvar   ! variable name
-      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   dta     ! output field on model grid (2 dimensional)
-      INTEGER                   , INTENT(in ) ::   nrec    ! record number to read (ie time slice)
-      TYPE(MAP_POINTER)         , INTENT(in ) ::   map     ! global-to-local mapping indices
-      INTEGER  , INTENT(in), OPTIONAL         ::   igrd, ibdy, jpk_bdy  ! grid type, set number and number of vertical levels in the bdy data
-      LOGICAL  , INTENT(in), OPTIONAL         ::   fvl     ! grid type, set number and number of vertical levels in the bdy data
-      INTEGER                                 ::   jpkm1_bdy! number of vertical levels in the bdy data minus 1
-      !!
-      INTEGER                                 ::   ipi      ! length of boundary data on local process
-      INTEGER                                 ::   ipj      ! length of dummy dimension ( = 1 )
-      INTEGER                                 ::   ipk      ! number of vertical levels of dta ( 2D: ipk=1 ; 3D: ipk=jpk )
-      INTEGER                                 ::   ilendta  ! length of data in file
-      INTEGER                                 ::   idvar    ! variable ID
-      INTEGER                                 ::   ib, ik, ji, jj   ! loop counters
-      INTEGER                                 ::   ierr
-      REAL(wp)                                ::   fv          ! fillvalue 
-      REAL(wp), POINTER, DIMENSION(:,:,:)     ::   dta_read    ! work space for global data
-      REAL(wp), POINTER, DIMENSION(:,:,:)     ::   dta_read_z  ! work space for global data
-      REAL(wp), POINTER, DIMENSION(:,:,:)     ::   dta_read_dz ! work space for global data
-      !!---------------------------------------------------------------------
-      !
-      ipi = SIZE( dta, 1 )
-      ipj = 1
-      ipk = SIZE( dta, 3 )
-      !
-      idvar   = iom_varid( num, clvar )
-      ilendta = iom_file(num)%dimsz(1,idvar)
-
-      IF ( ln_bdy ) THEN
-         ipj = iom_file(num)%dimsz(2,idvar)
-         IF( map%ll_unstruc) THEN   ! unstructured open boundary data file
-            dta_read => dta_global
-            IF( PRESENT(jpk_bdy) ) THEN
-               IF( jpk_bdy>0 ) THEN
-                  dta_read_z => dta_global_z
-                  dta_read_dz => dta_global_dz
-                  jpkm1_bdy = jpk_bdy-1
-               ENDIF
-            ENDIF
-         ELSE                       ! structured open boundary file
-            dta_read => dta_global2
-            IF( PRESENT(jpk_bdy) ) THEN
-               IF( jpk_bdy>0 ) THEN
-                  dta_read_z => dta_global2_z
-                  dta_read_dz => dta_global2_dz
-                  jpkm1_bdy = jpk_bdy-1
-               ENDIF
-            ENDIF
-         ENDIF
-      ENDIF
-
-      IF(lwp) WRITE(numout,*) 'Dim size for ',        TRIM(clvar),' is ', ilendta
-      IF(lwp) WRITE(numout,*) 'Number of levels for ',TRIM(clvar),' is ', ipk
-      !
-      SELECT CASE( ipk )
-      CASE(1)        ;   
-      CALL iom_get ( num, jpdom_unknown, clvar, dta_read(1:ilendta,1:ipj,1    ), nrec )
-         IF ( map%ll_unstruc) THEN ! unstructured open boundary data file
-            DO ib = 1, ipi
-              DO ik = 1, ipk
-                dta(ib,1,ik) =  dta_read(map%ptr(ib),1,ik)
-              END DO
-            END DO
-         ELSE ! we assume that this is a structured open boundary file
-            DO ib = 1, ipi
-               jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-               ji=map%ptr(ib)-(jj-1)*ilendta
-               DO ik = 1, ipk
-                  dta(ib,1,ik) =  dta_read(ji,jj,ik)
-               END DO
-            END DO
-         ENDIF
+      INTEGER                   , INTENT(in   ) ::   knum         ! stream number
+      CHARACTER(LEN=*)          , INTENT(in   ) ::   cdvar        ! variable name
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdta         ! bdy output field on model grid
+      INTEGER                   , INTENT(in   ) ::   krec         ! record number to read (ie time slice)
+      INTEGER , DIMENSION(:)    , INTENT(in   ) ::   kmap         ! global-to-local bdy mapping indices
+      ! optional variables used for vertical interpolation:
+      INTEGER, OPTIONAL         , INTENT(in   ) ::   kgrd         ! grid type (t, u, v)
+      INTEGER, OPTIONAL         , INTENT(in   ) ::   kbdy         ! bdy number
+      LOGICAL, OPTIONAL         , INTENT(in   ) ::   ldtotvel     ! true if total ( = barotrop + barocline) velocity
+      LOGICAL, OPTIONAL         , INTENT(in   ) ::   ldzint       ! true if 3D variable requires a vertical interpolation
+      !!
+      INTEGER                                   ::   ipi          ! length of boundary data on local process
+      INTEGER                                   ::   ipj          ! length of dummy dimension ( = 1 )
+      INTEGER                                   ::   ipk          ! number of vertical levels of pdta ( 2D: ipk=1 ; 3D: ipk=jpk )
+      INTEGER                                   ::   ipkb         ! number of vertical levels in boundary data file
+      INTEGER                                   ::   idvar        ! variable ID
+      INTEGER                                   ::   indims       ! number of dimensions of the variable
+      INTEGER, DIMENSION(4)                     ::   idimsz       ! size of variable dimensions 
+      REAL(wp)                                  ::   zfv          ! fillvalue 
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   zz_read      ! work space for global boundary data
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   zdta_read    ! work space local data requiring vertical interpolation
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   zdta_read_z  ! work space local data requiring vertical interpolation
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   zdta_read_dz ! work space local data requiring vertical interpolation
+      CHARACTER(LEN=1),DIMENSION(3)             ::   clgrid
+      LOGICAL                                   ::   lluld        ! is the variable using the unlimited dimension
+      LOGICAL                                   ::   llzint       ! local value of ldzint
+      !!---------------------------------------------------------------------
+      !
+      clgrid = (/'t','u','v'/)
+      !
+      ipi = SIZE( pdta, 1 )
+      ipj = SIZE( pdta, 2 )   ! must be equal to 1
+      ipk = SIZE( pdta, 3 )
+      !
+      llzint = .FALSE.
+      IF( PRESENT(ldzint) )   llzint = ldzint
+      !
+      idvar = iom_varid( knum, cdvar, kndims = indims, kdimsz = idimsz, lduld = lluld  )
+      IF( indims == 4 .OR. ( indims == 3 .AND. .NOT. lluld ) ) THEN   ;   ipkb = idimsz(3)   ! xy(zl)t or xy(zl)
+      ELSE                                                            ;   ipkb = 1           ! xy or xyt
+      ENDIF
+      !
+      ALLOCATE( zz_read( idimsz(1), idimsz(2), ipkb ) )  ! ++++++++ !!! this can be very big...         
+      !
+      IF( ipk == 1 ) THEN
+
+         IF( ipkb /= 1 ) CALL ctl_stop( 'fld_map : we must have ipkb = 1 to read surface data' )
+         CALL iom_get ( knum, jpdom_unknown, cdvar, zz_read(:,:,1), krec )   ! call iom_get with a 2D file
+         CALL fld_map_core( zz_read, kmap, pdta )
 
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       ! Do we include something here to adjust barotropic velocities !
       ! in case of a depth difference between bdy files and          !
-      ! bathymetry in the case ln_full_vel = .false. and jpk_bdy>0?  !
+      ! bathymetry in the case ln_totvel = .false. and ipkb>0?       !
       ! [as the enveloping and parital cells could change H]         !
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-      CASE DEFAULT   ;
-
-      IF( PRESENT(jpk_bdy) .AND. jpk_bdy>0 ) THEN       ! boundary data not on model grid: vertical interpolation
-         CALL iom_getatt(num, '_FillValue', fv, cdvar=clvar )
-         dta_read(:,:,:) = -ABS(fv)
-         dta_read_z(:,:,:) = 0._wp
-         dta_read_dz(:,:,:) = 0._wp
-         CALL iom_get ( num, jpdom_unknown, clvar, dta_read(1:ilendta,1:ipj,1:jpk_bdy), nrec )
-         SELECT CASE( igrd )                  
-            CASE(1)
-               CALL iom_get ( num, jpdom_unknown, 'gdept', dta_read_z(1:ilendta,1:ipj,1:jpk_bdy) )
-               CALL iom_get ( num, jpdom_unknown, 'e3t',  dta_read_dz(1:ilendta,1:ipj,1:jpk_bdy) )
-            CASE(2)  
-               CALL iom_get ( num, jpdom_unknown, 'gdepu', dta_read_z(1:ilendta,1:ipj,1:jpk_bdy) )
-               CALL iom_get ( num, jpdom_unknown, 'e3u',  dta_read_dz(1:ilendta,1:ipj,1:jpk_bdy) )
-            CASE(3)
-               CALL iom_get ( num, jpdom_unknown, 'gdepv', dta_read_z(1:ilendta,1:ipj,1:jpk_bdy) )
-               CALL iom_get ( num, jpdom_unknown, 'e3v',  dta_read_dz(1:ilendta,1:ipj,1:jpk_bdy) )
-         END SELECT
-
-      IF ( ln_bdy ) & 
-         CALL fld_bdy_interp(dta_read, dta_read_z, dta_read_dz, map, jpk_bdy, igrd, ibdy, fv, dta, fvl, ilendta)
-
-      ELSE ! boundary data assumed to be on model grid
-         
-         CALL iom_get ( num, jpdom_unknown, clvar, dta_read(1:ilendta,1:ipj,1:ipk), nrec )                    
-         IF ( map%ll_unstruc) THEN ! unstructured open boundary data file
-            DO ib = 1, ipi
-              DO ik = 1, ipk
-                dta(ib,1,ik) =  dta_read(map%ptr(ib),1,ik)
-              END DO
+      ELSE
+         !
+         CALL iom_get ( knum, jpdom_unknown, cdvar, zz_read(:,:,:), krec )   ! call iom_get with a 3D file
+         !
+         IF( ipkb /= ipk .OR. llzint ) THEN   ! boundary data not on model vertical grid : vertical interpolation
+            !
+            IF( ipk == jpk .AND. iom_varid(knum,'gdep'//clgrid(kgrd)) /= -1 .AND. iom_varid(knum,'e3'//clgrid(kgrd)) /= -1 ) THEN
+               
+               ALLOCATE( zdta_read(ipi,ipj,ipkb), zdta_read_z(ipi,ipj,ipkb), zdta_read_dz(ipi,ipj,ipkb) )
+                
+               CALL fld_map_core( zz_read, kmap, zdta_read )
+               CALL iom_get ( knum, jpdom_unknown, 'gdep'//clgrid(kgrd), zz_read )   ! read only once? Potential temporal evolution?
+               CALL fld_map_core( zz_read, kmap, zdta_read_z )
+               CALL iom_get ( knum, jpdom_unknown,   'e3'//clgrid(kgrd), zz_read )   ! read only once? Potential temporal evolution?
+               CALL fld_map_core( zz_read, kmap, zdta_read_dz )
+               
+               CALL iom_getatt(knum, '_FillValue', zfv, cdvar=cdvar )
+               CALL fld_bdy_interp(zdta_read, zdta_read_z, zdta_read_dz, pdta, kgrd, kbdy, zfv, ldtotvel)
+               DEALLOCATE( zdta_read, zdta_read_z, zdta_read_dz )
+               
+            ELSE
+               IF( ipk /= jpk ) CALL ctl_stop( 'fld_map : this should be an impossible case...' )
+               WRITE(ctmp1,*) 'fld_map : vertical interpolation for bdy variable '//TRIM(cdvar)//' requires ' 
+               IF( iom_varid(knum, 'gdep'//clgrid(kgrd)) == -1 ) CALL ctl_stop( ctmp1//'gdep'//clgrid(kgrd)//' variable' )
+               IF( iom_varid(knum,   'e3'//clgrid(kgrd)) == -1 ) CALL ctl_stop( ctmp1//  'e3'//clgrid(kgrd)//' variable' )
+
+            ENDIF
+            !
+         ELSE                            ! bdy data assumed to be the same levels as bdy variables
+            !
+            CALL fld_map_core( zz_read, kmap, pdta )
+            !
+         ENDIF   ! ipkb /= ipk
+      ENDIF   ! ipk == 1
+      
+      DEALLOCATE( zz_read )
+
+   END SUBROUTINE fld_map
+
+     
+   SUBROUTINE fld_map_core( pdta_read, kmap, pdta_bdy )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_map_core  ***
+      !!
+      !! ** Purpose :  inner core of fld_map
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdta_read    ! global boundary data
+      INTEGER,  DIMENSION(:    ), INTENT(in   ) ::   kmap         ! global-to-local bdy mapping indices
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdta_bdy     ! bdy output field on model grid
+      !!
+      INTEGER,  DIMENSION(3) ::   idim_read,  idim_bdy            ! arrays dimensions
+      INTEGER                ::   ji, jj, jk, jb                  ! loop counters
+      INTEGER                ::   im1
+      !!---------------------------------------------------------------------
+      !
+      idim_read = SHAPE( pdta_read )
+      idim_bdy  = SHAPE( pdta_bdy  )
+      !
+      ! in all cases: idim_bdy(2) == 1 .AND. idim_read(1) * idim_read(2) == idim_bdy(1)
+      ! structured BDY with rimwidth > 1                     : idim_read(2) == rimwidth /= 1
+      ! structured BDY with rimwidth == 1 or unstructured BDY: idim_read(2) == 1
+      !
+      IF( idim_read(2) > 1 ) THEN    ! structured BDY with rimwidth > 1  
+         DO jk = 1, idim_bdy(3)
+            DO jb = 1, idim_bdy(1)
+               im1 = kmap(jb) - 1
+               jj = im1 / idim_read(1) + 1
+               ji = MOD( im1, idim_read(1) ) + 1
+               pdta_bdy(jb,1,jk) =  pdta_read(ji,jj,jk)
             END DO
-         ELSE ! we assume that this is a structured open boundary file
-            DO ib = 1, ipi
-               jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-               ji=map%ptr(ib)-(jj-1)*ilendta
-               DO ik = 1, ipk
-                  dta(ib,1,ik) =  dta_read(ji,jj,ik)
-               END DO
+         END DO
+      ELSE
+         DO jk = 1, idim_bdy(3)
+            DO jb = 1, idim_bdy(1)   ! horizontal remap of bdy data on the local bdy 
+               pdta_bdy(jb,1,jk) = pdta_read(kmap(jb),1,jk)
             END DO
-         ENDIF
-      ENDIF ! PRESENT(jpk_bdy)
-      END SELECT
-
-   END SUBROUTINE fld_map
+         END DO
+      ENDIF
+      
+   END SUBROUTINE fld_map_core
    
-   SUBROUTINE fld_bdy_interp(dta_read, dta_read_z, dta_read_dz, map, jpk_bdy, igrd, ibdy, fv, dta, fvl, ilendta)
-
+   
+   SUBROUTINE fld_bdy_interp(pdta_read, pdta_read_z, pdta_read_dz, pdta, kgrd, kbdy, pfv, ldtotvel)
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_bdy_interp  ***
@@ -847,284 +832,159 @@
       USE bdy_oce, ONLY:  idx_bdy         ! indexing for map <-> ij transformation
 
-      REAL(wp), POINTER, DIMENSION(:,:,:), INTENT(in )     ::   dta_read      ! work space for global data
-      REAL(wp), POINTER, DIMENSION(:,:,:), INTENT(in )     ::   dta_read_z    ! work space for global data
-      REAL(wp), POINTER, DIMENSION(:,:,:), INTENT(in )     ::   dta_read_dz   ! work space for global data
-      REAL(wp) , INTENT(in)                                ::   fv            ! fillvalue and alternative -ABS(fv)
-      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   dta                        ! output field on model grid (2 dimensional)
-      TYPE(MAP_POINTER)         , INTENT(in ) ::   map                        ! global-to-local mapping indices
-      LOGICAL  , INTENT(in), OPTIONAL         ::   fvl                        ! grid type, set number and number of vertical levels in the bdy data
-      INTEGER  , INTENT(in)                   ::   igrd, ibdy, jpk_bdy        ! number of levels in bdy data
-      INTEGER  , INTENT(in)                   ::   ilendta                    ! length of data in file
-      !!
-      INTEGER                                 ::   ipi                        ! length of boundary data on local process
-      INTEGER                                 ::   ipj                        ! length of dummy dimension ( = 1 )
-      INTEGER                                 ::   ipk                        ! number of vertical levels of dta ( 2D: ipk=1 ; 3D: ipk=jpk )
-      INTEGER                                 ::   jpkm1_bdy                  ! number of levels in bdy data minus 1
-      INTEGER                                 ::   ib, ik, ikk                ! loop counters
-      INTEGER                                 ::   ji, jj, zij, zjj           ! temporary indices
-      REAL(wp)                                ::   zl, zi, zh                 ! tmp variable for current depth and interpolation factor
-      REAL(wp)                                ::   fv_alt, ztrans, ztrans_new ! fillvalue and alternative -ABS(fv)
-      CHARACTER (LEN=10)                      ::   ibstr
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdta_read       ! data read in bdy file
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pdta_read_z     ! depth of the data read in bdy file
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pdta_read_dz    ! thickness of the levels in bdy file
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdta            ! output field on model grid (2 dimensional)
+      REAL(wp)                  , INTENT(in   ) ::   pfv             ! fillvalue of the data read in bdy file
+      LOGICAL                   , INTENT(in   ) ::   ldtotvel        ! true if toal ( = barotrop + barocline) velocity
+      INTEGER                   , INTENT(in   ) ::   kgrd            ! grid type (t, u, v)
+      INTEGER                   , INTENT(in   ) ::   kbdy            ! bdy number
+      !!
+      INTEGER                                   ::   ipi             ! length of boundary data on local process
+      INTEGER                                   ::   ipkb            ! number of vertical levels in boundary data file
+      INTEGER                                   ::   jb, ji, jj, jk, jkb   ! loop counters
+      REAL(wp)                                  ::   zcoef
+      REAL(wp)                                  ::   zl, zi, zh      ! tmp variable for current depth and interpolation factor
+      REAL(wp)                                  ::   zfv_alt, ztrans, ztrans_new ! fillvalue and alternative -ABS(pfv)
+      REAL(wp), DIMENSION(jpk)                  ::   zdepth, zdhalf  ! level and half-level depth
       !!---------------------------------------------------------------------
      
-
-      ipi       = SIZE( dta, 1 )
-      ipj       = SIZE( dta_read, 2 )
-      ipk       = SIZE( dta, 3 )
-      jpkm1_bdy = jpk_bdy-1
+      ipi  = SIZE( pdta, 1 )
+      ipkb = SIZE( pdta_read, 3 )
       
-      fv_alt = -ABS(fv)  ! set _FillValue < 0 as we make use of MAXVAL and MAXLOC later
-      DO ib = 1, ipi
-            zij = idx_bdy(ibdy)%nbi(ib,igrd)
-            zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-         IF(narea==2) WRITE(*,*) 'MAPI', ib, igrd, map%ptr(ib), narea-1, zij, zjj
-      ENDDO
-      !
-      IF ( map%ll_unstruc ) THEN                            ! unstructured open boundary data file
-
-         DO ib = 1, ipi
-            DO ik = 1, jpk_bdy
-               IF( ( dta_read(map%ptr(ib),1,ik) == fv ) ) THEN
-                  dta_read_z(map%ptr(ib),1,ik)  = fv_alt ! safety: put fillvalue into external depth field so consistent with data
-                  dta_read_dz(map%ptr(ib),1,ik) = 0._wp  ! safety: put 0._wp into external thickness factors to ensure transport is correct
+      zfv_alt = -ABS(pfv)  ! set _FillValue < 0 as we make use of MAXVAL and MAXLOC later
+      !
+      WHERE( pdta_read == pfv )
+         pdta_read_z  = zfv_alt ! safety: put fillvalue into external depth field so consistent with data
+         pdta_read_dz = 0._wp   ! safety: put 0._wp into external thickness factors to ensure transport is correct
+      ENDWHERE
+      
+      DO jb = 1, ipi
+         ji = idx_bdy(kbdy)%nbi(jb,kgrd)
+         jj = idx_bdy(kbdy)%nbj(jb,kgrd)
+         zh  = SUM(pdta_read_dz(jb,1,:) )
+         !
+         ! Warnings to flag differences in the input and model topgraphy - is this useful/necessary?
+         SELECT CASE( kgrd )                         
+         CASE(1)
+            IF( ABS( (zh - ht_n(ji,jj)) / ht_n(ji,jj)) * tmask(ji,jj,1) > 0.01_wp ) THEN
+               WRITE(ctmp1,"(I10.10)") jb 
+               CALL ctl_warn('fld_bdy_interp: T depths differ between grids at BDY point '//TRIM(ctmp1)//' by more than 1%')
+               !   IF(lwp) WRITE(numout,*) 'DEPTHT', zh, sum(e3t_n(ji,jj,:), mask=tmask(ji,jj,:)==1),  ht_n(ji,jj), jb, jb, ji, jj
+            ENDIF
+         CASE(2)
+            IF( ABS( (zh - hu_n(ji,jj)) * r1_hu_n(ji,jj)) * umask(ji,jj,1) > 0.01_wp ) THEN
+               WRITE(ctmp1,"(I10.10)") jb 
+               CALL ctl_warn('fld_bdy_interp: U depths differ between grids at BDY point '//TRIM(ctmp1)//' by more than 1%')
+               !   IF(lwp) WRITE(numout,*) 'DEPTHU', zh, SUM(e3u_n(ji,jj,:), mask=umask(ji,jj,:)==1),  SUM(umask(ji,jj,:)), &
+               !      &                hu_n(ji,jj), jb, jb, ji, jj, narea-1, pdta_read(jb,1,:)
+            ENDIF
+         CASE(3)
+            IF( ABS( (zh - hv_n(ji,jj)) * r1_hv_n(ji,jj)) * vmask(ji,jj,1) > 0.01_wp ) THEN
+               WRITE(ctmp1,"(I10.10)") jb
+               CALL ctl_warn('fld_bdy_interp: V depths differ between grids at BDY point '//TRIM(ctmp1)//' by more than 1%')
+            ENDIF
+         END SELECT
+         !
+         SELECT CASE( kgrd )                         
+         CASE(1)
+            ! depth of T points:
+            zdepth(:) = gdept_n(ji,jj,:)
+         CASE(2)
+            ! depth of U points: we must not use gdept_n as we don't want to do a communication
+            !   --> copy what is done for gdept_n in domvvl...
+            zdhalf(1) = 0.0_wp
+            zdepth(1) = 0.5_wp * e3uw_n(ji,jj,1)
+            DO jk = 2, jpk                               ! vertical sum
+               !    zcoef = umask - wumask    ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt
+               !                              ! 1 everywhere from mbkt to mikt + 1 or 1 (if no isf)
+               !                              ! 0.5 where jk = mikt     
+               !!gm ???????   BUG ?  gdept_n as well as gde3w_n  does not include the thickness of ISF ??
+               zcoef = ( umask(ji,jj,jk) - wumask(ji,jj,jk) )
+               zdhalf(jk) = zdhalf(jk-1) + e3u_n(ji,jj,jk-1)
+               zdepth(jk) =      zcoef  * ( zdhalf(jk  ) + 0.5 * e3uw_n(ji,jj,jk))  &
+                  &         + (1-zcoef) * ( zdepth(jk-1) +       e3uw_n(ji,jj,jk))
+            END DO
+         CASE(3)
+            ! depth of V points: we must not use gdept_n as we don't want to do a communication
+            !   --> copy what is done for gdept_n in domvvl...
+            zdhalf(1) = 0.0_wp
+            zdepth(1) = 0.5_wp * e3vw_n(ji,jj,1)
+            DO jk = 2, jpk                               ! vertical sum
+               !    zcoef = vmask - wvmask    ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt
+               !                              ! 1 everywhere from mbkt to mikt + 1 or 1 (if no isf)
+               !                              ! 0.5 where jk = mikt     
+               !!gm ???????   BUG ?  gdept_n as well as gde3w_n  does not include the thickness of ISF ??
+               zcoef = ( vmask(ji,jj,jk) - wvmask(ji,jj,jk) )
+               zdhalf(jk) = zdhalf(jk-1) + e3v_n(ji,jj,jk-1)
+               zdepth(jk) =      zcoef  * ( zdhalf(jk  ) + 0.5 * e3vw_n(ji,jj,jk))  &
+                  &         + (1-zcoef) * ( zdepth(jk-1) +       e3vw_n(ji,jj,jk))
+            END DO
+         END SELECT
+         !
+         DO jk = 1, jpk                      
+            IF(     zdepth(jk) < pdta_read_z(jb,1,          1) ) THEN                ! above the first level of external data
+               pdta(jb,1,jk) =  pdta_read(jb,1,1)
+            ELSEIF( zdepth(jk) > pdta_read_z(jb,1,ipkb) ) THEN                       ! below the last level of external data 
+               pdta(jb,1,jk) =  pdta_read(jb,1,MAXLOC(pdta_read_z(jb,1,:),1))
+            ELSE                                                             ! inbetween: vertical interpolation between jkb & jkb+1
+               DO jkb = 1, ipkb-1                                            ! when  gdept_n(jkb) < zdepth(jk) < gdept_n(jkb+1)
+                  IF( ( ( zdepth(jk) - pdta_read_z(jb,1,jkb) ) * ( zdepth(jk) - pdta_read_z(jb,1,jkb+1) ) <= 0._wp ) &
+                     &    .AND. ( pdta_read_z(jb,1,jkb+1) /= zfv_alt) ) THEN   ! linear interpolation between 2 levels
+                     zi = ( zdepth(jk) - pdta_read_z(jb,1,jkb) ) / ( pdta_read_z(jb,1,jkb+1) - pdta_read_z(jb,1,jkb) )
+                     pdta(jb,1,jk) = pdta_read(jb,1,jkb) + ( pdta_read  (jb,1,jkb+1) - pdta_read  (jb,1,jkb) ) * zi
+                  ENDIF
+               END DO
+            ENDIF
+         END DO   ! jpk
+         !
+      END DO   ! ipi
+      
+      IF(kgrd == 2) THEN                                  ! do we need to adjust the transport term?
+         DO jb = 1, ipi
+            ji = idx_bdy(kbdy)%nbi(jb,kgrd)
+            jj = idx_bdy(kbdy)%nbj(jb,kgrd)
+            zh  = SUM(pdta_read_dz(jb,1,:) )
+            ztrans = 0._wp
+            ztrans_new = 0._wp
+            DO jkb = 1, ipkb                              ! calculate transport on input grid
+               ztrans     = ztrans     + pdta_read(jb,1,jkb) * pdta_read_dz(jb, 1,jkb)
+            ENDDO
+            DO jk = 1, jpk                                ! calculate transport on model grid
+               ztrans_new = ztrans_new +      pdta(jb,1,jk ) *        e3u_n(ji,jj,jk ) * umask(ji,jj,jk)
+            ENDDO
+            DO jk = 1, jpk                                ! make transport correction
+               IF(ldtotvel) THEN ! bdy data are total velocity so adjust bt transport term to match input data
+                  pdta(jb,1,jk) = ( pdta(jb,1,jk) + ( ztrans - ztrans_new ) * r1_hu_n(ji,jj) ) * umask(ji,jj,jk)
+               ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
+                  pdta(jb,1,jk) =   pdta(jb,1,jk) + (  0._wp - ztrans_new ) * r1_hu_n(ji,jj)   * umask(ji,jj,jk)
                ENDIF
             ENDDO
-         ENDDO 
-
-         DO ib = 1, ipi
-            zij = idx_bdy(ibdy)%nbi(ib,igrd)
-            zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-            zh  = SUM(dta_read_dz(map%ptr(ib),1,:) )
-            ! Warnings to flag differences in the input and model topgraphy - is this useful/necessary?
-            SELECT CASE( igrd )                         
-               CASE(1)
-                  IF( ABS( (zh - ht_n(zij,zjj)) / ht_n(zij,zjj)) * tmask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: T depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                 !   IF(lwp) WRITE(*,*) 'DEPTHT', zh, sum(e3t_n(zij,zjj,:), mask=tmask(zij,zjj,:)==1),  ht_n(zij,zjj), map%ptr(ib), ib, zij, zjj
-                  ENDIF
-               CASE(2)
-                  IF( ABS( (zh - hu_n(zij,zjj)) * r1_hu_n(zij,zjj)) * umask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: U depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                     IF(lwp) WRITE(*,*) 'DEPTHU', zh, sum(e3u_n(zij,zjj,:), mask=umask(zij,zjj,:)==1),  sum(umask(zij,zjj,:)), &
-                       &                hu_n(zij,zjj), map%ptr(ib), ib, zij, zjj, narea-1  , &
-                        &                dta_read(map%ptr(ib),1,:)
-                  ENDIF
-               CASE(3)
-                  IF( ABS( (zh - hv_n(zij,zjj)) * r1_hv_n(zij,zjj)) * vmask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: V depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                  ENDIF
-            END SELECT
-            DO ik = 1, ipk                      
-               SELECT CASE( igrd )                       
-                  CASE(1)
-                     zl =  gdept_n(zij,zjj,ik)                                          ! if using in step could use fsdept instead of gdept_n?
-                  CASE(2)
-                     IF(ln_sco) THEN
-                        zl =  ( gdept_n(zij,zjj,ik) + gdept_n(zij+1,zjj,ik) ) * 0.5_wp  ! if using in step could use fsdept instead of gdept_n?
-                     ELSE
-                        zl =  MIN( gdept_n(zij,zjj,ik), gdept_n(zij+1,zjj,ik) ) 
-                     ENDIF
-                  CASE(3)
-                     IF(ln_sco) THEN
-                        zl =  ( gdept_n(zij,zjj,ik) + gdept_n(zij,zjj+1,ik) ) * 0.5_wp  ! if using in step could use fsdept instead of gdept_n?
-                     ELSE
-                        zl =  MIN( gdept_n(zij,zjj,ik), gdept_n(zij,zjj+1,ik) )
-                     ENDIF
-               END SELECT
-               IF( zl < dta_read_z(map%ptr(ib),1,1) ) THEN                                         ! above the first level of external data
-                  dta(ib,1,ik) =  dta_read(map%ptr(ib),1,1)
-               ELSEIF( zl > MAXVAL(dta_read_z(map%ptr(ib),1,:),1) ) THEN                           ! below the last level of external data 
-                  dta(ib,1,ik) =  dta_read(map%ptr(ib),1,MAXLOC(dta_read_z(map%ptr(ib),1,:),1))
-               ELSE                                                                                ! inbetween : vertical interpolation between ikk & ikk+1
-                  DO ikk = 1, jpkm1_bdy                                                            ! when  gdept_n(ikk) < zl < gdept_n(ikk+1)
-                     IF( ( (zl-dta_read_z(map%ptr(ib),1,ikk)) * (zl-dta_read_z(map%ptr(ib),1,ikk+1)) <= 0._wp) &
-                    &    .AND. (dta_read_z(map%ptr(ib),1,ikk+1) /= fv_alt)) THEN
-                        zi           = ( zl - dta_read_z(map%ptr(ib),1,ikk) ) / &
-                       &               ( dta_read_z(map%ptr(ib),1,ikk+1) - dta_read_z(map%ptr(ib),1,ikk) )
-                        dta(ib,1,ik) = dta_read(map%ptr(ib),1,ikk) + &
-                       &               ( dta_read(map%ptr(ib),1,ikk+1) - dta_read(map%ptr(ib),1,ikk) ) * zi
-                     ENDIF
-                  END DO
-               ENDIF
-            END DO
-         END DO
-
-         IF(igrd == 2) THEN                                 ! do we need to adjust the transport term?
-            DO ib = 1, ipi
-              zij = idx_bdy(ibdy)%nbi(ib,igrd)
-              zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-              zh  = SUM(dta_read_dz(map%ptr(ib),1,:) )
-              ztrans = 0._wp
-              ztrans_new = 0._wp
-              DO ik = 1, jpk_bdy                            ! calculate transport on input grid
-                  ztrans     = ztrans     + dta_read(map%ptr(ib),1,ik) * dta_read_dz(map%ptr(ib),1,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! calculate transport on model grid
-                  ztrans_new = ztrans_new + dta(ib,1,ik) * e3u_n(zij,zjj,ik) * umask(zij,zjj,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! make transport correction
-                 IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                    dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * r1_hu_n(zij,zjj) ) * umask(zij,zjj,ik)
-                 ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                    IF( ABS(ztrans * r1_hu_n(zij,zjj)) > 0.01_wp ) &
-                   &   CALL ctl_warn('fld_bdy_interp: barotropic component of > 0.01 ms-1 found in baroclinic velocities at')
-                    dta(ib,1,ik) = dta(ib,1,ik) + ( 0._wp - ztrans_new ) * r1_hu_n(zij,zjj) * umask(zij,zjj,ik)
-                 ENDIF
-              ENDDO
+         ENDDO
+      ENDIF
+      
+      IF(kgrd == 3) THEN                                  ! do we need to adjust the transport term?
+         DO jb = 1, ipi
+            ji = idx_bdy(kbdy)%nbi(jb,kgrd)
+            jj = idx_bdy(kbdy)%nbj(jb,kgrd)
+            zh  = SUM(pdta_read_dz(jb,1,:) )
+            ztrans = 0._wp
+            ztrans_new = 0._wp
+            DO jkb = 1, ipkb                              ! calculate transport on input grid
+               ztrans     = ztrans     + pdta_read(jb,1,jkb) * pdta_read_dz(jb, 1,jkb)
             ENDDO
-         ENDIF
-
-         IF(igrd == 3) THEN                                 ! do we need to adjust the transport term?
-            DO ib = 1, ipi
-              zij = idx_bdy(ibdy)%nbi(ib,igrd)
-              zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-              zh  = SUM(dta_read_dz(map%ptr(ib),1,:) )
-              ztrans = 0._wp
-              ztrans_new = 0._wp
-              DO ik = 1, jpk_bdy                            ! calculate transport on input grid
-                  ztrans     = ztrans     + dta_read(map%ptr(ib),1,ik) * dta_read_dz(map%ptr(ib),1,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! calculate transport on model grid
-                  ztrans_new = ztrans_new + dta(ib,1,ik) * e3v_n(zij,zjj,ik) * vmask(zij,zjj,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! make transport correction
-                 IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                    dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * r1_hv_n(zij,zjj) ) * vmask(zij,zjj,ik)
-                 ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                    dta(ib,1,ik) = dta(ib,1,ik) + ( 0._wp - ztrans_new ) * r1_hv_n(zij,zjj) * vmask(zij,zjj,ik)
-                 ENDIF
-              ENDDO
+            DO jk = 1, jpk                                ! calculate transport on model grid
+               ztrans_new = ztrans_new +      pdta(jb,1,jk ) *        e3v_n(ji,jj,jk ) * vmask(ji,jj,jk)
             ENDDO
-         ENDIF
-  
-      ELSE ! structured open boundary file
-
-         DO ib = 1, ipi
-            jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-            ji=map%ptr(ib)-(jj-1)*ilendta
-            DO ik = 1, jpk_bdy                      
-               IF( ( dta_read(ji,jj,ik) == fv ) ) THEN
-                  dta_read_z(ji,jj,ik)  = fv_alt ! safety: put fillvalue into external depth field so consistent with data
-                  dta_read_dz(ji,jj,ik) = 0._wp  ! safety: put 0._wp into external thickness factors to ensure transport is correct
+            DO jk = 1, jpk                                ! make transport correction
+               IF(ldtotvel) THEN ! bdy data are total velocity so adjust bt transport term to match input data
+                  pdta(jb,1,jk) = ( pdta(jb,1,jk) + ( ztrans - ztrans_new ) * r1_hv_n(ji,jj) ) * vmask(ji,jj,jk)
+               ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
+                  pdta(jb,1,jk) =   pdta(jb,1,jk) + (  0._wp - ztrans_new ) * r1_hv_n(ji,jj)   * vmask(ji,jj,jk)
                ENDIF
             ENDDO
-         ENDDO 
-       
-
-         DO ib = 1, ipi
-            jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-            ji=map%ptr(ib)-(jj-1)*ilendta
-            zij = idx_bdy(ibdy)%nbi(ib,igrd)
-            zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-            zh  = SUM(dta_read_dz(ji,jj,:) )
-            ! Warnings to flag differences in the input and model topgraphy - is this useful/necessary?
-            SELECT CASE( igrd )                         
-               CASE(1)
-                  IF( ABS( (zh - ht_n(zij,zjj)) / ht_n(zij,zjj)) * tmask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: T depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                 !   IF(lwp) WRITE(*,*) 'DEPTHT', zh, sum(e3t_n(zij,zjj,:), mask=tmask(zij,zjj,:)==1),  ht_n(zij,zjj), map%ptr(ib), ib, zij, zjj
-                  ENDIF
-               CASE(2)
-                  IF( ABS( (zh - hu_n(zij,zjj)) * r1_hu_n(zij,zjj)) * umask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: U depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                  ENDIF
-               CASE(3)
-                  IF( ABS( (zh - hv_n(zij,zjj)) * r1_hv_n(zij,zjj)) * vmask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: V depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                  ENDIF
-            END SELECT
-            DO ik = 1, ipk                      
-               SELECT CASE( igrd )                          ! coded for sco - need zco and zps option using min
-                  CASE(1)
-                     zl =  gdept_n(zij,zjj,ik)              ! if using in step could use fsdept instead of gdept_n?
-                  CASE(2)
-                     IF(ln_sco) THEN
-                        zl =  ( gdept_n(zij,zjj,ik) + gdept_n(zij+1,zjj,ik) ) * 0.5_wp  ! if using in step could use fsdept instead of gdept_n?
-                     ELSE
-                        zl =  MIN( gdept_n(zij,zjj,ik), gdept_n(zij+1,zjj,ik) )
-                     ENDIF
-                  CASE(3)
-                     IF(ln_sco) THEN
-                        zl =  ( gdept_n(zij,zjj,ik) + gdept_n(zij,zjj+1,ik) ) * 0.5_wp  ! if using in step could use fsdept instead of gdept_n?
-                     ELSE
-                        zl =  MIN( gdept_n(zij,zjj,ik), gdept_n(zij,zjj+1,ik) )
-                     ENDIF
-               END SELECT
-               IF( zl < dta_read_z(ji,jj,1) ) THEN                                      ! above the first level of external data
-                  dta(ib,1,ik) =  dta_read(ji,jj,1)
-               ELSEIF( zl > MAXVAL(dta_read_z(ji,jj,:),1) ) THEN                        ! below the last level of external data 
-                  dta(ib,1,ik) =  dta_read(ji,jj,MAXLOC(dta_read_z(ji,jj,:),1))
-               ELSE                                                                     ! inbetween : vertical interpolation between ikk & ikk+1
-                  DO ikk = 1, jpkm1_bdy                                                 ! when  gdept_n(ikk) < zl < gdept_n(ikk+1)
-                     IF( ( (zl-dta_read_z(ji,jj,ikk)) * (zl-dta_read_z(ji,jj,ikk+1)) <= 0._wp) &
-                    &    .AND. (dta_read_z(ji,jj,ikk+1) /= fv_alt)) THEN
-                        zi           = ( zl - dta_read_z(ji,jj,ikk) ) / &
-                       &               ( dta_read_z(ji,jj,ikk+1) - dta_read_z(ji,jj,ikk) )
-                        dta(ib,1,ik) = dta_read(ji,jj,ikk) + &
-                       &               ( dta_read(ji,jj,ikk+1) - dta_read(ji,jj,ikk) ) * zi
-                     ENDIF
-                  END DO
-               ENDIF
-            END DO
-         END DO
-
-         IF(igrd == 2) THEN                                 ! do we need to adjust the transport term?
-            DO ib = 1, ipi
-               jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-               ji=map%ptr(ib)-(jj-1)*ilendta
-               zij = idx_bdy(ibdy)%nbi(ib,igrd)
-               zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-               zh = SUM(dta_read_dz(ji,jj,:) )
-               ztrans = 0._wp
-               ztrans_new = 0._wp
-               DO ik = 1, jpk_bdy                            ! calculate transport on input grid
-                  ztrans = ztrans + dta_read(ji,jj,ik) * dta_read_dz(ji,jj,ik)
-               ENDDO
-               DO ik = 1, ipk                                ! calculate transport on model grid
-                  ztrans_new = ztrans_new + dta(ib,1,ik) * e3u_n(zij,zjj,ik) * umask(zij,zjj,ik)
-               ENDDO
-               DO ik = 1, ipk                                ! make transport correction
-                  IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * r1_hu_n(zij,zjj) ) * umask(zij,zjj,ik)
-                  ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( 0._wp  - ztrans_new ) * r1_hu_n(zij,zjj) ) * umask(zij,zjj,ik)
-                  ENDIF
-               ENDDO
-            ENDDO
-         ENDIF
-
-         IF(igrd == 3) THEN                                 ! do we need to adjust the transport term?
-            DO ib = 1, ipi
-               jj  = 1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-               ji  = map%ptr(ib)-(jj-1)*ilendta
-               zij = idx_bdy(ibdy)%nbi(ib,igrd)
-               zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-               zh  = SUM(dta_read_dz(ji,jj,:) )
-               ztrans = 0._wp
-               ztrans_new = 0._wp
-               DO ik = 1, jpk_bdy                            ! calculate transport on input grid
-                  ztrans     = ztrans     + dta_read(ji,jj,ik) * dta_read_dz(ji,jj,ik)
-               ENDDO
-               DO ik = 1, ipk                                ! calculate transport on model grid
-                  ztrans_new = ztrans_new + dta(ib,1,ik) * e3v_n(zij,zjj,ik) * vmask(zij,zjj,ik)
-               ENDDO
-               DO ik = 1, ipk                                ! make transport correction
-                  IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * r1_hv_n(zij,zjj) ) * vmask(zij,zjj,ik)
-                  ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( 0._wp  - ztrans_new ) * r1_hv_n(zij,zjj) ) * vmask(zij,zjj,ik)
-                  ENDIF
-               ENDDO
-            ENDDO
-         ENDIF
-
-      ENDIF ! endif unstructured or structured
-
+         ENDDO
+      ENDIF
+      
    END SUBROUTINE fld_bdy_interp
 
@@ -1151,4 +1011,5 @@
       imf = SIZE( sd )
       DO ju = 1, imf
+         IF( TRIM(sd(ju)%clrootname) == 'NOT USED' )   CYCLE
          ill = LEN_TRIM( sd(ju)%vcomp )
          DO jn = 2-COUNT((/sd(ju)%ln_tint/)), 2
@@ -1159,4 +1020,5 @@
                   iv = -1
                   DO jv = 1, imf
+                     IF( TRIM(sd(jv)%clrootname) == 'NOT USED' )   CYCLE
                      IF( TRIM(sd(jv)%vcomp) == TRIM(clcomp) )   iv = jv
                   END DO
@@ -1197,11 +1059,11 @@
       LOGICAL, OPTIONAL, INTENT(in   ) ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
       !
-      LOGICAL :: llprevyr              ! are we reading previous year  file?
-      LOGICAL :: llprevmth             ! are we reading previous month file?
-      INTEGER :: iyear, imonth, iday   ! first day of the current file in yyyy mm dd
-      INTEGER :: isec_week             ! number of seconds since start of the weekly file
-      INTEGER :: indexyr               ! year undex (O/1/2: previous/current/next)
-      INTEGER :: iyear_len, imonth_len ! length (days) of iyear and imonth             ! 
-      CHARACTER(len = 256)::   clname  ! temporary file name
+      LOGICAL  :: llprevyr              ! are we reading previous year  file?
+      LOGICAL  :: llprevmth             ! are we reading previous month file?
+      INTEGER  :: iyear, imonth, iday   ! first day of the current file in yyyy mm dd
+      INTEGER  :: isec_week             ! number of seconds since start of the weekly file
+      INTEGER  :: indexyr               ! year undex (O/1/2: previous/current/next)
+      REAL(wp) :: zyear_len, zmonth_len ! length (days) of iyear and imonth             ! 
+      CHARACTER(len = 256) ::   clname  ! temporary file name
       !!----------------------------------------------------------------------
       IF( PRESENT(kyear) ) THEN                             ! use given values 
@@ -1254,22 +1116,22 @@
          ! find the last record to be read -> update sdjf%nreclast
          indexyr = iyear - nyear + 1
-         iyear_len = nyear_len( indexyr )
+         zyear_len = REAL(nyear_len( indexyr ), wp)
          SELECT CASE ( indexyr )
-         CASE ( 0 )   ;   imonth_len = 31   ! previous year -> imonth = 12
-         CASE ( 1 )   ;   imonth_len = nmonth_len(imonth) 
-         CASE ( 2 )   ;   imonth_len = 31   ! next     year -> imonth = 1
+         CASE ( 0 )   ;   zmonth_len = 31.   ! previous year -> imonth = 12
+         CASE ( 1 )   ;   zmonth_len = REAL(nmonth_len(imonth), wp)
+         CASE ( 2 )   ;   zmonth_len = 31.   ! next     year -> imonth = 1
          END SELECT
          !
          ! last record to be read in the current file
-         IF    ( sdjf%nfreqh == -12 ) THEN                 ;   sdjf%nreclast = 1    !  yearly mean
-         ELSEIF( sdjf%nfreqh ==  -1 ) THEN                                          ! monthly mean
+         IF    ( sdjf%freqh == -12. ) THEN                 ;   sdjf%nreclast = 1    !  yearly mean
+         ELSEIF( sdjf%freqh ==  -1. ) THEN                                          ! monthly mean
             IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = 1
             ELSE                                           ;   sdjf%nreclast = 12
             ENDIF
          ELSE                                                                       ! higher frequency mean (in hours)
-            IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = NINT( 24 * imonth_len / sdjf%nfreqh )
-            ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ;   sdjf%nreclast = NINT( 24 * 7          / sdjf%nfreqh )
-            ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ;   sdjf%nreclast = NINT( 24              / sdjf%nfreqh )
-            ELSE                                           ;   sdjf%nreclast = NINT( 24 * iyear_len  / sdjf%nfreqh )
+            IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = NINT( 24. * zmonth_len / sdjf%freqh )
+            ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ;   sdjf%nreclast = NINT( 24. * 7.         / sdjf%freqh )
+            ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ;   sdjf%nreclast = NINT( 24.              / sdjf%freqh )
+            ELSE                                           ;   sdjf%nreclast = NINT( 24. * zyear_len  / sdjf%freqh )
             ENDIF
          ENDIF
@@ -1299,7 +1161,8 @@
       !
       DO jf = 1, SIZE(sdf)
-         sdf(jf)%clrootname = TRIM( cdir )//TRIM( sdf_n(jf)%clname )
+         sdf(jf)%clrootname = sdf_n(jf)%clname
+         IF( TRIM(sdf_n(jf)%clname) /= 'NOT USED' )   sdf(jf)%clrootname = TRIM( cdir )//sdf(jf)%clrootname
          sdf(jf)%clname     = "not yet defined"
-         sdf(jf)%nfreqh     = sdf_n(jf)%nfreqh
+         sdf(jf)%freqh      = sdf_n(jf)%freqh
          sdf(jf)%clvar      = sdf_n(jf)%clvar
          sdf(jf)%ln_tint    = sdf_n(jf)%ln_tint
@@ -1308,7 +1171,7 @@
          sdf(jf)%num        = -1
          sdf(jf)%wgtname    = " "
-         IF( LEN( TRIM(sdf_n(jf)%wname) ) > 0 )   sdf(jf)%wgtname = TRIM( cdir )//TRIM( sdf_n(jf)%wname )
+         IF( LEN( TRIM(sdf_n(jf)%wname) ) > 0 )   sdf(jf)%wgtname = TRIM( cdir )//sdf_n(jf)%wname
          sdf(jf)%lsmname = " "
-         IF( LEN( TRIM(sdf_n(jf)%lname) ) > 0 )   sdf(jf)%lsmname = TRIM( cdir )//TRIM( sdf_n(jf)%lname )
+         IF( LEN( TRIM(sdf_n(jf)%lname) ) > 0 )   sdf(jf)%lsmname = TRIM( cdir )//sdf_n(jf)%lname
          sdf(jf)%vcomp      = sdf_n(jf)%vcomp
          sdf(jf)%rotn(:)    = .TRUE.   ! pretend to be rotated -> won't try to rotate data before the first call to fld_get
@@ -1317,5 +1180,10 @@
          IF( sdf(jf)%cltype(1:4) == 'week' .AND. sdf(jf)%ln_clim )   &
             &   CALL ctl_stop('fld_clopn: weekly file ('//TRIM(sdf(jf)%clrootname)//') needs ln_clim = .FALSE.')
-         sdf(jf)%nreclast = -1 ! Set to non zero default value to avoid errors, is updated to meaningful value during fld_clopn
+         sdf(jf)%nreclast   = -1 ! Set to non zero default value to avoid errors, is updated to meaningful value during fld_clopn
+         sdf(jf)%igrd       = 0
+         sdf(jf)%ibdy       = 0
+         sdf(jf)%imap       => NULL()
+         sdf(jf)%ltotvel    = .FALSE.
+         sdf(jf)%lzint      = .FALSE.
       END DO
       !
@@ -1331,5 +1199,5 @@
          DO jf = 1, SIZE(sdf)
             WRITE(numout,*) '      root filename: '  , TRIM( sdf(jf)%clrootname ), '   variable name: ', TRIM( sdf(jf)%clvar )
-            WRITE(numout,*) '         frequency: '      ,       sdf(jf)%nfreqh      ,   &
+            WRITE(numout,*) '         frequency: '      ,       sdf(jf)%freqh       ,   &
                &                  '   time interp: '    ,       sdf(jf)%ln_tint     ,   &
                &                  '   climatology: '    ,       sdf(jf)%ln_clim
Index: NEMO/trunk/src/OCE/SBC/sbcapr.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcapr.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcapr.F90	(revision 11536)
@@ -71,9 +71,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_apr in reference namelist : File for atmospheric pressure forcing
       READ  ( numnam_ref, namsbc_apr, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_apr in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_apr in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namsbc_apr in configuration namelist : File for atmospheric pressure forcing
       READ  ( numnam_cfg, namsbc_apr, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_apr in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_apr in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_apr )
       !
Index: NEMO/trunk/src/OCE/SBC/sbcblk.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcblk.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcblk.F90	(revision 11536)
@@ -182,9 +182,9 @@
       REWIND( numnam_ref )                !* Namelist namsbc_blk in reference namelist : bulk parameters
       READ  ( numnam_ref, namsbc_blk, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_blk in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_blk in reference namelist' )
       !
       REWIND( numnam_cfg )                !* Namelist namsbc_blk in configuration namelist : bulk parameters
       READ  ( numnam_cfg, namsbc_blk, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_blk in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_blk in configuration namelist' )
       !
       IF(lwm) WRITE( numond, namsbc_blk )
@@ -201,5 +201,5 @@
       !
       IF( ln_dm2dc ) THEN                 !* check: diurnal cycle on Qsr
-         IF( sn_qsr%nfreqh /= 24 )   CALL ctl_stop( 'sbc_blk_init: ln_dm2dc=T only with daily short-wave input' )
+         IF( sn_qsr%freqh /= 24. )   CALL ctl_stop( 'sbc_blk_init: ln_dm2dc=T only with daily short-wave input' )
          IF( sn_qsr%ln_tint ) THEN 
             CALL ctl_warn( 'sbc_blk_init: ln_dm2dc=T daily qsr time interpolation done by sbcdcy module',   &
@@ -225,5 +225,5 @@
          ALLOCATE( sf(ifpr)%fnow(jpi,jpj,1) )
          IF( slf_i(ifpr)%ln_tint )   ALLOCATE( sf(ifpr)%fdta(jpi,jpj,1,2) )
-         IF( slf_i(ifpr)%nfreqh > 0. .AND. MOD( 3600. * slf_i(ifpr)%nfreqh , REAL(nn_fsbc) * rdt) /= 0. )   &
+         IF( slf_i(ifpr)%freqh > 0. .AND. MOD( NINT(3600. * slf_i(ifpr)%freqh), nn_fsbc * NINT(rdt) ) /= 0 )   &
             &  CALL ctl_warn( 'sbc_blk_init: sbcmod timestep rdt*nn_fsbc is NOT a submultiple of atmospheric forcing frequency.',   &
             &                 '               This is not ideal. You should consider changing either rdt or nn_fsbc value...' )
Index: NEMO/trunk/src/OCE/SBC/sbccpl.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbccpl.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbccpl.F90	(revision 11536)
@@ -266,9 +266,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_cpl in reference namelist : Variables for OASIS coupling
       READ  ( numnam_ref, namsbc_cpl, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_cpl in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_cpl in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namsbc_cpl in configuration namelist : Variables for OASIS coupling
       READ  ( numnam_cfg, namsbc_cpl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_cpl in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_cpl in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_cpl )
       !
Index: NEMO/trunk/src/OCE/SBC/sbcflx.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcflx.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcflx.F90	(revision 11536)
@@ -93,13 +93,13 @@
          REWIND( numnam_ref )              ! Namelist namsbc_flx in reference namelist : Files for fluxes
          READ  ( numnam_ref, namsbc_flx, IOSTAT = ios, ERR = 901)
-901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_flx in reference namelist', lwp )
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_flx in reference namelist' )
 
          REWIND( numnam_cfg )              ! Namelist namsbc_flx in configuration namelist : Files for fluxes
          READ  ( numnam_cfg, namsbc_flx, IOSTAT = ios, ERR = 902 )
-902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_flx in configuration namelist', lwp )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_flx in configuration namelist' )
          IF(lwm) WRITE ( numond, namsbc_flx ) 
          !
          !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing?
-         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   &
+         IF( ln_dm2dc .AND. sn_qsr%freqh /= 24. )   &
             &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' ) 
          !
Index: NEMO/trunk/src/OCE/SBC/sbcice_cice.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcice_cice.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcice_cice.F90	(revision 11536)
@@ -764,9 +764,9 @@
          REWIND( numnam_ref )              ! Namelist namsbc_cice in reference namelist : 
          READ  ( numnam_ref, namsbc_cice, IOSTAT = ios, ERR = 901)
-901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_cice in reference namelist', lwp )
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_cice in reference namelist' )
 
          REWIND( numnam_cfg )              ! Namelist namsbc_cice in configuration namelist : Parameters of the run
          READ  ( numnam_cfg, namsbc_cice, IOSTAT = ios, ERR = 902 )
-902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_cice in configuration namelist', lwp )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_cice in configuration namelist' )
          IF(lwm) WRITE ( numond, namsbc_cice )
 
Index: NEMO/trunk/src/OCE/SBC/sbcice_if.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcice_if.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcice_if.F90	(revision 11536)
@@ -76,9 +76,9 @@
          REWIND( numnam_ref )              ! Namelist namsbc_iif in reference namelist : Ice if file
          READ  ( numnam_ref, namsbc_iif, IOSTAT = ios, ERR = 901)
-901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_iif in reference namelist', lwp )
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_iif in reference namelist' )
 
          REWIND( numnam_cfg )              ! Namelist Namelist namsbc_iif in configuration namelist : Ice if file
          READ  ( numnam_cfg, namsbc_iif, IOSTAT = ios, ERR = 902 )
-902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_iif in configuration namelist', lwp )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_iif in configuration namelist' )
          IF(lwm) WRITE ( numond, namsbc_iif )
 
Index: NEMO/trunk/src/OCE/SBC/sbcisf.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcisf.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcisf.F90	(revision 11536)
@@ -278,9 +278,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_rnf in reference namelist : Runoffs 
       READ  ( numnam_ref, namsbc_isf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_isf in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_isf in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namsbc_rnf in configuration namelist : Runoffs
       READ  ( numnam_cfg, namsbc_isf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_isf in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_isf in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_isf )
 
Index: NEMO/trunk/src/OCE/SBC/sbcmod.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcmod.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcmod.F90	(revision 11536)
@@ -110,8 +110,8 @@
       REWIND( numnam_ref )          !* Namelist namsbc in reference namelist : Surface boundary
       READ  ( numnam_ref, namsbc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc in reference namelist' )
       REWIND( numnam_cfg )          !* Namelist namsbc in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namsbc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc in configuration namelist' )
       IF(lwm) WRITE( numond, namsbc )
       !
@@ -307,9 +307,13 @@
       !
       !                             !* check consistency between model timeline and nn_fsbc
-      IF( MOD( nitend - nit000 + 1, nn_fsbc) /= 0 .OR.   &
-          MOD( nstock             , nn_fsbc) /= 0 ) THEN
-         WRITE(ctmp1,*) 'sbc_init : experiment length (', nitend - nit000 + 1, ') or nstock (', nstock,   &
-            &           ' is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
-         CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
+      IF( ln_rst_list .OR. nn_stock /= -1 ) THEN   ! we will do restart files
+         IF( MOD( nitend - nit000 + 1, nn_fsbc) /= 0 ) THEN
+            WRITE(ctmp1,*) 'sbc_init : experiment length (', nitend - nit000 + 1, ') is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
+            CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
+         ENDIF
+         IF( .NOT. ln_rst_list .AND. MOD( nn_stock, nn_fsbc) /= 0 ) THEN   ! we don't use nn_stock if ln_rst_list
+            WRITE(ctmp1,*) 'sbc_init : nn_stock (', nn_stock, ') is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
+            CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
+         ENDIF
       ENDIF
       !
Index: NEMO/trunk/src/OCE/SBC/sbcrnf.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcrnf.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcrnf.F90	(revision 11536)
@@ -267,9 +267,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_rnf in reference namelist : Runoffs 
       READ  ( numnam_ref, namsbc_rnf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_rnf in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_rnf in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namsbc_rnf in configuration namelist : Runoffs
       READ  ( numnam_cfg, namsbc_rnf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_rnf in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_rnf in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_rnf )
       !
Index: NEMO/trunk/src/OCE/SBC/sbcssr.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcssr.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcssr.F90	(revision 11536)
@@ -166,9 +166,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_ssr in reference namelist : 
       READ  ( numnam_ref, namsbc_ssr, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_ssr in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_ssr in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namsbc_ssr in configuration namelist :
       READ  ( numnam_cfg, namsbc_ssr, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_ssr in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_ssr in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_ssr )
 
Index: NEMO/trunk/src/OCE/SBC/sbcwave.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcwave.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/sbcwave.F90	(revision 11536)
@@ -397,9 +397,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_wave in reference namelist : File for drag coeff. from wave model
       READ  ( numnam_ref, namsbc_wave, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_wave in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_wave in reference namelist' )
          
       REWIND( numnam_cfg )              ! Namelist namsbc_wave in configuration namelist : File for drag coeff. from wave model
       READ  ( numnam_cfg, namsbc_wave, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_wave in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_wave in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_wave )
       !
Index: NEMO/trunk/src/OCE/SBC/tideini.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/tideini.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/tideini.F90	(revision 11536)
@@ -60,9 +60,9 @@
       REWIND( numnam_ref )              ! Namelist nam_tide in reference namelist : Tides
       READ  ( numnam_ref, nam_tide, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_tide in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_tide in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist nam_tide in configuration namelist : Tides
       READ  ( numnam_cfg, nam_tide, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_tide in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_tide in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_tide )
       !
Index: NEMO/trunk/src/OCE/SBC/updtide.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/updtide.F90	(revision 11204)
+++ NEMO/trunk/src/OCE/SBC/updtide.F90	(revision 11536)
@@ -27,5 +27,5 @@
 CONTAINS
 
-   SUBROUTINE upd_tide( kt, kit, time_offset )
+   SUBROUTINE upd_tide( kt, kit, kt_offset )
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE upd_tide  ***
@@ -39,9 +39,9 @@
       INTEGER, INTENT(in)           ::   kt      ! ocean time-step index
       INTEGER, INTENT(in), OPTIONAL ::   kit     ! external mode sub-time-step index (lk_dynspg_ts=T)
-      INTEGER, INTENT(in), OPTIONAL ::   time_offset ! time offset in number 
+      INTEGER, INTENT(in), OPTIONAL ::   kt_offset ! time offset in number 
                                                      ! of internal steps             (lk_dynspg_ts=F)
                                                      ! of external steps             (lk_dynspg_ts=T)
       !
-      INTEGER  ::   joffset      ! local integer
+      INTEGER  ::   ioffset      ! local integer
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   zt, zramp    ! local scalar
@@ -52,11 +52,11 @@
       zt = ( kt - kt_tide ) * rdt
       !
-      joffset = 0
-      IF( PRESENT( time_offset ) )   joffset = time_offset
+      ioffset = 0
+      IF( PRESENT( kt_offset ) )   ioffset = kt_offset
       !
       IF( PRESENT( kit ) )   THEN
-         zt = zt + ( kit +  joffset - 1 ) * rdt / REAL( nn_baro, wp )
+         zt = zt + ( kit +  ioffset - 1 ) * rdt / REAL( nn_baro, wp )
       ELSE
-         zt = zt + joffset * rdt
+         zt = zt + ioffset * rdt
       ENDIF
       !
@@ -70,5 +70,5 @@
       IF( ln_tide_ramp ) THEN         ! linear increase if asked
          zt = ( kt - nit000 ) * rdt
-         IF( PRESENT( kit ) )   zt = zt + ( kit + joffset -1) * rdt / REAL( nn_baro, wp )
+         IF( PRESENT( kit ) )   zt = zt + ( kit + ioffset -1) * rdt / REAL( nn_baro, wp )
          zramp = MIN(  MAX( zt / (rdttideramp*rday) , 0._wp ) , 1._wp  )
          pot_astro(:,:) = zramp * pot_astro(:,:)
