Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytides.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytides.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytides.F90	(revision 12143)
@@ -70,5 +70,4 @@
       INTEGER                                   ::   inum, igrd
       INTEGER, DIMENSION(3)                     ::   ilen0       !: length of boundary data (from OBC arrays)
-      INTEGER, POINTER, DIMENSION(:)            ::   nblen, nblenrim     ! short cuts
       INTEGER                                   ::   ios                 ! Local integer output status for namelist read
       CHARACTER(len=80)                         ::   clfile              !: full file name for tidal input file 
@@ -77,14 +76,11 @@
       !!
       TYPE(TIDES_DATA),  POINTER                ::   td                  !: local short cut   
-      TYPE(MAP_POINTER), DIMENSION(jpbgrd)      ::   ibmap_ptr           !: array of pointers to nbmap
       !!
       NAMELIST/nambdy_tide/filtide, ln_bdytide_2ddta, ln_bdytide_conj
       !!----------------------------------------------------------------------
       !
-      IF (nb_bdy>0) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'bdytide_init : initialization of tidal harmonic forcing at open boundaries'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
-      ENDIF
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'bdytide_init : initialization of tidal harmonic forcing at open boundaries'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
 
       REWIND(numnam_cfg)
@@ -94,15 +90,14 @@
             !
             td => tides(ib_bdy)
-            nblen => idx_bdy(ib_bdy)%nblen
-            nblenrim => idx_bdy(ib_bdy)%nblenrim
 
             ! Namelist nambdy_tide : tidal harmonic forcing at open boundaries
             filtide(:) = ''
 
+            REWIND( numnam_ref )
+            READ  ( numnam_ref, nambdy_tide, IOSTAT = ios, ERR = 901)
+901         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_tide in reference namelist' )
             ! Don't REWIND here - may need to read more than one of these namelists. 
-            READ  ( numnam_ref, nambdy_tide, IOSTAT = ios, ERR = 901)
-901         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_tide in reference namelist', lwp )
             READ  ( numnam_cfg, nambdy_tide, IOSTAT = ios, ERR = 902 )
-902         IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy_tide in configuration namelist', lwp )
+902         IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy_tide in configuration namelist' )
             IF(lwm) WRITE ( numond, nambdy_tide )
             !                                               ! Parameter control and print
@@ -125,6 +120,6 @@
             ! JC: If FRS scheme is used, we assume that tidal is needed over the whole
             ! relaxation area      
-            IF( cn_dyn2d(ib_bdy) == 'frs' ) THEN   ;   ilen0(:) = nblen   (:)
-            ELSE                                   ;   ilen0(:) = nblenrim(:)
+            IF( cn_dyn2d(ib_bdy) == 'frs' ) THEN   ;   ilen0(:) = idx_bdy(ib_bdy)%nblen   (:)
+            ELSE                                   ;   ilen0(:) = idx_bdy(ib_bdy)%nblenrim(:)
             ENDIF
 
@@ -161,4 +156,5 @@
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
                      ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+                     IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! to remove?
                      td%ssh0(ib,itide,1) = ztr(ii,ij)
                      td%ssh0(ib,itide,2) = zti(ii,ij)
@@ -177,4 +173,5 @@
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
                      ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+                     IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! to remove?
                      td%u0(ib,itide,1) = ztr(ii,ij)
                      td%u0(ib,itide,2) = zti(ii,ij)
@@ -193,4 +190,5 @@
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
                      ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+                     IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! to remove?
                      td%v0(ib,itide,1) = ztr(ii,ij)
                      td%v0(ib,itide,2) = zti(ii,ij)
@@ -207,9 +205,4 @@
                ALLOCATE( dta_read( MAXVAL(ilen0(1:3)), 1, 1 ) )
                !
-               ! Set map structure
-               ibmap_ptr(1)%ptr => idx_bdy(ib_bdy)%nbmap(:,1)   ;   ibmap_ptr(1)%ll_unstruc = ln_coords_file(ib_bdy)
-               ibmap_ptr(2)%ptr => idx_bdy(ib_bdy)%nbmap(:,2)   ;   ibmap_ptr(2)%ll_unstruc = ln_coords_file(ib_bdy)
-               ibmap_ptr(3)%ptr => idx_bdy(ib_bdy)%nbmap(:,3)   ;   ibmap_ptr(3)%ll_unstruc = ln_coords_file(ib_bdy)
-
                ! Open files and read in tidal forcing data
                ! -----------------------------------------
@@ -219,7 +212,7 @@
                   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:ilen0(1),1:1,1:1) , 1,  ibmap_ptr(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,  ibmap_ptr(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 )
@@ -227,7 +220,7 @@
                   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:ilen0(2),1:1,1:1) , 1, ibmap_ptr(2) )
+                  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, ibmap_ptr(2) )
+                  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 )
@@ -235,7 +228,7 @@
                   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:ilen0(3),1:1,1:1) , 1, ibmap_ptr(3) )
+                  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, ibmap_ptr(3) )
+                  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 )
@@ -269,5 +262,5 @@
 
 
-   SUBROUTINE bdytide_update( kt, idx, dta, td, jit, time_offset )
+   SUBROUTINE bdytide_update( kt, idx, dta, td, kit, kt_offset )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdytide_update  ***
@@ -280,10 +273,10 @@
       TYPE(OBC_DATA)   , INTENT(inout) ::   dta         ! OBC external data
       TYPE(TIDES_DATA) , INTENT(inout) ::   td          ! tidal harmonics data
