Index: branches/UKMO/dev_r5518_CICE_coupling_GSI7/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- branches/UKMO/dev_r5518_CICE_coupling_GSI7/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 5606)
+++ branches/UKMO/dev_r5518_CICE_coupling_GSI7/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 5612)
@@ -69,6 +69,7 @@
    END TYPE FLD
 
-   TYPE, PUBLIC ::   MAP_POINTER      !: Array of integer pointers to 1D arrays
-      INTEGER, POINTER   ::  ptr(:)
+   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
 
@@ -153,5 +154,7 @@
       IF( PRESENT(kit) )   ll_firstcall = ll_firstcall .and. kit == 1
 
-      it_offset = 0
+      IF ( nn_components == jp_iam_sas ) THEN   ;   it_offset = nn_fsbc
+      ELSE                                      ;   it_offset = 0
+      ENDIF
       IF( PRESENT(kt_offset) )   it_offset = kt_offset
 
@@ -451,5 +454,7 @@
       ENDIF
       !
-      it_offset = 0
+      IF ( nn_components == jp_iam_sas ) THEN   ;   it_offset = nn_fsbc
+      ELSE                                      ;   it_offset = 0
+      ENDIF
       IF( PRESENT(kt_offset) )   it_offset = kt_offset
       IF( PRESENT(kit) ) THEN   ;   it_offset = ( kit + it_offset ) * NINT( rdt/REAL(nn_baro,wp) )
@@ -601,6 +606,6 @@
       !
       IF( ASSOCIATED(map%ptr) ) THEN
-         IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1), map%ptr )
-         ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1), map%ptr )
+         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
       ELSE IF( LEN(TRIM(sdjf%wgtname)) > 0 ) THEN
@@ -672,5 +677,5 @@
       REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   dta   ! output field on model grid (2 dimensional)
       INTEGER                   , INTENT(in ) ::   nrec    ! record number to read (ie time slice)
-      INTEGER,  DIMENSION(:)    , INTENT(in ) ::   map     ! global-to-local mapping indices
+      TYPE(MAP_POINTER)         , INTENT(in ) ::   map     ! global-to-local mapping indices
       !!
       INTEGER                                 ::   ipi      ! length of boundary data on local process
@@ -693,7 +698,7 @@
 #if defined key_bdy
       ipj = iom_file(num)%dimsz(2,idvar)
-      IF (ipj == 1) THEN ! we assume that this is a structured open boundary file
+      IF ( map%ll_unstruc) THEN ! unstructured open boundary data file
          dta_read => dta_global
-      ELSE
+      ELSE                      ! structured open boundary data file
          dta_read => dta_global2
       ENDIF
@@ -708,14 +713,14 @@
       END SELECT
       !
-      IF (ipj==1) THEN
+      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(ib),1,ik)
+               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
+      ELSE                       ! structured open boundary data file
          DO ib = 1, ipi
-            jj=1+floor(REAL(map(ib)-1)/REAL(ilendta))
-            ji=map(ib)-(jj-1)*ilendta
+            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)
@@ -1020,5 +1025,5 @@
       INTEGER                           ::   ipk           ! temporary vertical dimension
       CHARACTER (len=5)                 ::   aname
-      INTEGER , DIMENSION(3)            ::   ddims
+      INTEGER , DIMENSION(:), ALLOCATABLE ::   ddims
       INTEGER , POINTER, DIMENSION(:,:) ::   data_src
       REAL(wp), POINTER, DIMENSION(:,:) ::   data_tmp
@@ -1043,4 +1048,9 @@
 
       !! get dimensions
+      IF ( SIZE(sd%fnow, 3) > 1 ) THEN
+         ALLOCATE( ddims(4) )
+      ELSE
+         ALLOCATE( ddims(3) )
+      ENDIF
       id = iom_varid( inum, sd%clvar, ddims )
 
@@ -1139,4 +1149,6 @@
          CALL ctl_stop( '    fld_weight : unable to read the file ' )
       ENDIF
+
+      DEALLOCATE (ddims )
 
       CALL wrk_dealloc( jpi,jpj, data_src )   ! integer
