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 5164 – NEMO

Changeset 5164


Ignore:
Timestamp:
2015-03-24T16:18:32+01:00 (9 years ago)
Author:
timgraham
Message:

Fixed initial calculation of nsec_day, nsec_month,nsec_week,nsec_year

Location:
branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90

    r5075 r5164  
    9090      nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 ) 
    9191 
    92       CALL ymds2ju( nyear, nmonth, nday, nn_time0*3600._wp, fjulday )  ! we assume that we start run at 00:00 
     92      CALL ymds2ju( nyear, nmonth, nday, nn_time0*3600._wp, fjulday )   
    9393      IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < 0.1 / rday )   fjulday = REAL(NINT(fjulday),wp)   ! avoid truncation error 
    94       IF( nn_time0 == 0 ) fjulday = fjulday + 1.                       ! move back to the day at nit000 (and not at nit000 - 1) 
     94      IF( nn_time0*3600 - ndt05 .lt. 0 ) fjulday = fjulday + 1.                    ! move back to the day at nit000 (and not at nit000 - 1) 
    9595 
    9696      nsec1jan000 = 0 
     
    113113      !compute number of days between last monday and today 
    114114      CALL ymds2ju( 1900, 01, 01, 0.0, zjul )  ! compute julian day value of 01.01.1900 (our reference that was a Monday) 
    115       inbday = NINT(fjulday - zjul)            ! compute nb day between  01.01.1900 and current day 
     115      inbday = FLOOR(fjulday - zjul)            ! compute nb day between  01.01.1900 and start of current day 
    116116      idweek = MOD(inbday, 7)                  ! compute nb day between last monday and current day 
     117      IF (idweek .lt. 0) idweek=idweek+7       ! Avoid negative values for dates before 01.01.1900 
    117118 
    118119      ! number of seconds since the beginning of current year/month/week/day at the middle of the time-step 
    119       nsec_year  = nday_year * nsecd + nn_time0*3600._wp - ndt05   ! 1 time step before the middle of the first time step 
    120       nsec_month = nday      * nsecd + nn_time0*3600._wp - ndt05   ! because day will be called at the beginning of step 
     120      IF (nn_time0*3600-ndt05 .gt. 0) THEN 
     121         ! 1 timestep before current middle of first time step is still the same day 
     122         nsec_year  = (nday_year-1) * nsecd + nn_time0*3600._wp - ndt05  
     123         nsec_month = (nday-1)      * nsecd + nn_time0*3600._wp - ndt05     
     124      ELSE 
     125         ! 1 time step before the middle of the first time step is the previous day  
     126         nsec_year  = nday_year * nsecd + nn_time0*3600._wp - ndt05  
     127         nsec_month = nday      * nsecd + nn_time0*3600._wp - ndt05    
     128      ENDIF 
    121129      nsec_week  = idweek    * nsecd + nn_time0*3600._wp - ndt05 
    122       nsec_day   =             nsecd + nn_time0*3600._wp - ndt05 
     130      nsec_day   =             nn_time0*3600._wp - ndt05  
    123131      IF( nsec_day .lt. 0 ) nsec_day = nsec_day + nsecd 
    124        
     132      IF( nsec_week .lt. 0 ) nsec_week = nsec_week + nsecd*7 
     133 
    125134      ! control print 
    126       IF(lwp) WRITE(numout,'(a,i6,a,i2,a,i2,a,i8,a,i8)')' =======>> 1/2 time step before the start of the run DATE Y/M/D = ',   & 
    127            &                   nyear, '/', nmonth, '/', nday, '  nsec_day:', nsec_day, '  nsec_week:', nsec_week 
     135      IF(lwp) WRITE(numout,'(a,i6,a,i2,a,i2,a,i8,a,i8,a,i8,a,i8)')' =======>> 1/2 time step before the start of the run DATE Y/M/D = ',   & 
     136           &                   nyear, '/', nmonth, '/', nday, '  nsec_day:', nsec_day, '  nsec_week:', nsec_week, '  & 
     137           &                   nsec_month:', nsec_month , '  nsec_year:' , nsec_year 
    128138 
    129139      ! Up to now, calendar parameters are related to the end of previous run (nit000-1) 
     
    335345               ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day) 
    336346               ndastp = ndate0        ! ndate0 read in the namelist in dom_nam 
     347               IF( nn_time0*3600-ndt05 .lt. 0 )  ndastp=ndastp-1      ! Start hour is specified in the namelist (default 0) 
    337348               adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 
    338349               ! note this is wrong if time step has changed during run 
     
    341352            ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day) 
    342353            ndastp = ndate0           ! ndate0 read in the namelist in dom_nam 
     354            IF( nn_time0*3600-ndt05 .lt. 0 )  ndastp=ndastp-1      ! Start hour is specified in the namelist (default 0) 
    343355            adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 
    344356         ENDIF 
    345          IF( nn_time0 == 0 )  ndastp=ndastp-1      ! Start hour is specified in the namelist (default 0) 
    346357         IF( ABS(adatrj  - REAL(NINT(adatrj),wp)) < 0.1 / rday )   adatrj = REAL(NINT(adatrj),wp)   ! avoid truncation error 
    347358         ! 
  • branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/SBC/sbctide.F90

    r4292 r5164  
    4949      !!---------------------------------------------------------------------- 
    5050 
    51       IF( nsec_day == NINT(0.5_wp * rdttra(1)) ) THEN      ! start a new day 
     51      IF( nsec_day == NINT(0.5_wp * rdttra(1))  ) THEN      ! start a new day 
    5252         ! 
    5353         IF( kt == nit000 ) THEN 
Note: See TracChangeset for help on using the changeset viewer.