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