-      INTEGER, OPTIONAL, INTENT(in   ) ::   jit         ! Barotropic timestep counter (for timesplitting option)
-      INTEGER, OPTIONAL, INTENT(in   ) ::   time_offset ! time offset in units of timesteps. NB. if jit
+      INTEGER, OPTIONAL, INTENT(in   ) ::   kit         ! Barotropic timestep counter (for timesplitting option)
+      INTEGER, OPTIONAL, INTENT(in   ) ::   kt_offset   ! time offset in units of timesteps. NB. if kit
       !                                                 ! is present then units = subcycle timesteps.
-      !                                                 ! time_offset = 0  => get data at "now"    time level
-      !                                                 ! time_offset = -1 => get data at "before" time level
-      !                                                 ! time_offset = +1 => get data at "after"  time level
+      !                                                 ! kt_offset = 0  => get data at "now"    time level
+      !                                                 ! kt_offset = -1 => get data at "before" time level
+      !                                                 ! kt_offset = +1 => get data at "after"  time level
       !                                                 ! etc.
       !
@@ -300,6 +293,6 @@
 
       zflag=1
-      IF ( PRESENT(jit) ) THEN
-        IF ( jit /= 1 ) zflag=0
+      IF ( PRESENT(kit) ) THEN
+        IF ( kit /= 1 ) zflag=0
       ENDIF
 
@@ -320,10 +313,10 @@
 
       time_add = 0
-      IF( PRESENT(time_offset) ) THEN
-         time_add = time_offset
+      IF( PRESENT(kt_offset) ) THEN
+         time_add = kt_offset
       ENDIF
          
-      IF( PRESENT(jit) ) THEN  
-         z_arg = ((kt-kt_tide) * rdt + (jit+0.5_wp*(time_add-1)) * rdt / REAL(nn_baro,wp) )
+      IF( PRESENT(kit) ) THEN  
+         z_arg = ((kt-kt_tide) * rdt + (kit+0.5_wp*(time_add-1)) * rdt / REAL(nn_baro,wp) )
       ELSE                              
          z_arg = ((kt-kt_tide)+time_add) * rdt
@@ -358,5 +351,5 @@
 
 
-   SUBROUTINE bdy_dta_tides( kt, kit, time_offset )
+   SUBROUTINE bdy_dta_tides( kt, kit, kt_offset )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_dta_tides  ***
@@ -367,9 +360,9 @@
       INTEGER,           INTENT(in) ::   kt          ! Main timestep counter
       INTEGER, OPTIONAL, INTENT(in) ::   kit         ! Barotropic timestep counter (for timesplitting option)
-      INTEGER, OPTIONAL, INTENT(in) ::   time_offset ! time offset in units of timesteps. NB. if kit
+      INTEGER, OPTIONAL, INTENT(in) ::   kt_offset   ! time offset in units of timesteps. NB. if kit
       !                                              ! is present then units = subcycle timesteps.
-      !                                              ! time_offset = 0  => get data at "now"    time level
-      !                                              ! time_offset = -1 => get data at "before" time level
-      !                                              ! time_offset = +1 => get data at "after"  time level
+      !                                              ! kt_offset = 0  => get data at "now"    time level
+      !                                              ! kt_offset = -1 => get data at "before" time level
+      !                                              ! kt_offset = +1 => get data at "after"  time level
       !                                              ! etc.
       !
@@ -386,6 +379,6 @@
 
       time_add = 0
-      IF( PRESENT(time_offset) ) THEN
-         time_add = time_offset
+      IF( PRESENT(kt_offset) ) THEN
+         time_add = kt_offset
       ENDIF
       
@@ -432,7 +425,7 @@
             ! If time splitting, initialize arrays from slow varying open boundary data:
             IF ( PRESENT(kit) ) THEN           
-               IF ( dta_bdy(ib_bdy)%ll_ssh ) dta_bdy(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy_s(ib_bdy)%ssh(1:ilen0(1))
-               IF ( dta_bdy(ib_bdy)%ll_u2d ) dta_bdy(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy_s(ib_bdy)%u2d(1:ilen0(2))
-               IF ( dta_bdy(ib_bdy)%ll_v2d ) dta_bdy(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy_s(ib_bdy)%v2d(1:ilen0(3))
+               IF ( dta_bdy(ib_bdy)%lneed_ssh   ) dta_bdy(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy_s(ib_bdy)%ssh(1:ilen0(1))
+               IF ( dta_bdy(ib_bdy)%lneed_dyn2d ) dta_bdy(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy_s(ib_bdy)%u2d(1:ilen0(2))
+               IF ( dta_bdy(ib_bdy)%lneed_dyn2d ) dta_bdy(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy_s(ib_bdy)%v2d(1:ilen0(3))
             ENDIF
             !
@@ -444,5 +437,5 @@
                z_sist = zramp * SIN( z_sarg )
                !
-               IF ( dta_bdy(ib_bdy)%ll_ssh ) THEN
+               IF ( dta_bdy(ib_bdy)%lneed_ssh ) THEN
                   igrd=1                              ! SSH on tracer grid
                   DO ib = 1, ilen0(igrd)
@@ -453,5 +446,5 @@
                ENDIF
                !
-               IF ( dta_bdy(ib_bdy)%ll_u2d ) THEN
+               IF ( dta_bdy(ib_bdy)%lneed_dyn2d ) THEN
                   igrd=2                              ! U grid
                   DO ib = 1, ilen0(igrd)
@@ -460,7 +453,4 @@
                         &                        tides(ib_bdy)%u(ib,itide,2)*z_sist )
                   END DO
-               ENDIF
-               !
-               IF ( dta_bdy(ib_bdy)%ll_v2d ) THEN
                   igrd=3                              ! V grid
                   DO ib = 1, ilen0(igrd) 
