1 | MODULE daymod_tam |
---|
2 | #ifdef key_tam |
---|
3 | !!====================================================================== |
---|
4 | !! *** MODULE daymod_tam *** |
---|
5 | !! Ocean : calendar, tangent and adjoint model version |
---|
6 | !!===================================================================== |
---|
7 | !! History of the direct module : |
---|
8 | !! ! 94-09 (M. Pontaud M. Imbard) Original code |
---|
9 | !! ! 97-03 (O. Marti) |
---|
10 | !! ! 97-05 (G. Madec) |
---|
11 | !! ! 97-08 (M. Imbard) |
---|
12 | !! 9.0 ! 03-09 (G. Madec) F90 + nyear, nmonth, nday |
---|
13 | !! ! 04-01 (A.M. Treguier) new calculation based on adatrj |
---|
14 | !! ! 06-08 (G. Madec) surface module major update |
---|
15 | !! History : |
---|
16 | !! 8.x ! 1998--2004 (A. Weaver, N. Daget) daytam |
---|
17 | !! 9.0 ! 08-05 (A. Vidard) skeleton |
---|
18 | !! ! 08-08 (A. Vidard) 04-01 version, based on daytam |
---|
19 | !! ! 02-09 (A. Vidard) 06-08 version |
---|
20 | !!---------------------------------------------------------------------- |
---|
21 | !!---------------------------------------------------------------------- |
---|
22 | !! day_tam : calendar |
---|
23 | !! |
---|
24 | !! ------------------------------- |
---|
25 | !! ----------- WARNING ----------- |
---|
26 | !! |
---|
27 | !! we assume that the time step is a divisor of the number of second of in a day |
---|
28 | !! ---> MOD( rday, rdttra(1) ) == 0 |
---|
29 | !! |
---|
30 | !! ----------- WARNING ----------- |
---|
31 | !! ------------------------------- |
---|
32 | !! |
---|
33 | !!---------------------------------------------------------------------- |
---|
34 | !! * Modules used |
---|
35 | USE par_kind, ONLY: & ! Precision variables |
---|
36 | & wp |
---|
37 | USE phycst, ONLY: & |
---|
38 | & rday |
---|
39 | USE dom_oce, ONLY: & ! ocean space and time domain |
---|
40 | & rdttra |
---|
41 | USE in_out_manager, ONLY: & ! I/O manager |
---|
42 | & lwp, & |
---|
43 | & nleapy, & |
---|
44 | & numout |
---|
45 | USE daymod, ONLY: & |
---|
46 | & day , & |
---|
47 | & day_mth , & |
---|
48 | & nyear_len , & |
---|
49 | & nmonth_len, & |
---|
50 | & nyear , & !: current year |
---|
51 | & nmonth , & !: current month |
---|
52 | & nday , & !: current day of the month |
---|
53 | & nday_year , & !: curent day counted from jan 1st of the current year |
---|
54 | & ndastp , & !: time step date in year/month/day aammjj |
---|
55 | & rsec_year , & !: current time step counted in second since 00h jan 1st of the current year |
---|
56 | & rsec_month, & !: current time step counted in second since 00h 1st day of the current month |
---|
57 | & rsec_day , & !: current time step counted in second since 00h of the current day |
---|
58 | & adatrj !: number of elapsed days since the begining of the run |
---|
59 | ! ! it is the accumulated duration of previous runs |
---|
60 | ! ! that may have been run with different time steps. |
---|
61 | |
---|
62 | |
---|
63 | IMPLICIT NONE |
---|
64 | PRIVATE |
---|
65 | |
---|
66 | !! * Routine accessibility |
---|
67 | PUBLIC day_tam ! called by steptan.F90 and stepadj.F90 |
---|
68 | |
---|
69 | CONTAINS |
---|
70 | |
---|
71 | SUBROUTINE day_tam( kt, kindic ) |
---|
72 | !!---------------------------------------------------------------------- |
---|
73 | !! *** ROUTINE day_tam *** |
---|
74 | !! |
---|
75 | !! ** Purpose : Compute the date with a day iteration IF necessary. |
---|
76 | !! forward for the tangent linear, backward for the adjoint |
---|
77 | !! |
---|
78 | !! * Arguments |
---|
79 | INTEGER, INTENT( in ) :: kt ! ocean time-step indices |
---|
80 | INTEGER, INTENT( in ) :: kindic ! forward (0) or backward (1) |
---|
81 | !!---------------------------------------------------------------------- |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | SELECT CASE ( kindic ) |
---|
87 | CASE ( 0 ) |
---|
88 | ! ---------------------------------------------- |
---|
89 | ! Forward running Calendar for the tangent model |
---|
90 | ! ---------------------------------------------- |
---|
91 | CALL day( kt ) |
---|
92 | CASE ( 1 ) |
---|
93 | ! ---------------------------------------------- |
---|
94 | ! Backward running Calendar for the adjoint model |
---|
95 | ! ---------------------------------------------- |
---|
96 | CALL day_adj( kt ) |
---|
97 | CASE default |
---|
98 | IF (lwp) WRITE(numout,*) 'day_tam called with a wrong kindic: ',kindic |
---|
99 | CALL abort |
---|
100 | END SELECT |
---|
101 | END SUBROUTINE day_tam |
---|
102 | SUBROUTINE day_adj( kt ) |
---|
103 | !!---------------------------------------------------------------------- |
---|
104 | !! *** ROUTINE day_adj *** |
---|
105 | !! |
---|
106 | !! ** Purpose : Compute the date with a day iteration backward |
---|
107 | !! if necessary. |
---|
108 | !! |
---|
109 | !! ** Method : - ??? |
---|
110 | !! |
---|
111 | !! ** Action : - nyear : current year |
---|
112 | !! - nmonth : current month of the year nyear |
---|
113 | !! - nday : current day of the month nmonth |
---|
114 | !! - nday_year : current day of the year nyear |
---|
115 | !! - ndastp : = nyear*10000 + nmonth*100 + nday |
---|
116 | !! - adatrj : date in days since the beginning of the run |
---|
117 | !! - rsec_year : current time of the year (in second since 00h, jan 1st) |
---|
118 | !!---------------------------------------------------------------------- |
---|
119 | INTEGER, INTENT(in) :: kt ! ocean time-step indices |
---|
120 | ! |
---|
121 | CHARACTER (len=25) :: charout |
---|
122 | !!---------------------------------------------------------------------- |
---|
123 | |
---|
124 | ! ! New time-step |
---|
125 | rsec_year = rsec_year - rdttra(1) |
---|
126 | rsec_month = rsec_month - rdttra(1) |
---|
127 | rsec_day = rsec_day - rdttra(1) |
---|
128 | adatrj = adatrj + rdttra(1) / rday |
---|
129 | |
---|
130 | IF( rsec_day < 0 ) THEN ! NEW day |
---|
131 | ! |
---|
132 | nday = nday - 1 |
---|
133 | nday_year = nday_year - 1 |
---|
134 | rsec_day = rday - 0.5 * rdttra(1) |
---|
135 | ! |
---|
136 | IF( nday == 0 ) THEN ! NEW month |
---|
137 | nmonth = nmonth - 1 |
---|
138 | IF( nmonth == 0 ) THEN ! NEW year |
---|
139 | nyear = nyear - 1 |
---|
140 | nmonth = 12 |
---|
141 | nday_year = nyear_len(0) |
---|
142 | rsec_year = nday_year * rday - 0.5 * rdttra(1) |
---|
143 | IF( nleapy == 1 ) CALL day_mth |
---|
144 | ENDIF |
---|
145 | nday = nmonth_len(nmonth) |
---|
146 | rsec_month = nmonth_len(nmonth) * rday - 0.5 * rdttra(1) |
---|
147 | ENDIF |
---|
148 | ! |
---|
149 | ndastp = nyear * 10000 + nmonth * 100 + nday ! NEW date |
---|
150 | ! |
---|
151 | IF(lwp) WRITE(numout,'(a,i8,a,i4.4,a,i2.2,a,i2.2,a,i3.3)') '======>> time-step =', kt, & |
---|
152 | & ' New day, DATE Y/M/D = ', nyear, '/', nmonth, '/', nday, ' nday_year = ', nday_year |
---|
153 | IF(lwp) WRITE(numout,'(a,F9.0,a,F9.0,a,F9.0)') ' rsec_year = ', rsec_year, & |
---|
154 | & ' rsec_month = ', rsec_month, ' rsec_day = ', rsec_day |
---|
155 | ENDIF |
---|
156 | |
---|
157 | ! |
---|
158 | END SUBROUTINE day_adj |
---|
159 | |
---|
160 | !!====================================================================== |
---|
161 | #endif |
---|
162 | END MODULE daymod_tam |
---|