1 |
heimbach |
1.1 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/Attic/cost_curmtr.F,v 1.1.2.2 2003/07/07 16:18:17 heimbach Exp $ |
2 |
|
|
|
3 |
|
|
#include "COST_CPPOPTIONS.h" |
4 |
|
|
|
5 |
|
|
subroutine cost_CurMtr( |
6 |
|
|
I myiter, |
7 |
|
|
I mytime, |
8 |
|
|
I mythid |
9 |
|
|
& ) |
10 |
|
|
|
11 |
|
|
c ================================================================== |
12 |
|
|
c SUBROUTINE cost_CurMtr |
13 |
|
|
c ================================================================== |
14 |
|
|
c |
15 |
|
|
c o Evaluate cost function contribution of Vector-Measuring |
16 |
|
|
c Current Meters. |
17 |
|
|
c |
18 |
|
|
c started: Elisabeth Remy eremy@ucsd.edu 30-Aug-2000 |
19 |
|
|
c modified: G. Gebbie, gebbie@mit.edu, 3- May- 2002. |
20 |
|
|
c |
21 |
|
|
c ================================================================== |
22 |
|
|
c SUBROUTINE cost_CurMtr |
23 |
|
|
c ================================================================== |
24 |
|
|
|
25 |
|
|
implicit none |
26 |
|
|
|
27 |
|
|
c == global variables == |
28 |
|
|
|
29 |
|
|
#include "EEPARAMS.h" |
30 |
|
|
#include "SIZE.h" |
31 |
|
|
#include "GRID.h" |
32 |
|
|
#include "DYNVARS.h" |
33 |
|
|
|
34 |
|
|
#include "cal.h" |
35 |
|
|
#include "ecco_cost.h" |
36 |
|
|
#include "ctrl.h" |
37 |
|
|
#include "ctrl_dummy.h" |
38 |
|
|
#include "optim.h" |
39 |
|
|
|
40 |
|
|
c == routine arguments == |
41 |
|
|
|
42 |
|
|
integer myiter |
43 |
|
|
_RL mytime |
44 |
|
|
integer mythid |
45 |
|
|
|
46 |
|
|
c == local variables == |
47 |
|
|
|
48 |
|
|
integer bi,bj |
49 |
|
|
integer i,j,k |
50 |
|
|
integer itlo,ithi |
51 |
|
|
integer jtlo,jthi |
52 |
|
|
integer jmin,jmax |
53 |
|
|
integer imin,imax |
54 |
|
|
integer nrec |
55 |
|
|
integer irec |
56 |
|
|
integer ilu |
57 |
|
|
|
58 |
|
|
_RL fctile_curmtr |
59 |
|
|
_RL fcthread_curmtr |
60 |
|
|
_RL wwwu (1-olx:snx+olx,1-oly:sny+oly) |
61 |
|
|
_RL wwwv (1-olx:snx+olx,1-oly:sny+oly) |
62 |
|
|
_RL wu (1-olx:snx+olx,1-oly:sny+oly) |
63 |
|
|
_RL wv (1-olx:snx+olx,1-oly:sny+oly) |
64 |
|
|
_RL umask (1-olx:snx+olx,1-oly:sny+oly) |
65 |
|
|
_RL vmask (1-olx:snx+olx,1-oly:sny+oly) |
66 |
|
|
_RL tmpuobs (1-olx:snx+olx,1-oly:sny+oly) |
67 |
|
|
_RL tmpubar (1-olx:snx+olx,1-oly:sny+oly) |
68 |
|
|
_RL tmpvobs (1-olx:snx+olx,1-oly:sny+oly) |
69 |
|
|
_RL tmpvbar (1-olx:snx+olx,1-oly:sny+oly) |
70 |
|
|
_RL spval |
71 |
|
|
|
72 |
|
|
character*(80) fnameuvel |
73 |
|
|
character*(80) fnamevvel |
74 |
|
|
|
75 |
|
|
logical doglobalread |
76 |
|
|
logical ladinit |
77 |
|
|
|
78 |
|
|
character*(MAX_LEN_MBUF) msgbuf |
79 |
|
|
|
80 |
|
|
c == external functions == |
81 |
|
|
|
82 |
|
|
integer ilnblnk |
83 |
|
|
external ilnblnk |
84 |
|
|
|
85 |
|
|
c == end of interface == |
86 |
|
|
|
87 |
|
|
jtlo = mybylo(mythid) |
88 |
|
|
jthi = mybyhi(mythid) |
89 |
|
|
itlo = mybxlo(mythid) |
90 |
|
|
ithi = mybxhi(mythid) |
91 |
|
|
jmin = 1 |
92 |
|
|
jmax = sny |
93 |
|
|
imin = 1 |
94 |
|
|
imax = snx |
95 |
|
|
|
96 |
|
|
spval = -9990. |
97 |
|
|
|
98 |
|
|
c-- Read state record from global file. |
99 |
|
|
doglobalread = .false. |
100 |
|
|
ladinit = .false. |
101 |
|
|
|
102 |
|
|
#ifdef ALLOW_CURMTR_COST_CONTRIBUTION |
103 |
|
|
|
104 |
|
|
#ifdef ECCO_VERBOSE |
105 |
|
|
write(msgbuf,'(a)') ' ' |
106 |
|
|
call print_message( msgbuf, standardmessageunit, |
107 |
|
|
& SQUEEZE_RIGHT , mythid) |
108 |
|
|
write(msgbuf,'(a,i8.8)') |
109 |
|
|
& ' cost_Curmtr: number of records to process =', nmonsrec |
110 |
|
|
call print_message( msgbuf, standardmessageunit, |
111 |
|
|
& SQUEEZE_RIGHT , mythid) |
112 |
|
|
write(msgbuf,'(a)') ' ' |
113 |
|
|
call print_message( msgbuf, standardmessageunit, |
114 |
|
|
& SQUEEZE_RIGHT , mythid) |
115 |
|
|
#endif |
116 |
|
|
|
117 |
|
|
if (optimcycle .ge. 0) then |
118 |
|
|
ilu=ilnblnk( ubarfile ) |
119 |
|
|
write(fnameuvel(1:80),'(2a,i10.10)') |
120 |
|
|
& ubarfile(1:ilu), '.', optimcycle |
121 |
|
|
endif |
122 |
|
|
|
123 |
|
|
if (optimcycle .ge. 0) then |
124 |
|
|
ilu=ilnblnk( vbarfile ) |
125 |
|
|
write(fnamevvel(1:80),'(2a,i10.10)') |
126 |
|
|
& vbarfile(1:ilu), '.', optimcycle |
127 |
|
|
endif |
128 |
|
|
|
129 |
|
|
fcthread_curmtr = 0. _d 0 |
130 |
|
|
|
131 |
|
|
c-- Loop over records. |
132 |
|
|
do irec = 1,nmonsrec |
133 |
|
|
|
134 |
|
|
cgg First do the Zonal Velocity. |
135 |
|
|
c-- Read time averages and the monthly mean data. |
136 |
|
|
call active_read_xyz( fnameuvel, ubar, irec, |
137 |
|
|
& doglobalread, ladinit, |
138 |
|
|
& optimcycle, mythid, xx_ubar_mean_dummy ) |
139 |
|
|
|
140 |
|
|
|
141 |
|
|
cgg Then meridional velocity. |
142 |
|
|
call active_read_xyz( fnamevvel, vbar, irec, |
143 |
|
|
& doglobalread, ladinit, |
144 |
|
|
& optimcycle, mythid, xx_vbar_mean_dummy ) |
145 |
|
|
|
146 |
|
|
cgg( fixed precision of file.) |
147 |
|
|
call mdsreadfield( curmtrufile,cost_iprec, 'RL', nr, curmtruobs, |
148 |
|
|
& irec, mythid) |
149 |
|
|
|
150 |
|
|
call mdsreadfield( curmtrvfile,cost_iprec, 'RL', nr, curmtrvobs, |
151 |
|
|
& irec, mythid) |
152 |
|
|
|
153 |
|
|
|
154 |
|
|
c-- Loop over this thread's tiles. |
155 |
|
|
do bj = jtlo,jthi |
156 |
|
|
do bi = itlo,ithi |
157 |
|
|
c-- Loop over the model layers |
158 |
|
|
|
159 |
|
|
fctile_curmtr = 0. _d 0 |
160 |
|
|
|
161 |
|
|
do k = 1,nr |
162 |
|
|
|
163 |
|
|
c-- Determine the weights to be used. |
164 |
|
|
do j = jmin,jmax |
165 |
|
|
do i = imin,imax |
166 |
|
|
umask(i,j) = 1. _d 0 |
167 |
|
|
vmask(i,j) = 1. _d 0 |
168 |
|
|
if (curmtruobs(i,j,k,bi,bj) .eq. 0.) then |
169 |
|
|
umask(i,j) = 0. _d 0 |
170 |
|
|
endif |
171 |
|
|
|
172 |
|
|
if (curmtrvobs(i,j,k,bi,bj) .eq. 0.) then |
173 |
|
|
vmask(i,j) = 0. _d 0 |
174 |
|
|
endif |
175 |
|
|
|
176 |
|
|
if (curmtruobs(i,j,k,bi,bj) .lt. spval) then |
177 |
|
|
umask(i,j) = 0. _d 0 |
178 |
|
|
endif |
179 |
|
|
|
180 |
|
|
if (curmtrvobs(i,j,k,bi,bj) .lt. spval) then |
181 |
|
|
vmask(i,j) = 0. _d 0 |
182 |
|
|
endif |
183 |
|
|
|
184 |
|
|
cph( |
185 |
|
|
cph print *, 'WARNING: SPECIFIC SETUP FOR ECCO' |
186 |
|
|
cph below statement could be replaced by following |
187 |
|
|
cph to make it independnet of Nr: |
188 |
|
|
cph |
189 |
|
|
cph if ( rC(K) .GT. -1000. ) then |
190 |
|
|
cph) |
191 |
|
|
c set cmask=0 in areas shallower than 1000m |
192 |
|
|
cgg if (_hFacC(i,j,13,bi,bj) .eq. 0.) then |
193 |
|
|
cgg cmask(i,j) = 0. _d 0 |
194 |
|
|
cgg endif |
195 |
|
|
|
196 |
|
|
if (_hFacW(i,j,k,bi,bj) .eq. 0.) then |
197 |
|
|
umask(i,j) = 0. _d 0 |
198 |
|
|
endif |
199 |
|
|
|
200 |
|
|
if (_hFacS(i,j,k,bi,bj) .eq. 0.) then |
201 |
|
|
vmask(i,j) = 0. _d 0 |
202 |
|
|
endif |
203 |
|
|
|
204 |
|
|
enddo |
205 |
|
|
enddo |
206 |
|
|
|
207 |
|
|
do j = jmin,jmax |
208 |
|
|
do i = imin,imax |
209 |
|
|
wwwu(i,j) = cosphi(i,j,bi,bj)*umask(i,j) |
210 |
|
|
wwwv(i,j) = cosphi(i,j,bi,bj)*vmask(i,j) |
211 |
|
|
|
212 |
|
|
tmpuobs(i,j) = curmtruobs(i,j,k,bi,bj) |
213 |
|
|
tmpubar(i,j) = ubar(i,j,k,bi,bj) |
214 |
|
|
|
215 |
|
|
tmpvobs(i,j) = curmtrvobs(i,j,k,bi,bj) |
216 |
|
|
tmpvbar(i,j) = vbar(i,j,k,bi,bj) |
217 |
|
|
|
218 |
|
|
#ifdef SUBEX_2DEG |
219 |
|
|
cgg( Perform the comparison in observation space. |
220 |
|
|
if ( (i.eq.5) .and. (j.eq.13)) then |
221 |
|
|
tmpubar(i,j) = ubar(5,12,k,bi,bj) |
222 |
|
|
tmpvbar(i,j) = (vbar(4,12,k,bi,bj) + vbar(5,12,k,bi,bj) |
223 |
|
|
& +vbar(4,13,k,bi,bj) + vbar(5,13,k,bi,bj))/4. |
224 |
|
|
endif |
225 |
|
|
if ( (i .eq. 11) .and. (j .eq. 13)) then |
226 |
|
|
tmpubar(i,j) = ubar(11,12,k,bi,bj) |
227 |
|
|
tmpvbar(i,j) = (vbar(10,12,k,bi,bj) + vbar(11,12,k,bi,bj) |
228 |
|
|
& +vbar(10,13,k,bi,bj) + vbar(11,13,k,bi,bj))/4. |
229 |
|
|
endif |
230 |
|
|
if ( (i .eq. 8) .and. (j .eq. 9)) then |
231 |
|
|
tmpubar(i,j) = (ubar(7,8,k,bi,bj) + ubar(8,8,k,bi,bj) |
232 |
|
|
& +ubar(7,9,k,bi,bj) + ubar(8,9,k,bi,bj))/4. |
233 |
|
|
tmpvbar(i,j) = vbar(7,9,k,bi,bj) |
234 |
|
|
endif |
235 |
|
|
if ( (i .eq. 5) .and. (j .eq. 5)) then |
236 |
|
|
tmpubar(i,j) = (ubar(5,4,k,bi,bj) + ubar(5,5,k,bi,bj))/2. |
237 |
|
|
tmpvbar(i,j) = (vbar(4,5,k,bi,bj) + vbar(5,5,k,bi,bj))/2. |
238 |
|
|
endif |
239 |
|
|
if ( (i .eq. 11) .and. (j .eq. 5)) then |
240 |
|
|
tmpubar(i,j) = (ubar(11,4,k,bi,bj)+ubar(11,5,k,bi,bj))/2. |
241 |
|
|
tmpvbar(i,j) = (vbar(10,5,k,bi,bj)+vbar(11,5,k,bi,bj))/2. |
242 |
|
|
endif |
243 |
|
|
#endif |
244 |
|
|
|
245 |
|
|
cgg( Weights are subject to individual's preference. |
246 |
|
|
wu(i,j) = wcurrent2(i,j,k,bi,bj) |
247 |
|
|
wv(i,j) = wcurrent2(i,j,k,bi,bj) |
248 |
|
|
cgg wtmp(i,j) = wtheta2(i,j,k,bi,bj) |
249 |
|
|
enddo |
250 |
|
|
enddo |
251 |
|
|
|
252 |
|
|
do j = jmin,jmax |
253 |
|
|
do i = imin,imax |
254 |
|
|
c-- The array tmpuobs contains current meter velocities. |
255 |
|
|
cgg if(umask(i,j).eq.1.0 .and.tmpubar(i,j) .ne. 0. ) then |
256 |
|
|
cgg print *,'cost_curmtr U',i,j,tmpubar(i,j),tmpuobs(i,j) |
257 |
|
|
cgg endif |
258 |
|
|
|
259 |
|
|
cgg if(vmask(i,j).eq.1.0.and.tmpvbar(i,j) .ne. 0.) then |
260 |
|
|
cgg print *,'cost_curmtr V',i,j,tmpvbar(i,j),tmpvobs(i,j) |
261 |
|
|
cgg endif |
262 |
|
|
|
263 |
|
|
cgg( Add one more zero check. |
264 |
|
|
if (tmpubar(i,j) .ne. 0.) then |
265 |
|
|
fctile_curmtr = fctile_curmtr + |
266 |
|
|
& (wu(i,j)*wwwu(i,j))* |
267 |
|
|
& (tmpubar(i,j)-tmpuobs(i,j))* |
268 |
|
|
& (tmpubar(i,j)-tmpuobs(i,j)) |
269 |
|
|
endif |
270 |
|
|
|
271 |
|
|
cgg( Add one more zero check. |
272 |
|
|
if (tmpvbar(i,j) .ne. 0.) then |
273 |
|
|
fctile_curmtr = fctile_curmtr + |
274 |
|
|
& (wv(i,j)*wwwv(i,j))* |
275 |
|
|
& (tmpvbar(i,j)-tmpvobs(i,j))* |
276 |
|
|
& (tmpvbar(i,j)-tmpvobs(i,j)) |
277 |
|
|
endif |
278 |
|
|
enddo |
279 |
|
|
enddo |
280 |
|
|
enddo |
281 |
|
|
c-- End of loop over layers. |
282 |
|
|
|
283 |
|
|
fcthread_curmtr = fcthread_curmtr + fctile_curmtr |
284 |
|
|
objf_curmtr(bi,bj) = objf_curmtr(bi,bj) + fctile_curmtr |
285 |
|
|
|
286 |
|
|
#ifdef ECCO_VERBOSE |
287 |
|
|
write(msgbuf,'(a)') ' ' |
288 |
|
|
call print_message( msgbuf, standardmessageunit, |
289 |
|
|
& SQUEEZE_RIGHT , mythid) |
290 |
|
|
write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)') |
291 |
|
|
& ' COST_curmtr: irec,bi,bj = ',irec,bi,bj |
292 |
|
|
call print_message( msgbuf, standardmessageunit, |
293 |
|
|
& SQUEEZE_RIGHT , mythid) |
294 |
|
|
write(msgbuf,'(a,d22.15)') |
295 |
|
|
& ' COST_Curmtr: cost function = ', fctile_curmtr |
296 |
|
|
call print_message( msgbuf, standardmessageunit, |
297 |
|
|
& SQUEEZE_RIGHT , mythid) |
298 |
|
|
write(msgbuf,'(a)') ' ' |
299 |
|
|
call print_message( msgbuf, standardmessageunit, |
300 |
|
|
& SQUEEZE_RIGHT , mythid) |
301 |
|
|
#endif |
302 |
|
|
|
303 |
|
|
enddo |
304 |
|
|
enddo |
305 |
|
|
|
306 |
|
|
#ifdef ECCO_VERBOSE |
307 |
|
|
c-- Print cost function for all tiles. |
308 |
|
|
_GLOBAL_SUM_R8( fcthread_curmtr , myThid ) |
309 |
|
|
write(msgbuf,'(a)') ' ' |
310 |
|
|
call print_message( msgbuf, standardmessageunit, |
311 |
|
|
& SQUEEZE_RIGHT , mythid) |
312 |
|
|
write(msgbuf,'(a,i8.8)') |
313 |
|
|
& ' cost_Curmtr: irec = ',irec |
314 |
|
|
call print_message( msgbuf, standardmessageunit, |
315 |
|
|
& SQUEEZE_RIGHT , mythid) |
316 |
|
|
write(msgbuf,'(a,a,d22.15)') |
317 |
|
|
& ' global cost function value', |
318 |
|
|
& ' ( CurMtr ) = ',fcthread_curmtr |
319 |
|
|
call print_message( msgbuf, standardmessageunit, |
320 |
|
|
& SQUEEZE_RIGHT , mythid) |
321 |
|
|
write(msgbuf,'(a)') ' ' |
322 |
|
|
call print_message( msgbuf, standardmessageunit, |
323 |
|
|
& SQUEEZE_RIGHT , mythid) |
324 |
|
|
#endif |
325 |
|
|
|
326 |
|
|
enddo |
327 |
|
|
c-- End of second loop over records. |
328 |
|
|
|
329 |
|
|
#else |
330 |
|
|
c-- Do not enter the calculation of the CTD temperature contribution |
331 |
|
|
c-- to the final cost function. |
332 |
|
|
|
333 |
|
|
fctile_curmtr = 0. _d 0 |
334 |
|
|
fcthread_curmtr = 0. _d 0 |
335 |
|
|
|
336 |
|
|
crg |
337 |
|
|
nrec = 1 |
338 |
|
|
crg |
339 |
|
|
|
340 |
|
|
_BEGIN_MASTER( mythid ) |
341 |
|
|
write(msgbuf,'(a)') ' ' |
342 |
|
|
call print_message( msgbuf, standardmessageunit, |
343 |
|
|
& SQUEEZE_RIGHT , mythid) |
344 |
|
|
write(msgbuf,'(a,a)') |
345 |
|
|
& ' cost_Curmtr: no contribution of CTD temperature ', |
346 |
|
|
& ' to cost function.' |
347 |
|
|
call print_message( msgbuf, standardmessageunit, |
348 |
|
|
& SQUEEZE_RIGHT , mythid) |
349 |
|
|
write(msgbuf,'(a,a,i9.8)') |
350 |
|
|
& ' cost_Curmtr: number of records that would have', |
351 |
|
|
& ' been processed: ',nrec |
352 |
|
|
call print_message( msgbuf, standardmessageunit, |
353 |
|
|
& SQUEEZE_RIGHT , mythid) |
354 |
|
|
write(msgbuf,'(a)') ' ' |
355 |
|
|
call print_message( msgbuf, standardmessageunit, |
356 |
|
|
& SQUEEZE_RIGHT , mythid) |
357 |
|
|
_END_MASTER( mythid ) |
358 |
|
|
#endif |
359 |
|
|
|
360 |
|
|
return |
361 |
|
|
end |
362 |
|
|
|
363 |
|
|
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
|