/[MITgcm]/MITgcm/pkg/ecco/cost_drift.F
ViewVC logotype

Contents of /MITgcm/pkg/ecco/cost_drift.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Wed Dec 3 23:08:40 2003 UTC (20 years, 5 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint52l_pre, checkpoint52e_pre, hrcube4, checkpoint52n_post, checkpoint52j_post, checkpoint53d_post, checkpoint54a_pre, checkpoint55c_post, checkpoint54e_post, checkpoint52e_post, checkpoint53c_post, checkpoint55d_pre, hrcube_1, checkpoint52j_pre, checkpoint54a_post, checkpoint52d_pre, checkpoint52l_post, checkpoint52k_post, checkpoint54b_post, checkpoint53b_pre, checkpoint55b_post, checkpoint54d_post, checkpoint53f_post, checkpoint52m_post, checkpoint55, checkpoint53a_post, checkpoint54, checkpoint54f_post, checkpoint53b_post, checkpoint53, checkpoint52d_post, checkpoint53g_post, checkpoint52f_post, hrcube5, checkpoint52i_post, checkpoint55a_post, checkpoint53d_pre, checkpoint54c_post, checkpoint52i_pre, checkpoint52h_pre, checkpoint52f_pre, hrcube_2, hrcube_3
Branch point for: netcdf-sm0
Changes since 1.1: +3 -3 lines
adjustments in ecco cost terms:
o ARGO: replace cost_readargo*
o cost_drift: change weights
o cost_hyd: SIO misses cost_sst and doesnt use
            cost_ctd?clim terms
o XBT: active_file was wrong (needs xyz instead of xy)

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_drift.F,v 1.1 2003/11/06 22:10:07 heimbach Exp $
2
3 #include "COST_CPPOPTIONS.h"
4
5
6 subroutine cost_Drift(
7 I myiter,
8 I mytime,
9 I mythid
10 & )
11
12 c ==================================================================
13 c SUBROUTINE cost_Drift
14 c ==================================================================
15 c
16 c o Evaluate cost function contribution of the t and S difference
17 c between the first and the last year.
18 c
19 c started: from the "old" code
20 c
21 c Elisabeth Remy eremy@ucsd.edu july 31 2001
22 c
23 c heimbach@mit.edu 17-Jun-2003: SIO merge:
24 c changed cosphi(i,j,bi,bj)*100.0 factor to
25 c cosphi(i,j,bi,bj)*2.5
26 c
27 c ==================================================================
28 c SUBROUTINE cost_Drift
29 c ==================================================================
30
31 implicit none
32
33 c == global variables ==
34
35 #include "EEPARAMS.h"
36 #include "SIZE.h"
37 #include "GRID.h"
38 #include "DYNVARS.h"
39
40 #include "cal.h"
41 #include "ecco_cost.h"
42 #include "ctrl.h"
43 #include "ctrl_dummy.h"
44 #include "optim.h"
45
46 c == routine arguments ==
47
48 integer myiter
49 _RL mytime
50 integer mythid
51
52 c == local variables ==
53
54 _RS one_rs
55 parameter( one_rs = 1. )
56
57 integer bi,bj
58 integer i,j,k
59 integer itlo,ithi
60 integer jtlo,jthi
61 integer jmin,jmax
62 integer imin,imax
63 integer irec
64 integer iltheta
65 integer ilsalt
66 integer nf, nl
67
68 _RL fctilet
69 _RL fctiles
70 _RL fcthread_tdrift
71 _RL fcthread_tdrifs
72
73 character*(80) fnametheta
74 character*(80) fnamesalt
75
76 logical doglobalread
77 logical ladinit
78
79 character*(MAX_LEN_MBUF) msgbuf
80
81 c == external functions ==
82
83 integer ilnblnk
84 external ilnblnk
85
86 c == end of interface ==
87
88 jtlo = mybylo(mythid)
89 jthi = mybyhi(mythid)
90 itlo = mybxlo(mythid)
91 ithi = mybxhi(mythid)
92 jmin = 1
93 jmax = sny
94 imin = 1
95 imax = snx
96
97 c-- Read tiled data.
98 doglobalread = .false.
99 ladinit = .false.
100
101 #ifdef ALLOW_DRIFT_COST_CONTRIBUTION
102
103 #ifdef ECCO_VERBOSE
104 _BEGIN_MASTER( mythid )
105 write(msgbuf,'(a)') ' '
106 call print_message( msgbuf, standardmessageunit,
107 & SQUEEZE_RIGHT , mythid)
108 write(msgbuf,'(a,i8.8)')
109 & ' cost_Theta: 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 _END_MASTER( mythid )
116 #endif
117
118 if (optimcycle .ge. 0) then
119 iltheta = ilnblnk( tbarfile )
120 write(fnametheta(1:80),'(2a,i10.10)')
121 & tbarfile(1:iltheta),'.',optimcycle
122
123 ilsalt = ilnblnk( sbarfile )
124 write(fnamesalt(1:80),'(2a,i10.10)')
125 & sbarfile(1:ilsalt),'.',optimcycle
126 endif
127
128 if (nmonsrec.lt.12) then
129 print*
130 print*,' cost_Drift: assimilation period smaller'
131 print*,' than 1 year, no drift computed.'
132 print*
133 stop ' ... stopped in cost_Drift.'
134 endif
135
136 fcthread_tdrift = 0. _d 0
137 fcthread_tdrifs = 0. _d 0
138
139 do bj = jtlo,jthi
140 do bi = itlo,ithi
141 do k = 1,nr
142 do j = jmin,jmax
143 do i = imin,imax
144 Tfmean(i,j,k,bi,bj) = 0.0
145 Sfmean(i,j,k,bi,bj) = 0.0
146 Tlmean(i,j,k,bi,bj) = 0.0
147 Slmean(i,j,k,bi,bj) = 0.0
148 enddo
149 enddo
150 enddo
151 enddo
152 enddo
153
154 nf = 0
155 nl = 0
156
157 c-- Loop over records.
158 do irec = 1,12
159
160 c-- Read time averages and the monthly mean data.
161 call active_read_xyz( fnametheta, tbar, irec,
162 & doglobalread, ladinit,
163 & optimcycle, mythid,
164 & xx_tbar_mean_dummy )
165
166 call active_read_xyz( fnamesalt, sbar, irec,
167 & doglobalread, ladinit,
168 & optimcycle, mythid,
169 & xx_sbar_mean_dummy )
170
171 nf = nf + 1
172 do bj = jtlo,jthi
173 do bi = itlo,ithi
174 do k = 1,nr
175 do j = jmin,jmax
176 do i = imin,imax
177 Tfmean(i,j,k,bi,bj) = Tfmean(i,j,k,bi,bj) +
178 & tbar(i,j,k,bi,bj)
179 Sfmean(i,j,k,bi,bj) = Sfmean(i,j,k,bi,bj) +
180 & sbar(i,j,k,bi,bj)
181 enddo
182 enddo
183 enddo
184 enddo
185 enddo
186
187 enddo
188
189 do irec = nmonsrec-12+1, nmonsrec
190
191 c-- Read time averages and the monthly mean data.
192 call active_read_xyz( fnametheta, tbar, irec,
193 & doglobalread, ladinit,
194 & optimcycle, mythid,
195 & xx_tbar_mean_dummy )
196
197 call active_read_xyz( fnamesalt, sbar, irec,
198 & doglobalread, ladinit,
199 & optimcycle, mythid,
200 & xx_sbar_mean_dummy )
201
202 nl = nl + 1
203
204 do bj = jtlo,jthi
205 do bi = itlo,ithi
206 do k = 1,nr
207 do j = jmin,jmax
208 do i = imin,imax
209 Tlmean(i,j,k,bi,bj) = Tlmean(i,j,k,bi,bj) +
210 & tbar(i,j,k,bi,bj)
211 Slmean(i,j,k,bi,bj) = Slmean(i,j,k,bi,bj) +
212 & sbar(i,j,k,bi,bj)
213 enddo
214 enddo
215 enddo
216 enddo
217 enddo
218
219 enddo
220
221
222 do bj = jtlo,jthi
223 do bi = itlo,ithi
224
225 c-- Loop over the model layers
226 fctiles = 0. _d 0
227 fctilet = 0. _d 0
228
229 do k = 1,nr
230
231 c-- Compute model misfit and cost function term for
232 c the temperature field.
233 do j = jmin,jmax
234 do i = imin,imax
235 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
236 fctiles = fctiles +
237 & (wsalt(k,bi,bj)*cosphi(i,j,bi,bj)*2.5*
238 & (Slmean(i,j,k,bi,bj)/nl - Sfmean(i,j,k,bi,bj)/nf)*
239 & (Slmean(i,j,k,bi,bj)/nl - Sfmean(i,j,k,bi,bj)/nf))
240 &
241 fctilet = fctilet +
242 & (wtheta(k,bi,bj)*cosphi(i,j,bi,bj)*2.5*
243 & (Tlmean(i,j,k,bi,bj)/nl - Tfmean(i,j,k,bi,bj)/nf)*
244 & (Tlmean(i,j,k,bi,bj)/nl - Tfmean(i,j,k,bi,bj)/nf))
245 endif
246 enddo
247 enddo
248
249 enddo
250 c-- End of loop over layers.
251
252 fcthread_tdrift = fcthread_tdrift + fctilet
253 fcthread_tdrifs = fcthread_tdrifs + fctiles
254 objf_tdrift(bi,bj) = objf_tdrift(bi,bj) + fctilet
255 objf_sdrift(bi,bj) = objf_sdrift(bi,bj) + fctiles
256
257 #ifdef ECCO_VERBOSE
258 c-- Print cost function for each tile in each thread.
259 write(msgbuf,'(a)') ' '
260 call print_message( msgbuf, standardmessageunit,
261 & SQUEEZE_RIGHT , mythid)
262 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
263 & ' cost_Drift: irec,bi,bj = ',irec,bi,bj
264 call print_message( msgbuf, standardmessageunit,
265 & SQUEEZE_RIGHT , mythid)
266 write(msgbuf,'(a,d22.15)')
267 & ' cost function (temperature) = ',
268 & fctilet+fctiles
269 call print_message( msgbuf, standardmessageunit,
270 & SQUEEZE_RIGHT , mythid)
271 write(msgbuf,'(a)') ' '
272 call print_message( msgbuf, standardmessageunit,
273 & SQUEEZE_RIGHT , mythid)
274 #endif
275
276 enddo
277 enddo
278
279 #ifdef ECCO_VERBOSE
280 c-- Print cost function for all tiles.
281 c _GLOBAL_SUM_R8( fcthread_tdrift , myThid )
282 c _GLOBAL_SUM_R8( fcthread_tdrifs , myThid )
283 write(msgbuf,'(a)') ' '
284 call print_message( msgbuf, standardmessageunit,
285 & SQUEEZE_RIGHT , mythid)
286 write(msgbuf,'(a,i8.8)')
287 & ' cost_Drift: irec = ',irec
288 call print_message( msgbuf, standardmessageunit,
289 & SQUEEZE_RIGHT , mythid)
290 write(msgbuf,'(a,a,d22.15)')
291 & ' global cost function value',
292 & ' (temp + salt) = ',fcthread_tdrift+fcthread_tdrifs
293 call print_message( msgbuf, standardmessageunit,
294 & SQUEEZE_RIGHT , mythid)
295 write(msgbuf,'(a)') ' '
296 call print_message( msgbuf, standardmessageunit,
297 & SQUEEZE_RIGHT , mythid)
298 #endif
299
300 #else
301 c-- Do not enter the calculation of the drift contribution to
302 c-- the final cost function.
303
304 _BEGIN_MASTER( mythid )
305 write(msgbuf,'(a)') ' '
306 call print_message( msgbuf, standardmessageunit,
307 & SQUEEZE_RIGHT , mythid)
308 write(msgbuf,'(a,a)')
309 & ' cost_Drift: no contribution of drift between the first ',
310 & 'and the last year to cost function.'
311 call print_message( msgbuf, standardmessageunit,
312 & SQUEEZE_RIGHT , mythid)
313 write(msgbuf,'(a,a,i9.8)')
314 & ' cost_Drift: number of records that would have',
315 & ' been processed: ',nmonsrec
316 call print_message( msgbuf, standardmessageunit,
317 & SQUEEZE_RIGHT , mythid)
318 write(msgbuf,'(a)') ' '
319 call print_message( msgbuf, standardmessageunit,
320 & SQUEEZE_RIGHT , mythid)
321 _END_MASTER( mythid )
322 #endif
323
324 return
325 end
326

  ViewVC Help
Powered by ViewVC 1.1.22