1 !WRF+/TL:MODEL_LAYER:BOUNDARY
2 !Created by Ning Pan, 2010-08
9 USE module_model_constants
13 ! set the bdyzone. We are hardwiring this here and we'll
14 ! decide later where it should be set and stored
16 INTEGER, PARAMETER :: bdyzone = 4
17 INTEGER, PARAMETER :: bdyzone_x = bdyzone
18 INTEGER, PARAMETER :: bdyzone_y = bdyzone
22 !-----------------------------------
24 SUBROUTINE g_set_physical_bc2d( dat,g_dat, variable_in, &
26 ids,ide, jds,jde, & ! domain dims
27 ims,ime, jms,jme, & ! memory dims
28 ips,ipe, jps,jpe, & ! patch dims
33 INTEGER, INTENT(IN ) :: ids,ide, jds,jde
34 INTEGER, INTENT(IN ) :: ims,ime, jms,jme
35 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe
36 INTEGER, INTENT(IN ) :: its,ite, jts,jte
37 CHARACTER, INTENT(IN ) :: variable_in
41 REAL, DIMENSION( ims:ime , jms:jme ) :: dat,g_dat
42 TYPE( grid_config_rec_type ) config_flags
44 INTEGER :: i, j, istag, jstag, itime
46 LOGICAL :: debug, open_bc_copy
52 open_bc_copy = .false.
54 variable = variable_in
55 IF ( variable_in .ge. 'A' .and. variable_in .le. 'Z' ) THEN
56 variable = CHAR( ICHAR(variable_in) - ICHAR('A') + ICHAR('a') )
58 IF ((variable == 'u') .or. (variable == 'v') .or. &
59 (variable == 'w') .or. (variable == 't') .or. &
60 (variable == 'x') .or. (variable == 'y') .or. &
61 (variable == 'r') .or. (variable == 'p') ) open_bc_copy = .true.
63 ! begin, first set a staggering variable
68 IF ((variable == 'u') .or. (variable == 'x')) istag = 0
69 IF ((variable == 'v') .or. (variable == 'y')) jstag = 0
72 write(6,*) ' in bc2d, var is ',variable, istag, jstag
73 write(6,*) ' b.cs are ', &
74 config_flags%periodic_x, &
75 config_flags%periodic_y
78 IF ( variable == 'd' ) then !JDM
82 IF ( variable == 'e' ) then !JDM
85 IF ( variable == 'f' ) then !JDM
89 periodicity_x: IF( ( config_flags%periodic_x ) ) THEN
90 IF ( ( ids == ips ) .and. ( ide == ipe ) ) THEN ! test if east and west both on-processor
91 IF ( its == ids ) THEN
93 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
94 DO i = 0,-(bdyzone-1),-1
95 g_dat(ids+i-1,j) = g_dat(ide+i-1,j)
96 dat(ids+i-1,j) = dat(ide+i-1,j)
102 IF ( ite == ide ) THEN
104 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
105 !! DO i = 1 , bdyzone
106 DO i = -istag , bdyzone
107 g_dat(ide+i+istag,j) = g_dat(ids+i+istag,j)
108 dat(ide+i+istag,j) = dat(ids+i+istag,j)
117 symmetry_xs: IF( ( config_flags%symmetric_xs ) .and. &
118 ( its == ids ) ) THEN
120 IF ( (variable /= 'u') .and. (variable /= 'x') ) THEN
122 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
124 g_dat(ids-i,j) = g_dat(ids+i-1,j)
125 dat(ids-i,j) = dat(ids+i-1,j)
131 IF( variable == 'u' ) THEN
133 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
135 g_dat(ids-i,j) = - g_dat(ids+i,j)
136 dat(ids-i,j) = - dat(ids+i,j)
142 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
144 g_dat(ids-i,j) = g_dat(ids+i,j)
145 dat(ids-i,j) = dat(ids+i,j)
156 ! now the symmetry boundary at xe
158 symmetry_xe: IF( ( config_flags%symmetric_xe ) .and. &
159 ( ite == ide ) ) THEN
161 IF ( (variable /= 'u') .and. (variable /= 'x') ) THEN
163 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
165 g_dat(ide+i-1,j) = g_dat(ide-i,j)
166 dat(ide+i-1,j) = dat(ide-i,j)
172 IF (variable == 'u' ) THEN
174 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
176 g_dat(ide+i,j) = - g_dat(ide-i,j)
177 dat(ide+i,j) = - dat(ide-i,j)
184 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
186 g_dat(ide+i,j) = g_dat(ide-i,j)
187 dat(ide+i,j) = dat(ide-i,j)
198 ! set open b.c in X copy into boundary zone here. WCS, 19 March 2000
200 open_xs: IF( ( config_flags%open_xs .or. &
201 config_flags%specified .or. &
202 config_flags%nested ) .and. &
203 ( its == ids ) .and. open_bc_copy ) THEN
205 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
206 g_dat(ids-1,j) = g_dat(ids,j)
207 dat(ids-1,j) = dat(ids,j)
208 g_dat(ids-2,j) = g_dat(ids,j)
209 dat(ids-2,j) = dat(ids,j)
210 g_dat(ids-3,j) = g_dat(ids,j)
211 dat(ids-3,j) = dat(ids,j)
217 ! now the open boundary copy at xe
219 open_xe: IF( ( config_flags%open_xe .or. &
220 config_flags%specified .or. &
221 config_flags%nested ) .and. &
222 ( ite == ide ) .and. open_bc_copy ) THEN
224 IF ( variable /= 'u' .and. variable /= 'x') THEN
226 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
227 g_dat(ide ,j) = g_dat(ide-1,j)
228 dat(ide ,j) = dat(ide-1,j)
229 g_dat(ide+1,j) = g_dat(ide-1,j)
230 dat(ide+1,j) = dat(ide-1,j)
231 g_dat(ide+2,j) = g_dat(ide-1,j)
232 dat(ide+2,j) = dat(ide-1,j)
237 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
238 g_dat(ide+1,j) = g_dat(ide,j)
239 dat(ide+1,j) = dat(ide,j)
240 g_dat(ide+2,j) = g_dat(ide,j)
241 dat(ide+2,j) = dat(ide,j)
242 g_dat(ide+3,j) = g_dat(ide,j)
243 dat(ide+3,j) = dat(ide,j)
250 ! end open b.c in X copy into boundary zone addition. WCS, 19 March 2000
254 ! same procedure in y
256 periodicity_y: IF( ( config_flags%periodic_y ) ) THEN
257 IF ( ( jds == jps ) .and. ( jde == jpe ) ) THEN ! test of both north and south on processor
259 IF( jts == jds ) then
261 DO j = 0, -(bdyzone-1), -1
262 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
263 g_dat(i,jds+j-1) = g_dat(i,jde+j-1)
264 dat(i,jds+j-1) = dat(i,jde+j-1)
270 IF( jte == jde ) then
272 DO j = -jstag, bdyzone
273 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
274 g_dat(i,jde+j+jstag) = g_dat(i,jds+j+jstag)
275 dat(i,jde+j+jstag) = dat(i,jds+j+jstag)
285 symmetry_ys: IF( ( config_flags%symmetric_ys ) .and. &
288 IF ( (variable /= 'v') .and. (variable /= 'y') ) THEN
291 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
292 g_dat(i,jds-j) = g_dat(i,jds+j-1)
293 dat(i,jds-j) = dat(i,jds+j-1)
299 IF (variable == 'v') THEN
302 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
303 g_dat(i,jds-j) = - g_dat(i,jds+j)
304 dat(i,jds-j) = - dat(i,jds+j)
311 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
312 g_dat(i,jds-j) = g_dat(i,jds+j)
313 dat(i,jds-j) = dat(i,jds+j)
323 ! now the symmetry boundary at ye
325 symmetry_ye: IF( ( config_flags%symmetric_ye ) .and. &
326 ( jte == jde ) ) THEN
328 IF ( (variable /= 'v') .and. (variable /= 'y') ) THEN
331 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
332 g_dat(i,jde+j-1) = g_dat(i,jde-j)
333 dat(i,jde+j-1) = dat(i,jde-j)
339 IF (variable == 'v' ) THEN
342 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
343 g_dat(i,jde+j) = - g_dat(i,jde-j)
344 dat(i,jde+j) = - dat(i,jde-j)
351 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
352 g_dat(i,jde+j) = g_dat(i,jde-j)
353 dat(i,jde+j) = dat(i,jde-j)
363 ! set open b.c in Y copy into boundary zone here. WCS, 19 March 2000
365 open_ys: IF( ( config_flags%open_ys .or. &
366 config_flags%polar .or. &
367 config_flags%specified .or. &
368 config_flags%nested ) .and. &
369 ( jts == jds) .and. open_bc_copy ) THEN
371 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
372 g_dat(i,jds-1) = g_dat(i,jds)
373 dat(i,jds-1) = dat(i,jds)
374 g_dat(i,jds-2) = g_dat(i,jds)
375 dat(i,jds-2) = dat(i,jds)
376 g_dat(i,jds-3) = g_dat(i,jds)
377 dat(i,jds-3) = dat(i,jds)
382 ! now the open boundary copy at ye
384 open_ye: IF( ( config_flags%open_ye .or. &
385 config_flags%polar .or. &
386 config_flags%specified .or. &
387 config_flags%nested ) .and. &
388 ( jte == jde ) .and. open_bc_copy ) THEN
390 IF (variable /= 'v' .and. variable /= 'y' ) THEN
392 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
393 g_dat(i,jde ) = g_dat(i,jde-1)
394 dat(i,jde ) = dat(i,jde-1)
395 g_dat(i,jde+1) = g_dat(i,jde-1)
396 dat(i,jde+1) = dat(i,jde-1)
397 g_dat(i,jde+2) = g_dat(i,jde-1)
398 dat(i,jde+2) = dat(i,jde-1)
403 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
404 g_dat(i,jde+1) = g_dat(i,jde)
405 dat(i,jde+1) = dat(i,jde)
406 g_dat(i,jde+2) = g_dat(i,jde)
407 dat(i,jde+2) = dat(i,jde)
408 g_dat(i,jde+3) = g_dat(i,jde)
409 dat(i,jde+3) = dat(i,jde)
416 ! end open b.c in Y copy into boundary zone addition. WCS, 19 March 2000
420 ! fix corners for doubly periodic domains
422 IF ( config_flags%periodic_x .and. config_flags%periodic_y &
423 .and. (ids == ips) .and. (ide == ipe) &
424 .and. (jds == jps) .and. (jde == jpe) ) THEN
426 IF ( (its == ids) .and. (jts == jds) ) THEN ! lower left corner fill
427 DO j = 0, -(bdyzone-1), -1
428 DO i = 0, -(bdyzone-1), -1
429 g_dat(ids+i-1,jds+j-1) = g_dat(ide+i-1,jde+j-1)
430 dat(ids+i-1,jds+j-1) = dat(ide+i-1,jde+j-1)
435 IF ( (ite == ide) .and. (jts == jds) ) THEN ! lower right corner fill
436 DO j = 0, -(bdyzone-1), -1
438 g_dat(ide+i+istag,jds+j-1) = g_dat(ids+i+istag,jde+j-1)
439 dat(ide+i+istag,jds+j-1) = dat(ids+i+istag,jde+j-1)
444 IF ( (ite == ide) .and. (jte == jde) ) THEN ! upper right corner fill
447 g_dat(ide+i+istag,jde+j+jstag) = g_dat(ids+i+istag,jds+j+jstag)
448 dat(ide+i+istag,jde+j+jstag) = dat(ids+i+istag,jds+j+jstag)
453 IF ( (its == ids) .and. (jte == jde) ) THEN ! upper left corner fill
455 DO i = 0, -(bdyzone-1), -1
456 g_dat(ids+i-1,jde+j+jstag) = g_dat(ide+i-1,jds+j+jstag)
457 dat(ids+i-1,jde+j+jstag) = dat(ide+i-1,jds+j+jstag)
464 END SUBROUTINE g_set_physical_bc2d
466 !-----------------------------------
468 SUBROUTINE g_set_physical_bc3d( dat,g_dat, variable_in, &
470 ids,ide, jds,jde, kds,kde, & ! domain dims
471 ims,ime, jms,jme, kms,kme, & ! memory dims
472 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
473 its,ite, jts,jte, kts,kte )
477 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
478 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
479 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
480 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
481 CHARACTER, INTENT(IN ) :: variable_in
483 CHARACTER :: variable
485 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) :: dat,g_dat
486 TYPE( grid_config_rec_type ) config_flags
488 INTEGER :: i, j, k, istag, jstag, itime, k_end
490 LOGICAL :: debug, open_bc_copy
496 open_bc_copy = .false.
498 variable = variable_in
499 IF ( variable_in .ge. 'A' .and. variable_in .le. 'Z' ) THEN
500 variable = CHAR( ICHAR(variable_in) - ICHAR('A') + ICHAR('a') )
503 IF ((variable == 'u') .or. (variable == 'v') .or. &
504 (variable == 'w') .or. (variable == 't') .or. &
505 (variable == 'd') .or. (variable == 'e') .or. &
506 (variable == 'x') .or. (variable == 'y') .or. &
507 (variable == 'f') .or. (variable == 'r') .or. &
508 (variable == 'p') ) open_bc_copy = .true.
510 ! begin, first set a staggering variable
514 k_end = max(1,min(kde-1,kte))
517 IF ((variable == 'u') .or. (variable == 'x')) istag = 0
518 IF ((variable == 'v') .or. (variable == 'y')) jstag = 0
519 IF ((variable == 'd') .or. (variable == 'xy')) then
523 IF ((variable == 'e') ) then
528 IF ((variable == 'f') ) then
533 IF ( variable == 'w') k_end = min(kde,kte)
538 write(6,*) ' in bc, var is ',variable, istag, jstag, kte, k_end
539 write(6,*) ' b.cs are ', &
540 config_flags%periodic_x, &
541 config_flags%periodic_y
544 periodicity_x: IF( ( config_flags%periodic_x ) ) THEN
546 IF ( ( ids == ips ) .and. ( ide == ipe ) ) THEN ! test if both east and west on-processor
547 IF ( its == ids ) THEN
549 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
551 DO i = 0,-(bdyzone-1),-1
552 g_dat(ids+i-1,k,j) = g_dat(ide+i-1,k,j)
553 dat(ids+i-1,k,j) = dat(ide+i-1,k,j)
561 IF ( ite == ide ) THEN
563 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
565 DO i = -istag , bdyzone
566 g_dat(ide+i+istag,k,j) = g_dat(ids+i+istag,k,j)
567 dat(ide+i+istag,k,j) = dat(ids+i+istag,k,j)
578 symmetry_xs: IF( ( config_flags%symmetric_xs ) .and. &
579 ( its == ids ) ) THEN
581 IF ( (variable /= 'u') .and. (variable /= 'x') ) THEN
583 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
586 g_dat(ids-i,k,j) = g_dat(ids+i-1,k,j)
587 dat(ids-i,k,j) = dat(ids+i-1,k,j)
594 IF ( variable == 'u' ) THEN
596 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
599 g_dat(ids-i,k,j) = - g_dat(ids+i,k,j)
600 dat(ids-i,k,j) = - dat(ids+i,k,j)
607 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
610 g_dat(ids-i,k,j) = g_dat(ids+i,k,j)
611 dat(ids-i,k,j) = dat(ids+i,k,j)
623 ! now the symmetry boundary at xe
625 symmetry_xe: IF( ( config_flags%symmetric_xe ) .and. &
626 ( ite == ide ) ) THEN
628 IF ( (variable /= 'u') .and. (variable /= 'x') ) THEN
630 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
633 g_dat(ide+i-1,k,j) = g_dat(ide-i,k,j)
634 dat(ide+i-1,k,j) = dat(ide-i,k,j)
641 IF (variable == 'u') THEN
643 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
646 g_dat(ide+i,k,j) = - g_dat(ide-i,k,j)
647 dat(ide+i,k,j) = - dat(ide-i,k,j)
654 DO j = MAX(jds,jts-1), MIN(jte+1,jde+jstag)
657 g_dat(ide+i,k,j) = g_dat(ide-i,k,j)
658 dat(ide+i,k,j) = dat(ide-i,k,j)
669 ! set open b.c in X copy into boundary zone here. WCS, 19 March 2000
671 open_xs: IF( ( config_flags%open_xs .or. &
672 config_flags%specified .or. &
673 config_flags%nested ) .and. &
674 ( its == ids ) .and. open_bc_copy ) THEN
676 DO j = jts-bdyzone, MIN(jte,jde+jstag)+bdyzone
678 g_dat(ids-1,k,j) = g_dat(ids,k,j)
679 dat(ids-1,k,j) = dat(ids,k,j)
680 g_dat(ids-2,k,j) = g_dat(ids,k,j)
681 dat(ids-2,k,j) = dat(ids,k,j)
682 g_dat(ids-3,k,j) = g_dat(ids,k,j)
683 dat(ids-3,k,j) = dat(ids,k,j)
690 ! now the open_xe boundary copy
692 open_xe: IF( ( config_flags%open_xe .or. &
693 config_flags%specified .or. &
694 config_flags%nested ) .and. &
695 ( ite == ide ) .and. open_bc_copy ) THEN
697 IF (variable /= 'u' .and. variable /= 'x' ) THEN
699 DO j = jts-bdyzone, MIN(jte,jde+jstag)+bdyzone
701 g_dat(ide ,k,j) = g_dat(ide-1,k,j)
702 dat(ide ,k,j) = dat(ide-1,k,j)
703 g_dat(ide+1,k,j) = g_dat(ide-1,k,j)
704 dat(ide+1,k,j) = dat(ide-1,k,j)
705 g_dat(ide+2,k,j) = g_dat(ide-1,k,j)
706 dat(ide+2,k,j) = dat(ide-1,k,j)
712 !!!!!!! I am not sure about this one! JM 20020402
713 DO j = MAX(jds,jts-1)-bdyzone, MIN(jte+1,jde+jstag)+bdyzone
715 g_dat(ide+1,k,j) = g_dat(ide,k,j)
716 dat(ide+1,k,j) = dat(ide,k,j)
717 g_dat(ide+2,k,j) = g_dat(ide,k,j)
718 dat(ide+2,k,j) = dat(ide,k,j)
719 g_dat(ide+3,k,j) = g_dat(ide,k,j)
720 dat(ide+3,k,j) = dat(ide,k,j)
728 ! end open b.c in X copy into boundary zone addition. WCS, 19 March 2000
732 ! same procedure in y
734 periodicity_y: IF( ( config_flags%periodic_y ) ) THEN
735 IF ( ( jds == jps ) .and. ( jde == jpe ) ) THEN ! test if both north and south on processor
736 IF( jts == jds ) then
738 DO j = 0, -(bdyzone-1), -1
740 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
741 g_dat(i,k,jds+j-1) = g_dat(i,k,jde+j-1)
742 dat(i,k,jds+j-1) = dat(i,k,jde+j-1)
749 IF( jte == jde ) then
751 DO j = -jstag, bdyzone
753 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
754 g_dat(i,k,jde+j+jstag) = g_dat(i,k,jds+j+jstag)
755 dat(i,k,jde+j+jstag) = dat(i,k,jds+j+jstag)
766 symmetry_ys: IF( ( config_flags%symmetric_ys ) .and. &
769 IF ( (variable /= 'v') .and. (variable /= 'y') ) THEN
773 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
774 g_dat(i,k,jds-j) = g_dat(i,k,jds+j-1)
775 dat(i,k,jds-j) = dat(i,k,jds+j-1)
782 IF (variable == 'v') THEN
786 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
787 g_dat(i,k,jds-j) = - g_dat(i,k,jds+j)
788 dat(i,k,jds-j) = - dat(i,k,jds+j)
797 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
798 g_dat(i,k,jds-j) = g_dat(i,k,jds+j)
799 dat(i,k,jds-j) = dat(i,k,jds+j)
810 ! now the symmetry boundary at ye
812 symmetry_ye: IF( ( config_flags%symmetric_ye ) .and. &
813 ( jte == jde ) ) THEN
815 IF ( (variable /= 'v') .and. (variable /= 'y') ) THEN
819 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
820 g_dat(i,k,jde+j-1) = g_dat(i,k,jde-j)
821 dat(i,k,jde+j-1) = dat(i,k,jde-j)
828 IF ( variable == 'v' ) THEN
832 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
833 g_dat(i,k,jde+j) = - g_dat(i,k,jde-j)
834 dat(i,k,jde+j) = - dat(i,k,jde-j)
843 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
844 g_dat(i,k,jde+j) = g_dat(i,k,jde-j)
845 dat(i,k,jde+j) = dat(i,k,jde-j)
856 ! set open b.c in Y copy into boundary zone here. WCS, 19 March 2000
858 open_ys: IF( ( config_flags%open_ys .or. &
859 config_flags%polar .or. &
860 config_flags%specified .or. &
861 config_flags%nested ) .and. &
862 ( jts == jds) .and. open_bc_copy ) THEN
865 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
866 g_dat(i,k,jds-1) = g_dat(i,k,jds)
867 dat(i,k,jds-1) = dat(i,k,jds)
868 g_dat(i,k,jds-2) = g_dat(i,k,jds)
869 dat(i,k,jds-2) = dat(i,k,jds)
870 g_dat(i,k,jds-3) = g_dat(i,k,jds)
871 dat(i,k,jds-3) = dat(i,k,jds)
877 ! now the open boundary copy at ye
879 open_ye: IF( ( config_flags%open_ye .or. &
880 config_flags%polar .or. &
881 config_flags%specified .or. &
882 config_flags%nested ) .and. &
883 ( jte == jde ) .and. open_bc_copy ) THEN
885 IF (variable /= 'v' .and. variable /= 'y' ) THEN
888 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
889 g_dat(i,k,jde ) = g_dat(i,k,jde-1)
890 dat(i,k,jde ) = dat(i,k,jde-1)
891 g_dat(i,k,jde+1) = g_dat(i,k,jde-1)
892 dat(i,k,jde+1) = dat(i,k,jde-1)
893 g_dat(i,k,jde+2) = g_dat(i,k,jde-1)
894 dat(i,k,jde+2) = dat(i,k,jde-1)
901 DO i = MAX(ids,its-1), MIN(ite+1,ide+istag)
902 g_dat(i,k,jde+1) = g_dat(i,k,jde)
903 dat(i,k,jde+1) = dat(i,k,jde)
904 g_dat(i,k,jde+2) = g_dat(i,k,jde)
905 dat(i,k,jde+2) = dat(i,k,jde)
906 g_dat(i,k,jde+3) = g_dat(i,k,jde)
907 dat(i,k,jde+3) = dat(i,k,jde)
915 ! end open b.c in Y copy into boundary zone addition. WCS, 19 March 2000
919 ! fix corners for doubly periodic domains
921 IF ( config_flags%periodic_x .and. config_flags%periodic_y &
922 .and. (ids == ips) .and. (ide == ipe) &
923 .and. (jds == jps) .and. (jde == jpe) ) THEN
925 IF ( (its == ids) .and. (jts == jds) ) THEN ! lower left corner fill
926 DO j = 0, -(bdyzone-1), -1
928 DO i = 0, -(bdyzone-1), -1
929 g_dat(ids+i-1,k,jds+j-1) = g_dat(ide+i-1,k,jde+j-1)
930 dat(ids+i-1,k,jds+j-1) = dat(ide+i-1,k,jde+j-1)
936 IF ( (ite == ide) .and. (jts == jds) ) THEN ! lower right corner fill
937 DO j = 0, -(bdyzone-1), -1
940 g_dat(ide+i+istag,k,jds+j-1) = g_dat(ids+i+istag,k,jde+j-1)
941 dat(ide+i+istag,k,jds+j-1) = dat(ids+i+istag,k,jde+j-1)
947 IF ( (ite == ide) .and. (jte == jde) ) THEN ! upper right corner fill
951 g_dat(ide+i+istag,k,jde+j+jstag) = g_dat(ids+i+istag,k,jds+j+jstag)
952 dat(ide+i+istag,k,jde+j+jstag) = dat(ids+i+istag,k,jds+j+jstag)
958 IF ( (its == ids) .and. (jte == jde) ) THEN ! upper left corner fill
961 DO i = 0, -(bdyzone-1), -1
962 g_dat(ids+i-1,k,jde+j+jstag) = g_dat(ide+i-1,k,jds+j+jstag)
963 dat(ids+i-1,k,jde+j+jstag) = dat(ide+i-1,k,jds+j+jstag)
971 END SUBROUTINE g_set_physical_bc3d
973 !------------------------------------------------------------------------
975 SUBROUTINE g_init_module_bc
976 END SUBROUTINE g_init_module_bc
978 !------------------------------------------------------------------------
980 SUBROUTINE g_relax_bdytend ( field, g_field, field_tend, g_field_tend, &
981 field_bdy_xs, g_field_bdy_xs, &
982 field_bdy_xe, g_field_bdy_xe, &
983 field_bdy_ys, g_field_bdy_ys, &
984 field_bdy_ye, g_field_bdy_ye, &
985 field_bdy_tend_xs, g_field_bdy_tend_xs, &
986 field_bdy_tend_xe, g_field_bdy_tend_xe, &
987 field_bdy_tend_ys, g_field_bdy_tend_ys, &
988 field_bdy_tend_ye, g_field_bdy_tend_ye, &
989 variable_in, config_flags, &
990 spec_bdy_width, spec_zone, relax_zone, &
992 ids,ide, jds,jde, kds,kde, & ! domain dims
993 ims,ime, jms,jme, kms,kme, & ! memory dims
994 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
995 its,ite, jts,jte, kts,kte )
999 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde
1000 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme
1001 INTEGER, INTENT(IN) :: ips,ipe, jps,jpe, kps,kpe
1002 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte
1003 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone, relax_zone
1004 REAL, INTENT(IN) :: dtbc
1005 CHARACTER, INTENT(IN) :: variable_in
1007 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: g_field
1008 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: field
1009 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: g_field_tend
1010 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: field_tend
1011 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_xs, g_field_bdy_xe
1012 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_xs, field_bdy_xe
1013 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_ys, g_field_bdy_ye
1014 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_ys, field_bdy_ye
1015 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_tend_xs, g_field_bdy_tend_xe
1016 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_tend_xs, field_bdy_tend_xe
1017 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_tend_ys, g_field_bdy_tend_ye
1018 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_tend_ys, field_bdy_tend_ye
1019 REAL, DIMENSION( spec_bdy_width ), INTENT(IN) :: fcx, gcx
1020 TYPE(grid_config_rec_type), INTENT(IN) :: config_flags
1023 CALL g_relax_bdytend_core ( field, g_field, field_tend, g_field_tend, &
1024 field_bdy_xs, g_field_bdy_xs, &
1025 field_bdy_xe, g_field_bdy_xe, &
1026 field_bdy_ys, g_field_bdy_ys, &
1027 field_bdy_ye, g_field_bdy_ye, &
1028 field_bdy_tend_xs, g_field_bdy_tend_xs, &
1029 field_bdy_tend_xe, g_field_bdy_tend_xe, &
1030 field_bdy_tend_ys, g_field_bdy_tend_ys, &
1031 field_bdy_tend_ye, g_field_bdy_tend_ye, &
1032 variable_in, config_flags, &
1033 spec_bdy_width, spec_zone, relax_zone, &
1035 ids,ide, jds,jde, kds,kde, & ! domain dims
1036 ims,ime, jms,jme, kms,kme, & ! memory dims
1037 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1038 its,ite, jts,jte, kts,kte, & ! patch dims
1039 ims,ime, jms,jme, kms,kme ) ! dimension of the field argument
1041 END SUBROUTINE g_relax_bdytend
1043 ! version that allows tile-sized version of field. Note, caller should define the
1044 ! field to be -+1 of tile size in each dimension because routine is going off onto halo
1045 ! for example, see relax_bdytend in dyn_em/module_bc_em.F
1046 SUBROUTINE g_relax_bdytend_tile ( field, g_field, field_tend, g_field_tend, &
1047 field_bdy_xs, g_field_bdy_xs, &
1048 field_bdy_xe, g_field_bdy_xe, &
1049 field_bdy_ys, g_field_bdy_ys, &
1050 field_bdy_ye, g_field_bdy_ye, &
1051 field_bdy_tend_xs, g_field_bdy_tend_xs, &
1052 field_bdy_tend_xe, g_field_bdy_tend_xe, &
1053 field_bdy_tend_ys, g_field_bdy_tend_ys, &
1054 field_bdy_tend_ye, g_field_bdy_tend_ye, &
1055 variable_in, config_flags, &
1056 spec_bdy_width, spec_zone, relax_zone, &
1058 ids,ide, jds,jde, kds,kde, & ! domain dims
1059 ims,ime, jms,jme, kms,kme, & ! memory dims
1060 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1061 its,ite, jts,jte, kts,kte, &
1062 iXs,iXe, jXs,jXe, kXs,kXe & ! dims of first argument
1067 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde
1068 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme
1069 INTEGER, INTENT(IN) :: ips,ipe, jps,jpe, kps,kpe
1070 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte
1071 INTEGER, INTENT(IN) :: iXs,iXe, jXs,jXe, kXs,kXe
1072 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone, relax_zone
1073 REAL, INTENT(IN) :: dtbc
1074 CHARACTER, INTENT(IN) :: variable_in
1076 REAL, DIMENSION(iXs:iXe, kXs:kXe, jXs:jXe ), INTENT(IN ) :: g_field
1077 REAL, DIMENSION(iXs:iXe, kXs:kXe, jXs:jXe ), INTENT(IN ) :: field
1078 REAL, DIMENSION(ims:ime, kms:kme, jms:jme ), INTENT(INOUT) :: g_field_tend
1079 REAL, DIMENSION(ims:ime, kms:kme, jms:jme ), INTENT(INOUT) :: field_tend
1080 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_xs, g_field_bdy_xe
1081 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_xs, field_bdy_xe
1082 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_ys, g_field_bdy_ye
1083 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_ys, field_bdy_ye
1084 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_tend_xs, g_field_bdy_tend_xe
1085 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_tend_xs, field_bdy_tend_xe
1086 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_tend_ys, g_field_bdy_tend_ye
1087 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_tend_ys, field_bdy_tend_ye
1088 REAL, DIMENSION(spec_bdy_width), INTENT(IN) :: fcx, gcx
1089 TYPE(grid_config_rec_type), INTENT(IN) :: config_flags
1092 CALL g_relax_bdytend_core ( field, g_field, field_tend, g_field_tend, &
1093 field_bdy_xs, g_field_bdy_xs, &
1094 field_bdy_xe, g_field_bdy_xe, &
1095 field_bdy_ys, g_field_bdy_ys, &
1096 field_bdy_ye, g_field_bdy_ye, &
1097 field_bdy_tend_xs, g_field_bdy_tend_xs, &
1098 field_bdy_tend_xe, g_field_bdy_tend_xe, &
1099 field_bdy_tend_ys, g_field_bdy_tend_ys, &
1100 field_bdy_tend_ye, g_field_bdy_tend_ye, &
1101 variable_in, config_flags, &
1102 spec_bdy_width, spec_zone, relax_zone, &
1104 ids,ide, jds,jde, kds,kde, & ! domain dims
1105 ims,ime, jms,jme, kms,kme, & ! memory dims
1106 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1107 its,ite, jts,jte, kts,kte, &
1108 iXs,iXe, jXs,jXe, kXs,kXe ) ! dimension of the field argument
1110 END SUBROUTINE g_relax_bdytend_tile
1112 ! Tapenade 3.5 (r3785) - 22 Mar 2011 18:35
1114 ! Differentiation of relax_bdytend_core in forward (tangent) mode:
1115 ! variations of useful results: field_tend
1116 ! with respect to varying inputs: field field_bdy_xe field_bdy_tend_xe
1117 ! field_tend field_bdy_xs field_bdy_tend_xs field_bdy_ye
1118 ! field_bdy_tend_ye field_bdy_ys field_bdy_tend_ys
1119 ! RW status of diff variables: field:in field_bdy_xe:in field_bdy_tend_xe:in
1120 ! field_tend:in-out field_bdy_xs:in field_bdy_tend_xs:in
1121 ! field_bdy_ye:in field_bdy_tend_ye:in field_bdy_ys:in
1122 ! field_bdy_tend_ys:in
1127 ! field (1st arg) dims; might be tile or patch
1128 SUBROUTINE G_RELAX_BDYTEND_CORE(field, fieldd, field_tend, field_tendd, &
1129 & field_bdy_xs, field_bdy_xsd, field_bdy_xe, field_bdy_xed, field_bdy_ys&
1130 & , field_bdy_ysd, field_bdy_ye, field_bdy_yed, field_bdy_tend_xs, &
1131 & field_bdy_tend_xsd, field_bdy_tend_xe, field_bdy_tend_xed, &
1132 & field_bdy_tend_ys, field_bdy_tend_ysd, field_bdy_tend_ye, &
1133 & field_bdy_tend_yed, variable_in, config_flags, spec_bdy_width, &
1134 & spec_zone, relax_zone, dtbc, fcx, gcx, ids, ide, jds, jde, kds, kde, &
1135 & ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe, its, ite, &
1136 & jts, jte, kts, kte, ixs, ixe, jxs, jxe, kxs, kxe)
1138 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde
1139 INTEGER, INTENT(IN) :: ims, ime, jms, jme, kms, kme
1140 INTEGER, INTENT(IN) :: ips, ipe, jps, jpe, kps, kpe
1141 INTEGER, INTENT(IN) :: its, ite, jts, jte, kts, kte
1142 INTEGER, INTENT(IN) :: ixs, ixe, jxs, jxe, kxs, kxe
1143 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone, relax_zone
1144 REAL, INTENT(IN) :: dtbc
1145 CHARACTER, INTENT(IN) :: variable_in
1146 REAL, DIMENSION(ixs:ixe, kxs:kxe, jxs:jxe), INTENT(IN) :: field
1147 REAL, DIMENSION(ixs:ixe, kxs:kxe, jxs:jxe), INTENT(IN) :: fieldd
1148 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: &
1150 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: &
1152 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
1153 & field_bdy_xs, field_bdy_xe
1154 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
1155 & field_bdy_xsd, field_bdy_xed
1156 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
1157 & field_bdy_ys, field_bdy_ye
1158 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
1159 & field_bdy_ysd, field_bdy_yed
1160 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
1161 & field_bdy_tend_xs, field_bdy_tend_xe
1162 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
1163 & field_bdy_tend_xsd, field_bdy_tend_xed
1164 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
1165 & field_bdy_tend_ys, field_bdy_tend_ye
1166 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
1167 & field_bdy_tend_ysd, field_bdy_tend_yed
1168 REAL, DIMENSION(spec_bdy_width), INTENT(IN) :: fcx, gcx
1169 TYPE(GRID_CONFIG_REC_TYPE) :: config_flags
1170 CHARACTER :: variable
1171 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, im1, ip1
1172 INTEGER :: b_dist, b_limit
1173 REAL :: fls0, fls1, fls2, fls3, fls4
1174 REAL :: fls0d, fls1d, fls2d, fls3d, fls4d
1175 LOGICAL :: periodic_x
1192 periodic_x = config_flags%periodic_x
1193 variable = variable_in
1194 IF (variable .EQ. 'U') variable = 'u'
1195 IF (variable .EQ. 'V') variable = 'v'
1196 IF (variable .EQ. 'M') variable = 'm'
1197 IF (variable .EQ. 'H') variable = 'h'
1200 IF (ite .GT. ide - 1) THEN
1207 IF (jte .GT. jde - 1) THEN
1213 IF (variable .EQ. 'u') ibe = ide
1214 IF (variable .EQ. 'u') THEN
1215 IF (ite .GT. ide) THEN
1221 IF (variable .EQ. 'v') jbe = jde
1222 IF (variable .EQ. 'v') THEN
1223 IF (jte .GT. jde) THEN
1229 IF (variable .EQ. 'm') ktf = kte
1230 IF (variable .EQ. 'h') ktf = kte
1231 IF (jts - jbs .LT. relax_zone) THEN
1232 IF (jts .LT. jbs + spec_zone) THEN
1233 max1 = jbs + spec_zone
1237 IF (jtf .GT. jbs + relax_zone - 1) THEN
1238 min1 = jbs + relax_zone - 1
1246 IF (periodic_x) b_limit = 0
1248 IF (its .LT. b_limit + ibs) THEN
1249 max2 = b_limit + ibs
1253 IF (itf .GT. ibe - b_limit) THEN
1254 min2 = ibe - b_limit
1259 IF (i - 1 .LT. ibs) THEN
1264 IF (i + 1 .GT. ibe) THEN
1269 fls0d = field_bdy_ysd(i, k, b_dist+1) + dtbc*&
1270 & field_bdy_tend_ysd(i, k, b_dist+1) - fieldd(i, k, j)
1271 fls0 = field_bdy_ys(i, k, b_dist+1) + dtbc*field_bdy_tend_ys(i&
1272 & , k, b_dist+1) - field(i, k, j)
1273 fls1d = field_bdy_ysd(im1, k, b_dist+1) + dtbc*&
1274 & field_bdy_tend_ysd(im1, k, b_dist+1) - fieldd(im1, k, j)
1275 fls1 = field_bdy_ys(im1, k, b_dist+1) + dtbc*field_bdy_tend_ys&
1276 & (im1, k, b_dist+1) - field(im1, k, j)
1277 fls2d = field_bdy_ysd(ip1, k, b_dist+1) + dtbc*&
1278 & field_bdy_tend_ysd(ip1, k, b_dist+1) - fieldd(ip1, k, j)
1279 fls2 = field_bdy_ys(ip1, k, b_dist+1) + dtbc*field_bdy_tend_ys&
1280 & (ip1, k, b_dist+1) - field(ip1, k, j)
1281 fls3d = field_bdy_ysd(i, k, b_dist) + dtbc*field_bdy_tend_ysd(&
1282 & i, k, b_dist) - fieldd(i, k, j-1)
1283 fls3 = field_bdy_ys(i, k, b_dist) + dtbc*field_bdy_tend_ys(i, &
1284 & k, b_dist) - field(i, k, j-1)
1285 fls4d = field_bdy_ysd(i, k, b_dist+2) + dtbc*&
1286 & field_bdy_tend_ysd(i, k, b_dist+2) - fieldd(i, k, j+1)
1287 fls4 = field_bdy_ys(i, k, b_dist+2) + dtbc*field_bdy_tend_ys(i&
1288 & , k, b_dist+2) - field(i, k, j+1)
1289 field_tendd(i, k, j) = field_tendd(i, k, j) + fcx(b_dist+1)*&
1290 & fls0d - gcx(b_dist+1)*(fls1d+fls2d+fls3d+fls4d-4.*fls0d)
1291 field_tend(i, k, j) = field_tend(i, k, j) + fcx(b_dist+1)*fls0&
1292 & - gcx(b_dist+1)*(fls1+fls2+fls3+fls4-4.*fls0)
1297 IF (jbe - jtf .LT. relax_zone) THEN
1298 IF (jts .LT. jbe - relax_zone + 1) THEN
1299 max3 = jbe - relax_zone + 1
1303 IF (jtf .GT. jbe - spec_zone) THEN
1304 min3 = jbe - spec_zone
1312 IF (periodic_x) b_limit = 0
1314 IF (its .LT. b_limit + ibs) THEN
1315 max4 = b_limit + ibs
1319 IF (itf .GT. ibe - b_limit) THEN
1320 min4 = ibe - b_limit
1325 IF (i - 1 .LT. ibs) THEN
1330 IF (i + 1 .GT. ibe) THEN
1335 fls0d = field_bdy_yed(i, k, b_dist+1) + dtbc*&
1336 & field_bdy_tend_yed(i, k, b_dist+1) - fieldd(i, k, j)
1337 fls0 = field_bdy_ye(i, k, b_dist+1) + dtbc*field_bdy_tend_ye(i&
1338 & , k, b_dist+1) - field(i, k, j)
1339 fls1d = field_bdy_yed(im1, k, b_dist+1) + dtbc*&
1340 & field_bdy_tend_yed(im1, k, b_dist+1) - fieldd(im1, k, j)
1341 fls1 = field_bdy_ye(im1, k, b_dist+1) + dtbc*field_bdy_tend_ye&
1342 & (im1, k, b_dist+1) - field(im1, k, j)
1343 fls2d = field_bdy_yed(ip1, k, b_dist+1) + dtbc*&
1344 & field_bdy_tend_yed(ip1, k, b_dist+1) - fieldd(ip1, k, j)
1345 fls2 = field_bdy_ye(ip1, k, b_dist+1) + dtbc*field_bdy_tend_ye&
1346 & (ip1, k, b_dist+1) - field(ip1, k, j)
1347 fls3d = field_bdy_yed(i, k, b_dist) + dtbc*field_bdy_tend_yed(&
1348 & i, k, b_dist) - fieldd(i, k, j+1)
1349 fls3 = field_bdy_ye(i, k, b_dist) + dtbc*field_bdy_tend_ye(i, &
1350 & k, b_dist) - field(i, k, j+1)
1351 fls4d = field_bdy_yed(i, k, b_dist+2) + dtbc*&
1352 & field_bdy_tend_yed(i, k, b_dist+2) - fieldd(i, k, j-1)
1353 fls4 = field_bdy_ye(i, k, b_dist+2) + dtbc*field_bdy_tend_ye(i&
1354 & , k, b_dist+2) - field(i, k, j-1)
1355 field_tendd(i, k, j) = field_tendd(i, k, j) + fcx(b_dist+1)*&
1356 & fls0d - gcx(b_dist+1)*(fls1d+fls2d+fls3d+fls4d-4.*fls0d)
1357 field_tend(i, k, j) = field_tend(i, k, j) + fcx(b_dist+1)*fls0&
1358 & - gcx(b_dist+1)*(fls1+fls2+fls3+fls4-4.*fls0)
1363 IF (.NOT.periodic_x) THEN
1364 IF (its - ibs .LT. relax_zone) THEN
1365 IF (its .LT. ibs + spec_zone) THEN
1366 max5 = ibs + spec_zone
1370 IF (itf .GT. ibs + relax_zone - 1) THEN
1371 min5 = ibs + relax_zone - 1
1379 IF (jts .LT. b_dist + jbs + 1) THEN
1380 max6 = b_dist + jbs + 1
1384 IF (jtf .GT. jbe - b_dist - 1) THEN
1385 min6 = jbe - b_dist - 1
1390 fls0d = field_bdy_xsd(j, k, b_dist+1) + dtbc*&
1391 & field_bdy_tend_xsd(j, k, b_dist+1) - fieldd(i, k, j)
1392 fls0 = field_bdy_xs(j, k, b_dist+1) + dtbc*field_bdy_tend_xs&
1393 & (j, k, b_dist+1) - field(i, k, j)
1394 fls1d = field_bdy_xsd(j-1, k, b_dist+1) + dtbc*&
1395 & field_bdy_tend_xsd(j-1, k, b_dist+1) - fieldd(i, k, j-1)
1396 fls1 = field_bdy_xs(j-1, k, b_dist+1) + dtbc*&
1397 & field_bdy_tend_xs(j-1, k, b_dist+1) - field(i, k, j-1)
1398 fls2d = field_bdy_xsd(j+1, k, b_dist+1) + dtbc*&
1399 & field_bdy_tend_xsd(j+1, k, b_dist+1) - fieldd(i, k, j+1)
1400 fls2 = field_bdy_xs(j+1, k, b_dist+1) + dtbc*&
1401 & field_bdy_tend_xs(j+1, k, b_dist+1) - field(i, k, j+1)
1402 fls3d = field_bdy_xsd(j, k, b_dist) + dtbc*&
1403 & field_bdy_tend_xsd(j, k, b_dist) - fieldd(i-1, k, j)
1404 fls3 = field_bdy_xs(j, k, b_dist) + dtbc*field_bdy_tend_xs(j&
1405 & , k, b_dist) - field(i-1, k, j)
1406 fls4d = field_bdy_xsd(j, k, b_dist+2) + dtbc*&
1407 & field_bdy_tend_xsd(j, k, b_dist+2) - fieldd(i+1, k, j)
1408 fls4 = field_bdy_xs(j, k, b_dist+2) + dtbc*field_bdy_tend_xs&
1409 & (j, k, b_dist+2) - field(i+1, k, j)
1410 field_tendd(i, k, j) = field_tendd(i, k, j) + fcx(b_dist+1)*&
1411 & fls0d - gcx(b_dist+1)*(fls1d+fls2d+fls3d+fls4d-4.*fls0d)
1412 field_tend(i, k, j) = field_tend(i, k, j) + fcx(b_dist+1)*&
1413 & fls0 - gcx(b_dist+1)*(fls1+fls2+fls3+fls4-4.*fls0)
1418 IF (ibe - itf .LT. relax_zone) THEN
1419 IF (its .LT. ibe - relax_zone + 1) THEN
1420 max7 = ibe - relax_zone + 1
1424 IF (itf .GT. ibe - spec_zone) THEN
1425 min7 = ibe - spec_zone
1433 IF (jts .LT. b_dist + jbs + 1) THEN
1434 max8 = b_dist + jbs + 1
1438 IF (jtf .GT. jbe - b_dist - 1) THEN
1439 min8 = jbe - b_dist - 1
1444 fls0d = field_bdy_xed(j, k, b_dist+1) + dtbc*&
1445 & field_bdy_tend_xed(j, k, b_dist+1) - fieldd(i, k, j)
1446 fls0 = field_bdy_xe(j, k, b_dist+1) + dtbc*field_bdy_tend_xe&
1447 & (j, k, b_dist+1) - field(i, k, j)
1448 fls1d = field_bdy_xed(j-1, k, b_dist+1) + dtbc*&
1449 & field_bdy_tend_xed(j-1, k, b_dist+1) - fieldd(i, k, j-1)
1450 fls1 = field_bdy_xe(j-1, k, b_dist+1) + dtbc*&
1451 & field_bdy_tend_xe(j-1, k, b_dist+1) - field(i, k, j-1)
1452 fls2d = field_bdy_xed(j+1, k, b_dist+1) + dtbc*&
1453 & field_bdy_tend_xed(j+1, k, b_dist+1) - fieldd(i, k, j+1)
1454 fls2 = field_bdy_xe(j+1, k, b_dist+1) + dtbc*&
1455 & field_bdy_tend_xe(j+1, k, b_dist+1) - field(i, k, j+1)
1456 fls3d = field_bdy_xed(j, k, b_dist) + dtbc*&
1457 & field_bdy_tend_xed(j, k, b_dist) - fieldd(i+1, k, j)
1458 fls3 = field_bdy_xe(j, k, b_dist) + dtbc*field_bdy_tend_xe(j&
1459 & , k, b_dist) - field(i+1, k, j)
1460 fls4d = field_bdy_xed(j, k, b_dist+2) + dtbc*&
1461 & field_bdy_tend_xed(j, k, b_dist+2) - fieldd(i-1, k, j)
1462 fls4 = field_bdy_xe(j, k, b_dist+2) + dtbc*field_bdy_tend_xe&
1463 & (j, k, b_dist+2) - field(i-1, k, j)
1464 field_tendd(i, k, j) = field_tendd(i, k, j) + fcx(b_dist+1)*&
1465 & fls0d - gcx(b_dist+1)*(fls1d+fls2d+fls3d+fls4d-4.*fls0d)
1466 field_tend(i, k, j) = field_tend(i, k, j) + fcx(b_dist+1)*&
1467 & fls0 - gcx(b_dist+1)*(fls1+fls2+fls3+fls4-4.*fls0)
1473 END SUBROUTINE G_RELAX_BDYTEND_CORE
1474 !------------------------------------------------------------------------
1476 SUBROUTINE g_spec_bdytend ( field_tend, g_field_tend, &
1477 field_bdy_xs, g_field_bdy_xs, &
1478 field_bdy_xe, g_field_bdy_xe, &
1479 field_bdy_ys, g_field_bdy_ys, &
1480 field_bdy_ye, g_field_bdy_ye, &
1481 field_bdy_tend_xs, g_field_bdy_tend_xs, &
1482 field_bdy_tend_xe, g_field_bdy_tend_xe, &
1483 field_bdy_tend_ys, g_field_bdy_tend_ys, &
1484 field_bdy_tend_ye, g_field_bdy_tend_ye, &
1485 variable_in, config_flags, &
1486 spec_bdy_width, spec_zone, &
1487 ids,ide, jds,jde, kds,kde, & ! domain dims
1488 ims,ime, jms,jme, kms,kme, & ! memory dims
1489 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1490 its,ite, jts,jte, kts,kte )
1492 ! spec_bdy_width is only used to dimension the boundary arrays.
1493 ! spec_zone is the width of the outer specified b.c.s that are set here.
1497 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde
1498 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme
1499 INTEGER, INTENT(IN) :: ips,ipe, jps,jpe, kps,kpe
1500 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte
1501 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone
1502 CHARACTER, INTENT(IN) :: variable_in
1504 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(OUT) :: g_field_tend
1505 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(OUT) :: field_tend
1507 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_xs, g_field_bdy_xe
1508 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_ys, g_field_bdy_ye
1509 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_tend_xs, g_field_bdy_tend_xe
1510 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: g_field_bdy_tend_ys, g_field_bdy_tend_ye
1511 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_xs, field_bdy_xe
1512 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_ys, field_bdy_ye
1513 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_tend_xs, field_bdy_tend_xe
1514 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: field_bdy_tend_ys, field_bdy_tend_ye
1515 TYPE(grid_config_rec_type), INTENT(IN) :: config_flags
1517 CHARACTER :: variable
1518 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf
1519 INTEGER :: b_dist, b_limit
1520 LOGICAL :: periodic_x
1523 periodic_x = config_flags%periodic_x
1525 variable = variable_in
1527 IF (variable == 'U') variable = 'u'
1528 IF (variable == 'V') variable = 'v'
1529 IF (variable == 'M') variable = 'm'
1530 IF (variable == 'H') variable = 'h'
1534 itf = min(ite,ide-1)
1537 jtf = min(jte,jde-1)
1539 IF (variable == 'u') ibe = ide
1540 IF (variable == 'u') itf = min(ite,ide)
1541 IF (variable == 'v') jbe = jde
1542 IF (variable == 'v') jtf = min(jte,jde)
1543 IF (variable == 'm') ktf = kte
1544 IF (variable == 'h') ktf = kte
1546 IF (jts - jbs .lt. spec_zone) THEN
1548 DO j = jts, min(jtf,jbs+spec_zone-1)
1551 IF(periodic_x)b_limit = 0
1553 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1554 g_field_tend(i,k,j) = g_field_bdy_tend_ys(i, k, b_dist+1)
1555 field_tend(i,k,j) = field_bdy_tend_ys(i, k, b_dist+1)
1560 IF (jbe - jtf .lt. spec_zone) THEN
1562 DO j = max(jts,jbe-spec_zone+1), jtf
1565 IF(periodic_x)b_limit = 0
1567 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1568 g_field_tend(i,k,j) = g_field_bdy_tend_ye(i, k, b_dist+1)
1569 field_tend(i,k,j) = field_bdy_tend_ye(i, k, b_dist+1)
1575 IF(.NOT.periodic_x)THEN
1576 IF (its - ibs .lt. spec_zone) THEN
1578 DO i = its, min(itf,ibs+spec_zone-1)
1581 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1582 g_field_tend(i,k,j) = g_field_bdy_tend_xs(j, k, b_dist+1)
1583 field_tend(i,k,j) = field_bdy_tend_xs(j, k, b_dist+1)
1589 IF (ibe - itf .lt. spec_zone) THEN
1591 DO i = max(its,ibe-spec_zone+1), itf
1594 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1595 g_field_tend(i,k,j) = g_field_bdy_tend_xe(j, k, b_dist+1)
1596 field_tend(i,k,j) = field_bdy_tend_xe(j, k, b_dist+1)
1603 END SUBROUTINE g_spec_bdytend
1605 !------------------------------------------------------------------------
1607 SUBROUTINE g_couple_bdy ( field, g_field, &
1608 variable_in, config_flags, &
1611 ids,ide, jds,jde, kds,kde, & ! domain dims
1612 ims,ime, jms,jme, kms,kme, & ! memory dims
1613 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1614 its,ite, jts,jte, kts,kte )
1616 ! This subroutine adds the tendencies in the boundary specified region.
1617 ! spec_zone is the width of the outer specified b.c.s that are set here.
1622 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
1623 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
1624 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
1625 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
1626 INTEGER, INTENT(IN ) :: spec_zone
1627 CHARACTER, INTENT(IN ) :: variable_in
1628 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: g_mu
1629 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: mu
1630 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: msf
1631 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: g_field
1632 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: field
1633 TYPE( grid_config_rec_type ) config_flags
1635 CHARACTER :: variable
1636 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf
1637 INTEGER :: b_dist, b_limit
1638 LOGICAL :: periodic_x
1640 periodic_x = config_flags%periodic_x
1642 variable = variable_in
1644 IF (variable == 'U') variable = 'u'
1645 IF (variable == 'V') variable = 'v'
1646 IF (variable == 'T') variable = 't'
1647 IF (variable == 'H') variable = 'h'
1648 IF (variable == 'W') variable = 'w'
1652 itf = min(ite,ide-1)
1655 jtf = min(jte,jde-1)
1657 IF (variable == 'u') ibe = ide
1658 IF (variable == 'u') itf = min(ite,ide)
1659 IF (variable == 'v') jbe = jde
1660 IF (variable == 'v') jtf = min(jte,jde)
1661 IF (variable == 'h') ktf = kte
1662 IF (variable == 'w') ktf = kte
1664 IF (jts - jbs .lt. spec_zone) THEN
1666 DO j = jts, min(jtf,jbs+spec_zone-1)
1669 IF(periodic_x)b_limit = 0
1671 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1672 if (variable == 't' .or. variable == 'h') then
1673 g_field(i,k,j) = g_field(i,k,j)*mu(i,j) + field(i,k,j)*g_mu(i,j)
1674 field(i,k,j) = field(i,k,j)*mu(i,j)
1676 g_field(i,k,j) = (g_field(i,k,j)*mu(i,j)+field(i,k,j)*g_mu(i,j)) / msf(i,j)
1677 field(i,k,j) = field(i,k,j)*mu(i,j)/msf(i,j)
1683 IF (jbe - jtf .lt. spec_zone) THEN
1685 DO j = max(jts,jbe-spec_zone+1), jtf
1688 IF(periodic_x)b_limit = 0
1690 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1691 if (variable == 't' .or. variable == 'h') then
1692 g_field(i,k,j) = g_field(i,k,j)*mu(i,j) + field(i,k,j)*g_mu(i,j)
1693 field(i,k,j) = field(i,k,j)*mu(i,j)
1695 g_field(i,k,j) = (g_field(i,k,j)*mu(i,j)+field(i,k,j)*g_mu(i,j)) / msf(i,j)
1696 field(i,k,j) = field(i,k,j)*mu(i,j)/msf(i,j)
1703 IF(.NOT.periodic_x)THEN
1704 IF (its - ibs .lt. spec_zone) THEN
1706 DO i = its, min(itf,ibs+spec_zone-1)
1709 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1710 if (variable == 't' .or. variable == 'h') then
1711 g_field(i,k,j) = g_field(i,k,j)*mu(i,j) + field(i,k,j)*g_mu(i,j)
1712 field(i,k,j) = field(i,k,j)*mu(i,j)
1714 g_field(i,k,j) = (g_field(i,k,j)*mu(i,j)+field(i,k,j)*g_mu(i,j)) / msf(i,j)
1715 field(i,k,j) = field(i,k,j)*mu(i,j)/msf(i,j)
1722 IF (ibe - itf .lt. spec_zone) THEN
1724 DO i = max(its,ibe-spec_zone+1), itf
1727 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1728 if (variable == 't' .or. variable == 'h') then
1729 g_field(i,k,j) = g_field(i,k,j)*mu(i,j) + field(i,k,j)*g_mu(i,j)
1730 field(i,k,j) = field(i,k,j)*mu(i,j)
1732 g_field(i,k,j) = (g_field(i,k,j)*mu(i,j)+field(i,k,j)*g_mu(i,j)) / msf(i,j)
1733 field(i,k,j) = field(i,k,j)*mu(i,j)/msf(i,j)
1741 END SUBROUTINE g_couple_bdy
1743 !------------------------------------------------------------------------
1745 SUBROUTINE g_uncouple_bdy( field, g_field, &
1746 variable_in, config_flags, &
1749 ids,ide, jds,jde, kds,kde, & ! domain dims
1750 ims,ime, jms,jme, kms,kme, & ! memory dims
1751 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1752 its,ite, jts,jte, kts,kte )
1754 ! This subroutine adds the tendencies in the boundary specified region.
1755 ! spec_zone is the width of the outer specified b.c.s that are set here.
1760 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
1761 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
1762 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
1763 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
1764 INTEGER, INTENT(IN ) :: spec_zone
1765 CHARACTER, INTENT(IN ) :: variable_in
1766 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: g_mu
1767 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: mu
1768 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: msf
1769 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: g_field
1770 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: field
1771 TYPE( grid_config_rec_type ) config_flags
1773 CHARACTER :: variable
1774 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf
1775 INTEGER :: b_dist, b_limit
1776 LOGICAL :: periodic_x
1778 periodic_x = config_flags%periodic_x
1780 variable = variable_in
1782 IF (variable == 'U') variable = 'u'
1783 IF (variable == 'V') variable = 'v'
1784 IF (variable == 'T') variable = 't'
1785 IF (variable == 'H') variable = 'h'
1786 IF (variable == 'W') variable = 'w'
1790 itf = min(ite,ide-1)
1793 jtf = min(jte,jde-1)
1795 IF (variable == 'u') ibe = ide
1796 IF (variable == 'u') itf = min(ite,ide)
1797 IF (variable == 'v') jbe = jde
1798 IF (variable == 'v') jtf = min(jte,jde)
1799 IF (variable == 'h') ktf = kte
1800 IF (variable == 'w') ktf = kte
1802 IF (jts - jbs .lt. spec_zone) THEN
1804 DO j = jts, min(jtf,jbs+spec_zone-1)
1807 IF(periodic_x)b_limit = 0
1809 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1810 if (variable == 't' .or. variable == 'h') then
1811 g_field(i,k,j) = g_field(i,k,j)/mu(i,j) &
1812 - field(i,k,j)*g_mu(i,j)/(mu(i,j)*mu(i,j))
1813 field(i,k,j) = field(i,k,j)/mu(i,j)
1815 g_field(i,k,j) = ( g_field(i,k,j)/mu(i,j) &
1816 - field(i,k,j)*g_mu(i,j)/(mu(i,j)*mu(i,j)) ) &
1818 field(i,k,j) = field(i,k,j)/mu(i,j)*msf(i,j)
1824 IF (jbe - jtf .lt. spec_zone) THEN
1826 DO j = max(jts,jbe-spec_zone+1), jtf
1829 IF(periodic_x)b_limit = 0
1831 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1832 if (variable == 't' .or. variable == 'h') then
1833 g_field(i,k,j) = g_field(i,k,j)/mu(i,j) &
1834 - field(i,k,j)*g_mu(i,j)/(mu(i,j)*mu(i,j))
1835 field(i,k,j) = field(i,k,j)/mu(i,j)
1837 g_field(i,k,j) = ( g_field(i,k,j)/mu(i,j) &
1838 - field(i,k,j)*g_mu(i,j)/(mu(i,j)*mu(i,j)) ) &
1840 field(i,k,j) = field(i,k,j)/mu(i,j)*msf(i,j)
1847 IF(.NOT.periodic_x)THEN
1848 IF (its - ibs .lt. spec_zone) THEN
1850 DO i = its, min(itf,ibs+spec_zone-1)
1853 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1854 if (variable == 't' .or. variable == 'h') then
1855 g_field(i,k,j) = g_field(i,k,j)/mu(i,j) &
1856 - field(i,k,j)*g_mu(i,j)/(mu(i,j)*mu(i,j))
1857 field(i,k,j) = field(i,k,j)/mu(i,j)
1859 g_field(i,k,j) = ( g_field(i,k,j)/mu(i,j) &
1860 - field(i,k,j)*g_mu(i,j)/(mu(i,j)*mu(i,j)) ) &
1862 field(i,k,j) = field(i,k,j)/mu(i,j)*msf(i,j)
1869 IF (ibe - itf .lt. spec_zone) THEN
1871 DO i = max(its,ibe-spec_zone+1), itf
1874 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1875 if (variable == 't' .or. variable == 'h') then
1876 g_field(i,k,j) = g_field(i,k,j)/mu(i,j) &
1877 - field(i,k,j)*g_mu(i,j)/(mu(i,j)*mu(i,j))
1878 field(i,k,j) = field(i,k,j)/mu(i,j)
1880 g_field(i,k,j) = ( g_field(i,k,j)/mu(i,j) &
1881 - field(i,k,j)*g_mu(i,j)/(mu(i,j)*mu(i,j)) ) &
1883 field(i,k,j) = field(i,k,j)/mu(i,j)*msf(i,j)
1891 END SUBROUTINE g_uncouple_bdy
1892 !------------------------------------------------------------------------
1894 SUBROUTINE g_spec_bdyupdate( field, g_field, &
1895 field_tend, g_field_tend, dt, &
1896 variable_in, config_flags, &
1898 ids,ide, jds,jde, kds,kde, & ! domain dims
1899 ims,ime, jms,jme, kms,kme, & ! memory dims
1900 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1901 its,ite, jts,jte, kts,kte )
1903 ! This subroutine adds the tendencies in the boundary specified region.
1904 ! spec_zone is the width of the outer specified b.c.s that are set here.
1909 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
1910 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
1911 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
1912 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
1913 INTEGER, INTENT(IN ) :: spec_zone
1914 CHARACTER, INTENT(IN ) :: variable_in
1915 REAL, INTENT(IN ) :: dt
1918 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: g_field
1919 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: field
1920 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(IN ) :: g_field_tend
1921 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(IN ) :: field_tend
1922 TYPE( grid_config_rec_type ) config_flags
1924 CHARACTER :: variable
1925 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf
1926 INTEGER :: b_dist, b_limit
1927 LOGICAL :: periodic_x
1929 periodic_x = config_flags%periodic_x
1931 variable = variable_in
1933 IF (variable == 'U') variable = 'u'
1934 IF (variable == 'V') variable = 'v'
1935 IF (variable == 'M') variable = 'm'
1936 IF (variable == 'H') variable = 'h'
1940 itf = min(ite,ide-1)
1943 jtf = min(jte,jde-1)
1945 IF (variable == 'u') ibe = ide
1946 IF (variable == 'u') itf = min(ite,ide)
1947 IF (variable == 'v') jbe = jde
1948 IF (variable == 'v') jtf = min(jte,jde)
1949 IF (variable == 'm') ktf = kte
1950 IF (variable == 'h') ktf = kte
1952 IF (jts - jbs .lt. spec_zone) THEN
1954 DO j = jts, min(jtf,jbs+spec_zone-1)
1957 IF(periodic_x)b_limit = 0
1959 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1960 g_field(i,k,j) = g_field(i,k,j) + dt*g_field_tend(i,k,j)
1961 field(i,k,j) = field(i,k,j) + dt*field_tend(i,k,j)
1966 IF (jbe - jtf .lt. spec_zone) THEN
1968 DO j = max(jts,jbe-spec_zone+1), jtf
1971 IF(periodic_x)b_limit = 0
1973 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1974 g_field(i,k,j) = g_field(i,k,j) + dt*g_field_tend(i,k,j)
1975 field(i,k,j) = field(i,k,j) + dt*field_tend(i,k,j)
1981 IF(.NOT.periodic_x)THEN
1982 IF (its - ibs .lt. spec_zone) THEN
1984 DO i = its, min(itf,ibs+spec_zone-1)
1987 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1988 g_field(i,k,j) = g_field(i,k,j) + dt*g_field_tend(i,k,j)
1989 field(i,k,j) = field(i,k,j) + dt*field_tend(i,k,j)
1995 IF (ibe - itf .lt. spec_zone) THEN
1997 DO i = max(its,ibe-spec_zone+1), itf
2000 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2001 g_field(i,k,j) = g_field(i,k,j) + dt*g_field_tend(i,k,j)
2002 field(i,k,j) = field(i,k,j) + dt*field_tend(i,k,j)
2009 END SUBROUTINE g_spec_bdyupdate
2010 !------------------------------------------------------------------------
2011 ! Generated by TAPENADE (INRIA, Tropics team)
2012 ! Tapenade 3.10 (r5498) - 20 Jan 2015 09:48
2014 ! Differentiation of spec_bdy_final in forward (tangent) mode:
2015 ! variations of useful results: field
2016 ! with respect to varying inputs: field field_bdy_xe field_bdy_tend_xe
2017 ! field_bdy_xs field_bdy_tend_xs field_bdy_ye field_bdy_tend_ye
2018 ! field_bdy_ys field_bdy_tend_ys mu
2019 ! RW status of diff variables: field:in-out field_bdy_xe:in field_bdy_tend_xe:in
2020 ! field_bdy_xs:in field_bdy_tend_xs:in field_bdy_ye:in
2021 ! field_bdy_tend_ye:in field_bdy_ys:in field_bdy_tend_ys:in
2026 SUBROUTINE g_SPEC_BDY_FINAL(field, fieldd, mu, mud, msf, field_bdy_xs, &
2027 & field_bdy_xsd, field_bdy_xe, field_bdy_xed, field_bdy_ys, &
2028 & field_bdy_ysd, field_bdy_ye, field_bdy_yed, field_bdy_tend_xs, &
2029 & field_bdy_tend_xsd, field_bdy_tend_xe, field_bdy_tend_xed, &
2030 & field_bdy_tend_ys, field_bdy_tend_ysd, field_bdy_tend_ye, &
2031 & field_bdy_tend_yed, variable_in, config_flags, spec_bdy_width, &
2032 & spec_zone, dtbc, ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms&
2033 & , kme, ips, ipe, jps, jpe, kps, kpe, its, ite, jts, jte, kts, kte)
2035 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde
2036 INTEGER, INTENT(IN) :: ims, ime, jms, jme, kms, kme
2037 INTEGER, INTENT(IN) :: ips, ipe, jps, jpe, kps, kpe
2038 INTEGER, INTENT(IN) :: its, ite, jts, jte, kts, kte
2039 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone
2040 REAL, INTENT(IN) :: dtbc
2041 CHARACTER, INTENT(IN) :: variable_in
2042 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: field
2043 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: fieldd
2044 REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN) :: mu, msf
2045 REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN) :: mud
2046 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
2047 & field_bdy_xs, field_bdy_xe
2048 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
2049 & field_bdy_xsd, field_bdy_xed
2050 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
2051 & field_bdy_ys, field_bdy_ye
2052 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
2053 & field_bdy_ysd, field_bdy_yed
2054 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
2055 & field_bdy_tend_xs, field_bdy_tend_xe
2056 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
2057 & field_bdy_tend_xsd, field_bdy_tend_xed
2058 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
2059 & field_bdy_tend_ys, field_bdy_tend_ye
2060 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
2061 & field_bdy_tend_ysd, field_bdy_tend_yed
2062 TYPE(GRID_CONFIG_REC_TYPE) :: config_flags
2063 CHARACTER :: variable
2064 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, im1, ip1
2065 INTEGER :: b_dist, b_limit
2066 REAL :: bfield, xmsf, xmu
2067 REAL :: bfieldd, xmud
2068 LOGICAL :: periodic_x, msfcouple, mucouple
2081 periodic_x = config_flags%periodic_x
2082 variable = variable_in
2083 IF (variable .EQ. 'U') variable = 'u'
2084 IF (variable .EQ. 'V') variable = 'v'
2085 IF (variable .EQ. 'W') variable = 'w'
2086 IF (variable .EQ. 'M') variable = 'm'
2087 IF (variable .EQ. 'T') variable = 't'
2088 IF (variable .EQ. 'H') variable = 'h'
2091 IF (ite .GT. ide - 1) THEN
2098 IF (jte .GT. jde - 1) THEN
2104 IF (variable .EQ. 'u') ibe = ide
2105 IF (variable .EQ. 'u') THEN
2106 IF (ite .GT. ide) THEN
2112 IF (variable .EQ. 'v') jbe = jde
2113 IF (variable .EQ. 'v') THEN
2114 IF (jte .GT. jde) THEN
2120 IF (variable .EQ. 'm') ktf = kde
2121 IF (variable .EQ. 'h') ktf = kde
2122 IF (variable .EQ. 'w') ktf = kde
2125 IF ((variable .EQ. 'u' .OR. variable .EQ. 'v') .OR. variable .EQ. 'w'&
2126 & ) msfcouple = .true.
2127 IF (variable .EQ. 'm') mucouple = .false.
2130 IF (jts - jbs .LT. spec_zone) THEN
2131 IF (jtf .GT. jbs + spec_zone - 1) THEN
2132 min1 = jbs + spec_zone - 1
2142 IF (periodic_x) b_limit = 0
2144 IF (its .LT. b_limit + ibs) THEN
2145 max1 = b_limit + ibs
2149 IF (itf .GT. ibe - b_limit) THEN
2150 min3 = ibe - b_limit
2155 bfieldd = field_bdy_ysd(i, k, b_dist+1) + dtbc*&
2156 & field_bdy_tend_ysd(i, k, b_dist+1)
2157 bfield = field_bdy_ys(i, k, b_dist+1) + dtbc*field_bdy_tend_ys&
2159 IF (msfcouple) xmsf = msf(i, j)
2164 fieldd(i, k, j) = (xmsf*bfieldd*xmu-xmsf*bfield*xmud)/xmu**2
2165 field(i, k, j) = xmsf*bfield/xmu
2172 IF (jbe - jtf .LT. spec_zone) THEN
2173 IF (jts .LT. jbe - spec_zone + 1) THEN
2174 max2 = jbe - spec_zone + 1
2182 IF (periodic_x) b_limit = 0
2184 IF (its .LT. b_limit + ibs) THEN
2185 max3 = b_limit + ibs
2189 IF (itf .GT. ibe - b_limit) THEN
2190 min4 = ibe - b_limit
2195 bfieldd = field_bdy_yed(i, k, b_dist+1) + dtbc*&
2196 & field_bdy_tend_yed(i, k, b_dist+1)
2197 bfield = field_bdy_ye(i, k, b_dist+1) + dtbc*field_bdy_tend_ye&
2199 IF (msfcouple) xmsf = msf(i, j)
2204 fieldd(i, k, j) = (xmsf*bfieldd*xmu-xmsf*bfield*xmud)/xmu**2
2205 field(i, k, j) = xmsf*bfield/xmu
2210 IF (.NOT.periodic_x) THEN
2211 IF (its - ibs .LT. spec_zone) THEN
2212 IF (itf .GT. ibs + spec_zone - 1) THEN
2213 min2 = ibs + spec_zone - 1
2221 IF (jts .LT. b_dist + jbs + 1) THEN
2222 max4 = b_dist + jbs + 1
2226 IF (jtf .GT. jbe - b_dist - 1) THEN
2227 min5 = jbe - b_dist - 1
2232 bfieldd = field_bdy_xsd(j, k, b_dist+1) + dtbc*&
2233 & field_bdy_tend_xsd(j, k, b_dist+1)
2234 bfield = field_bdy_xs(j, k, b_dist+1) + dtbc*&
2235 & field_bdy_tend_xs(j, k, b_dist+1)
2236 IF (msfcouple) xmsf = msf(i, j)
2241 fieldd(i, k, j) = (xmsf*bfieldd*xmu-xmsf*bfield*xmud)/xmu**2
2242 field(i, k, j) = xmsf*bfield/xmu
2247 IF (ibe - itf .LT. spec_zone) THEN
2248 IF (its .LT. ibe - spec_zone + 1) THEN
2249 max5 = ibe - spec_zone + 1
2257 IF (jts .LT. b_dist + jbs + 1) THEN
2258 max6 = b_dist + jbs + 1
2262 IF (jtf .GT. jbe - b_dist - 1) THEN
2263 min6 = jbe - b_dist - 1
2268 bfieldd = field_bdy_xed(j, k, b_dist+1) + dtbc*&
2269 & field_bdy_tend_xed(j, k, b_dist+1)
2270 bfield = field_bdy_xe(j, k, b_dist+1) + dtbc*&
2271 & field_bdy_tend_xe(j, k, b_dist+1)
2272 IF (msfcouple) xmsf = msf(i, j)
2277 fieldd(i, k, j) = (xmsf*bfieldd*xmu-xmsf*bfield*xmud)/xmu**2
2278 field(i, k, j) = xmsf*bfield/xmu
2284 END SUBROUTINE g_SPEC_BDY_FINAL
2285 !------------------------------------------------------------------------
2287 SUBROUTINE g_zero_grad_bdy ( field, g_field, &
2288 variable_in, config_flags, &
2290 ids,ide, jds,jde, kds,kde, & ! domain dims
2291 ims,ime, jms,jme, kms,kme, & ! memory dims
2292 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
2293 its,ite, jts,jte, kts,kte )
2295 ! This subroutine sets zero gradient conditions in the boundary specified region.
2296 ! spec_zone is the width of the outer specified b.c.s that are set here.
2301 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
2302 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
2303 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
2304 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
2305 INTEGER, INTENT(IN ) :: spec_zone
2306 CHARACTER, INTENT(IN ) :: variable_in
2309 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: g_field
2310 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: field
2311 TYPE( grid_config_rec_type ) config_flags
2313 CHARACTER :: variable
2314 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, i_inner, j_inner
2315 INTEGER :: b_dist, b_limit
2316 LOGICAL :: periodic_x
2318 periodic_x = config_flags%periodic_x
2320 variable = variable_in
2322 IF (variable == 'U') variable = 'u'
2323 IF (variable == 'V') variable = 'v'
2327 itf = min(ite,ide-1)
2330 jtf = min(jte,jde-1)
2332 IF (variable == 'u') ibe = ide
2333 IF (variable == 'u') itf = min(ite,ide)
2334 IF (variable == 'v') jbe = jde
2335 IF (variable == 'v') jtf = min(jte,jde)
2336 IF (variable == 'w') ktf = kde
2338 IF (jts - jbs .lt. spec_zone) THEN
2340 DO j = jts, min(jtf,jbs+spec_zone-1)
2343 IF(periodic_x)b_limit = 0
2345 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2346 i_inner = max(i,ibs+spec_zone)
2347 i_inner = min(i_inner,ibe-spec_zone)
2348 IF(periodic_x)i_inner = i
2349 g_field(i,k,j) = g_field(i_inner,k,jbs+spec_zone)
2350 field(i,k,j) = field(i_inner,k,jbs+spec_zone)
2355 IF (jbe - jtf .lt. spec_zone) THEN
2357 DO j = max(jts,jbe-spec_zone+1), jtf
2360 IF(periodic_x)b_limit = 0
2362 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2363 i_inner = max(i,ibs+spec_zone)
2364 i_inner = min(i_inner,ibe-spec_zone)
2365 IF(periodic_x)i_inner = i
2366 g_field(i,k,j) = g_field(i_inner,k,jbe-spec_zone)
2367 field(i,k,j) = field(i_inner,k,jbe-spec_zone)
2373 IF(.NOT.periodic_x)THEN
2374 IF (its - ibs .lt. spec_zone) THEN
2376 DO i = its, min(itf,ibs+spec_zone-1)
2379 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2380 j_inner = max(j,jbs+spec_zone)
2381 j_inner = min(j_inner,jbe-spec_zone)
2382 g_field(i,k,j) = g_field(ibs+spec_zone,k,j_inner)
2383 field(i,k,j) = field(ibs+spec_zone,k,j_inner)
2389 IF (ibe - itf .lt. spec_zone) THEN
2391 DO i = max(its,ibe-spec_zone+1), itf
2394 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2395 j_inner = max(j,jbs+spec_zone)
2396 j_inner = min(j_inner,jbe-spec_zone)
2397 g_field(i,k,j) = g_field(ibe-spec_zone,k,j_inner)
2398 field(i,k,j) = field(ibe-spec_zone,k,j_inner)
2405 END SUBROUTINE g_zero_grad_bdy
2406 !------------------------------------------------------------------------
2408 SUBROUTINE g_flow_dep_bdy ( field, g_field, &
2409 u, v, config_flags, &
2411 ids,ide, jds,jde, kds,kde, & ! domain dims
2412 ims,ime, jms,jme, kms,kme, & ! memory dims
2413 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
2414 its,ite, jts,jte, kts,kte )
2418 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde
2419 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme
2420 INTEGER, INTENT(IN) :: ips,ipe, jps,jpe, kps,kpe
2421 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte
2422 INTEGER, INTENT(IN) :: spec_zone
2424 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: g_field
2425 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: field
2426 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN ) :: u
2427 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN ) :: v
2428 TYPE(grid_config_rec_type), INTENT(IN) :: config_flags
2430 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, i_inner, j_inner
2431 INTEGER :: b_dist, b_limit
2432 LOGICAL :: periodic_x
2435 periodic_x = config_flags%periodic_x
2439 itf = min(ite,ide-1)
2442 jtf = min(jte,jde-1)
2445 IF (jts - jbs .lt. spec_zone) THEN
2447 DO j = jts, min(jtf,jbs+spec_zone-1)
2450 IF(periodic_x)b_limit = 0
2452 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2453 i_inner = max(i,ibs+spec_zone)
2454 i_inner = min(i_inner,ibe-spec_zone)
2455 IF(periodic_x)i_inner = i
2456 IF(v(i,k,j) .lt. 0.)THEN
2457 g_field(i,k,j) = g_field(i_inner,k,jbs+spec_zone)
2458 field(i,k,j) = field(i_inner,k,jbs+spec_zone)
2467 IF (jbe - jtf .lt. spec_zone) THEN
2469 DO j = max(jts,jbe-spec_zone+1), jtf
2472 IF(periodic_x)b_limit = 0
2474 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2475 i_inner = max(i,ibs+spec_zone)
2476 i_inner = min(i_inner,ibe-spec_zone)
2477 IF(periodic_x)i_inner = i
2478 IF(v(i,k,j+1) .gt. 0.)THEN
2479 g_field(i,k,j) = g_field(i_inner,k,jbe-spec_zone)
2480 field(i,k,j) = field(i_inner,k,jbe-spec_zone)
2490 IF(.NOT.periodic_x)THEN
2491 IF (its - ibs .lt. spec_zone) THEN
2493 DO i = its, min(itf,ibs+spec_zone-1)
2496 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2497 j_inner = max(j,jbs+spec_zone)
2498 j_inner = min(j_inner,jbe-spec_zone)
2499 IF(u(i,k,j) .lt. 0.)THEN
2500 g_field(i,k,j) = g_field(ibs+spec_zone,k,j_inner)
2501 field(i,k,j) = field(ibs+spec_zone,k,j_inner)
2511 IF (ibe - itf .lt. spec_zone) THEN
2513 DO i = max(its,ibe-spec_zone+1), itf
2516 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2517 j_inner = max(j,jbs+spec_zone)
2518 j_inner = min(j_inner,jbe-spec_zone)
2519 IF(u(i+1,k,j) .gt. 0.)THEN
2520 g_field(i,k,j) = g_field(ibe-spec_zone,k,j_inner)
2521 field(i,k,j) = field(ibe-spec_zone,k,j_inner)
2532 END SUBROUTINE g_flow_dep_bdy
2534 ! Generated by TAPENADE (INRIA, Tropics team)
2535 ! Tapenade 3.6 (r4165) - 21 sep 2011 20:54
2537 ! Differentiation of flow_dep_bdy_qnn in forward (tangent) mode:
2538 ! variations of useful results: field
2539 ! with respect to varying inputs: field
2540 ! RW status of diff variables: field:in-out
2544 SUBROUTINE G_FLOW_DEP_BDY_QNN(field, fieldd, u, v, config_flags, &
2545 & spec_zone, ccn_conc, ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme&
2546 & , ips, ipe, jps, jpe, kps, kpe, its, ite, jts, jte, kts, kte)
2548 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde
2549 INTEGER, INTENT(IN) :: ims, ime, jms, jme, kms, kme
2550 INTEGER, INTENT(IN) :: ips, ipe, jps, jpe, kps, kpe
2551 INTEGER, INTENT(IN) :: its, ite, jts, jte, kts, kte
2552 INTEGER, INTENT(IN) :: spec_zone
2553 REAL, INTENT(IN) :: ccn_conc ! RAS
2554 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: field
2555 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: fieldd
2556 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: u
2557 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: v
2558 TYPE(GRID_CONFIG_REC_TYPE) :: config_flags
2559 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, i_inner, &
2561 INTEGER :: b_dist, b_limit
2562 LOGICAL :: periodic_x
2577 periodic_x = config_flags%periodic_x
2580 IF (ite .GT. ide - 1) THEN
2587 IF (jte .GT. jde - 1) THEN
2593 IF (jts - jbs .LT. spec_zone) THEN
2594 IF (jtf .GT. jbs + spec_zone - 1) THEN
2595 min1 = jbs + spec_zone - 1
2603 IF (periodic_x) b_limit = 0
2605 IF (its .LT. b_limit + ibs) THEN
2606 max1 = b_limit + ibs
2610 IF (itf .GT. ibe - b_limit) THEN
2611 min3 = ibe - b_limit
2616 IF (i .LT. ibs + spec_zone) THEN
2617 i_inner = ibs + spec_zone
2621 IF (i_inner .GT. ibe - spec_zone) THEN
2622 i_inner = ibe - spec_zone
2626 IF (periodic_x) i_inner = i
2627 IF (v(i, k, j) .LT. 0.) THEN
2628 fieldd(i, k, j) = fieldd(i_inner, k, jbs+spec_zone)
2629 field(i, k, j) = field(i_inner, k, jbs+spec_zone)
2631 fieldd(i, k, j) = 0.0
2632 field(i, k, j) = ccn_conc
2638 IF (jbe - jtf .LT. spec_zone) THEN
2639 IF (jts .LT. jbe - spec_zone + 1) THEN
2640 max2 = jbe - spec_zone + 1
2648 IF (periodic_x) b_limit = 0
2650 IF (its .LT. b_limit + ibs) THEN
2651 max3 = b_limit + ibs
2655 IF (itf .GT. ibe - b_limit) THEN
2656 min4 = ibe - b_limit
2661 IF (i .LT. ibs + spec_zone) THEN
2662 i_inner = ibs + spec_zone
2666 IF (i_inner .GT. ibe - spec_zone) THEN
2667 i_inner = ibe - spec_zone
2671 IF (periodic_x) i_inner = i
2672 IF (v(i, k, j+1) .GT. 0.) THEN
2673 fieldd(i, k, j) = fieldd(i_inner, k, jbe-spec_zone)
2674 field(i, k, j) = field(i_inner, k, jbe-spec_zone)
2676 fieldd(i, k, j) = 0.0
2677 field(i, k, j) = ccn_conc
2683 IF (.NOT.periodic_x) THEN
2684 IF (its - ibs .LT. spec_zone) THEN
2685 IF (itf .GT. ibs + spec_zone - 1) THEN
2686 min2 = ibs + spec_zone - 1
2694 IF (jts .LT. b_dist + jbs + 1) THEN
2695 max4 = b_dist + jbs + 1
2699 IF (jtf .GT. jbe - b_dist - 1) THEN
2700 min5 = jbe - b_dist - 1
2705 IF (j .LT. jbs + spec_zone) THEN
2706 j_inner = jbs + spec_zone
2710 IF (j_inner .GT. jbe - spec_zone) THEN
2711 j_inner = jbe - spec_zone
2715 IF (u(i, k, j) .LT. 0.) THEN
2716 fieldd(i, k, j) = fieldd(ibs+spec_zone, k, j_inner)
2717 field(i, k, j) = field(ibs+spec_zone, k, j_inner)
2719 fieldd(i, k, j) = 0.0
2720 field(i, k, j) = ccn_conc
2726 IF (ibe - itf .LT. spec_zone) THEN
2727 IF (its .LT. ibe - spec_zone + 1) THEN
2728 max5 = ibe - spec_zone + 1
2736 IF (jts .LT. b_dist + jbs + 1) THEN
2737 max6 = b_dist + jbs + 1
2741 IF (jtf .GT. jbe - b_dist - 1) THEN
2742 min6 = jbe - b_dist - 1
2747 IF (j .LT. jbs + spec_zone) THEN
2748 j_inner = jbs + spec_zone
2752 IF (j_inner .GT. jbe - spec_zone) THEN
2753 j_inner = jbe - spec_zone
2757 IF (u(i+1, k, j) .GT. 0.) THEN
2758 fieldd(i, k, j) = fieldd(ibe-spec_zone, k, j_inner)
2759 field(i, k, j) = field(ibe-spec_zone, k, j_inner)
2761 fieldd(i, k, j) = 0.0
2762 field(i, k, j) = ccn_conc
2769 END SUBROUTINE G_FLOW_DEP_BDY_QNN
2771 !---------------------------------------------ntu3m---------------------------
2772 SUBROUTINE g_flow_dep_bdy_fixed_inflow(field,g_field,u,v,config_flags, &
2773 spec_zone,ids,ide,jds,jde,kds,kde,ims, &
2774 ime,jms,jme,kms,kme,ips,ipe,jps,jpe,kps, &
2775 kpe,its,ite,jts,jte,kts,kte)
2776 !-----------------------------------------------------------------------------
2779 INTEGER, INTENT(IN) :: ids,ide,jds,jde,kds,kde,ims,ime,jms,jme,kms, &
2780 kme,ips,ipe,jps,jpe,kps,kpe,its,ite,jts,jte, &
2782 REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: g_field, &
2784 REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(IN) :: u,v
2785 TYPE(grid_config_rec_type), INTENT(IN) :: config_flags
2786 INTEGER :: i,j,k,ibs,ibe,jbs,jbe,itf,jtf,ktf,i_inner,j_inner, &
2788 LOGICAL :: periodic_x
2790 periodic_x = config_flags%periodic_x
2793 itf = min(ite,ide-1)
2796 jtf = min(jte,jde-1)
2799 IF (jts - jbs .lt. spec_zone) THEN
2801 DO j = jts, min(jtf,jbs+spec_zone-1)
2804 IF (periodic_x) b_limit = 0
2806 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2807 i_inner = max(i,ibs+spec_zone)
2808 i_inner = min(i_inner,ibe-spec_zone)
2809 IF (periodic_x) i_inner = i
2810 IF (v(i,k,j) .lt. 0.) THEN
2811 g_field(i,k,j) = g_field(i_inner,k,jbs+spec_zone)
2812 field(i,k,j) = field(i_inner,k,jbs+spec_zone)
2814 g_field(i,k,j) = g_field(i,k,j)
2815 field(i,k,j) = field(i,k,j)
2821 IF (jbe - jtf .lt. spec_zone) THEN
2823 DO j = max(jts,jbe-spec_zone+1), jtf
2826 IF (periodic_x) b_limit = 0
2828 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2829 i_inner = max(i,ibs+spec_zone)
2830 i_inner = min(i_inner,ibe-spec_zone)
2831 IF (periodic_x) i_inner = i
2832 IF (v(i,k,j+1) .gt. 0.) THEN
2833 g_field(i,k,j) = g_field(i_inner,k,jbe-spec_zone)
2834 field(i,k,j) = field(i_inner,k,jbe-spec_zone)
2836 g_field(i,k,j) = g_field(i,k,j)
2837 field(i,k,j) = field(i,k,j)
2844 IF (.NOT.periodic_x) THEN
2845 IF (its - ibs .lt. spec_zone) THEN
2847 DO i = its, min(itf,ibs+spec_zone-1)
2850 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2851 j_inner = max(j,jbs+spec_zone)
2852 j_inner = min(j_inner,jbe-spec_zone)
2853 IF (u(i,k,j) .lt. 0.) THEN
2854 g_field(i,k,j) = g_field(ibs+spec_zone,k,j_inner)
2855 field(i,k,j) = field(ibs+spec_zone,k,j_inner)
2857 g_field(i,k,j) = g_field(i,k,j)
2858 field(i,k,j) = field(i,k,j)
2865 IF (ibe - itf .lt. spec_zone) THEN
2867 DO i = max(its,ibe-spec_zone+1), itf
2870 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2871 j_inner = max(j,jbs+spec_zone)
2872 j_inner = min(j_inner,jbe-spec_zone)
2873 IF (u(i+1,k,j) .gt. 0.) THEN
2874 g_field(i,k,j) = g_field(ibe-spec_zone,k,j_inner)
2875 field(i,k,j) = field(ibe-spec_zone,k,j_inner)
2877 g_field(i,k,j) = g_field(i,k,j)
2878 field(i,k,j) = field(i,k,j)
2886 END SUBROUTINE g_flow_dep_bdy_fixed_inflow
2887 !-----------------------------------------------ntu3m----------------------------
2889 END MODULE g_module_bc