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

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

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


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

  ViewVC Help
Powered by ViewVC 1.1.22