1 |
C $Header: /u/gcmpack/MITgcm/pkg/grdchk/grdchk_loc.F,v 1.8 2003/11/04 20:47:42 heimbach Exp $ |
2 |
|
3 |
#include "CTRL_CPPOPTIONS.h" |
4 |
|
5 |
subroutine grdchk_get_position( mythid ) |
6 |
|
7 |
c ================================================================== |
8 |
c SUBROUTINE grdchk_loc |
9 |
c ================================================================== |
10 |
c |
11 |
c o Get the location of a given component of the control vector for |
12 |
c the current process. |
13 |
c |
14 |
c started: Christian Eckert eckert@mit.edu 04-Apr-2000 |
15 |
c continued: heimbach@mit.edu: 13-Jun-2001 |
16 |
c |
17 |
c ================================================================== |
18 |
c SUBROUTINE grdchk_loc |
19 |
c ================================================================== |
20 |
|
21 |
implicit none |
22 |
|
23 |
c == global variables == |
24 |
|
25 |
#include "EEPARAMS.h" |
26 |
#include "SIZE.h" |
27 |
#include "GRID.h" |
28 |
#include "ctrl.h" |
29 |
#include "grdchk.h" |
30 |
|
31 |
c == routine arguments == |
32 |
|
33 |
integer icvrec |
34 |
integer jtile |
35 |
integer itile |
36 |
integer layer |
37 |
integer obcspos |
38 |
integer itilepos |
39 |
integer jtilepos |
40 |
integer itest |
41 |
integer ierr |
42 |
integer mythid |
43 |
|
44 |
#ifdef ALLOW_GRDCHK |
45 |
c == local variables == |
46 |
|
47 |
integer iG,jG |
48 |
integer bi,bj |
49 |
integer i,j,k |
50 |
integer iobcs |
51 |
integer biwrk,bjwrk |
52 |
integer iwrk, jwrk, kwrk |
53 |
integer iobcswrk |
54 |
integer irec, irecwrk |
55 |
integer itlo,ithi |
56 |
integer jtlo,jthi |
57 |
integer jmin,jmax |
58 |
integer imin,imax |
59 |
integer icomptest |
60 |
integer nobcsmax |
61 |
integer pastit |
62 |
|
63 |
_RL wetlocal |
64 |
|
65 |
c == end of interface == |
66 |
|
67 |
jtlo = 1 |
68 |
jthi = nsy |
69 |
itlo = 1 |
70 |
ithi = nsx |
71 |
jmin = 1 |
72 |
jmax = sny |
73 |
imin = 1 |
74 |
imax = snx |
75 |
|
76 |
_BEGIN_MASTER( mythid ) |
77 |
|
78 |
c-- determine proc. number from following assumptions |
79 |
|
80 |
iG = INT(iGloPos/sNx) + 1 |
81 |
jG = INT(jGloPos/sNy) + 1 |
82 |
grdchkwhichproc = iG-1 + (jG-1)*nPx |
83 |
|
84 |
itilepos = iGloPos - (iG-1)*sNx |
85 |
jtilepos = jGloPos - (jG-1)*sNy |
86 |
layer = kGloPos |
87 |
obcspos = obcsglo |
88 |
icvrec = recglo |
89 |
|
90 |
if ( myProcId .EQ. grdchkwhichproc ) then |
91 |
|
92 |
c initialise parameters |
93 |
ierr = -5 |
94 |
pastit = -1 |
95 |
wetlocal = 0 |
96 |
|
97 |
itest = 0 |
98 |
icomptest = 0 |
99 |
irecwrk = 1 |
100 |
bjwrk = 1 |
101 |
biwrk = 1 |
102 |
kwrk = 1 |
103 |
iobcswrk = 1 |
104 |
jwrk = 1 |
105 |
iwrk = 1 |
106 |
|
107 |
c-- set max loop index for obcs multiplicities |
108 |
if ( ncvargrd(grdchkvarindex) .eq. 'm' ) then |
109 |
nobcsmax = nobcs |
110 |
else |
111 |
nobcsmax = 1 |
112 |
endif |
113 |
|
114 |
c-- Start to loop over records. |
115 |
do irec = irecwrk, ncvarrecs(grdchkvarindex) |
116 |
iobcs = MOD((irec-1),nobcsmax) + 1 |
117 |
do bj = bjwrk, jthi |
118 |
do bi = biwrk, ithi |
119 |
do k = kwrk, ncvarnrmax(grdchkvarindex) |
120 |
|
121 |
if ( ierr .ne. 0 ) then |
122 |
icvrec = irec |
123 |
itile = bi |
124 |
jtile = bj |
125 |
|
126 |
do j = jwrk, ncvarymax(grdchkvarindex) |
127 |
do i = iwrk, ncvarxmax(grdchkvarindex) |
128 |
if (ierr .ne. 0) then |
129 |
if ( ncvargrd(grdchkvarindex) .eq. 'c' ) then |
130 |
if ( maskC(i,j,k,bi,bj) .gt. 0.) then |
131 |
icomptest = icomptest + 1 |
132 |
endif |
133 |
wetlocal = maskC(i,j,k,bi,bj) |
134 |
else if ( ncvargrd(grdchkvarindex) .eq. 's' ) then |
135 |
if ( _maskS(i,j,k,bi,bj) .gt. 0.) then |
136 |
icomptest = icomptest + 1 |
137 |
endif |
138 |
wetlocal = _maskS(i,j,k,bi,bj) |
139 |
else if ( ncvargrd(grdchkvarindex) .eq. 'w' ) then |
140 |
if ( _maskW(i,j,k,bi,bj) .gt. 0.) then |
141 |
icomptest = icomptest + 1 |
142 |
endif |
143 |
wetlocal = _maskW(i,j,k,bi,bj) |
144 |
else if ( ncvargrd(grdchkvarindex) .eq. 'm' ) then |
145 |
if ( grdchkvarindex .EQ. 11 ) then |
146 |
#ifdef ALLOW_OBCSN_CONTROL |
147 |
if (grdchk_maskxz(i,k,bi,bj,iobcs) .gt. 0.) then |
148 |
icomptest = icomptest + 1 |
149 |
endif |
150 |
wetlocal = grdchk_maskxz(i,k,bi,bj,iobcs) |
151 |
#endif |
152 |
else if ( grdchkvarindex .EQ. 12 ) then |
153 |
#ifdef ALLOW_OBCSS_CONTROL |
154 |
if (grdchk_maskxz(i,k,bi,bj,iobcs) .gt. 0.) then |
155 |
icomptest = icomptest + 1 |
156 |
endif |
157 |
wetlocal = grdchk_maskxz(i,k,bi,bj,iobcs) |
158 |
#endif |
159 |
else if ( grdchkvarindex .EQ. 13 ) then |
160 |
#ifdef ALLOW_OBCSW_CONTROL |
161 |
if (grdchk_maskyz(j,k,bi,bj,iobcs) .gt. 0.) then |
162 |
icomptest = icomptest + 1 |
163 |
endif |
164 |
wetlocal = grdchk_maskyz(j,k,bi,bj,iobcs) |
165 |
#endif |
166 |
else if ( grdchkvarindex .EQ. 14 ) then |
167 |
#ifdef ALLOW_OBCSE_CONTROL |
168 |
if (grdchk_maskyz(j,k,bi,bj,iobcs) .gt. 0.) then |
169 |
icomptest = icomptest + 1 |
170 |
endif |
171 |
wetlocal = grdchk_maskyz(j,k,bi,bj,iobcs) |
172 |
#endif |
173 |
endif |
174 |
endif |
175 |
c |
176 |
if ( i .EQ. itilepos .AND. |
177 |
& j .EQ. jtilepos .AND. |
178 |
& k .EQ. layer .AND. |
179 |
& iobcs .EQ. obcspos .AND. |
180 |
& irec .EQ. icvrec ) then |
181 |
pastit = 0 |
182 |
if ( wetlocal .NE.0 ) then |
183 |
nbeg = icomptest |
184 |
nend = nbeg + nend |
185 |
ierr = 0 |
186 |
print '(a,6I5)', |
187 |
& ' grad-res exact position met: ' |
188 |
print '(a,7I5)', |
189 |
& ' grad-res ', grdchkwhichproc, |
190 |
& nbeg, itilepos, jtilepos, layer, |
191 |
& iG, jG |
192 |
endif |
193 |
else if ( pastit .EQ. 0 .AND. |
194 |
& wetlocal .NE.0 ) then |
195 |
nbeg = icomptest |
196 |
nend = nbeg + nend |
197 |
ierr = 0 |
198 |
print '(a,6I5)', |
199 |
& ' grad-res closest next position: ' |
200 |
print '(a,7I5)', |
201 |
& ' grad-res ', grdchkwhichproc, |
202 |
& nbeg, itilepos, jtilepos, layer, |
203 |
& iG, jG |
204 |
endif |
205 |
c |
206 |
endif |
207 |
enddo |
208 |
iwrk = 1 |
209 |
enddo |
210 |
jwrk = 1 |
211 |
else if (ierr .NE. 0) then |
212 |
itest = itest + nwettile(bi,bj,k,iobcs) |
213 |
iwrk = 1 |
214 |
jwrk = 1 |
215 |
endif |
216 |
c-- End of loop over k |
217 |
enddo |
218 |
kwrk = 1 |
219 |
c-- End of loop over bi |
220 |
enddo |
221 |
biwrk = 1 |
222 |
c-- End of loop over bj |
223 |
enddo |
224 |
bjwrk = 1 |
225 |
c-- End of loop over iobcs |
226 |
cph enddo |
227 |
cph iobcswrk = 1 |
228 |
c-- End of loop over irec records. |
229 |
enddo |
230 |
|
231 |
c-- End of if myProcId statement |
232 |
endif |
233 |
|
234 |
_END_MASTER( mythid ) |
235 |
|
236 |
_BARRIER |
237 |
|
238 |
#endif /* ALLOW_GRDCHK */ |
239 |
|
240 |
end |
241 |
|