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 2323 for trunk – NEMO

Changeset 2323 for trunk


Ignore:
Timestamp:
2010-10-27T16:26:04+02:00 (13 years ago)
Author:
smasson
Message:

bugfix: temporal shift in fldread in the trunk, see ticket:745

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/OPA_SRC/SBC/fldread.F90

    r1955 r2323  
    123123      INTEGER  ::   ireclast   ! last record to be read in the current year file 
    124124      INTEGER  ::   isecend    ! number of second since Jan. 1st 00h of nit000 year at nitend 
     125      INTEGER  ::   isecsbc    ! number of seconds between Jan. 1st 00h of nit000 year and the middle of sbc time step 
    125126      LOGICAL  ::   llnxtyr    ! open next year  file? 
    126127      LOGICAL  ::   llnxtmth   ! open next month file? 
     
    132133      ! 
    133134      imf = SIZE( sd ) 
     135      isecsbc = nsec_year + nsec1jan000 + NINT(0.5 * REAL(kn_fsbc - 1,wp) * rdttra(1))   ! centrered in the middle of sbc time step 
     136      ! 
    134137      !                                         ! ===================== ! 
    135138      DO jf = 1, imf                            !    LOOP OVER FIELD    ! 
    136139         !                                      ! ===================== ! 
    137140         ! 
    138          IF( kt == nit000 )   CALL fld_init( sd(jf) ) 
     141         IF( kt == nit000 )   CALL fld_init( kn_fsbc, sd(jf) ) 
    139142         ! 
    140143         ! read/update the after data? 
    141          IF( nsec_year + nsec1jan000 > sd(jf)%nswap_sec ) THEN  
     144         IF( isecsbc > sd(jf)%nswap_sec ) THEN  
    142145 
    143146            IF( sd(jf)%ln_tint ) THEN         ! time interpolation: swap before record field 
     
    148151 
    149152            ! update record informations 
    150             CALL fld_rec( sd(jf) ) 
     153            CALL fld_rec( kn_fsbc, sd(jf) ) 
    151154 
    152155            ! do we have to change the year/month/day of the forcing field??  
     
    277280               ENDIF 
    278281               ! 
    279                ztinta =  REAL( nsec_year + nsec1jan000 - sd(jf)%nrec_b(2), wp ) / REAL( sd(jf)%nrec_a(2) - sd(jf)%nrec_b(2), wp ) 
     282               ztinta =  REAL( isecsbc - sd(jf)%nrec_b(2), wp ) / REAL( sd(jf)%nrec_a(2) - sd(jf)%nrec_b(2), wp ) 
    280283               ztintb =  1. - ztinta 
    281284!CDIR COLLAPSE 
     
    302305 
    303306 
    304    SUBROUTINE fld_init( sdjf ) 
     307   SUBROUTINE fld_init( kn_fsbc, sdjf ) 
    305308      !!--------------------------------------------------------------------- 
    306309      !!                    ***  ROUTINE fld_init  *** 
     
    311314      !! ** Method  :    
    312315      !!---------------------------------------------------------------------- 
     316      INTEGER  , INTENT(in   ) ::   kn_fsbc     ! sbc computation period (in time step)  
    313317      TYPE(FLD), INTENT(inout) ::   sdjf        ! input field related variables 
    314318      !! 
     
    331335             
    332336      ! define record informations 
    333       CALL fld_rec( sdjf ) 
     337      CALL fld_rec( kn_fsbc, sdjf ) 
     338 
     339      ! Note: shifting time to be centrered in the middle of sbc time step impacts only nsec_* variables of the calendar  
    334340 
    335341      IF( sdjf%ln_tint ) THEN ! we need to read the previous record and we will put it in the current record structure 
     
    406412 
    407413 
    408    SUBROUTINE fld_rec( sdjf ) 
     414   SUBROUTINE fld_rec( kn_fsbc, sdjf ) 
    409415      !!--------------------------------------------------------------------- 
    410416      !!                    ***  ROUTINE fld_rec  *** 
     
    414420      !! ** Method  :    
    415421      !!---------------------------------------------------------------------- 
     422      INTEGER  , INTENT(in   ) ::   kn_fsbc     ! sbc computation period (in time step)  
    416423      TYPE(FLD), INTENT(inout) ::   sdjf        ! input field related variables 
    417424      !! 
     
    421428      INTEGER  ::   ifreq_sec   ! frequency mean (in seconds) 
    422429      !!---------------------------------------------------------------------- 
     430      ! 
     431      ! Note: shifting time to be centrered in the middle of sbc time step impacts only nsec_* variables of the calendar  
    423432      ! 
    424433      IF( sdjf%nfreqh == -1 ) THEN      ! monthly mean 
     
    458467         ELSE                                      ;   ztmp = REAL(nsec_year ,wp)   ! since 00h on Jan 1 of the current year 
    459468         ENDIF 
     469         ztmp = ztmp + 0.5 * REAL(kn_fsbc - 1, wp) * rdttra(1)   ! shift time to be centrered in the middle of sbc time step 
     470         ztmp = ztmp + 0.01 * rdttra(1)                          ! add 0.01 time step to avoid truncation error  
    460471         IF( sdjf%ln_tint ) THEN                ! time interpolation, shift by 1/2 record 
    461472            ! 
     
    471482            !       forcing record :  1     2     3 
    472483            !                    
    473             ztmp= ztmp / ifreq_sec + 0.5 
     484            ztmp = ztmp / REAL(ifreq_sec, wp) + 0.5 
    474485         ELSE                  
    475486            ! 
     
    485496            !       forcing record :  1     2     3 
    486497            !                             
    487             ztmp= ztmp / ifreq_sec 
     498            ztmp = ztmp / REAL(ifreq_sec, wp) 
    488499         ENDIF 
    489500         irec = 1 + INT( ztmp ) 
Note: See TracChangeset for help on using the changeset viewer.