/[MITgcm]/MITgcm/pkg/ctrl/ctrl_getrec.F
ViewVC logotype

Contents of /MITgcm/pkg/ctrl/ctrl_getrec.F

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


Revision 1.10 - (show annotations) (download)
Mon Mar 22 02:16:43 2010 UTC (14 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62t, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l
Changes since 1.9: +2 -2 lines
finish removing unbalanced quote (single or double) in commented line

1 C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_getrec.F,v 1.9 2007/10/09 00:00:00 jmc Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "CTRL_CPPOPTIONS.h"
6
7
8 subroutine ctrl_GetRec(
9 I thefield,
10 O fac,
11 O first,
12 O changed,
13 O count0,
14 O count1,
15 I mytime,
16 I myiter,
17 I mythid
18 & )
19
20 c ==================================================================
21 c SUBROUTINE ctrl_GetRec
22 c ==================================================================
23 c
24 c o Get flags, counters, and the linear interpolation factor for a
25 c given control vector contribution.
26 c
27 c started: Christian Eckert eckert@mit.edu 30-Jun-1999
28 c
29 c changed: Christian Eckert eckert@mit.edu 14-Jan-2000
30 c
31 c - Restructured the code in order to create a package
32 c for the MITgcmUV.
33 c
34 c Christian Eckert eckert@mit.edu 24-Feb-2000
35 c
36 c - Changed Routine names (package prefix: ecco_)
37 c
38 c ==================================================================
39 c SUBROUTINE ctrl_GetRec
40 c ==================================================================
41
42 implicit none
43
44 c == global variables ==
45
46 #include "EEPARAMS.h"
47 #include "SIZE.h"
48
49 #include "ctrl.h"
50 #ifdef ALLOW_CAL
51 # include "cal.h"
52 #endif
53
54 c == routine arguments ==
55
56 character*(*) thefield
57 _RL fac
58 logical first
59 logical changed
60 integer count0
61 integer count1
62 _RL mytime
63 integer myiter
64 integer mythid
65
66 c == local variables ==
67
68 #ifdef ALLOW_CAL
69
70 integer mydate(4)
71 integer previousdate(4)
72 integer difftime(4)
73
74 integer fldcount
75 _RL fldsecs
76 integer prevfldcount
77 _RL prevfldsecs
78 integer flddate(4)
79
80 integer fldstartdate(4)
81 _RL fldperiod
82
83 logical lArgErr
84
85 #ifdef ECCO_VERBOSE
86 character*(max_len_mbuf) msgbuf
87 #endif
88
89 c == end of interface ==
90
91 lArgErr = .true.
92 fldperiod = 0.
93
94 c Map the field parameters.
95
96 if ( thefield .eq. 'xx_hflux' ) then
97 call cal_CopyDate(
98 I xx_hfluxstartdate,
99 O fldstartdate,
100 I mythid
101 & )
102 fldperiod = xx_hfluxperiod
103 lArgErr = .false.
104 c
105 else if ( thefield .eq. 'xx_atemp' ) then
106 call cal_CopyDate(
107 I xx_atempstartdate,
108 O fldstartdate,
109 I mythid
110 & )
111 fldperiod = xx_atempperiod
112 lArgErr = .false.
113 c
114 else if ( thefield .eq. 'xx_sflux' ) then
115 call cal_CopyDate(
116 I xx_sfluxstartdate,
117 O fldstartdate,
118 I mythid
119 & )
120 fldperiod = xx_sfluxperiod
121 lArgErr = .false.
122 c
123 else if ( thefield .eq. 'xx_aqh' ) then
124 call cal_CopyDate(
125 I xx_aqhstartdate,
126 O fldstartdate,
127 I mythid
128 & )
129 fldperiod = xx_aqhperiod
130 lArgErr = .false.
131 c
132 else if ( thefield .eq. 'xx_precip' ) then
133 call cal_CopyDate(
134 I xx_precipstartdate,
135 O fldstartdate,
136 I mythid
137 & )
138 fldperiod = xx_precipperiod
139 lArgErr = .false.
140 c
141 else if ( thefield .eq. 'xx_swflux' ) then
142 call cal_CopyDate(
143 I xx_swfluxstartdate,
144 O fldstartdate,
145 I mythid
146 & )
147 fldperiod = xx_swfluxperiod
148 lArgErr = .false.
149 c
150 else if ( thefield .eq. 'xx_swdown' ) then
151 call cal_CopyDate(
152 I xx_swdownstartdate,
153 O fldstartdate,
154 I mythid
155 & )
156 fldperiod = xx_swdownperiod
157 lArgErr = .false.
158 c
159 else if ( thefield .eq. 'xx_lwflux' ) then
160 call cal_CopyDate(
161 I xx_lwfluxstartdate,
162 O fldstartdate,
163 I mythid
164 & )
165 fldperiod = xx_lwfluxperiod
166 lArgErr = .false.
167 c
168 else if ( thefield .eq. 'xx_lwdown' ) then
169 call cal_CopyDate(
170 I xx_lwdownstartdate,
171 O fldstartdate,
172 I mythid
173 & )
174 fldperiod = xx_lwdownperiod
175 lArgErr = .false.
176 c
177 else if ( thefield .eq. 'xx_evap' ) then
178 call cal_CopyDate(
179 I xx_evapstartdate,
180 O fldstartdate,
181 I mythid
182 & )
183 fldperiod = xx_evapperiod
184 lArgErr = .false.
185 c
186 else if ( thefield .eq. 'xx_snowprecip' ) then
187 call cal_CopyDate(
188 I xx_snowprecipstartdate,
189 O fldstartdate,
190 I mythid
191 & )
192 fldperiod = xx_snowprecipperiod
193 lArgErr = .false.
194 c
195 else if ( thefield .eq. 'xx_apressure' ) then
196 call cal_CopyDate(
197 I xx_apressurestartdate,
198 O fldstartdate,
199 I mythid
200 & )
201 fldperiod = xx_apressureperiod
202 lArgErr = .false.
203 c
204 else if ( thefield .eq. 'xx_runoff' ) then
205 call cal_CopyDate(
206 I xx_runoffstartdate,
207 O fldstartdate,
208 I mythid
209 & )
210 fldperiod = xx_runoffperiod
211 lArgErr = .false.
212 c
213 else if ( thefield .eq. 'xx_tauu' ) then
214 call cal_CopyDate(
215 I xx_tauustartdate,
216 O fldstartdate,
217 I mythid
218 & )
219 fldperiod = xx_tauuperiod
220 lArgErr = .false.
221 c
222 else if ( thefield .eq. 'xx_uwind' ) then
223 call cal_CopyDate(
224 I xx_uwindstartdate,
225 O fldstartdate,
226 I mythid
227 & )
228 fldperiod = xx_uwindperiod
229 lArgErr = .false.
230 c
231 else if ( thefield .eq. 'xx_tauv' ) then
232 call cal_CopyDate(
233 I xx_tauvstartdate,
234 O fldstartdate,
235 I mythid
236 & )
237 fldperiod = xx_tauvperiod
238 lArgErr = .false.
239 c
240 else if ( thefield .eq. 'xx_vwind' ) then
241 call cal_CopyDate(
242 I xx_vwindstartdate,
243 O fldstartdate,
244 I mythid
245 & )
246 fldperiod = xx_vwindperiod
247 lArgErr = .false.
248 c
249 else if ( thefield .eq. 'xx_obcsn' ) then
250 call cal_CopyDate(
251 I xx_obcsnstartdate,
252 O fldstartdate,
253 I mythid
254 & )
255 fldperiod = xx_obcsnperiod
256 lArgErr = .false.
257 c
258 else if ( thefield .eq. 'xx_obcss' ) then
259 call cal_CopyDate(
260 I xx_obcssstartdate,
261 O fldstartdate,
262 I mythid
263 & )
264 fldperiod = xx_obcssperiod
265 lArgErr = .false.
266 c
267 else if ( thefield .eq. 'xx_obcsw' ) then
268 call cal_CopyDate(
269 I xx_obcswstartdate,
270 O fldstartdate,
271 I mythid
272 & )
273 fldperiod = xx_obcswperiod
274 lArgErr = .false.
275 c
276 else if ( thefield .eq. 'xx_obcse' ) then
277 call cal_CopyDate(
278 I xx_obcsestartdate,
279 O fldstartdate,
280 I mythid
281 & )
282 fldperiod = xx_obcseperiod
283 lArgErr = .false.
284 c
285 else if ( thefield .eq. 'xx_sst' ) then
286 call cal_CopyDate(
287 I xx_sststartdate,
288 O fldstartdate,
289 I mythid
290 & )
291 fldperiod = xx_sstperiod
292 lArgErr = .false.
293 c
294 else if ( thefield .eq. 'xx_sss' ) then
295 call cal_CopyDate(
296 I xx_sssstartdate,
297 O fldstartdate,
298 I mythid
299 & )
300 fldperiod = xx_sssperiod
301 lArgErr = .false.
302 endif
303
304 c-- Check the field argument.
305 if ( lArgErr ) then
306 print*,' The subroutine *ctrl_GetRec* has been called'
307 print*,' with an illegal field specification.'
308 stop ' ... stopped in ctrl_GetRec.'
309 endif
310
311 c-- Determine the current date.
312 call cal_GetDate( myiter, mytime, mydate, mythid )
313
314 c Determine the flux record just before mycurrentdate.
315 call cal_TimePassed( fldstartdate, mydate, difftime,
316 & mythid )
317 call cal_ToSeconds( difftime, fldsecs, mythid )
318 cgg Added a 0.5 safety net.
319 fldsecs = int((fldsecs+0.5)/fldperiod)*fldperiod
320 fldcount = int((fldsecs+0.5)/fldperiod) + 1
321
322 c Set switches for reading new records.
323 first = ((mytime - modelstart) .lt. 0.5*modelstep)
324
325 if ( first) then
326 changed = .false.
327 else
328 call cal_GetDate( myiter-1, mytime-modelstep,
329 & previousdate, mythid )
330
331 call cal_TimePassed( fldstartdate, previousdate,
332 & difftime, mythid )
333 call cal_ToSeconds( difftime, prevfldsecs, mythid )
334 cgg Added a 0.5 safety net.
335 prevfldsecs = int((prevfldsecs+0.5)/fldperiod)*fldperiod
336 prevfldcount = int((prevfldsecs+0.5)/fldperiod) + 1
337
338 if (fldcount .ne. prevfldcount) then
339 changed = .true.
340 else
341 changed = .false.
342 endif
343 endif
344
345 count0 = fldcount
346 count1 = fldcount + 1
347
348 call cal_TimeInterval( fldsecs, 'secs', difftime, mythid )
349 call cal_AddTime( fldstartdate, difftime, flddate, mythid )
350 call cal_TimePassed( flddate, mydate, difftime, mythid )
351 call cal_ToSeconds( difftime, fldsecs, mythid )
352
353 c Weight belonging to irec for linear interpolation purposes.
354 c Note: The weight as chosen here is 1. - fac of the "old"
355 c MITgcm estimation program.
356 fac = 1. - fldsecs/fldperiod
357
358 #ifdef ECCO_VERBOSE
359 c Do some printing for the protocol.
360 _BEGIN_MASTER( mythid )
361 write(msgbuf,'(a)') ' '
362 call print_message( msgbuf, standardmessageunit,
363 & SQUEEZE_RIGHT , mythid)
364 write(msgbuf,'(a,a)')
365 & ' ctrl_getrec: thefield: ',
366 & thefield
367 call print_message( msgbuf, standardmessageunit,
368 & SQUEEZE_RIGHT , mythid)
369 write(msgbuf,'(a,2x,l2,2x,l2,2x,D15.8)')
370 & ' first, changed, fac:',
371 & first, changed, fac
372 call print_message( msgbuf, standardmessageunit,
373 & SQUEEZE_RIGHT , mythid)
374 write(msgbuf,'(a,i4,i4)')
375 & ' count0, count1:',
376 & count0, count1
377 call print_message( msgbuf, standardmessageunit,
378 & SQUEEZE_RIGHT , mythid)
379 write(msgbuf,'(a)') ' '
380 call print_message( msgbuf, standardmessageunit,
381 & SQUEEZE_RIGHT , mythid)
382 _END_MASTER( mythid )
383 #endif
384
385 #endif /* ALLOW_CAL */
386
387 return
388 end
389

  ViewVC Help
Powered by ViewVC 1.1.22