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

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

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


Revision 1.1 - (show annotations) (download)
Thu Nov 6 22:10:07 2003 UTC (20 years, 6 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, branch-netcdf, checkpoint52d_pre, checkpoint52l_post, checkpoint52k_post, checkpoint52b_pre, checkpoint54b_post, checkpoint53b_pre, checkpoint55b_post, checkpoint54d_post, checkpoint53f_post, checkpoint52m_post, checkpoint55, checkpoint53a_post, checkpoint54, checkpoint54f_post, checkpoint53b_post, checkpoint53, checkpoint52, checkpoint52d_post, checkpoint52a_post, checkpoint52b_post, checkpoint53g_post, checkpoint52f_post, checkpoint52c_post, ecco_c52_e35, hrcube5, checkpoint52a_pre, checkpoint52i_post, checkpoint55a_post, checkpoint53d_pre, checkpoint54c_post, checkpoint52i_pre, checkpoint51u_post, checkpoint52h_pre, checkpoint52f_pre, hrcube_2, hrcube_3
Branch point for: netcdf-sm0
o merging from ecco-branch
o pkg/ecco now containes ecco-specific part of cost function
o top level routines the_main_loop, forward_step
  supersede those in model/src/
  previous input data.cost now in data.ecco
  (new namelist ecco_cost_nml)

1 C $Header: /u/gcmpack/MITgcm/pkg/cost/Attic/cost_driftw.F,v 1.1.2.2 2003/06/19 15:21:16 heimbach Exp $
2
3 #include "COST_CPPOPTIONS.h"
4
5
6 subroutine cost_driftw(
7 I myiter,
8 I mytime,
9 I mythid
10 & )
11
12 c ==================================================================
13 c SUBROUTINE cost_Driftw
14 c ==================================================================
15 c
16 c o Evaluate cost function contribution of the w difference
17 c between the first and the last year.
18 c
19 c started: from cost_drift
20 c
21 c Armin Koehl akoehl@ucsd.edu 26-Feb-2002
22 c
23 c heimbach@mit.edu 17-Jun-2003 SIO merge:
24 c changed 1e12*cosphi(i,j,bi,bj) factor to
25 c 2.5e11*cosphi(i,j,bi,bj)
26 c
27 c ==================================================================
28 c SUBROUTINE cost_Driftw
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 ilw
65 integer nf, nl
66
67 _RL fctilew
68 _RL fcthread_wdrift
69
70 character*(80) fnamew
71
72 logical doglobalread
73 logical ladinit
74
75 character*(MAX_LEN_MBUF) msgbuf
76
77 c == external functions ==
78
79 integer ilnblnk
80 external ilnblnk
81
82 c == end of interface ==
83
84 jtlo = mybylo(mythid)
85 jthi = mybyhi(mythid)
86 itlo = mybxlo(mythid)
87 ithi = mybxhi(mythid)
88 jmin = 1
89 jmax = sny
90 imin = 1
91 imax = snx
92
93 c-- Read tiled data.
94 doglobalread = .false.
95 ladinit = .false.
96
97 #ifdef ALLOW_DRIFTW_COST_CONTRIBUTION
98
99 #ifdef ECCO_VERBOSE
100 _BEGIN_MASTER( mythid )
101 write(msgbuf,'(a)') ' '
102 call print_message( msgbuf, standardmessageunit,
103 & SQUEEZE_RIGHT , mythid)
104 write(msgbuf,'(a,i8.8)')
105 & ' cost_driftw: number of records to process = ',nmonsrec
106 call print_message( msgbuf, standardmessageunit,
107 & SQUEEZE_RIGHT , mythid)
108 write(msgbuf,'(a)') ' '
109 call print_message( msgbuf, standardmessageunit,
110 & SQUEEZE_RIGHT , mythid)
111 _END_MASTER( mythid )
112 #endif
113
114 if (optimcycle .ge. 0) then
115 ilw = ilnblnk( wbarfile )
116 write(fnamew(1:80),'(2a,i10.10)')
117 & wbarfile(1:ilw),'.',optimcycle
118 endif
119
120 if (nmonsrec.lt.12) then
121 print*
122 print*,' cost_Driftw: assimilation period smaller'
123 print*,' than 1 year, no drift computed.'
124 print*
125 stop ' ... stopped in cost_Driftw.'
126 endif
127
128 fcthread_wdrift = 0. _d 0
129
130 do bj = jtlo,jthi
131 do bi = itlo,ithi
132 do k = 1,nr
133 do j = jmin,jmax
134 do i = imin,imax
135 wfmean(i,j,k,bi,bj) = 0.0
136 wlmean(i,j,k,bi,bj) = 0.0
137 enddo
138 enddo
139 enddo
140 enddo
141 enddo
142
143 nf = 0
144 nl = 0
145
146 c-- Loop over records.
147 do irec = 1,12
148
149 c-- Read time averages and the monthly mean data.
150 call active_read_xyz( fnamew, wbar, irec,
151 & doglobalread, ladinit,
152 & optimcycle, mythid,
153 & xx_wbar_mean_dummy )
154
155 nf = nf + 1
156 do bj = jtlo,jthi
157 do bi = itlo,ithi
158 do k = 1,nr
159 do j = jmin,jmax
160 do i = imin,imax
161 wfmean(i,j,k,bi,bj) = wfmean(i,j,k,bi,bj) +
162 & wbar(i,j,k,bi,bj)
163 enddo
164 enddo
165 enddo
166 enddo
167 enddo
168
169 enddo
170
171 do irec = nmonsrec-12+1, nmonsrec
172
173 c-- Read time averages and the monthly mean data.
174 call active_read_xyz( fnamew, wbar, irec,
175 & doglobalread, ladinit,
176 & optimcycle, mythid,
177 & xx_wbar_mean_dummy )
178
179 nl = nl + 1
180
181 do bj = jtlo,jthi
182 do bi = itlo,ithi
183 do k = 1,nr
184 do j = jmin,jmax
185 do i = imin,imax
186 wlmean(i,j,k,bi,bj) = wlmean(i,j,k,bi,bj) +
187 & wbar(i,j,k,bi,bj)
188 enddo
189 enddo
190 enddo
191 enddo
192 enddo
193
194 enddo
195
196
197 do bj = jtlo,jthi
198 do bi = itlo,ithi
199
200 c-- Loop over the model layers
201 fctilew = 0. _d 0
202
203 do k = 1,nr
204
205 c-- Compute model misfit and cost function term for
206 c the vertical velovity field. The error is 1e-4 m/s.
207 do j = jmin,jmax
208 do i = imin,imax
209 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
210 fctilew = fctilew +
211 & (2.5e11*cosphi(i,j,bi,bj)*
212 & (wlmean(i,j,k,bi,bj)/nl - wfmean(i,j,k,bi,bj)/nf)*
213 & (wlmean(i,j,k,bi,bj)/nl - wfmean(i,j,k,bi,bj)/nf))
214 endif
215 enddo
216 enddo
217
218 enddo
219 c-- End of loop over layers.
220
221 fcthread_wdrift = fcthread_wdrift + fctilew
222 objf_wdrift(bi,bj) = objf_wdrift(bi,bj) + fctilew
223
224 #ifdef ECCO_VERBOSE
225 c-- Print cost function for each tile in each thread.
226 write(msgbuf,'(a)') ' '
227 call print_message( msgbuf, standardmessageunit,
228 & SQUEEZE_RIGHT , mythid)
229 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
230 & ' cost_Driftw: irec,bi,bj = ',irec,bi,bj
231 call print_message( msgbuf, standardmessageunit,
232 & SQUEEZE_RIGHT , mythid)
233 write(msgbuf,'(a,d22.15)')
234 & ' cost function (wvel) = ',
235 & fctilet+fctiles
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 #endif
242
243 enddo
244 enddo
245
246 #ifdef ECCO_VERBOSE
247 c-- Print cost function for all tiles.
248 _GLOBAL_SUM_R8( fcthread_tdrift , myThid )
249 _GLOBAL_SUM_R8( fcthread_tdrifs , myThid )
250 write(msgbuf,'(a)') ' '
251 call print_message( msgbuf, standardmessageunit,
252 & SQUEEZE_RIGHT , mythid)
253 write(msgbuf,'(a,i8.8)')
254 & ' cost_Drift: irec = ',irec
255 call print_message( msgbuf, standardmessageunit,
256 & SQUEEZE_RIGHT , mythid)
257 write(msgbuf,'(a,a,d22.15)')
258 & ' cost function value',
259 & ' (wvel) = ',fcthread_tdrifw
260 call print_message( msgbuf, standardmessageunit,
261 & SQUEEZE_RIGHT , mythid)
262 write(msgbuf,'(a)') ' '
263 call print_message( msgbuf, standardmessageunit,
264 & SQUEEZE_RIGHT , mythid)
265 #endif
266
267 #else
268 c-- Do not enter the calculation of the drift contribution to
269 c-- the final cost function.
270
271 _BEGIN_MASTER( mythid )
272 write(msgbuf,'(a)') ' '
273 call print_message( msgbuf, standardmessageunit,
274 & SQUEEZE_RIGHT , mythid)
275 write(msgbuf,'(a,a)')
276 & ' cost_Driftw: no contribution of drift between the first ',
277 & 'and the last year to cost function.'
278 call print_message( msgbuf, standardmessageunit,
279 & SQUEEZE_RIGHT , mythid)
280 write(msgbuf,'(a,a,i9.8)')
281 & ' cost_Driftw: number of records that would have',
282 & ' been processed: ',nmonsrec
283 call print_message( msgbuf, standardmessageunit,
284 & SQUEEZE_RIGHT , mythid)
285 write(msgbuf,'(a)') ' '
286 call print_message( msgbuf, standardmessageunit,
287 & SQUEEZE_RIGHT , mythid)
288 _END_MASTER( mythid )
289 #endif
290
291 return
292 end
293

  ViewVC Help
Powered by ViewVC 1.1.22