/[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.23 - (show annotations) (download)
Sat Oct 18 13:12:27 2008 UTC (15 years, 7 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint61f, checkpoint61g, checkpoint61e, checkpoint61h, checkpoint61i
Changes since 1.22: +9 -1 lines
More calls.

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

  ViewVC Help
Powered by ViewVC 1.1.22