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 tags/nemo_v1/NEMO/OPA_SRC – NEMO

source: tags/nemo_v1/NEMO/OPA_SRC/daymod.F90 @ 4739

Last change on this file since 4739 was 247, checked in by opalod, 19 years ago

CL : Add CVS Header and CeCILL licence information

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 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
15   IMPLICIT NONE
16   PRIVATE
17
18   !! * Routine accessibility
19   PUBLIC day        ! called by step.F90
20
21   !! * Shared module variables
22   INTEGER , PUBLIC ::   &  !:
23      nyear     ,   &  !: current year
24      nmonth    ,   &  !: current month
25      nday      ,   &  !: current day of the month
26      nday_year ,   &  !: curent day counted from jan 1st of the current year
27      ndastp           !: time step date in year/month/day aammjj
28   REAL(wp), PUBLIC ::   &  !:
29       adatrj   ,   &  !: number of elapsed days since the begining of the run
30       adatrj0         !: value of adatrj at nit000-1 (before the present run).
31       !               !  it is the accumulated duration of previous runs
32       !               !  that may have been run with different time steps.
33   !!----------------------------------------------------------------------
34   !!  OPA 9.0 , LOCEAN-IPSL (2005)
35   !! $Header$
36   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
37   !!----------------------------------------------------------------------
38
39CONTAINS
40
41   SUBROUTINE day( kt )
42      !!----------------------------------------------------------------------
43      !!                      ***  ROUTINE day  ***
44      !!
45      !! ** Purpose :   Compute the date with a day iteration IF necessary.
46      !!
47      !! ** Method  : - ???
48      !!
49      !! ** Action  : - nyear     : current year
50      !!              - nmonth    : current month of the year nyear
51      !!              - nday      : current day of the month nmonth
52      !!              - nday_year : current day of the year nyear
53      !!              - ndastp    : =nyear*10000+nmonth*100+nday
54      !!              - adatrj    : date in days since the beginning of the run
55      !!
56      !! History :
57      !!        !  94-09  (M. Pontaud M. Imbard)  Original code
58      !!        !  97-03  (O. Marti)
59      !!        !  97-05  (G. Madec)
60      !!        !  97-08  (M. Imbard)
61      !!   9.0  !  03-09  (G. Madec)  F90 + nyear, nmonth, nday
62      !!        !  04-01  (A.M. Treguier) new calculation based on adatrj
63      !!----------------------------------------------------------------------     
64      !! * Arguments
65      INTEGER, INTENT( in ) ::   kt      ! ocean time-step indices
66
67      !! * Local declarations
68      INTEGER  ::   js                   ! dummy loop indice
69      INTEGER  ::   iend, iday0, iday1   ! temporary integers
70      REAL(wp) :: zadatrjn, zadatrjb     ! adatrj at timestep kt-1 and kt-2
71      !!----------------------------------------------------------------------
72
73      ! 0.  initialization of adatrj0 and nday, nmonth,nyear, nday_year.
74      !     ndastp has been initialized in domain.F90 or restart.F90
75      !-----------------------------------------------------------------
76
77      IF( kt == nit000 ) THEN
78
79         IF( .NOT.ln_rstart )   adatrj0 = 0.e0      ! adatrj0 initialized in rst_read when restart
80
81         adatrj  = adatrj0
82         nyear   =   ndastp / 10000
83         nmonth  = ( ndastp - (nyear * 10000) ) / 100
84         nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 ) 
85
86         ! Calculates nday_year, day since january 1st (useful to read  daily forcing fields)
87         nday_year =  nday
88         !                               ! accumulates days of previous months of this year
89         DO js = 1, nmonth-1
90            IF( nleapy == 1 .AND. MOD( nyear, 4 ) == 0 ) THEN
91               nday_year = nday_year + nbiss(js)
92            ELSE
93               nday_year = nday_year + nobis(js)
94            ENDIF
95         END DO
96
97      ENDIF
98
99      ! I.  calculates adatrj, zadatrjn, zadatrjb.
100      ! ------------------------------------------------------------------
101
102      adatrj    = adatrj0 + ( kt - nit000 + 1 ) * rdttra(1) / rday
103      zadatrjn  = adatrj0 + ( kt - nit000     ) * rdttra(1) / rday
104      zadatrjb  = adatrj0 + ( kt - nit000 - 1 ) * rdttra(1) / rday
105
106
107      ! II.  increment the date.  The date corresponds to 'now' variables (kt-1),
108      !      which is the time step of forcing fields.
109      !      Do not do this at nit000  unless nrstdt= 2
110      !      In that case ndastp (read in restart) was for step nit000-2
111      ! -------------------------------------------------------------------
112
113      iday0 = INT( zadatrjb )
114      iday1 = INT( zadatrjn )
115
116      IF( iday1 - iday0 >= 1 .AND. ( kt /= nit000 .OR. nrstdt == 2 ) ) THEN
117
118         ! increase calendar
119         nyear  =   ndastp / 10000
120         nmonth = ( ndastp - (nyear * 10000) ) / 100
121         nday   =   ndastp - (nyear * 10000) - ( nmonth * 100 ) 
122         nday = nday + 1
123         IF( nleapy == 1 .AND. MOD( nyear, 4 ) == 0 ) THEN
124            iend = nbiss(nmonth)
125         ELSEIF( nleapy > 1 ) THEN
126            iend = nleapy
127         ELSE
128            iend = nobis(nmonth)
129         ENDIF
130         IF( nday == iend + 1 ) THEN
131            nday  = 1
132            nmonth = nmonth + 1
133            IF( nmonth == 13 ) THEN
134               nmonth  = 1
135               nyear = nyear + 1
136            ENDIF
137         ENDIF
138         ndastp = nyear * 10000 + nmonth * 100 + nday
139
140         ! Calculates nday_year, day since january 1st (useful to read  daily forcing fields)
141         nday_year =  nday
142         !                                ! accumulates days of previous months of this year
143         DO js = 1, nmonth-1
144            IF( nleapy == 1 .AND. MOD( nyear, 4 ) == 0 ) THEN
145               nday_year = nday_year + nbiss(js)
146            ELSE
147               nday_year = nday_year + nobis(js)
148            ENDIF
149         END DO
150
151         IF(lwp) WRITE(numout,*)' ==============>> time-step =', kt, ' New day, DATE= ',   &
152            &                   nyear, '/', nmonth, '/', nday, 'nday_year:', nday_year
153      ENDIF
154
155      IF(l_ctl) WRITE(numout,*)' kt =', kt, 'd/m/y =', nday, nmonth, nyear
156
157   END SUBROUTINE day
158
159   !!======================================================================
160END MODULE daymod
Note: See TracBrowser for help on using the repository browser.