1 |
C $Header: /u/gcmpack/models/MITgcmUV/pkg/monitor/mon_stats_rl.F,v 1.2 2001/06/04 20:04:24 adcroft Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
SUBROUTINE MON_STATS_RL( |
7 |
I myNr, arr, arrMask,arrhFac, arrArea, arrDr, |
8 |
O theMin,theMax,theMean,theSD,theDel2, |
9 |
I myThid ) |
10 |
C /==========================================================\ |
11 |
C | SUBROUTINE MON_STATS_RL | |
12 |
C | o Calculate bare statistics of global array "_RL arr" | |
13 |
C |==========================================================| |
14 |
C \==========================================================/ |
15 |
IMPLICIT NONE |
16 |
|
17 |
C === Global data === |
18 |
#include "SIZE.h" |
19 |
#include "EEPARAMS.h" |
20 |
|
21 |
C === Routine arguments === |
22 |
INTEGER myNr |
23 |
_RL arr(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy) |
24 |
_RS arrMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy) |
25 |
_RS arrhFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy) |
26 |
_RS arrArea(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
27 |
_RS arrDr(myNr) |
28 |
_RL theMin |
29 |
_RL theMax |
30 |
_RL theMean |
31 |
_RL theSD |
32 |
_RL theDel2 |
33 |
INTEGER myThid |
34 |
|
35 |
C === Local variables ==== |
36 |
INTEGER bi,bj,I,J,K |
37 |
INTEGER numPnts |
38 |
LOGICAL noPnts |
39 |
_RL tmpVal,rNumPnts |
40 |
_RL theVar |
41 |
_RL theVol, tmpVol |
42 |
|
43 |
theMin=0. |
44 |
theMax=0. |
45 |
theMean=0. |
46 |
theSD=0. |
47 |
theVar=0. |
48 |
theDel2=0. |
49 |
theVol=0. |
50 |
numPnts=0 |
51 |
noPnts=.TRUE. |
52 |
|
53 |
DO bj=myByLo(myThid),myByHi(myThid) |
54 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
55 |
DO K=1,myNr |
56 |
DO J=1,sNy |
57 |
DO I=1,sNx |
58 |
tmpVal=arr(I,J,K,bi,bj) |
59 |
c IF (tmpVal.NE.0. .AND. noPnts) THEN |
60 |
IF (arrMask(I,J,K,bi,bj).NE.0. .AND. noPnts) THEN |
61 |
theMin=tmpVal |
62 |
theMax=tmpVal |
63 |
noPnts=.FALSE. |
64 |
ENDIF |
65 |
c IF (tmpVal.NE.0.) THEN |
66 |
IF (arrMask(I,J,K,bi,bj).NE.0.) THEN |
67 |
theMin=min(theMin,tmpVal) |
68 |
theMax=max(theMax,tmpVal) |
69 |
theDel2 = theDel2+0.25*ABS( |
70 |
& (arr(I+1,J,K,bi,bj)-tmpVal)*arrMask(I+1,J,K,bi,bj) |
71 |
& +(arr(I-1,J,K,bi,bj)-tmpVal)*arrMask(I-1,J,K,bi,bj) |
72 |
& +(arr(I,J+1,K,bi,bj)-tmpVal)*arrMask(I,J+1,K,bi,bj) |
73 |
& +(arr(I,J-1,K,bi,bj)-tmpVal)*arrMask(I,J-1,K,bi,bj) |
74 |
& ) |
75 |
numPnts=numPnts+1 |
76 |
tmpVol = arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K) |
77 |
theVol = theVol + tmpVol |
78 |
theMean = theMean + tmpVol*tmpVal |
79 |
theVar = theVar + tmpVol*tmpVal**2 |
80 |
ENDIF |
81 |
ENDDO |
82 |
ENDDO |
83 |
ENDDO |
84 |
ENDDO |
85 |
ENDDO |
86 |
|
87 |
theMin=-theMin |
88 |
_GLOBAL_MAX_R8(theMin,myThid) |
89 |
theMin=-theMin |
90 |
_GLOBAL_MAX_R8(theMax,myThid) |
91 |
_GLOBAL_SUM_R8(theDel2,myThid) |
92 |
_GLOBAL_SUM_R8(theVol,myThid) |
93 |
_GLOBAL_SUM_R8(theMean,myThid) |
94 |
_GLOBAL_SUM_R8(theVar,myThid) |
95 |
tmpVal=FLOAT(numPnts) |
96 |
_GLOBAL_SUM_R8(tmpVal,myThid) |
97 |
numPnts=INT(tmpVal+0.5) |
98 |
|
99 |
IF (tmpVal.GT.0.) THEN |
100 |
rNumPnts=1./tmpVal |
101 |
theDel2=theDel2*rNumPnts |
102 |
ENDIF |
103 |
|
104 |
IF (theVol.GT.0.) THEN |
105 |
theMean=theMean/theVol |
106 |
theVar=theVar/theVol |
107 |
|
108 |
DO bj=myByLo(myThid),myByHi(myThid) |
109 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
110 |
DO K=1,myNr |
111 |
DO J=1,sNy |
112 |
DO I=1,sNx |
113 |
tmpVal=arr(I,J,K,bi,bj) |
114 |
c IF (tmpVal.NE.0.) THEN |
115 |
IF (arrMask(I,J,K,bi,bj).NE.0.) THEN |
116 |
tmpVol=arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K) |
117 |
theSD = theSD + tmpVol*(tmpVal-theMean)**2 |
118 |
ENDIF |
119 |
ENDDO |
120 |
ENDDO |
121 |
ENDDO |
122 |
ENDDO |
123 |
ENDDO |
124 |
|
125 |
_GLOBAL_SUM_R8(theSD,myThid) |
126 |
|
127 |
theSD=sqrt(theSD/theVol) |
128 |
c theSD=sqrt(theVar-theMean**2) |
129 |
ENDIF |
130 |
|
131 |
RETURN |
132 |
END |