/[MITgcm]/MITgcm/pkg/debug/debug_fld_stats_rl.F
ViewVC logotype

Contents of /MITgcm/pkg/debug/debug_fld_stats_rl.F

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


Revision 1.4 - (show annotations) (download)
Tue Jul 26 16:23:52 2016 UTC (7 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint65z, checkpoint65y, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, HEAD
Changes since 1.3: +84 -57 lines
- change GLOBAL_SUM to GLOBAL_SUM_TILE (result independent of tile to
  proc/thread mapping);
- fix Min & Max for case where 1 thread has only empty tiles;
- use RL variable to count number of wet grid points (with big domain,
  can be too large to fit into integer*4).

1 C $Header: /u/gcmpack/MITgcm/pkg/debug/debug_fld_stats_rl.F,v 1.3 2009/04/28 18:10:47 jmc Exp $
2 C $Name: $
3
4 #include "DEBUG_OPTIONS.h"
5
6 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
7 CBOP
8 C !ROUTINE: DEBUG_FLD_STATS_RL
9
10 C !INTERFACE:
11 SUBROUTINE DEBUG_FLD_STATS_RL(
12 I myNr, arr, exclValue,
13 O theMin, theMax, theMean, theSD,
14 I myThid )
15
16 C *==========================================================*
17 C | SUBROUTINE DEBUG_FLD_STATS_RL |
18 C | o Calculate bare statistics of global array "_RL arr" |
19 C *==========================================================*
20
21 C !USES:
22 IMPLICIT NONE
23
24 C === Global data ===
25 #include "SIZE.h"
26 #include "EEPARAMS.h"
27
28 C !INPUT/OUTPUT PARAMETERS:
29 C myNr :: 3rd dimension of input field array
30 C arr :: input field array
31 C exclValue :: exclusion value
32 C theMin :: field minimum value
33 C theMax :: field maximun value
34 C theMean :: field averaged value
35 C theStD :: field Standard Deviation
36 C myThid :: my Thread Id number
37 INTEGER myNr
38 _RL arr(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy)
39 _RL exclValue
40 _RL theMin
41 _RL theMax
42 _RL theMean
43 _RL theSD
44 INTEGER myThid
45
46 C !LOCAL VARIABLES:
47 INTEGER bi,bj,i,j,k
48 LOGICAL noPnts
49 _RL tmpVal
50 _RL nbPnts, rNbPnts
51 _RL theVar
52 _RL tileMean(nSx,nSy)
53 _RL tileVar (nSx,nSy)
54 _RL tileSD (nSx,nSy)
55 _RL tileNbPt(nSx,nSy)
56 CEOP
57
58 theMin = 0.
59 theMax = 0.
60 theMean= 0.
61 theSD = 0.
62 theVar = 0.
63 nbPnts = 0.
64 noPnts = .TRUE.
65
66 DO bj=myByLo(myThid),myByHi(myThid)
67 DO bi=myBxLo(myThid),myBxHi(myThid)
68 tileNbPt(bi,bj) = 0.
69 tileMean(bi,bj) = 0.
70 tileVar (bi,bj) = 0.
71 DO k=1,myNr
72 DO j=1,sNy
73 DO i=1,sNx
74 tmpVal = arr(i,j,k,bi,bj)
75 IF ( tmpVal.NE.exclValue .AND. noPnts ) THEN
76 theMin = tmpVal
77 theMax = tmpVal
78 noPnts = .FALSE.
79 ENDIF
80 IF ( tmpVal.NE.exclValue ) THEN
81 theMin = MIN( theMin, tmpVal )
82 theMax = MAX( theMax, tmpVal )
83 tileNbPt(bi,bj) = tileNbPt(bi,bj) + 1. _d 0
84 tileMean(bi,bj) = tileMean(bi,bj) + tmpVal
85 tileVar (bi,bj) = tileVar (bi,bj) + tmpVal*tmpVal
86 ENDIF
87 ENDDO
88 ENDDO
89 ENDDO
90 ENDDO
91 ENDDO
92
93 CALL GLOBAL_SUM_TILE_RL( tileNbPt, nbPnts, myThid )
94 CALL GLOBAL_SUM_TILE_RL( tileMean, theMean, myThid )
95 c CALL GLOBAL_SUM_TILE_RL( tileVar , theVar, myThid )
96
97 IF ( nbPnts.GT.zeroRL ) THEN
98 rNbPnts = 1. _d 0/nbPnts
99 theMean = theMean*rNbPnts
100 c theVar = theVar *rNbPnts
101
102 IF ( noPnts ) theMin = theMean
103 theMin = -theMin
104 _GLOBAL_MAX_RL( theMin, myThid )
105 theMin = -theMin
106 IF ( noPnts ) theMax = theMean
107 _GLOBAL_MAX_RL( theMax, myThid )
108
109 DO bj=myByLo(myThid),myByHi(myThid)
110 DO bi=myBxLo(myThid),myBxHi(myThid)
111 tileSD(bi,bj) = 0.
112 DO k=1,myNr
113 DO j=1,sNy
114 DO i=1,sNx
115 tmpVal = arr(i,j,k,bi,bj)
116 IF ( tmpVal.NE.exclValue ) THEN
117 tileSD(bi,bj) = tileSD(bi,bj)
118 & + (tmpVal-theMean)*(tmpVal-theMean)
119 ENDIF
120 ENDDO
121 ENDDO
122 ENDDO
123 ENDDO
124 ENDDO
125
126 CALL GLOBAL_SUM_TILE_RL( tileSD, theSD, myThid )
127
128 theSD = SQRT( theSD*rNbPnts )
129 c theSD = SQRT( theVar - theMean*theMean )
130 ENDIF
131
132 RETURN
133 END

  ViewVC Help
Powered by ViewVC 1.1.22