/[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.5 - (hide annotations) (download)
Fri Mar 5 02:28:11 2004 UTC (20 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint52l_pre, hrcube5, checkpoint52l_post
Changes since 1.4: +10 -7 lines
fix problem in min/max monitor when 1 tile is empty

1 jmc 1.5 C $Header: /u/gcmpack/MITgcm/pkg/monitor/mon_stats_rs.F,v 1.4 2004/02/06 19:59:36 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 jmc 1.5 _RL theMean
27     _RL theSD
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 jmc 1.5 _RL theMeanTile,theSDTile
37 adcroft 1.1
38     theMin=0.
39     theMax=0.
40     theMean=0.
41     theSD=0.
42     theVar=0.
43     numPnts=0
44     noPnts=.TRUE.
45    
46     DO bj=myByLo(myThid),myByHi(myThid)
47     DO bi=myBxLo(myThid),myBxHi(myThid)
48 adcroft 1.4 theVarTile=0.
49     theMeanTile=0.
50 adcroft 1.1 DO K=1,myNr
51     DO J=1,sNy
52     DO I=1,sNx
53     tmpVal=arr(I,J,K,bi,bj)
54     IF (tmpVal.NE.0. .AND. noPnts) THEN
55     theMin=tmpVal
56     theMax=tmpVal
57     noPnts=.FALSE.
58     ENDIF
59     IF (tmpVal.NE.0.) THEN
60     theMin=min(theMin,tmpVal)
61     theMax=max(theMax,tmpVal)
62 adcroft 1.4 theMeanTile=theMeanTile+tmpVal
63     theVarTile=theVarTile+tmpVal**2
64 adcroft 1.1 numPnts=numPnts+1
65     ENDIF
66     ENDDO
67     ENDDO
68     ENDDO
69 adcroft 1.4 theMean=theMean+theMeanTile
70     theVar=theVar+theVarTile
71 adcroft 1.1 ENDDO
72     ENDDO
73    
74     _GLOBAL_SUM_R8(theMean,myThid)
75     _GLOBAL_SUM_R8(theVar,myThid)
76     tmpVal=FLOAT(numPnts)
77     _GLOBAL_SUM_R8(tmpVal,myThid)
78     numPnts=INT(tmpVal+0.5)
79    
80     IF (tmpVal.GT.0.) THEN
81     rNumPnts=1./tmpVal
82     theMean=theMean*rNumPnts
83     theVar=theVar*rNumPnts
84 jmc 1.5 IF ( noPnts ) theMin = theMean
85     theMin=-theMin
86     _GLOBAL_MAX_R8(theMin,myThid)
87     theMin=-theMin
88     IF ( noPnts ) theMax = theMean
89     _GLOBAL_MAX_R8(theMax,myThid)
90 adcroft 1.1
91     DO bj=myByLo(myThid),myByHi(myThid)
92     DO bi=myBxLo(myThid),myBxHi(myThid)
93 adcroft 1.4 theSDtile=0.
94 adcroft 1.1 DO K=1,myNr
95     DO J=1,sNy
96     DO I=1,sNx
97     tmpVal=arr(I,J,K,bi,bj)
98     IF (tmpVal.NE.0.) THEN
99 adcroft 1.4 theSDtile=theSDtile+(tmpVal-theMean)**2
100 adcroft 1.1 ENDIF
101     ENDDO
102     ENDDO
103     ENDDO
104 adcroft 1.4 theSD=theSD+theSDtile
105 adcroft 1.1 ENDDO
106     ENDDO
107    
108     _GLOBAL_SUM_R8(theSD,myThid)
109    
110 adcroft 1.2 theSD=sqrt(theSD*rNumPnts)
111     c theSD=sqrt(theVar-theMean**2)
112 adcroft 1.1 ENDIF
113    
114     RETURN
115     END

  ViewVC Help
Powered by ViewVC 1.1.22