/[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.11 - (show annotations) (download)
Fri Jun 25 19:23:02 2004 UTC (19 years, 11 months ago) by molod
Branch: MAIN
CVS Tags: checkpoint53f_post
Changes since 1.10: +36 -3 lines
Add another instance to the fill_diagnostics choices for shadowed local arrays

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

  ViewVC Help
Powered by ViewVC 1.1.22