New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 6225 for branches/2014/dev_r4704_NOC5_MPP_BDY_UPDATE/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90 – NEMO

Ignore:
Timestamp:
2016-01-08T10:35:19+01:00 (8 years ago)
Author:
jamesharle
Message:

Update MPP_BDY_UPDATE branch to be consistent with head of trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4704_NOC5_MPP_BDY_UPDATE/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90

    r4624 r6225  
    1515   !!   'key_bdy'     Open Boundary Condition 
    1616   !!---------------------------------------------------------------------- 
    17    !!   PUBLIC 
    18    !!      bdytide_init     : read of namelist and initialisation of tidal harmonics data 
    19    !!      tide_update   : calculation of tidal forcing at each timestep 
    20    !!---------------------------------------------------------------------- 
    21    USE timing          ! Timing 
    22    USE oce             ! ocean dynamics and tracers  
    23    USE dom_oce         ! ocean space and time domain 
    24    USE iom 
    25    USE in_out_manager  ! I/O units 
    26    USE phycst          ! physical constants 
    27    USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    28    USE bdy_par         ! Unstructured boundary parameters 
    29    USE bdy_oce         ! ocean open boundary conditions 
    30    USE daymod          ! calendar 
    31    USE wrk_nemo        ! Memory allocation 
    32    USE tideini 
    33 !   USE tide_mod       ! Useless ?? 
    34    USE fldread, ONLY: fld_map 
    35    USE dynspg_oce, ONLY: lk_dynspg_ts 
     17   !!   bdytide_init  : read of namelist and initialisation of tidal harmonics data 
     18   !!   tide_update   : calculation of tidal forcing at each timestep 
     19   !!---------------------------------------------------------------------- 
     20   USE oce            ! ocean dynamics and tracers  
     21   USE dom_oce        ! ocean space and time domain 
     22   USE phycst         ! physical constants 
     23   USE bdy_par        ! Unstructured boundary parameters 
     24   USE bdy_oce        ! ocean open boundary conditions 
     25   USE tideini        !  
     26   USE daymod         ! calendar 
     27   ! 
     28   USE in_out_manager ! I/O units 
     29   USE iom            ! xIO server 
     30   USE fldread        ! 
     31   USE lbclnk         ! ocean lateral boundary conditions (or mpp link) 
     32   USE wrk_nemo       ! Memory allocation 
     33   USE timing         ! timing 
    3634 
    3735   IMPLICIT NONE 
     
    4341 
    4442   TYPE, PUBLIC ::   TIDES_DATA     !: Storage for external tidal harmonics data 
    45       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   ssh0       !: Tidal constituents : SSH0 (read in file) 
    46       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   u0         !: Tidal constituents : U0   (read in file) 
    47       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   v0         !: Tidal constituents : V0   (read in file) 
    48       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   ssh        !: Tidal constituents : SSH  (after nodal cor.) 
    49       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   u          !: Tidal constituents : U    (after nodal cor.) 
    50       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   v          !: Tidal constituents : V    (after nodal cor.) 
     43      REAL(wp), POINTER, DIMENSION(:,:,:)    ::   ssh0     !: Tidal constituents : SSH0   (read in file) 
     44      REAL(wp), POINTER, DIMENSION(:,:,:)    ::   u0, v0   !: Tidal constituents : U0, V0 (read in file) 
     45      REAL(wp), POINTER, DIMENSION(:,:,:)    ::   ssh      !: Tidal constituents : SSH    (after nodal cor.) 
     46      REAL(wp), POINTER, DIMENSION(:,:,:)    ::   u , v    !: Tidal constituents : U , V  (after nodal cor.) 
    5147   END TYPE TIDES_DATA 
    5248 
     
    5450   TYPE(TIDES_DATA), PUBLIC, DIMENSION(jp_bdy), TARGET :: tides  !: External tidal harmonics data 
    5551!$AGRIF_END_DO_NOT_TREAT 
    56    TYPE(OBC_DATA)  , PRIVATE, DIMENSION(jp_bdy) :: dta_bdy_s  !: bdy external data (slow component) 
     52   TYPE(OBC_DATA)  , PUBLIC, DIMENSION(jp_bdy) :: dta_bdy_s  !: bdy external data (slow component) 
    5753 
    5854   !!---------------------------------------------------------------------- 
    5955   !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
    60    !! $Id$  
     56   !! $Id$ 
    6157   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
    6258   !!---------------------------------------------------------------------- 
     
    8884      !! 
    8985      TYPE(TIDES_DATA),  POINTER                ::   td                  !: local short cut    
     86      TYPE(MAP_POINTER), DIMENSION(jpbgrd)      ::   ibmap_ptr           !: array of pointers to nbmap 
    9087      !! 
    9188      NAMELIST/nambdy_tide/filtide, ln_bdytide_2ddta, ln_bdytide_conj 
    9289      !!---------------------------------------------------------------------- 
    93  
    94       IF( nn_timing == 1 ) CALL timing_start('bdytide_init') 
    95  
     90      ! 
     91      IF( nn_timing == 1 )   CALL timing_start('bdytide_init') 
     92      ! 
    9693      IF (nb_bdy>0) THEN 
    9794         IF(lwp) WRITE(numout,*) 
     
    125122            IF(lwp) WRITE(numout,*) '             Number of tidal components to read: ', nb_harmo 
    126123            IF(lwp) THEN  
    127                     WRITE(numout,*) '             Tidal cpt name    -     Phase speed (deg/hr)'             
     124                    WRITE(numout,*) '             Tidal components: '  
    128125               DO itide = 1, nb_harmo 
    129                   WRITE(numout,*)  '             ', Wave(ntide(itide))%cname_tide, omega_tide(itide)   
     126                  WRITE(numout,*)  '                 ', Wave(ntide(itide))%cname_tide  
    130127               END DO 
    131128            ENDIF  
     
    220217               !  
    221218               ALLOCATE( dta_read( MAXVAL(ilen0(1:3)), 1, 1 ) ) 
     219               ! 
     220               ! Set map structure 
     221               ibmap_ptr(1)%ptr => idx_bdy(ib_bdy)%nbmap(:,1) 
     222               ibmap_ptr(1)%ll_unstruc = ln_coords_file(ib_bdy) 
     223               ibmap_ptr(2)%ptr => idx_bdy(ib_bdy)%nbmap(:,2) 
     224               ibmap_ptr(2)%ll_unstruc = ln_coords_file(ib_bdy) 
     225               ibmap_ptr(3)%ptr => idx_bdy(ib_bdy)%nbmap(:,3) 
     226               ibmap_ptr(3)%ll_unstruc = ln_coords_file(ib_bdy) 
    222227 
    223228               ! Open files and read in tidal forcing data 
     
    228233                  clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_T.nc' 
    229234                  CALL iom_open( clfile, inum ) 
    230                   CALL fld_map( inum, 'z1' , dta_read(1:ilen0(1),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) ) 
     235                  CALL fld_map( inum, 'z1' , dta_read(1:ilen0(1),1:1,1:1) , 1,  ibmap_ptr(1) ) 
    231236                  td%ssh0(:,itide,1) = dta_read(1:ilen0(1),1,1) 
    232                   CALL fld_map( inum, 'z2' , dta_read(1:ilen0(1),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) ) 
     237                  CALL fld_map( inum, 'z2' , dta_read(1:ilen0(1),1:1,1:1) , 1,  ibmap_ptr(1) ) 
    233238                  td%ssh0(:,itide,2) = dta_read(1:ilen0(1),1,1) 
    234239                  CALL iom_close( inum ) 
     
    236241                  clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_U.nc' 
    237242                  CALL iom_open( clfile, inum ) 
    238                   CALL fld_map( inum, 'u1' , dta_read(1:ilen0(2),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) ) 
     243                  CALL fld_map( inum, 'u1' , dta_read(1:ilen0(2),1:1,1:1) , 1, ibmap_ptr(2) ) 
    239244                  td%u0(:,itide,1) = dta_read(1:ilen0(2),1,1) 
    240                   CALL fld_map( inum, 'u2' , dta_read(1:ilen0(2),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) ) 
     245                  CALL fld_map( inum, 'u2' , dta_read(1:ilen0(2),1:1,1:1) , 1, ibmap_ptr(2) ) 
    241246                  td%u0(:,itide,2) = dta_read(1:ilen0(2),1,1) 
    242247                  CALL iom_close( inum ) 
     
    244249                  clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_V.nc' 
    245250                  CALL iom_open( clfile, inum ) 
    246                   CALL fld_map( inum, 'v1' , dta_read(1:ilen0(3),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) ) 
     251                  CALL fld_map( inum, 'v1' , dta_read(1:ilen0(3),1:1,1:1) , 1, ibmap_ptr(3) ) 
    247252                  td%v0(:,itide,1) = dta_read(1:ilen0(3),1,1) 
    248                   CALL fld_map( inum, 'v2' , dta_read(1:ilen0(3),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) ) 
     253                  CALL fld_map( inum, 'v2' , dta_read(1:ilen0(3),1:1,1:1) , 1, ibmap_ptr(3) ) 
    249254                  td%v0(:,itide,2) = dta_read(1:ilen0(3),1,1) 
    250255                  CALL iom_close( inum ) 
     
    255260            ENDIF ! ln_bdytide_2ddta=.true. 
    256261            ! 
    257             IF ( ln_bdytide_conj ) THEN ! assume complex conjugate in data files 
     262            IF( ln_bdytide_conj ) THEN    ! assume complex conjugate in data files 
    258263               td%ssh0(:,:,2) = - td%ssh0(:,:,2) 
    259264               td%u0  (:,:,2) = - td%u0  (:,:,2) 
     
    261266            ENDIF 
    262267            ! 
    263             IF ( lk_dynspg_ts ) THEN ! Allocate arrays to save slowly varying boundary data during 
    264                                      ! time splitting integration 
    265                ALLOCATE( dta_bdy_s(ib_bdy)%ssh ( ilen0(1) ) ) 
    266                ALLOCATE( dta_bdy_s(ib_bdy)%u2d ( ilen0(2) ) ) 
    267                ALLOCATE( dta_bdy_s(ib_bdy)%v2d ( ilen0(3) ) ) 
    268                dta_bdy_s(ib_bdy)%ssh(:) = 0.e0 
    269                dta_bdy_s(ib_bdy)%u2d(:) = 0.e0 
    270                dta_bdy_s(ib_bdy)%v2d(:) = 0.e0 
    271             ENDIF 
     268            ! Allocate slow varying data in the case of time splitting: 
     269            ! Do it anyway because at this stage knowledge of free surface scheme is unknown 
     270            ALLOCATE( dta_bdy_s(ib_bdy)%ssh ( ilen0(1) ) ) 
     271            ALLOCATE( dta_bdy_s(ib_bdy)%u2d ( ilen0(2) ) ) 
     272            ALLOCATE( dta_bdy_s(ib_bdy)%v2d ( ilen0(3) ) ) 
     273            dta_bdy_s(ib_bdy)%ssh(:) = 0._wp 
     274            dta_bdy_s(ib_bdy)%u2d(:) = 0._wp 
     275            dta_bdy_s(ib_bdy)%v2d(:) = 0._wp 
    272276            ! 
    273277         ENDIF ! nn_dyn2d_dta(ib_bdy) .ge. 2 
    274278         ! 
    275279      END DO ! loop on ib_bdy 
    276  
    277       IF( nn_timing == 1 ) CALL timing_stop('bdytide_init') 
    278  
     280      ! 
     281      IF( nn_timing == 1 )   CALL timing_stop('bdytide_init') 
     282      ! 
    279283   END SUBROUTINE bdytide_init 
    280284 
    281    SUBROUTINE bdytide_update ( kt, idx, dta, td, jit, time_offset ) 
     285 
     286   SUBROUTINE bdytide_update( kt, idx, dta, td, jit, time_offset ) 
    282287      !!---------------------------------------------------------------------- 
    283288      !!                 ***  SUBROUTINE bdytide_update  *** 
     
    286291      !!                 
    287292      !!---------------------------------------------------------------------- 
    288       INTEGER, INTENT( in )            ::   kt          ! Main timestep counter 
    289       TYPE(OBC_INDEX), INTENT( in )    ::   idx         ! OBC indices 
    290       TYPE(OBC_DATA),  INTENT(inout)  ::   dta         ! OBC external data 
    291       TYPE(TIDES_DATA),INTENT( inout ) ::   td          ! tidal harmonics data 
    292       INTEGER,INTENT(in),OPTIONAL      ::   jit         ! Barotropic timestep counter (for timesplitting option) 
    293       INTEGER,INTENT( in ), OPTIONAL  ::   time_offset ! time offset in units of timesteps. NB. if jit 
    294                                                         ! is present then units = subcycle timesteps. 
    295                                                         ! time_offset = 0  => get data at "now"    time level 
    296                                                         ! time_offset = -1 => get data at "before" time level 
    297                                                         ! time_offset = +1 => get data at "after"  time level 
    298                                                         ! etc. 
    299       !! 
    300       INTEGER, DIMENSION(3)            ::   ilen0       !: length of boundary data (from OBC arrays) 
    301       INTEGER                          :: itide, igrd, ib   ! dummy loop indices 
    302       INTEGER                          :: time_add          ! time offset in units of timesteps 
    303       REAL(wp)                         :: z_arg, z_sarg, zflag, zramp       
     293      INTEGER          , INTENT(in   ) ::   kt          ! Main timestep counter 
     294      TYPE(OBC_INDEX)  , INTENT(in   ) ::   idx         ! OBC indices 
     295      TYPE(OBC_DATA)   , INTENT(inout) ::   dta         ! OBC external data 
     296      TYPE(TIDES_DATA) , INTENT(inout) ::   td          ! tidal harmonics data 
     297      INTEGER, OPTIONAL, INTENT(in   ) ::   jit         ! Barotropic timestep counter (for timesplitting option) 
     298      INTEGER, OPTIONAL, INTENT(in   ) ::   time_offset ! time offset in units of timesteps. NB. if jit 
     299      !                                                 ! is present then units = subcycle timesteps. 
     300      !                                                 ! time_offset = 0  => get data at "now"    time level 
     301      !                                                 ! time_offset = -1 => get data at "before" time level 
     302      !                                                 ! time_offset = +1 => get data at "after"  time level 
     303      !                                                 ! etc. 
     304      ! 
     305      INTEGER  ::   itide, igrd, ib       ! dummy loop indices 
     306      INTEGER  ::   time_add              ! time offset in units of timesteps 
     307      INTEGER, DIMENSION(3) ::   ilen0    ! length of boundary data (from OBC arrays) 
     308      REAL(wp) ::   z_arg, z_sarg, zflag, zramp   ! local scalars     
    304309      REAL(wp), DIMENSION(jpmax_harmo) :: z_sist, z_cost 
    305310      !!---------------------------------------------------------------------- 
    306  
    307       IF( nn_timing == 1 ) CALL timing_start('bdytide_update') 
    308  
     311      ! 
     312      IF( nn_timing == 1 )   CALL timing_start('bdytide_update') 
     313      ! 
    309314      ilen0(1) =  SIZE(td%ssh(:,1,1)) 
    310315      ilen0(2) =  SIZE(td%u(:,1,1)) 
     
    316321      ENDIF 
    317322 
    318       IF ( nsec_day == NINT(0.5_wp * rdttra(1)) .AND. zflag==1 ) THEN 
     323      IF ( (nsec_day == NINT(0.5_wp * rdt) .OR. kt==nit000) .AND. zflag==1 ) THEN 
    319324        ! 
    320         kt_tide = kt 
     325        kt_tide = kt - (nsec_day - 0.5_wp * rdt)/rdt 
    321326        ! 
    322327        IF(lwp) THEN 
     
    367372      END DO 
    368373      ! 
    369       IF( nn_timing == 1 ) CALL timing_stop('bdytide_update') 
     374      IF( nn_timing == 1 )   CALL timing_stop('bdytide_update') 
    370375      ! 
    371376   END SUBROUTINE bdytide_update 
     
    378383      !!                 
    379384      !!---------------------------------------------------------------------- 
    380       INTEGER, INTENT( in )            ::   kt          ! Main timestep counter 
    381       INTEGER, INTENT( in ),OPTIONAL  ::   kit         ! Barotropic timestep counter (for timesplitting option) 
    382       INTEGER, INTENT( in ),OPTIONAL  ::   time_offset ! time offset in units of timesteps. NB. if kit 
    383                                                         ! is present then units = subcycle timesteps. 
    384                                                         ! time_offset = 0  => get data at "now"    time level 
    385                                                         ! time_offset = -1 => get data at "before" time level 
    386                                                         ! time_offset = +1 => get data at "after"  time level 
    387                                                         ! etc. 
    388       !! 
    389       LOGICAL  :: lk_first_btstp  ! =.TRUE. if time splitting and first barotropic step 
    390       INTEGER,          DIMENSION(jpbgrd) :: ilen0  
    391       INTEGER, DIMENSION(1:jpbgrd) :: nblen, nblenrim  ! short cuts 
    392       INTEGER  :: itide, ib_bdy, ib, igrd                     ! loop indices 
    393       INTEGER  :: time_add                                    ! time offset in units of timesteps 
    394       REAL(wp) :: z_arg, z_sarg, zramp, zoff, z_cost, z_sist       
    395       !!---------------------------------------------------------------------- 
    396  
    397       IF( nn_timing == 1 ) CALL timing_start('bdy_dta_tides') 
    398  
     385      INTEGER,           INTENT(in) ::   kt          ! Main timestep counter 
     386      INTEGER, OPTIONAL, INTENT(in) ::   kit         ! Barotropic timestep counter (for timesplitting option) 
     387      INTEGER, OPTIONAL, INTENT(in) ::   time_offset ! time offset in units of timesteps. NB. if kit 
     388      !                                              ! is present then units = subcycle timesteps. 
     389      !                                              ! time_offset = 0  => get data at "now"    time level 
     390      !                                              ! time_offset = -1 => get data at "before" time level 
     391      !                                              ! time_offset = +1 => get data at "after"  time level 
     392      !                                              ! etc. 
     393      ! 
     394      LOGICAL  ::   lk_first_btstp            ! =.TRUE. if time splitting and first barotropic step 
     395      INTEGER  ::   itide, ib_bdy, ib, igrd   ! loop indices 
     396      INTEGER  ::   time_add                  ! time offset in units of timesteps 
     397      INTEGER, DIMENSION(jpbgrd)   ::   ilen0  
     398      INTEGER, DIMENSION(1:jpbgrd) ::   nblen, nblenrim  ! short cuts 
     399      REAL(wp) ::   z_arg, z_sarg, zramp, zoff, z_cost, z_sist       
     400      !!---------------------------------------------------------------------- 
     401      ! 
     402      IF( nn_timing == 1 )   CALL timing_start('bdy_dta_tides') 
     403      ! 
    399404      lk_first_btstp=.TRUE. 
    400405      IF ( PRESENT(kit).AND.( kit /= 1 ) ) THEN ; lk_first_btstp=.FALSE. ; ENDIF 
     
    407412      ! Absolute time from model initialization:    
    408413      IF( PRESENT(kit) ) THEN   
    409          z_arg = ( kt + (kit+0.5_wp*(time_add-1)) / REAL(nn_baro,wp) ) * rdt 
     414         z_arg = ( kt + (kit+time_add-1) / REAL(nn_baro,wp) ) * rdt 
    410415      ELSE                               
    411416         z_arg = ( kt + time_add ) * rdt 
     
    418423      DO ib_bdy = 1,nb_bdy 
    419424 
    420          ! line below should be simplified (runoff case) 
    421 !! CHANUT: TO BE SORTED OUT 
    422 !!         IF (( nn_dyn2d_dta(ib_bdy) .ge. 2 ).AND.(nn_tra(ib_bdy).NE.4)) THEN 
    423425         IF ( nn_dyn2d_dta(ib_bdy) .ge. 2 ) THEN 
    424426 
     
    434436            ! We refresh nodal factors every day below 
    435437            ! This should be done somewhere else 
    436             IF ( nsec_day == NINT(0.5_wp * rdttra(1)) .AND. lk_first_btstp ) THEN 
    437                ! 
    438                kt_tide = kt                
     438            IF ( ( nsec_day == NINT(0.5_wp * rdt) .OR. kt==nit000 ) .AND. lk_first_btstp ) THEN 
     439               ! 
     440               kt_tide = kt - (nsec_day - 0.5_wp * rdt)/rdt 
    439441               ! 
    440442               IF(lwp) THEN 
     
    450452            zoff = -kt_tide * rdt ! time offset relative to nodal factor computation time 
    451453            ! 
    452             ! If time splitting, save data at first barotropic iteration 
    453             IF ( PRESENT(kit) ) THEN 
    454                IF ( lk_first_btstp ) THEN ! Save slow varying open boundary data: 
    455                   dta_bdy_s(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy(ib_bdy)%ssh(1:ilen0(1)) 
    456                   dta_bdy_s(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy(ib_bdy)%u2d(1:ilen0(2)) 
    457                   dta_bdy_s(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy(ib_bdy)%v2d(1:ilen0(3)) 
    458  
    459                ELSE ! Initialize arrays from slow varying open boundary data:             
    460                   dta_bdy(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy_s(ib_bdy)%ssh(1:ilen0(1)) 
    461                   dta_bdy(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy_s(ib_bdy)%u2d(1:ilen0(2)) 
    462                   dta_bdy(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy_s(ib_bdy)%v2d(1:ilen0(3)) 
    463                ENDIF 
     454            ! If time splitting, initialize arrays from slow varying open boundary data: 
     455            IF ( PRESENT(kit) ) THEN            
     456               IF ( dta_bdy(ib_bdy)%ll_ssh ) dta_bdy(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy_s(ib_bdy)%ssh(1:ilen0(1)) 
     457               IF ( dta_bdy(ib_bdy)%ll_u2d ) dta_bdy(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy_s(ib_bdy)%u2d(1:ilen0(2)) 
     458               IF ( dta_bdy(ib_bdy)%ll_v2d ) dta_bdy(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy_s(ib_bdy)%v2d(1:ilen0(3)) 
    464459            ENDIF 
    465460            ! 
     
    471466               z_sist = zramp * SIN( z_sarg ) 
    472467               ! 
    473                igrd=1                              ! SSH on tracer grid 
    474                DO ib = 1, ilen0(igrd) 
    475                   dta_bdy(ib_bdy)%ssh(ib) = dta_bdy(ib_bdy)%ssh(ib) + & 
    476                      &                      ( tides(ib_bdy)%ssh(ib,itide,1)*z_cost + & 
    477                      &                        tides(ib_bdy)%ssh(ib,itide,2)*z_sist ) 
    478                END DO 
    479                ! 
    480                igrd=2                              ! U grid 
    481                DO ib = 1, ilen0(igrd) 
    482                   dta_bdy(ib_bdy)%u2d(ib) = dta_bdy(ib_bdy)%u2d(ib) + & 
    483                      &                      ( tides(ib_bdy)%u(ib,itide,1)*z_cost + & 
    484                      &                        tides(ib_bdy)%u(ib,itide,2)*z_sist ) 
    485                END DO 
    486                ! 
    487                igrd=3                              ! V grid 
    488                DO ib = 1, ilen0(igrd)  
    489                   dta_bdy(ib_bdy)%v2d(ib) = dta_bdy(ib_bdy)%v2d(ib) + & 
    490                      &                      ( tides(ib_bdy)%v(ib,itide,1)*z_cost + & 
    491                      &                        tides(ib_bdy)%v(ib,itide,2)*z_sist ) 
    492                END DO 
    493             END DO 
     468               IF ( dta_bdy(ib_bdy)%ll_ssh ) THEN 
     469                  igrd=1                              ! SSH on tracer grid 
     470                  DO ib = 1, ilen0(igrd) 
     471                     dta_bdy(ib_bdy)%ssh(ib) = dta_bdy(ib_bdy)%ssh(ib) + & 
     472                        &                      ( tides(ib_bdy)%ssh(ib,itide,1)*z_cost + & 
     473                        &                        tides(ib_bdy)%ssh(ib,itide,2)*z_sist ) 
     474                  END DO 
     475               ENDIF 
     476               ! 
     477               IF ( dta_bdy(ib_bdy)%ll_u2d ) THEN 
     478                  igrd=2                              ! U grid 
     479                  DO ib = 1, ilen0(igrd) 
     480                     dta_bdy(ib_bdy)%u2d(ib) = dta_bdy(ib_bdy)%u2d(ib) + & 
     481                        &                      ( tides(ib_bdy)%u(ib,itide,1)*z_cost + & 
     482                        &                        tides(ib_bdy)%u(ib,itide,2)*z_sist ) 
     483                  END DO 
     484               ENDIF 
     485               ! 
     486               IF ( dta_bdy(ib_bdy)%ll_v2d ) THEN 
     487                  igrd=3                              ! V grid 
     488                  DO ib = 1, ilen0(igrd)  
     489                     dta_bdy(ib_bdy)%v2d(ib) = dta_bdy(ib_bdy)%v2d(ib) + & 
     490                        &                      ( tides(ib_bdy)%v(ib,itide,1)*z_cost + & 
     491                        &                        tides(ib_bdy)%v(ib,itide,2)*z_sist ) 
     492                  END DO 
     493               ENDIF 
     494            END DO              
    494495         END IF 
    495496      END DO 
     
    499500   END SUBROUTINE bdy_dta_tides 
    500501 
     502 
    501503   SUBROUTINE tide_init_elevation( idx, td ) 
    502504      !!---------------------------------------------------------------------- 
    503505      !!                 ***  ROUTINE tide_init_elevation  *** 
    504506      !!---------------------------------------------------------------------- 
    505       TYPE(OBC_INDEX), INTENT( in )      ::   idx     ! OBC indices 
    506       TYPE(TIDES_DATA),INTENT( inout )   ::   td      ! tidal harmonics data 
    507       !! * Local declarations 
    508       INTEGER, DIMENSION(1)            ::   ilen0       !: length of boundary data (from OBC arrays) 
     507      TYPE(OBC_INDEX) , INTENT(in   ) ::   idx   ! OBC indices 
     508      TYPE(TIDES_DATA), INTENT(inout) ::   td    ! tidal harmonics data 
     509      ! 
     510      INTEGER ::   itide, igrd, ib       ! dummy loop indices 
     511      INTEGER, DIMENSION(1) ::   ilen0   ! length of boundary data (from OBC arrays) 
    509512      REAL(wp),ALLOCATABLE, DIMENSION(:) ::   mod_tide, phi_tide 
    510       INTEGER                            ::   itide, igrd, ib      ! dummy loop indices 
    511  
     513      !!---------------------------------------------------------------------- 
     514      ! 
    512515      igrd=1    
    513516                              ! SSH on tracer grid. 
    514     
    515517      ilen0(1) =  SIZE(td%ssh0(:,1,1)) 
    516  
    517       ALLOCATE(mod_tide(ilen0(igrd)),phi_tide(ilen0(igrd))) 
    518  
     518      ! 
     519      ALLOCATE( mod_tide(ilen0(igrd)), phi_tide(ilen0(igrd)) ) 
     520      ! 
    519521      DO itide = 1, nb_harmo 
    520522         DO ib = 1, ilen0(igrd) 
     
    531533         ENDDO 
    532534      END DO 
    533  
    534       DEALLOCATE(mod_tide,phi_tide) 
    535  
     535      ! 
     536      DEALLOCATE( mod_tide, phi_tide ) 
     537      ! 
    536538   END SUBROUTINE tide_init_elevation 
    537539 
     540 
    538541   SUBROUTINE tide_init_velocities( idx, td ) 
    539542      !!---------------------------------------------------------------------- 
    540543      !!                 ***  ROUTINE tide_init_elevation  *** 
    541544      !!---------------------------------------------------------------------- 
    542       TYPE(OBC_INDEX), INTENT( in )      ::   idx     ! OBC indices 
    543       TYPE(TIDES_DATA),INTENT( inout )      ::   td      ! tidal harmonics data 
    544       !! * Local declarations 
    545       INTEGER, DIMENSION(3)            ::   ilen0       !: length of boundary data (from OBC arrays) 
     545      TYPE(OBC_INDEX) , INTENT(in   ) ::   idx   ! OBC indices 
     546      TYPE(TIDES_DATA), INTENT(inout) ::   td    ! tidal harmonics data 
     547      ! 
     548      INTEGER ::   itide, igrd, ib       ! dummy loop indices 
     549      INTEGER, DIMENSION(3) ::   ilen0   ! length of boundary data (from OBC arrays) 
    546550      REAL(wp),ALLOCATABLE, DIMENSION(:) ::   mod_tide, phi_tide 
    547       INTEGER                            ::   itide, igrd, ib      ! dummy loop indices 
    548  
     551      !!---------------------------------------------------------------------- 
     552      ! 
    549553      ilen0(2) =  SIZE(td%u0(:,1,1)) 
    550554      ilen0(3) =  SIZE(td%v0(:,1,1)) 
    551  
     555      ! 
    552556      igrd=2                                 ! U grid. 
    553  
    554       ALLOCATE(mod_tide(ilen0(igrd)),phi_tide(ilen0(igrd))) 
    555  
     557      ! 
     558      ALLOCATE( mod_tide(ilen0(igrd)) , phi_tide(ilen0(igrd)) ) 
     559      ! 
    556560      DO itide = 1, nb_harmo 
    557561         DO ib = 1, ilen0(igrd) 
     
    568572         ENDDO 
    569573      END DO 
    570  
    571       DEALLOCATE(mod_tide,phi_tide) 
    572  
     574      ! 
     575      DEALLOCATE( mod_tide , phi_tide ) 
     576      ! 
    573577      igrd=3                                 ! V grid. 
    574  
    575       ALLOCATE(mod_tide(ilen0(igrd)),phi_tide(ilen0(igrd))) 
     578      ! 
     579      ALLOCATE( mod_tide(ilen0(igrd)) , phi_tide(ilen0(igrd)) ) 
    576580 
    577581      DO itide = 1, nb_harmo 
     
    589593         ENDDO 
    590594      END DO 
    591  
    592       DEALLOCATE(mod_tide,phi_tide) 
    593  
     595      ! 
     596      DEALLOCATE( mod_tide, phi_tide ) 
     597      ! 
    594598  END SUBROUTINE tide_init_velocities 
     599 
    595600#else 
    596601   !!---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.