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

source: trunk/NEMO/OPA_SRC/daymod.F90 @ 699

Last change on this file since 699 was 699, checked in by smasson, 17 years ago

insert revision Id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.5 KB
Line 
1MODULE daymod
2   !!======================================================================
3   !!                       ***  MODULE  daymod  ***
4   !! Ocean        :  calendar
5   !!=====================================================================
6
7   !!----------------------------------------------------------------------
8   !!   day        : calendar
9   !!----------------------------------------------------------------------
10   !! * Modules used
11   USE dom_oce         ! ocean space and time domain
12   USE phycst          ! physical constants
13   USE in_out_manager  ! I/O manager
14   USE prtctl          ! Print control
15
16   IMPLICIT NONE
17   PRIVATE
18
19   !! * Routine accessibility
20   PUBLIC day        ! called by step.F90
21
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   !! $Id$
37   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
38   !!----------------------------------------------------------------------
39
40CONTAINS
41
42   SUBROUTINE day( kt )
43      !!----------------------------------------------------------------------
44      !!                      ***  ROUTINE day  ***
45      !!
46      !! ** Purpose :   Compute the date with a day iteration IF necessary.
47      !!
48      !! ** Method  : - ???
49      !!
50      !! ** Action  : - nyear     : current year
51      !!              - nmonth    : current month of the year nyear
52      !!              - nday      : current day of the month nmonth
53      !!              - nday_year : current day of the year nyear
54      !!              - ndastp    : =nyear*10000+nmonth*100+nday
55      !!              - 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
64      !!----------------------------------------------------------------------     
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
73      !!----------------------------------------------------------------------
74
75      ! 0.  initialization of adatrj0 and nday, nmonth,nyear, nday_year.
76      !     ndastp has been initialized in domain.F90 or restart.F90
77      !-----------------------------------------------------------------
78
79      IF( kt == nit000 ) THEN
80
81         IF( .NOT.ln_rstart )   adatrj0 = 0.e0      ! adatrj0 initialized in rst_read when restart
82
83         adatrj  = adatrj0
84         nyear   =   ndastp / 10000
85         nmonth  = ( ndastp - (nyear * 10000) ) / 100
86         nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 ) 
87
88         ! Calculates nday_year, day since january 1st (useful to read  daily forcing fields)
89         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)
96            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)
131         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
139         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)
160      ENDIF
161
162   END SUBROUTINE day
163
164   !!======================================================================
165END MODULE daymod
Note: See TracBrowser for help on using the repository browser.