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 888 for trunk/NEMO/OPA_SRC/daymod.F90 – NEMO

Ignore:
Timestamp:
2008-04-11T19:05:03+02:00 (16 years ago)
Author:
ctlod
Message:

merge dev_001_SBC branche with the trunk to include the New Surface Module package, see ticket: #113

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/OPA_SRC/daymod.F90

    r719 r888  
    44   !! Ocean        :  calendar  
    55   !!===================================================================== 
     6   !! History :        !  94-09  (M. Pontaud M. Imbard)  Original code 
     7   !!                  !  97-03  (O. Marti) 
     8   !!                  !  97-05  (G. Madec)  
     9   !!                  !  97-08  (M. Imbard) 
     10   !!             9.0  !  03-09  (G. Madec)  F90 + nyear, nmonth, nday 
     11   !!                  !  04-01  (A.M. Treguier) new calculation based on adatrj 
     12   !!                  !  06-08  (G. Madec)  surface module major update 
     13   !!----------------------------------------------------------------------       
    614 
    715   !!---------------------------------------------------------------------- 
    816   !!   day        : calendar 
    917   !!---------------------------------------------------------------------- 
    10    !! * Modules used 
    1118   USE dom_oce         ! ocean space and time domain 
    1219   USE phycst          ! physical constants 
     
    1724   PRIVATE 
    1825 
    19    !! * Routine accessibility 
    2026   PUBLIC day        ! called by step.F90 
    2127 
    22    !! * Shared module variables 
    23    INTEGER , PUBLIC ::   &  !: 
    24       nyear     ,   &  !: current year 
    25       nmonth    ,   &  !: current month 
    26       nday      ,   &  !: current day of the month 
    27       nday_year ,   &  !: curent day counted from jan 1st of the current year 
    28       ndastp           !: time step date in year/month/day aammjj 
    29    REAL(wp), PUBLIC ::   &  !: 
    30        adatrj   ,   &  !: number of elapsed days since the begining of the run 
    31        adatrj0         !: value of adatrj at nit000-1 (before the present run). 
    32        !               !  it is the accumulated duration of previous runs 
    33        !               !  that may have been run with different time steps. 
    34    !!---------------------------------------------------------------------- 
    35    !!  OPA 9.0 , LOCEAN-IPSL (2005)  
    36    !! $Header$  
    37    !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
     28   INTEGER , PUBLIC ::   nyear       !: current year 
     29   INTEGER , PUBLIC ::   nmonth      !: current month 
     30   INTEGER , PUBLIC ::   nday        !: current day of the month 
     31   INTEGER , PUBLIC ::   nday_year   !: current day counted from jan 1st of the current year 
     32   REAL(wp), PUBLIC ::   rsec_year   !: current time step counted in second since 00h jan 1st of the current year 
     33   REAL(wp), PUBLIC ::   rsec_month  !: current time step counted in second since 00h 1st day of the current month 
     34   REAL(wp), PUBLIC ::   rsec_day    !: current time step counted in second since 00h         of the current day 
     35   INTEGER , PUBLIC ::   ndastp      !: time step date in year/month/day aammjj 
     36 
     37!!gm supprimer adatrj et adatrj0 ==> remplacer par rsecday..... 
     38   REAL(wp), PUBLIC ::   adatrj      !: number of elapsed days since the begining of the run 
     39   REAL(wp), PUBLIC ::   adatrj0     !: value of adatrj at nit000-1 (before the present run). 
     40   !                                 !  it is the accumulated duration of previous runs 
     41   !                                 !  that may have been run with different time steps. 
     42   INTEGER , PUBLIC, DIMENSION(0:13) ::   nmonth_len   !: length of the current year 
     43 
     44   INTEGER, PUBLIC, DIMENSION(12) ::   nbiss = (/ 31, 29, 31, 30, 31, 30,    &  !: number of days per month 
     45      &                                           31, 31, 30, 31, 30, 31 /)     !: (leap-year) 
     46   INTEGER, PUBLIC, DIMENSION(12) ::   nobis = (/ 31, 28, 31, 30, 31, 30,    &  !: number of days per month 
     47      &                                           31, 31, 30, 31, 30, 31 /)     !: (365 days a year) 
     48 
     49   REAL(wp), PUBLIC, DIMENSION(0:14) ::   rmonth_half(0:14) 
     50 
     51   !!---------------------------------------------------------------------- 
     52   !!  OPA 9.0 , LOCEAN-IPSL (2006)  
     53   !! $Id$ 
     54   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
    3855   !!---------------------------------------------------------------------- 
    3956 
     
    5471      !!              - ndastp    : =nyear*10000+nmonth*100+nday 
    5572      !!              - adatrj    : date in days since the beginning of the run 
    56       !! 
    57       !! History : 
    58       !!        !  94-09  (M. Pontaud M. Imbard)  Original code 
    59       !!        !  97-03  (O. Marti) 
    60       !!        !  97-05  (G. Madec)  
    61       !!        !  97-08  (M. Imbard) 
    62       !!   9.0  !  03-09  (G. Madec)  F90 + nyear, nmonth, nday 
    63       !!        !  04-01  (A.M. Treguier) new calculation based on adatrj 
     73      !!              - rsec_year : current time of the year (in second since 00h, jan 1st) 
    6474      !!----------------------------------------------------------------------       
    65       !! * Arguments 
    66       INTEGER, INTENT( in ) ::   kt      ! ocean time-step indices 
    67  
    68       !! * Local declarations 
    69       INTEGER  ::   js                   ! dummy loop indice 
    70       INTEGER  ::   iend, iday0, iday1   ! temporary integers 
    71       REAL(wp) :: zadatrjn, zadatrjb     ! adatrj at timestep kt-1 and kt-2  
    72       CHARACTER (len=25) :: charout 
     75      INTEGER, INTENT(in) ::   kt        ! ocean time-step indices 
     76      ! 
     77      INTEGER  ::   js, jm               ! dummy loop indice 
     78      CHARACTER (len=25) ::   charout 
    7379      !!---------------------------------------------------------------------- 
    7480 
     
    7783      !----------------------------------------------------------------- 
    7884 
    79       IF( kt == nit000 ) THEN 
    80  
     85      !                        ! ---------------- ! 
     86      IF( kt == -1 ) THEN      !  Initialisation  ! 
     87         !                     ! ---------------- ! 
     88         ! 
    8189         IF( .NOT.ln_rstart )   adatrj0 = 0.e0      ! adatrj0 initialized in rst_read when restart  
    8290 
    83          adatrj  = adatrj0 
     91         ! set the calandar from adatrj0 and ndastp (read in restart file and namelist) 
     92         adatrj  =   adatrj0      !???? bug.... toujours rest   !!gm 
    8493         nyear   =   ndastp / 10000 
    8594         nmonth  = ( ndastp - (nyear * 10000) ) / 100 
    8695         nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 )  
    8796 
    88          ! Calculates nday_year, day since january 1st (useful to read  daily forcing fields) 
     97         ! length of the month of the current year (from nleapy, read in namelist) 
     98         nmonth_len(0) = nbiss(12)   ;   nmonth_len(13) = nbiss(1) 
     99         SELECT CASE( nleapy ) 
     100         CASE( 1  )    
     101            IF( MOD( nyear, 4 ) == 0 ) THEN 
     102               ;          nmonth_len(1:12) = nbiss(:)      ! 366 days per year (leap year) 
     103            ELSE 
     104               ;          nmonth_len(1:12) = nobis(:)      ! 365 days per year 
     105            ENDIF 
     106         CASE( 0  )   ;   nmonth_len(1:12) = nobis(:)      ! 365 days per year 
     107         CASE( 2: )   ;   nmonth_len(1:13) = nleapy        ! 12*nleapy days per year 
     108         END SELECT 
     109 
     110         ! half month in second since the bigining of the year 
     111         rmonth_half(0) = - 0.5 * rday * REAL( nmonth_len( 0 ) ) 
     112         DO jm = 1, 12 
     113            rmonth_half(jm) = rmonth_half(jm-1) + 0.5 * rday * REAL( nmonth_len(jm-1) + nmonth_len(jm) ) 
     114         END DO 
     115         rmonth_half(13) = rmonth_half( 1 ) + 365. * rday 
     116         rmonth_half(14) = rmonth_half( 2 ) + 365. * rday 
     117 
     118         ! day since january 1st (useful to read  daily forcing fields) 
    89119         nday_year =  nday 
    90          !                               ! accumulates days of previous months of this year 
    91          DO js = 1, nmonth-1 
    92             IF( nleapy == 1 .AND. MOD( nyear, 4 ) == 0 ) THEN 
    93                nday_year = nday_year + nbiss(js) 
    94             ELSE 
    95                nday_year = nday_year + nobis(js) 
     120         DO js = 1, nmonth - 1             ! accumulates days of previous months of this year 
     121            nday_year = nday_year + nmonth_len(js) 
     122         END DO 
     123 
     124         ! number of seconds since... 
     125         IF( ln_rstart )   THEN 
     126            rsec_year  = REAL( nday_year ) * rday     - rdttra(1)      ! 00h 1st day of the current year 
     127            rsec_month = REAL( nday      ) * rday     - rdttra(1)      ! 00h 1st day of the current month 
     128            rsec_day   = REAL( nday      ) * rday     - rdttra(1)      ! 00h         of the current day 
     129         ELSE 
     130            rsec_year  = REAL( nday_year - 1 ) * rday - rdttra(1)      ! 00h 1st day of the current year 
     131            rsec_month = REAL( nday      - 1 ) * rday - rdttra(1)      ! 00h 1st day of the current month 
     132            rsec_day   =                              - rdttra(1)      ! 00h         of the current day 
     133         ENDIF 
     134 
     135         ! control print 
     136         IF(lwp) WRITE(numout,*)' ==============>> time-step =', kt, ' Initial DATE Y/M/D = ',   & 
     137               &                   nyear, '/', nmonth, '/', nday, '  rsec_day:', rsec_day 
     138 
     139         !                     ! -------------------------------- !  
     140      ELSE                     !  Model calendar at time-step kt  ! 
     141         !                     ! -------------------------------- !  
     142 
     143         rsec_year  = rsec_year  + rdttra(1)                 ! New time-step 
     144         rsec_month = rsec_month + rdttra(1)                 ! New time-step 
     145         rsec_day   = rsec_day   + rdttra(1)                 ! New time-step 
     146 
     147         adatrj    = adatrj0 + ( kt - nit000 + 1 ) * rdttra(1) / rday 
     148 
     149         IF( rsec_day >= rday ) THEN 
     150            ! 
     151            rsec_day  = 0.e0                               ! NEW day 
     152            nday      = nday + 1 
     153            nday_year = nday_year + 1 
     154            ! 
     155            IF( nday == nmonth_len(nmonth) + 1 ) THEN      ! NEW month 
     156               nday  = 1 
     157               rsec_month = 0.e0    
     158               nmonth = nmonth + 1 
     159               IF( nmonth == 13 ) THEN                     ! NEW year 
     160                  nyear     = nyear + 1 
     161                  nmonth    = 1 
     162                  nday_year = 1 
     163                  rsec_year = 0.e0 
     164                  !                                        ! update the length of the month 
     165                  IF( nleapy == 1 ) THEN                   ! of the current year (if necessary) 
     166                     IF( MOD( nyear, 4 ) == 0 ) THEN 
     167                        nmonth_len(1:12) = nbiss(:)              ! 366 days per year (leap year) 
     168                     ELSE 
     169                        nmonth_len(1:12) = nobis(:)              ! 365 days per year 
     170                     ENDIF 
     171                     ! half month in second since the bigining of the year 
     172                     rmonth_half(0) = - 0.5 * rday * REAL( nmonth_len( 0 ) ) 
     173                     DO jm = 1, 12 
     174                        rmonth_half(jm) = rmonth_half(jm-1) + 0.5 * rday * REAL( nmonth_len(jm-1) + nmonth_len(jm) ) 
     175                     END DO 
     176                     rmonth_half(13) = rmonth_half( 1 ) + 365. * rday 
     177                     rmonth_half(14) = rmonth_half( 2 ) + 365. * rday 
     178                  ENDIF 
     179               ENDIF 
    96180            ENDIF 
    97          END DO 
    98  
    99       ENDIF 
    100  
    101       ! I.  calculates adatrj, zadatrjn, zadatrjb. 
    102       ! ------------------------------------------------------------------ 
    103  
    104       adatrj    = adatrj0 + ( kt - nit000 + 1 ) * rdttra(1) / rday 
    105       zadatrjn  = adatrj0 + ( kt - nit000     ) * rdttra(1) / rday 
    106       zadatrjb  = adatrj0 + ( kt - nit000 - 1 ) * rdttra(1) / rday 
    107  
    108  
    109       ! II.  increment the date.  The date corresponds to 'now' variables (kt-1), 
    110       !      which is the time step of forcing fields.  
    111       !      Do not do this at nit000  unless nrstdt= 2 
    112       !      In that case ndastp (read in restart) was for step nit000-2 
    113       ! ------------------------------------------------------------------- 
    114  
    115       iday0 = INT( zadatrjb ) 
    116       iday1 = INT( zadatrjn ) 
    117  
    118       IF( iday1 - iday0 >= 1 .AND. ( kt /= nit000 .OR. nrstdt == 2 ) ) THEN 
    119  
    120          ! increase calendar 
    121          nyear  =   ndastp / 10000 
    122          nmonth = ( ndastp - (nyear * 10000) ) / 100 
    123          nday   =   ndastp - (nyear * 10000) - ( nmonth * 100 )  
    124          nday = nday + 1 
    125          IF( nleapy == 1 .AND. MOD( nyear, 4 ) == 0 ) THEN 
    126             iend = nbiss(nmonth) 
    127          ELSEIF( nleapy > 1 ) THEN  
    128             iend = nleapy 
    129          ELSE  
    130             iend = nobis(nmonth) 
     181 
     182            ! 
     183            ndastp = nyear * 10000 + nmonth * 100 + nday   ! NEW date 
     184            ! 
     185           IF(lwp) WRITE(numout,'(a,i8,a,i4,a,i2,a,i2,a,i3)') '======>> time-step =', kt,   & 
     186              &   '      New day, DATE Y/M/D = ', nyear, '/', nmonth, '/', nday, '      nday_year = ', nday_year 
     187           IF(lwp) WRITE(numout,'(a,F9.0,a,F9.0,a,F9.0)') '         rsec_year = ', rsec_year,   & 
     188              &   '   rsec_month = ', rsec_month, '   rsec_day = ', rsec_day 
    131189         ENDIF 
    132          IF( nday == iend + 1 ) THEN 
    133             nday  = 1 
    134             nmonth = nmonth + 1 
    135             IF( nmonth == 13 ) THEN 
    136                nmonth  = 1 
    137                nyear = nyear + 1 
    138             ENDIF 
     190 
     191         IF(ln_ctl) THEN 
     192            WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear 
     193            CALL prt_ctl_info(charout) 
    139194         ENDIF 
    140          ndastp = nyear * 10000 + nmonth * 100 + nday 
    141  
    142          ! Calculates nday_year, day since january 1st (useful to read  daily forcing fields) 
    143          nday_year =  nday 
    144          !                                ! accumulates days of previous months of this year 
    145          DO js = 1, nmonth-1 
    146             IF( nleapy == 1 .AND. MOD( nyear, 4 ) == 0 ) THEN 
    147                nday_year = nday_year + nbiss(js) 
    148             ELSE 
    149                nday_year = nday_year + nobis(js) 
    150             ENDIF 
    151          END DO 
    152  
    153          IF(lwp) WRITE(numout,*)' ==============>> time-step =', kt, ' New day, DATE= ',   & 
    154             &                   nyear, '/', nmonth, '/', nday, 'nday_year:', nday_year 
    155       ENDIF 
    156  
    157       IF(ln_ctl) THEN 
    158          WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear 
    159          CALL prt_ctl_info(charout, itime=kt) 
     195         ! 
    160196      ENDIF 
    161197 
Note: See TracChangeset for help on using the changeset viewer.