6 |
CBOP |
CBOP |
7 |
C !ROUTINE: DIAGSTATS_FILL |
C !ROUTINE: DIAGSTATS_FILL |
8 |
C !INTERFACE: |
C !INTERFACE: |
9 |
SUBROUTINE DIAGSTATS_FILL( inpFld, ndId, kInQSd, region2fill, |
SUBROUTINE DIAGSTATS_FILL( |
10 |
I kLev, nLevs, bibjflg, biArg, bjArg, myThid ) |
I inpFld, fractFld, scaleFact, nLevFract, |
11 |
|
I ndId, kInQSd, region2fill, kLev, nLevs, |
12 |
|
I bibjflg, biArg, bjArg, myThid ) |
13 |
|
|
14 |
C !DESCRIPTION: |
C !DESCRIPTION: |
15 |
C*********************************************************************** |
C*********************************************************************** |
16 |
C compute statistics over 1 tile |
C compute statistics over 1 tile |
17 |
C and increment the diagnostics array |
C and increment the diagnostics array |
18 |
|
C using a scaling factor |
19 |
|
C and with the option to use a fraction-weight (assumed |
20 |
|
C to be the counter-mate of the current diagnostics) |
21 |
C*********************************************************************** |
C*********************************************************************** |
22 |
C !USES: |
C !USES: |
23 |
IMPLICIT NONE |
IMPLICIT NONE |
33 |
C Arguments Description |
C Arguments Description |
34 |
C ---------------------- |
C ---------------------- |
35 |
C inpFld ..... Field to increment diagnostics array |
C inpFld ..... Field to increment diagnostics array |
36 |
|
C fractFld ... fraction used for weighted average diagnostics |
37 |
|
C scaleFact .. scaling factor |
38 |
|
C nLevFract .. number of levels of the fraction field, =0 : do not use fraction |
39 |
C ndId ... Diagnostics Id Number (in available diag list) of diag to process |
C ndId ... Diagnostics Id Number (in available diag list) of diag to process |
40 |
C kInQSd ... Pointer to the slot in qSdiag to fill |
C kInQSd ... Pointer to the slot in qSdiag to fill |
41 |
C region2fill array, indicates whether to compute statistics over region |
C region2fill array, indicates whether to compute statistics over region |
43 |
C kLev ..... Integer flag for vertical levels: |
C kLev ..... Integer flag for vertical levels: |
44 |
C > 0 (any integer): WHICH single level to increment in qSdiag. |
C > 0 (any integer): WHICH single level to increment in qSdiag. |
45 |
C 0,-1 to increment "nLevs" levels in qSdiag, |
C 0,-1 to increment "nLevs" levels in qSdiag, |
46 |
C 0 : fill-in in the same order as the input array |
C 0 : fill-in in the same order as the input array |
47 |
C -1: fill-in in reverse order. |
C -1: fill-in in reverse order. |
48 |
C nLevs ...... indicates Number of levels of the input field array |
C nLevs ...... indicates Number of levels of the input field array |
49 |
C (whether to fill-in all the levels (kLev<1) or just one (kLev>0)) |
C (whether to fill-in all the levels (kLev<1) or just one (kLev>0)) |
65 |
C or there will be out of bounds problems! |
C or there will be out of bounds problems! |
66 |
C*********************************************************************** |
C*********************************************************************** |
67 |
_RL inpFld(*) |
_RL inpFld(*) |
68 |
|
_RL fractFld(*) |
69 |
|
_RL scaleFact |
70 |
|
INTEGER nLevFract |
71 |
INTEGER ndId, kInQSd |
INTEGER ndId, kInQSd |
72 |
INTEGER region2fill(0:nRegions) |
INTEGER region2fill(0:nRegions) |
73 |
INTEGER kLev, nLevs, bibjflg, biArg, bjArg |
INTEGER kLev, nLevs, bibjflg, biArg, bjArg |
76 |
|
|
77 |
C !LOCAL VARIABLES: |
C !LOCAL VARIABLES: |
78 |
C =============== |
C =============== |
79 |
c INTEGER m, n |
C useFract :: flag to increment (or not) with fraction-weigted inpFld |
80 |
|
LOGICAL useFract |
81 |
|
INTEGER sizF |
82 |
INTEGER sizI1,sizI2,sizJ1,sizJ2 |
INTEGER sizI1,sizI2,sizJ1,sizJ2 |
83 |
INTEGER sizTx,sizTy |
INTEGER sizTx,sizTy |
84 |
INTEGER iRun, jRun, k, bi, bj |
INTEGER iRun, jRun, k, bi, bj |
92 |
c IF ( ndId.NE.0 .AND. kInQSd.NE.0 ) THEN |
c IF ( ndId.NE.0 .AND. kInQSd.NE.0 ) THEN |
93 |
|
|
94 |
C- select range for 1rst & 2nd indices to accumulate |
C- select range for 1rst & 2nd indices to accumulate |
95 |
C depending on variable location on C-grid, |
C depending on variable location on C-grid, |
96 |
parms1 = gdiag(ndId)(1:8) |
parms1 = gdiag(ndId)(1:8) |
97 |
IF ( parms1(2:2).EQ.'Z' ) THEN |
IF ( parms1(2:2).EQ.'Z' ) THEN |
98 |
iRun = sNx+1 |
iRun = sNx+1 |
143 |
ELSE |
ELSE |
144 |
STOP 'ABNORMAL END in DIAGSTATS_FILL: kLev > nLevs > 0' |
STOP 'ABNORMAL END in DIAGSTATS_FILL: kLev > nLevs > 0' |
145 |
ENDIF |
ENDIF |
146 |
C- Which part of qSdiag to update: kd = 3rd index, |
C- Which part of qSdiag to update: kd = 3rd index, |
147 |
C and do the loop >> do k=kFirst,kLast ; kd = kd0 + k*ksgn << |
C and do the loop >> do k=kFirst,kLast ; kd = kd0 + k*ksgn << |
148 |
C 1rst try this: for the mask: km = km0 + k*ksgn so that kd= km + kInQSd - 1 |
C 1rst try this: for the mask: km = km0 + k*ksgn so that kd= km + kInQSd - 1 |
149 |
IF ( kLev.EQ.-1 ) THEN |
IF ( kLev.EQ.-1 ) THEN |
150 |
ksgn = -1 |
ksgn = -1 |
151 |
kd0 = kInQSd + nLevs |
kd0 = kInQSd + nLevs |
159 |
kd0 = kInQSd + kLev - 1 |
kd0 = kInQSd + kLev - 1 |
160 |
km0 = kLev |
km0 = kLev |
161 |
ENDIF |
ENDIF |
162 |
|
C- Set fraction-weight option : |
163 |
|
useFract = nLevFract.GT.0 |
164 |
|
IF ( useFract ) THEN |
165 |
|
sizF = nLevFract |
166 |
|
ELSE |
167 |
|
sizF = 1 |
168 |
|
ENDIF |
169 |
|
|
170 |
C- Check for consistency with Nb of levels reserved in storage array |
C- Check for consistency with Nb of levels reserved in storage array |
171 |
kStore = kd0 + MAX(ksgn*kFirst,ksgn*kLast) - kInQSd + 1 |
kStore = kd0 + MAX(ksgn*kFirst,ksgn*kLast) - kInQSd + 1 |
188 |
ENDIF |
ENDIF |
189 |
|
|
190 |
IF ( bibjflg.EQ.0 ) THEN |
IF ( bibjflg.EQ.0 ) THEN |
191 |
|
|
192 |
DO bj=myByLo(myThid), myByHi(myThid) |
DO bj=myByLo(myThid), myByHi(myThid) |
193 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
DO bi=myBxLo(myThid), myBxHi(myThid) |
194 |
DO k = kFirst,kLast |
DO k = kFirst,kLast |
196 |
km = km0 + ksgn*k |
km = km0 + ksgn*k |
197 |
CALL DIAGSTATS_LOCAL( |
CALL DIAGSTATS_LOCAL( |
198 |
U qSdiag(0,0,kd,bi,bj), |
U qSdiag(0,0,kd,bi,bj), |
199 |
I inpFld, |
I inpFld, fractFld, scaleFact, useFract, sizF, |
200 |
I sizI1,sizI2,sizJ1,sizJ2,nLevs,sizTx,sizTy, |
I sizI1,sizI2,sizJ1,sizJ2,nLevs,sizTx,sizTy, |
201 |
I iRun,jRun,k,bi,bj, |
I iRun,jRun,k,bi,bj, |
202 |
I km, bi, bj, region2fill, |
I km, bi, bj, region2fill, |
212 |
km = km0 + ksgn*k |
km = km0 + ksgn*k |
213 |
CALL DIAGSTATS_LOCAL( |
CALL DIAGSTATS_LOCAL( |
214 |
U qSdiag(0,0,kd,biArg,bjArg), |
U qSdiag(0,0,kd,biArg,bjArg), |
215 |
I inpFld, |
I inpFld, fractFld, scaleFact, useFract, sizF, |
216 |
I sizI1,sizI2,sizJ1,sizJ2,nLevs,sizTx,sizTy, |
I sizI1,sizI2,sizJ1,sizJ2,nLevs,sizTx,sizTy, |
217 |
I iRun,jRun,k,bi,bj, |
I iRun,jRun,k,bi,bj, |
218 |
I km, biArg, bjArg, region2fill, |
I km, biArg, bjArg, region2fill, |
225 |
|
|
226 |
c ENDIF |
c ENDIF |
227 |
|
|
228 |
RETURN |
RETURN |
229 |
END |
END |