/[MITgcm]/MITgcm/pkg/diagnostics/diagstats_local.F
ViewVC logotype

Annotation of /MITgcm/pkg/diagnostics/diagstats_local.F

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


Revision 1.5 - (hide annotations) (download)
Fri Nov 4 01:30:33 2005 UTC (18 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint57y_post, checkpoint57y_pre, checkpoint58, checkpoint57x_post, checkpoint57z_post
Changes since 1.4: +1 -2 lines
remove unused variables (reduces number of compiler warning)

1 jmc 1.5 C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagstats_local.F,v 1.4 2005/07/11 19:02:17 jmc Exp $
2 jmc 1.1 C $Name: $
3    
4     #include "DIAG_OPTIONS.h"
5    
6     CBOP
7     C !ROUTINE: DIAGSTATS_LOCAL
8     C !INTERFACE:
9     SUBROUTINE DIAGSTATS_LOCAL(
10     U statFld,
11 jmc 1.4 I inpFld, frcFld,
12     I scaleFact, power, useFract, sizF,
13 jmc 1.1 I sizI1,sizI2,sizJ1,sizJ2,sizK,sizTx,sizTy,
14     I iRun,jRun,kIn,biIn,bjIn,
15     I k,bi,bj, region2fill, ndId, parsFld,
16     I myThid)
17    
18     C !DESCRIPTION:
19 jmc 1.2 C Update array statFld
20 jmc 1.1 C by adding statistics over the range [1:iRun],[1:jRun]
21     C from input field array inpFld
22 jmc 1.2 C- note:
23 jmc 1.1 C a) this S/R should not see DIAGNOSTICS pkg commons blocks (in DIAGNOSTICS.h)
24     C b) for main grid variables, get area & weigting factors (to compute global mean)
25     C from the main common blocks.
26 jmc 1.2 C c) for other type of grids, call a specifics S/R which include its own
27 jmc 1.1 C grid common blocks
28    
29     C !USES:
30     IMPLICIT NONE
31    
32     #include "EEPARAMS.h"
33     #include "SIZE.h"
34     #include "DIAGNOSTICS_SIZE.h"
35     #include "PARAMS.h"
36     #include "GRID.h"
37 jmc 1.2 c #include "SURFACE.h"
38 jmc 1.1
39     C !INPUT/OUTPUT PARAMETERS:
40     C == Routine Arguments ==
41     C statFld :: cumulative statistics array (updated)
42     C inpFld :: input field array to process (compute stats & add to statFld)
43 jmc 1.3 C frcFld :: fraction used for weighted-average diagnostics
44     C scaleFact :: scaling factor
45 jmc 1.4 C power :: option to fill-in with the field square (power=2)
46 jmc 1.3 C useFract :: if True, use fraction-weight
47     C sizF :: size of frcFld array: 3rd dimension
48 jmc 1.1 C sizI1,sizI2 :: size of inpFld array: 1rst index range (min,max)
49     C sizJ1,sizJ2 :: size of inpFld array: 2nd index range (min,max)
50     C sizK :: size of inpFld array: 3rd dimension
51     C sizTx,sizTy :: size of inpFld array: tile dimensions
52     C iRun,jRun :: range of 1rst & 2nd index
53 jmc 1.3 C kIn :: level index of inpFld array to porcess
54     C biIn,bjIn :: tile indices of inpFld array to process
55 jmc 1.1 C k,bi,bj :: level and tile indices used for weighting (mask,area ...)
56     C region2fill :: indicates whether to compute statistics over this region
57     C ndId :: Diagnostics Id Number (in available diag. list)
58     C parsFld :: parser field with characteristics of the diagnostics
59     C myThid :: my Thread Id number
60     _RL statFld(0:nStats,0:nRegions)
61     INTEGER sizI1,sizI2,sizJ1,sizJ2
62 jmc 1.3 INTEGER sizF,sizK,sizTx,sizTy
63 jmc 1.1 _RL inpFld(sizI1:sizI2,sizJ1:sizJ2,sizK,sizTx,sizTy)
64 jmc 1.3 _RL frcFld(sizI1:sizI2,sizJ1:sizJ2,sizF,sizTx,sizTy)
65     _RL scaleFact
66 jmc 1.4 INTEGER power
67 jmc 1.3 LOGICAL useFract
68 jmc 1.1 INTEGER iRun, jRun, kIn, biIn, bjIn
69     INTEGER k, bi, bj, ndId
70     INTEGER region2fill(0:nRegions)
71     CHARACTER*16 parsFld
72     INTEGER myThid
73     CEOP
74    
75     C !LOCAL VARIABLES:
76     C i,j :: loop indices
77 jmc 1.3 INTEGER i, n, km, kFr
78 jmc 1.1 INTEGER im, ix, iv
79     PARAMETER ( iv = nStats - 2 , im = nStats - 1 , ix = nStats )
80     LOGICAL exclSpVal
81     LOGICAL useWeight
82     _RL statLoc(0:nStats)
83     _RL drLoc
84     _RL specialVal
85     _RL getcon
86     EXTERNAL getcon
87    
88     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
89    
90     useWeight = .FALSE.
91     exclSpVal = .FALSE.
92     specialVal = 0.
93     IF ( useFIZHI ) THEN
94     exclSpVal = .TRUE.
95 jmc 1.2 specialVal = getcon('UNDEF')
96 jmc 1.1 ENDIF
97 jmc 1.3 kFr = MIN(kIn,sizF)
98 jmc 1.2
99 jmc 1.1 DO n=0,nRegions
100     IF (region2fill(n).NE.0) THEN
101     C--- Compute statistics for this tile, level and region:
102 jmc 1.2
103 jmc 1.1 C- case of a special region (no specific regional mask)
104     IF ( n.EQ.0 ) THEN
105    
106     IF ( parsFld(10:10) .EQ. 'R' ) THEN
107    
108     drLoc = drF(k)
109     IF ( parsFld(9:9).EQ.'L') drLoc = drC(k)
110     IF ( parsFld(9:9).EQ.'U') drLoc = drC(MIN(k+1,Nr))
111     IF ( parsFld(9:9).EQ.'M') useWeight = .TRUE.
112    
113     IF ( parsFld(2:2).EQ.'U' ) THEN
114 jmc 1.2 CALL DIAGSTATS_CALC(
115 jmc 1.1 O statLoc,
116     I inpFld(sizI1,sizJ1,kIn,biIn,bjIn),
117 jmc 1.3 I frcFld(sizI1,sizJ1,kFr,biIn,bjIn),
118 jmc 1.4 I scaleFact, power, useFract,
119 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
120 jmc 1.1 I maskH(1-Olx,1-Oly,bi,bj), maskW(1-Olx,1-Oly,k,bi,bj),
121 jmc 1.2 I hFacW(1-Olx,1-Oly,k,bi,bj), rAw(1-Olx,1-Oly,bi,bj),
122 jmc 1.1 I drLoc, specialVal, exclSpVal, useWeight, myThid )
123     c I drLoc, k,bi,bj, parsFld, myThid )
124     ELSEIF ( parsFld(2:2).EQ.'V' ) THEN
125 jmc 1.2 CALL DIAGSTATS_CALC(
126 jmc 1.1 O statLoc,
127     I inpFld(sizI1,sizJ1,kIn,biIn,bjIn),
128 jmc 1.3 I frcFld(sizI1,sizJ1,kFr,biIn,bjIn),
129 jmc 1.4 I scaleFact, power, useFract,
130 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
131 jmc 1.1 I maskH(1-Olx,1-Oly,bi,bj), maskS(1-Olx,1-Oly,k,bi,bj),
132 jmc 1.2 I hFacS(1-Olx,1-Oly,k,bi,bj), rAs(1-Olx,1-Oly,bi,bj),
133 jmc 1.1 I drLoc, specialVal, exclSpVal, useWeight, myThid )
134     ELSE
135 jmc 1.2 CALL DIAGSTATS_CALC(
136 jmc 1.1 O statLoc,
137     I inpFld(sizI1,sizJ1,kIn,biIn,bjIn),
138 jmc 1.3 I frcFld(sizI1,sizJ1,kFr,biIn,bjIn),
139 jmc 1.4 I scaleFact, power, useFract,
140 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
141 jmc 1.1 I maskH(1-Olx,1-Oly,bi,bj), maskC(1-Olx,1-Oly,k,bi,bj),
142     I hFacC(1-Olx,1-Oly,k,bi,bj), rA(1-Olx,1-Oly,bi,bj),
143     I drLoc, specialVal, exclSpVal, useWeight, myThid )
144     ENDIF
145    
146 jmc 1.2 ELSEIF ( useFIZHI .AND.
147     & (parsFld(10:10).EQ.'L' .OR. parsFld(10:10).EQ.'M')
148     & ) THEN
149     CALL DIAGSTATS_LM_CALC(
150 jmc 1.1 O statLoc,
151     I inpFld(sizI1,sizJ1,kIn,biIn,bjIn),
152 jmc 1.3 I frcFld(sizI1,sizJ1,kFr,biIn,bjIn),
153 jmc 1.4 I scaleFact, power, useFract,
154 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
155 jmc 1.1 I maskH(1-Olx,1-Oly,bi,bj), maskH(1-Olx,1-Oly,bi,bj),
156 jmc 1.2 I rA(1-Olx,1-Oly,bi,bj),
157     I specialVal, exclSpVal,
158     I k,bi,bj, parsFld, myThid )
159     ELSEIF ( useLand .AND.
160     & (parsFld(10:10).EQ.'G' .OR. parsFld(10:10).EQ.'g')
161     & ) THEN
162     CALL DIAGSTATS_G_CALC(
163     O statLoc,
164     I inpFld(sizI1,sizJ1,kIn,biIn,bjIn),
165 jmc 1.3 I frcFld(sizI1,sizJ1,kFr,biIn,bjIn),
166 jmc 1.4 I scaleFact, power, useFract,
167 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
168     I maskH(1-Olx,1-Oly,bi,bj),
169     I rA(1-Olx,1-Oly,bi,bj),
170     I specialVal, exclSpVal,
171     I k,bi,bj, parsFld, myThid )
172 jmc 1.1 c ELSEIF ( parsFld(10:10) .EQ. 'I' ) THEN
173     c ELSEIF ( parsFld(10:10) .EQ. '1' ) THEN
174     ELSE
175    
176     km = 1
177     IF ( usingPCoords ) km = Nr
178     drLoc = 1. _d 0
179     IF ( parsFld(2:2).EQ.'U' ) THEN
180 jmc 1.2 CALL DIAGSTATS_CALC(
181 jmc 1.1 O statLoc,
182     I inpFld(sizI1,sizJ1,kIn,biIn,bjIn),
183 jmc 1.3 I frcFld(sizI1,sizJ1,kFr,biIn,bjIn),
184 jmc 1.4 I scaleFact, power, useFract,
185 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
186 jmc 1.1 I maskH(1-Olx,1-Oly,bi,bj), maskW(1-Olx,1-Oly,km,bi,bj),
187 jmc 1.2 I maskW(1-Olx,1-Oly,km,bi,bj),rAw(1-Olx,1-Oly,bi,bj),
188 jmc 1.1 I drLoc, specialVal, exclSpVal, useWeight, myThid )
189     ELSEIF ( parsFld(2:2).EQ.'V' ) THEN
190 jmc 1.2 CALL DIAGSTATS_CALC(
191 jmc 1.1 O statLoc,
192     I inpFld(sizI1,sizJ1,kIn,biIn,bjIn),
193 jmc 1.3 I frcFld(sizI1,sizJ1,kFr,biIn,bjIn),
194 jmc 1.4 I scaleFact, power, useFract,
195 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
196 jmc 1.1 I maskH(1-Olx,1-Oly,bi,bj), maskS(1-Olx,1-Oly,km,bi,bj),
197 jmc 1.2 I maskS(1-Olx,1-Oly,km,bi,bj),rAs(1-Olx,1-Oly,bi,bj),
198 jmc 1.1 I drLoc, specialVal, exclSpVal, useWeight, myThid )
199     ELSE
200 jmc 1.2 CALL DIAGSTATS_CALC(
201 jmc 1.1 O statLoc,
202     I inpFld(sizI1,sizJ1,kIn,biIn,bjIn),
203 jmc 1.3 I frcFld(sizI1,sizJ1,kFr,biIn,bjIn),
204 jmc 1.4 I scaleFact, power, useFract,
205 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
206 jmc 1.1 I maskH(1-Olx,1-Oly,bi,bj), maskH(1-Olx,1-Oly,bi,bj),
207     I maskH(1-Olx,1-Oly,bi,bj), rA(1-Olx,1-Oly,bi,bj),
208     I drLoc, specialVal, exclSpVal, useWeight, myThid )
209     ENDIF
210    
211     ENDIF
212    
213     C Update cumulative statistics array
214     IF ( statLoc(0).GT.0. ) THEN
215     IF ( statFld(0,n).LE.0. ) THEN
216     statFld(im,n) = statLoc(im)
217     statFld(ix,n) = statLoc(ix)
218     ELSE
219     statFld(im,n) = MIN( statFld(im,n), statLoc(im) )
220     statFld(ix,n) = MAX( statFld(ix,n), statLoc(ix) )
221     ENDIF
222     DO i=0,iv
223     statFld(i,n) = statFld(i,n) + statLoc(i)
224     ENDDO
225     ENDIF
226    
227     ENDIF
228    
229     C--- processing region "n" ends here.
230     ENDIF
231     ENDDO
232    
233 jmc 1.2 RETURN
234     END
235    
236     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
237    
238     CBOP
239     C !ROUTINE: DIAGSTATS_LM_CALC
240     C !INTERFACE:
241     SUBROUTINE DIAGSTATS_LM_CALC(
242     O statArr,
243 jmc 1.4 I inpArr, frcArr, scaleFact, power, useFract,
244 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2, iRun,jRun,
245     I regMask, arrMask, arrArea,
246     I specialVal, exclSpVal,
247     I k,bi,bj, parsFld, myThid )
248    
249     C !DESCRIPTION:
250     C Compute statistics for this tile, level, region
251     C using FIZHI level thickness
252    
253     C !USES:
254     IMPLICIT NONE
255    
256     #include "EEPARAMS.h"
257     #include "SIZE.h"
258     #ifdef ALLOW_FIZHI
259     #include "fizhi_SIZE.h"
260     #include "gridalt_mapping.h"
261     #endif
262    
263     C !INPUT/OUTPUT PARAMETERS:
264     C == Routine Arguments ==
265     C statArr :: output statistics array
266     C inpArr :: input field array to process (compute stats & add to statFld)
267 jmc 1.3 C frcArr :: fraction used for weighted-average diagnostics
268 jmc 1.4 C scaleFact :: scaling factor
269     C power :: option to fill-in with the field square (power=2)
270 jmc 1.3 C useFract :: if True, use fraction-weight
271 jmc 1.2 C nStats :: size of output statArr
272     C sizI1,sizI2 :: size of inpArr array: 1rst index range (min,max)
273     C sizJ1,sizJ2 :: size of inpArr array: 2nd index range (min,max)
274     C iRun,jRun :: range of 1rst & 2nd index to process
275     C regMask :: regional mask
276     C arrMask :: mask for this input array
277     C arrArea :: Area weighting factor
278     C specialVal :: special value in input array (to exclude if exclSpVal=T)
279     C exclSpVal :: if T, exclude "specialVal" in input array
280     C k,bi,bj :: level and tile indices used for weighting (mask,area ...)
281     C parsFld :: parser field with characteristics of the diagnostics
282     C myThid :: my Thread Id number
283     INTEGER nStats,sizI1,sizI2,sizJ1,sizJ2
284     INTEGER iRun, jRun
285     _RL statArr(0:nStats)
286     _RL inpArr (sizI1:sizI2,sizJ1:sizJ2)
287 jmc 1.3 _RL frcArr (sizI1:sizI2,sizJ1:sizJ2)
288     _RL scaleFact
289 jmc 1.4 INTEGER power
290 jmc 1.3 LOGICAL useFract
291 jmc 1.2 _RS regMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
292     _RS arrMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
293     _RS arrArea(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
294     _RL specialVal
295     LOGICAL exclSpVal
296     INTEGER k, bi, bj
297     CHARACTER*16 parsFld
298     INTEGER myThid
299     CEOP
300    
301     #ifdef ALLOW_FIZHI
302     C !LOCAL VARIABLES:
303     LOGICAL useWeight
304     INTEGER kl
305     _RL drLoc
306    
307     c IF ( useFIZHI ) THEN
308    
309     IF ( parsFld(10:10).EQ.'L' ) THEN
310     kl = 1 + Nrphys - k
311     useWeight = .TRUE.
312     ELSE
313     kl = 1
314     useWeight = .FALSE.
315     ENDIF
316     drLoc = 1. _d 0
317    
318     C- jmc: here we have a Problem if RL & RS are not the same:
319     C since dpphys is RL but argument is RS. leave it like this for now
320     C and will change it once the Regions are fully implemented.
321    
322     CALL DIAGSTATS_CALC(
323     O statArr,
324 jmc 1.4 I inpArr, frcArr, scaleFact, power, useFract,
325 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
326     I regMask, arrMask,
327     I dpphys(1-Olx,1-Oly,kl,bi,bj), arrArea,
328     I drLoc, specialVal, exclSpVal, useWeight, myThid )
329    
330     c ENDIF
331     #endif /* ALLOW_FIZHI */
332    
333     RETURN
334     END
335    
336     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
337    
338     CBOP
339     C !ROUTINE: DIAGSTATS_G_CALC
340     C !INTERFACE:
341     SUBROUTINE DIAGSTATS_G_CALC(
342     O statArr,
343 jmc 1.4 I inpArr, frcArr, scaleFact, power, useFract,
344 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2, iRun,jRun,
345     I regMask, arrArea,
346     I specialVal, exclSpVal,
347     I k,bi,bj, parsFld, myThid )
348    
349     C !DESCRIPTION:
350     C Compute statistics for this tile, level, region
351     C using "ground" (land) type fraction
352    
353     C !USES:
354     IMPLICIT NONE
355    
356     #include "EEPARAMS.h"
357     #ifdef ALLOW_LAND
358     # include "LAND_SIZE.h"
359     # include "LAND_PARAMS.h"
360     # ifdef ALLOW_AIM
361     # include "AIM_FFIELDS.h"
362     # endif
363     #else
364     # include "SIZE.h"
365     #endif
366    
367     C !INPUT/OUTPUT PARAMETERS:
368     C == Routine Arguments ==
369     C statArr :: output statistics array
370     C inpArr :: input field array to process (compute stats & add to statFld)
371 jmc 1.3 C frcArr :: fraction used for weighted-average diagnostics
372 jmc 1.4 C scaleFact :: scaling factor
373     C power :: option to fill-in with the field square (power=2)
374 jmc 1.3 C useFract :: if True, use fraction-weight
375 jmc 1.2 C nStats :: size of output statArr
376     C sizI1,sizI2 :: size of inpArr array: 1rst index range (min,max)
377     C sizJ1,sizJ2 :: size of inpArr array: 2nd index range (min,max)
378     C iRun,jRun :: range of 1rst & 2nd index to process
379     C regMask :: regional mask
380     C arrArea :: Area weighting factor
381     C specialVal :: special value in input array (to exclude if exclSpVal=T)
382     C exclSpVal :: if T, exclude "specialVal" in input array
383     C k,bi,bj :: level and tile indices used for weighting (mask,area ...)
384     C parsFld :: parser field with characteristics of the diagnostics
385     C myThid :: my Thread Id number
386     INTEGER nStats,sizI1,sizI2,sizJ1,sizJ2
387     INTEGER iRun, jRun
388     _RL statArr(0:nStats)
389     _RL inpArr (sizI1:sizI2,sizJ1:sizJ2)
390 jmc 1.3 _RL frcArr (sizI1:sizI2,sizJ1:sizJ2)
391     _RL scaleFact
392 jmc 1.4 INTEGER power
393 jmc 1.3 LOGICAL useFract
394 jmc 1.2 _RS regMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
395     _RS arrArea(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
396     _RL specialVal
397     LOGICAL exclSpVal
398     INTEGER k, bi, bj
399     CHARACTER*16 parsFld
400     INTEGER myThid
401     CEOP
402    
403     #ifdef ALLOW_LAND
404     C !LOCAL VARIABLES:
405     LOGICAL useWeight
406     INTEGER kl
407     _RL drLoc
408    
409     c IF ( useLand ) THEN
410    
411     IF ( parsFld(10:10).EQ.'G' ) THEN
412     kl = MIN(k,land_nLev)
413     drLoc = land_dzF(kl)
414     ELSE
415     drLoc = 1. _d 0
416     ENDIF
417     useWeight = .TRUE.
418    
419     CALL DIAGSTATS_CALC(
420     O statArr,
421 jmc 1.4 I inpArr, frcArr, scaleFact, power, useFract,
422 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2,iRun,jRun,
423     I regMask, aim_landFr(1-Olx,1-Oly,bi,bj),
424     I aim_landFr(1-Olx,1-Oly,bi,bj), arrArea,
425     I drLoc, specialVal, exclSpVal, useWeight, myThid )
426    
427     c ENDIF
428     #endif /* ALLOW_LAND */
429    
430     RETURN
431 jmc 1.1 END
432    
433     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
434    
435     CBOP
436     C !ROUTINE: DIAGSTATS_CALC
437     C !INTERFACE:
438 jmc 1.2 SUBROUTINE DIAGSTATS_CALC(
439     O statArr,
440 jmc 1.4 I inpArr, frcArr, scaleFact, power, useFract,
441 jmc 1.2 I nStats,sizI1,sizI2,sizJ1,sizJ2, iRun,jRun,
442 jmc 1.1 I regMask, arrMask, arrhFac, arrArea,
443     I arrDr, specialVal, exclSpVal, useWeight,
444     I myThid )
445    
446     C !DESCRIPTION:
447     C Compute statistics for this tile, level, region
448    
449     C !USES:
450     IMPLICIT NONE
451    
452     #include "EEPARAMS.h"
453     #include "SIZE.h"
454    
455     C !INPUT/OUTPUT PARAMETERS:
456     C == Routine Arguments ==
457 jmc 1.2 C statArr :: output statistics array
458 jmc 1.1 C inpArr :: input field array to process (compute stats & add to statFld)
459 jmc 1.3 C frcArr :: fraction used for weighted-average diagnostics
460 jmc 1.4 C scaleFact :: scaling factor
461     C power :: option to fill-in with the field square (power=2)
462 jmc 1.3 C useFract :: if True, use fraction-weight
463 jmc 1.2 C nStats :: size of output array: statArr
464 jmc 1.1 C sizI1,sizI2 :: size of inpArr array: 1rst index range (min,max)
465     C sizJ1,sizJ2 :: size of inpArr array: 2nd index range (min,max)
466     C iRun,jRun :: range of 1rst & 2nd index to process
467     C regMask :: regional mask
468     C arrMask :: mask for this input array
469     C arrhFac :: weight factor (horizontally varying)
470     C arrArea :: Area weighting factor
471     C arrDr :: uniform weighting factor
472     C specialVal :: special value in input array (to exclude if exclSpVal=T)
473     C exclSpVal :: if T, exclude "specialVal" in input array
474     C useWeight :: use weight factor "arrhFac"
475     Cc k,bi,bj :: level and tile indices used for weighting (mask,area ...)
476     Cc parsFld :: parser field with characteristics of the diagnostics
477     C myThid :: my Thread Id number
478 jmc 1.2 INTEGER nStats,sizI1,sizI2,sizJ1,sizJ2
479     INTEGER iRun, jRun
480 jmc 1.1 _RL statArr(0:nStats)
481     _RL inpArr (sizI1:sizI2,sizJ1:sizJ2)
482 jmc 1.3 _RL frcArr (sizI1:sizI2,sizJ1:sizJ2)
483     _RL scaleFact
484 jmc 1.4 INTEGER power
485 jmc 1.3 LOGICAL useFract
486 jmc 1.1 _RS regMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
487     _RS arrMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
488     _RS arrhFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
489     _RS arrArea(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
490     _RL arrDr
491     _RL specialVal
492     LOGICAL exclSpVal
493     LOGICAL useWeight
494     INTEGER myThid
495     CEOP
496    
497     C !LOCAL VARIABLES:
498     C i,j :: loop indices
499     INTEGER i, j, n
500 jmc 1.2 INTEGER im, ix
501 jmc 1.1 _RL tmpVol
502 jmc 1.3 _RL tmpFld
503 jmc 1.4 _RL tmpFac
504 jmc 1.1
505 jmc 1.2 im = nStats - 1
506     ix = nStats
507 jmc 1.1 DO n=0,nStats
508     statArr(n) = 0.
509     ENDDO
510 jmc 1.4 tmpFac = scaleFact
511     IF ( power.EQ.2) tmpFac = scaleFact*scaleFact
512 jmc 1.1
513 jmc 1.3 IF ( useFract .AND. exclSpVal ) THEN
514 jmc 1.1
515     DO j = 1,jRun
516     DO i = 1,iRun
517 jmc 1.3 IF ( arrMask(i,j).NE.0. .AND. frcArr(i,j).NE.0.
518     & .AND. inpArr(i,j).NE.specialVal ) THEN
519 jmc 1.4 IF ( power.EQ.2) THEN
520     tmpFld = tmpFac*inpArr(i,j)*inpArr(i,j)
521     ELSE
522     tmpFld = tmpFac*inpArr(i,j)
523     ENDIF
524 jmc 1.1 IF ( statArr(0).EQ.0. ) THEN
525 jmc 1.3 statArr(im) = tmpFld
526     statArr(ix) = tmpFld
527 jmc 1.1 ELSE
528 jmc 1.3 statArr(im) = MIN(tmpFld,statArr(im))
529     statArr(ix) = MAX(tmpFld,statArr(ix))
530     ENDIF
531     IF ( useWeight ) THEN
532     tmpVol = arrDr*arrhFac(i,j)*arrArea(i,j)*frcArr(i,j)
533     ELSE
534     tmpVol = arrDr*arrArea(i,j)*frcArr(i,j)
535     ENDIF
536     statArr(0) = statArr(0) + tmpVol
537     statArr(1) = statArr(1) + tmpVol*tmpFld
538     statArr(2) = statArr(2) + tmpVol*tmpFld*tmpFld
539     ENDIF
540     ENDDO
541     ENDDO
542    
543     ELSEIF ( useFract ) THEN
544    
545     DO j = 1,jRun
546     DO i = 1,iRun
547     IF ( arrMask(i,j).NE.0. .AND. frcArr(i,j).NE.0. ) THEN
548 jmc 1.4 IF ( power.EQ.2) THEN
549     tmpFld = tmpFac*inpArr(i,j)*inpArr(i,j)
550     ELSE
551     tmpFld = tmpFac*inpArr(i,j)
552     ENDIF
553 jmc 1.3 IF ( statArr(0).EQ.0. ) THEN
554     statArr(im) = tmpFld
555     statArr(ix) = tmpFld
556     ELSE
557     statArr(im) = MIN(tmpFld,statArr(im))
558     statArr(ix) = MAX(tmpFld,statArr(ix))
559     ENDIF
560     IF ( useWeight ) THEN
561     tmpVol = arrDr*arrhFac(i,j)*arrArea(i,j)*frcArr(i,j)
562     ELSE
563     tmpVol = arrDr*arrArea(i,j)*frcArr(i,j)
564     ENDIF
565     statArr(0) = statArr(0) + tmpVol
566     statArr(1) = statArr(1) + tmpVol*tmpFld
567     statArr(2) = statArr(2) + tmpVol*tmpFld*tmpFld
568     ENDIF
569     ENDDO
570     ENDDO
571    
572     ELSEIF ( exclSpVal ) THEN
573    
574     DO j = 1,jRun
575     DO i = 1,iRun
576     IF ( arrMask(i,j).NE.0.
577     & .AND. inpArr(i,j).NE.specialVal ) THEN
578 jmc 1.4 IF ( power.EQ.2) THEN
579     tmpFld = tmpFac*inpArr(i,j)*inpArr(i,j)
580     ELSE
581     tmpFld = tmpFac*inpArr(i,j)
582     ENDIF
583 jmc 1.3 IF ( statArr(0).EQ.0. ) THEN
584     statArr(im) = tmpFld
585     statArr(ix) = tmpFld
586     ELSE
587     statArr(im) = MIN(tmpFld,statArr(im))
588     statArr(ix) = MAX(tmpFld,statArr(ix))
589 jmc 1.1 ENDIF
590     IF ( useWeight ) THEN
591     tmpVol = arrDr*arrhFac(i,j)*arrArea(i,j)
592     ELSE
593     tmpVol = arrDr*arrArea(i,j)
594     ENDIF
595     statArr(0) = statArr(0) + tmpVol
596 jmc 1.3 statArr(1) = statArr(1) + tmpVol*tmpFld
597     statArr(2) = statArr(2) + tmpVol*tmpFld*tmpFld
598 jmc 1.1 ENDIF
599     ENDDO
600     ENDDO
601    
602     ELSE
603    
604     DO j = 1,jRun
605     DO i = 1,iRun
606     c IF ( regMask(i,j).NE.0. .AND. arrMask(i,j).NE.0. ) THEN
607     IF ( arrMask(i,j).NE.0. ) THEN
608 jmc 1.4 IF ( power.EQ.2) THEN
609     tmpFld = tmpFac*inpArr(i,j)*inpArr(i,j)
610     ELSE
611     tmpFld = tmpFac*inpArr(i,j)
612     ENDIF
613 jmc 1.1 IF ( statArr(0).EQ.0. ) THEN
614 jmc 1.3 statArr(im) = tmpFld
615     statArr(ix) = tmpFld
616 jmc 1.1 ELSE
617 jmc 1.3 statArr(im) = MIN(tmpFld,statArr(im))
618     statArr(ix) = MAX(tmpFld,statArr(ix))
619 jmc 1.1 ENDIF
620     IF ( useWeight ) THEN
621     tmpVol = arrDr*arrhFac(i,j)*arrArea(i,j)
622     ELSE
623     tmpVol = arrDr*arrArea(i,j)
624     ENDIF
625     statArr(0) = statArr(0) + tmpVol
626 jmc 1.3 statArr(1) = statArr(1) + tmpVol*tmpFld
627     statArr(2) = statArr(2) + tmpVol*tmpFld*tmpFld
628 jmc 1.1 ENDIF
629     ENDDO
630     ENDDO
631    
632     ENDIF
633    
634 jmc 1.2 RETURN
635 jmc 1.1 END

  ViewVC Help
Powered by ViewVC 1.1.22