/[MITgcm]/MITgcm/pkg/cal/cal_getmonthsrec.F
ViewVC logotype

Contents of /MITgcm/pkg/cal/cal_getmonthsrec.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Mon May 14 22:07:26 2001 UTC (22 years, 11 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint47e_post, checkpoint44e_post, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, release1_p13_pre, checkpoint50c_post, checkpoint46f_post, checkpoint48e_post, checkpoint50c_pre, checkpoint44f_post, checkpoint46b_post, checkpoint43a-release1mods, ecco_c50_e32, ecco_c50_e33, ecco_c50_e30, ecco_c50_e31, release1_p13, checkpoint40pre3, checkpoint40pre1, checkpoint40pre7, checkpoint40pre6, checkpoint48i_post, checkpoint40pre9, checkpoint40pre8, checkpoint46l_pre, chkpt44d_post, checkpoint51, checkpoint50, release1_p8, release1_p9, checkpoint50d_post, release1_p1, release1_p2, release1_p3, release1_p4, release1_p5, release1_p6, release1_p7, checkpoint50b_pre, checkpoint44e_pre, checkpoint51f_post, release1_b1, ecco_c51_e34d, ecco_c51_e34e, ecco_c51_e34f, ecco_c51_e34g, ecco_c51_e34a, ecco_c51_e34b, ecco_c51_e34c, checkpoint48b_post, checkpoint43, checkpoint51d_post, checkpoint48c_pre, checkpoint47d_pre, release1_chkpt44d_post, checkpoint47a_post, checkpoint48d_pre, checkpoint51j_post, checkpoint47i_post, checkpoint47d_post, icebear5, icebear4, icebear3, icebear2, checkpoint46d_pre, checkpoint40pre2, checkpoint48d_post, release1-branch_tutorials, checkpoint48f_post, checkpoint45d_post, checkpoint46j_pre, chkpt44a_post, checkpoint44h_pre, checkpoint48h_post, checkpoint40pre4, ecco_c50_e29, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint46j_post, checkpoint51h_pre, checkpoint46k_post, ecco_c50_e28, chkpt44c_pre, checkpoint48a_post, checkpoint45a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, ecco_c44_e19, ecco_c44_e18, ecco_c44_e17, ecco_c44_e16, release1_p12, release1_p10, release1_p11, release1_p16, release1_p17, release1_p14, release1_p15, checkpoint47j_post, ecco_c50_e33a, branch-exfmods-tag, checkpoint44g_post, branchpoint-genmake2, checkpoint46e_pre, checkpoint48c_post, checkpoint45b_post, checkpoint46b_pre, release1-branch-end, release1_final_v1, checkpoint51b_post, checkpoint51c_post, checkpoint46c_pre, checkpoint46, checkpoint47b_post, checkpoint44b_post, ecco_c51_e34, checkpoint46h_pre, checkpoint46m_post, checkpoint46a_pre, checkpoint50g_post, checkpoint45c_post, ecco_ice2, ecco_ice1, checkpoint44h_post, checkpoint46g_post, release1_p12_pre, checkpoint39, ecco_c44_e22, checkpoint50h_post, checkpoint50e_pre, checkpoint50i_post, ecco_c44_e25, checkpoint51i_pre, checkpoint40pre5, checkpoint47f_post, checkpoint50e_post, chkpt44a_pre, checkpoint46i_post, ecco_c44_e23, ecco_c44_e20, ecco_c44_e21, ecco_c44_e26, ecco_c44_e27, ecco_c44_e24, checkpoint46c_post, ecco-branch-mod1, ecco-branch-mod2, ecco-branch-mod3, ecco-branch-mod4, ecco-branch-mod5, checkpoint50d_pre, checkpoint46e_post, release1_beta1, checkpoint51e_post, checkpoint44b_pre, checkpoint42, checkpoint40, checkpoint41, checkpoint47, checkpoint44, checkpoint45, checkpoint48, checkpoint49, checkpoint46h_post, checkpoint51f_pre, chkpt44c_post, checkpoint48g_post, checkpoint47h_post, checkpoint44f_pre, checkpoint51g_post, checkpoint46d_post, checkpoint50b_post, release1-branch_branchpoint, checkpoint51a_post
Branch point for: c24_e25_ice, branch-exfmods-curt, release1_final, release1-branch, branch-genmake2, release1, ecco-branch, release1_50yr, icebear, release1_coupled
Added calendar package.
Not currently supported by mitgcm, i.e. disabled by default.

1 C $Header: /u/gcmpack/development/heimbach/ecco_env/pkg/cal/cal_getmonthsrec.F,v 1.4 2001/02/02 16:57:22 heimbach Exp $
2
3 #include "CAL_CPPOPTIONS.h"
4
5 subroutine cal_GetMonthsRec(
6 O fac, first, changed,
7 O count0, count1,
8 I mytime, myiter, mythid
9 & )
10
11 c ==================================================================
12 c SUBROUTINE cal_GetMonthsRec
13 c ==================================================================
14 c
15 c o Given the current model time or iteration number this routine
16 c returns the corrresponding months that will have to be used in
17 c order to interpolate monthly mean fields. The routine derives
18 c from *exf_GetMonthsRec* of the external forcing package.
19 c
20 c started: Christian Eckert eckert@mit.edu 21-Apr-2000
21 c - ported from the external forcing package and slightly
22 c modified (10 --> nmonthyear-2, 12 --> nmonthyear).
23 c
24 c changed: Patrick Heimbach heimbach@mit.edu 15-Jun-2000
25 c - fixed bug for count1 = nmonthyear
26 c
27 c ==================================================================
28 c SUBROUTINE cal_GetMonthsRec
29 c ==================================================================
30
31 implicit none
32
33 c == global variables ==
34
35 #include "cal.h"
36
37 c == routine arguments ==
38
39 _RL fac
40 logical first
41 logical changed
42 integer count0
43 integer count1
44 _RL mytime
45 integer myiter
46 integer mythid
47
48 c == local variables ==
49
50 integer currentdate(4)
51 integer midtime(4)
52 integer middate(4)
53 integer middate0(4)
54 integer middate1(4)
55 integer prevdate(4)
56 integer shifttime(4)
57 integer startofmonth(4)
58 integer endofmonth(4)
59 integer difftime(4)
60 integer present
61 integer previous
62 integer next
63 integer prevcount
64 integer modelsteptime(4)
65
66 _RL currentsecs
67 _RL prevsecs
68 _RL midsecs_np
69 _RL diffsecs
70 _RL midsecs
71
72 c == end of interface ==
73
74 ce --> Include a check whether the right calendar is used.
75
76 shifttime(1) = 1
77 shifttime(2) = 0
78 shifttime(3) = 0
79 shifttime(4) = -1
80
81 call cal_TimeInterval( -modelstep, 'secs', modelsteptime,
82 & mythid )
83
84 c Determine the current date and the current month.
85 call cal_GetDate( myiter, mytime, currentdate, mythid )
86
87 present = mod(currentdate(1)/100,100)
88 startofmonth(1) = (currentdate(1)/100)*100 + 1
89 startofmonth(2) = 0
90 startofmonth(3) = 0
91 startofmonth(4) = 0
92 endofmonth(1) = (currentdate(1)/100)*100 +
93 & ndaymonth(present,currentdate(3))
94 endofmonth(2) = 235959
95 endofmonth(3) = 0
96 endofmonth(4) = 0
97
98 call cal_FullDate( startofmonth(1), startofmonth(2),
99 & startofmonth, mythid )
100 call cal_FullDate( endofmonth(1), endofmonth(2),
101 & endofmonth, mythid )
102
103 c Determine middle of current month.
104 currentsecs = float(
105 & (mod(currentdate(1),100)-1)*secondsperday +
106 & currentdate(2)/10000*secondsperhour +
107 & mod(currentdate(2)/100,100)*secondsperminute +
108 & mod(currentdate(2),100)
109 & )
110 midsecs = float(ndaymonth(present,currentdate(3))*
111 & secondsperday/2)
112
113 call cal_TimeInterval( midsecs, 'secs', midtime, mythid )
114 call cal_AddTime( startofmonth, midtime, middate, mythid )
115 call cal_AddTime( currentdate, modelsteptime, prevdate, mythid )
116
117 prevsecs = float(
118 & (mod(prevdate(1),100)-1)*secondsperday +
119 & prevdate(2)/10000*secondsperhour +
120 & mod(prevdate(2)/100,100)*secondsperminute +
121 & mod(prevdate(2),100)
122 & )
123
124 c-- Set switches for reading new records.
125 first = ((mytime - modelstart) .lt. 0.5*modelstep)
126
127 if ( first ) then
128 changed = .false.
129 endif
130
131 if ( currentsecs .lt. midsecs ) then
132
133 count0 = mod(present+nmonthyear-2,nmonthyear)+1
134 prevcount = count0
135
136 shifttime(1) = -shifttime(1)
137 call cal_AddTime( startofmonth, shifttime, middate0, mythid )
138 middate0(1) = (middate0(1)/100)*100 + 1
139 middate0(2) = 0
140 middate0(3) = 0
141 middate0(4) = 0
142 call cal_FullDate( middate0(1), middate0(2), middate0,
143 & mythid )
144
145 previous = mod(middate0(1)/100,100)
146
147 midsecs_np = float(ndaymonth(previous,middate0(3))*
148 & secondsperday/2)
149
150 call cal_TimeInterval( midsecs_np, 'secs', midtime, mythid )
151 call cal_AddTime( middate0, midtime, middate0, mythid )
152
153 count1 = present
154
155 middate1(1) = middate(1)
156 middate1(2) = middate(2)
157 middate1(3) = middate(3)
158 middate1(4) = middate(4)
159
160 else
161
162 count0 = present
163
164 if ( prevsecs .lt. midsecs ) then
165 prevcount = mod(present+nmonthyear-2,nmonthyear)+1
166 else
167 prevcount = present
168 endif
169
170 middate0(1) = middate(1)
171 middate0(2) = middate(2)
172 middate0(3) = middate(3)
173 middate0(4) = middate(4)
174
175 count1 = mod(present+1,nmonthyear)
176 if ( count1 .EQ. 0 ) count1 = nmonthyear
177
178 call cal_AddTime( endofmonth, shifttime, middate1, mythid )
179 middate1(1) = (middate1(1)/100)*100 + 1
180 middate1(2) = 0
181 middate1(3) = 0
182 middate1(4) = 0
183
184 call cal_FullDate( middate1(1), middate1(2), middate1,
185 & mythid )
186 next = mod(middate1(1)/100,100)
187 midsecs_np = float(ndaymonth(next,middate1(3))*
188 & secondsperday/2)
189 call cal_TimeInterval( midsecs_np, 'secs', midtime, mythid )
190 call cal_AddTime( middate1, midtime, middate1, mythid )
191
192 endif
193
194 call cal_SubDates( middate1, middate0, difftime, mythid )
195 call cal_ToSeconds( difftime, diffsecs, mythid )
196
197 c Set counters, switches, and the linear interpolation factor.
198 if ( (.not. first) .and. (prevcount .ne. count0) ) then
199 changed = .true.
200 else
201 changed = .false.
202 endif
203
204 if ( currentsecs .lt. midsecs ) then
205 fac = (midsecs - currentsecs)/diffsecs
206 else
207 fac = (2.*midsecs + midsecs_np - currentsecs)/
208 & diffsecs
209 endif
210
211 return
212 end
213

  ViewVC Help
Powered by ViewVC 1.1.22