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

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

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


Revision 1.4 - (hide annotations) (download)
Fri Feb 6 19:59:36 2004 UTC (20 years, 7 months ago) by adcroft
Branch: MAIN
CVS Tags: hrcube4, checkpoint52j_pre, checkpoint52k_post, hrcube_3, checkpoint52j_post
Changes since 1.3: +13 -7 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 adcroft 1.4 C $Header: /u/gcmpack/MITgcm/pkg/monitor/mon_stats_rs.F,v 1.3 2003/05/13 18:18:05 adcroft Exp $
2 adcroft 1.2 C $Name: $
3 adcroft 1.1
4 adcroft 1.3 #include "MONITOR_OPTIONS.h"
5 adcroft 1.1
6     SUBROUTINE MON_STATS_RS(
7     I myNr, arr,
8     O theMin,theMax,theMean,theSD,
9     I myThid )
10     C /==========================================================\
11     C | SUBROUTINE MON_STATS_RS |
12     C | o Calculate bare statistics of global array "_RS 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     _RS arr(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy)
24     _RL theMin
25     _RL theMax
26 adcroft 1.4 _RL theMean,theMeanTile
27     _RL theSD,theSDTile
28 adcroft 1.1 INTEGER myThid
29    
30     C === Local variables ====
31     INTEGER bi,bj,I,J,K
32     INTEGER numPnts
33     LOGICAL noPnts
34     _RL tmpVal,rNumPnts
35 adcroft 1.4 _RL theVar,theVarTile
36 adcroft 1.1
37     theMin=0.
38     theMax=0.
39     theMean=0.
40     theSD=0.
41     theVar=0.
42     numPnts=0
43     noPnts=.TRUE.
44    
45     DO bj=myByLo(myThid),myByHi(myThid)
46     DO bi=myBxLo(myThid),myBxHi(myThid)
47 adcroft 1.4 theVarTile=0.
48     theMeanTile=0.
49 adcroft 1.1 DO K=1,myNr
50     DO J=1,sNy
51     DO I=1,sNx
52     tmpVal=arr(I,J,K,bi,bj)
53     IF (tmpVal.NE.0. .AND. noPnts) THEN
54     theMin=tmpVal
55     theMax=tmpVal
56     noPnts=.FALSE.
57     ENDIF
58     IF (tmpVal.NE.0.) THEN
59     theMin=min(theMin,tmpVal)
60     theMax=max(theMax,tmpVal)
61 adcroft 1.4 theMeanTile=theMeanTile+tmpVal
62     theVarTile=theVarTile+tmpVal**2
63 adcroft 1.1 numPnts=numPnts+1
64     ENDIF
65     ENDDO
66     ENDDO
67     ENDDO
68 adcroft 1.4 theMean=theMean+theMeanTile
69     theVar=theVar+theVarTile
70 adcroft 1.1 ENDDO
71     ENDDO
72    
73     theMin=-theMin
74     _GLOBAL_MAX_R8(theMin,myThid)
75     theMin=-theMin
76     _GLOBAL_MAX_R8(theMax,myThid)
77     _GLOBAL_SUM_R8(theMean,myThid)
78     _GLOBAL_SUM_R8(theVar,myThid)
79     tmpVal=FLOAT(numPnts)
80     _GLOBAL_SUM_R8(tmpVal,myThid)
81     numPnts=INT(tmpVal+0.5)
82    
83     IF (tmpVal.GT.0.) THEN
84     rNumPnts=1./tmpVal
85     theMean=theMean*rNumPnts
86     theVar=theVar*rNumPnts
87    
88     DO bj=myByLo(myThid),myByHi(myThid)
89     DO bi=myBxLo(myThid),myBxHi(myThid)
90 adcroft 1.4 theSDtile=0.
91 adcroft 1.1 DO K=1,myNr
92     DO J=1,sNy
93     DO I=1,sNx
94     tmpVal=arr(I,J,K,bi,bj)
95     IF (tmpVal.NE.0.) THEN
96 adcroft 1.4 theSDtile=theSDtile+(tmpVal-theMean)**2
97 adcroft 1.1 ENDIF
98     ENDDO
99     ENDDO
100     ENDDO
101 adcroft 1.4 theSD=theSD+theSDtile
102 adcroft 1.1 ENDDO
103     ENDDO
104    
105     _GLOBAL_SUM_R8(theSD,myThid)
106    
107 adcroft 1.2 theSD=sqrt(theSD*rNumPnts)
108     c theSD=sqrt(theVar-theMean**2)
109 adcroft 1.1 ENDIF
110    
111     RETURN
112     END

  ViewVC Help
Powered by ViewVC 1.1.22