/[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.7 - (show annotations) (download)
Fri Feb 6 19:59:36 2004 UTC (20 years, 4 months ago) by adcroft
Branch: MAIN
CVS Tags: hrcube4, checkpoint52j_pre, hrcube_3, checkpoint52j_post
Changes since 1.6: +21 -11 lines
Changed the order of operations for global sums of arrays.
 o the global sum used to accumulate sequentially over all tiles on a single
   process and then the result be passed to _GLOBAL_SUM()
 o now we create a sum per tile and accumulate the sums
   - this should fix differences in sum for two tiles on 1 or 2 processors
   - this may help when using more than2 tiles but is not guaranteed
   - introducing a gather operation in GLOBAL_SUM() will fix differences
     for multiple tiles but only for fixed tiles configurations
   - an array based sum function is needed to make this independent of
     tile configuration

1 C $Header: /u/gcmpack/MITgcm/pkg/monitor/mon_stats_rl.F,v 1.6 2003/11/10 23:03:29 jmc 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,theMeanTile
31 _RL theSD,theSDTile
32 _RL theDel2,theDel2Tile
33 _RL theVol,theVolTile
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
44 theMin=0.
45 theMax=0.
46 theMean=0.
47 theSD=0.
48 theVar=0.
49 theDel2=0.
50 theVol=0.
51 numPnts=0
52 noPnts=.TRUE.
53
54 DO bj=myByLo(myThid),myByHi(myThid)
55 DO bi=myBxLo(myThid),myBxHi(myThid)
56 theDel2 = 0.
57 theVol = 0.
58 theMean = 0.
59 theVar = 0.
60 DO K=1,myNr
61 DO J=1,sNy
62 DO I=1,sNx
63 tmpVal=arr(I,J,K,bi,bj)
64 c IF (tmpVal.NE.0. .AND. noPnts) THEN
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 c IF (tmpVal.NE.0.) THEN
71 IF (arrMask(I,J,K,bi,bj).NE.0.) THEN
72 theMin=min(theMin,tmpVal)
73 theMax=max(theMax,tmpVal)
74 theDel2Tile = theDel2Tile+0.25*ABS(
75 & (arr(I+1,J,K,bi,bj)-tmpVal)*arrMask(I+1,J,K,bi,bj)
76 & +(arr(I-1,J,K,bi,bj)-tmpVal)*arrMask(I-1,J,K,bi,bj)
77 & +(arr(I,J+1,K,bi,bj)-tmpVal)*arrMask(I,J+1,K,bi,bj)
78 & +(arr(I,J-1,K,bi,bj)-tmpVal)*arrMask(I,J-1,K,bi,bj)
79 & )
80 numPnts=numPnts+1
81 tmpVol = arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K)
82 & *arrMask(I,J,K,bi,bj)
83 theVolTile = theVolTile + tmpVol
84 theMeanTile = theMeanTile + tmpVol*tmpVal
85 theVarTile = theVarTile + tmpVol*tmpVal**2
86 ENDIF
87 ENDDO
88 ENDDO
89 ENDDO
90 theDel2 = theDel2 + theDel2Tile
91 theVol = theVol + theVolTile
92 theMean = theMean + theMeanTile
93 theVar = theVar + theVarTile
94 ENDDO
95 ENDDO
96
97 theMin=-theMin
98 _GLOBAL_MAX_R8(theMin,myThid)
99 theMin=-theMin
100 _GLOBAL_MAX_R8(theMax,myThid)
101 _GLOBAL_SUM_R8(theDel2,myThid)
102 _GLOBAL_SUM_R8(theVol,myThid)
103 _GLOBAL_SUM_R8(theMean,myThid)
104 _GLOBAL_SUM_R8(theVar,myThid)
105 tmpVal=FLOAT(numPnts)
106 _GLOBAL_SUM_R8(tmpVal,myThid)
107 numPnts=INT(tmpVal+0.5)
108
109 IF (tmpVal.GT.0.) THEN
110 rNumPnts=1./tmpVal
111 theDel2=theDel2*rNumPnts
112 ENDIF
113
114 IF (theVol.GT.0.) THEN
115 theMean=theMean/theVol
116 theVar=theVar/theVol
117
118 DO bj=myByLo(myThid),myByHi(myThid)
119 DO bi=myBxLo(myThid),myBxHi(myThid)
120 theSDtile=0.
121 DO K=1,myNr
122 DO J=1,sNy
123 DO I=1,sNx
124 tmpVal=arr(I,J,K,bi,bj)
125 c IF (tmpVal.NE.0.) THEN
126 IF (arrMask(I,J,K,bi,bj).NE.0.) THEN
127 tmpVol=arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K)
128 & *arrMask(I,J,K,bi,bj)
129 theSDtile = theSDtile + tmpVol*(tmpVal-theMean)**2
130 ENDIF
131 ENDDO
132 ENDDO
133 ENDDO
134 theSD = theSD + theSDtile
135 ENDDO
136 ENDDO
137
138 _GLOBAL_SUM_R8(theSD,myThid)
139
140 theSD=sqrt(theSD/theVol)
141 c theSD=sqrt(theVar-theMean**2)
142 ENDIF
143
144 RETURN
145 END

  ViewVC Help
Powered by ViewVC 1.1.22