1 |
C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/pkg/ecco/Attic/cost_scat.F,v 1.1 2003/11/06 22:10:08 heimbach Exp $ |
2 |
|
3 |
#include "COST_CPPOPTIONS.h" |
4 |
|
5 |
|
6 |
subroutine cost_scat( |
7 |
I myiter, |
8 |
I mytime, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_scat |
14 |
c ================================================================== |
15 |
c |
16 |
c o Evaluate cost function contribution of surface wind stress observations. |
17 |
c |
18 |
c started: Detlef Satmmer 01-mar-2002 copy from cost_sst.F |
19 |
c |
20 |
c ================================================================== |
21 |
c SUBROUTINE cost_scat |
22 |
c ================================================================== |
23 |
|
24 |
implicit none |
25 |
|
26 |
c == global variables == |
27 |
|
28 |
#include "EEPARAMS.h" |
29 |
#include "SIZE.h" |
30 |
#include "GRID.h" |
31 |
#include "DYNVARS.h" |
32 |
|
33 |
#include "cal.h" |
34 |
#include "ecco_cost.h" |
35 |
#include "ctrl.h" |
36 |
#include "ctrl_dummy.h" |
37 |
#include "optim.h" |
38 |
|
39 |
c == routine arguments == |
40 |
|
41 |
integer myiter |
42 |
_RL mytime |
43 |
integer mythid |
44 |
|
45 |
c == local variables == |
46 |
|
47 |
integer bi,bj |
48 |
integer i,j,k |
49 |
integer itlo,ithi |
50 |
integer jtlo,jthi |
51 |
integer jmin,jmax |
52 |
integer imin,imax |
53 |
integer irec |
54 |
integer levmon |
55 |
integer levoff |
56 |
integer ilsalt |
57 |
|
58 |
_RL fctile_scatx |
59 |
_RL fcthread_scatx |
60 |
_RL fctile_scaty |
61 |
_RL fcthread_scaty |
62 |
|
63 |
character*(80) fnametaux |
64 |
character*(80) fnametauy |
65 |
|
66 |
logical doglobalread |
67 |
logical ladinit |
68 |
|
69 |
character*(MAX_LEN_MBUF) msgbuf |
70 |
|
71 |
c == external functions == |
72 |
|
73 |
integer ilnblnk |
74 |
external ilnblnk |
75 |
|
76 |
c == end of interface == |
77 |
|
78 |
jtlo = mybylo(mythid) |
79 |
jthi = mybyhi(mythid) |
80 |
itlo = mybxlo(mythid) |
81 |
ithi = mybxhi(mythid) |
82 |
jmin = 1 |
83 |
jmax = sny |
84 |
imin = 1 |
85 |
imax = snx |
86 |
|
87 |
c-- Read tiled data. |
88 |
doglobalread = .false. |
89 |
ladinit = .false. |
90 |
|
91 |
#ifdef ALLOW_SCAT_COST_CONTRIBUTION |
92 |
|
93 |
#ifdef ECCO_VERBOSE |
94 |
_BEGIN_MASTER( mythid ) |
95 |
write(msgbuf,'(a)') ' ' |
96 |
call print_message( msgbuf, standardmessageunit, |
97 |
& SQUEEZE_RIGHT , mythid) |
98 |
write(msgbuf,'(a,i8.8)') |
99 |
& ' cost_scat: number of records to process = ',nmonsrec |
100 |
call print_message( msgbuf, standardmessageunit, |
101 |
& SQUEEZE_RIGHT , mythid) |
102 |
write(msgbuf,'(a)') ' ' |
103 |
call print_message( msgbuf, standardmessageunit, |
104 |
& SQUEEZE_RIGHT , mythid) |
105 |
_END_MASTER( mythid ) |
106 |
#endif |
107 |
|
108 |
if (optimcycle .ge. 0) then |
109 |
ilsalt = ilnblnk( tauxbarfile ) |
110 |
write(fnametaux(1:80),'(2a,i10.10)') |
111 |
& tauxbarfile(1:ilsalt),'.',optimcycle |
112 |
ilsalt = ilnblnk( tauybarfile ) |
113 |
write(fnametauy(1:80),'(2a,i10.10)') |
114 |
& tauybarfile(1:ilsalt),'.',optimcycle |
115 |
else |
116 |
print* |
117 |
print*,' cost_scat: optimcycle has a wrong value.' |
118 |
print*,' optimcycle = ',optimcycle |
119 |
print* |
120 |
stop ' ... stopped in cost_scat.' |
121 |
endif |
122 |
|
123 |
fcthread_scatx = 0. _d 0 |
124 |
fcthread_scaty = 0. _d 0 |
125 |
|
126 |
c-- Loop over records. |
127 |
do irec = 1,nmonsrec |
128 |
|
129 |
c-- Read time averages and the monthly mean data. |
130 |
call active_read_xy( fnametaux, tauxbar, irec, |
131 |
& doglobalread, ladinit, |
132 |
& optimcycle, mythid, |
133 |
& xx_taux_mean_dummy ) |
134 |
|
135 |
call active_read_xy( fnametauy, tauybar, irec, |
136 |
& doglobalread, ladinit, |
137 |
& optimcycle, mythid, |
138 |
& xx_tauy_mean_dummy ) |
139 |
|
140 |
|
141 |
do bj = jtlo,jthi |
142 |
do bi = itlo,ithi |
143 |
|
144 |
fctile_scatx = 0. _d 0 |
145 |
fctile_scaty = 0. _d 0 |
146 |
|
147 |
k = 1 |
148 |
|
149 |
c-- Compute cost rel. to monthly SCAT field. |
150 |
call cost_ReadscatXFields( irec, mythid ) |
151 |
do j = jmin,jmax |
152 |
do i = imin,imax |
153 |
if (_hFacC(i,j,k,bi,bj) .ne. 0.) then |
154 |
fctile_scatx = fctile_scatx + |
155 |
& wscatx(i,j,bi,bj)*cosphi(i,j,bi,bj)* |
156 |
& ( (tauxbar(i,j,bi,bj)-scatxdat(i,j,bi,bj))* |
157 |
& (tauxbar(i,j,bi,bj)-scatxdat(i,j,bi,bj))* |
158 |
& scatxmask(i,j,bi,bj) ) |
159 |
endif |
160 |
enddo |
161 |
enddo |
162 |
|
163 |
c-- Compute cost rel. to monthly SCAT field. |
164 |
call cost_ReadscatYFields( irec, mythid ) |
165 |
do j = jmin,jmax |
166 |
do i = imin,imax |
167 |
if (_hFacC(i,j,k,bi,bj) .ne. 0.) then |
168 |
fctile_scaty = fctile_scaty + |
169 |
& wscaty(i,j,bi,bj)*cosphi(i,j,bi,bj)* |
170 |
& ( (tauybar(i,j,bi,bj)-scatydat(i,j,bi,bj))* |
171 |
& (tauybar(i,j,bi,bj)-scatydat(i,j,bi,bj))* |
172 |
& scatymask(i,j,bi,bj) ) |
173 |
endif |
174 |
enddo |
175 |
enddo |
176 |
|
177 |
|
178 |
fcthread_scatx = fcthread_scatx + fctile_scatx |
179 |
objf_scatx(bi,bj) = objf_scatx(bi,bj) + fctile_scatx |
180 |
fcthread_scaty = fcthread_scaty + fctile_scaty |
181 |
objf_scaty(bi,bj) = objf_scaty(bi,bj) + fctile_scaty |
182 |
|
183 |
#ifdef ECCO_VERBOSE |
184 |
c-- Print cost fscat for each tile in each thread. |
185 |
write(msgbuf,'(a)') ' ' |
186 |
call print_message( msgbuf, standardmessageunit, |
187 |
& SQUEEZE_RIGHT , mythid) |
188 |
write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)') |
189 |
& ' cost_scat: irec,bi,bj = ',irec,bi,bj |
190 |
call print_message( msgbuf, standardmessageunit, |
191 |
& SQUEEZE_RIGHT , mythid) |
192 |
write(msgbuf,'(a,2d22.15)') |
193 |
& ' cost function (scat) = ', |
194 |
& fctile_scatx, fctile_scaty |
195 |
call print_message( msgbuf, standardmessageunit, |
196 |
& SQUEEZE_RIGHT , mythid) |
197 |
#endif |
198 |
|
199 |
enddo |
200 |
enddo |
201 |
|
202 |
#ifdef ECCO_VERBOSE |
203 |
c-- Print cost function for all tiles. |
204 |
_GLOBAL_SUM_R8( fcthread_scatx , myThid ) |
205 |
write(msgbuf,'(a)') ' ' |
206 |
call print_message( msgbuf, standardmessageunit, |
207 |
& SQUEEZE_RIGHT , mythid) |
208 |
write(msgbuf,'(a,i8.8)') |
209 |
& ' cost_scatx: irec = ',irec |
210 |
call print_message( msgbuf, standardmessageunit, |
211 |
& SQUEEZE_RIGHT , mythid) |
212 |
write(msgbuf,'(a,a,d22.15)') |
213 |
& ' global cost function value', |
214 |
& ' ( SCAT ) = ',fcthread_scatx |
215 |
call print_message( msgbuf, standardmessageunit, |
216 |
& SQUEEZE_RIGHT , mythid) |
217 |
write(msgbuf,'(a)') ' ' |
218 |
call print_message( msgbuf, standardmessageunit, |
219 |
& SQUEEZE_RIGHT , mythid) |
220 |
#endif |
221 |
|
222 |
enddo |
223 |
c-- End of loop over records. |
224 |
|
225 |
#else |
226 |
c-- Do not enter the calculation of the temperature contribution to |
227 |
c-- the final cost function. |
228 |
|
229 |
fctile_scatx = 0. _d 0 |
230 |
fcthread_scatx = 0. _d 0 |
231 |
fctile_scaty = 0. _d 0 |
232 |
fcthread_scaty = 0. _d 0 |
233 |
|
234 |
_BEGIN_MASTER( mythid ) |
235 |
write(msgbuf,'(a)') ' ' |
236 |
call print_message( msgbuf, standardmessageunit, |
237 |
& SQUEEZE_RIGHT , mythid) |
238 |
write(msgbuf,'(a,a)') |
239 |
& ' cost_scat: no contribution of temperature field ', |
240 |
& 'to cost function.' |
241 |
call print_message( msgbuf, standardmessageunit, |
242 |
& SQUEEZE_RIGHT , mythid) |
243 |
write(msgbuf,'(a,a,i9.8)') |
244 |
& ' cost_scat: number of records that would have', |
245 |
& ' been processed: ',nmonsrec |
246 |
call print_message( msgbuf, standardmessageunit, |
247 |
& SQUEEZE_RIGHT , mythid) |
248 |
write(msgbuf,'(a)') ' ' |
249 |
call print_message( msgbuf, standardmessageunit, |
250 |
& SQUEEZE_RIGHT , mythid) |
251 |
_END_MASTER( mythid ) |
252 |
#endif |
253 |
|
254 |
return |
255 |
end |
256 |
|