Index: NEMO/branches/UKMO/NEMO_4.0.4_CO9_shelf_climate/src/OCE/BDY/bdytides.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_CO9_shelf_climate/src/OCE/BDY/bdytides.F90	(revision 15675)
+++ NEMO/branches/UKMO/NEMO_4.0.4_CO9_shelf_climate/src/OCE/BDY/bdytides.F90	(revision 15683)
@@ -69,5 +69,5 @@
       INTEGER                                   ::   ii, ij              ! dummy loop indices
       INTEGER                                   ::   inum, igrd
-      INTEGER                                   ::   isz                 ! bdy data size
+      INTEGER, DIMENSION(3)                     ::   ilen0               ! length of boundary data (from OBC arrays)
       INTEGER                                   ::   ios                 ! Local integer output status for namelist read
       CHARACTER(len=80)                         ::   clfile              ! full file name for tidal input file 
@@ -117,4 +117,9 @@
             IF(lwp) WRITE(numout,*) ' '
 
+            ! If FRS scheme is used, we assume that tidal is needed over the whole relaxation area      
+            IF( cn_dyn2d(ib_bdy) == 'frs' ) THEN   ;   ilen0(:) = idx_bdy(ib_bdy)%nblen   (:)
+            ELSE                                   ;   ilen0(:) = idx_bdy(ib_bdy)%nblenrim(:)
+            ENDIF
+
             ! Allocate space for tidal harmonics data - get size from BDY data arrays
             ! Allocate also slow varying data in the case of time splitting:
@@ -122,16 +127,16 @@
             ! -----------------------------------------------------------------------
             IF( ASSOCIATED(dta%ssh) ) THEN   ! we use bdy ssh on this mpi subdomain
-               isz = SIZE(dta%ssh)
-               ALLOCATE( td%ssh0( isz, nb_harmo, 2 ), td%ssh( isz, nb_harmo, 2 ), dta_bdy_s(ib_bdy)%ssh( isz ) )
+               !IF(lwp) WRITE(numout,*) '             nambdy_tide bdytides.F90 JCastillo Tide Update SSH: ', ilen0(1), SIZE(dta%ssh)
+               ALLOCATE( td%ssh0( ilen0(1), nb_harmo, 2 ), td%ssh( ilen0(1), nb_harmo, 2 ), dta_bdy_s(ib_bdy)%ssh( ilen0(1) ) )
                dta_bdy_s(ib_bdy)%ssh(:) = 0._wp   ! needed?
             ENDIF
             IF( ASSOCIATED(dta%u2d) ) THEN   ! we use bdy u2d on this mpi subdomain
-               isz = SIZE(dta%u2d)
-               ALLOCATE( td%u0  ( isz, nb_harmo, 2 ), td%u  ( isz, nb_harmo, 2 ), dta_bdy_s(ib_bdy)%u2d( isz ) )
+               !IF(lwp) WRITE(numout,*) '             nambdy_tide bdytides.F90 JCastillo Tide Update U: ', ilen0(2), SIZE(dta%u2d)
+               ALLOCATE( td%u0  ( ilen0(2), nb_harmo, 2 ), td%u  ( ilen0(2), nb_harmo, 2 ), dta_bdy_s(ib_bdy)%u2d( ilen0(2) ) )
                dta_bdy_s(ib_bdy)%u2d(:) = 0._wp   ! needed?
             ENDIF
             IF( ASSOCIATED(dta%v2d) ) THEN   ! we use bdy v2d on this mpi subdomain
-               isz = SIZE(dta%v2d)
-               ALLOCATE( td%v0  ( isz, nb_harmo, 2 ), td%v  ( isz, nb_harmo, 2 ), dta_bdy_s(ib_bdy)%v2d( isz ) )
+               !IF(lwp) WRITE(numout,*) '             nambdy_tide bdytides.F90 JCastillo Tide Update V: ', ilen0(3), SIZE(dta%v2d)
+               ALLOCATE( td%v0  ( ilen0(3), nb_harmo, 2 ), td%v  ( ilen0(3), nb_harmo, 2 ), dta_bdy_s(ib_bdy)%v2d( ilen0(3) ) )
                dta_bdy_s(ib_bdy)%v2d(:) = 0._wp   ! needed?
             ENDIF
@@ -147,4 +152,5 @@
                !
                ! SSH fields
+               IF( ASSOCIATED(dta%ssh) ) THEN   ! we use bdy ssh on this mpi subdomain
                   clfile = TRIM(filtide)//'_grid_T.nc'
                   CALL iom_open( clfile , inum ) 
