/[MITgcm]/MITgcm/pkg/diagnostics/diagstats_fill.F
ViewVC logotype

Annotation of /MITgcm/pkg/diagnostics/diagstats_fill.F

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


Revision 1.2 - (hide annotations) (download)
Sun Jul 10 00:57:18 2005 UTC (18 years, 10 months ago) by jmc
Branch: MAIN
Changes since 1.1: +34 -14 lines
modif to fill a diagnostics using a scaling factor and a fraction-weight
      field ; does not affect diagnostics_fill.F arguments.

1 jmc 1.2 C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagstats_fill.F,v 1.1 2005/05/20 07:28:51 jmc Exp $
2 jmc 1.1 C $Name: $
3    
4     #include "DIAG_OPTIONS.h"
5    
6     CBOP
7     C !ROUTINE: DIAGSTATS_FILL
8     C !INTERFACE:
9 jmc 1.2 SUBROUTINE DIAGSTATS_FILL(
10     I inpFld, fractFld, scaleFact, nLevFract,
11     I ndId, kInQSd, region2fill, kLev, nLevs,
12     I bibjflg, biArg, bjArg, myThid )
13 jmc 1.1
14     C !DESCRIPTION:
15     C***********************************************************************
16 jmc 1.2 C compute statistics over 1 tile
17     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 jmc 1.1 C***********************************************************************
22     C !USES:
23     IMPLICIT NONE
24    
25     C == Global variables ===
26     #include "EEPARAMS.h"
27     #include "SIZE.h"
28     #include "DIAGNOSTICS_SIZE.h"
29     #include "DIAGNOSTICS.h"
30    
31     C !INPUT PARAMETERS:
32     C***********************************************************************
33     C Arguments Description
34     C ----------------------
35     C inpFld ..... Field to increment diagnostics array
36 jmc 1.2 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 jmc 1.1 C ndId ... Diagnostics Id Number (in available diag list) of diag to process
40     C kInQSd ... Pointer to the slot in qSdiag to fill
41     C region2fill array, indicates whether to compute statistics over region
42     C "j" (if region2fill(j)=1) or not (if region2fill(j)=0)
43     C kLev ..... Integer flag for vertical levels:
44     C > 0 (any integer): WHICH single level to increment in qSdiag.
45     C 0,-1 to increment "nLevs" levels in qSdiag,
46 jmc 1.2 C 0 : fill-in in the same order as the input array
47 jmc 1.1 C -1: fill-in in reverse order.
48     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))
50     C bibjflg .... Integer flag to indicate instructions for bi bj loop
51     C 0 indicates that the bi-bj loop must be done here
52     C 1 indicates that the bi-bj loop is done OUTSIDE
53     C 2 indicates that the bi-bj loop is done OUTSIDE
54     C AND that we have been sent a local array (with overlap regions)
55     C 3 indicates that the bi-bj loop is done OUTSIDE
56     C AND that we have been sent a local array
57     C AND that the array has no overlap region (interior only)
58     C NOTE - bibjflg can be NEGATIVE to indicate not to increment counter
59     C biArg ...... X-direction tile number - used for bibjflg=1-3
60     C bjArg ...... Y-direction tile number - used for bibjflg=1-3
61     C myThid :: my thread Id number
62     C***********************************************************************
63     C NOTE: User beware! If a local (1 tile only) array
64     C is sent here, bibjflg MUST NOT be set to 0
65     C or there will be out of bounds problems!
66     C***********************************************************************
67     _RL inpFld(*)
68 jmc 1.2 _RL fractFld(*)
69     _RL scaleFact
70     INTEGER nLevFract
71 jmc 1.1 INTEGER ndId, kInQSd
72     INTEGER region2fill(0:nRegions)
73     INTEGER kLev, nLevs, bibjflg, biArg, bjArg
74     INTEGER myThid
75     CEOP
76    
77     C !LOCAL VARIABLES:
78     C ===============
79 jmc 1.2 C useFract :: flag to increment (or not) with fraction-weigted inpFld
80     LOGICAL useFract
81     INTEGER sizF
82 jmc 1.1 INTEGER sizI1,sizI2,sizJ1,sizJ2
83     INTEGER sizTx,sizTy
84     INTEGER iRun, jRun, k, bi, bj
85     INTEGER kFirst, kLast
86     INTEGER kd, kd0, ksgn, kStore
87     CHARACTER*8 parms1
88     CHARACTER*(MAX_LEN_MBUF) msgBuf
89     INTEGER km, km0
90    
91     C If-sequence to see if we are a valid and an active diagnostic
92     c IF ( ndId.NE.0 .AND. kInQSd.NE.0 ) THEN
93    
94     C- select range for 1rst & 2nd indices to accumulate
95 jmc 1.2 C depending on variable location on C-grid,
96 jmc 1.1 parms1 = gdiag(ndId)(1:8)
97     IF ( parms1(2:2).EQ.'Z' ) THEN
98     iRun = sNx+1
99     jRun = sNy+1
100     c ELSEIF ( parms1(2:2).EQ.'U' ) THEN
101     c iRun = sNx+1
102     c jRun = sNy
103     c ELSEIF ( parms1(2:2).EQ.'V' ) THEN
104     c iRun = sNx
105     c jRun = sNy+1
106     ELSE
107     iRun = sNx
108     jRun = sNy
109     ENDIF
110    
111     C- Dimension of the input array:
112     IF (ABS(bibjflg).EQ.3) THEN
113     sizI1 = 1
114     sizI2 = sNx
115     sizJ1 = 1
116     sizJ2 = sNy
117     iRun = sNx
118     jRun = sNy
119     ELSE
120     sizI1 = 1-OLx
121     sizI2 = sNx+OLx
122     sizJ1 = 1-OLy
123     sizJ2 = sNy+OLy
124     ENDIF
125     IF (ABS(bibjflg).GE.2) THEN
126     sizTx = 1
127     sizTy = 1
128     ELSE
129     sizTx = nSx
130     sizTy = nSy
131     ENDIF
132     C- Which part of inpFld to add : k = 3rd index,
133     C and do the loop >> do k=kFirst,kLast <<
134     IF (kLev.LE.0) THEN
135     kFirst = 1
136     kLast = nLevs
137     ELSEIF ( nLevs.EQ.1 ) THEN
138     kFirst = 1
139     kLast = 1
140     ELSEIF ( kLev.LE.nLevs ) THEN
141     kFirst = kLev
142     kLast = kLev
143     ELSE
144     STOP 'ABNORMAL END in DIAGSTATS_FILL: kLev > nLevs > 0'
145     ENDIF
146 jmc 1.2 C- Which part of qSdiag to update: kd = 3rd index,
147 jmc 1.1 C and do the loop >> do k=kFirst,kLast ; kd = kd0 + k*ksgn <<
148 jmc 1.2 C 1rst try this: for the mask: km = km0 + k*ksgn so that kd= km + kInQSd - 1
149 jmc 1.1 IF ( kLev.EQ.-1 ) THEN
150     ksgn = -1
151     kd0 = kInQSd + nLevs
152     km0 = 1 + nLevs
153     ELSEIF ( kLev.EQ.0 ) THEN
154     ksgn = 1
155     kd0 = kInQSd - 1
156     km0 = 0
157     ELSE
158     ksgn = 0
159     kd0 = kInQSd + kLev - 1
160     km0 = kLev
161     ENDIF
162 jmc 1.2 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 jmc 1.1
170     C- Check for consistency with Nb of levels reserved in storage array
171     kStore = kd0 + MAX(ksgn*kFirst,ksgn*kLast) - kInQSd + 1
172     IF ( kStore.GT.kdiag(ndId) ) THEN
173     _BEGIN_MASTER(myThid)
174     WRITE(msgBuf,'(2A,I3,A)') 'DIAGSTATS_FILL: ',
175     & 'exceed Nb of levels(=',kdiag(ndId),' ) reserved '
176     CALL PRINT_ERROR( msgBuf , myThid )
177     WRITE(msgBuf,'(2A,I4,2A)') 'DIAGSTATS_FILL: ',
178     & 'for Diagnostics #', ndId, ' : ', cdiag(ndId)
179     CALL PRINT_ERROR( msgBuf , myThid )
180     WRITE(msgBuf,'(2A,2I4,I3)') 'calling DIAGSTATS_FILL ',
181     I 'with kLev,nLevs,bibjFlg=', kLev,nLevs,bibjFlg
182     CALL PRINT_ERROR( msgBuf , myThid )
183     WRITE(msgBuf,'(2A,I6,A)') 'DIAGSTATS_FILL: ',
184     I '==> trying to store up to ', kStore, ' levels'
185     CALL PRINT_ERROR( msgBuf , myThid )
186     STOP 'ABNORMAL END: S/R DIAGSTATS_FILL'
187     _END_MASTER(myThid)
188     ENDIF
189    
190     IF ( bibjflg.EQ.0 ) THEN
191 jmc 1.2
192 jmc 1.1 DO bj=myByLo(myThid), myByHi(myThid)
193     DO bi=myBxLo(myThid), myBxHi(myThid)
194     DO k = kFirst,kLast
195     kd = kd0 + ksgn*k
196     km = km0 + ksgn*k
197     CALL DIAGSTATS_LOCAL(
198     U qSdiag(0,0,kd,bi,bj),
199 jmc 1.2 I inpFld, fractFld, scaleFact, useFract, sizF,
200 jmc 1.1 I sizI1,sizI2,sizJ1,sizJ2,nLevs,sizTx,sizTy,
201     I iRun,jRun,k,bi,bj,
202     I km, bi, bj, region2fill,
203     I ndId, gdiag(ndId), myThid )
204     ENDDO
205     ENDDO
206     ENDDO
207     ELSE
208     bi = MIN(biArg,sizTx)
209     bj = MIN(bjArg,sizTy)
210     DO k = kFirst,kLast
211     kd = kd0 + ksgn*k
212     km = km0 + ksgn*k
213     CALL DIAGSTATS_LOCAL(
214     U qSdiag(0,0,kd,biArg,bjArg),
215 jmc 1.2 I inpFld, fractFld, scaleFact, useFract, sizF,
216 jmc 1.1 I sizI1,sizI2,sizJ1,sizJ2,nLevs,sizTx,sizTy,
217     I iRun,jRun,k,bi,bj,
218     I km, biArg, bjArg, region2fill,
219     I ndId, gdiag(ndId), myThid )
220     ENDDO
221     ENDIF
222    
223     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
224     c ELSE
225    
226     c ENDIF
227    
228 jmc 1.2 RETURN
229 jmc 1.1 END

  ViewVC Help
Powered by ViewVC 1.1.22