1 |
heimbach |
1.1 |
|
2 |
|
|
#include "CPP_OPTIONS.h" |
3 |
|
|
|
4 |
|
|
SUBROUTINE DEBUG_FLD_STATS_RS( |
5 |
|
|
I myNr, arr, |
6 |
|
|
O theMin,theMax,theMean,theSD, |
7 |
|
|
I myThid ) |
8 |
|
|
C /==========================================================\ |
9 |
|
|
C | SUBROUTINE DEBUG_FLD_STATS_RS | |
10 |
|
|
C | o Calculate bare statistics of global array "_RS arr" | |
11 |
|
|
C |==========================================================| |
12 |
|
|
C \==========================================================/ |
13 |
|
|
IMPLICIT NONE |
14 |
|
|
|
15 |
|
|
C === Global data === |
16 |
|
|
#include "SIZE.h" |
17 |
|
|
#include "EEPARAMS.h" |
18 |
|
|
|
19 |
|
|
C === Routine arguments === |
20 |
|
|
INTEGER myNr |
21 |
|
|
_RS arr(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy) |
22 |
|
|
_RL theMin |
23 |
|
|
_RL theMax |
24 |
|
|
_RL theMean |
25 |
|
|
_RL theSD |
26 |
|
|
INTEGER myThid |
27 |
|
|
|
28 |
|
|
C === Local variables ==== |
29 |
|
|
INTEGER bi,bj,I,J,K |
30 |
|
|
INTEGER numPnts |
31 |
|
|
LOGICAL noPnts |
32 |
|
|
_RL tmpVal,rNumPnts |
33 |
|
|
_RL theVar |
34 |
|
|
|
35 |
|
|
theMin=0. |
36 |
|
|
theMax=0. |
37 |
|
|
theMean=0. |
38 |
|
|
theSD=0. |
39 |
|
|
theVar=0. |
40 |
|
|
numPnts=0 |
41 |
|
|
noPnts=.TRUE. |
42 |
|
|
|
43 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
44 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
45 |
|
|
DO K=1,myNr |
46 |
|
|
DO J=1,sNy |
47 |
|
|
DO I=1,sNx |
48 |
|
|
tmpVal=arr(I,J,K,bi,bj) |
49 |
|
|
IF (tmpVal.NE.0. .AND. noPnts) THEN |
50 |
|
|
theMin=tmpVal |
51 |
|
|
theMax=tmpVal |
52 |
|
|
noPnts=.FALSE. |
53 |
|
|
ENDIF |
54 |
|
|
IF (tmpVal.NE.0.) THEN |
55 |
|
|
theMin=min(theMin,tmpVal) |
56 |
|
|
theMax=max(theMax,tmpVal) |
57 |
|
|
theMean=theMean+tmpVal |
58 |
|
|
theVar=theVar+tmpVal**2 |
59 |
|
|
numPnts=numPnts+1 |
60 |
|
|
ENDIF |
61 |
|
|
ENDDO |
62 |
|
|
ENDDO |
63 |
|
|
ENDDO |
64 |
|
|
ENDDO |
65 |
|
|
ENDDO |
66 |
|
|
|
67 |
|
|
theMin=-theMin |
68 |
|
|
_GLOBAL_MAX_R8(theMin,myThid) |
69 |
|
|
theMin=-theMin |
70 |
|
|
_GLOBAL_MAX_R8(theMax,myThid) |
71 |
|
|
_GLOBAL_SUM_R8(theMean,myThid) |
72 |
|
|
_GLOBAL_SUM_R8(theVar,myThid) |
73 |
|
|
tmpVal=FLOAT(numPnts) |
74 |
|
|
_GLOBAL_SUM_R8(tmpVal,myThid) |
75 |
|
|
numPnts=INT(tmpVal+0.5) |
76 |
|
|
|
77 |
|
|
IF (tmpVal.GT.0.) THEN |
78 |
|
|
rNumPnts=1./tmpVal |
79 |
|
|
theMean=theMean*rNumPnts |
80 |
|
|
theVar=theVar*rNumPnts |
81 |
|
|
|
82 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
83 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
84 |
|
|
DO K=1,myNr |
85 |
|
|
DO J=1,sNy |
86 |
|
|
DO I=1,sNx |
87 |
|
|
tmpVal=arr(I,J,K,bi,bj) |
88 |
|
|
IF (tmpVal.NE.0.) THEN |
89 |
|
|
theSD=theSD+(tmpVal-theMean)**2 |
90 |
|
|
ENDIF |
91 |
|
|
ENDDO |
92 |
|
|
ENDDO |
93 |
|
|
ENDDO |
94 |
|
|
ENDDO |
95 |
|
|
ENDDO |
96 |
|
|
|
97 |
|
|
_GLOBAL_SUM_R8(theSD,myThid) |
98 |
|
|
|
99 |
|
|
theSD=sqrt(theSD*rNumPnts) |
100 |
|
|
c theSD=sqrt(theVar-theMean**2) |
101 |
|
|
ENDIF |
102 |
|
|
|
103 |
|
|
RETURN |
104 |
|
|
END |