/[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.3 - (show annotations) (download)
Thu Nov 6 22:05:08 2003 UTC (20 years, 7 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint52l_pre, hrcube4, hrcube5, checkpoint57g_pre, checkpoint57b_post, checkpoint52d_pre, checkpoint57g_post, checkpoint56b_post, checkpoint52j_pre, checkpoint54d_post, checkpoint54e_post, checkpoint57h_post, checkpoint57d_post, checkpoint57i_post, checkpoint52l_post, checkpoint52k_post, checkpoint55, checkpoint54, checkpoint57, checkpoint56, checkpoint53, checkpoint52, checkpoint52f_post, checkpoint54f_post, checkpoint55i_post, checkpoint57l_post, checkpoint52i_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint55c_post, checkpoint52e_pre, checkpoint57f_post, checkpoint52e_post, checkpoint53d_post, checkpoint57a_post, checkpoint57h_pre, checkpoint52b_pre, checkpoint54b_post, checkpoint52m_post, checkpoint55g_post, checkpoint52b_post, checkpoint52c_post, checkpoint57c_post, checkpoint52f_pre, checkpoint55d_post, checkpoint54a_pre, checkpoint53c_post, checkpoint55d_pre, checkpoint57c_pre, checkpoint55j_post, checkpoint54a_post, checkpoint55h_post, checkpoint57e_post, checkpoint55b_post, checkpoint53a_post, checkpoint55f_post, checkpoint52d_post, checkpoint53g_post, eckpoint57e_pre, checkpoint52a_pre, checkpoint52i_post, checkpoint52h_pre, checkpoint56a_post, checkpoint53f_post, checkpoint57h_done, checkpoint52j_post, checkpoint57j_post, checkpoint57f_pre, branch-netcdf, checkpoint52n_post, checkpoint53b_pre, checkpoint56c_post, checkpoint57a_pre, checkpoint55a_post, checkpoint57k_post, checkpoint53b_post, checkpoint52a_post, ecco_c52_e35, checkpoint53d_pre, checkpoint55e_post, checkpoint54c_post, checkpoint51u_post
Branch point for: netcdf-sm0
Changes since 1.2: +5 -4 lines
o merging from ecco-branch
o cleaned some cross-dependencies and updated CPP options

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

  ViewVC Help
Powered by ViewVC 1.1.22