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 7351 for branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90 – NEMO

Ignore:
Timestamp:
2016-11-28T17:04:10+01:00 (7 years ago)
Author:
emanuelaclementi
Message:

ticket #1805 step 3: /2016/dev_INGV_UKMO_2016 aligned to the trunk at revision 7161

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90

    r5930 r7351  
    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 
     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 
    3534 
    3635   IMPLICIT NONE 
     
    4241 
    4342   TYPE, PUBLIC ::   TIDES_DATA     !: Storage for external tidal harmonics data 
    44       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   ssh0       !: Tidal constituents : SSH0 (read in file) 
    45       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   u0         !: Tidal constituents : U0   (read in file) 
    46       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   v0         !: Tidal constituents : V0   (read in file) 
    47       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   ssh        !: Tidal constituents : SSH  (after nodal cor.) 
    48       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   u          !: Tidal constituents : U    (after nodal cor.) 
    49       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.) 
    5047   END TYPE TIDES_DATA 
    5148 
     
    5754   !!---------------------------------------------------------------------- 
    5855   !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
    59    !! $Id$  
     56   !! $Id$ 
    6057   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
    6158   !!---------------------------------------------------------------------- 
     
    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,*) 
     
    263260            ENDIF ! ln_bdytide_2ddta=.true. 
    264261            ! 
    265             IF ( ln_bdytide_conj ) THEN ! assume complex conjugate in data files 
     262            IF( ln_bdytide_conj ) THEN    ! assume complex conjugate in data files 
    266263               td%ssh0(:,:,2) = - td%ssh0(:,:,2) 
    267264               td%u0  (:,:,2) = - td%u0  (:,:,2) 
     
    274271            ALLOCATE( dta_bdy_s(ib_bdy)%u2d ( ilen0(2) ) ) 
    275272            ALLOCATE( dta_bdy_s(ib_bdy)%v2d ( ilen0(3) ) ) 
    276             dta_bdy_s(ib_bdy)%ssh(:) = 0.e0 
    277             dta_bdy_s(ib_bdy)%u2d(:) = 0.e0 
    278             dta_bdy_s(ib_bdy)%v2d(:) = 0.e0 
     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 
    279276            ! 
    280277         ENDIF ! nn_dyn2d_dta(ib_bdy) .ge. 2 
    281278         ! 
    282279      END DO ! loop on ib_bdy 
    283  
    284       IF( nn_timing == 1 ) CALL timing_stop('bdytide_init') 
    285  
     280      ! 
     281      IF( nn_timing == 1 )   CALL timing_stop('bdytide_init') 
     282      ! 
    286283   END SUBROUTINE bdytide_init 
    287284 
    288    SUBROUTINE bdytide_update ( kt, idx, dta, td, jit, time_offset ) 
     285 
     286   SUBROUTINE bdytide_update( kt, idx, dta, td, jit, time_offset ) 
    289287      !!---------------------------------------------------------------------- 
    290288      !!                 ***  SUBROUTINE bdytide_update  *** 
     
    293291      !!                 
    294292      !!---------------------------------------------------------------------- 
    295       INTEGER, INTENT( in )            ::   kt          ! Main timestep counter 
    296       TYPE(OBC_INDEX), INTENT( in )    ::   idx         ! OBC indices 
    297       TYPE(OBC_DATA),  INTENT(inout)  ::   dta         ! OBC external data 
    298       TYPE(TIDES_DATA),INTENT( inout ) ::   td          ! tidal harmonics data 
    299       INTEGER,INTENT(in),OPTIONAL      ::   jit         ! Barotropic timestep counter (for timesplitting option) 
    300       INTEGER,INTENT( in ), OPTIONAL  ::   time_offset ! time offset in units of timesteps. NB. if jit 
    301                                                         ! is present then units = subcycle timesteps. 
    302                                                         ! time_offset = 0  => get data at "now"    time level 
    303                                                         ! time_offset = -1 => get data at "before" time level 
    304                                                         ! time_offset = +1 => get data at "after"  time level 
    305                                                         ! etc. 
    306       !! 
    307       INTEGER, DIMENSION(3)            ::   ilen0       !: length of boundary data (from OBC arrays) 
    308       INTEGER                          :: itide, igrd, ib   ! dummy loop indices 
    309       INTEGER                          :: time_add          ! time offset in units of timesteps 
    310       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     
    311309      REAL(wp), DIMENSION(jpmax_harmo) :: z_sist, z_cost 
    312310      !!---------------------------------------------------------------------- 
    313  
    314       IF( nn_timing == 1 ) CALL timing_start('bdytide_update') 
    315  
     311      ! 
     312      IF( nn_timing == 1 )   CALL timing_start('bdytide_update') 
     313      ! 
    316314      ilen0(1) =  SIZE(td%ssh(:,1,1)) 
    317315      ilen0(2) =  SIZE(td%u(:,1,1)) 
     
    323321      ENDIF 
    324322 
    325       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 
    326324        ! 
    327         kt_tide = kt 
     325        kt_tide = kt - (nsec_day - 0.5_wp * rdt)/rdt 
    328326        ! 
    329327        IF(lwp) THEN 
     
    374372      END DO 
    375373      ! 
    376       IF( nn_timing == 1 ) CALL timing_stop('bdytide_update') 
     374      IF( nn_timing == 1 )   CALL timing_stop('bdytide_update') 
    377375      ! 
    378376   END SUBROUTINE bdytide_update 
     
    385383      !!                 
    386384      !!---------------------------------------------------------------------- 
    387       INTEGER, INTENT( in )            ::   kt          ! Main timestep counter 
    388       INTEGER, INTENT( in ),OPTIONAL  ::   kit         ! Barotropic timestep counter (for timesplitting option) 
    389       INTEGER, INTENT( in ),OPTIONAL  ::   time_offset ! time offset in units of timesteps. NB. if kit 
    390                                                         ! is present then units = subcycle timesteps. 
    391                                                         ! time_offset = 0  => get data at "now"    time level 
    392                                                         ! time_offset = -1 => get data at "before" time level 
    393                                                         ! time_offset = +1 => get data at "after"  time level 
    394                                                         ! etc. 
    395       !! 
    396       LOGICAL  :: lk_first_btstp  ! =.TRUE. if time splitting and first barotropic step 
    397       INTEGER, DIMENSION(jpbgrd) :: ilen0  
    398       INTEGER, DIMENSION(1:jpbgrd) :: nblen, nblenrim  ! short cuts 
    399       INTEGER  :: itide, ib_bdy, ib, igrd                     ! loop indices 
    400       INTEGER  :: time_add                                    ! time offset in units of timesteps 
    401       REAL(wp) :: z_arg, z_sarg, zramp, zoff, z_cost, z_sist       
    402       !!---------------------------------------------------------------------- 
    403  
    404       IF( nn_timing == 1 ) CALL timing_start('bdy_dta_tides') 
    405  
     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      ! 
    406404      lk_first_btstp=.TRUE. 
    407405      IF ( PRESENT(kit).AND.( kit /= 1 ) ) THEN ; lk_first_btstp=.FALSE. ; ENDIF 
     
    438436            ! We refresh nodal factors every day below 
    439437            ! This should be done somewhere else 
    440             IF ( nsec_day == NINT(0.5_wp * rdttra(1)) .AND. lk_first_btstp ) THEN 
    441                ! 
    442                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 
    443441               ! 
    444442               IF(lwp) THEN 
     
    502500   END SUBROUTINE bdy_dta_tides 
    503501 
     502 
    504503   SUBROUTINE tide_init_elevation( idx, td ) 
    505504      !!---------------------------------------------------------------------- 
    506505      !!                 ***  ROUTINE tide_init_elevation  *** 
    507506      !!---------------------------------------------------------------------- 
    508       TYPE(OBC_INDEX), INTENT( in )      ::   idx     ! OBC indices 
    509       TYPE(TIDES_DATA),INTENT( inout )   ::   td      ! tidal harmonics data 
    510       !! * Local declarations 
    511       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) 
    512512      REAL(wp),ALLOCATABLE, DIMENSION(:) ::   mod_tide, phi_tide 
    513       INTEGER                            ::   itide, igrd, ib      ! dummy loop indices 
    514  
     513      !!---------------------------------------------------------------------- 
     514      ! 
    515515      igrd=1    
    516516                              ! SSH on tracer grid. 
    517     
    518517      ilen0(1) =  SIZE(td%ssh0(:,1,1)) 
    519  
    520       ALLOCATE(mod_tide(ilen0(igrd)),phi_tide(ilen0(igrd))) 
    521  
     518      ! 
     519      ALLOCATE( mod_tide(ilen0(igrd)), phi_tide(ilen0(igrd)) ) 
     520      ! 
    522521      DO itide = 1, nb_harmo 
    523522         DO ib = 1, ilen0(igrd) 
     
    534533         ENDDO 
    535534      END DO 
    536  
    537       DEALLOCATE(mod_tide,phi_tide) 
    538  
     535      ! 
     536      DEALLOCATE( mod_tide, phi_tide ) 
     537      ! 
    539538   END SUBROUTINE tide_init_elevation 
    540539 
     540 
    541541   SUBROUTINE tide_init_velocities( idx, td ) 
    542542      !!---------------------------------------------------------------------- 
    543543      !!                 ***  ROUTINE tide_init_elevation  *** 
    544544      !!---------------------------------------------------------------------- 
    545       TYPE(OBC_INDEX), INTENT( in )      ::   idx     ! OBC indices 
    546       TYPE(TIDES_DATA),INTENT( inout )      ::   td      ! tidal harmonics data 
    547       !! * Local declarations 
    548       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) 
    549550      REAL(wp),ALLOCATABLE, DIMENSION(:) ::   mod_tide, phi_tide 
    550       INTEGER                            ::   itide, igrd, ib      ! dummy loop indices 
    551  
     551      !!---------------------------------------------------------------------- 
     552      ! 
    552553      ilen0(2) =  SIZE(td%u0(:,1,1)) 
    553554      ilen0(3) =  SIZE(td%v0(:,1,1)) 
    554  
     555      ! 
    555556      igrd=2                                 ! U grid. 
    556  
    557       ALLOCATE(mod_tide(ilen0(igrd)),phi_tide(ilen0(igrd))) 
    558  
     557      ! 
     558      ALLOCATE( mod_tide(ilen0(igrd)) , phi_tide(ilen0(igrd)) ) 
     559      ! 
    559560      DO itide = 1, nb_harmo 
    560561         DO ib = 1, ilen0(igrd) 
     
    571572         ENDDO 
    572573      END DO 
    573  
    574       DEALLOCATE(mod_tide,phi_tide) 
    575  
     574      ! 
     575      DEALLOCATE( mod_tide , phi_tide ) 
     576      ! 
    576577      igrd=3                                 ! V grid. 
    577  
    578       ALLOCATE(mod_tide(ilen0(igrd)),phi_tide(ilen0(igrd))) 
     578      ! 
     579      ALLOCATE( mod_tide(ilen0(igrd)) , phi_tide(ilen0(igrd)) ) 
    579580 
    580581      DO itide = 1, nb_harmo 
     
    592593         ENDDO 
    593594      END DO 
    594  
    595       DEALLOCATE(mod_tide,phi_tide) 
    596  
     595      ! 
     596      DEALLOCATE( mod_tide, phi_tide ) 
     597      ! 
    597598  END SUBROUTINE tide_init_velocities 
     599 
    598600#else 
    599601   !!---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.