/[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.16 - (show annotations) (download)
Thu Oct 16 20:04:23 2014 UTC (9 years, 7 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65l, checkpoint65m, checkpoint65g, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65o, HEAD
Changes since 1.15: +40 -38 lines
- remove variables, codes associated with NON-generic NON-obcs
  controls, unless ECCO_CTRL_DEPRECATED is defined
- ctrl_readparms.F : include ctrl_local_params.h unless
  ECCO_CTRL_DEPRECATED is defined

1 C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_getrec.F,v 1.15 2014/10/09 00:49:26 gforget Exp $
2 C $Name: $
3
4 #include "CTRL_OPTIONS.h"
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 #include "ctrl.h"
47 #include "CTRL_OBCS.h"
48 #ifdef ALLOW_CAL
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_CAL
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 character*(max_len_mbuf) msgBuf
84 CML#ifdef ECCO_VERBOSE
85 CML character*(max_len_mbuf) msgbuf
86 CML#endif
87
88 c == end of interface ==
89
90 write(msgBuf,'(A)')
91 & 'Oops, I thought that this routine is never used.'
92 call print_error( msgBuf , 1)
93 write(msgBuf,'(A)')
94 & 'To continue, remove the stop statement from ctrl_getrec.F'
95 call print_error( msgBuf , 1)
96 write(msgBuf,'(A)')
97 & 'or use s/r ctrl_get_gen_rec instead.'
98 call print_error( msgBuf , 1)
99 stop 'ABNORMAL END: S/R CTRL_GETREC'
100
101 lArgErr = .true.
102 fldperiod = 0.
103
104 c Map the field parameters.
105
106 if ( thefield .eq. 'xx_obcsn' ) then
107 call cal_CopyDate(
108 I xx_obcsnstartdate,
109 O fldstartdate,
110 I mythid
111 & )
112 fldperiod = xx_obcsnperiod
113 lArgErr = .false.
114 c
115 else if ( thefield .eq. 'xx_obcss' ) then
116 call cal_CopyDate(
117 I xx_obcssstartdate,
118 O fldstartdate,
119 I mythid
120 & )
121 fldperiod = xx_obcssperiod
122 lArgErr = .false.
123 c
124 else if ( thefield .eq. 'xx_obcsw' ) then
125 call cal_CopyDate(
126 I xx_obcswstartdate,
127 O fldstartdate,
128 I mythid
129 & )
130 fldperiod = xx_obcswperiod
131 lArgErr = .false.
132 c
133 else if ( thefield .eq. 'xx_obcse' ) then
134 call cal_CopyDate(
135 I xx_obcsestartdate,
136 O fldstartdate,
137 I mythid
138 & )
139 fldperiod = xx_obcseperiod
140 lArgErr = .false.
141 c
142 #ifdef ECCO_CTRL_DEPRECATED
143 else if ( thefield .eq. 'xx_hflux' ) then
144 call cal_CopyDate(
145 I xx_hfluxstartdate,
146 O fldstartdate,
147 I mythid
148 & )
149 fldperiod = xx_hfluxperiod
150 lArgErr = .false.
151 c
152 else if ( thefield .eq. 'xx_atemp' ) then
153 call cal_CopyDate(
154 I xx_atempstartdate,
155 O fldstartdate,
156 I mythid
157 & )
158 fldperiod = xx_atempperiod
159 lArgErr = .false.
160 c
161 else if ( thefield .eq. 'xx_sflux' ) then
162 call cal_CopyDate(
163 I xx_sfluxstartdate,
164 O fldstartdate,
165 I mythid
166 & )
167 fldperiod = xx_sfluxperiod
168 lArgErr = .false.
169 c
170 else if ( thefield .eq. 'xx_aqh' ) then
171 call cal_CopyDate(
172 I xx_aqhstartdate,
173 O fldstartdate,
174 I mythid
175 & )
176 fldperiod = xx_aqhperiod
177 lArgErr = .false.
178 c
179 else if ( thefield .eq. 'xx_precip' ) then
180 call cal_CopyDate(
181 I xx_precipstartdate,
182 O fldstartdate,
183 I mythid
184 & )
185 fldperiod = xx_precipperiod
186 lArgErr = .false.
187 c
188 else if ( thefield .eq. 'xx_swflux' ) then
189 call cal_CopyDate(
190 I xx_swfluxstartdate,
191 O fldstartdate,
192 I mythid
193 & )
194 fldperiod = xx_swfluxperiod
195 lArgErr = .false.
196 c
197 else if ( thefield .eq. 'xx_swdown' ) then
198 call cal_CopyDate(
199 I xx_swdownstartdate,
200 O fldstartdate,
201 I mythid
202 & )
203 fldperiod = xx_swdownperiod
204 lArgErr = .false.
205 c
206 else if ( thefield .eq. 'xx_lwflux' ) then
207 call cal_CopyDate(
208 I xx_lwfluxstartdate,
209 O fldstartdate,
210 I mythid
211 & )
212 fldperiod = xx_lwfluxperiod
213 lArgErr = .false.
214 c
215 else if ( thefield .eq. 'xx_lwdown' ) then
216 call cal_CopyDate(
217 I xx_lwdownstartdate,
218 O fldstartdate,
219 I mythid
220 & )
221 fldperiod = xx_lwdownperiod
222 lArgErr = .false.
223 c
224 else if ( thefield .eq. 'xx_evap' ) then
225 call cal_CopyDate(
226 I xx_evapstartdate,
227 O fldstartdate,
228 I mythid
229 & )
230 fldperiod = xx_evapperiod
231 lArgErr = .false.
232 c
233 else if ( thefield .eq. 'xx_snowprecip' ) then
234 call cal_CopyDate(
235 I xx_snowprecipstartdate,
236 O fldstartdate,
237 I mythid
238 & )
239 fldperiod = xx_snowprecipperiod
240 lArgErr = .false.
241 c
242 else if ( thefield .eq. 'xx_apressure' ) then
243 call cal_CopyDate(
244 I xx_apressurestartdate,
245 O fldstartdate,
246 I mythid
247 & )
248 fldperiod = xx_apressureperiod
249 lArgErr = .false.
250 c
251 else if ( thefield .eq. 'xx_runoff' ) then
252 call cal_CopyDate(
253 I xx_runoffstartdate,
254 O fldstartdate,
255 I mythid
256 & )
257 fldperiod = xx_runoffperiod
258 lArgErr = .false.
259 c
260 else if ( thefield .eq. 'xx_tauu' ) then
261 call cal_CopyDate(
262 I xx_tauustartdate,
263 O fldstartdate,
264 I mythid
265 & )
266 fldperiod = xx_tauuperiod
267 lArgErr = .false.
268 c
269 else if ( thefield .eq. 'xx_uwind' ) then
270 call cal_CopyDate(
271 I xx_uwindstartdate,
272 O fldstartdate,
273 I mythid
274 & )
275 fldperiod = xx_uwindperiod
276 lArgErr = .false.
277 c
278 else if ( thefield .eq. 'xx_tauv' ) then
279 call cal_CopyDate(
280 I xx_tauvstartdate,
281 O fldstartdate,
282 I mythid
283 & )
284 fldperiod = xx_tauvperiod
285 lArgErr = .false.
286 c
287 else if ( thefield .eq. 'xx_vwind' ) then
288 call cal_CopyDate(
289 I xx_vwindstartdate,
290 O fldstartdate,
291 I mythid
292 & )
293 fldperiod = xx_vwindperiod
294 lArgErr = .false.
295 c
296 else if ( thefield .eq. 'xx_sst' ) then
297 call cal_CopyDate(
298 I xx_sststartdate,
299 O fldstartdate,
300 I mythid
301 & )
302 fldperiod = xx_sstperiod
303 lArgErr = .false.
304 c
305 else if ( thefield .eq. 'xx_sss' ) then
306 call cal_CopyDate(
307 I xx_sssstartdate,
308 O fldstartdate,
309 I mythid
310 & )
311 fldperiod = xx_sssperiod
312 lArgErr = .false.
313 #endif /* ECCO_CTRL_DEPRECATED */
314 endif
315
316 c-- Check the field argument.
317 if ( lArgErr ) then
318 print*,' The subroutine *ctrl_GetRec* has been called'
319 print*,' with an illegal field specification.'
320 stop ' ... stopped in ctrl_GetRec.'
321 endif
322
323 c-- Determine the current date.
324 call cal_GetDate( myiter, mytime, mydate, mythid )
325
326 c Determine the flux record just before mycurrentdate.
327 call cal_TimePassed( fldstartdate, mydate, difftime,
328 & mythid )
329 call cal_ToSeconds( difftime, fldsecs, mythid )
330 cgg Added a 0.5 safety net.
331 fldsecs = int((fldsecs+0.5)/fldperiod)*fldperiod
332 fldcount = int((fldsecs+0.5)/fldperiod) + 1
333
334 c Set switches for reading new records.
335 first = ((mytime - modelstart) .lt. 0.5*modelstep)
336
337 if ( first) then
338 changed = .false.
339 else
340 call cal_GetDate( myiter-1, mytime-modelstep,
341 & previousdate, mythid )
342
343 call cal_TimePassed( fldstartdate, previousdate,
344 & difftime, mythid )
345 call cal_ToSeconds( difftime, prevfldsecs, mythid )
346 cgg Added a 0.5 safety net.
347 prevfldsecs = int((prevfldsecs+0.5)/fldperiod)*fldperiod
348 prevfldcount = int((prevfldsecs+0.5)/fldperiod) + 1
349
350 if (fldcount .ne. prevfldcount) then
351 changed = .true.
352 else
353 changed = .false.
354 endif
355 endif
356
357 count0 = fldcount
358 count1 = fldcount + 1
359
360 call cal_TimeInterval( fldsecs, 'secs', difftime, mythid )
361 call cal_AddTime( fldstartdate, difftime, flddate, mythid )
362 call cal_TimePassed( flddate, mydate, difftime, mythid )
363 call cal_ToSeconds( difftime, fldsecs, mythid )
364
365 c Weight belonging to irec for linear interpolation purposes.
366 c Note: The weight as chosen here is 1. - fac of the "old"
367 c MITgcm estimation program.
368 fac = 1. - fldsecs/fldperiod
369
370 #ifdef ECCO_VERBOSE
371 c Do some printing for the protocol.
372 _BEGIN_MASTER( mythid )
373 write(msgbuf,'(a)') ' '
374 call print_message( msgbuf, standardmessageunit,
375 & SQUEEZE_RIGHT , mythid)
376 write(msgbuf,'(a,a)')
377 & ' ctrl_getrec: thefield: ',
378 & thefield
379 call print_message( msgbuf, standardmessageunit,
380 & SQUEEZE_RIGHT , mythid)
381 write(msgbuf,'(a,2x,l2,2x,l2,2x,D15.8)')
382 & ' first, changed, fac:',
383 & first, changed, fac
384 call print_message( msgbuf, standardmessageunit,
385 & SQUEEZE_RIGHT , mythid)
386 write(msgbuf,'(a,i4,i4)')
387 & ' count0, count1:',
388 & count0, count1
389 call print_message( msgbuf, standardmessageunit,
390 & SQUEEZE_RIGHT , mythid)
391 write(msgbuf,'(a)') ' '
392 call print_message( msgbuf, standardmessageunit,
393 & SQUEEZE_RIGHT , mythid)
394 _END_MASTER( mythid )
395 #endif
396
397 #endif /* ALLOW_CAL */
398
399 return
400 end

  ViewVC Help
Powered by ViewVC 1.1.22