1 |
C $Header: /u/gcmpack/MITgcm/pkg/ctrl/Attic/ctrl_getrec.F,v 1.1.2.3 2003/06/19 15:18:48 heimbach Exp $ |
2 |
|
3 |
#include "CTRL_CPPOPTIONS.h" |
4 |
|
5 |
|
6 |
subroutine ctrl_GetRec( |
7 |
I thefield, |
8 |
O fac, |
9 |
O first, |
10 |
O changed, |
11 |
O count0, |
12 |
O count1, |
13 |
I mytime, |
14 |
I myiter, |
15 |
I mythid |
16 |
& ) |
17 |
|
18 |
c ================================================================== |
19 |
c SUBROUTINE ctrl_GetRec |
20 |
c ================================================================== |
21 |
c |
22 |
c o Get flags, counters, and the linear interpolation factor for a |
23 |
c given control vector contribution. |
24 |
c |
25 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
26 |
c |
27 |
c changed: Christian Eckert eckert@mit.edu 14-Jan-2000 |
28 |
c |
29 |
c - Restructured the code in order to create a package |
30 |
c for the MITgcmUV. |
31 |
c |
32 |
c Christian Eckert eckert@mit.edu 24-Feb-2000 |
33 |
c |
34 |
c - Changed Routine names (package prefix: ecco_) |
35 |
c |
36 |
c ================================================================== |
37 |
c SUBROUTINE ctrl_GetRec |
38 |
c ================================================================== |
39 |
|
40 |
implicit none |
41 |
|
42 |
c == global variables == |
43 |
|
44 |
#include "EEPARAMS.h" |
45 |
#include "SIZE.h" |
46 |
|
47 |
#include "ctrl.h" |
48 |
#ifdef ALLOW_CALENDAR |
49 |
# include "cal.h" |
50 |
#endif |
51 |
|
52 |
c == routine arguments == |
53 |
|
54 |
character*(*) thefield |
55 |
_RL fac |
56 |
logical first |
57 |
logical changed |
58 |
integer count0 |
59 |
integer count1 |
60 |
_RL mytime |
61 |
integer myiter |
62 |
integer mythid |
63 |
|
64 |
c == local variables == |
65 |
|
66 |
#ifdef ALLOW_CALENDAR |
67 |
|
68 |
integer mydate(4) |
69 |
integer previousdate(4) |
70 |
integer difftime(4) |
71 |
|
72 |
integer fldcount |
73 |
_RL fldsecs |
74 |
integer prevfldcount |
75 |
_RL prevfldsecs |
76 |
integer flddate(4) |
77 |
|
78 |
integer fldstartdate(4) |
79 |
_RL fldperiod |
80 |
|
81 |
logical lArgErr |
82 |
|
83 |
#ifdef ECCO_VERBOSE |
84 |
character*(max_len_mbuf) msgbuf |
85 |
#endif |
86 |
|
87 |
c == end of interface == |
88 |
|
89 |
lArgErr = .true. |
90 |
fldperiod = 0. |
91 |
|
92 |
c Map the field parameters. |
93 |
|
94 |
if ( thefield .eq. 'xx_hflux' ) then |
95 |
call cal_CopyDate( |
96 |
I xx_hfluxstartdate, |
97 |
O fldstartdate, |
98 |
I mythid |
99 |
& ) |
100 |
fldperiod = xx_hfluxperiod |
101 |
lArgErr = .false. |
102 |
else if ( thefield .eq. 'xx_atemp' ) then |
103 |
call cal_CopyDate( |
104 |
I xx_atempstartdate, |
105 |
O fldstartdate, |
106 |
I mythid |
107 |
& ) |
108 |
fldperiod = xx_atempperiod |
109 |
lArgErr = .false. |
110 |
else if ( thefield .eq. 'xx_sflux' ) then |
111 |
call cal_CopyDate( |
112 |
I xx_sfluxstartdate, |
113 |
O fldstartdate, |
114 |
I mythid |
115 |
& ) |
116 |
fldperiod = xx_sfluxperiod |
117 |
lArgErr = .false. |
118 |
else if ( thefield .eq. 'xx_aqh' ) then |
119 |
call cal_CopyDate( |
120 |
I xx_aqhstartdate, |
121 |
O fldstartdate, |
122 |
I mythid |
123 |
& ) |
124 |
fldperiod = xx_aqhperiod |
125 |
lArgErr = .false. |
126 |
else if ( thefield .eq. 'xx_tauu' ) then |
127 |
call cal_CopyDate( |
128 |
I xx_tauustartdate, |
129 |
O fldstartdate, |
130 |
I mythid |
131 |
& ) |
132 |
fldperiod = xx_tauuperiod |
133 |
lArgErr = .false. |
134 |
else if ( thefield .eq. 'xx_uwind' ) then |
135 |
call cal_CopyDate( |
136 |
I xx_uwindstartdate, |
137 |
O fldstartdate, |
138 |
I mythid |
139 |
& ) |
140 |
fldperiod = xx_uwindperiod |
141 |
lArgErr = .false. |
142 |
else if ( thefield .eq. 'xx_tauv' ) then |
143 |
call cal_CopyDate( |
144 |
I xx_tauvstartdate, |
145 |
O fldstartdate, |
146 |
I mythid |
147 |
& ) |
148 |
fldperiod = xx_tauvperiod |
149 |
lArgErr = .false. |
150 |
else if ( thefield .eq. 'xx_vwind' ) then |
151 |
call cal_CopyDate( |
152 |
I xx_vwindstartdate, |
153 |
O fldstartdate, |
154 |
I mythid |
155 |
& ) |
156 |
fldperiod = xx_vwindperiod |
157 |
lArgErr = .false. |
158 |
else if ( thefield .eq. 'xx_obcsn' ) then |
159 |
call cal_CopyDate( |
160 |
I xx_obcsnstartdate, |
161 |
O fldstartdate, |
162 |
I mythid |
163 |
& ) |
164 |
fldperiod = xx_obcsnperiod |
165 |
lArgErr = .false. |
166 |
else if ( thefield .eq. 'xx_obcss' ) then |
167 |
call cal_CopyDate( |
168 |
I xx_obcssstartdate, |
169 |
O fldstartdate, |
170 |
I mythid |
171 |
& ) |
172 |
fldperiod = xx_obcssperiod |
173 |
lArgErr = .false. |
174 |
else if ( thefield .eq. 'xx_obcsw' ) then |
175 |
call cal_CopyDate( |
176 |
I xx_obcswstartdate, |
177 |
O fldstartdate, |
178 |
I mythid |
179 |
& ) |
180 |
fldperiod = xx_obcswperiod |
181 |
lArgErr = .false. |
182 |
else if ( thefield .eq. 'xx_obcse' ) then |
183 |
call cal_CopyDate( |
184 |
I xx_obcsestartdate, |
185 |
O fldstartdate, |
186 |
I mythid |
187 |
& ) |
188 |
fldperiod = xx_obcseperiod |
189 |
lArgErr = .false. |
190 |
endif |
191 |
|
192 |
c-- Check the field argument. |
193 |
if ( lArgErr ) then |
194 |
print*,' The subroutine *ctrl_GetRec* has been called' |
195 |
print*,' with an illegal field specification.' |
196 |
stop ' ... stopped in ctrl_GetRec.' |
197 |
endif |
198 |
|
199 |
c-- Determine the current date. |
200 |
call cal_GetDate( myiter, mytime, mydate, mythid ) |
201 |
|
202 |
c Determine the flux record just before mycurrentdate. |
203 |
call cal_TimePassed( fldstartdate, mydate, difftime, |
204 |
& mythid ) |
205 |
call cal_ToSeconds( difftime, fldsecs, mythid ) |
206 |
cgg Added a 0.5 safety net. |
207 |
fldsecs = int((fldsecs+0.5)/fldperiod)*fldperiod |
208 |
fldcount = int((fldsecs+0.5)/fldperiod) + 1 |
209 |
|
210 |
c Set switches for reading new records. |
211 |
first = ((mytime - modelstart) .lt. 0.5*modelstep) |
212 |
|
213 |
if ( first) then |
214 |
changed = .false. |
215 |
else |
216 |
call cal_GetDate( myiter-1, mytime-modelstep, |
217 |
& previousdate, mythid ) |
218 |
|
219 |
call cal_TimePassed( fldstartdate, previousdate, |
220 |
& difftime, mythid ) |
221 |
call cal_ToSeconds( difftime, prevfldsecs, mythid ) |
222 |
cgg Added a 0.5 safety net. |
223 |
prevfldsecs = int((prevfldsecs+0.5)/fldperiod)*fldperiod |
224 |
prevfldcount = int((prevfldsecs+0.5)/fldperiod) + 1 |
225 |
|
226 |
if (fldcount .ne. prevfldcount) then |
227 |
changed = .true. |
228 |
else |
229 |
changed = .false. |
230 |
endif |
231 |
endif |
232 |
|
233 |
count0 = fldcount |
234 |
count1 = fldcount + 1 |
235 |
|
236 |
call cal_TimeInterval( fldsecs, 'secs', difftime, mythid ) |
237 |
call cal_AddTime( fldstartdate, difftime, flddate, mythid ) |
238 |
call cal_TimePassed( flddate, mydate, difftime, mythid ) |
239 |
call cal_ToSeconds( difftime, fldsecs, mythid ) |
240 |
|
241 |
c Weight belonging to irec for linear interpolation purposes. |
242 |
c Note: The weight as chosen here is 1. - fac of the "old" |
243 |
c MITgcm's estimation program. |
244 |
fac = 1. - fldsecs/fldperiod |
245 |
|
246 |
#ifdef ECCO_VERBOSE |
247 |
c Do some printing for the protocol. |
248 |
_BEGIN_MASTER( mythid ) |
249 |
write(msgbuf,'(a)') ' ' |
250 |
call print_message( msgbuf, standardmessageunit, |
251 |
& SQUEEZE_RIGHT , mythid) |
252 |
write(msgbuf,'(a,a)') |
253 |
& ' ctrl_getrec: thefield: ', |
254 |
& thefield |
255 |
call print_message( msgbuf, standardmessageunit, |
256 |
& SQUEEZE_RIGHT , mythid) |
257 |
write(msgbuf,'(a,2x,l2,2x,l2,2x,D15.8)') |
258 |
& ' first, changed, fac:', |
259 |
& first, changed, fac |
260 |
call print_message( msgbuf, standardmessageunit, |
261 |
& SQUEEZE_RIGHT , mythid) |
262 |
write(msgbuf,'(a,i4,i4)') |
263 |
& ' count0, count1:', |
264 |
& count0, count1 |
265 |
call print_message( msgbuf, standardmessageunit, |
266 |
& SQUEEZE_RIGHT , mythid) |
267 |
write(msgbuf,'(a)') ' ' |
268 |
call print_message( msgbuf, standardmessageunit, |
269 |
& SQUEEZE_RIGHT , mythid) |
270 |
_END_MASTER( mythid ) |
271 |
#endif |
272 |
|
273 |
#endif /* ALLOW_CALENDAR */ |
274 |
|
275 |
return |
276 |
end |
277 |
|