1 |
heimbach |
1.3 |
C $Header: /u/gcmpack/MITgcm/pkg/grdchk/grdchk_loc.F,v 1.2.4.1 2002/05/30 22:12:32 heimbach Exp $ |
2 |
heimbach |
1.2 |
|
3 |
|
|
#include "CTRL_CPPOPTIONS.h" |
4 |
|
|
|
5 |
|
|
|
6 |
|
|
subroutine grdchk_loc( |
7 |
|
|
I icomp, |
8 |
|
|
I ichknum, |
9 |
|
|
O icvrec, |
10 |
|
|
O itile, |
11 |
|
|
O jtile, |
12 |
|
|
O layer, |
13 |
|
|
O itilepos, |
14 |
|
|
O jtilepos, |
15 |
|
|
O itest, |
16 |
|
|
O ierr, |
17 |
|
|
I mythid |
18 |
|
|
& ) |
19 |
|
|
|
20 |
|
|
c ================================================================== |
21 |
|
|
c SUBROUTINE grdchk_loc |
22 |
|
|
c ================================================================== |
23 |
|
|
c |
24 |
|
|
c o Get the location of a given component of the control vector for |
25 |
|
|
c the current process. |
26 |
|
|
c |
27 |
|
|
c started: Christian Eckert eckert@mit.edu 04-Apr-2000 |
28 |
|
|
c continued: heimbach@mit.edu: 13-Jun-2001 |
29 |
|
|
c |
30 |
|
|
c ================================================================== |
31 |
|
|
c SUBROUTINE grdchk_loc |
32 |
|
|
c ================================================================== |
33 |
|
|
|
34 |
|
|
implicit none |
35 |
|
|
|
36 |
|
|
c == global variables == |
37 |
|
|
|
38 |
|
|
#include "EEPARAMS.h" |
39 |
|
|
#include "SIZE.h" |
40 |
|
|
#include "GRID.h" |
41 |
|
|
#include "ctrl.h" |
42 |
|
|
#include "grdchk.h" |
43 |
|
|
|
44 |
|
|
c == routine arguments == |
45 |
|
|
|
46 |
|
|
integer icomp |
47 |
|
|
integer ichknum |
48 |
|
|
integer icvrec |
49 |
|
|
integer jtile |
50 |
|
|
integer itile |
51 |
|
|
integer layer |
52 |
|
|
integer itilepos |
53 |
|
|
integer jtilepos |
54 |
|
|
integer itest |
55 |
|
|
integer ierr |
56 |
|
|
integer mythid |
57 |
|
|
|
58 |
|
|
#ifdef ALLOW_GRADIENT_CHECK |
59 |
|
|
c == local variables == |
60 |
|
|
|
61 |
|
|
integer bi,bj |
62 |
|
|
integer i,j,k |
63 |
|
|
integer biwrk,bjwrk |
64 |
|
|
integer iwrk, jwrk, kwrk |
65 |
|
|
integer irec, irecwrk |
66 |
|
|
integer itlo,ithi |
67 |
|
|
integer jtlo,jthi |
68 |
|
|
integer jmin,jmax |
69 |
|
|
integer imin,imax |
70 |
|
|
integer icomptest |
71 |
|
|
|
72 |
|
|
c == end of interface == |
73 |
|
|
|
74 |
|
|
jtlo = 1 |
75 |
|
|
jthi = nsy |
76 |
|
|
itlo = 1 |
77 |
|
|
ithi = nsx |
78 |
|
|
jmin = 1 |
79 |
|
|
jmax = sny |
80 |
|
|
imin = 1 |
81 |
|
|
imax = snx |
82 |
|
|
|
83 |
|
|
_BEGIN_MASTER( mythid ) |
84 |
|
|
|
85 |
|
|
c initialise parameters |
86 |
|
|
ierr = -5 |
87 |
|
|
|
88 |
|
|
if ( icomp .gt. 0 ) then |
89 |
|
|
if ( icomp .le. ncvarcomp ) then |
90 |
|
|
c-- A valid component of the control variable has been selected. |
91 |
|
|
if ( ichknum .EQ. 1 ) then |
92 |
|
|
itest = 0 |
93 |
|
|
icomptest = 0 |
94 |
|
|
irecwrk = 1 |
95 |
|
|
bjwrk = 1 |
96 |
|
|
biwrk = 1 |
97 |
|
|
kwrk = 1 |
98 |
|
|
jwrk = 1 |
99 |
|
|
iwrk = 1 |
100 |
|
|
else |
101 |
|
|
itest = itestmem(ichknum-1) |
102 |
|
|
icomptest = icompmem(ichknum-1) |
103 |
|
|
irecwrk = irecmem(ichknum-1) |
104 |
|
|
bjwrk = bjmem (ichknum-1) |
105 |
|
|
biwrk = bimem (ichknum-1) |
106 |
|
|
kwrk = klocmem(ichknum-1) |
107 |
|
|
jwrk = jlocmem(ichknum-1) |
108 |
|
|
iwrk = ilocmem(ichknum-1) |
109 |
|
|
iwrk = iwrk + 1 |
110 |
|
|
end if |
111 |
|
|
|
112 |
|
|
c-- Start to loop over records. |
113 |
|
|
do irec = irecwrk, ncvarrecs(grdchkvarindex) |
114 |
|
|
do bj = bjwrk, jthi |
115 |
|
|
do bi = biwrk, ithi |
116 |
|
|
do k = kwrk, ncvarnrmax(grdchkvarindex) |
117 |
|
|
|
118 |
|
|
if ( (ierr .ne. 0) .and. |
119 |
|
|
& (icomp .gt. itest) .and. |
120 |
|
|
& (icomp .le. itest + nwettile(bi,bj,k))) then |
121 |
|
|
icvrec = irec |
122 |
|
|
itile = bi |
123 |
|
|
jtile = bj |
124 |
|
|
|
125 |
|
|
do j = jwrk, sny |
126 |
|
|
do i = iwrk, snx |
127 |
|
|
if (ierr .ne. 0) then |
128 |
|
|
if ( ncvargrd(grdchkvarindex) .eq. 'c' ) then |
129 |
heimbach |
1.3 |
if ( maskC(i,j,k,bi,bj) .gt. 0.) then |
130 |
heimbach |
1.2 |
icomptest = icomptest + 1 |
131 |
|
|
endif |
132 |
|
|
else if ( ncvargrd(grdchkvarindex) .eq. 's' ) then |
133 |
|
|
if ( _maskS(i,j,k,bi,bj) .gt. 0.) then |
134 |
|
|
icomptest = icomptest + 1 |
135 |
|
|
endif |
136 |
|
|
else if ( ncvargrd(grdchkvarindex) .eq. 'w' ) then |
137 |
|
|
if ( _maskW(i,j,k,bi,bj) .gt. 0.) then |
138 |
|
|
icomptest = icomptest + 1 |
139 |
|
|
endif |
140 |
|
|
endif |
141 |
|
|
if ( icomp .eq. icomptest ) then |
142 |
|
|
itilepos = i |
143 |
|
|
jtilepos = j |
144 |
|
|
layer = k |
145 |
|
|
ierr = 0 |
146 |
|
|
endif |
147 |
|
|
endif |
148 |
|
|
enddo |
149 |
|
|
iwrk = 1 |
150 |
|
|
enddo |
151 |
|
|
jwrk = 1 |
152 |
|
|
else if (ierr .NE. 0) then |
153 |
|
|
itest = itest + nwettile(bi,bj,k) |
154 |
|
|
iwrk = 1 |
155 |
|
|
jwrk = 1 |
156 |
|
|
else |
157 |
|
|
c |
158 |
|
|
endif |
159 |
|
|
c-- End of loop over k |
160 |
|
|
enddo |
161 |
|
|
kwrk = 1 |
162 |
|
|
c-- End of loop over bi |
163 |
|
|
enddo |
164 |
|
|
biwrk = 1 |
165 |
|
|
c-- End of loop over bj |
166 |
|
|
enddo |
167 |
|
|
bjwrk = 1 |
168 |
|
|
c-- End of loop over records. |
169 |
|
|
enddo |
170 |
|
|
else |
171 |
|
|
if ( icomp .gt. maxncvarcomps ) then |
172 |
|
|
c-- Such a component does not exist. |
173 |
|
|
ierr = -4 |
174 |
|
|
icvrec = -1 |
175 |
|
|
jtile = -1 |
176 |
|
|
itile = -1 |
177 |
|
|
layer = -1 |
178 |
|
|
jtilepos = -1 |
179 |
|
|
itilepos = -1 |
180 |
|
|
else |
181 |
|
|
c-- The component is a land point. |
182 |
|
|
ierr = -3 |
183 |
|
|
icvrec = -1 |
184 |
|
|
jtile = -1 |
185 |
|
|
itile = -1 |
186 |
|
|
layer = -1 |
187 |
|
|
jtilepos = -1 |
188 |
|
|
itilepos = -1 |
189 |
|
|
endif |
190 |
|
|
endif |
191 |
|
|
else |
192 |
|
|
if ( icomp .lt. 0 ) then |
193 |
|
|
c-- Such a component does not exist. |
194 |
|
|
ierr = -2 |
195 |
|
|
icvrec = -1 |
196 |
|
|
jtile = -1 |
197 |
|
|
itile = -1 |
198 |
|
|
layer = -1 |
199 |
|
|
jtilepos = -1 |
200 |
|
|
itilepos = -1 |
201 |
|
|
else |
202 |
|
|
c-- Component zero. |
203 |
|
|
ierr = -1 |
204 |
|
|
icvrec = -1 |
205 |
|
|
jtile = -1 |
206 |
|
|
itile = -1 |
207 |
|
|
layer = -1 |
208 |
|
|
jtilepos = -1 |
209 |
|
|
itilepos = -1 |
210 |
|
|
endif |
211 |
|
|
endif |
212 |
|
|
|
213 |
|
|
_END_MASTER( mythid ) |
214 |
|
|
|
215 |
|
|
_BARRIER |
216 |
|
|
|
217 |
|
|
#endif /* ALLOW_GRADIENT_CHECK */ |
218 |
|
|
|
219 |
|
|
end |
220 |
|
|
|