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

Contents of /MITgcm/pkg/diagnostics/diag_vegtile_fill.F

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


Revision 1.12 - (show annotations) (download)
Sun Jan 3 00:42:45 2010 UTC (14 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint63, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x
Changes since 1.11: +3 -1 lines
avoid unused variables

1 C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diag_vegtile_fill.F,v 1.11 2009/09/03 20:46:12 jmc Exp $
2 C $Name: $
3
4 #include "DIAG_OPTIONS.h"
5
6 CBOP
7 C !ROUTINE: DIAG_VEGTILE_FILL
8 C !INTERFACE:
9 SUBROUTINE DIAG_VEGTILE_FILL(
10 & field,indx,chfr,ib,numpts,npeice,
11 & check, chardiag, kLev, nLevs, bi, bj, myThid )
12 C !DESCRIPTION:
13 C***********************************************************************
14 C Increment the diagnostics array with a vegetation tile space field
15 C***********************************************************************
16 C !USES:
17 IMPLICIT NONE
18
19 C == Global variables ===
20 #include "EEPARAMS.h"
21 #include "SIZE.h"
22 #include "DIAGNOSTICS_SIZE.h"
23 #include "DIAGNOSTICS.h"
24
25 C !INPUT PARAMETERS:
26 C***********************************************************************
27 C field :: array to be mapped to grid space [ib,levs] and added to qdiag
28 C indx :: array of horizontal indices of grid points to convert to
29 C tile space[numpts]
30 C chfr :: fractional area covered by the tile [ib]
31 C ib :: inner dimension of source array and number of points in
32 C array a that need to be pasted
33 C numpts :: total number of points which were stripped
34 C npeice :: the current strip number to be filled
35 C check :: logical to check for undefined values
36 C chardiag :: Character expression for diag to fill
37 C kLev :: Integer flag for vertical levels:
38 C > 0 (any integer): which single level to increment
39 C 0,-1 to increment "nLevs" levels in qdiag:
40 C 0 : fill-in in the same order as the input array
41 C -1 : fill-in in reverse order.
42 C nLevs :: indicates Number of levels of the input field array
43 C bi :: X-direction tile number
44 C bj :: Y-direction tile number
45 C myThid :: my thread Id number
46 C***********************************************************************
47 CHARACTER*8 chardiag
48 INTEGER kLev, nLevs, bi, bj
49 INTEGER myThid
50 INTEGER ib,numpts,npeice
51 INTEGER indx(numpts)
52 _RL field(ib,nlevs), chfr(ib)
53 LOGICAL check
54 CEOP
55
56 C !LOCAL VARIABLES:
57 C ===============
58 INTEGER m, n
59 INTEGER ndiagnum, ipointer
60 INTEGER k, kFirst, kLast
61 INTEGER kd, kd0, ksgn, kStore
62 CHARACTER*(MAX_LEN_MBUF) msgBuf
63 INTEGER offset, Lena
64 INTEGER ivt, ij, i
65 _RL undef
66 INTEGER iSp, ndId, j,l
67 INTEGER region2fill(0:nRegions)
68 _RL scaleFact
69 _RL gridField(sNx*sNy,nlevs), gridFrac(sNx*sNy)
70 #ifndef REAL4_IS_SLOW
71 _RS dummyRS(1)
72 #endif
73
74 #ifdef ALLOW_FIZHI
75 _RL getcon
76 EXTERNAL getcon
77 #endif
78
79 C Run through list of active diagnostics to make sure
80 C we are trying to fill a valid diagnostic
81
82 undef = UNSET_RL
83 #ifdef ALLOW_FIZHI
84 IF ( check ) undef = getcon('UNDEF')
85 #endif
86 ndiagnum = 0
87 ipointer = 0
88 DO n=1,nlists
89 DO m=1,nActive(n)
90 IF ( chardiag.EQ.flds(m,n) .AND. idiag(m,n).GT.0 ) THEN
91 ndiagnum = jdiag(m,n)
92 ipointer = idiag(m,n)
93 IF ( ndiagnum.NE.0 .AND. ndiag(ipointer,1,1).GE.0 ) THEN
94 C-- do the filling: start here:
95
96 IF ( (ABS(kLev).LE.1) .AND. (npeice.EQ.1) ) THEN
97 C Increment the counter for the diagnostic
98 ndiag(ipointer,bi,bj) = ndiag(ipointer,bi,bj) + 1
99 ENDIF
100
101 offset = ib*(npeice-1)
102 Lena = MIN(ib,numpts-offset)
103
104 C- Which part of field to add : k = 3rd index,
105 C and do the loop >> do k=kFirst,kLast <<
106 IF (kLev.LE.0) THEN
107 kFirst = 1
108 kLast = nLevs
109 ELSEIF ( nLevs.EQ.1 ) THEN
110 kFirst = 1
111 kLast = 1
112 ELSEIF ( kLev.LE.nLevs ) THEN
113 kFirst = kLev
114 kLast = kLev
115 ELSE
116 STOP 'ABNORMAL END: S/R DIAGNOSTICS_FILL kLev > nLevs > 0'
117 ENDIF
118 C- Which part of qdiag to update: kd = 3rd index,
119 C and do the loop >> do k=kFirst,kLast ; kd = kd0 + k*ksgn <<
120 IF ( kLev.EQ.-1 ) THEN
121 ksgn = -1
122 kd0 = ipointer + nLevs
123 ELSEIF ( kLev.EQ.0 ) THEN
124 ksgn = 1
125 kd0 = ipointer - 1
126 ELSE
127 ksgn = 0
128 kd0 = ipointer + kLev - 1
129 ENDIF
130
131 C- Check for consistency with Nb of levels reserved in storage array
132 kStore = kd0 + MAX(ksgn*kFirst,ksgn*kLast) - ipointer + 1
133 IF ( kStore.GT.kdiag(ndiagnum) ) THEN
134 _BEGIN_MASTER(myThid)
135 WRITE(msgBuf,'(2A,I4,A)') 'DIAGNOSTICS_FILL: ',
136 & 'exceed Nb of levels(=',kdiag(ndiagnum),' ) reserved '
137 CALL PRINT_ERROR( msgBuf , myThid )
138 WRITE(msgBuf,'(2A,I6,2A)') 'DIAGNOSTICS_FILL: ',
139 & 'for Diagnostics #', ndiagnum, ' : ', chardiag
140 CALL PRINT_ERROR( msgBuf , myThid )
141 WRITE(msgBuf,'(2A,2I4,I3)') 'calling DIAGNOSTICS_FILL ',
142 & 'with kLev,nLevs=', kLev,nLevs
143 CALL PRINT_ERROR( msgBuf , myThid )
144 WRITE(msgBuf,'(2A,I6,A)') 'DIAGNOSTICS_FILL: ',
145 & '==> trying to store up to ', kStore, ' levels'
146 CALL PRINT_ERROR( msgBuf , myThid )
147 STOP 'ABNORMAL END: S/R DIAGNOSTICS_FILL'
148 _END_MASTER(myThid)
149 ENDIF
150
151 DO k = kFirst,kLast
152 kd = kd0 + ksgn*k
153 IF ( check ) THEN
154 DO ivt = 1,Lena
155 ij = indx(ivt+offset) - 1
156 j = 1 + INT(ij/sNx)
157 i = 1 + MOD(ij,sNx)
158 IF ( field(ivt,k).EQ.undef ) THEN
159 qdiag(i,j,kd,bi,bj) = undef
160 ELSEIF ( qdiag(i,j,kd,bi,bj).NE.undef ) THEN
161 qdiag(i,j,kd,bi,bj) = qdiag(i,j,kd,bi,bj)
162 & + field(ivt,k)*chfr(ivt)
163 ENDIF
164 ENDDO
165 ELSE
166 DO ivt = 1,Lena
167 ij = indx(ivt+offset) - 1
168 j = 1 + INT(ij/sNx)
169 i = 1 + MOD(ij,sNx)
170 qdiag(i,j,kd,bi,bj) = qdiag(i,j,kd,bi,bj)
171 & + field(ivt,k)*chfr(ivt)
172 ENDDO
173 ENDIF
174 ENDDO
175
176 C-- do the filling: ends here.
177 ENDIF
178 ENDIF
179 ENDDO
180 ENDDO
181
182 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
183 C-- Global/Regional Statistics :
184 scaleFact = 1. _d 0
185
186 C Run through list of active statistics-diagnostics to make sure
187 C we are trying to compute & fill a valid diagnostic
188
189 DO n=1,diagSt_nbLists
190 DO m=1,diagSt_nbActv(n)
191 IF ( chardiag.EQ.diagSt_Flds(m,n) .AND. iSdiag(m,n).GT.0 ) THEN
192 iSp = iSdiag(m,n)
193 IF ( qSdiag(0,0,iSp,bi,bj).GE.0. ) THEN
194 ndId = jSdiag(m,n)
195 C- Find list of regions to fill:
196 DO j=0,nRegions
197 region2fill(j) = diagSt_region(j,n)
198 ENDDO
199 C- if this diagnostics appears in several lists (with same freq)
200 C then add regions from other lists
201 DO l=1,diagSt_nbLists
202 DO k=1,diagSt_nbActv(l)
203 IF ( iSdiag(k,l).EQ.-iSp ) THEN
204 DO j=0,nRegions
205 region2fill(j) = MAX(region2fill(j),diagSt_region(j,l))
206 ENDDO
207 ENDIF
208 ENDDO
209 ENDDO
210
211 C- Which part of field to add : k = 3rd index,
212 C and do the loop >> do k=kFirst,kLast <<
213 IF (kLev.LE.0) THEN
214 kFirst = 1
215 kLast = nLevs
216 ELSE
217 kFirst = 1
218 kLast = 1
219 ENDIF
220
221 C- Fill local array with grid-space field after conversion.
222 offset = ib*(npeice-1)
223 Lena = MIN(ib,numpts-offset)
224
225 DO ij = 1,sNx*sNy
226 gridFrac(ij)= 0.
227 ENDDO
228 DO ivt = 1,Lena
229 ij = indx(ivt+offset)
230 gridFrac(ij)=gridFrac(ij)+chfr(ivt)
231 ENDDO
232
233 DO k = kFirst,kLast
234 DO ij = 1,sNx*sNy
235 gridField(ij,k)= 0.
236 ENDDO
237 IF ( check ) THEN
238 DO ivt = 1,Lena
239 ij = indx(ivt+offset)
240 IF ( field(ivt,k).EQ.undef ) THEN
241 gridField(ij,k) = undef
242 ELSEIF ( gridFrac(ij).GT.0. _d 0 ) THEN
243 gridField(ij,k) = gridField(ij,k)
244 & + field(ivt,k)*chfr(ivt)/gridFrac(ij)
245 ENDIF
246 ENDDO
247 ELSE
248 DO ivt = 1,Lena
249 ij = indx(ivt+offset)
250 IF ( gridFrac(ij).GT.0. _d 0 ) THEN
251 gridField(ij,k) = gridField(ij,k)
252 & + field(ivt,k)*chfr(ivt)/gridFrac(ij)
253 ENDIF
254 ENDDO
255 ENDIF
256 ENDDO
257
258 C- diagnostics is valid and Active: Now do the filling
259 CALL DIAGSTATS_FILL(
260 I gridField, gridFrac,
261 #ifndef REAL4_IS_SLOW
262 I dummyRS, dummyRS,
263 #endif
264 I scaleFact, 1, 0, 1,
265 I ndId, iSp, region2fill, kLev, nLevs,
266 I 3, bi, bj, myThid )
267 ENDIF
268 ENDIF
269 ENDDO
270 ENDDO
271
272 RETURN
273 END

  ViewVC Help
Powered by ViewVC 1.1.22