/[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.6 - (show annotations) (download)
Tue Mar 30 22:18:20 2004 UTC (20 years, 2 months ago) by molod
Branch: MAIN
Changes since 1.5: +2 -2 lines
Correct argument list description in prologue

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

  ViewVC Help
Powered by ViewVC 1.1.22