1 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/Attic/cost_ctds.F,v 1.1.2.3 2002/04/04 10:58:58 heimbach Exp $ |
2 |
|
3 |
#include "COST_CPPOPTIONS.h" |
4 |
|
5 |
|
6 |
subroutine cost_CTDS( |
7 |
I myiter, |
8 |
I mytime, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_CTDS |
14 |
c ================================================================== |
15 |
c |
16 |
c o Evaluate cost function contribution of CTD temperature data. |
17 |
c |
18 |
c started: Elisabeth Remy eremy@ucsd.edu 30-Aug-2000 |
19 |
c |
20 |
c ================================================================== |
21 |
c SUBROUTINE cost_CTDS |
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 nrec |
54 |
integer irec |
55 |
integer ilu |
56 |
|
57 |
_RL fctile_ctds |
58 |
_RL fcthread_ctds |
59 |
_RL www (1-olx:snx+olx,1-oly:sny+oly) |
60 |
_RL wtmp (1-olx:snx+olx,1-oly:sny+oly) |
61 |
_RL tmpobs (1-olx:snx+olx,1-oly:sny+oly) |
62 |
_RL tmpbar (1-olx:snx+olx,1-oly:sny+oly) |
63 |
_RL spval |
64 |
|
65 |
character*(80) fnamesalt |
66 |
|
67 |
logical doglobalread |
68 |
logical ladinit |
69 |
|
70 |
character*(MAX_LEN_MBUF) msgbuf |
71 |
|
72 |
cnew( |
73 |
integer il |
74 |
integer mody, modm |
75 |
integer iyear, imonth |
76 |
character*(80) fnametmp |
77 |
logical exst |
78 |
cnew) |
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 = 25. |
97 |
|
98 |
c-- Read state record from global file. |
99 |
doglobalread = .false. |
100 |
ladinit = .false. |
101 |
|
102 |
#ifdef ALLOW_CTDS_COST_CONTRIBUTION |
103 |
|
104 |
if (optimcycle .ge. 0) then |
105 |
ilu=ilnblnk( sbarfile ) |
106 |
write(fnamesalt(1:80),'(2a,i10.10)') |
107 |
& sbarfile(1:ilu),'.',optimcycle |
108 |
endif |
109 |
|
110 |
fcthread_ctds = 0. _d 0 |
111 |
|
112 |
cnew( |
113 |
mody = modelstartdate(1)/10000 |
114 |
modm = modelstartdate(1)/100 - mody*100 |
115 |
cnew) |
116 |
|
117 |
c-- Loop over records. |
118 |
do irec = 1,nmonsrec |
119 |
|
120 |
c-- Read time averages and the monthly mean data. |
121 |
call active_read_xyz( fnamesalt, sbar, irec, |
122 |
& doglobalread, ladinit, |
123 |
& optimcycle, mythid, xx_sbar_mean_dummy ) |
124 |
|
125 |
cnew( |
126 |
iyear = mody + INT((modm-1+irec-1)/12) |
127 |
imonth = 1 + MOD(modm-1+irec-1,12) |
128 |
il=ilnblnk(ctdsfile) |
129 |
write(fnametmp(1:80),'(2a,i4)') |
130 |
& ctdsfile(1:il), '_', iyear |
131 |
inquire( file=fnametmp, exist=exst ) |
132 |
if (.NOT. exst) then |
133 |
write(fnametmp(1:80),'(a)') ctdsfile(1:il) |
134 |
imonth = irec |
135 |
endif |
136 |
|
137 |
call mdsreadfield( fnametmp, cost_iprec, 'RL', nr, ctdsobs, |
138 |
& imonth, mythid) |
139 |
cnew) |
140 |
|
141 |
c-- Loop over this thread's tiles. |
142 |
do bj = jtlo,jthi |
143 |
do bi = itlo,ithi |
144 |
c-- Loop over the model layers |
145 |
|
146 |
fctile_ctds = 0. _d 0 |
147 |
|
148 |
do k = 1,nr |
149 |
|
150 |
c-- Determine the weights to be used. |
151 |
do j = jmin,jmax |
152 |
do i = imin,imax |
153 |
cph( |
154 |
cph print *, 'WARNING: SPECIFIC SETUP FOR ECCO' |
155 |
cph below statement could be replaced by following |
156 |
cph to make it independnet of Nr: |
157 |
cph |
158 |
cph if ( rC(K) .GT. -1000. ) then |
159 |
cph) |
160 |
if ((ctdsobs(i,j,k,bi,bj) .ne. 0.).and. |
161 |
& (ctdsobs(i,j,k,bi,bj) .gt. spval).and. |
162 |
& (_hFacC(i,j,13,bi,bj) .ne. 0.).and. |
163 |
& (_hFacC(i,j,k,bi,bj) .ne. 0.)) then |
164 |
www(i,j) = cosphi(i,j,bi,bj) |
165 |
tmpobs(i,j) = ctdsobs(i,j,k,bi,bj) |
166 |
tmpbar(i,j) = sbar(i,j,k,bi,bj) |
167 |
c wtmp(i,j) = wsalt(k,bi,bj) |
168 |
wtmp(i,j) = wsalt2(i,j,k,bi,bj) |
169 |
|
170 |
fctile_ctds = fctile_ctds + |
171 |
& (wtmp(i,j)*www(i,j))* |
172 |
& (tmpbar(i,j)-tmpobs(i,j))* |
173 |
& (tmpbar(i,j)-tmpobs(i,j)) |
174 |
endif |
175 |
enddo |
176 |
enddo |
177 |
enddo |
178 |
c-- End of loop over layers. |
179 |
|
180 |
fcthread_ctds = fcthread_ctds + fctile_ctds |
181 |
objf_ctds(bi,bj) = objf_ctds(bi,bj) + fctile_ctds |
182 |
|
183 |
#ifdef ECCO_VERBOSE |
184 |
write(msgbuf,'(a)') ' ' |
185 |
call print_message( msgbuf, standardmessageunit, |
186 |
& SQUEEZE_RIGHT , mythid) |
187 |
write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)') |
188 |
& ' COST_CTDS: irec,bi,bj = ',irec,bi,bj |
189 |
call print_message( msgbuf, standardmessageunit, |
190 |
& SQUEEZE_RIGHT , mythid) |
191 |
write(msgbuf,'(a,d22.15)') |
192 |
& ' COST_CTDS: cost function = ', fctile_ctds |
193 |
call print_message( msgbuf, standardmessageunit, |
194 |
& SQUEEZE_RIGHT , mythid) |
195 |
write(msgbuf,'(a)') ' ' |
196 |
call print_message( msgbuf, standardmessageunit, |
197 |
& SQUEEZE_RIGHT , mythid) |
198 |
#endif |
199 |
|
200 |
enddo |
201 |
enddo |
202 |
|
203 |
#ifdef ECCO_VERBOSE |
204 |
c-- Print cost function for all tiles. |
205 |
_GLOBAL_SUM_R8( fcthread_ctds , myThid ) |
206 |
write(msgbuf,'(a)') ' ' |
207 |
call print_message( msgbuf, standardmessageunit, |
208 |
& SQUEEZE_RIGHT , mythid) |
209 |
write(msgbuf,'(a,i8.8)') |
210 |
& ' cost_CTDS: irec = ',irec |
211 |
call print_message( msgbuf, standardmessageunit, |
212 |
& SQUEEZE_RIGHT , mythid) |
213 |
write(msgbuf,'(a,a,d22.15)') |
214 |
& ' global cost function value', |
215 |
& ' ( CTD sal. ) = ',fcthread_ctds |
216 |
call print_message( msgbuf, standardmessageunit, |
217 |
& SQUEEZE_RIGHT , mythid) |
218 |
write(msgbuf,'(a)') ' ' |
219 |
call print_message( msgbuf, standardmessageunit, |
220 |
& SQUEEZE_RIGHT , mythid) |
221 |
#endif |
222 |
|
223 |
enddo |
224 |
c-- End of second loop over records. |
225 |
|
226 |
#else |
227 |
c-- Do not enter the calculation of the CTD temperature contribution |
228 |
c-- to the final cost function. |
229 |
|
230 |
fctile_ctds = 0. _d 0 |
231 |
fcthread_ctds = 0. _d 0 |
232 |
|
233 |
crg |
234 |
nrec = 1 |
235 |
crg |
236 |
|
237 |
_BEGIN_MASTER( mythid ) |
238 |
write(msgbuf,'(a)') ' ' |
239 |
call print_message( msgbuf, standardmessageunit, |
240 |
& SQUEEZE_RIGHT , mythid) |
241 |
write(msgbuf,'(a,a)') |
242 |
& ' cost_CTDS: no contribution of CTD temperature ', |
243 |
& ' to cost function.' |
244 |
call print_message( msgbuf, standardmessageunit, |
245 |
& SQUEEZE_RIGHT , mythid) |
246 |
write(msgbuf,'(a,a,i9.8)') |
247 |
& ' cost_CDTS: number of records that would have', |
248 |
& ' been processed: ',nrec |
249 |
call print_message( msgbuf, standardmessageunit, |
250 |
& SQUEEZE_RIGHT , mythid) |
251 |
write(msgbuf,'(a)') ' ' |
252 |
call print_message( msgbuf, standardmessageunit, |
253 |
& SQUEEZE_RIGHT , mythid) |
254 |
_END_MASTER( mythid ) |
255 |
#endif |
256 |
|
257 |
return |
258 |
end |