@@ -153,5 +159,4 @@
                      CALL iom_get( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_z1', ztr(:,:) )
                      CALL iom_get( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_z2', zti(:,:) ) 
-                     IF( ASSOCIATED(dta%ssh) ) THEN   ! we use bdy ssh on this mpi subdomain
                      DO ib = 1, SIZE(dta%ssh)
                         ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -160,9 +165,10 @@
                         td%ssh0(ib,itide,2) = zti(ii,ij)
                      END DO
-                     ENDIF
                   END DO
                   CALL iom_close( inum )
+               END IF
                !
                ! U fields
+               IF( ASSOCIATED(dta%u2d) ) THEN   ! we use bdy u2d on this mpi subdomain
                   clfile = TRIM(filtide)//'_grid_U.nc'
                   CALL iom_open( clfile , inum ) 
@@ -171,5 +177,4 @@
                      CALL iom_get  ( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_u1', ztr(:,:) )
                      CALL iom_get  ( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_u2', zti(:,:) )
-                     IF( ASSOCIATED(dta%u2d) ) THEN   ! we use bdy u2d on this mpi subdomain
                      DO ib = 1, SIZE(dta%u2d)
                         ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -178,9 +183,10 @@
                         td%u0(ib,itide,2) = zti(ii,ij)
                      END DO
-                  END IF
                   END DO
-               CALL iom_close( inum )
+                  CALL iom_close( inum )
+               END IF
                !
                ! V fields
+               IF( ASSOCIATED(dta%v2d) ) THEN   ! we use bdy v2d on this mpi subdomain
                   clfile = TRIM(filtide)//'_grid_V.nc'
                   CALL iom_open( clfile , inum ) 
@@ -189,5 +195,4 @@
                      CALL iom_get  ( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_v1', ztr(:,:) )
                      CALL iom_get  ( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_v2', zti(:,:) )
-                     IF( ASSOCIATED(dta%v2d) ) THEN   ! we use bdy v2d on this mpi subdomain
                      DO ib = 1, SIZE(dta%v2d)
                         ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -196,7 +201,7 @@
                         td%v0(ib,itide,2) = zti(ii,ij)
                      END DO
-                  END IF
                   END DO
-               CALL iom_close( inum )
+                  CALL iom_close( inum )
+               END IF
                !
                DEALLOCATE( ztr, zti ) 
@@ -214,33 +219,30 @@
                   !                                                              ! SSH fields
                   IF( ASSOCIATED(dta%ssh) ) THEN   ! we use bdy ssh on this mpi subdomain
-                     isz = SIZE(dta%ssh)
                      clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_T.nc'
                      CALL iom_open( clfile, inum )
-                     CALL fld_map( inum, 'z1', dta_read(1:isz,1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) )
-                     td%ssh0(:,itide,1) = dta_read(1:isz,1,1)
-                     CALL fld_map( inum, 'z2', dta_read(1:isz,1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) )
-                     td%ssh0(:,itide,2) = dta_read(1:isz,1,1)
+                     CALL fld_map( inum, 'z1', dta_read(1:ilen0(1),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) )
+                     td%ssh0(:,itide,1) = dta_read(1:ilen0(1),1,1)
+                     CALL fld_map( inum, 'z2', dta_read(1:ilen0(1),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) )
+                     td%ssh0(:,itide,2) = dta_read(1:ilen0(1),1,1)
                      CALL iom_close( inum )
                   ENDIF
                   !                                                              ! U fields
                   IF( ASSOCIATED(dta%u2d) ) THEN   ! we use bdy u2d on this mpi subdomain
-                     isz = SIZE(dta%u2d)
                      clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_U.nc'
                      CALL iom_open( clfile, inum )
-                     CALL fld_map( inum, 'u1', dta_read(1:isz,1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) )
-                     td%u0(:,itide,1) = dta_read(1:isz,1,1)
-                     CALL fld_map( inum, 'u2', dta_read(1:isz,1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) )
-                     td%u0(:,itide,2) = dta_read(1:isz,1,1)
+                     CALL fld_map( inum, 'u1', dta_read(1:ilen0(2),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) )
+                     td%u0(:,itide,1) = dta_read(1:ilen0(2),1,1)
+                     CALL fld_map( inum, 'u2', dta_read(1:ilen0(2),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) )
+                     td%u0(:,itide,2) = dta_read(1:ilen0(2),1,1)
                      CALL iom_close( inum )
                   ENDIF
                   !                                                              ! V fields
                   IF( ASSOCIATED(dta%v2d) ) THEN   ! we use bdy v2d on this mpi subdomain
-                     isz = SIZE(dta%v2d)
                      clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_V.nc'
                      CALL iom_open( clfile, inum )
-                     CALL fld_map( inum, 'v1', dta_read(1:isz,1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) )
-                     td%v0(:,itide,1) = dta_read(1:isz,1,1)
-                     CALL fld_map( inum, 'v2', dta_read(1:isz,1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) )
-                     td%v0(:,itide,2) = dta_read(1:isz,1,1)
+                     CALL fld_map( inum, 'v1', dta_read(1:ilen0(3),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) )
+                     td%v0(:,itide,1) = dta_read(1:ilen0(3),1,1)
+                     CALL fld_map( inum, 'v2', dta_read(1:ilen0(3),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) )
+                     td%v0(:,itide,2) = dta_read(1:ilen0(3),1,1)
                      CALL iom_close( inum )
                   ENDIF
