/[MITgcm]/MITgcm/pkg/monitor/mon_calc_stats_rs.F
ViewVC logotype

Contents of /MITgcm/pkg/monitor/mon_calc_stats_rs.F

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


Revision 1.1 - (show annotations) (download)
Mon Dec 21 00:03:40 2009 UTC (14 years, 4 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, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint62, checkpoint63, checkpoint65x, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x
new version for statistics with mask & volume:
 - use hFac & 2-D mask (instead of 3-D mask + hFac in previous mon_stats_rl.F).
 - change del2 calculation.

1 C $Header: /u/gcmpack/MITgcm/pkg/monitor/mon_stats_rl.F,v 1.13 2009/04/28 18:16:53 jmc Exp $
2 C $Name: $
3
4 #include "MONITOR_OPTIONS.h"
5
6 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
7 CBOP
8 C !ROUTINE: MON_CALC_STATS_RS
9
10 C !INTERFACE:
11 SUBROUTINE MON_CALC_STATS_RS(
12 I myNr, arr, arrhFac, arrMask, arrArea, arrDr,
13 O theMin, theMax, theMean, theSD, theDel2, theVol,
14 I myThid )
15
16 C Calculate statistics of global array ``\_RS arr''.
17 C account for volume and mask
18
19 C !USES:
20 IMPLICIT NONE
21 #include "SIZE.h"
22 #include "EEPARAMS.h"
23
24 C !INPUT/OUTPUT PARAMETERS:
25 INTEGER myNr
26 _RS arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy)
27 _RS arrhFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy)
28 _RS arrMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
29 _RS arrArea(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
30 _RS arrDr(myNr)
31 _RL theMin, theMax, theMean, theSD, theDel2, theVol
32 INTEGER myThid
33 CEOP
34
35 C !LOCAL VARIABLES:
36 INTEGER bi,bj,i,j,k
37 INTEGER numPnts
38 LOGICAL noPnts
39 _RL tmpVal
40 _RL tmpMask
41 _RL tmpVol
42 _RL ddx, ddy
43 _RL theVar
44 _RL tileMean(nSx,nSy)
45 _RL tileVar (nSx,nSy)
46 _RL tileSD (nSx,nSy)
47 _RL tileDel2(nSx,nSy)
48 _RL tileVol (nSx,nSy)
49
50 theMin = 0.
51 theMax = 0.
52 theMean= 0.
53 theSD = 0.
54 theVar = 0.
55 theDel2= 0.
56 theVol = 0.
57 numPnts= 0
58 noPnts = .TRUE.
59
60 DO bj=myByLo(myThid),myByHi(myThid)
61 DO bi=myBxLo(myThid),myBxHi(myThid)
62 tileDel2(bi,bj) = 0.
63 tileVol (bi,bj) = 0.
64 tileMean(bi,bj) = 0.
65 tileVar (bi,bj) = 0.
66 DO k=1,myNr
67 DO j=1,sNy
68 DO i=1,sNx
69 tmpVal = arr(i,j,k,bi,bj)
70 tmpMask = arrMask(i,j,bi,bj)*arrhFac(i,j,k,bi,bj)
71 IF ( tmpMask.GT.0. _d 0 .AND. noPnts ) THEN
72 theMin=tmpVal
73 theMax=tmpVal
74 noPnts=.FALSE.
75 ENDIF
76 IF ( tmpMask.GT.0. _d 0 ) THEN
77 theMin = MIN(theMin,tmpVal)
78 theMax = MAX(theMax,tmpVal)
79 C-- like old code (but using hFac instead of mask): identical if no partial cell
80 c tileDel2(bi,bj) = tileDel2(bi,bj)
81 c & + 0.25*ABS(
82 c & (arr(i+1,j,k,bi,bj)-tmpVal)*arrhFac(i+1,j,k,bi,bj)
83 c & +(arr(i-1,j,k,bi,bj)-tmpVal)*arrhFac(i-1,j,k,bi,bj)
84 c & +(arr(i,j+1,k,bi,bj)-tmpVal)*arrhFac(i,j+1,k,bi,bj)
85 c & +(arr(i,j-1,k,bi,bj)-tmpVal)*arrhFac(i,j-1,k,bi,bj)
86 c & )
87 C-- New form:
88 ddx = arrhFac(i+1,j,k,bi,bj)*arrhFac(i-1,j,k,bi,bj)
89 IF ( ddx.GT.0. _d 0 ) THEN
90 ddx = (arr(i+1,j,k,bi,bj)-tmpVal)
91 & + (arr(i-1,j,k,bi,bj)-tmpVal)
92 ENDIF
93 ddy = arrhFac(i,j+1,k,bi,bj)*arrhFac(i,j-1,k,bi,bj)
94 IF ( ddy.GT.0. _d 0 ) THEN
95 ddy = (arr(i,j+1,k,bi,bj)-tmpVal)
96 & + (arr(i,j-1,k,bi,bj)-tmpVal)
97 ENDIF
98 tileDel2(bi,bj) = tileDel2(bi,bj) + ddx*ddx + ddy*ddy
99
100 numPnts=numPnts+1
101 tmpVol = arrArea(i,j,bi,bj)*arrDr(k)*tmpMask
102 tileVol (bi,bj) = tileVol (bi,bj) + tmpVol
103 tileMean(bi,bj) = tileMean(bi,bj) + tmpVol*tmpVal
104 tileVar (bi,bj) = tileVar (bi,bj) + tmpVol*tmpVal*tmpVal
105 ENDIF
106 ENDDO
107 ENDDO
108 ENDDO
109 ENDDO
110 ENDDO
111
112 CALL GLOBAL_SUM_TILE_RL( tileDel2, theDel2, myThid )
113 CALL GLOBAL_SUM_TILE_RL( tileVol , theVol , myThid )
114 CALL GLOBAL_SUM_TILE_RL( tileMean, theMean, myThid )
115 c CALL GLOBAL_SUM_TILE_RL( tileVar , theVar , myThid )
116
117 CALL GLOBAL_SUM_INT( numPnts, myThid )
118
119 IF ( numPnts.GT.0 ) THEN
120 tmpVal = FLOAT(numPnts)
121 c theDel2 = theDel2/tmpVal
122 theDel2 = SQRT(theDel2)/tmpVal
123 ENDIF
124
125 IF ( theVol.GT.0. _d 0 ) THEN
126 theMean= theMean/theVol
127 theVar = theVar/theVol
128 IF ( noPnts ) theMin = theMean
129 theMin = -theMin
130 _GLOBAL_MAX_RL(theMin,myThid)
131 theMin = -theMin
132 IF ( noPnts ) theMax = theMean
133 _GLOBAL_MAX_RL(theMax,myThid)
134
135 DO bj=myByLo(myThid),myByHi(myThid)
136 DO bi=myBxLo(myThid),myBxHi(myThid)
137 tileSD(bi,bj)=0.
138 DO k=1,myNr
139 DO j=1,sNy
140 DO i=1,sNx
141 tmpVal=arr(i,j,k,bi,bj)
142 tmpMask = arrMask(i,j,bi,bj)*arrhFac(i,j,k,bi,bj)
143 IF ( tmpMask.GT.0. _d 0 ) THEN
144 tmpVol = arrArea(i,j,bi,bj)*arrDr(k)*tmpMask
145 tileSD(bi,bj) = tileSD(bi,bj)
146 & + tmpVol*(tmpVal-theMean)*(tmpVal-theMean)
147 ENDIF
148 ENDDO
149 ENDDO
150 ENDDO
151 ENDDO
152 ENDDO
153
154 CALL GLOBAL_SUM_TILE_RL( tileSD, theSD, myThid )
155
156 theSD = SQRT(theSD/theVol)
157 c theSD = SQRT(theVar-theMean*theMean)
158 ENDIF
159
160 RETURN
161 END

  ViewVC Help
Powered by ViewVC 1.1.22