/[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.10 - (show annotations) (download)
Mon Jun 21 15:42:38 2004 UTC (19 years, 11 months ago) by molod
Branch: MAIN
Changes since 1.9: +3 -2 lines
Missed something from last check-in

1 C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/fill_diagnostics.F,v 1.9 2004/06/21 15:41:51 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 bi ......... X-direction process(or) number - used for bibjflg=1,2
25 C bj ......... Y-direction process(or) number - used for bibjflg=1,2
26 C arrayin .... Field to increment diagnostics array
27 C NOTE: User beware! If a local (1 tile only) array
28 C is sent here, bibjflg MUST NOT be set to 0
29 C or there will be out of bounds problems!
30 C***********************************************************************
31 implicit none
32 #include "EEPARAMS.h"
33 #include "CPP_OPTIONS.h"
34 #include "SIZE.h"
35 #include "diagnostics_SIZE.h"
36 #include "diagnostics.h"
37
38 integer myThid,levflg,nlevs,bibjflg,bi,bj
39 character *8 chardiag
40 _RL arrayin(*)
41
42 c Local variables
43 c ===============
44 integer i, j, n, ndiagnum, bihere, bjhere, levhere, ipointer
45 _RL array(1-OLx:sNx+Olx,1-Oly:sNy+Oly,nlevs,Nsx,Nsy)
46 _RL arrayloc(sNx,sNy,nlevs)
47 integer irun,jrun,krun,birun,bjrun
48
49 C Run through list of active diagnostics to make sure
50 C we are trying to fill a valid diagnostic
51
52 ndiagnum = 0
53 ipointer = 0
54 do n = 1,ndiagt
55 if(chardiag.eq.cdiag(n)) then
56 ndiagnum = n
57 ipointer = idiag(n)
58 endif
59 enddo
60
61 C If-sequence to see if we are a valid and an active diagnostic
62
63 IF ( ndiagnum.ne.0 .and. ipointer.ne.0 ) THEN
64
65 C Increment the counter for the diagnostic (if we are at bi=bj=1)
66 if ((bi.eq.1).and.(bj.eq.1).and.(levflg.le.1))
67 . ndiag(ndiagnum) = ndiag(ndiagnum) + 1
68
69 C Check to see if we need to do a bi-bj loop here
70
71 if(bibjflg.eq.0) then
72 irun = sNx+2*Olx
73 jrun = sNy+2*Oly
74 krun = nlevs
75 birun = myBxHi(myThid)-myBxLo(myThid)+1
76 bjrun = myByHi(myThid)-myByLo(myThid)+1
77
78 do bjhere=myByLo(myThid), myByHi(myThid)
79 do bihere=myBxLo(myThid), myBxHi(myThid)
80
81 if(levflg.eq.0)then
82 do levhere = 1,nlevs
83 call fillit(arrayin,irun,jrun,krun,levhere,levhere,birun,bjrun,
84 . bihere,bjhere,array)
85 do j = 1,sNy
86 do i = 1,sNx
87 qdiag(i,j,ipointer+levhere-1,bihere,bjhere) =
88 . qdiag(i,j,ipointer+levhere-1,bihere,bjhere) +
89 . array(i,j,levhere,bihere,bjhere)
90 enddo
91 enddo
92 enddo
93 else
94 call fillit(arrayin,irun,jrun,krun,levflg,1,birun,bjrun,
95 . bihere,bjhere,array)
96 do j = 1,sNy
97 do i = 1,sNx
98 qdiag(i,j,ipointer+levflg-1,bihere,bjhere) =
99 . qdiag(i,j,ipointer+levflg-1,bihere,bjhere) +
100 . array(i,j,nlevs,bihere,bjhere)
101 enddo
102 enddo
103 endif
104
105 enddo
106 enddo
107
108 elseif(bibjflg.eq.1) then
109 irun = sNx+2*Olx
110 jrun = sNy+2*Oly
111 krun = nlevs
112 birun = myBxHi(myThid)-myBxLo(myThid)+1
113 bjrun = myByHi(myThid)-myByLo(myThid)+1
114
115 if(levflg.eq.0)then
116 do levhere = 1,nlevs
117 call fillit(arrayin,irun,jrun,krun,levhere,levhere,birun,bjrun,
118 . bi,bj,array)
119 do j = 1,sNy
120 do i = 1,sNx
121 qdiag(i,j,ipointer+levhere-1,bi,bj) =
122 . qdiag(i,j,ipointer+levhere-1,bi,bj) + array(i,j,levhere,bi,bj)
123 enddo
124 enddo
125 enddo
126 else
127 call fillit(arrayin,irun,jrun,krun,levflg,1,birun,bjrun,
128 . bi,bj,array)
129 do j = 1,sNy
130 do i = 1,sNx
131 qdiag(i,j,ipointer+levflg-1,bi,bj) =
132 . qdiag(i,j,ipointer+levflg-1,bi,bj) + array(i,j,nlevs,bi,bj)
133 enddo
134 enddo
135 endif
136
137 elseif(bibjflg.eq.2) then
138 irun = sNx
139 jrun = sNy
140 krun = nlevs
141 birun = 1
142 bjrun = 1
143
144 if(levflg.eq.0)then
145 do levhere = 1,nlevs
146 call fillit(arrayin,irun,jrun,krun,levhere,levhere,birun,bjrun,
147 . 1,1,arrayloc)
148 do j = 1,sNy
149 do i = 1,sNx
150 qdiag(i,j,ipointer+levhere-1,bi,bj) =
151 . qdiag(i,j,ipointer+levhere-1,bi,bj) + arrayloc(i,j,levhere)
152 enddo
153 enddo
154 enddo
155 else
156 call fillit(arrayin,irun,jrun,krun,levflg,1,birun,bjrun,
157 . 1,1,arrayloc)
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) + arrayloc(i,j,nlevs)
162 enddo
163 enddo
164 endif
165
166 endif
167
168 ELSE
169
170 C if (myThid.eq.1) write(6,1000) chardiag
171
172 ENDIF
173
174 1000 format(' ',' Warning: Trying to write to diagnostic ',a8,
175 . ' But it is not a valid (or active) name ')
176 return
177 end
178
179 subroutine fillit(arrayin,irun,jrun,krun,klevf,klevt,birun,bjrun,
180 . bi,bj,arrayout)
181
182 implicit none
183 #include "EEPARAMS.h"
184
185 integer irun, jrun, krun, klevf, klevt, birun, bjrun, bi, bj
186 _RL arrayin(irun,jrun,krun,birun,bjrun)
187 _RL arrayout(irun,jrun,krun,birun,bjrun)
188
189 integer i, j
190
191 do j = 1,jrun
192 do i = 1,irun
193 arrayout(i,j,klevt,bi,bj) = arrayin(i,j,klevf,bi,bj)
194 enddo
195 enddo
196
197 return
198 end

  ViewVC Help
Powered by ViewVC 1.1.22