/[MITgcm]/MITgcm/pkg/obcs/obcs_mon_stats.F
ViewVC logotype

Contents of /MITgcm/pkg/obcs/obcs_mon_stats.F

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


Revision 1.3 - (show annotations) (download)
Mon Sep 17 22:06:17 2012 UTC (11 years, 8 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint64, checkpoint65, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, HEAD
Changes since 1.2: +19 -7 lines
- pass OB_indexNone as (new) argument to S/R OBCS_MON_STATS_EW,NS_RL;
- If 1 OB location is on 2 tiles (@ edge of 2 tiles), select the one which
  communicates with tile interior rather than with halo region.

1 C $Header: /u/gcmpack/MITgcm/pkg/obcs/obcs_mon_stats.F,v 1.2 2011/03/01 23:39:37 jmc Exp $
2 C $Name: $
3
4 #include "OBCS_OPTIONS.h"
5
6 C-- File obcs_mon_stats.F: compute statistic of a field at OB section
7 C-- Contents
8 C-- o OBCS_MON_STATS_EW_RL
9 C-- o OBCS_MON_STATS_NS_RL
10
11 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
12 CBOP
13 C !ROUTINE: OBCS_MON_STATS_EW_RL
14
15 C !INTERFACE:
16 SUBROUTINE OBCS_MON_STATS_EW_RL(
17 I tHasOBE, tHasOBW, iEb, iWb, iNone,
18 I kSize, mSize, gPos,
19 I arr, arrhFac, arrDy, arrDr, mskInC,
20 O arrStats,
21 I myThid )
22
23 C !DESCRIPTION:
24 C *==========================================================*
25 C | SUBROUTINE OBCS_MON_STATS_EW_RL
26 C | o Caclulate field statistics at Eastern & Western OB
27 C *==========================================================*
28
29 C !USES:
30 IMPLICIT NONE
31
32 C === Global variables ===
33 #include "SIZE.h"
34 #include "EEPARAMS.h"
35
36 C !INPUT PARAMETERS:
37 C tHasOBE :: list of OBE active tiles
38 C tHasOBW :: list of OBW active tiles
39 C iEb :: index of Eastern OB
40 C iWb :: index of Western OB
41 C iNone :: null index value
42 C kSize :: field-array 3rd dimension
43 C mSize :: hFac-array 3rd dimension
44 C gPos :: field position on C-grid ( 0=center , 1=U , 2=V , 3=Corner)
45 C arr :: field-array
46 C arrhFac :: hFac factor
47 C arrDy :: grid-cell length along OB
48 C arrDr :: grid-level thickness
49 C mskInC :: 2-d mask defining the interior region (cell centered)
50 C myThid :: my Thread Id number
51 LOGICAL tHasOBE(nSx,nSy)
52 LOGICAL tHasOBW(nSx,nSy)
53 INTEGER iEb(1-OLy:sNy+OLy,nSx,nSy)
54 INTEGER iWb(1-OLy:sNy+OLy,nSx,nSy)
55 INTEGER iNone
56 INTEGER kSize
57 INTEGER mSize
58 INTEGER gPos
59 _RL arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,kSize,nSx,nSy)
60 _RS arrhFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy,mSize,nSx,nSy)
61 _RS arrDy (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
62 _RS arrDr (kSize)
63 _RS mskInC (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
64 INTEGER myThid
65
66 C !OUTPUT PARAMETERS:
67 C arrStats :: field statistics at Eatern & Western OB
68 _RL arrStats(0:4,2)
69 CEOP
70
71 #ifdef ALLOW_OBCS
72 #ifdef ALLOW_MONITOR
73
74 C !FUNCTIONS:
75
76 C !LOCAL VARIABLES:
77 C bi, bj :: tile indices
78 C j, k :: loop indices
79 C ii, iB :: local index of open boundary
80 INTEGER bi, bj
81 INTEGER j, k, km
82 INTEGER ii, iB
83 LOGICAL noPnts
84 _RL tmpA, tmpV, tmpMask
85 _RL theMin, theMax, theArea, theMean, theVar
86 _RL tileArea(nSx,nSy)
87 _RL tileMean(nSx,nSy)
88 _RL tileVar (nSx,nSy)
89
90 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
91
92 DO k=0,4
93 arrStats(k,1) = 0. _d 0
94 ENDDO
95 #ifdef ALLOW_OBCS_EAST
96 theMin = 0.
97 theMax = 0.
98 theMean= 0.
99 theVar = 0.
100 theArea= 0.
101 noPnts = .TRUE.
102 c IF ( usingEast_OB ) THEN
103 DO bj=myByLo(myThid),myByHi(myThid)
104 DO bi=myBxLo(myThid),myBxHi(myThid)
105 tileArea(bi,bj) = 0.
106 tileMean(bi,bj) = 0.
107 tileVar (bi,bj) = 0.
108 IF ( tHasOBE(bi,bj) ) THEN
109 DO k=1,kSize
110 km = MIN(k,mSize)
111 DO j=1,sNy
112 tmpMask = 0.
113 ii = iEb(j,bi,bj)
114 C- If 1 OB location is on 2 tiles (@ edge of 2 tiles), select the one which
115 C communicates with tile interior (sNx+1) rather than with halo region (i=1)
116 IF ( ii.NE.iNone .AND. ii.GT.1 ) THEN
117 iB = ii
118 tmpMask = arrhFac(iB,j,km,bi,bj)
119 & *( mskInC(ii-1,j,bi,bj)-mskInC(ii,j,bi,bj) )
120 ENDIF
121 IF ( tmpMask.GT.0. _d 0 ) THEN
122 tmpV = arr(ii,j,k,bi,bj)
123 tmpA = arrDy(iB,j,bi,bj)*arrDr(k)*tmpMask
124 IF ( noPnts ) THEN
125 theMin = tmpV
126 theMax = tmpV
127 noPnts = .FALSE.
128 ENDIF
129 theMin = MIN( theMin, tmpV )
130 theMax = MAX( theMax, tmpV )
131 tileArea(bi,bj) = tileArea(bi,bj) + tmpA
132 tileMean(bi,bj) = tileMean(bi,bj) + tmpA*tmpV
133 tileVar (bi,bj) = tileVar (bi,bj) + tmpA*tmpV*tmpV
134 ENDIF
135 ENDDO
136 ENDDO
137 ENDIF
138 ENDDO
139 ENDDO
140 CALL GLOBAL_SUM_TILE_RL( tileArea, theArea, myThid )
141 c ENDIF
142 IF ( theArea.GT.0. ) THEN
143 CALL GLOBAL_SUM_TILE_RL( tileMean, theMean, myThid )
144 CALL GLOBAL_SUM_TILE_RL( tileVar , theVar , myThid )
145 arrStats(0,1) = theArea
146 arrStats(1,1) = theMean
147 arrStats(2,1) = theVar
148
149 theMean = theMean/theArea
150 IF ( noPnts ) theMin = theMean
151 theMin = -theMin
152 _GLOBAL_MAX_RL(theMin,myThid)
153 theMin = -theMin
154 IF ( noPnts ) theMax = theMean
155 _GLOBAL_MAX_RL(theMax,myThid)
156 arrStats(3,1) = theMin
157 arrStats(4,1) = theMax
158
159 ENDIF
160 #endif /* ALLOW_OBCS_EAST */
161
162 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
163
164 DO k=0,4
165 arrStats(k,2) = 0. _d 0
166 ENDDO
167 #ifdef ALLOW_OBCS_WEST
168 theMin = 0.
169 theMax = 0.
170 theMean= 0.
171 theVar = 0.
172 theArea= 0.
173 noPnts = .TRUE.
174 c IF ( usingWest_OB ) THEN
175 DO bj=myByLo(myThid),myByHi(myThid)
176 DO bi=myBxLo(myThid),myBxHi(myThid)
177 tileArea(bi,bj) = 0.
178 tileMean(bi,bj) = 0.
179 tileVar (bi,bj) = 0.
180 IF ( tHasOBW(bi,bj) ) THEN
181 DO k=1,kSize
182 km = MIN(k,mSize)
183 DO j=1,sNy
184 tmpMask = 0.
185 ii = iWb(j,bi,bj)
186 C- If 1 OB location is on 2 tiles (@ edge of 2 tiles), select the one which
187 C communicates with tile interior (i=0) rather than with halo region (i=sNx)
188 IF ( ii.NE.iNone .AND. ii.LT.sNx ) THEN
189 iB = ii+1
190 tmpMask = arrhFac(iB,j,km,bi,bj)
191 & *( mskInC(ii+1,j,bi,bj)-mskInC(ii,j,bi,bj) )
192 ENDIF
193 IF ( tmpMask.GT.0. _d 0 ) THEN
194 IF ( gPos.EQ.1 .OR. gPos.EQ.3 ) ii = iB
195 tmpV = arr(ii,j,k,bi,bj)
196 tmpA = arrDy(iB,j,bi,bj)*arrDr(k)*tmpMask
197 IF ( noPnts ) THEN
198 theMin = tmpV
199 theMax = tmpV
200 noPnts = .FALSE.
201 ENDIF
202 theMin = MIN( theMin, tmpV )
203 theMax = MAX( theMax, tmpV )
204 tileArea(bi,bj) = tileArea(bi,bj) + tmpA
205 tileMean(bi,bj) = tileMean(bi,bj) + tmpA*tmpV
206 tileVar (bi,bj) = tileVar (bi,bj) + tmpA*tmpV*tmpV
207 ENDIF
208 ENDDO
209 ENDDO
210 ENDIF
211 ENDDO
212 ENDDO
213 CALL GLOBAL_SUM_TILE_RL( tileArea, theArea, myThid )
214 c ENDIF
215 IF ( theArea.GT.0. ) THEN
216 CALL GLOBAL_SUM_TILE_RL( tileMean, theMean, myThid )
217 CALL GLOBAL_SUM_TILE_RL( tileVar , theVar , myThid )
218 arrStats(0,2) = theArea
219 arrStats(1,2) = theMean
220 arrStats(2,2) = theVar
221
222 theMean = theMean/theArea
223 IF ( noPnts ) theMin = theMean
224 theMin = -theMin
225 _GLOBAL_MAX_RL(theMin,myThid)
226 theMin = -theMin
227 IF ( noPnts ) theMax = theMean
228 _GLOBAL_MAX_RL(theMax,myThid)
229 arrStats(3,2) = theMin
230 arrStats(4,2) = theMax
231
232 ENDIF
233 #endif /* ALLOW_OBCS_WEST */
234
235 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
236
237 #endif /* ALLOW_MONITOR */
238 #endif /* ALLOW_OBCS */
239
240 RETURN
241 END
242
243 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
244 CBOP
245 C !ROUTINE: OBCS_MON_STATS_NS_RL
246
247 C !INTERFACE:
248 SUBROUTINE OBCS_MON_STATS_NS_RL(
249 I tHasOBN, tHasOBS, jNb, jSb, jNone,
250 I kSize, mSize, gPos,
251 I arr, arrhFac, arrDx, arrDr, mskInC,
252 O arrStats,
253 I myThid )
254
255 C !DESCRIPTION:
256 C *==========================================================*
257 C | SUBROUTINE OBCS_MON_STATS_NS_RL
258 C | o Caclulate field statistics at Northern & Southern OB
259 C *==========================================================*
260
261 C !USES:
262 IMPLICIT NONE
263
264 C === Global variables ===
265 #include "SIZE.h"
266 #include "EEPARAMS.h"
267
268 C !INPUT PARAMETERS:
269 C tHasOBN :: list of OBN active tiles
270 C tHasOBS :: list of OBS active tiles
271 C jNb :: index of Northern OB
272 C jSb :: index of Southern OB
273 C jNone :: null index value
274 C kSize :: field-array 3rd dimension
275 C mSize :: hFac-array 3rd dimension
276 C gPos :: field position on C-grid ( 0=center , 1=U , 2=V , 3=Corner)
277 C arr :: field-array
278 C arrhFac :: hFac factor
279 C arrDx :: grid-cell length along OB
280 C arrDr :: grid-level thickness
281 C mskInC :: 2-d mask defining the interior region (cell centered)
282 C myThid :: my Thread Id number
283 LOGICAL tHasOBN(nSx,nSy)
284 LOGICAL tHasOBS(nSx,nSy)
285 INTEGER jNb(1-OLx:sNx+OLx,nSx,nSy)
286 INTEGER jSb(1-OLx:sNx+OLx,nSx,nSy)
287 INTEGER jNone
288 INTEGER kSize
289 INTEGER mSize
290 INTEGER gPos
291 _RL arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,kSize,nSx,nSy)
292 _RS arrhFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy,mSize,nSx,nSy)
293 _RS arrDx (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
294 _RS arrDr (kSize)
295 _RS mskInC (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
296 INTEGER myThid
297
298 C !OUTPUT PARAMETERS:
299 C arrStats :: field statistics at Northern & Southern OB
300 _RL arrStats(0:4,2)
301 CEOP
302
303 #ifdef ALLOW_OBCS
304 #ifdef ALLOW_MONITOR
305
306 C !FUNCTIONS:
307
308 C !LOCAL VARIABLES:
309 C bi, bj :: tile indices
310 C i, k :: loop indices
311 C jj, jB :: local index of open boundary
312 INTEGER bi, bj
313 INTEGER i, k, km
314 INTEGER jj, jB
315 LOGICAL noPnts
316 _RL tmpA, tmpV, tmpMask
317 _RL theMin, theMax, theArea, theMean, theVar
318 _RL tileArea(nSx,nSy)
319 _RL tileMean(nSx,nSy)
320 _RL tileVar (nSx,nSy)
321
322 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
323
324 DO k=0,4
325 arrStats(k,1) = 0. _d 0
326 ENDDO
327 #ifdef ALLOW_OBCS_NORTH
328 theMin = 0.
329 theMax = 0.
330 theMean= 0.
331 theVar = 0.
332 theArea= 0.
333 noPnts = .TRUE.
334 c IF ( usingNorth_OB ) THEN
335 DO bj=myByLo(myThid),myByHi(myThid)
336 DO bi=myBxLo(myThid),myBxHi(myThid)
337 tileArea(bi,bj) = 0.
338 tileMean(bi,bj) = 0.
339 tileVar (bi,bj) = 0.
340 IF ( tHasOBN(bi,bj) ) THEN
341 DO k=1,kSize
342 km = MIN(k,mSize)
343 DO i=1,sNx
344 tmpMask = 0.
345 jj = jNb(i,bi,bj)
346 C- If 1 OB location is on 2 tiles (@ edge of 2 tiles), select the one which
347 C communicates with tile interior (sNy+1) rather than with halo region (j=1)
348 IF ( jj.NE.jNone .AND. jj.GT.1 ) THEN
349 jB = jj
350 tmpMask = arrhFac(i,jB,km,bi,bj)
351 & *( mskInC(i,jj-1,bi,bj)-mskInC(i,jj,bi,bj) )
352 ENDIF
353 IF ( tmpMask.GT.0. _d 0 ) THEN
354 tmpV = arr(i,jj,k,bi,bj)
355 tmpA = arrDx(i,jB,bi,bj)*arrDr(k)*tmpMask
356 IF ( noPnts ) THEN
357 theMin = tmpV
358 theMax = tmpV
359 noPnts = .FALSE.
360 ENDIF
361 theMin = MIN( theMin, tmpV )
362 theMax = MAX( theMax, tmpV )
363 tileArea(bi,bj) = tileArea(bi,bj) + tmpA
364 tileMean(bi,bj) = tileMean(bi,bj) + tmpA*tmpV
365 tileVar (bi,bj) = tileVar (bi,bj) + tmpA*tmpV*tmpV
366 ENDIF
367 ENDDO
368 ENDDO
369 ENDIF
370 ENDDO
371 ENDDO
372 CALL GLOBAL_SUM_TILE_RL( tileArea, theArea, myThid )
373 c ENDIF
374 IF ( theArea.GT.0. ) THEN
375 CALL GLOBAL_SUM_TILE_RL( tileMean, theMean, myThid )
376 CALL GLOBAL_SUM_TILE_RL( tileVar , theVar , myThid )
377 arrStats(0,1) = theArea
378 arrStats(1,1) = theMean
379 arrStats(2,1) = theVar
380
381 theMean = theMean/theArea
382 IF ( noPnts ) theMin = theMean
383 theMin = -theMin
384 _GLOBAL_MAX_RL(theMin,myThid)
385 theMin = -theMin
386 IF ( noPnts ) theMax = theMean
387 _GLOBAL_MAX_RL(theMax,myThid)
388 arrStats(3,1) = theMin
389 arrStats(4,1) = theMax
390
391 ENDIF
392 #endif /* ALLOW_OBCS_NORTH */
393
394 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
395
396 DO k=0,4
397 arrStats(k,2) = 0. _d 0
398 ENDDO
399 #ifdef ALLOW_OBCS_SOUTH
400 theMin = 0.
401 theMax = 0.
402 theMean= 0.
403 theVar = 0.
404 theArea= 0.
405 noPnts = .TRUE.
406 c IF ( usingSouth_OB ) THEN
407 DO bj=myByLo(myThid),myByHi(myThid)
408 DO bi=myBxLo(myThid),myBxHi(myThid)
409 tileArea(bi,bj) = 0.
410 tileMean(bi,bj) = 0.
411 tileVar (bi,bj) = 0.
412 IF ( tHasOBS(bi,bj) ) THEN
413 DO k=1,kSize
414 km = MIN(k,mSize)
415 DO i=1,sNx
416 tmpMask = 0.
417 jj = jSb(i,bi,bj)
418 C- If 1 OB location is on 2 tiles (@ edge of 2 tiles), select the one which
419 C communicates with tile interior (j=0) rather than with halo region (j=sNy)
420 IF ( jj.NE.jNone .AND. jj.LT.sNy ) THEN
421 jB = jj+1
422 tmpMask = arrhFac(i,jB,km,bi,bj)
423 & *( mskInC(i,jj+1,bi,bj)-mskInC(i,jj,bi,bj) )
424 ENDIF
425 IF ( tmpMask.GT.0. _d 0 ) THEN
426 IF ( gPos.EQ.2 .OR. gPos.EQ.3 ) jj = jB
427 tmpV = arr(i,jj,k,bi,bj)
428 tmpA = arrDx(i,jB,bi,bj)*arrDr(k)*tmpMask
429 IF ( noPnts ) THEN
430 theMin = tmpV
431 theMax = tmpV
432 noPnts = .FALSE.
433 ENDIF
434 theMin = MIN( theMin, tmpV )
435 theMax = MAX( theMax, tmpV )
436 tileArea(bi,bj) = tileArea(bi,bj) + tmpA
437 tileMean(bi,bj) = tileMean(bi,bj) + tmpA*tmpV
438 tileVar (bi,bj) = tileVar (bi,bj) + tmpA*tmpV*tmpV
439 ENDIF
440 ENDDO
441 ENDDO
442 ENDIF
443 ENDDO
444 ENDDO
445 CALL GLOBAL_SUM_TILE_RL( tileArea, theArea, myThid )
446 c ENDIF
447 IF ( theArea.GT.0. ) THEN
448 CALL GLOBAL_SUM_TILE_RL( tileMean, theMean, myThid )
449 CALL GLOBAL_SUM_TILE_RL( tileVar , theVar , myThid )
450 arrStats(0,2) = theArea
451 arrStats(1,2) = theMean
452 arrStats(2,2) = theVar
453
454 theMean = theMean/theArea
455 IF ( noPnts ) theMin = theMean
456 theMin = -theMin
457 _GLOBAL_MAX_RL(theMin,myThid)
458 theMin = -theMin
459 IF ( noPnts ) theMax = theMean
460 _GLOBAL_MAX_RL(theMax,myThid)
461 arrStats(3,2) = theMin
462 arrStats(4,2) = theMax
463
464 ENDIF
465 #endif /* ALLOW_OBCS_SOUTH */
466
467 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
468
469 #endif /* ALLOW_MONITOR */
470 #endif /* ALLOW_OBCS */
471
472 RETURN
473 END

  ViewVC Help
Powered by ViewVC 1.1.22