/[MITgcm]/MITgcm/pkg/ctrl/ctrl_init_wet.F
ViewVC logotype

Contents of /MITgcm/pkg/ctrl/ctrl_init_wet.F

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


Revision 1.9 - (show annotations) (download)
Mon Mar 22 02:16:43 2010 UTC (14 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t
Changes since 1.8: +2 -2 lines
finish removing unbalanced quote (single or double) in commented line

1 C
2 C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_init_wet.F,v 1.8 2008/04/19 18:02:16 heimbach Exp $
3 C $Name: $
4
5 #include "CTRL_CPPOPTIONS.h"
6
7 subroutine ctrl_init_wet( mythid )
8
9 c ==================================================================
10 c SUBROUTINE ctrl_init_wet
11 c ==================================================================
12
13 implicit none
14
15 c == global variables ==
16
17 #include "EEPARAMS.h"
18 #include "SIZE.h"
19 #include "PARAMS.h"
20 #include "GRID.h"
21 #include "ctrl.h"
22
23 #ifdef ALLOW_OBCS_CONTROL
24 # include "OBCS.h"
25 #endif
26
27 c == routine arguments ==
28
29 integer mythid
30
31 c == local variables ==
32
33 integer bi,bj
34 integer i,j,k
35 integer itlo,ithi
36 integer jtlo,jthi
37 integer jmin,jmax
38 integer imin,imax
39 integer ntmp
40 integer ntmp2(4)
41 integer iobcs
42 integer nwetc3d
43 integer nwettmp
44 #ifdef ALLOW_OBCS_CONTROL
45 integer ntmpob(nobcs)
46 #endif
47 _RL dummy
48
49 character*(80) ymaskobcs
50 character*(max_len_mbuf) msgbuf
51
52 c-- Set loop ranges.
53 jtlo = mybylo(mythid)
54 jthi = mybyhi(mythid)
55 itlo = mybxlo(mythid)
56 ithi = mybxhi(mythid)
57 jmin = 1
58 jmax = sny
59 imin = 1
60 imax = snx
61
62 c-- Determine the number of wet points in each tile:
63 c-- maskc, masks, and maskw.
64
65 c-- Initialise the counters.
66 do bj = jtlo,jthi
67 do bi = itlo,ithi
68 do k = 1,nr
69 nwetctile(bi,bj,k) = 0
70 nwetstile(bi,bj,k) = 0
71 nwetwtile(bi,bj,k) = 0
72 nwetvtile(bi,bj,k) = 0
73 enddo
74 enddo
75 enddo
76
77 #ifdef ALLOW_OBCS_CONTROL
78 c-- Initialise obcs counters.
79 do bj = jtlo,jthi
80 do bi = itlo,ithi
81 do k = 1,nr
82 do iobcs = 1,nobcs
83 #ifdef ALLOW_OBCSN_CONTROL
84 nwetobcsn(bi,bj,k,iobcs) = 0
85 #endif
86 #ifdef ALLOW_OBCSS_CONTROL
87 nwetobcss(bi,bj,k,iobcs) = 0
88 #endif
89 #ifdef ALLOW_OBCSW_CONTROL
90 nwetobcsw(bi,bj,k,iobcs) = 0
91 #endif
92 #ifdef ALLOW_OBCSE_CONTROL
93 nwetobcse(bi,bj,k,iobcs) = 0
94 #endif
95 enddo
96 enddo
97 enddo
98 enddo
99 #endif
100
101 c-- Count wet points on each tile.
102 do bj = jtlo,jthi
103 do bi = itlo,ithi
104 do k = 1,nr
105 do j = jmin,jmax
106 do i = imin,imax
107 c-- Center mask.
108 if (hFacC(i,j,k,bi,bj) .ne. 0.) then
109 nwetctile(bi,bj,k) = nwetctile(bi,bj,k) + 1
110 endif
111 c-- South mask.
112 if (maskS(i,j,k,bi,bj) .eq. 1.) then
113 nwetstile(bi,bj,k) = nwetstile(bi,bj,k) + 1
114 endif
115 c-- West mask.
116 if (maskW(i,j,k,bi,bj) .eq. 1.) then
117 nwetwtile(bi,bj,k) = nwetwtile(bi,bj,k) + 1
118 endif
119 #if (defined (ALLOW_EFLUXP0_CONTROL))
120 c-- Vertical mask.
121 if (hFacV(i,j,k,bi,bj) .ne. 0.) then
122 nwetvtile(bi,bj,k) = nwetvtile(bi,bj,k) + 1
123 endif
124 #endif
125 enddo
126 enddo
127 enddo
128 enddo
129 enddo
130
131 #ifdef ALLOW_OBCSN_CONTROL
132 c-- Count wet points at Northern boundary.
133 c-- mask conventions are adopted from obcs_apply_ts, obcs_apply_uv
134 ymaskobcs = 'maskobcsn'
135 call ctrl_mask_set_xz( 0, OB_Jn, nwetobcsn, ymaskobcs, mythid )
136 #endif
137
138 #ifdef ALLOW_OBCSS_CONTROL
139 c-- Count wet points at Southern boundary.
140 c-- mask conventions are adopted from obcs_apply_ts, obcs_apply_uv
141 ymaskobcs = 'maskobcss'
142 call ctrl_mask_set_xz( 1, OB_Js, nwetobcss, ymaskobcs, mythid )
143 #endif
144
145 #ifdef ALLOW_OBCSW_CONTROL
146 c-- Count wet points at Western boundary.
147 c-- mask conventions are adopted from obcs_apply_ts, obcs_apply_uv
148 ymaskobcs = 'maskobcsw'
149 call ctrl_mask_set_yz( 1, OB_Iw, nwetobcsw, ymaskobcs, mythid )
150 #endif
151
152 #ifdef ALLOW_OBCSE_CONTROL
153 c-- Count wet points at Eastern boundary.
154 c-- mask conventions are adopted from obcs_apply_ts, obcs_apply_uv
155 ymaskobcs = 'maskobcse'
156 call ctrl_mask_set_yz( 0, OB_Ie, nwetobcse, ymaskobcs, mythid )
157 #endif
158
159 _BEGIN_MASTER( mythid )
160 c-- Determine the total number of control variables.
161 nvartype = 0
162 nvarlength = 0
163 do i = 1,maxcvars
164 c
165 if ( ncvarindex(i) .ne. -1 ) then
166 nvartype = nvartype + 1
167 do bj = jtlo,jthi
168 do bi = itlo,ithi
169 do k = 1,ncvarnrmax(i)
170 if ( ncvargrd(i) .eq. 'c' ) then
171 nvarlength = nvarlength +
172 & ncvarrecs(i)*nwetctile(bi,bj,k)
173 else if ( ncvargrd(i) .eq. 's' ) then
174 nvarlength = nvarlength +
175 & ncvarrecs(i)*nwetstile(bi,bj,k)
176 else if ( ncvargrd(i) .eq. 'w' ) then
177 nvarlength = nvarlength +
178 & ncvarrecs(i)*nwetwtile(bi,bj,k)
179 else if ( ncvargrd(i) .eq. 'v' ) then
180 nvarlength = nvarlength +
181 & ncvarrecs(i)*nwetvtile(bi,bj,k)
182 else if ( ncvargrd(i) .eq. 'm' ) then
183 #ifdef ALLOW_OBCS_CONTROL
184 do iobcs = 1, nobcs
185 cgg This overcounts the number of o.b. control points by a factor of "nobcs".
186 cgg As an ad-hoc solution I have divided by nobcs everywhere.
187 if ( i .eq. 11 ) then
188 #ifdef ALLOW_OBCSN_CONTROL
189 nvarlength = nvarlength +
190 & (ncvarrecs(i)/nobcs)
191 & *nwetobcsn(bi,bj,k,iobcs)
192 #endif
193 else if ( i .eq. 12 ) then
194 #ifdef ALLOW_OBCSS_CONTROL
195 nvarlength = nvarlength +
196 & (ncvarrecs(i)/nobcs)
197 & *nwetobcss(bi,bj,k,iobcs)
198 #endif
199 else if ( i .eq. 13 ) then
200 #ifdef ALLOW_OBCSW_CONTROL
201 nvarlength = nvarlength +
202 & (ncvarrecs(i)/nobcs)
203 & *nwetobcsw(bi,bj,k,iobcs)
204 #endif
205 else if ( i .eq. 14 ) then
206 #ifdef ALLOW_OBCSE_CONTROL
207 nvarlength = nvarlength +
208 & (ncvarrecs(i)/nobcs)
209 & *nwetobcse(bi,bj,k,iobcs)
210 #endif
211 end if
212 enddo
213 #endif
214 else
215 print*,'ctrl_init: invalid grid location'
216 print*,' control variable = ',ncvarindex(i)
217 print*,' grid location = ',ncvargrd(i)
218 stop ' ... stopped in ctrl_init'
219 endif
220 enddo
221 enddo
222 enddo
223 endif
224 enddo
225
226 cph(
227 write(msgbuf,'(a,2x,I10)')
228 & 'ctrl-wet 1: nvarlength = ', nvarlength
229 call print_message( msgbuf, standardmessageunit,
230 & SQUEEZE_RIGHT , mythid)
231 write(msgbuf,'(a,2x,I10)')
232 & 'ctrl-wet 2: surface wet C = ', nwetctile(1,1,1)
233 call print_message( msgbuf, standardmessageunit,
234 & SQUEEZE_RIGHT , mythid)
235 write(msgbuf,'(a,2x,I10)')
236 & 'ctrl-wet 3: surface wet W = ', nwetwtile(1,1,1)
237 call print_message( msgbuf, standardmessageunit,
238 & SQUEEZE_RIGHT , mythid)
239 write(msgbuf,'(a,2x,I10)')
240 & 'ctrl-wet 4: surface wet S = ', nwetstile(1,1,1)
241 call print_message( msgbuf, standardmessageunit,
242 & SQUEEZE_RIGHT , mythid)
243 write(msgbuf,'(a,2x,I10)')
244 & 'ctrl-wet 4a:surface wet V = ', nwetvtile(1,1,1)
245 call print_message( msgbuf, standardmessageunit,
246 & SQUEEZE_RIGHT , mythid)
247
248 nwetc3d = 0
249 do k = 1, Nr
250 nwetc3d = nwetc3d + nwetctile(1,1,k)
251 end do
252 write(msgbuf,'(a,2x,I10)')
253 & 'ctrl-wet 5: 3D wet points = ', nwetc3d
254 call print_message( msgbuf, standardmessageunit,
255 & SQUEEZE_RIGHT , mythid)
256
257 do i = 1, maxcvars
258 write(msgbuf,'(a,2x,I3,2x,I10)')
259 & 'ctrl-wet 6: no recs for i = ', i, ncvarrecs(i)
260 call print_message( msgbuf, standardmessageunit,
261 & SQUEEZE_RIGHT , mythid)
262 end do
263
264 nwettmp =
265 & 2*nwetc3d +
266 & ncvarrecs(3)*nwetctile(1,1,1) +
267 & ncvarrecs(4)*nwetctile(1,1,1) +
268 & ncvarrecs(5)*nwetwtile(1,1,1) +
269 & ncvarrecs(6)*nwetstile(1,1,1)
270 write(msgbuf,'(a,2x,I10)')
271 & 'ctrl-wet 7: flux ', nwettmp
272 call print_message( msgbuf, standardmessageunit,
273 & SQUEEZE_RIGHT , mythid)
274
275 nwettmp =
276 & 2*nwetc3d +
277 & ncvarrecs(7)*nwetctile(1,1,1) +
278 & ncvarrecs(8)*nwetctile(1,1,1) +
279 & ncvarrecs(9)*nwetwtile(1,1,1) +
280 & ncvarrecs(10)*nwetstile(1,1,1)
281 write(msgbuf,'(a,2x,I10)')
282 & 'ctrl-wet 8: atmos ', nwettmp
283 call print_message( msgbuf, standardmessageunit,
284 & SQUEEZE_RIGHT , mythid)
285
286 #ifdef ALLOW_OBCSN_CONTROL
287 write(msgbuf,'(a,2x,4I10)')
288 & 'ctrl-wet 9: surface wet obcsn = '
289 & , nwetobcsn(1,1,1,1), nwetobcsn(1,1,1,2)
290 & , nwetobcsn(1,1,1,3), nwetobcsn(1,1,1,4)
291 call print_message( msgbuf, standardmessageunit,
292 & SQUEEZE_RIGHT , mythid)
293 #endif
294 #ifdef ALLOW_OBCSS_CONTROL
295 write(msgbuf,'(a,2x,4I10)')
296 & 'ctrl-wet 10: surface wet obcss = '
297 & , nwetobcss(1,1,1,1), nwetobcss(1,1,1,2)
298 & , nwetobcss(1,1,1,3), nwetobcss(1,1,1,4)
299 call print_message( msgbuf, standardmessageunit,
300 & SQUEEZE_RIGHT , mythid)
301 #endif
302 #ifdef ALLOW_OBCSW_CONTROL
303 write(msgbuf,'(a,2x,4I10)')
304 & 'ctrl-wet 11: surface wet obcsw = '
305 & , nwetobcsw(1,1,1,1), nwetobcsw(1,1,1,2)
306 & , nwetobcsw(1,1,1,3), nwetobcsw(1,1,1,4)
307 call print_message( msgbuf, standardmessageunit,
308 & SQUEEZE_RIGHT , mythid)
309 #endif
310 #ifdef ALLOW_OBCSE_CONTROL
311 write(msgbuf,'(a,2x,4I10)')
312 & 'ctrl-wet 12: surface wet obcse = '
313 & , nwetobcse(1,1,1,1), nwetobcse(1,1,1,2)
314 & , nwetobcse(1,1,1,3), nwetobcse(1,1,1,4)
315 call print_message( msgbuf, standardmessageunit,
316 & SQUEEZE_RIGHT , mythid)
317 #endif
318 cph)
319
320 write(msgbuf,'(a)')
321 & 'ctrl-wet -------------------------------------------------'
322 call print_message( msgbuf, standardmessageunit,
323 & SQUEEZE_RIGHT , mythid)
324
325 CALL GLOBAL_SUM_INT( nvarlength, myThid )
326
327 write(msgbuf,'(a,2x,I3,2x,I10)')
328 & 'ctrl-wet 13: global nvarlength for Nr =', nr, nvarlength
329 call print_message( msgbuf, standardmessageunit,
330 & SQUEEZE_RIGHT , mythid)
331
332 write(msgbuf,'(a)')
333 & 'ctrl-wet -------------------------------------------------'
334 call print_message( msgbuf, standardmessageunit,
335 & SQUEEZE_RIGHT , mythid)
336
337 c
338 c Summation of wet point counters
339 c
340 do k = 1, nr
341
342 ntmp2(1)=0
343 do bj=1,nSy
344 do bi=1,nSx
345 ntmp2(1)=ntmp2(1)+nWetcTile(bi,bj,k)
346 enddo
347 enddo
348 CALL GLOBAL_SUM_INT( ntmp2(1), myThid )
349 nWetcGlobal(k)=ntmp2(1)
350
351 ntmp2(2)=0
352 do bj=1,nSy
353 do bi=1,nSx
354 ntmp2(2)=ntmp2(2)+nWetsTile(bi,bj,k)
355 enddo
356 enddo
357 CALL GLOBAL_SUM_INT( ntmp2(2), myThid )
358 nWetsGlobal(k)=ntmp2(2)
359
360 ntmp2(3)=0
361 do bj=1,nSy
362 do bi=1,nSx
363 ntmp2(3)=ntmp2(3)+nWetwTile(bi,bj,k)
364 enddo
365 enddo
366 CALL GLOBAL_SUM_INT( ntmp2(3), myThid )
367 nWetwGlobal(k)=ntmp2(3)
368
369 ntmp2(4)=0
370 do bj=1,nSy
371 do bi=1,nSx
372 ntmp2(4)=ntmp2(4)+nWetvTile(bi,bj,k)
373 enddo
374 enddo
375 CALL GLOBAL_SUM_INT( ntmp2(4), myThid )
376 nWetvGlobal(k)=ntmp2(4)
377
378 write(msgbuf,'(a,2x,I3,4(2x,I10))')
379 & 'ctrl-wet 14: global nWet C/S/W/V k=', k, ntmp2
380 call print_message( msgbuf, standardmessageunit,
381 & SQUEEZE_RIGHT , mythid)
382
383 enddo
384
385 write(msgbuf,'(a)')
386 & 'ctrl-wet -------------------------------------------------'
387 call print_message( msgbuf, standardmessageunit,
388 & SQUEEZE_RIGHT , mythid)
389
390 do k = 1, nr
391
392 #ifdef ALLOW_OBCSN_CONTROL
393 do iobcs = 1, nobcs
394 ntmpob(iobcs)=0
395 do bj=1,nSy
396 do bi=1,nSx
397 ntmpob(iobcs)=ntmpob(iobcs)+nwetobcsn(bi,bj,k,iobcs)
398 enddo
399 enddo
400 CALL GLOBAL_SUM_INT( ntmpob(iobcs), myThid )
401 nwetobcsnglo(k,iobcs)=ntmpob(iobcs)
402 enddo
403 write(msgbuf,'(a,2x,I3,4(2x,I10))')
404 & 'ctrl-wet 15a: global obcsN T,S,U,V k=', k, ntmpob
405 call print_message( msgbuf, standardmessageunit,
406 & SQUEEZE_RIGHT , mythid)
407 #endif
408 #ifdef ALLOW_OBCSS_CONTROL
409 do iobcs = 1, nobcs
410 ntmpob(iobcs)=0
411 do bj=1,nSy
412 do bi=1,nSx
413 ntmpob(iobcs)=ntmpob(iobcs)+nwetobcss(bi,bj,k,iobcs)
414 enddo
415 enddo
416 CALL GLOBAL_SUM_INT( ntmpob(iobcs), myThid )
417 nwetobcssglo(k,iobcs)=ntmpob(iobcs)
418 enddo
419 write(msgbuf,'(a,2x,I3,4(2x,I10))')
420 & 'ctrl-wet 15b: global obcsS T,S,U,V k=', k, ntmpob
421 call print_message( msgbuf, standardmessageunit,
422 & SQUEEZE_RIGHT , mythid)
423 #endif
424 #ifdef ALLOW_OBCSW_CONTROL
425 do iobcs = 1, nobcs
426 ntmpob(iobcs)=0
427 do bj=1,nSy
428 do bi=1,nSx
429 ntmpob(iobcs)=ntmpob(iobcs)+nwetobcsw(bi,bj,k,iobcs)
430 enddo
431 enddo
432 CALL GLOBAL_SUM_INT( ntmpob(iobcs), myThid )
433 nwetobcswglo(k,iobcs)=ntmpob(iobcs)
434 enddo
435 write(msgbuf,'(a,2x,I3,4(2x,I10))')
436 & 'ctrl-wet 15c: global obcsW T,S,U,V k=', k, ntmpob
437 call print_message( msgbuf, standardmessageunit,
438 & SQUEEZE_RIGHT , mythid)
439 #endif
440 #ifdef ALLOW_OBCSE_CONTROL
441 do iobcs = 1, nobcs
442 ntmpob(iobcs)=0
443 do bj=1,nSy
444 do bi=1,nSx
445 ntmpob(iobcs)=ntmpob(iobcs)+nwetobcse(bi,bj,k,iobcs)
446 enddo
447 enddo
448 CALL GLOBAL_SUM_INT( ntmpob(iobcs), myThid )
449 nwetobcseglo(k,iobcs)=ntmpob(iobcs)
450 enddo
451 write(msgbuf,'(a,2x,I3,4(2x,I10))')
452 & 'ctrl-wet 15d: global obcsE T,S,U,V k=', k, ntmpob
453 call print_message( msgbuf, standardmessageunit,
454 & SQUEEZE_RIGHT , mythid)
455 #endif
456
457 enddo
458
459 write(msgbuf,'(a)')
460 & 'ctrl-wet -------------------------------------------------'
461 call print_message( msgbuf, standardmessageunit,
462 & SQUEEZE_RIGHT , mythid)
463
464 #ifdef ALLOW_OBCSN_CONTROL
465 do iobcs = 1, nobcs
466 ntmpob(iobcs)=0
467 do k = 1, nr
468 ntmpob(iobcs)=ntmpob(iobcs)+nwetobcsnglo(k,iobcs)
469 enddo
470 enddo
471 write(msgbuf,'(a,4(2x,I10))')
472 & 'ctrl-wet 16a: global SUM(K) obcsN T,S,U,V ', ntmpob
473 call print_message( msgbuf, standardmessageunit,
474 & SQUEEZE_RIGHT , mythid)
475 #endif
476 #ifdef ALLOW_OBCSS_CONTROL
477 do iobcs = 1, nobcs
478 ntmpob(iobcs)=0
479 do k = 1, nr
480 ntmpob(iobcs)=ntmpob(iobcs)+nwetobcssglo(k,iobcs)
481 enddo
482 enddo
483 write(msgbuf,'(a,4(2x,I10))')
484 & 'ctrl-wet 16b: global SUM(K) obcsS T,S,U,V ', ntmpob
485 call print_message( msgbuf, standardmessageunit,
486 & SQUEEZE_RIGHT , mythid)
487 #endif
488 #ifdef ALLOW_OBCSW_CONTROL
489 do iobcs = 1, nobcs
490 ntmpob(iobcs)=0
491 do k = 1, nr
492 ntmpob(iobcs)=ntmpob(iobcs)+nwetobcswglo(k,iobcs)
493 enddo
494 enddo
495 write(msgbuf,'(a,4(2x,I10))')
496 & 'ctrl-wet 16c: global SUM(K) obcsW T,S,U,V ', ntmpob
497 call print_message( msgbuf, standardmessageunit,
498 & SQUEEZE_RIGHT , mythid)
499 #endif
500 #ifdef ALLOW_OBCSE_CONTROL
501 do iobcs = 1, nobcs
502 ntmpob(iobcs)=0
503 do k = 1, nr
504 ntmpob(iobcs)=ntmpob(iobcs)+nwetobcseglo(k,iobcs)
505 enddo
506 enddo
507 write(msgbuf,'(a,4(2x,I10))')
508 & 'ctrl-wet 16d: global SUM(K) obcsE T,S,U,V ', ntmpob
509 call print_message( msgbuf, standardmessageunit,
510 & SQUEEZE_RIGHT , mythid)
511 #endif
512
513 write(msgbuf,'(a)')
514 & 'ctrl-wet -------------------------------------------------'
515 call print_message( msgbuf, standardmessageunit,
516 & SQUEEZE_RIGHT , mythid)
517
518 write(msgbuf,'(a,2x,I10)')
519 & 'ctrl_init: no. of control variables: ', nvartype
520 call print_message( msgbuf, standardmessageunit,
521 & SQUEEZE_RIGHT , mythid)
522 write(msgbuf,'(a,2x,I10)')
523 & 'ctrl_init: control vector length: ', nvarlength
524 call print_message( msgbuf, standardmessageunit,
525 & SQUEEZE_RIGHT , mythid)
526
527 _END_MASTER( mythid )
528
529 c Set unit weight to 1
530 c
531 do bj=1,nSy
532 do bi=1,nSx
533 do k=1, nr
534 wunit(k,bi,bj) = 1. _d 0
535 enddo
536 do k=1,Nr
537 do j=1-oly,sNy+oly
538 do i=1-olx,sNx+olx
539 tmpfld3d(i,j,k,bi,bj) = 1. _d 0
540 enddo
541 enddo
542 enddo
543 enddo
544 enddo
545
546 c write masks and weights to files to be read by a master process
547 c
548 call active_write_xyz( 'maskCtrlC', maskC, 1, 0, mythid, dummy)
549 call active_write_xyz( 'maskCtrlW', maskW, 1, 0, mythid, dummy)
550 call active_write_xyz( 'maskCtrlS', maskS, 1, 0, mythid, dummy)
551 #if (defined (ALLOW_EFLUXP0_CONTROL))
552 call active_write_xyz( 'maskhFacV', hFacV, 1, 0, mythid, dummy)
553 #endif
554 call active_write_xyz( 'wunit', tmpfld3d, 1, 0, mythid, dummy)
555
556
557 return
558 end

  ViewVC Help
Powered by ViewVC 1.1.22