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

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

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


Revision 1.5 - (show annotations) (download)
Thu Feb 26 22:20:36 2004 UTC (20 years, 2 months ago) by molod
Branch: MAIN
Changes since 1.4: +21 -0 lines
Fix implementation

1 subroutine getdiag (myThid,lev,ipoint,undef,qtmp)
2 C***********************************************************************
3 C PURPOSE
4 C Retrieve averaged model diagnostic
5 C INPUT:
6 C lev ..... Diagnostic LEVEL
7 C ipoint ..... DIAGNOSTIC NUMBER FROM MENU
8 C undef ..... UNDEFINED VALUE
9 C bi ..... X-direction process(or) number
10 C bj ..... Y-direction process(or) number
11 C
12 C OUTPUT:
13 C qtmp ..... AVERAGED DIAGNOSTIC QUANTITY
14 C
15 C***********************************************************************
16 implicit none
17
18 #include "EEPARAMS.h"
19 #include "CPP_OPTIONS.h"
20 #include "SIZE.h"
21
22 #ifdef ALLOW_FIZHI
23 #include "fizhi_SIZE.h"
24 #else
25 integer Nrphys
26 parameter (Nrphys=1)
27 #endif
28
29 #include "diagnostics_SIZE.h"
30 #include "diagnostics.h"
31
32 integer myThid,lev,ipoint
33 _RL undef
34 _RL qtmp(1-OLx:sNx+Olx,1-Oly:sNy+Oly,Nr+Nrphys,Nsx,Nsy)
35
36 _RL factor
37 integer i,j,ipnt,klev
38 integer bi,bj
39
40 if (ipoint.lt.1) go to 999
41
42 klev = kdiag(ipoint)
43 if(klev.ge.lev) then
44 ipnt = idiag(ipoint) + lev - 1
45 factor = 1.0
46 if(ndiag(ipoint).ne.0) factor = 1.0/ndiag(ipoint)
47
48 do bj=myByLo(myThid), myByHi(myThid)
49 do bi=myBxLo(myThid), myBxHi(myThid)
50
51 do j = 1,sNy
52 do i = 1,sNx
53 if( qdiag(i,j,ipnt,bi,bj).ne.undef ) then
54 qtmp(i,j,lev,bi,bj) = qdiag(i,j,ipnt,bi,bj)*factor
55 else
56 qtmp(i,j,lev,bi,bj) = undef
57 endif
58 enddo
59 enddo
60
61 enddo
62 enddo
63
64 endif
65
66 999 return
67 end
68
69 subroutine getdiag2 (myThid,lev,ipoint,undef,qtmp)
70 C***********************************************************************
71 C PURPOSE
72 C Retrieve averaged model diagnostic
73 C INPUT:
74 C lev ..... Diagnostic LEVEL
75 C ipoint ..... DIAGNOSTIC NUMBER FROM MENU
76 C undef ..... UNDEFINED VALUE
77 C
78 C OUTPUT:
79 C qtmp ..... AVERAGED DIAGNOSTIC QUANTITY
80 C
81 C***********************************************************************
82 implicit none
83
84 #include "EEPARAMS.h"
85 #include "CPP_OPTIONS.h"
86 #include "SIZE.h"
87
88 #ifdef ALLOW_FIZHI
89 #include "fizhi_SIZE.h"
90 #else
91 integer Nrphys
92 parameter (Nrphys=1)
93 #endif
94
95 #include "diagnostics_SIZE.h"
96 #include "diagnostics.h"
97
98 integer myThid,lev,ipoint
99 _RL undef
100 _RL qtmp(1-OLx:sNx+Olx,1-Oly:sNy+Oly,Nr+Nrphys,Nsx,Nsy)
101
102 integer i,j,ipnt,klev
103 integer bi,bj
104
105 if (ipoint.lt.1) go to 999
106
107 klev = kdiag(ipoint)
108 if(klev.ge.lev) then
109 ipnt = idiag(ipoint) + lev - 1
110
111 do bj=myByLo(myThid), myByHi(myThid)
112 do bi=myBxLo(myThid), myBxHi(myThid)
113
114 do j = 1,sNy
115 do i = 1,sNx
116 if( qdiag(i,j,ipnt,bi,bj).ne.undef ) then
117 qtmp(i,j,lev,bi,bj) = qdiag(i,j,ipnt,bi,bj)
118 else
119 qtmp(i,j,lev,bi,bj) = undef
120 endif
121 enddo
122 enddo
123
124 enddo
125 enddo
126
127 endif
128
129 999 return
130 end
131 subroutine clrindx (myThid,listnum)
132 C***********************************************************************
133 C
134 C PURPOSE
135 C DRIVER TO CLEAR DIAGNOSTICS SPECIFIED IN DIAGNOSTIC INDEX LIST
136 C
137 C ARGUMENT DESCRIPTION
138 C listnum .... diagnostics list number
139 C
140 C***********************************************************************
141
142 implicit none
143 #include "EEPARAMS.h"
144 #include "CPP_OPTIONS.h"
145 #include "SIZE.h"
146
147 #ifdef ALLOW_FIZHI
148 #include "fizhi_SIZE.h"
149 #else
150 integer Nrphys
151 parameter (Nrphys=1)
152 #endif
153
154 #include "diagnostics_SIZE.h"
155 #include "diagnostics.h"
156
157 integer myThid, listnum
158
159 integer m, n
160 character*8 parms1
161 character*1 parse1(8)
162 character*3 mate_index
163 integer mate
164
165 equivalence ( parms1 , parse1(1) )
166 equivalence ( mate_index , parse1(6) )
167
168 do n=1,nfields(listnum)
169 do m=1,ndiagt
170 if( flds(n,listnum).eq.cdiag(m) .and. idiag(m).ne.0 ) then
171 call clrdiag (myThid,m)
172
173 c Check for Counter Diagnostic
174 c ----------------------------
175 parms1 = gdiag(m)
176 if( parse1(5).eq.'C' ) then
177 read (mate_index,100) mate
178 call clrdiag (myThid,mate)
179 endif
180 endif
181 enddo
182 enddo
183
184 100 format(i3)
185 RETURN
186 END
187
188
189 subroutine clrdiag (myThid,index)
190 C***********************************************************************
191 C PURPOSE
192 C ZERO OUT MODEL DIAGNOSTIC ARRAY ELEMENTS
193 C***********************************************************************
194
195 implicit none
196 #include "EEPARAMS.h"
197 #include "CPP_OPTIONS.h"
198 #include "SIZE.h"
199
200 #ifdef ALLOW_FIZHI
201 #include "fizhi_SIZE.h"
202 #else
203 integer Nrphys
204 parameter (Nrphys=1)
205 #endif
206
207 #include "diagnostics_SIZE.h"
208 #include "diagnostics.h"
209
210 integer myThid, index
211
212 integer bi,bj
213 integer i,j,k
214
215 C **********************************************************************
216 C **** SET DIAGNOSTIC AND COUNTER TO ZERO ****
217 C **********************************************************************
218
219 do bj=myByLo(myThid), myByHi(myThid)
220 do bi=myBxLo(myThid), myBxHi(myThid)
221 do k = 1,kdiag(index)
222 do j = 1,sNy
223 do i = 1,sNx
224 qdiag(i,j,idiag(index)+k-1,bi,bj) = 0.0
225 enddo
226 enddo
227 enddo
228 enddo
229 enddo
230
231 ndiag(index) = 0
232
233 return
234 end
235
236 subroutine setdiag (myThid,num,ndiagmx)
237 C***********************************************************************
238 C
239 C PURPOSE
240 C SET POINTER LOCATIONS, NAMES, LEVELS and TITLES FOR DIAGNOSTIC NUM
241 C
242 C***********************************************************************
243
244 implicit none
245 #include "CPP_OPTIONS.h"
246 #include "SIZE.h"
247
248 #ifdef ALLOW_FIZHI
249 #include "fizhi_SIZE.h"
250 #else
251 integer Nrphys
252 parameter (Nrphys=1)
253 #endif
254
255 #include "diagnostics_SIZE.h"
256 #include "diagnostics.h"
257
258 integer num,myThid,ndiagmx
259 integer ipointer
260
261 DATA IPOINTER / 1 /
262
263 character*8 parms1
264 character*1 parse1(8)
265 character*3 mate_index
266 integer mate
267
268 equivalence ( parms1 , parse1(1) )
269 equivalence ( mate_index , parse1(6) )
270
271 C **********************************************************************
272 C **** SET POINTERS FOR DIAGNOSTIC NUM ****
273 C **********************************************************************
274
275 parms1 = gdiag(num)
276
277 IF( IDIAG(NUM).EQ.0 ) THEN
278 if(ndiagmx+kdiag(num).gt.numdiags) then
279 write(6,4000)num,cdiag(num)
280 else
281 IDIAG(NUM) = IPOINTER
282 IPOINTER = IPOINTER + KDIAG(NUM)
283 ndiagmx = ndiagmx + KDIAG(NUM)
284 if(myThid.eq.1) WRITE(6,2000)KDIAG(NUM),NUM,CDIAG(NUM),ndiagmx
285 endif
286 ELSE
287 if(myThid.eq.1) WRITE(6,3000) NUM, CDIAG(NUM)
288 ENDIF
289
290 c Check for Counter Diagnostic
291 c ----------------------------
292 if( parse1(5).eq.'C') then
293 read (mate_index,100) mate
294
295 IF( IDIAG(mate).EQ.0 ) THEN
296 if(ndiagmx+kdiag(num).gt.numdiags) then
297 write(6,5000)num,cdiag(num)
298 else
299 IDIAG(mate) = IPOINTER
300 IPOINTER = IPOINTER + KDIAG(mate)
301 ndiagmx = ndiagmx + KDIAG(mate)
302 if(myThid.eq.1)WRITE(6,2000)KDIAG(mate),mate,CDIAG(mate),ndiagmx
303 endif
304 ELSE
305 if(myThid.eq.1) WRITE(6,3000) mate, CDIAG(mate)
306 ENDIF
307 endif
308
309 RETURN
310
311 100 format(i3)
312 2000 FORMAT(1X,'Allocating ',I2,' Level(s) for Diagnostic # ',I3,
313 . ' (',A8,'), Total Number of Diagnostics: ',I5)
314 3000 FORMAT(1X,'Diagnostic # ',I3,' (',A8,') has already been set')
315 4000 FORMAT(1X,'Unable to allocate space for Diagnostic # ',I3,
316 . ' (',A8,')')
317 5000 FORMAT(1X,'Unable to allocate space for Counter Diagnostic # ',
318 . I3,' (',A8,')',' WARNING - Diag will not accumulate properly')
319 END

  ViewVC Help
Powered by ViewVC 1.1.22