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_STATS_RL |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE MON_STATS_RL( |
12 |
I myNr, arr, arrMask,arrhFac, arrArea, arrDr, |
13 |
O theMin,theMax,theMean,theSD,theDel2,theVol, |
14 |
I myThid ) |
15 |
|
16 |
C Calculate bare statistics of global array ``\_RL arr''. |
17 |
|
18 |
C !USES: |
19 |
IMPLICIT NONE |
20 |
#include "SIZE.h" |
21 |
#include "EEPARAMS.h" |
22 |
|
23 |
C !INPUT PARAMETERS: |
24 |
INTEGER myNr |
25 |
_RL arr(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy) |
26 |
_RS arrMask(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 arrArea(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
29 |
_RS arrDr(myNr) |
30 |
_RL theMin, theMax, theMean, theSD, theDel2, theVol |
31 |
INTEGER myThid |
32 |
CEOP |
33 |
|
34 |
C !LOCAL VARIABLES: |
35 |
INTEGER bi,bj,I,J,K |
36 |
INTEGER numPnts |
37 |
LOGICAL noPnts |
38 |
_RL tmpVal,rNumPnts |
39 |
_RL theVar |
40 |
_RL tmpVol |
41 |
_RL tileMean(nSx,nSy) |
42 |
_RL tileVar (nSx,nSy) |
43 |
_RL tileSD (nSx,nSy) |
44 |
_RL tileDel2(nSx,nSy) |
45 |
_RL tileVol (nSx,nSy) |
46 |
|
47 |
C Since 2009/12/21 MON_CALC_STATS_RL replaces MON_STATS_RL |
48 |
C which is now disabled |
49 |
STOP 'ABNORMAL END: S/R MON_STATS_RL no longer maintained' |
50 |
|
51 |
theMin=0. |
52 |
theMax=0. |
53 |
theMean=0. |
54 |
theSD=0. |
55 |
theVar=0. |
56 |
theDel2=0. |
57 |
theVol=0. |
58 |
numPnts=0 |
59 |
noPnts=.TRUE. |
60 |
|
61 |
DO bj=myByLo(myThid),myByHi(myThid) |
62 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
63 |
tileDel2(bi,bj) = 0. |
64 |
tileVol (bi,bj) = 0. |
65 |
tileMean(bi,bj) = 0. |
66 |
tileVar (bi,bj) = 0. |
67 |
DO K=1,myNr |
68 |
DO J=1,sNy |
69 |
DO I=1,sNx |
70 |
tmpVal=arr(I,J,K,bi,bj) |
71 |
IF (arrMask(I,J,K,bi,bj).NE.0. .AND. noPnts) THEN |
72 |
theMin=tmpVal |
73 |
theMax=tmpVal |
74 |
noPnts=.FALSE. |
75 |
ENDIF |
76 |
IF (arrMask(I,J,K,bi,bj).NE.0.) THEN |
77 |
theMin=min(theMin,tmpVal) |
78 |
theMax=max(theMax,tmpVal) |
79 |
tileDel2(bi,bj) = tileDel2(bi,bj) |
80 |
& + 0.25*ABS( |
81 |
& (arr(I+1,J,K,bi,bj)-tmpVal)*arrMask(I+1,J,K,bi,bj) |
82 |
& +(arr(I-1,J,K,bi,bj)-tmpVal)*arrMask(I-1,J,K,bi,bj) |
83 |
& +(arr(I,J+1,K,bi,bj)-tmpVal)*arrMask(I,J+1,K,bi,bj) |
84 |
& +(arr(I,J-1,K,bi,bj)-tmpVal)*arrMask(I,J-1,K,bi,bj) |
85 |
& ) |
86 |
numPnts=numPnts+1 |
87 |
tmpVol = arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K) |
88 |
& *arrMask(I,J,K,bi,bj) |
89 |
tileVol (bi,bj) = tileVol (bi,bj) + tmpVol |
90 |
tileMean(bi,bj) = tileMean(bi,bj) + tmpVol*tmpVal |
91 |
tileVar (bi,bj) = tileVar (bi,bj) + tmpVol*tmpVal*tmpVal |
92 |
ENDIF |
93 |
ENDDO |
94 |
ENDDO |
95 |
ENDDO |
96 |
c theDel2 = theDel2 + tileDel2(bi,bj) |
97 |
c theVol = theVol + tileVol(bi,bj) |
98 |
c theMean = theMean + tileMean(bi,bj) |
99 |
c theVar = theVar + tileVar (bi,bj) |
100 |
ENDDO |
101 |
ENDDO |
102 |
|
103 |
c _GLOBAL_SUM_RL(theDel2,myThid) |
104 |
c _GLOBAL_SUM_RL(theVol,myThid) |
105 |
c _GLOBAL_SUM_RL(theMean,myThid) |
106 |
c _GLOBAL_SUM_RL(theVar,myThid) |
107 |
CALL GLOBAL_SUM_TILE_RL( tileDel2, theDel2, myThid ) |
108 |
CALL GLOBAL_SUM_TILE_RL( tileVol , theVol , myThid ) |
109 |
CALL GLOBAL_SUM_TILE_RL( tileMean, theMean, myThid ) |
110 |
CALL GLOBAL_SUM_TILE_RL( tileVar , theVar , myThid ) |
111 |
tmpVal=FLOAT(numPnts) |
112 |
_GLOBAL_SUM_RL(tmpVal,myThid) |
113 |
numPnts=NINT(tmpVal) |
114 |
|
115 |
IF (tmpVal.GT.0.) THEN |
116 |
rNumPnts=1. _d 0/tmpVal |
117 |
theDel2=theDel2*rNumPnts |
118 |
ENDIF |
119 |
|
120 |
IF (theVol.GT.0.) THEN |
121 |
theMean=theMean/theVol |
122 |
theVar=theVar/theVol |
123 |
IF ( noPnts ) theMin = theMean |
124 |
theMin=-theMin |
125 |
_GLOBAL_MAX_RL(theMin,myThid) |
126 |
theMin=-theMin |
127 |
IF ( noPnts ) theMax = theMean |
128 |
_GLOBAL_MAX_RL(theMax,myThid) |
129 |
|
130 |
DO bj=myByLo(myThid),myByHi(myThid) |
131 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
132 |
tileSD(bi,bj)=0. |
133 |
DO K=1,myNr |
134 |
DO J=1,sNy |
135 |
DO I=1,sNx |
136 |
tmpVal=arr(I,J,K,bi,bj) |
137 |
IF (arrMask(I,J,K,bi,bj).NE.0.) THEN |
138 |
tmpVol=arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K) |
139 |
& *arrMask(I,J,K,bi,bj) |
140 |
tileSD(bi,bj) = tileSD(bi,bj) |
141 |
& + tmpVol*(tmpVal-theMean)*(tmpVal-theMean) |
142 |
ENDIF |
143 |
ENDDO |
144 |
ENDDO |
145 |
ENDDO |
146 |
c theSD = theSD + tileSD(bi,bj) |
147 |
ENDDO |
148 |
ENDDO |
149 |
|
150 |
c _GLOBAL_SUM_RL(theSD,myThid) |
151 |
CALL GLOBAL_SUM_TILE_RL( tileSD, theSD, myThid ) |
152 |
|
153 |
theSD = SQRT(theSD/theVol) |
154 |
c theSD = SQRT(theVar-theMean*theMean) |
155 |
ENDIF |
156 |
|
157 |
RETURN |
158 |
END |