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

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

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


Revision 1.17 - (show annotations) (download)
Tue Dec 14 04:59:36 2004 UTC (19 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.16: +1 -1 lines
FILE REMOVED
remove old version (now replaced by diagnostics_fill.F)

1 C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/fill_diagnostics.F,v 1.16 2004/12/13 21:55:48 jmc Exp $
2 C $Name: $
3
4 #include "DIAG_OPTIONS.h"
5
6 subroutine fill_diagnostics (myThid, chardiag, levflg, nlevs,
7 . bibjflg, bi, bj, arrayin)
8 C***********************************************************************
9 C Purpose
10 C -------
11 C Wrapper routine to increment the diagnostics array with a field
12 C
13 C Arguments Description
14 C ----------------------
15 C myThid ..... Current Process(or)
16 C chardiag ... Character expression for diag to fill
17 C levflg ..... Integer flag for vertical levels:
18 C 0 indicates multiple levels incremented in qdiag
19 C non-0 (any integer) - WHICH single level to increment.
20 C negative integer - the input data array is single-leveled
21 C positive integer - the input data array is multi-leveled
22 C nlevs ...... indicates Number of levels to be filled (1 if levflg <> 0)
23 C positive: fill in "nlevs" levels in the same order as
24 C the input array
25 C negative: fill in -nlevs levels in reverse order.
26 C bibjflg .... Integer flag to indicate instructions for bi bj loop
27 C 0 indicates that the bi-bj loop must be done here
28 C 1 indicates that the bi-bj loop is done OUTSIDE
29 C 2 indicates that the bi-bj loop is done OUTSIDE
30 C AND that we have been sent a local array
31 C 3 indicates that the bi-bj loop is done OUTSIDE
32 C AND that we have been sent a local array
33 C AND that the array has the shadow regions
34 C bi ......... X-direction process(or) number - used for bibjflg=1-3
35 C bj ......... Y-direction process(or) number - used for bibjflg=1-3
36 C arrayin .... Field to increment diagnostics array
37 C NOTE: User beware! If a local (1 tile only) array
38 C is sent here, bibjflg MUST NOT be set to 0
39 C or there will be out of bounds problems!
40 C***********************************************************************
41 implicit none
42 #include "EEPARAMS.h"
43 #include "SIZE.h"
44 #include "DIAGNOSTICS_SIZE.h"
45 #include "DIAGNOSTICS.h"
46
47 integer myThid,levflg,nlevs,bibjflg,bi,bj
48 character *8 chardiag
49 _RL arrayin(*)
50
51 c Local variables
52 c ===============
53 integer i, j, n, ndiagnum, bihere, bjhere, levhere, ipointer
54 _RL array(1-OLx:sNx+Olx,1-Oly:sNy+Oly)
55 _RL arrayloc(sNx,sNy)
56 integer irun,jrun,krun,birun,bjrun
57 integer level
58
59 C Run through list of active diagnostics to make sure
60 C we are trying to fill a valid diagnostic
61
62 ndiagnum = 0
63 ipointer = 0
64 do n = 1,ndiagt
65 if(chardiag.eq.cdiag(n)) then
66 ndiagnum = n
67 ipointer = idiag(n)
68 endif
69 enddo
70
71 C If-sequence to see if we are a valid and an active diagnostic
72
73 IF ( ndiagnum.ne.0 .and. ipointer.ne.0 ) THEN
74
75 C Increment the counter for the diagnostic (if we are at bi=bj=1)
76 if ((bi.eq.1).and.(bj.eq.1).and.
77 . ((levflg.eq.0).or.(abs(levflg).eq.1)))
78 . ndiag(ndiagnum) = ndiag(ndiagnum) + 1
79
80 C Check to see if we need to do a bi-bj loop here
81
82 if(bibjflg.eq.0) then
83 irun = sNx+2*Olx
84 jrun = sNy+2*Oly
85 krun = abs(nlevs)
86 c birun = myBxHi(myThid)-myBxLo(myThid)+1
87 c bjrun = myByHi(myThid)-myByLo(myThid)+1
88 birun = nSx
89 bjrun = nSy
90
91 do bjhere=myByLo(myThid), myByHi(myThid)
92 do bihere=myBxLo(myThid), myBxHi(myThid)
93
94 if(levflg.eq.0)then
95 do levhere = 1,krun
96 level = levhere
97 IF (nlevs.LT.0) level=1-nlevs-levhere
98 call fillit(arrayin,irun,jrun,krun,levhere,birun,bjrun,
99 . bihere,bjhere,array)
100 do j = 1,sNy
101 do i = 1,sNx
102 qdiag(i,j,ipointer+level-1,bihere,bjhere) =
103 . qdiag(i,j,ipointer+level-1,bihere,bjhere) +
104 . array(i,j)
105 enddo
106 enddo
107 enddo
108 elseif(levflg.gt.0)then
109 call fillit(arrayin,irun,jrun,krun,levflg,birun,bjrun,
110 . bihere,bjhere,array)
111 do j = 1,sNy
112 do i = 1,sNx
113 qdiag(i,j,ipointer+levflg-1,bihere,bjhere) =
114 . qdiag(i,j,ipointer+levflg-1,bihere,bjhere) +
115 . array(i,j)
116 enddo
117 enddo
118 else
119 level = -1 * levflg
120 call fillit(arrayin,irun,jrun,1,1,birun,bjrun,
121 . bihere,bjhere,array)
122 do j = 1,sNy
123 do i = 1,sNx
124 qdiag(i,j,ipointer+level-1,bihere,bjhere) =
125 . qdiag(i,j,ipointer+level-1,bihere,bjhere) +
126 . array(i,j)
127 enddo
128 enddo
129 endif
130
131 enddo
132 enddo
133
134 elseif(bibjflg.eq.1) then
135 irun = sNx+2*Olx
136 jrun = sNy+2*Oly
137 krun = abs(nlevs)
138 birun = nSx
139 bjrun = nSy
140
141 if(levflg.eq.0)then
142 do levhere = 1,krun
143 level = levhere
144 IF (nlevs.LT.0) level=1-nlevs-levhere
145 call fillit(arrayin,irun,jrun,krun,levhere,birun,bjrun,
146 . bi,bj,array)
147 do j = 1,sNy
148 do i = 1,sNx
149 qdiag(i,j,ipointer+level-1,bi,bj) =
150 . qdiag(i,j,ipointer+level-1,bi,bj) +
151 . array(i,j)
152 enddo
153 enddo
154 enddo
155 elseif(levflg.gt.0)then
156 call fillit(arrayin,irun,jrun,krun,levflg,birun,bjrun,
157 . bi,bj,array)
158 do j = 1,sNy
159 do i = 1,sNx
160 qdiag(i,j,ipointer+levflg-1,bi,bj) =
161 . qdiag(i,j,ipointer+levflg-1,bi,bj) + array(i,j)
162 enddo
163 enddo
164 else
165 level = -1 * levflg
166 call fillit(arrayin,irun,jrun,1,1,birun,bjrun,
167 . bi,bj,array)
168 do j = 1,sNy
169 do i = 1,sNx
170 qdiag(i,j,ipointer+level-1,bi,bj) =
171 . qdiag(i,j,ipointer+level-1,bi,bj) + array(i,j)
172 enddo
173 enddo
174 endif
175
176 elseif(bibjflg.eq.2) then
177 irun = sNx
178 jrun = sNy
179 krun = abs(nlevs)
180 birun = 1
181 bjrun = 1
182
183 if(levflg.eq.0)then
184 do levhere = 1,krun
185 level = levhere
186 IF (nlevs.LT.0) level=1-nlevs-levhere
187 call fillit(arrayin,irun,jrun,krun,levhere,birun,bjrun,
188 . 1,1,arrayloc)
189 do j = 1,sNy
190 do i = 1,sNx
191 qdiag(i,j,ipointer+level-1,bi,bj) =
192 . qdiag(i,j,ipointer+level-1,bi,bj) + arrayloc(i,j)
193 enddo
194 enddo
195 enddo
196 elseif(levflg.gt.0)then
197 call fillit(arrayin,irun,jrun,krun,levflg,birun,bjrun,
198 . 1,1,arrayloc)
199 do j = 1,sNy
200 do i = 1,sNx
201 qdiag(i,j,ipointer+levflg-1,bi,bj) =
202 . qdiag(i,j,ipointer+levflg-1,bi,bj) + arrayloc(i,j)
203 enddo
204 enddo
205 else
206 level = -1 * levflg
207 call fillit(arrayin,irun,jrun,1,1,birun,bjrun,
208 . 1,1,arrayloc)
209 do j = 1,sNy
210 do i = 1,sNx
211 qdiag(i,j,ipointer+level-1,bi,bj) =
212 . qdiag(i,j,ipointer+level-1,bi,bj) + arrayloc(i,j)
213 enddo
214 enddo
215 endif
216
217 elseif(bibjflg.eq.3) then
218 irun = sNx+2*Olx
219 jrun = sNy+2*Oly
220 krun = abs(nlevs)
221 birun = 1
222 bjrun = 1
223
224 if(levflg.eq.0)then
225 do levhere = 1,krun
226 level = levhere
227 IF (nlevs.LT.0) level=1-nlevs-levhere
228 call fillit(arrayin,irun,jrun,krun,levhere,birun,bjrun,
229 . 1,1,array)
230 do j = 1,sNy
231 do i = 1,sNx
232 qdiag(i,j,ipointer+level-1,bi,bj) =
233 . qdiag(i,j,ipointer+level-1,bi,bj) + array(i,j)
234 enddo
235 enddo
236 enddo
237 elseif(levflg.gt.0)then
238 call fillit(arrayin,irun,jrun,krun,levflg,birun,bjrun,
239 . 1,1,array)
240 do j = 1,sNy
241 do i = 1,sNx
242 qdiag(i,j,ipointer+levflg-1,bi,bj) =
243 . qdiag(i,j,ipointer+levflg-1,bi,bj) + array(i,j)
244 enddo
245 enddo
246 else
247 level = -1 * levflg
248 call fillit(arrayin,irun,jrun,1,1,birun,bjrun,
249 . 1,1,array)
250 do j = 1,sNy
251 do i = 1,sNx
252 qdiag(i,j,ipointer+level-1,bi,bj) =
253 . qdiag(i,j,ipointer+level-1,bi,bj) + array(i,j)
254 enddo
255 enddo
256 endif
257
258 endif
259
260 ELSE
261
262 C if (myThid.eq.1) write(6,1000) chardiag
263
264 ENDIF
265
266 1000 format(' ',' Warning: Trying to write to diagnostic ',a8,
267 . ' But it is not a valid (or active) name ')
268 return
269 end
270
271 subroutine fillit(arrayin,irun,jrun,krun,klevf,birun,bjrun,
272 . bi,bj,arrayout)
273
274 implicit none
275 #include "EEPARAMS.h"
276
277 integer irun, jrun, krun, klevf, birun, bjrun, bi, bj
278 _RL arrayin(irun,jrun,krun,birun,bjrun)
279 _RL arrayout(irun,jrun)
280
281 integer i, j
282
283 do j = 1,jrun
284 do i = 1,irun
285 arrayout(i,j) = arrayin(i,j,klevf,bi,bj)
286 enddo
287 enddo
288
289 return
290 end

  ViewVC Help
Powered by ViewVC 1.1.22