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 3764 for branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90 – NEMO

Ignore:
Timestamp:
2013-01-23T15:33:04+01:00 (11 years ago)
Author:
smasson
Message:

dev_MERGE_2012: report bugfixes done in the trunk from r3555 to r3763 into dev_MERGE_2012

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90

    r3680 r3764  
    22   !!====================================================================== 
    33   !!                       ***  MODULE  daymod  *** 
    4    !! Ocean        :  calendar  
     4   !! Ocean        :  calendar 
    55   !!===================================================================== 
    66   !! History :  OPA  ! 1994-09  (M. Pontaud M. Imbard)  Original code 
    77   !!                 ! 1997-03  (O. Marti) 
    8    !!                 ! 1997-05  (G. Madec)  
     8   !!                 ! 1997-05  (G. Madec) 
    99   !!                 ! 1997-08  (M. Imbard) 
    1010   !!   NEMO     1.0  ! 2003-09  (G. Madec)  F90 + nyear, nmonth, nday 
    1111   !!                 ! 2004-01  (A.M. Treguier) new calculation based on adatrj 
    1212   !!                 ! 2006-08  (G. Madec)  surface module major update 
    13    !!----------------------------------------------------------------------       
     13   !!---------------------------------------------------------------------- 
    1414 
    1515   !!---------------------------------------------------------------------- 
    1616   !!   day        : calendar 
    17    !!   
     17   !! 
    1818   !!           ------------------------------- 
    1919   !!           ----------- WARNING ----------- 
     
    2424   !!           ----------- WARNING ----------- 
    2525   !!           ------------------------------- 
    26    !!   
     26   !! 
    2727   !!---------------------------------------------------------------------- 
    2828   USE dom_oce         ! ocean space and time domain 
    2929   USE phycst          ! physical constants 
    3030   USE in_out_manager  ! I/O manager 
    31    USE iom             !  
     31   USE iom             ! 
    3232   USE ioipsl, ONLY :   ymds2ju   ! for calendar 
    3333   USE prtctl          ! Print control 
     
    4141   PUBLIC   day        ! called by step.F90 
    4242   PUBLIC   day_init   ! called by istate.F90 
    43  
    44    INTEGER ::   nsecd, nsecd05, ndt, ndt05 
     43   PUBLIC   day_mth    ! Needed by TAM 
     44 
     45   INTEGER, PUBLIC ::   nsecd, nsecd05, ndt, ndt05 ! (PUBLIC for TAM) 
    4546 
    4647   !!---------------------------------------------------------------------- 
     
    5455      !!---------------------------------------------------------------------- 
    5556      !!                   ***  ROUTINE day_init  *** 
    56       !!  
    57       !! ** Purpose :   Initialization of the calendar values to their values 1 time step before nit000  
     57      !! 
     58      !! ** Purpose :   Initialization of the calendar values to their values 1 time step before nit000 
    5859      !!                because day will be called at the beginning of step 
    5960      !! 
     
    8182      ndt05   = NINT(0.5 * rdttra(1)) 
    8283 
    83       IF( .NOT. lk_offline ) CALL day_rst( nit000, 'READ' )  
     84      IF( .NOT. lk_offline ) CALL day_rst( nit000, 'READ' ) 
    8485 
    8586      ! set the calandar from ndastp (read in restart file and namelist) 
     
    8788      nyear   =   ndastp / 10000 
    8889      nmonth  = ( ndastp - (nyear * 10000) ) / 100 
    89       nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 )  
     90      nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 ) 
    9091 
    9192      CALL ymds2ju( nyear, nmonth, nday, 0.0, fjulday )  ! we assume that we start run at 00:00 
     
    9596      nsec1jan000 = 0 
    9697      CALL day_mth 
    97        
     98 
    9899      IF ( nday == 0 ) THEN     !   for ex if ndastp = ndate0 - 1 
    99          nmonth = nmonth - 1   
     100         nmonth = nmonth - 1 
    100101         nday = nmonth_len(nmonth) 
    101102      ENDIF 
     
    106107         IF( nleapy == 1 )   CALL day_mth 
    107108      ENDIF 
    108        
     109 
    109110      ! day since january 1st 
    110111      nday_year = nday + SUM( nmonth_len(1:nmonth - 1) ) 
    111112 
    112       !compute number of days between last monday and today       
     113      !compute number of days between last monday and today 
    113114      CALL ymds2ju( 1900, 01, 01, 0.0, zjul )  ! compute julian day value of 01.01.1900 (our reference that was a Monday) 
    114       inbday = NINT(fjulday - zjul)            ! compute nb day between  01.01.1900 and current day   
    115       idweek = MOD(inbday, 7)                  ! compute nb day between last monday and current day   
     115      inbday = NINT(fjulday - zjul)            ! compute nb day between  01.01.1900 and current day 
     116      idweek = MOD(inbday, 7)                  ! compute nb day between last monday and current day 
    116117 
    117118      ! number of seconds since the beginning of current year/month/week/day at the middle of the time-step 
     
    135136      !!---------------------------------------------------------------------- 
    136137      !!                   ***  ROUTINE day_init  *** 
    137       !!  
     138      !! 
    138139      !! ** Purpose :   calendar values related to the months 
    139140      !! 
     
    147148 
    148149      ! length of the month of the current year (from nleapy, read in namelist) 
    149       IF ( nleapy < 2 ) THEN  
     150      IF ( nleapy < 2 ) THEN 
    150151         nmonth_len(:) = (/ 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 /) 
    151152         nyear_len(:) = 365 
     
    167168      ! time since Jan 1st   0     1     2    ...    11    12    13 
    168169      !          ---------*--|--*--|--*--| ... |--*--|--*--|--*--|-------------------------------------- 
    169       !                 <---> <---> <--->  ...  <---> <---> <--->         
     170      !                 <---> <---> <--->  ...  <---> <---> <---> 
    170171      ! month number      0     1     2    ...    11    12    13 
    171172      ! 
     
    180181         nmonth_end(jm) = nmonth_end(jm-1) + nsecd * nmonth_len(jm) 
    181182      END DO 
    182       !            
    183    END SUBROUTINE  
     183      ! 
     184   END SUBROUTINE 
    184185 
    185186 
     
    187188      !!---------------------------------------------------------------------- 
    188189      !!                      ***  ROUTINE day  *** 
    189       !!  
     190      !! 
    190191      !! ** Purpose :   Compute the date with a day iteration IF necessary. 
    191192      !! 
     
    199200      !!              - adatrj    : date in days since the beginning of the run 
    200201      !!              - nsec_year : current time of the year (in second since 00h, jan 1st) 
    201       !!----------------------------------------------------------------------       
     202      !!---------------------------------------------------------------------- 
    202203      INTEGER, INTENT(in) ::   kt        ! ocean time-step indices 
    203204      ! 
     
    210211      zprec = 0.1 / rday 
    211212      !                                                 ! New time-step 
    212       nsec_year  = nsec_year  + ndt  
    213       nsec_month = nsec_month + ndt                  
     213      nsec_year  = nsec_year  + ndt 
     214      nsec_month = nsec_month + ndt 
    214215      nsec_week  = nsec_week  + ndt 
    215       nsec_day   = nsec_day   + ndt                 
     216      nsec_day   = nsec_day   + ndt 
    216217      adatrj  = adatrj  + rdttra(1) / rday 
    217218      fjulday = fjulday + rdttra(1) / rday 
    218219      IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < zprec )   fjulday = REAL(NINT(fjulday),wp)   ! avoid truncation error 
    219220      IF( ABS(adatrj  - REAL(NINT(adatrj ),wp)) < zprec )   adatrj  = REAL(NINT(adatrj ),wp)   ! avoid truncation error 
    220        
     221 
    221222      IF( nsec_day > nsecd ) THEN                       ! New day 
    222223         ! 
     
    251252 
    252253      IF( nsec_week > 7*nsecd )   nsec_week = ndt05     ! New week 
    253        
     254 
    254255      IF(ln_ctl) THEN 
    255256         WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear 
     
    268269      !!--------------------------------------------------------------------- 
    269270      !!                   ***  ROUTINE ts_rst  *** 
    270       !!  
     271      !! 
    271272      !!  ** Purpose : Read or write calendar in restart file: 
    272       !!  
     273      !! 
    273274      !!  WRITE(READ) mode: 
    274       !!       kt        : number of time step since the begining of the experiment at the  
     275      !!       kt        : number of time step since the begining of the experiment at the 
    275276      !!                   end of the current(previous) run 
    276       !!       adatrj(0) : number of elapsed days since the begining of the experiment at the  
     277      !!       adatrj(0) : number of elapsed days since the begining of the experiment at the 
    277278      !!                   end of the current(previous) run (REAL -> keep fractions of day) 
    278279      !!       ndastp    : date at the end of the current(previous) run (coded as yyyymmdd integer) 
    279       !!  
     280      !! 
    280281      !!   According to namelist parameter nrstdt, 
    281282      !!       nrstdt = 0  no control on the date (nit000 is  arbitrary). 
     
    295296      REAL(wp) ::   zkt, zndastp 
    296297      !!---------------------------------------------------------------------- 
    297        
     298 
    298299      IF( TRIM(cdrw) == 'READ' ) THEN 
    299300 
     
    312313               WRITE(numout,*) 
    313314            ENDIF 
    314             ! Control of date  
    315             IF( nit000 - NINT( zkt ) /= 1 .AND. nrstdt /= 0 )                                         &  
    316                  &   CALL ctl_stop( ' ===>>>> : problem with nit000 for the restart',                 &  
     315            ! Control of date 
     316            IF( nit000 - NINT( zkt ) /= 1 .AND. nrstdt /= 0 )                                         & 
     317                 &   CALL ctl_stop( ' ===>>>> : problem with nit000 for the restart',                 & 
    317318                 &                  ' verify the restart file or rerun with nrstdt = 0 (namelist)' ) 
    318319            ! define ndastp and adatrj 
    319             IF ( nrstdt == 2 ) THEN  
     320            IF ( nrstdt == 2 ) THEN 
    320321               ! read the parameters correspondting to nit000 - 1 (last time step of previous run) 
    321322               CALL iom_get( numror, 'ndastp', zndastp ) 
    322323               ndastp = NINT( zndastp ) 
    323324               CALL iom_get( numror, 'adatrj', adatrj  ) 
    324             ELSE  
     325            ELSE 
    325326               ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day) 
    326327               ndastp = ndate0 - 1     ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00 
    327                adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday  
    328                ! note this is wrong if time step has changed during run  
     328               adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 
     329               ! note this is wrong if time step has changed during run 
    329330            ENDIF 
    330331         ELSE 
    331332            ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day) 
    332333            ndastp = ndate0 - 1        ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00 
    333             adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday  
     334            adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 
    334335         ENDIF 
    335336         IF( ABS(adatrj  - REAL(NINT(adatrj),wp)) < 0.1 / rday )   adatrj = REAL(NINT(adatrj),wp)   ! avoid truncation error 
     
    347348            IF(lwp) WRITE(numout,*) 
    348349            IF(lwp) WRITE(numout,*) 'rst_write : write oce restart file  kt =', kt 
    349             IF(lwp) WRITE(numout,*) '~~~~~~~'          
     350            IF(lwp) WRITE(numout,*) '~~~~~~~' 
    350351         ENDIF 
    351352         ! calendar control 
    352          CALL iom_rstput( kt, nitrst, numrow, 'kt'     , REAL( kt    , wp) )   ! time-step  
     353         CALL iom_rstput( kt, nitrst, numrow, 'kt'     , REAL( kt    , wp) )   ! time-step 
    353354         CALL iom_rstput( kt, nitrst, numrow, 'ndastp' , REAL( ndastp, wp) )   ! date 
    354355         CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj            )   ! number of elapsed days since 
Note: See TracChangeset for help on using the changeset viewer.