1 |
C $Header: /u/gcmpack/MITgcm/pkg/monitor/mon_stats_latbnd_rl.F,v 1.4 2004/03/05 02:28:11 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "MONITOR_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP |
8 |
C !ROUTINE: MON_STATS_LATBND_RL |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE MON_STATS_LATBND_RL( |
12 |
I myNr, mskNr, kLoc, nSepBnd, ySepBnd, |
13 |
I arr, arrMask, arrhFac, arrArea, arrY, arrDr, |
14 |
O theMin,theMax,theMean,theVar,theVol, |
15 |
I myThid ) |
16 |
|
17 |
C !DESCRIPTION: |
18 |
C Calculate bare statistics of global array "\_RL arr" on each |
19 |
C Latitude band (given by \texttt{ySepBnd}). |
20 |
|
21 |
C !USES: |
22 |
IMPLICIT NONE |
23 |
#include "SIZE.h" |
24 |
#include "EEPARAMS.h" |
25 |
INTEGER NLATBND |
26 |
EXTERNAL NLATBND |
27 |
|
28 |
C !INPUT PARAMETERS: |
29 |
C nSepBnd :: Number of latitude bands |
30 |
C ySepBnd :: Southern latitude egde (from 2 to nSepBnd, 1 is not used) |
31 |
INTEGER myNr, mskNr, kLoc |
32 |
INTEGER nSepBnd |
33 |
_RS ySepBnd(nSepBnd) |
34 |
_RL arr(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy) |
35 |
_RS arrMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy,mskNr,nSx,nSy) |
36 |
_RS arrhFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy,mskNr,nSx,nSy) |
37 |
_RS arrArea(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
38 |
_RS arrY(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
39 |
_RS arrDr(myNr) |
40 |
_RL theMin(nSepBnd) |
41 |
_RL theMax(nSepBnd) |
42 |
_RL theMean(nSepBnd) |
43 |
_RL theVar(nSepBnd) |
44 |
_RL theVol(nSepBnd) |
45 |
INTEGER myThid |
46 |
CEOP |
47 |
|
48 |
C !LOCAL VARIABLES: |
49 |
INTEGER bi,bj,i,j,k,n |
50 |
INTEGER km, k1, k2 |
51 |
INTEGER numPnts |
52 |
LOGICAL noPnts(Ny) |
53 |
_RL tmpVal,rNumPnts |
54 |
_RL tmpVol |
55 |
|
56 |
C- set k index range [k1,k2] |
57 |
IF ( kLoc.EQ.0 ) THEN |
58 |
k1 = 1 |
59 |
k2 = myNr |
60 |
ELSE |
61 |
k1 = kLoc |
62 |
k2 = kLoc |
63 |
ENDIF |
64 |
|
65 |
DO n=1,nSepBnd |
66 |
noPnts(n)=.TRUE. |
67 |
theMin(n)=0. |
68 |
theMax(n)=0. |
69 |
theMean(n)=0. |
70 |
theVar(n)=0. |
71 |
theVol(n)=0. |
72 |
ENDDO |
73 |
|
74 |
DO bj=myByLo(myThid),myByHi(myThid) |
75 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
76 |
DO k=k1,k2 |
77 |
km = MIN(k,mskNr) |
78 |
DO j=1,sNy |
79 |
DO i=1,sNx |
80 |
n = NLATBND(nSepBnd, ySepBnd, arrY(i,j,bi,bj) ) |
81 |
tmpVal=arr(i,j,k,bi,bj) |
82 |
IF (arrMask(i,j,km,bi,bj).NE.0. .AND. noPnts(n)) THEN |
83 |
theMin(n)=tmpVal |
84 |
theMax(n)=tmpVal |
85 |
noPnts(n)=.FALSE. |
86 |
ENDIF |
87 |
IF (arrMask(i,j,km,bi,bj).NE.0.) THEN |
88 |
theMin(n)=MIN(theMin(n),tmpVal) |
89 |
theMax(n)=MAX(theMax(n),tmpVal) |
90 |
tmpVol = arrArea(i,j,bi,bj)*arrhFac(i,j,km,bi,bj)*arrDr(k) |
91 |
& *arrMask(i,j,km,bi,bj) |
92 |
theVol(n) = theVol(n) + tmpVol |
93 |
theMean(n)= theMean(n)+ tmpVol*tmpVal |
94 |
theVar(n) = theVar(n) + tmpVol*tmpVal*tmpVal |
95 |
ENDIF |
96 |
ENDDO |
97 |
ENDDO |
98 |
ENDDO |
99 |
ENDDO |
100 |
ENDDO |
101 |
|
102 |
DO n=1,nSepBnd |
103 |
_GLOBAL_SUM_R8(theVol(n), myThid) |
104 |
_GLOBAL_SUM_R8(theMean(n),myThid) |
105 |
_GLOBAL_SUM_R8(theVar(n), myThid) |
106 |
ENDDO |
107 |
|
108 |
DO n=1,nSepBnd |
109 |
IF (theVol(n).GT.0.) THEN |
110 |
theMean(n)= theMean(n)/theVol(n) |
111 |
theVar(n) = theVar(n) /theVol(n) |
112 |
theVar(n) = theVar(n) -theMean(n)*theMean(n) |
113 |
IF ( noPnts(n) ) theMin(n) = theMean(n) |
114 |
theMin(n) = -theMin(n) |
115 |
_GLOBAL_MAX_R8(theMin(n), myThid) |
116 |
theMin(n)=-theMin(n) |
117 |
IF ( noPnts(n) ) theMax(n) = theMin(n) |
118 |
_GLOBAL_MAX_R8(theMax(n), myThid) |
119 |
ENDIF |
120 |
ENDDO |
121 |
|
122 |
RETURN |
123 |
END |
124 |
|
125 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
126 |
CBOP |
127 |
C !ROUTINE: NLATBND |
128 |
|
129 |
C !INTERFACE: |
130 |
INTEGER FUNCTION NLATBND( nBnd, yBnd, yLoc ) |
131 |
IMPLICIT NONE |
132 |
|
133 |
C !DESCRIPTION: |
134 |
C Find the latidude band of yLoc in nSep strip |
135 |
|
136 |
C !INPUT PARAMETERS: |
137 |
C nBnd :: Number of latitude bands |
138 |
C yBnd :: latitude of southern boundary (for each lat. band) |
139 |
C yLoc :: current latitude |
140 |
INTEGER nBnd |
141 |
_RS yBnd(nBnd) |
142 |
_RS yLoc |
143 |
CEOP |
144 |
|
145 |
C !LOCAL VARIABLES: |
146 |
INTEGER n |
147 |
|
148 |
NLATBND = 1 |
149 |
DO n=2,nBnd |
150 |
IF (yLoc .GT. yBnd(n)) NLATBND = n |
151 |
ENDDO |
152 |
|
153 |
RETURN |
154 |
END |
155 |
|
156 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |