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

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

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


Revision 1.9 - (show annotations) (download)
Fri Mar 5 02:28:11 2004 UTC (20 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint52l_pre, hrcube5, checkpoint52l_post
Changes since 1.8: +13 -12 lines
fix problem in min/max monitor when 1 tile is empty

1 C $Header: /u/gcmpack/MITgcm/pkg/monitor/mon_stats_rl.F,v 1.8 2004/02/19 21:02:39 adcroft Exp $
2 C $Name: $
3
4 #include "MONITOR_OPTIONS.h"
5
6 SUBROUTINE MON_STATS_RL(
7 I myNr, arr, arrMask,arrhFac, arrArea, arrDr,
8 O theMin,theMax,theMean,theSD,theDel2,theVol,
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 _RL theVol
34 INTEGER myThid
35
36 C === Local variables ====
37 INTEGER bi,bj,I,J,K
38 INTEGER numPnts
39 LOGICAL noPnts
40 _RL tmpVal,rNumPnts
41 _RL theVar,theVarTile
42 _RL tmpVol
43 _RL theMeanTile, theSDTile, theDel2Tile, theVolTile
44
45 theMin=0.
46 theMax=0.
47 theMean=0.
48 theSD=0.
49 theVar=0.
50 theDel2=0.
51 theVol=0.
52 numPnts=0
53 noPnts=.TRUE.
54
55 DO bj=myByLo(myThid),myByHi(myThid)
56 DO bi=myBxLo(myThid),myBxHi(myThid)
57 theDel2Tile = 0.
58 theVolTile = 0.
59 theMeanTile = 0.
60 theVarTile = 0.
61 DO K=1,myNr
62 DO J=1,sNy
63 DO I=1,sNx
64 tmpVal=arr(I,J,K,bi,bj)
65 IF (arrMask(I,J,K,bi,bj).NE.0. .AND. noPnts) THEN
66 theMin=tmpVal
67 theMax=tmpVal
68 noPnts=.FALSE.
69 ENDIF
70 IF (arrMask(I,J,K,bi,bj).NE.0.) THEN
71 theMin=min(theMin,tmpVal)
72 theMax=max(theMax,tmpVal)
73 theDel2Tile = theDel2Tile+0.25*ABS(
74 & (arr(I+1,J,K,bi,bj)-tmpVal)*arrMask(I+1,J,K,bi,bj)
75 & +(arr(I-1,J,K,bi,bj)-tmpVal)*arrMask(I-1,J,K,bi,bj)
76 & +(arr(I,J+1,K,bi,bj)-tmpVal)*arrMask(I,J+1,K,bi,bj)
77 & +(arr(I,J-1,K,bi,bj)-tmpVal)*arrMask(I,J-1,K,bi,bj)
78 & )
79 numPnts=numPnts+1
80 tmpVol = arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K)
81 & *arrMask(I,J,K,bi,bj)
82 theVolTile = theVolTile + tmpVol
83 theMeanTile = theMeanTile + tmpVol*tmpVal
84 theVarTile = theVarTile + tmpVol*tmpVal**2
85 ENDIF
86 ENDDO
87 ENDDO
88 ENDDO
89 theDel2 = theDel2 + theDel2Tile
90 theVol = theVol + theVolTile
91 theMean = theMean + theMeanTile
92 theVar = theVar + theVarTile
93 ENDDO
94 ENDDO
95
96 _GLOBAL_SUM_R8(theDel2,myThid)
97 _GLOBAL_SUM_R8(theVol,myThid)
98 _GLOBAL_SUM_R8(theMean,myThid)
99 _GLOBAL_SUM_R8(theVar,myThid)
100 tmpVal=FLOAT(numPnts)
101 _GLOBAL_SUM_R8(tmpVal,myThid)
102 numPnts=NINT(tmpVal)
103
104 IF (tmpVal.GT.0.) THEN
105 rNumPnts=1./tmpVal
106 theDel2=theDel2*rNumPnts
107 ENDIF
108
109 IF (theVol.GT.0.) THEN
110 theMean=theMean/theVol
111 theVar=theVar/theVol
112 IF ( noPnts ) theMin = theMean
113 theMin=-theMin
114 _GLOBAL_MAX_R8(theMin,myThid)
115 theMin=-theMin
116 IF ( noPnts ) theMax = theMean
117 _GLOBAL_MAX_R8(theMax,myThid)
118
119 DO bj=myByLo(myThid),myByHi(myThid)
120 DO bi=myBxLo(myThid),myBxHi(myThid)
121 theSDtile=0.
122 DO K=1,myNr
123 DO J=1,sNy
124 DO I=1,sNx
125 tmpVal=arr(I,J,K,bi,bj)
126 c IF (tmpVal.NE.0.) THEN
127 IF (arrMask(I,J,K,bi,bj).NE.0.) THEN
128 tmpVol=arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K)
129 & *arrMask(I,J,K,bi,bj)
130 theSDtile = theSDtile + tmpVol*(tmpVal-theMean)**2
131 ENDIF
132 ENDDO
133 ENDDO
134 ENDDO
135 theSD = theSD + theSDtile
136 ENDDO
137 ENDDO
138
139 _GLOBAL_SUM_R8(theSD,myThid)
140
141 theSD=sqrt(theSD/theVol)
142 c theSD=sqrt(theVar-theMean**2)
143 ENDIF
144
145 RETURN
146 END

  ViewVC Help
Powered by ViewVC 1.1.22