/[MITgcm]/MITgcm/pkg/ecco/cost_averagesfields.F
ViewVC logotype

Contents of /MITgcm/pkg/ecco/cost_averagesfields.F

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


Revision 1.8 - (show annotations) (download)
Thu Feb 16 22:05:51 2006 UTC (18 years, 3 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint58c_post, checkpoint58b_post
Changes since 1.7: +1 -1 lines
Iwerdwahnsinnig!

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_averagesfields.F,v 1.7 2006/02/16 21:57:12 heimbach Exp $
2
3 #include "COST_CPPOPTIONS.h"
4 #ifdef ALLOW_OBCS
5 # include "OBCS_OPTIONS.h"
6 #endif
7 #ifdef ALLOW_SEAICE
8 # include "SEAICE_OPTIONS.h"
9 #endif
10
11 subroutine cost_averagesfields( mytime, mythid )
12
13 c ==================================================================
14 c SUBROUTINE cost_averagesfields
15 c ==================================================================
16 c
17 c o Compute time averages of etaN, theta, and salt. The counters
18 c are explicitly calculated instead of being incremented. This
19 c reduces dependencies. The latter is useful for the adjoint code
20 c generation.
21 c
22 c started: Christian Eckert eckert@mit.edu 30-Jun-1999
23 c
24 c changed: Christian Eckert eckert@mit.edu 24-Feb-2000
25 c
26 c - Restructured the code in order to create a package
27 c for the MITgcmUV.
28 c
29 c ==================================================================
30 c SUBROUTINE cost_averagesfields
31 c ==================================================================
32
33 implicit none
34
35 c == global variables ==
36
37 #include "EEPARAMS.h"
38 #include "SIZE.h"
39 #include "PARAMS.h"
40 #include "DYNVARS.h"
41 #include "CG2D.h"
42
43 #include "optim.h"
44 #include "ecco_cost.h"
45 #include "ctrl_dummy.h"
46 #ifdef ALLOW_EXF
47 # include "exf_fields.h"
48 #endif
49 #ifdef ALLOW_SEAICE
50 # include "SEAICE.h"
51 # include "SEAICE_COST.h"
52 #endif
53
54 c == routine arguments ==
55
56 _RL mytime
57 integer mythid
58
59 c == local variables ==
60
61 integer myiter
62 integer bi,bj
63 integer i,j,k
64 integer itlo,ithi
65 integer jtlo,jthi
66 integer jmin,jmax
67 integer imin,imax
68
69 logical first
70 logical startofday
71 logical startofmonth
72 logical inday
73 logical inmonth
74 logical last
75 logical endofday
76 logical endofmonth
77
78 integer ilps, ils,ilt
79
80 character*(128) fnamepsbar
81 character*(128) fnametbar
82 character*(128) fnamesbar
83 character*(128) fnameubar
84 character*(128) fnamevbar
85 character*(128) fnamewbar
86 character*(128) fnametauxbar
87 character*(128) fnametauybar
88 character*(128) fnamehfluxbar
89 character*(128) fnamesfluxbar
90
91 c == external functions ==
92
93 integer ilnblnk
94 external ilnblnk
95
96 c == end of interface ==
97
98 jtlo = mybylo(mythid)
99 jthi = mybyhi(mythid)
100 itlo = mybxlo(mythid)
101 ithi = mybxhi(mythid)
102 jmin = 1
103 jmax = sny
104 imin = 1
105 imax = snx
106
107 myiter = niter0 + INT((mytime-starttime)/deltaTClock+0.5)
108
109 c-- Get the time flags and record numbers for the time averaging.
110
111 call cost_averagesflags(
112 I myiter, mytime, mythid,
113 O first, startofday, startofmonth,
114 O inday, inmonth,
115 O last, endofday, endofmonth,
116 O sum1day, dayrec,
117 O sum1mon, monrec
118 & )
119
120 #ifdef ALLOW_SSH_COST_CONTRIBUTION
121 call cost_averagesgeneric(
122 & psbarfile,
123 & psbar, etan, xx_psbar_mean_dummy,
124 & first, last, startofday, endofday, inday,
125 & sum1day, dayrec, 1, mythid )
126 #endif
127
128 #if (defined (ALLOW_THETA_COST_CONTRIBUTION) || \
129 defined (ALLOW_CTDT_COST_CONTRIBUTION) || \
130 defined (ALLOW_XBT_COST_CONTRIBUTION) || \
131 defined (ALLOW_ARGO_THETA_COST_CONTRIBUTION) || \
132 defined (ALLOW_DRIFT_COST_CONTRIBUTION) || \
133 defined (ALLOW_OBCS_COST_CONTRIBUTION))
134 call cost_averagesgeneric(
135 & tbarfile,
136 & tbar, theta, xx_tbar_mean_dummy,
137 & first, last, startofmonth, endofmonth, inmonth,
138 & sum1mon, monrec, nr, mythid )
139 #else
140 #ifdef ALLOW_SST_COST_CONTRIBUTION
141 call cost_averagesgeneric(
142 & tbarfile,
143 & tbar, theta(1-Olx,1-Oly,1,1,1), xx_tbar_mean_dummy,
144 & first, last, startofmonth, endofmonth, inmonth,
145 & sum1mon, monrec, 1, mythid )
146 #endif
147 #endif
148
149 #if (defined (ALLOW_SALT_COST_CONTRIBUTION) || \
150 defined (ALLOW_CTDS_COST_CONTRIBUTION) || \
151 defined (ALLOW_ARGO_SALT_COST_CONTRIBUTION) || \
152 defined (ALLOW_DRIFT_COST_CONTRIBUTION) || \
153 defined (ALLOW_OBCS_COST_CONTRIBUTION))
154 call cost_averagesgeneric(
155 & sbarfile,
156 & sbar, salt, xx_sbar_mean_dummy,
157 & first, last, startofmonth, endofmonth, inmonth,
158 & sum1mon, monrec, nr, mythid )
159 #else
160 #ifdef ALLOW_SSS_COST_CONTRIBUTION
161 call cost_averagesgeneric(
162 & sbarfile,
163 & sbar, salt(1-Olx,1-Oly,1,1,1), xx_sbar_mean_dummy,
164 & first, last, startofmonth, endofmonth, inmonth,
165 & sum1mon, monrec, 1, mythid )
166 #endif
167 #endif
168
169 #ifdef ALLOW_DRIFTW_COST_CONTRIBUTION
170 call cost_averagesgeneric(
171 & wbarfile,
172 & wbar, wvel, xx_wbar_mean_dummy,
173 & first, last, startofmonth, endofmonth, inmonth,
174 & sum1mon, monrec, nr, mythid )
175 #endif
176
177 #if (defined (ALLOW_DRIFTER_COST_CONTRIBUTION) || \
178 defined (ALLOW_OBCS_COST_CONTRIBUTION))
179 cph There is a mismatch between the cost_drifer and the
180 cph cost_obcs usage of ubar, vbar.
181 cph cost_obcs refers to monthly means, cost_drifer to total mean.
182 cph Needs to be updated for cost_obcs!!!.
183 c-- Next, do the averages for velocitty.
184 if (first.or.startofmonth) then
185 do bj = jtlo,jthi
186 do bi = itlo,ithi
187 do k = 1,nr
188 do j = jmin,jmax
189 do i = imin,imax
190 ubar(i,j,k,bi,bj) = uVel(i,j,k,bi,bj)
191 vbar(i,j,k,bi,bj) = vVel(i,j,k,bi,bj)
192 enddo
193 enddo
194 enddo
195 enddo
196 enddo
197 else if (last .or. endofmonth) then
198 do bj = jtlo,jthi
199 do bi = itlo,ithi
200 do k = 1,nr
201 do j = jmin,jmax
202 do i = imin,imax
203 ubar(i,j,k,bi,bj) = (ubar (i,j,k,bi,bj) +
204 & uVel(i,j,k,bi,bj) )/
205 & float(sum1mon)
206 vbar(i,j,k,bi,bj) = (vbar (i,j,k,bi,bj) +
207 & vVel(i,j,k,bi,bj) )/
208 & float(sum1mon)
209 enddo
210 enddo
211 enddo
212 enddo
213 enddo
214
215 c-- Save ubar and vbar.
216 if (optimcycle .ge. 0) then
217 ils=ilnblnk( ubarfile )
218 write(fnameubar,'(2a,i10.10)') ubarfile(1:ils),'.',
219 & optimcycle
220 write(fnamevbar,'(2a,i10.10)') vbarfile(1:ils),'.',
221 & optimcycle
222 endif
223
224 call active_write_xyz( fnameubar, ubar, monrec, optimcycle,
225 & mythid, xx_ubar_mean_dummy)
226
227 call active_write_xyz( fnamevbar, vbar, monrec, optimcycle,
228 & mythid, xx_vbar_mean_dummy)
229
230 ce , myiter, mytime )
231
232 else if ( ( inmonth ) .and.
233 & .not. (first .or. startofmonth) .and.
234 & .not. (last .or. endofmonth ) ) then
235 c-- Accumulate ubar and vbar.
236 do bj = jtlo,jthi
237 do bi = itlo,ithi
238 do k = 1,nr
239 do j = jmin,jmax
240 do i = imin,imax
241 ubar(i,j,k,bi,bj) = ubar (i,j,k,bi,bj) +
242 & uVel (i,j,k,bi,bj)
243 vbar(i,j,k,bi,bj) = vbar (i,j,k,bi,bj) +
244 & vVel (i,j,k,bi,bj)
245 enddo
246 enddo
247 enddo
248 enddo
249 enddo
250 else
251 stop ' ... stopped in cost_averagesfields; ubar part.'
252 endif
253
254 #endif
255
256 #ifdef ALLOW_SCAT_COST_CONTRIBUTION
257 c-- Next, do the averages for velocitty.
258 if (first.or. startofmonth) then
259 do bj = jtlo,jthi
260 do bi = itlo,ithi
261 do j = jmin,jmax
262 do i = imin,imax
263 tauxbar(i,j,bi,bj) = ustress(i,j,bi,bj)
264 tauybar(i,j,bi,bj) = vstress(i,j,bi,bj)
265 enddo
266 enddo
267 enddo
268 enddo
269 else if (last .or. endofmonth) then
270 do bj = jtlo,jthi
271 do bi = itlo,ithi
272 do j = jmin,jmax
273 do i = imin,imax
274 tauxbar(i,j,bi,bj) = (tauxbar (i,j,bi,bj) +
275 & ustress(i,j,bi,bj) )/
276 & float(sum1mon)
277 tauybar(i,j,bi,bj) = (tauybar (i,j,bi,bj) +
278 & vstress(i,j,bi,bj) )/
279 & float(sum1mon)
280 enddo
281 enddo
282 enddo
283 enddo
284
285 c-- Save ubar and vbar.
286 if (optimcycle .ge. 0) then
287 ils=ilnblnk( tauxbarfile )
288 write(fnametauxbar,'(2a,i10.10)') tauxbarfile(1:ils),'.',
289 & optimcycle
290 ils=ilnblnk( tauybarfile )
291 write(fnametauybar,'(2a,i10.10)') tauybarfile(1:ils),'.',
292 & optimcycle
293 endif
294
295 call active_write_xy( fnametauxbar, tauxbar, monrec, optimcycle,
296 & mythid, xx_taux_mean_dummy)
297
298 call active_write_xy( fnametauybar, tauybar, monrec, optimcycle,
299 & mythid, xx_tauy_mean_dummy)
300
301
302 else if ( .not. (first.or. startofmonth) .and.
303 & .not. (last .or. endofmonth) ) then
304 c-- Accumulate ubar and vbar.
305 do bj = jtlo,jthi
306 do bi = itlo,ithi
307 do j = jmin,jmax
308 do i = imin,imax
309 tauxbar(i,j,bi,bj) = tauxbar (i,j,bi,bj) +
310 & ustress (i,j,bi,bj)
311 tauybar(i,j,bi,bj) = tauybar (i,j,bi,bj) +
312 & vstress (i,j,bi,bj)
313 enddo
314 enddo
315 enddo
316 enddo
317 else
318 stop ' ... stopped in cost_averagesfields; tauxbar part.'
319 endif
320
321
322 #endif
323
324 #ifdef ALLOW_MEAN_HFLUX_COST_CONTRIBUTION
325 c-- Next, do the averages for velocitty.
326 if (first) then
327 do bj = jtlo,jthi
328 do bi = itlo,ithi
329 do j = jmin,jmax
330 do i = imin,imax
331 hfluxbar(i,j,bi,bj)=hflux(i,j,bi,bj)
332 enddo
333 enddo
334 enddo
335 enddo
336 else if (last) then
337 do bj = jtlo,jthi
338 do bi = itlo,ithi
339 do j = jmin,jmax
340 do i = imin,imax
341 hfluxbar(i,j,bi,bj) =
342 & ( hfluxbar (i,j,bi,bj) + hflux(i,j,bi,bj) )
343 & /float(nTimeSteps)
344 enddo
345 enddo
346 enddo
347 enddo
348
349 c-- Save hfluxbar
350 if (optimcycle .ge. 0) then
351 ils=ilnblnk( hfluxbarfile )
352 write(fnamehfluxbar,'(2a,i10.10)') hfluxbarfile(1:ils),'.',
353 & optimcycle
354 endif
355
356 call active_write_xy( fnamehfluxbar, hfluxbar, 1,
357 & optimcycle, mythid, xx_hflux_mean_dummy)
358
359 else if ( .not. (first) .and.
360 & .not. (last ) ) then
361 c-- Accumulate ubar and vbar.
362 do bj = jtlo,jthi
363 do bi = itlo,ithi
364 do j = jmin,jmax
365 do i = imin,imax
366 hfluxbar(i,j,bi,bj) =
367 & hfluxbar(i,j,bi,bj) + hflux(i,j,bi,bj)
368 enddo
369 enddo
370 enddo
371 enddo
372 else
373 stop ' ... stopped in cost_averagesfields; hfluxbar part.'
374 endif
375
376 #endif
377
378 #ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION
379 c-- Next, do the averages for velocitty.
380 if (first ) then
381 do bj = jtlo,jthi
382 do bi = itlo,ithi
383 do j = jmin,jmax
384 do i = imin,imax
385 sfluxbar(i,j,bi,bj) = sflux(i,j,bi,bj)
386 enddo
387 enddo
388 enddo
389 enddo
390 else if (last) then
391 do bj = jtlo,jthi
392 do bi = itlo,ithi
393 do j = jmin,jmax
394 do i = imin,imax
395 sfluxbar(i,j,bi,bj) = (sfluxbar (i,j,bi,bj) +
396 & sflux(i,j,bi,bj) )/
397 & float(nTimeSteps)
398 enddo
399 enddo
400 enddo
401 enddo
402
403
404 c-- Save sfluxbar
405 if (optimcycle .ge. 0) then
406 ils=ilnblnk( sfluxbarfile )
407 write(fnamesfluxbar,'(2a,i10.10)') sfluxbarfile(1:ils),'.',
408 & optimcycle
409 endif
410
411 call active_write_xy( fnamesfluxbar, sfluxbar, 1,
412 & optimcycle, mythid, xx_sflux_mean_dummy)
413
414 else if ( .not. (first) .and.
415 & .not. (last ) ) then
416 c-- Accumulate ubar and vbar.
417 do bj = jtlo,jthi
418 do bi = itlo,ithi
419 do j = jmin,jmax
420 do i = imin,imax
421 sfluxbar(i,j,bi,bj) = sfluxbar (i,j,bi,bj) +
422 & sflux (i,j,bi,bj)
423 enddo
424 enddo
425 enddo
426 enddo
427 else
428 print*
429 stop ' ... stopped in cost_averagesfields; sfluxbar part.'
430 endif
431
432 #endif
433
434 #ifdef ALLOW_SEAICE
435
436 # ifdef ALLOW_SEAICE_COST_SMR_AREA
437 call cost_averagesgeneric(
438 & smrareabarfile,
439 & smrareabar, area, xx_smrareabar_mean_dummy,
440 & first, last, startofday, endofday, inday,
441 & sum1day, dayrec, 1, mythid )
442 # endif
443
444 #endif /* ALLOW_SEAICE */
445
446 return
447 end
448

  ViewVC Help
Powered by ViewVC 1.1.22