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

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

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


Revision 1.8 - (show annotations) (download)
Tue May 24 20:45:48 2011 UTC (13 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63p, checkpoint63q, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint63, checkpoint62z, checkpoint62y
Changes since 1.7: +4 -15 lines
split "OBCS.h" into 4 separated header files (OBCS_PARAMS,GRID,FIELDS,SEAICE)

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_obcsvol.F,v 1.7 2011/03/14 17:31:37 mlosch Exp $
2 C $Name: $
3
4 #include "COST_CPPOPTIONS.h"
5
6 subroutine cost_obcsvol(
7 I myiter,
8 I mytime,
9 I startrec,
10 I endrec,
11 I mythid
12 & )
13
14 c ==================================================================
15 c SUBROUTINE cost_obcsvol
16 c ==================================================================
17 c
18 c o cost function contribution obc -- Volume flux imbalance.
19 c
20 c ==================================================================
21 c SUBROUTINE cost_obcsvol
22 c ==================================================================
23
24 implicit none
25
26 c == global variables ==
27
28 #include "EEPARAMS.h"
29 #include "SIZE.h"
30 #include "PARAMS.h"
31 #include "GRID.h"
32 CML#include "DYNVARS.h"
33 #ifdef ALLOW_OBCS
34 c# include "OBCS_PARAMS.h"
35 # include "OBCS_GRID.h"
36 #endif
37
38 #include "cal.h"
39 #include "ecco_cost.h"
40 #include "ctrl.h"
41 #include "ctrl_dummy.h"
42 #include "optim.h"
43
44 c == routine arguments ==
45
46 integer myiter
47 _RL mytime
48 integer mythid
49 integer startrec
50 integer endrec
51
52 c == local variables ==
53
54 integer bi,bj
55 integer i,j,k
56 integer itlo,ithi
57 integer jtlo,jthi
58 integer jmin,jmax
59 integer imin,imax
60 integer irec
61 integer iobcs
62 integer nrec
63 integer ilfld
64 integer igg
65
66 _RL fctile
67 _RL sumvol
68 _RL gg
69 _RL tmpx
70 _RL tmpy
71 _RL wobcsvol
72 character*(80) fnamefldn
73 character*(80) fnameflds
74 character*(80) fnamefldw
75 character*(80) fnameflde
76
77 #if (defined ALLOW_OBCSN_CONTROL || defined ALLOW_OBCSS_CONTROL)
78 _RL tmpfldxz (1-olx:snx+olx,nr,nsx,nsy)
79 #endif
80 #if (defined ALLOW_OBCSE_CONTROL || defined ALLOW_OBCSW_CONTROL)
81 _RL tmpfldyz (1-oly:sny+oly,nr,nsx,nsy)
82 #endif
83
84 logical doglobalread
85 logical ladinit
86
87 #ifdef ECCO_VERBOSE
88 character*(MAX_LEN_MBUF) msgbuf
89 #endif
90
91 c == external functions ==
92
93 integer ilnblnk
94 external ilnblnk
95
96 c == end of interface ==
97
98 #ifdef OBCS_VOLFLUX_COST_CONTRIBUTION
99 #ifdef BAROTROPIC_OBVEL_CONTROL
100
101 stop 's/r cost_obcsvol needs to be fixed'
102
103 jtlo = mybylo(mythid)
104 jthi = mybyhi(mythid)
105 itlo = mybxlo(mythid)
106 ithi = mybxhi(mythid)
107 jmin = 1
108 jmax = sny
109 imin = 1
110 imax = snx
111
112 c-- Read tiled data.
113 doglobalread = .false.
114 ladinit = .false.
115
116 cgg Assume the number of records is the same for
117 cgg all boundaries.
118 c Number of records to be used.
119 nrec = endrec-startrec+1
120
121 sumvol = 0. _d 0
122 wobcsvol = .01
123 cgg Acceptable volume flux is 10^-3. Corresponds to 5 mm change over a year.
124 cgg Added a factor of 1000 because its very important to me.
125 wobcsvol = 1./(wobcsvol * wobcsvol)
126
127 #ifdef ECCO_VERBOSE
128 _BEGIN_MASTER( mythid )
129 write(msgbuf,'(a)') ' '
130 call print_message( msgbuf, standardmessageunit,
131 & SQUEEZE_RIGHT , mythid)
132 write(msgbuf,'(a)') ' '
133 call print_message( msgbuf, standardmessageunit,
134 & SQUEEZE_RIGHT , mythid)
135 write(msgbuf,'(a,i9.8)')
136 & ' cost_obcsvol: number of records to process: ',nrec
137 call print_message( msgbuf, standardmessageunit,
138 & SQUEEZE_RIGHT , mythid)
139 write(msgbuf,'(a)') ' '
140 call print_message( msgbuf, standardmessageunit,
141 & SQUEEZE_RIGHT , mythid)
142 _END_MASTER( mythid )
143 #endif
144
145 if (optimcycle .ge. 0) then
146 #ifdef ALLOW_OBCSN_CONTROL
147 ilfld=ilnblnk( xx_obcsn_file )
148 write(fnamefldn(1:80),'(2a,i10.10)')
149 & xx_obcsn_file(1:ilfld),'.', optimcycle
150 #endif
151 #ifdef ALLOW_OBCSS_CONTROL
152 ilfld=ilnblnk( xx_obcss_file )
153 write(fnameflds(1:80),'(2a,i10.10)')
154 & xx_obcss_file(1:ilfld),'.',optimcycle
155 #endif
156 #ifdef ALLOW_OBCSW_CONTROL
157 ilfld=ilnblnk( xx_obcsw_file )
158 write(fnamefldw(1:80),'(2a,i10.10)')
159 & xx_obcsw_file(1:ilfld),'.',optimcycle
160 #endif
161 #ifdef ALLOW_OBCSE_CONTROL
162 ilfld=ilnblnk( xx_obcse_file )
163 write(fnameflde(1:80),'(2a,i10.10)')
164 & xx_obcse_file(1:ilfld),'.',optimcycle
165 #endif
166 else
167 print*
168 print*,' obcs_obcsvol: optimcycle has a wrong value.'
169 print*,' optimcycle = ',optimcycle
170 print*
171 stop ' ... stopped in obcs_obcsvol.'
172 endif
173
174 do irec = 1,nrec
175 c-- Loop over records. For north boundary, we only need V velocity.
176
177 cgg Need to solve for iobcs. Then only keep iobcs=3.or.4.
178 gg = (irec-1)/nobcs
179 igg = int(gg)
180 iobcs = irec - igg*nobcs
181
182 #ifdef ALLOW_OBCSN_CONTROL
183 cgg Assume that nobcs=4, and V velocity is the 4th record. I cannot
184 cgg think of a more general way to do this.
185 if (iobcs.eq.4) then
186 call active_read_xz( fnamefldn, tmpfldxz, irec, doglobalread,
187 & ladinit, optimcycle, mythid
188 & , xx_obcsn_dummy )
189
190 cgg At this point, do not be concerned with the overlap halos.
191 cgg From experience, there is no control contribution in the
192 cgg velocity points outside the boundaries. This has something
193 cgg to do with the computational stencil, and the fact that we
194 cgg are diagonally offset. Could check later by employing both
195 cgg BALANCE_CONTROL_VOLFLUX and VOLFLUX_COST_CONTRIBUTION.
196 cgg
197 cgg 25-jan-03 --- no idea what i was talking about ^^^^
198 c-- Loop over this thread tiles.
199 do bj = jtlo,jthi
200 do bi = itlo,ithi
201
202 c-- Determine the weights to be used.
203 fctile = 0. _d 0
204
205 do k = 1, Nr
206 do i = imin,imax
207 j = OB_Jn(I,bi,bj)
208 cgg Barotropic velocity is stored in level 1.
209 tmpx = tmpfldxz(i,1,bi,bj)
210 if (maskS(i,j,k,bi,bj) .ne. 0.) then
211 cgg -- Positive is flux in.
212 fctile = fctile - tmpx* drF(k) *dxg(i,j,bi,bj)
213 & * _hFacS(i,j,k,bi,bj)
214 endif
215 enddo
216 enddo
217
218 sumvol = sumvol + fctile
219 enddo
220 enddo
221 endif
222 #endif
223
224 #ifdef ALLOW_OBCSS_CONTROL
225 cgg Assume that nobcs=4, and V velocity is the 4th record. I cannot
226 cgg think of a more general way to do this.
227 if (iobcs.eq.4) then
228 call active_read_xz( fnameflds, tmpfldxz, irec, doglobalread,
229 & ladinit, optimcycle, mythid
230 & , xx_obcss_dummy )
231
232 cgg At this point, do not be concerned with the overlap halos.
233 cgg From experience, there is no control contribution in the
234 cgg velocity points outside the boundaries. This has something
235 cgg to do with the computational stencil, and the fact that we
236 cgg are diagonally offset. Could check later by employing both
237 cgg BALANCE_CONTROL_VOLFLUX and VOLFLUX_COST_CONTRIBUTION.
238
239 c-- Loop over this thread tiles.
240 do bj = jtlo,jthi
241 do bi = itlo,ithi
242
243 c-- Determine the weights to be used.
244 fctile = 0. _d 0
245
246 do k = 1, Nr
247 do i = imin,imax
248 j = OB_Js(I,bi,bj)
249 cgg Barotropic velocity is stored in level 1.
250 tmpx = tmpfldxz(i,1,bi,bj)
251 if (maskS(i,j+1,k,bi,bj) .ne. 0.) then
252 cgg -- Positive is flux in.
253 fctile = fctile + tmpx* drF(k) *dxg(i,j+1,bi,bj)
254 & * _hFacS(i,j+1,k,bi,bj)
255 endif
256 enddo
257 enddo
258
259 sumvol = sumvol + fctile
260 enddo
261 enddo
262 endif
263
264 #endif
265
266 #ifdef ALLOW_OBCSW_CONTROL
267 cgg Assume that nobcs=4, and V velocity is the 4th record. I cannot
268 cgg think of a more general way to do this.
269 if (iobcs.eq.3) then
270 call active_read_yz( fnamefldw, tmpfldyz, irec, doglobalread,
271 & ladinit, optimcycle, mythid
272 & , xx_obcsw_dummy )
273
274 cgg At this point, do not be concerned with the overlap halos.
275 cgg From experience, there is no control contribution in the
276 cgg velocity points outside the boundaries. This has something
277 cgg to do with the computational stencil, and the fact that we
278 cgg are diagonally offset. Could check later by employing both
279 cgg BALANCE_CONTROL_VOLFLUX and VOLFLUX_COST_CONTRIBUTION.
280
281 c-- Loop over this thread tiles.
282 do bj = jtlo,jthi
283 do bi = itlo,ithi
284
285 c-- Determine the weights to be used.
286 fctile = 0. _d 0
287
288 do k = 1, Nr
289 do j = jmin,jmax
290 i = OB_Iw(j,bi,bj)
291 cgg Barotropic velocity is stored in the level 1.
292 tmpy = tmpfldyz(j,1,bi,bj)
293 if (maskW(i+1,j,k,bi,bj) .ne. 0.) then
294 cgg -- Positive is flux in.
295 fctile = fctile + tmpy* drF(k) *dyg(i+1,j,bi,bj)
296 & * _hFacW(i+1,j,k,bi,bj)
297 endif
298 enddo
299 enddo
300
301 sumvol = sumvol + fctile
302 enddo
303 enddo
304 endif
305
306 #endif
307
308 #ifdef ALLOW_OBCSE_CONTROL
309 cgg Assume that nobcs=4, and V velocity is the 4th record. I cannot
310 cgg think of a more general way to do this.
311 if (iobcs.eq.3) then
312 call active_read_yz( fnameflde, tmpfldyz, irec, doglobalread,
313 & ladinit, optimcycle, mythid
314 & , xx_obcse_dummy )
315
316 cgg At this point, do not be concerned with the overlap halos.
317 cgg From experience, there is no control contribution in the
318 cgg velocity points outside the boundaries. This has something
319 cgg to do with the computational stencil, and the fact that we
320 cgg are diagonally offset. Could check later by employing both
321 cgg BALANCE_CONTROL_VOLFLUX and VOLFLUX_COST_CONTRIBUTION.
322
323 c-- Loop over this thread tiles.
324 do bj = jtlo,jthi
325 do bi = itlo,ithi
326
327 c-- Determine the weights to be used.
328 fctile = 0. _d 0
329
330 do k = 1, Nr
331 do j = jmin,jmax
332 i = OB_Ie(j,bi,bj)
333 cgg Barotropic velocity stored in level 1.
334 tmpy = tmpfldyz(j,1,bi,bj)
335 if (maskW(i,j,k,bi,bj) .ne. 0.) then
336 cgg -- Positive is flux in.
337 fctile = fctile - tmpy* drF(k) *dyg(i,j,bi,bj)
338 & * _hFacW(i,j,k,bi,bj)
339 endif
340 enddo
341 enddo
342
343 sumvol = sumvol + fctile
344 enddo
345 enddo
346 endif
347
348 #endif
349
350 enddo
351 c-- End of loop over records.
352
353 c-- Do the global summation.
354 _GLOBAL_SUM_RL( sumvol, mythid )
355 objf_obcsvol = wobcsvol * sumvol* sumvol
356
357 #endif
358 #endif
359
360 return
361 end

  ViewVC Help
Powered by ViewVC 1.1.22