1 !WRF+/AD: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 a_set_physical_bc2d( a_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 ) :: a_dat
42 TYPE( grid_config_rec_type ) config_flags
44 INTEGER :: i, j, istag, jstag, itime
46 LOGICAL :: debug, open_bc_copy
56 open_bc_copy = .false.
58 variable = variable_in
59 IF ( variable_in .ge. 'A' .and. variable_in .le. 'Z' ) THEN
60 variable = CHAR( ICHAR(variable_in) - ICHAR('A') + ICHAR('a') )
62 IF ((variable == 'u') .or. (variable == 'v') .or. &
63 (variable == 'w') .or. (variable == 't') .or. &
64 (variable == 'x') .or. (variable == 'y') .or. &
65 (variable == 'r') .or. (variable == 'p') ) open_bc_copy = .true.
67 ! begin, first set a staggering variable
72 IF ((variable == 'u') .or. (variable == 'x')) istag = 0
73 IF ((variable == 'v') .or. (variable == 'y')) jstag = 0
76 write(6,*) ' in bc2d, var is ',variable, istag, jstag
77 write(6,*) ' b.cs are ', &
78 config_flags%periodic_x, &
79 config_flags%periodic_y
82 IF ( variable == 'd' ) then !JDM
86 IF ( variable == 'e' ) then !JDM
89 IF ( variable == 'f' ) then !JDM
93 ! fix corners for doubly periodic domains
95 IF ( config_flags%periodic_x .and. config_flags%periodic_y &
96 .and. (ids == ips) .and. (ide == ipe) &
97 .and. (jds == jps) .and. (jde == jpe) ) THEN
99 IF ( (its == ids) .and. (jte == jde) ) THEN ! upper left corner fill
101 DO i = -(bdyzone-1),0,1
102 a_aux = a_dat(ids+i-1,jde+j+jstag)
103 a_dat(ids+i-1,jde+j+jstag) = 0.0
104 a_dat(ide+i-1,jds+j+jstag) = a_dat(ide+i-1,jds+j+jstag) + a_aux
110 IF ( (ite == ide) .and. (jte == jde) ) THEN ! upper right corner fill
113 a_aux = a_dat(ide+i+istag,jde+j+jstag)
114 a_dat(ide+i+istag,jde+j+jstag) = 0.0
115 a_dat(ids+i+istag,jds+j+jstag) = a_dat(ids+i+istag,jds+j+jstag) + a_aux
121 IF ( (ite == ide) .and. (jts == jds) ) THEN ! lower right corner fill
122 DO j = -(bdyzone-1),0,1
124 a_aux = a_dat(ide+i+istag,jds+j-1)
125 a_dat(ide+i+istag,jds+j-1) = 0.0
126 a_dat(ids+i+istag,jde+j-1) = a_dat(ids+i+istag,jde+j-1) + a_aux
132 IF ( (its == ids) .and. (jts == jds) ) THEN ! lower left corner fill
133 DO j = -(bdyzone-1),0,1
134 DO i = -(bdyzone-1),0,1
135 a_aux = a_dat(ids+i-1,jds+j-1)
136 a_dat(ids+i-1,jds+j-1) = 0.0
137 a_dat(ide+i-1,jde+j-1) = a_dat(ide+i-1,jde+j-1) + a_aux
145 ! same procedure in y
147 periodicity_y: IF( ( config_flags%periodic_y ) ) THEN
149 IF ( ( jds == jps ) .and. ( jde == jpe ) ) THEN ! test of both north and south on processor
151 IF( jte == jde ) then
153 DO j = bdyzone,-jstag,-1
154 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
155 a_aux = a_dat(i,jde+j+jstag)
156 a_dat(i,jde+j+jstag) = 0.0
157 a_dat(i,jds+j+jstag) = a_dat(i,jds+j+jstag) + a_aux
164 IF( jts == jds ) then
166 DO j = -(bdyzone-1),0,1
167 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
168 a_aux = a_dat(i,jds+j-1)
169 a_dat(i,jds+j-1) = 0.0
170 a_dat(i,jde+j-1) = a_dat(i,jde+j-1) + a_aux
181 ! set open b.c in Y copy into boundary zone here. WCS, 19 March 2000
183 ! now the open boundary copy at ye
185 open_ye: IF( ( config_flags%open_ye .or. &
186 config_flags%polar .or. &
187 config_flags%specified .or. &
188 config_flags%nested ) .and. &
189 ( jte == jde ) .and. open_bc_copy ) THEN
191 IF (variable /= 'v' .and. variable /= 'y' ) THEN
193 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
194 a_aux = a_dat(i,jde )
196 a_dat(i,jde-1) = a_dat(i,jde-1) + a_aux
197 a_aux = a_dat(i,jde+1)
199 a_dat(i,jde-1) = a_dat(i,jde-1) + a_aux
200 a_aux = a_dat(i,jde+2)
202 a_dat(i,jde-1) = a_dat(i,jde-1) + a_aux
208 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
209 a_aux = a_dat(i,jde+1)
211 a_dat(i,jde ) = a_dat(i,jde ) + a_aux
212 a_aux = a_dat(i,jde+2)
214 a_dat(i,jde ) = a_dat(i,jde ) + a_aux
215 a_aux = a_dat(i,jde+3)
217 a_dat(i,jde ) = a_dat(i,jde ) + a_aux
225 open_ys: IF( ( config_flags%open_ys .or. &
226 config_flags%polar .or. &
227 config_flags%specified .or. &
228 config_flags%nested ) .and. &
229 ( jts == jds) .and. open_bc_copy ) THEN
231 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
232 a_aux = a_dat(i,jds-1)
234 a_dat(i,jds) = a_dat(i,jds) + a_aux
235 a_aux = a_dat(i,jds-2)
237 a_dat(i,jds) = a_dat(i,jds) + a_aux
238 a_aux = a_dat(i,jds-3)
240 a_dat(i,jds) = a_dat(i,jds) + a_aux
246 ! now the symmetry boundary at ye
248 symmetry_ye: IF( ( config_flags%symmetric_ye ) .and. &
249 ( jte == jde ) ) THEN
251 IF ( (variable /= 'v') .and. (variable /= 'y') ) THEN
254 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
255 a_aux = a_dat(i,jde+j-1)
256 a_dat(i,jde+j-1) = 0.0
257 a_dat(i,jde-j) = a_dat(i,jde-j) + a_aux
264 IF (variable == 'v' ) THEN
267 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
268 a_aux = - a_dat(i,jde+j)
270 a_dat(i,jde-j) = a_dat(i,jde-j) + a_aux
278 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
279 a_aux = a_dat(i,jde+j)
281 a_dat(i,jde-j) = a_dat(i,jde-j) + a_aux
292 symmetry_ys: IF( ( config_flags%symmetric_ys ) .and. &
295 IF ( (variable /= 'v') .and. (variable /= 'y') ) THEN
298 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
299 a_aux = a_dat(i,jds-j)
301 a_dat(i,jds+j-1) = a_dat(i,jds+j-1) + a_aux
308 IF (variable == 'v') THEN
311 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
312 a_aux = - a_dat(i,jds-j)
314 a_dat(i,jds+j) = a_dat(i,jds+j) + a_aux
322 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
323 a_aux = a_dat(i,jds-j)
325 a_dat(i,jds+j) = a_dat(i,jds+j) + a_aux
338 periodicity_x: IF( ( config_flags%periodic_x ) ) THEN
340 IF ( ( ids == ips ) .and. ( ide == ipe ) ) THEN ! test if east and west both on-processor
341 IF ( ite == ide ) THEN
343 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
344 DO i = bdyzone,-istag,-1
345 a_aux = a_dat(ide+i+istag,j)
346 a_dat(ide+i+istag,j) = 0.0
347 a_dat(ids+i+istag,j) = a_dat(ids+i+istag,j) + a_aux
354 IF ( its == ids ) THEN
356 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
357 DO i = -(bdyzone-1),0,1
358 a_aux = a_dat(ids+i-1,j)
359 a_dat(ids+i-1,j) = 0.0
360 a_dat(ide+i-1,j) = a_dat(ide+i-1,j) + a_aux
370 ! set open b.c in X copy into boundary zone here. WCS, 19 March 2000
372 ! now the open boundary copy at xe
374 open_xe: IF( ( config_flags%open_xe .or. &
375 config_flags%specified .or. &
376 config_flags%nested ) .and. &
377 ( ite == ide ) .and. open_bc_copy ) THEN
379 IF ( variable /= 'u' .and. variable /= 'x') THEN
381 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
382 a_aux = a_dat(ide ,j)
384 a_dat(ide-1,j) = a_dat(ide-1,j) + a_aux
385 a_aux = a_dat(ide+1,j)
387 a_dat(ide-1,j) = a_dat(ide-1,j) + a_aux
388 a_aux = a_dat(ide+2,j)
390 a_dat(ide-1,j) = a_dat(ide-1,j) + a_aux
396 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
397 a_aux = a_dat(ide+1,j)
399 a_dat(ide,j) = a_dat(ide,j) + a_aux
400 a_aux = a_dat(ide+2,j)
402 a_dat(ide,j) = a_dat(ide,j) + a_aux
403 a_aux = a_dat(ide+3,j)
405 a_dat(ide,j) = a_dat(ide,j) + a_aux
413 open_xs: IF( ( config_flags%open_xs .or. &
414 config_flags%specified .or. &
415 config_flags%nested ) .and. &
416 ( its == ids ) .and. open_bc_copy ) THEN
418 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
419 a_aux = a_dat(ids-1,j)
421 a_dat(ids,j) = a_dat(ids,j) + a_aux
422 a_aux = a_dat(ids-2,j)
424 a_dat(ids,j) = a_dat(ids,j) + a_aux
425 a_aux = a_dat(ids-3,j)
427 a_dat(ids,j) = a_dat(ids,j) + a_aux
433 ! end open b.c in X copy into boundary zone addition. WCS, 19 March 2000
435 ! now the symmetry boundary at xe
437 symmetry_xe: IF( ( config_flags%symmetric_xe ) .and. &
438 ( ite == ide ) ) THEN
440 IF ( (variable /= 'u') .and. (variable /= 'x') ) THEN
442 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
444 a_aux = a_dat(ide+i-1,j)
445 a_dat(ide+i-1,j) = 0.0
446 a_dat(ide-i,j) = a_dat(ide-i,j) + a_aux
453 IF (variable == 'u' ) THEN
455 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
456 DO i = bdyzone-1,0,-1
457 a_aux = - a_dat(ide+i,j)
459 a_dat(ide-i,j) = a_dat(ide-i,j) + a_aux
467 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
468 DO i = bdyzone-1,0,-1
469 a_aux = a_dat(ide+i,j)
471 a_dat(ide-i,j) = a_dat(ide-i,j) + a_aux
482 symmetry_xs: IF( ( config_flags%symmetric_xs ) .and. &
483 ( its == ids ) ) THEN
485 IF ( (variable /= 'u') .and. (variable /= 'x') ) THEN
487 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
489 a_aux = a_dat(ids-i,j)
491 a_dat(ide+i-1,j) = a_dat(ide+i-1,j) + a_aux
498 IF( variable == 'u' ) THEN
500 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
501 DO i = bdyzone-1,0,-1
502 a_aux = - a_dat(ids-i,j)
504 a_dat(ids+i,j) = a_dat(ids+i,j) + a_aux
511 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
512 DO i = bdyzone-1,0,-1
513 a_aux = a_dat(ids-i,j)
515 a_dat(ids+i,j) = a_dat(ids+i,j) + a_aux
528 END SUBROUTINE a_set_physical_bc2d
530 !-----------------------------------
532 SUBROUTINE a_set_physical_bc3d( a_dat, variable_in, &
534 ids,ide, jds,jde, kds,kde, & ! domain dims
535 ims,ime, jms,jme, kms,kme, & ! memory dims
536 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
537 its,ite, jts,jte, kts,kte )
541 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
542 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
543 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
544 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
545 CHARACTER, INTENT(IN ) :: variable_in
547 CHARACTER :: variable
549 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) :: a_dat
550 TYPE( grid_config_rec_type ) config_flags
552 INTEGER :: i, j, k, istag, jstag, itime, k_end
554 LOGICAL :: debug, open_bc_copy
564 open_bc_copy = .false.
566 variable = variable_in
567 IF ( variable_in .ge. 'A' .and. variable_in .le. 'Z' ) THEN
568 variable = CHAR( ICHAR(variable_in) - ICHAR('A') + ICHAR('a') )
571 IF ((variable == 'u') .or. (variable == 'v') .or. &
572 (variable == 'w') .or. (variable == 't') .or. &
573 (variable == 'd') .or. (variable == 'e') .or. &
574 (variable == 'x') .or. (variable == 'y') .or. &
575 (variable == 'f') .or. (variable == 'r') .or. &
576 (variable == 'p') ) open_bc_copy = .true.
578 ! begin, first set a staggering variable
582 k_end = max(1,min(kde-1,kte))
585 IF ((variable == 'u') .or. (variable == 'x')) istag = 0
586 IF ((variable == 'v') .or. (variable == 'y')) jstag = 0
587 IF ((variable == 'd') .or. (variable == 'xy')) then
591 IF ((variable == 'e') ) then
596 IF ((variable == 'f') ) then
601 IF ( variable == 'w') k_end = min(kde,kte)
606 write(6,*) ' in bc, var is ',variable, istag, jstag, kte, k_end
607 write(6,*) ' b.cs are ', &
608 config_flags%periodic_x, &
609 config_flags%periodic_y
612 ! fix corners for doubly periodic domains
614 IF ( config_flags%periodic_x .and. config_flags%periodic_y &
615 .and. (ids == ips) .and. (ide == ipe) &
616 .and. (jds == jps) .and. (jde == jpe) ) THEN
618 IF ( (its == ids) .and. (jte == jde) ) THEN ! upper left corner fill
621 DO i = -(bdyzone-1),0,1
622 a_aux = a_dat(ids+i-1,k,jde+j+jstag)
623 a_dat(ids+i-1,k,jde+j+jstag) = 0.0
624 a_dat(ide+i-1,k,jds+j+jstag) = a_dat(ide+i-1,k,jds+j+jstag) + a_aux
631 IF ( (ite == ide) .and. (jte == jde) ) THEN ! upper right corner fill
635 a_aux = a_dat(ide+i+istag,k,jde+j+jstag)
636 a_dat(ide+i+istag,k,jde+j+jstag) = 0.0
637 a_dat(ids+i+istag,k,jds+j+jstag) = a_dat(ids+i+istag,k,jds+j+jstag) + a_aux
644 IF ( (ite == ide) .and. (jts == jds) ) THEN ! lower right corner fill
645 DO j = -(bdyzone-1),0,1
648 a_aux = a_dat(ide+i+istag,k,jds+j-1)
649 a_dat(ide+i+istag,k,jds+j-1) = 0.0
650 a_dat(ids+i+istag,k,jde+j-1) = a_dat(ids+i+istag,k,jde+j-1) + a_aux
657 IF ( (its == ids) .and. (jts == jds) ) THEN ! lower left corner fill
658 DO j = -(bdyzone-1),0,1
660 DO i = -(bdyzone-1),0,1
661 a_aux = a_dat(ids+i-1,k,jds+j-1)
662 a_dat(ids+i-1,k,jds+j-1) = 0.0
663 a_dat(ide+i-1,k,jde+j-1) = a_dat(ide+i-1,k,jde+j-1) + a_aux
672 ! same procedure in y
674 periodicity_y: IF( ( config_flags%periodic_y ) ) THEN
675 IF ( ( jds == jps ) .and. ( jde == jpe ) ) THEN ! test if both north and south on processor
676 IF( jte == jde ) then
678 DO j = bdyzone,-jstag,-1
680 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
681 a_aux = a_dat(i,k,jde+j+jstag)
682 a_dat(i,k,jde+j+jstag) = 0.0
683 a_dat(i,k,jds+j+jstag) = a_dat(i,k,jds+j+jstag) + a_aux
691 IF( jts == jds ) then
693 DO j = -(bdyzone-1),0,1
695 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
696 a_aux = a_dat(i,k,jds+j-1)
697 a_dat(i,k,jds+j-1) = 0.0
698 a_dat(i,k,jde+j-1) = a_dat(i,k,jde+j-1) + a_aux
710 ! set open b.c in Y copy into boundary zone here. WCS, 19 March 2000
712 ! now the open boundary copy at ye
714 open_ye: IF( ( config_flags%open_ye .or. &
715 config_flags%polar .or. &
716 config_flags%specified .or. &
717 config_flags%nested ) .and. &
718 ( jte == jde ) .and. open_bc_copy ) THEN
720 IF (variable /= 'v' .and. variable /= 'y' ) THEN
723 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
724 a_aux = a_dat(i,k,jde )
725 a_dat(i,k,jde ) = 0.0
726 a_dat(i,k,jde-1) = a_dat(i,k,jde-1) + a_aux
727 a_aux = a_dat(i,k,jde+1)
728 a_dat(i,k,jde+1) = 0.0
729 a_dat(i,k,jde-1) = a_dat(i,k,jde-1) + a_aux
730 a_aux = a_dat(i,k,jde+2)
731 a_dat(i,k,jde+2) = 0.0
732 a_dat(i,k,jde-1) = a_dat(i,k,jde-1) + a_aux
740 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
741 a_aux = a_dat(i,k,jde+1)
742 a_dat(i,k,jde+1) = 0.0
743 a_dat(i,k,jde) = a_dat(i,k,jde) + a_aux
744 a_aux = a_dat(i,k,jde+2)
745 a_dat(i,k,jde+2) = 0.0
746 a_dat(i,k,jde) = a_dat(i,k,jde) + a_aux
747 a_aux = a_dat(i,k,jde+3)
748 a_dat(i,k,jde+3) = 0.0
749 a_dat(i,k,jde) = a_dat(i,k,jde) + a_aux
758 open_ys: IF( ( config_flags%open_ys .or. &
759 config_flags%polar .or. &
760 config_flags%specified .or. &
761 config_flags%nested ) .and. &
762 ( jts == jds) .and. open_bc_copy ) THEN
765 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
766 a_aux = a_dat(i,k,jds-1)
767 a_dat(i,k,jds-1) = 0.0
768 a_dat(i,k,jds) = a_dat(i,k,jds) + a_aux
769 a_aux = a_dat(i,k,jds-2)
770 a_dat(i,k,jds-2) = 0.0
771 a_dat(i,k,jds) = a_dat(i,k,jds) + a_aux
772 a_aux = a_dat(i,k,jds-3)
773 a_dat(i,k,jds-3) = 0.0
774 a_dat(i,k,jds) = a_dat(i,k,jds) + a_aux
781 ! end open b.c in Y copy into boundary zone addition. WCS, 19 March 2000
783 ! now the symmetry boundary at ye
785 symmetry_ye: IF( ( config_flags%symmetric_ye ) .and. &
786 ( jte == jde ) ) THEN
788 IF ( (variable /= 'v') .and. (variable /= 'y') ) THEN
792 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
793 a_aux = a_dat(i,k,jde+j-1)
794 a_dat(i,k,jde+j-1) = 0.0
795 a_dat(i,k,jde-j) = a_dat(i,k,jde-j) + a_aux
803 IF ( variable == 'v' ) THEN
807 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
808 a_aux = - a_dat(i,k,jde+j)
809 a_dat(i,k,jde+j) = 0.0
810 a_dat(i,k,jde-j) = a_dat(i,k,jde-j) + a_aux
820 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
821 a_aux = a_dat(i,k,jde+j)
822 a_dat(i,k,jde+j) = 0.0
823 a_dat(i,k,jde-j) = a_dat(i,k,jde-j) + a_aux
835 symmetry_ys: IF( ( config_flags%symmetric_ys ) .and. &
838 IF ( (variable /= 'v') .and. (variable /= 'y') ) THEN
842 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
843 a_aux = a_dat(i,k,jds-j)
844 a_dat(i,k,jds-j) = 0.0
845 a_dat(i,k,jds+j-1) = a_dat(i,k,jds+j-1) + a_aux
853 IF (variable == 'v') THEN
857 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
858 a_aux = - a_dat(i,k,jds-j)
859 a_dat(i,k,jds-j) = 0.0
860 a_dat(i,k,jds+j) = a_dat(i,k,jds+j) + a_aux
870 DO i = MIN(ite+1,ide+istag),MAX(ids,its-1),-1
871 a_aux = a_dat(i,k,jds-j)
872 a_dat(i,k,jds-j) = 0.0
873 a_dat(i,k,jds+j) = a_dat(i,k,jds+j) + a_aux
887 periodicity_x: IF( ( config_flags%periodic_x ) ) THEN
889 IF ( ( ids == ips ) .and. ( ide == ipe ) ) THEN ! test if both east and west on-processor
891 IF ( ite == ide ) THEN
893 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
895 DO i = bdyzone,-istag,-1
896 a_aux = a_dat(ide+i+istag,k,j)
897 a_dat(ide+i+istag,k,j) = 0.0
898 a_dat(ids+i+istag,k,j) = a_dat(ids+i+istag,k,j) + a_aux
906 IF ( its == ids ) THEN
908 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
910 DO i = -(bdyzone-1),0,1
911 a_aux = a_dat(ids+i-1,k,j)
912 a_dat(ids+i-1,k,j) = 0.0
913 a_dat(ide+i-1,k,j) = a_dat(ide+i-1,k,j) + a_aux
925 ! set open b.c in X copy into boundary zone here. WCS, 19 March 2000
927 ! now the open_xe boundary copy
929 open_xe: IF( ( config_flags%open_xe .or. &
930 config_flags%specified .or. &
931 config_flags%nested ) .and. &
932 ( ite == ide ) .and. open_bc_copy ) THEN
934 IF (variable /= 'u' .and. variable /= 'x' ) THEN
936 DO j = MIN(jte,jde+jstag)+bdyzone,jts-bdyzone,-1
938 a_aux = a_dat(ide ,k,j)
939 a_dat(ide ,k,j) = 0.0
940 a_dat(ide-1,k,j) = a_dat(ide-1,k,j) + a_aux
941 a_aux = a_dat(ide+1,k,j)
942 a_dat(ide+1,k,j) = 0.0
943 a_dat(ide-1,k,j) = a_dat(ide-1,k,j) + a_aux
944 a_aux = a_dat(ide+2,k,j)
945 a_dat(ide+2,k,j) = 0.0
946 a_dat(ide-1,k,j) = a_dat(ide-1,k,j) + a_aux
953 !!!!!!! I am not sure about this one! JM 20020402
954 DO j = MIN(jte+1,jde+jstag)+bdyzone,MAX(jds,jts-1)-bdyzone,-1
956 a_aux = a_dat(ide+1,k,j)
957 a_dat(ide+1,k,j) = 0.0
958 a_dat(ide,k,j) = a_dat(ide,k,j) + a_aux
959 a_aux = a_dat(ide+2,k,j)
960 a_dat(ide+2,k,j) = 0.0
961 a_dat(ide,k,j) = a_dat(ide,k,j) + a_aux
962 a_aux = a_dat(ide+3,k,j)
963 a_dat(ide+3,k,j) = 0.0
964 a_dat(ide,k,j) = a_dat(ide,k,j) + a_aux
973 open_xs: IF( ( config_flags%open_xs .or. &
974 config_flags%specified .or. &
975 config_flags%nested ) .and. &
976 ( its == ids ) .and. open_bc_copy ) THEN
978 DO j = MIN(jte,jde+jstag)+bdyzone,jts-bdyzone,-1
980 a_aux = a_dat(ids-1,k,j)
981 a_dat(ids-1,k,j) = 0.0
982 a_dat(ids,k,j) = a_dat(ids,k,j) + a_aux
983 a_aux = a_dat(ids-2,k,j)
984 a_dat(ids-2,k,j) = 0.0
985 a_dat(ids,k,j) = a_dat(ids,k,j) + a_aux
986 a_aux = a_dat(ids-3,k,j)
987 a_dat(ids-3,k,j) = 0.0
988 a_dat(ids,k,j) = a_dat(ids,k,j) + a_aux
995 ! end open b.c in X copy into boundary zone addition. WCS, 19 March 2000
997 ! now the symmetry boundary at xe
999 symmetry_xe: IF( ( config_flags%symmetric_xe ) .and. &
1000 ( ite == ide ) ) THEN
1002 IF ( (variable /= 'u') .and. (variable /= 'x') ) THEN
1004 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
1007 a_aux = a_dat(ide+i-1,k,j)
1008 a_dat(ide+i-1,k,j) = 0.0
1009 a_dat(ide-i,k,j) = a_dat(ide-i,k,j) + a_aux
1017 IF (variable == 'u') THEN
1019 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
1022 a_aux = - a_dat(ide+i,k,j)
1023 a_dat(ide+i,k,j) = 0.0
1024 a_dat(ide-i,k,j) = a_dat(ide-i,k,j) + a_aux
1032 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
1035 a_aux = a_dat(ide+i,k,j)
1036 a_dat(ide+i,k,j) = 0.0
1037 a_dat(ide-i,k,j) = a_dat(ide-i,k,j) + a_aux
1049 symmetry_xs: IF( ( config_flags%symmetric_xs ) .and. &
1050 ( its == ids ) ) THEN
1052 IF ( (variable /= 'u') .and. (variable /= 'x') ) THEN
1054 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
1057 a_aux = a_dat(ids-i,k,j)
1058 a_dat(ids-i,k,j) = 0.0
1059 a_dat(ids+i-1,k,j) = a_dat(ids+i-1,k,j) + a_aux
1067 IF ( variable == 'u' ) THEN
1069 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
1072 a_aux = - a_dat(ids-i,k,j)
1073 a_dat(ids-i,k,j) = 0.0
1074 a_dat(ids+i,k,j) = a_dat(ids+i,k,j) + a_aux
1082 DO j = MIN(jte+1,jde+jstag),MAX(jds,jts-1),-1
1085 a_aux = a_dat(ids-i,k,j)
1086 a_dat(ids-i,k,j) = 0.0
1087 a_dat(ids+i,k,j) = a_dat(ids+i,k,j) + a_aux
1099 END IF periodicity_x
1101 END SUBROUTINE a_set_physical_bc3d
1103 !------------------------------------------------------------------------
1105 SUBROUTINE a_init_module_bc
1106 END SUBROUTINE a_init_module_bc
1108 !------------------------------------------------------------------------
1110 ! a couple versions of this call to allow a smaller-than-memory dimensioned field (e.g. tile sized) ! to be passed in as the first argument. Both of these call the _core version defined below.
1111 SUBROUTINE a_relax_bdytend ( a_field, a_field_tend, &
1112 a_field_bdy_xs, a_field_bdy_xe, &
1113 a_field_bdy_ys, a_field_bdy_ye, &
1114 a_field_bdy_tend_xs, a_field_bdy_tend_xe, &
1115 a_field_bdy_tend_ys, a_field_bdy_tend_ye, &
1116 variable_in, config_flags, &
1117 spec_bdy_width, spec_zone, relax_zone, &
1119 ids,ide, jds,jde, kds,kde, & ! domain dims
1120 ims,ime, jms,jme, kms,kme, & ! memory dims
1121 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1122 its,ite, jts,jte, kts,kte )
1126 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde
1127 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme
1128 INTEGER, INTENT(IN) :: ips,ipe, jps,jpe, kps,kpe
1129 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte
1130 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone, relax_zone
1131 REAL, INTENT(IN) :: dtbc
1132 CHARACTER, INTENT(IN) :: variable_in
1134 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: a_field
1135 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN ) :: a_field_tend
1136 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_xs, a_field_bdy_xe
1137 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_ys, a_field_bdy_ye
1138 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_tend_xs, a_field_bdy_tend_xe
1139 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_tend_ys, a_field_bdy_tend_ye
1140 REAL, DIMENSION(spec_bdy_width), INTENT(IN) :: fcx, gcx
1141 TYPE(grid_config_rec_type), INTENT(IN) :: config_flags
1144 CALL a_relax_bdytend_core ( a_field, a_field_tend, &
1145 a_field_bdy_xs, a_field_bdy_xe, &
1146 a_field_bdy_ys, a_field_bdy_ye, &
1147 a_field_bdy_tend_xs, a_field_bdy_tend_xe, &
1148 a_field_bdy_tend_ys, a_field_bdy_tend_ye, &
1149 variable_in, config_flags, &
1150 spec_bdy_width, spec_zone, relax_zone, &
1152 ids,ide, jds,jde, kds,kde, & ! domain dims
1153 ims,ime, jms,jme, kms,kme, & ! memory dims
1154 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1155 its,ite, jts,jte, kts,kte, & ! patch dims
1156 ims,ime, jms,jme, kms,kme ) ! dimension of the field argument
1158 END SUBROUTINE a_relax_bdytend
1160 ! version that allows tile-sized version of field. Note, caller should define the
1161 ! field to be -+1 of tile size in each dimension because routine is going off onto halo
1162 ! for example, see relax_bdytend in dyn_em/module_bc_em.F
1163 SUBROUTINE a_relax_bdytend_tile ( a_field, a_field_tend, &
1164 a_field_bdy_xs, a_field_bdy_xe, &
1165 a_field_bdy_ys, a_field_bdy_ye, &
1166 a_field_bdy_tend_xs, a_field_bdy_tend_xe, &
1167 a_field_bdy_tend_ys, a_field_bdy_tend_ye, &
1168 variable_in, config_flags, &
1169 spec_bdy_width, spec_zone, relax_zone, &
1171 ids,ide, jds,jde, kds,kde, & ! domain dims
1172 ims,ime, jms,jme, kms,kme, & ! memory dims
1173 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1174 its,ite, jts,jte, kts,kte, &
1175 iXs,iXe, jXs,jXe, kXs,kXe & ! dims of first argument
1180 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde
1181 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme
1182 INTEGER, INTENT(IN) :: ips,ipe, jps,jpe, kps,kpe
1183 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte
1184 INTEGER, INTENT(IN) :: iXs,iXe, jXs,jXe, kXs,kXe
1185 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone, relax_zone
1186 REAL, INTENT(IN) :: dtbc
1187 CHARACTER, INTENT(IN) :: variable_in
1189 REAL, DIMENSION(iXs:iXe, kXs:kXe, jXs:jXe), INTENT(INOUT) :: a_field
1190 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN ) :: a_field_tend
1191 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_xs, a_field_bdy_xe
1192 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_ys, a_field_bdy_ye
1193 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_tend_xs, a_field_bdy_tend_xe
1194 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_tend_ys, a_field_bdy_tend_ye
1195 REAL, DIMENSION(spec_bdy_width), INTENT(IN) :: fcx, gcx
1196 TYPE(grid_config_rec_type), INTENT(IN) :: config_flags
1199 CALL a_relax_bdytend_core ( a_field, a_field_tend, &
1200 a_field_bdy_xs, a_field_bdy_xe, &
1201 a_field_bdy_ys, a_field_bdy_ye, &
1202 a_field_bdy_tend_xs, a_field_bdy_tend_xe, &
1203 a_field_bdy_tend_ys, a_field_bdy_tend_ye, &
1204 variable_in, config_flags, &
1205 spec_bdy_width, spec_zone, relax_zone, &
1207 ids,ide, jds,jde, kds,kde, & ! domain dims
1208 ims,ime, jms,jme, kms,kme, & ! memory dims
1209 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1210 its,ite, jts,jte, kts,kte, &
1211 iXs,iXe, jXs,jXe, kXs,kXe ) ! dimension of the field argument
1213 END SUBROUTINE a_relax_bdytend_tile
1215 ! Generated by TAPENADE (INRIA, Tropics team)
1216 ! Tapenade 3.5 (r3785) - 22 Mar 2011 18:35
1218 ! Differentiation of relax_bdytend_core in reverse (adjoint) mode:
1219 ! gradient of useful results: field field_bdy_xe field_bdy_tend_xe
1220 ! field_tend field_bdy_xs field_bdy_tend_xs field_bdy_ye
1221 ! field_bdy_tend_ye field_bdy_ys field_bdy_tend_ys
1222 ! with respect to varying inputs: field field_bdy_xe field_bdy_tend_xe
1223 ! field_tend field_bdy_xs field_bdy_tend_xs field_bdy_ye
1224 ! field_bdy_tend_ye field_bdy_ys field_bdy_tend_ys
1225 ! RW status of diff variables: field:incr field_bdy_xe:incr field_bdy_tend_xe:incr
1226 ! field_tend:in-out field_bdy_xs:incr field_bdy_tend_xs:incr
1227 ! field_bdy_ye:incr field_bdy_tend_ye:incr field_bdy_ys:incr
1228 ! field_bdy_tend_ys:incr
1233 ! field (1st arg) dims; might be tile or patch
1234 SUBROUTINE A_RELAX_BDYTEND_CORE(fieldb, field_tendb, &
1235 & field_bdy_xsb, field_bdy_xeb&
1236 & , field_bdy_ysb, field_bdy_yeb, &
1237 & field_bdy_tend_xsb, field_bdy_tend_xeb, &
1238 & field_bdy_tend_ysb, &
1239 & field_bdy_tend_yeb, variable_in, config_flags, spec_bdy_width, &
1240 & spec_zone, relax_zone, dtbc, fcx, gcx, ids, ide, jds, jde, kds, kde, &
1241 & ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe, its, ite, &
1242 & jts, jte, kts, kte, ixs, ixe, jxs, jxe, kxs, kxe)
1244 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde
1245 INTEGER, INTENT(IN) :: ims, ime, jms, jme, kms, kme
1246 INTEGER, INTENT(IN) :: ips, ipe, jps, jpe, kps, kpe
1247 INTEGER, INTENT(IN) :: its, ite, jts, jte, kts, kte
1248 INTEGER, INTENT(IN) :: ixs, ixe, jxs, jxe, kxs, kxe
1249 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone, relax_zone
1250 REAL, INTENT(IN) :: dtbc
1251 CHARACTER, INTENT(IN) :: variable_in
1252 REAL, DIMENSION(ixs:ixe, kxs:kxe, jxs:jxe) :: fieldb
1253 REAL, DIMENSION(ims:ime, kms:kme, jms:jme) :: field_tendb
1254 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width) :: field_bdy_xsb, &
1256 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width) :: field_bdy_ysb, &
1258 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width) :: &
1259 & field_bdy_tend_xsb, field_bdy_tend_xeb
1260 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width) :: &
1261 & field_bdy_tend_ysb, field_bdy_tend_yeb
1262 REAL, DIMENSION(spec_bdy_width), INTENT(IN) :: fcx, gcx
1263 TYPE(GRID_CONFIG_REC_TYPE) :: config_flags
1264 CHARACTER :: variable
1265 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, im1, ip1
1266 INTEGER :: b_dist, b_limit
1267 REAL :: fls0, fls1, fls2, fls3, fls4
1268 REAL :: fls0b, fls1b, fls2b, fls3b, fls4b
1269 LOGICAL :: periodic_x
1299 periodic_x = config_flags%periodic_x
1300 variable = variable_in
1301 IF (variable .EQ. 'U') variable = 'u'
1302 IF (variable .EQ. 'V') variable = 'v'
1303 IF (variable .EQ. 'M') variable = 'm'
1304 IF (variable .EQ. 'H') variable = 'h'
1307 IF (ite .GT. ide - 1) THEN
1314 IF (jte .GT. jde - 1) THEN
1320 IF (variable .EQ. 'u') ibe = ide
1321 IF (variable .EQ. 'u') THEN
1322 IF (ite .GT. ide) THEN
1328 IF (variable .EQ. 'v') jbe = jde
1329 IF (variable .EQ. 'v') THEN
1330 IF (jte .GT. jde) THEN
1336 IF (variable .EQ. 'm') ktf = kte
1337 IF (variable .EQ. 'h') ktf = kte
1338 IF (jts - jbs .LT. relax_zone) THEN
1339 IF (jts .LT. jbs + spec_zone) THEN
1340 max1 = jbs + spec_zone
1344 IF (jtf .GT. jbs + relax_zone - 1) THEN
1345 min1 = jbs + relax_zone - 1
1351 CALL PUSHINTEGER4(b_dist)
1354 IF (periodic_x) b_limit = 0
1356 IF (its .LT. b_limit + ibs) THEN
1357 max2 = b_limit + ibs
1361 IF (itf .GT. ibe - b_limit) THEN
1362 min2 = ibe - b_limit
1368 IF (i - 1 .LT. ibs) THEN
1369 CALL PUSHINTEGER4(im1)
1371 CALL PUSHCONTROL1B(0)
1373 CALL PUSHINTEGER4(im1)
1375 CALL PUSHCONTROL1B(1)
1377 IF (i + 1 .GT. ibe) THEN
1378 CALL PUSHINTEGER4(ip1)
1380 CALL PUSHCONTROL1B(0)
1382 CALL PUSHINTEGER4(ip1)
1384 CALL PUSHCONTROL1B(1)
1387 CALL PUSHINTEGER4(i - 1)
1388 CALL PUSHINTEGER4(ad_from)
1391 CALL PUSHCONTROL1B(0)
1393 CALL PUSHCONTROL1B(1)
1395 IF (jbe - jtf .LT. relax_zone) THEN
1396 IF (jts .LT. jbe - relax_zone + 1) THEN
1397 max3 = jbe - relax_zone + 1
1401 IF (jtf .GT. jbe - spec_zone) THEN
1402 min3 = jbe - spec_zone
1408 CALL PUSHINTEGER4(b_dist)
1411 IF (periodic_x) b_limit = 0
1413 IF (its .LT. b_limit + ibs) THEN
1414 max4 = b_limit + ibs
1418 IF (itf .GT. ibe - b_limit) THEN
1419 min4 = ibe - b_limit
1425 IF (i - 1 .LT. ibs) THEN
1426 CALL PUSHINTEGER4(im1)
1428 CALL PUSHCONTROL1B(0)
1430 CALL PUSHINTEGER4(im1)
1432 CALL PUSHCONTROL1B(1)
1434 IF (i + 1 .GT. ibe) THEN
1435 CALL PUSHINTEGER4(ip1)
1437 CALL PUSHCONTROL1B(0)
1439 CALL PUSHINTEGER4(ip1)
1441 CALL PUSHCONTROL1B(1)
1444 CALL PUSHINTEGER4(i - 1)
1445 CALL PUSHINTEGER4(ad_from0)
1448 CALL PUSHCONTROL1B(0)
1450 CALL PUSHCONTROL1B(1)
1452 IF (.NOT.periodic_x) THEN
1453 IF (its - ibs .LT. relax_zone) THEN
1454 IF (its .LT. ibs + spec_zone) THEN
1455 max5 = ibs + spec_zone
1459 IF (itf .GT. ibs + relax_zone - 1) THEN
1460 min5 = ibs + relax_zone - 1
1466 CALL PUSHINTEGER4(b_dist)
1469 IF (jts .LT. b_dist + jbs + 1) THEN
1470 max6 = b_dist + jbs + 1
1474 IF (jtf .GT. jbe - b_dist - 1) THEN
1475 min6 = jbe - b_dist - 1
1481 CALL PUSHINTEGER4(j - 1)
1482 CALL PUSHINTEGER4(ad_from1)
1485 CALL PUSHCONTROL1B(0)
1487 CALL PUSHCONTROL1B(1)
1489 IF (ibe - itf .LT. relax_zone) THEN
1490 IF (its .LT. ibe - relax_zone + 1) THEN
1491 max7 = ibe - relax_zone + 1
1495 IF (itf .GT. ibe - spec_zone) THEN
1496 min7 = ibe - spec_zone
1502 CALL PUSHINTEGER4(b_dist)
1505 IF (jts .LT. b_dist + jbs + 1) THEN
1506 max8 = b_dist + jbs + 1
1510 IF (jtf .GT. jbe - b_dist - 1) THEN
1511 min8 = jbe - b_dist - 1
1517 CALL PUSHINTEGER4(j - 1)
1518 CALL PUSHINTEGER4(ad_from2)
1523 CALL POPINTEGER4(ad_from2)
1524 CALL POPINTEGER4(ad_to2)
1525 DO j=ad_to2,ad_from2,-1
1526 tempb2 = -(gcx(b_dist+1)*field_tendb(i, k, j))
1527 fls0b = fcx(b_dist+1)*field_tendb(i, k, j) - 4.*tempb2
1532 field_bdy_xeb(j, k, b_dist+2) = field_bdy_xeb(j, k, b_dist+2&
1534 field_bdy_tend_xeb(j, k, b_dist+2) = field_bdy_tend_xeb(j, k&
1535 & , b_dist+2) + dtbc*fls4b
1536 fieldb(i-1, k, j) = fieldb(i-1, k, j) - fls4b
1537 field_bdy_xeb(j, k, b_dist) = field_bdy_xeb(j, k, b_dist) + &
1539 field_bdy_tend_xeb(j, k, b_dist) = field_bdy_tend_xeb(j, k, &
1540 & b_dist) + dtbc*fls3b
1541 fieldb(i+1, k, j) = fieldb(i+1, k, j) - fls3b
1542 field_bdy_xeb(j+1, k, b_dist+1) = field_bdy_xeb(j+1, k, &
1544 field_bdy_tend_xeb(j+1, k, b_dist+1) = field_bdy_tend_xeb(j+&
1545 & 1, k, b_dist+1) + dtbc*fls2b
1546 fieldb(i, k, j+1) = fieldb(i, k, j+1) - fls2b
1547 field_bdy_xeb(j-1, k, b_dist+1) = field_bdy_xeb(j-1, k, &
1549 field_bdy_tend_xeb(j-1, k, b_dist+1) = field_bdy_tend_xeb(j-&
1550 & 1, k, b_dist+1) + dtbc*fls1b
1551 fieldb(i, k, j-1) = fieldb(i, k, j-1) - fls1b
1552 field_bdy_xeb(j, k, b_dist+1) = field_bdy_xeb(j, k, b_dist+1&
1554 field_bdy_tend_xeb(j, k, b_dist+1) = field_bdy_tend_xeb(j, k&
1555 & , b_dist+1) + dtbc*fls0b
1556 fieldb(i, k, j) = fieldb(i, k, j) - fls0b
1559 CALL POPINTEGER4(b_dist)
1562 CALL POPCONTROL1B(branch)
1563 IF (branch .EQ. 0) THEN
1566 CALL POPINTEGER4(ad_from1)
1567 CALL POPINTEGER4(ad_to1)
1568 DO j=ad_to1,ad_from1,-1
1569 tempb1 = -(gcx(b_dist+1)*field_tendb(i, k, j))
1570 fls0b = fcx(b_dist+1)*field_tendb(i, k, j) - 4.*tempb1
1575 field_bdy_xsb(j, k, b_dist+2) = field_bdy_xsb(j, k, b_dist+2&
1577 field_bdy_tend_xsb(j, k, b_dist+2) = field_bdy_tend_xsb(j, k&
1578 & , b_dist+2) + dtbc*fls4b
1579 fieldb(i+1, k, j) = fieldb(i+1, k, j) - fls4b
1580 field_bdy_xsb(j, k, b_dist) = field_bdy_xsb(j, k, b_dist) + &
1582 field_bdy_tend_xsb(j, k, b_dist) = field_bdy_tend_xsb(j, k, &
1583 & b_dist) + dtbc*fls3b
1584 fieldb(i-1, k, j) = fieldb(i-1, k, j) - fls3b
1585 field_bdy_xsb(j+1, k, b_dist+1) = field_bdy_xsb(j+1, k, &
1587 field_bdy_tend_xsb(j+1, k, b_dist+1) = field_bdy_tend_xsb(j+&
1588 & 1, k, b_dist+1) + dtbc*fls2b
1589 fieldb(i, k, j+1) = fieldb(i, k, j+1) - fls2b
1590 field_bdy_xsb(j-1, k, b_dist+1) = field_bdy_xsb(j-1, k, &
1592 field_bdy_tend_xsb(j-1, k, b_dist+1) = field_bdy_tend_xsb(j-&
1593 & 1, k, b_dist+1) + dtbc*fls1b
1594 fieldb(i, k, j-1) = fieldb(i, k, j-1) - fls1b
1595 field_bdy_xsb(j, k, b_dist+1) = field_bdy_xsb(j, k, b_dist+1&
1597 field_bdy_tend_xsb(j, k, b_dist+1) = field_bdy_tend_xsb(j, k&
1598 & , b_dist+1) + dtbc*fls0b
1599 fieldb(i, k, j) = fieldb(i, k, j) - fls0b
1602 CALL POPINTEGER4(b_dist)
1606 CALL POPCONTROL1B(branch)
1607 IF (branch .EQ. 0) THEN
1610 CALL POPINTEGER4(ad_from0)
1611 CALL POPINTEGER4(ad_to0)
1612 DO i=ad_to0,ad_from0,-1
1613 tempb0 = -(gcx(b_dist+1)*field_tendb(i, k, j))
1614 fls0b = fcx(b_dist+1)*field_tendb(i, k, j) - 4.*tempb0
1619 field_bdy_yeb(i, k, b_dist+2) = field_bdy_yeb(i, k, b_dist+2) &
1621 field_bdy_tend_yeb(i, k, b_dist+2) = field_bdy_tend_yeb(i, k, &
1622 & b_dist+2) + dtbc*fls4b
1623 fieldb(i, k, j-1) = fieldb(i, k, j-1) - fls4b
1624 field_bdy_yeb(i, k, b_dist) = field_bdy_yeb(i, k, b_dist) + &
1626 field_bdy_tend_yeb(i, k, b_dist) = field_bdy_tend_yeb(i, k, &
1627 & b_dist) + dtbc*fls3b
1628 fieldb(i, k, j+1) = fieldb(i, k, j+1) - fls3b
1629 field_bdy_yeb(ip1, k, b_dist+1) = field_bdy_yeb(ip1, k, b_dist&
1631 field_bdy_tend_yeb(ip1, k, b_dist+1) = field_bdy_tend_yeb(ip1&
1632 & , k, b_dist+1) + dtbc*fls2b
1633 fieldb(ip1, k, j) = fieldb(ip1, k, j) - fls2b
1634 field_bdy_yeb(im1, k, b_dist+1) = field_bdy_yeb(im1, k, b_dist&
1636 field_bdy_tend_yeb(im1, k, b_dist+1) = field_bdy_tend_yeb(im1&
1637 & , k, b_dist+1) + dtbc*fls1b
1638 fieldb(im1, k, j) = fieldb(im1, k, j) - fls1b
1639 field_bdy_yeb(i, k, b_dist+1) = field_bdy_yeb(i, k, b_dist+1) &
1641 field_bdy_tend_yeb(i, k, b_dist+1) = field_bdy_tend_yeb(i, k, &
1642 & b_dist+1) + dtbc*fls0b
1643 fieldb(i, k, j) = fieldb(i, k, j) - fls0b
1644 CALL POPCONTROL1B(branch)
1645 IF (branch .EQ. 0) THEN
1646 CALL POPINTEGER4(ip1)
1648 CALL POPINTEGER4(ip1)
1650 CALL POPCONTROL1B(branch)
1651 IF (branch .EQ. 0) THEN
1652 CALL POPINTEGER4(im1)
1654 CALL POPINTEGER4(im1)
1658 CALL POPINTEGER4(b_dist)
1661 CALL POPCONTROL1B(branch)
1662 IF (branch .EQ. 0) THEN
1665 CALL POPINTEGER4(ad_from)
1666 CALL POPINTEGER4(ad_to)
1667 DO i=ad_to,ad_from,-1
1668 tempb = -(gcx(b_dist+1)*field_tendb(i, k, j))
1669 fls0b = fcx(b_dist+1)*field_tendb(i, k, j) - 4.*tempb
1674 field_bdy_ysb(i, k, b_dist+2) = field_bdy_ysb(i, k, b_dist+2) &
1676 field_bdy_tend_ysb(i, k, b_dist+2) = field_bdy_tend_ysb(i, k, &
1677 & b_dist+2) + dtbc*fls4b
1678 fieldb(i, k, j+1) = fieldb(i, k, j+1) - fls4b
1679 field_bdy_ysb(i, k, b_dist) = field_bdy_ysb(i, k, b_dist) + &
1681 field_bdy_tend_ysb(i, k, b_dist) = field_bdy_tend_ysb(i, k, &
1682 & b_dist) + dtbc*fls3b
1683 fieldb(i, k, j-1) = fieldb(i, k, j-1) - fls3b
1684 field_bdy_ysb(ip1, k, b_dist+1) = field_bdy_ysb(ip1, k, b_dist&
1686 field_bdy_tend_ysb(ip1, k, b_dist+1) = field_bdy_tend_ysb(ip1&
1687 & , k, b_dist+1) + dtbc*fls2b
1688 fieldb(ip1, k, j) = fieldb(ip1, k, j) - fls2b
1689 field_bdy_ysb(im1, k, b_dist+1) = field_bdy_ysb(im1, k, b_dist&
1691 field_bdy_tend_ysb(im1, k, b_dist+1) = field_bdy_tend_ysb(im1&
1692 & , k, b_dist+1) + dtbc*fls1b
1693 fieldb(im1, k, j) = fieldb(im1, k, j) - fls1b
1694 field_bdy_ysb(i, k, b_dist+1) = field_bdy_ysb(i, k, b_dist+1) &
1696 field_bdy_tend_ysb(i, k, b_dist+1) = field_bdy_tend_ysb(i, k, &
1697 & b_dist+1) + dtbc*fls0b
1698 fieldb(i, k, j) = fieldb(i, k, j) - fls0b
1699 CALL POPCONTROL1B(branch)
1700 IF (branch .EQ. 0) THEN
1701 CALL POPINTEGER4(ip1)
1703 CALL POPINTEGER4(ip1)
1705 CALL POPCONTROL1B(branch)
1706 IF (branch .EQ. 0) THEN
1707 CALL POPINTEGER4(im1)
1709 CALL POPINTEGER4(im1)
1713 CALL POPINTEGER4(b_dist)
1716 END SUBROUTINE A_RELAX_BDYTEND_CORE
1717 !------------------------------------------------------------------------
1719 SUBROUTINE a_spec_bdytend ( a_field_tend, &
1720 a_field_bdy_tend_xs, a_field_bdy_tend_xe, &
1721 a_field_bdy_tend_ys, a_field_bdy_tend_ye, &
1722 variable_in, config_flags, &
1723 spec_bdy_width, spec_zone, &
1724 ids,ide, jds,jde, kds,kde, & ! domain dims
1725 ims,ime, jms,jme, kms,kme, & ! memory dims
1726 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1727 its,ite, jts,jte, kts,kte )
1729 ! spec_bdy_width is only used to dimension the boundary arrays.
1730 ! spec_zone is the width of the outer specified b.c.s that are set here.
1734 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde
1735 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme
1736 INTEGER, INTENT(IN) :: ips,ipe, jps,jpe, kps,kpe
1737 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte
1738 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone
1739 CHARACTER, INTENT(IN) :: variable_in
1741 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: a_field_tend
1742 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_tend_xs, a_field_bdy_tend_xe
1743 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(INOUT) :: a_field_bdy_tend_ys, a_field_bdy_tend_ye
1744 TYPE( grid_config_rec_type ) config_flags
1746 CHARACTER :: variable
1747 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf
1748 INTEGER :: b_dist, b_limit
1749 LOGICAL :: periodic_x
1752 periodic_x = config_flags%periodic_x
1754 variable = variable_in
1756 IF (variable == 'U') variable = 'u'
1757 IF (variable == 'V') variable = 'v'
1758 IF (variable == 'M') variable = 'm'
1759 IF (variable == 'H') variable = 'h'
1763 itf = min(ite,ide-1)
1766 jtf = min(jte,jde-1)
1768 IF (variable == 'u') ibe = ide
1769 IF (variable == 'u') itf = min(ite,ide)
1770 IF (variable == 'v') jbe = jde
1771 IF (variable == 'v') jtf = min(jte,jde)
1772 IF (variable == 'm') ktf = kte
1773 IF (variable == 'h') ktf = kte
1776 IF(.NOT.periodic_x)THEN
1777 IF (ibe - itf .lt. spec_zone) THEN
1779 DO i = itf, max(its,ibe-spec_zone+1), -1
1782 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1783 a_field_bdy_tend_xe(j, k, b_dist+1) = a_field_bdy_tend_xe(j, k, b_dist+1) &
1784 + a_field_tend(i,k,j)
1785 a_field_tend(i,k,j) = 0.
1791 IF (its - ibs .lt. spec_zone) THEN
1793 DO i = min(itf,ibs+spec_zone-1), its, -1
1796 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1797 a_field_bdy_tend_xs(j, k, b_dist+1) = a_field_bdy_tend_xs(j, k, b_dist+1) &
1798 + a_field_tend(i,k,j)
1799 a_field_tend(i,k,j) = 0.
1807 IF (jbe - jtf .lt. spec_zone) THEN
1809 DO j = jtf, max(jts,jbe-spec_zone+1), -1
1812 IF(periodic_x)b_limit = 0
1814 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1815 a_field_bdy_tend_ye(i, k, b_dist+1) = a_field_bdy_tend_ye(i, k, b_dist+1) &
1816 + a_field_tend(i,k,j)
1817 a_field_tend(i,k,j) = 0.
1823 IF (jts - jbs .lt. spec_zone) THEN
1825 DO j = min(jtf,jbs+spec_zone-1), jts, -1
1828 IF(periodic_x)b_limit = 0
1830 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1831 a_field_bdy_tend_ys(i, k, b_dist+1) = a_field_bdy_tend_ys(i, k, b_dist+1) &
1832 + a_field_tend(i,k,j)
1833 a_field_tend(i,k,j) = 0.
1839 END SUBROUTINE a_spec_bdytend
1841 !------------------------------------------------------------------------
1843 SUBROUTINE a_spec_bdyupdate( a_field, &
1845 variable_in, config_flags, &
1847 ids,ide, jds,jde, kds,kde, & ! domain dims
1848 ims,ime, jms,jme, kms,kme, & ! memory dims
1849 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
1850 its,ite, jts,jte, kts,kte )
1852 ! This subroutine adds the tendencies in the boundary specified region.
1853 ! spec_zone is the width of the outer specified b.c.s that are set here.
1858 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
1859 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
1860 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
1861 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
1862 INTEGER, INTENT(IN ) :: spec_zone
1863 CHARACTER, INTENT(IN ) :: variable_in
1864 REAL, INTENT(IN ) :: dt
1867 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(IN ) :: a_field
1868 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: a_field_tend
1869 TYPE( grid_config_rec_type ) config_flags
1871 CHARACTER :: variable
1872 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf
1873 INTEGER :: b_dist, b_limit
1874 LOGICAL :: periodic_x
1876 periodic_x = config_flags%periodic_x
1878 variable = variable_in
1880 IF (variable == 'U') variable = 'u'
1881 IF (variable == 'V') variable = 'v'
1882 IF (variable == 'M') variable = 'm'
1883 IF (variable == 'H') variable = 'h'
1887 itf = min(ite,ide-1)
1890 jtf = min(jte,jde-1)
1892 IF (variable == 'u') ibe = ide
1893 IF (variable == 'u') itf = min(ite,ide)
1894 IF (variable == 'v') jbe = jde
1895 IF (variable == 'v') jtf = min(jte,jde)
1896 IF (variable == 'm') ktf = kte
1897 IF (variable == 'h') ktf = kte
1899 IF(.NOT.periodic_x)THEN
1900 IF (ibe - itf .lt. spec_zone) THEN
1902 DO i = max(its,ibe-spec_zone+1), itf
1905 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1906 a_field_tend(i,k,j) = a_field_tend(i,k,j) + dt * a_field(i,k,j)
1912 IF (its - ibs .lt. spec_zone) THEN
1914 DO i = its, min(itf,ibs+spec_zone-1)
1917 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
1918 a_field_tend(i,k,j) = a_field_tend(i,k,j) + dt * a_field(i,k,j)
1926 IF (jbe - jtf .lt. spec_zone) THEN
1928 DO j = max(jts,jbe-spec_zone+1), jtf
1931 IF(periodic_x)b_limit = 0
1933 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1934 a_field_tend(i,k,j) = a_field_tend(i,k,j) + dt * a_field(i,k,j)
1940 IF (jts - jbs .lt. spec_zone) THEN
1942 DO j = jts, min(jtf,jbs+spec_zone-1)
1945 IF(periodic_x)b_limit = 0
1947 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
1948 a_field_tend(i,k,j) = a_field_tend(i,k,j) + dt * a_field(i,k,j)
1954 END SUBROUTINE a_spec_bdyupdate
1955 !------------------------------------------------------------------------
1956 ! Generated by TAPENADE (INRIA, Tropics team)
1957 ! Tapenade 3.10 (r5498) - 20 Jan 2015 09:48
1959 ! Differentiation of spec_bdy_final in reverse (adjoint) mode:
1960 ! gradient of useful results: field field_bdy_xe field_bdy_tend_xe
1961 ! field_bdy_xs field_bdy_tend_xs field_bdy_ye field_bdy_tend_ye
1962 ! field_bdy_ys field_bdy_tend_ys mu
1963 ! with respect to varying inputs: field field_bdy_xe field_bdy_tend_xe
1964 ! field_bdy_xs field_bdy_tend_xs field_bdy_ye field_bdy_tend_ye
1965 ! field_bdy_ys field_bdy_tend_ys mu
1966 ! RW status of diff variables: field:in-out field_bdy_xe:incr
1967 ! field_bdy_tend_xe:incr field_bdy_xs:incr field_bdy_tend_xs:incr
1968 ! field_bdy_ye:incr field_bdy_tend_ye:incr field_bdy_ys:incr
1969 ! field_bdy_tend_ys:incr mu:incr
1973 SUBROUTINE a_SPEC_BDY_FINAL(field, fieldb, mu, mub, msf, field_bdy_xs, &
1974 & field_bdy_xsb, field_bdy_xe, field_bdy_xeb, field_bdy_ys, &
1975 & field_bdy_ysb, field_bdy_ye, field_bdy_yeb, field_bdy_tend_xs, &
1976 & field_bdy_tend_xsb, field_bdy_tend_xe, field_bdy_tend_xeb, &
1977 & field_bdy_tend_ys, field_bdy_tend_ysb, field_bdy_tend_ye, &
1978 & field_bdy_tend_yeb, variable_in, config_flags, spec_bdy_width, &
1979 & spec_zone, dtbc, ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms&
1980 & , kme, ips, ipe, jps, jpe, kps, kpe, its, ite, jts, jte, kts, kte)
1982 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde
1983 INTEGER, INTENT(IN) :: ims, ime, jms, jme, kms, kme
1984 INTEGER, INTENT(IN) :: ips, ipe, jps, jpe, kps, kpe
1985 INTEGER, INTENT(IN) :: its, ite, jts, jte, kts, kte
1986 INTEGER, INTENT(IN) :: spec_bdy_width, spec_zone
1987 REAL, INTENT(IN) :: dtbc
1988 CHARACTER, INTENT(IN) :: variable_in
1989 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: field
1990 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: fieldb
1991 REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN) :: mu, msf
1992 REAL, DIMENSION(ims:ime, jms:jme) :: mub
1993 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
1994 & field_bdy_xs, field_bdy_xe
1995 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width) :: field_bdy_xsb, &
1997 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
1998 & field_bdy_ys, field_bdy_ye
1999 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width) :: field_bdy_ysb, &
2001 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width), INTENT(IN) :: &
2002 & field_bdy_tend_xs, field_bdy_tend_xe
2003 REAL, DIMENSION(jms:jme, kds:kde, spec_bdy_width) :: &
2004 & field_bdy_tend_xsb, field_bdy_tend_xeb
2005 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width), INTENT(IN) :: &
2006 & field_bdy_tend_ys, field_bdy_tend_ye
2007 REAL, DIMENSION(ims:ime, kds:kde, spec_bdy_width) :: &
2008 & field_bdy_tend_ysb, field_bdy_tend_yeb
2009 TYPE(GRID_CONFIG_REC_TYPE) :: config_flags
2010 CHARACTER :: variable
2011 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, im1, ip1
2012 INTEGER :: b_dist, b_limit
2013 REAL :: bfield, xmsf, xmu
2014 REAL :: bfieldb, xmub
2015 LOGICAL :: periodic_x, msfcouple, mucouple
2041 periodic_x = config_flags%periodic_x
2042 variable = variable_in
2043 IF (variable .EQ. 'U') variable = 'u'
2044 IF (variable .EQ. 'V') variable = 'v'
2045 IF (variable .EQ. 'W') variable = 'w'
2046 IF (variable .EQ. 'M') variable = 'm'
2047 IF (variable .EQ. 'T') variable = 't'
2048 IF (variable .EQ. 'H') variable = 'h'
2051 IF (ite .GT. ide - 1) THEN
2058 IF (jte .GT. jde - 1) THEN
2064 IF (variable .EQ. 'u') ibe = ide
2065 IF (variable .EQ. 'u') THEN
2066 IF (ite .GT. ide) THEN
2072 IF (variable .EQ. 'v') jbe = jde
2073 IF (variable .EQ. 'v') THEN
2074 IF (jte .GT. jde) THEN
2080 IF (variable .EQ. 'm') ktf = kde
2081 IF (variable .EQ. 'h') ktf = kde
2082 IF (variable .EQ. 'w') ktf = kde
2085 IF ((variable .EQ. 'u' .OR. variable .EQ. 'v') .OR. variable .EQ. 'w'&
2086 & ) msfcouple = .true.
2087 IF (variable .EQ. 'm') mucouple = .false.
2090 IF (jts - jbs .LT. spec_zone) THEN
2091 IF (jtf .GT. jbs + spec_zone - 1) THEN
2092 min1 = jbs + spec_zone - 1
2098 CALL PUSHINTEGER4(b_dist)
2101 IF (periodic_x) b_limit = 0
2103 IF (its .LT. b_limit + ibs) THEN
2104 max1 = b_limit + ibs
2108 IF (itf .GT. ibe - b_limit) THEN
2109 min3 = ibe - b_limit
2116 CALL PUSHREAL8(xmsf)
2118 CALL PUSHCONTROL1B(0)
2120 CALL PUSHCONTROL1B(1)
2125 CALL PUSHCONTROL1B(0)
2127 CALL PUSHCONTROL1B(1)
2130 CALL PUSHINTEGER4(i - 1)
2131 CALL PUSHINTEGER4(ad_from)
2134 CALL PUSHCONTROL1B(0)
2136 CALL PUSHCONTROL1B(1)
2138 IF (jbe - jtf .LT. spec_zone) THEN
2139 IF (jts .LT. jbe - spec_zone + 1) THEN
2140 max2 = jbe - spec_zone + 1
2146 CALL PUSHINTEGER4(b_dist)
2149 IF (periodic_x) b_limit = 0
2151 IF (its .LT. b_limit + ibs) THEN
2152 max3 = b_limit + ibs
2156 IF (itf .GT. ibe - b_limit) THEN
2157 min4 = ibe - b_limit
2164 CALL PUSHREAL8(xmsf)
2166 CALL PUSHCONTROL1B(0)
2168 CALL PUSHCONTROL1B(1)
2173 CALL PUSHCONTROL1B(0)
2175 CALL PUSHCONTROL1B(1)
2178 CALL PUSHINTEGER4(i - 1)
2179 CALL PUSHINTEGER4(ad_from0)
2182 CALL PUSHCONTROL1B(0)
2184 CALL PUSHCONTROL1B(1)
2186 IF (.NOT.periodic_x) THEN
2187 IF (its - ibs .LT. spec_zone) THEN
2188 IF (itf .GT. ibs + spec_zone - 1) THEN
2189 min2 = ibs + spec_zone - 1
2195 CALL PUSHINTEGER4(b_dist)
2198 IF (jts .LT. b_dist + jbs + 1) THEN
2199 max4 = b_dist + jbs + 1
2203 IF (jtf .GT. jbe - b_dist - 1) THEN
2204 min5 = jbe - b_dist - 1
2211 CALL PUSHREAL8(xmsf)
2213 CALL PUSHCONTROL1B(0)
2215 CALL PUSHCONTROL1B(1)
2220 CALL PUSHCONTROL1B(0)
2222 CALL PUSHCONTROL1B(1)
2225 CALL PUSHINTEGER4(j - 1)
2226 CALL PUSHINTEGER4(ad_from1)
2229 CALL PUSHCONTROL1B(0)
2231 CALL PUSHCONTROL1B(1)
2233 IF (ibe - itf .LT. spec_zone) THEN
2234 IF (its .LT. ibe - spec_zone + 1) THEN
2235 max5 = ibe - spec_zone + 1
2241 CALL PUSHINTEGER4(b_dist)
2244 IF (jts .LT. b_dist + jbs + 1) THEN
2245 max6 = b_dist + jbs + 1
2249 IF (jtf .GT. jbe - b_dist - 1) THEN
2250 min6 = jbe - b_dist - 1
2257 CALL PUSHREAL8(xmsf)
2259 CALL PUSHCONTROL1B(0)
2261 CALL PUSHCONTROL1B(1)
2266 CALL PUSHCONTROL1B(0)
2268 CALL PUSHCONTROL1B(1)
2271 CALL PUSHINTEGER4(j - 1)
2272 CALL PUSHINTEGER4(ad_from2)
2278 CALL POPINTEGER4(ad_from2)
2279 CALL POPINTEGER4(ad_to2)
2280 DO j=ad_to2,ad_from2,-1
2281 bfield = field_bdy_xe(j, k, b_dist+1) + dtbc*&
2282 & field_bdy_tend_xe(j, k, b_dist+1)
2283 tempb2 = xmsf*fieldb(i, k, j)/xmu
2285 xmub = xmub - bfield*tempb2/xmu
2286 fieldb(i, k, j) = 0.0
2287 CALL POPCONTROL1B(branch)
2288 IF (branch .EQ. 0) THEN
2290 mub(i, j) = mub(i, j) + xmub
2293 CALL POPCONTROL1B(branch)
2294 IF (branch .EQ. 0) CALL POPREAL8(xmsf)
2295 field_bdy_xeb(j, k, b_dist+1) = field_bdy_xeb(j, k, b_dist+1&
2297 field_bdy_tend_xeb(j, k, b_dist+1) = field_bdy_tend_xeb(j, k&
2298 & , b_dist+1) + dtbc*bfieldb
2301 CALL POPINTEGER4(b_dist)
2306 CALL POPCONTROL1B(branch)
2307 IF (branch .EQ. 0) THEN
2310 CALL POPINTEGER4(ad_from1)
2311 CALL POPINTEGER4(ad_to1)
2312 DO j=ad_to1,ad_from1,-1
2313 bfield = field_bdy_xs(j, k, b_dist+1) + dtbc*&
2314 & field_bdy_tend_xs(j, k, b_dist+1)
2315 tempb1 = xmsf*fieldb(i, k, j)/xmu
2317 xmub = xmub - bfield*tempb1/xmu
2318 fieldb(i, k, j) = 0.0
2319 CALL POPCONTROL1B(branch)
2320 IF (branch .EQ. 0) THEN
2322 mub(i, j) = mub(i, j) + xmub
2325 CALL POPCONTROL1B(branch)
2326 IF (branch .EQ. 0) CALL POPREAL8(xmsf)
2327 field_bdy_xsb(j, k, b_dist+1) = field_bdy_xsb(j, k, b_dist+1&
2329 field_bdy_tend_xsb(j, k, b_dist+1) = field_bdy_tend_xsb(j, k&
2330 & , b_dist+1) + dtbc*bfieldb
2333 CALL POPINTEGER4(b_dist)
2339 CALL POPCONTROL1B(branch)
2340 IF (branch .EQ. 0) THEN
2343 CALL POPINTEGER4(ad_from0)
2344 CALL POPINTEGER4(ad_to0)
2345 DO i=ad_to0,ad_from0,-1
2346 bfield = field_bdy_ye(i, k, b_dist+1) + dtbc*field_bdy_tend_ye&
2348 tempb0 = xmsf*fieldb(i, k, j)/xmu
2350 xmub = xmub - bfield*tempb0/xmu
2351 fieldb(i, k, j) = 0.0
2352 CALL POPCONTROL1B(branch)
2353 IF (branch .EQ. 0) THEN
2355 mub(i, j) = mub(i, j) + xmub
2358 CALL POPCONTROL1B(branch)
2359 IF (branch .EQ. 0) CALL POPREAL8(xmsf)
2360 field_bdy_yeb(i, k, b_dist+1) = field_bdy_yeb(i, k, b_dist+1) &
2362 field_bdy_tend_yeb(i, k, b_dist+1) = field_bdy_tend_yeb(i, k, &
2363 & b_dist+1) + dtbc*bfieldb
2366 CALL POPINTEGER4(b_dist)
2369 CALL POPCONTROL1B(branch)
2370 IF (branch .EQ. 0) THEN
2373 CALL POPINTEGER4(ad_from)
2374 CALL POPINTEGER4(ad_to)
2375 DO i=ad_to,ad_from,-1
2376 bfield = field_bdy_ys(i, k, b_dist+1) + dtbc*field_bdy_tend_ys&
2378 tempb = xmsf*fieldb(i, k, j)/xmu
2380 xmub = xmub - bfield*tempb/xmu
2381 fieldb(i, k, j) = 0.0
2382 CALL POPCONTROL1B(branch)
2383 IF (branch .EQ. 0) THEN
2385 mub(i, j) = mub(i, j) + xmub
2388 CALL POPCONTROL1B(branch)
2389 IF (branch .EQ. 0) CALL POPREAL8(xmsf)
2390 field_bdy_ysb(i, k, b_dist+1) = field_bdy_ysb(i, k, b_dist+1) &
2392 field_bdy_tend_ysb(i, k, b_dist+1) = field_bdy_tend_ysb(i, k, &
2393 & b_dist+1) + dtbc*bfieldb
2396 CALL POPINTEGER4(b_dist)
2399 END SUBROUTINE a_SPEC_BDY_FINAL
2400 !------------------------------------------------------------------------
2402 SUBROUTINE a_zero_grad_bdy ( a_field, &
2403 variable_in, config_flags, &
2405 ids,ide, jds,jde, kds,kde, & ! domain dims
2406 ims,ime, jms,jme, kms,kme, & ! memory dims
2407 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
2408 its,ite, jts,jte, kts,kte )
2410 ! This subroutine sets zero gradient conditions in the boundary specified region.
2411 ! spec_zone is the width of the outer specified b.c.s that are set here.
2416 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
2417 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
2418 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
2419 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
2420 INTEGER, INTENT(IN ) :: spec_zone
2421 CHARACTER, INTENT(IN ) :: variable_in
2424 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: a_field
2425 TYPE( grid_config_rec_type ) config_flags
2427 CHARACTER :: variable
2428 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, i_inner, j_inner
2429 INTEGER :: b_dist, b_limit
2430 LOGICAL :: periodic_x
2436 periodic_x = config_flags%periodic_x
2438 variable = variable_in
2440 IF (variable == 'U') variable = 'u'
2441 IF (variable == 'V') variable = 'v'
2445 itf = min(ite,ide-1)
2448 jtf = min(jte,jde-1)
2450 IF (variable == 'u') ibe = ide
2451 IF (variable == 'u') itf = min(ite,ide)
2452 IF (variable == 'v') jbe = jde
2453 IF (variable == 'v') jtf = min(jte,jde)
2454 IF (variable == 'w') ktf = kde
2456 IF(.NOT.periodic_x)THEN
2458 IF (ibe - itf .lt. spec_zone) THEN
2460 DO i = itf, max(its,ibe-spec_zone+1), -1
2463 DO j = min(jtf,jbe-b_dist-1), max(jts,b_dist+jbs+1), -1
2464 j_inner = max(j,jbs+spec_zone)
2465 j_inner = min(j_inner,jbe-spec_zone)
2466 a_aux = a_aux + a_field(i,k,j)
2468 a_field(ibe-spec_zone,k,j_inner) = a_field(ibe-spec_zone,k,j_inner) + a_aux
2475 IF (its - ibs .lt. spec_zone) THEN
2477 DO i = min(itf,ibs+spec_zone-1), its, -1
2480 DO j = min(jtf,jbe-b_dist-1), max(jts,b_dist+jbs+1), -1
2481 j_inner = max(j,jbs+spec_zone)
2482 j_inner = min(j_inner,jbe-spec_zone)
2483 a_aux = a_aux + a_field(i,k,j)
2485 a_field(ibs+spec_zone,k,j_inner) = a_field(ibs+spec_zone,k,j_inner) + a_aux
2494 IF (jbe - jtf .lt. spec_zone) THEN
2496 DO j = jtf, max(jts,jbe-spec_zone+1), -1
2499 IF(periodic_x)b_limit = 0
2501 DO i = min(itf,ibe-b_limit), max(its,b_limit+ibs), -1
2502 i_inner = max(i,ibs+spec_zone)
2503 i_inner = min(i_inner,ibe-spec_zone)
2504 IF(periodic_x)i_inner = i
2505 a_aux = a_aux + a_field(i,k,j)
2507 a_field(i_inner,k,jbe-spec_zone) = a_field(i_inner,k,jbe-spec_zone) + a_aux
2514 IF (jts - jbs .lt. spec_zone) THEN
2516 DO j = min(jtf,jbs+spec_zone-1), jts, -1
2519 IF(periodic_x)b_limit = 0
2521 DO i = min(itf,ibe-b_limit), max(its,b_limit+ibs), -1
2522 i_inner = max(i,ibs+spec_zone)
2523 i_inner = min(i_inner,ibe-spec_zone)
2524 IF(periodic_x)i_inner = i
2525 a_aux = a_aux + a_field(i,k,j)
2527 a_field(i_inner,k,jbs+spec_zone) = a_field(i_inner,k,jbs+spec_zone) + a_aux
2534 END SUBROUTINE a_zero_grad_bdy
2536 !------------------------------------------------------------------------
2538 SUBROUTINE a_couple_bdy ( field, a_field, &
2539 variable_in, config_flags, &
2542 ids,ide, jds,jde, kds,kde, & ! domain dims
2543 ims,ime, jms,jme, kms,kme, & ! memory dims
2544 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
2545 its,ite, jts,jte, kts,kte )
2547 ! This subroutine adds the tendencies in the boundary specified region.
2548 ! spec_zone is the width of the outer specified b.c.s that are set here.
2553 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
2554 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
2555 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
2556 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
2557 INTEGER, INTENT(IN ) :: spec_zone
2558 CHARACTER, INTENT(IN ) :: variable_in
2559 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT) :: a_mu
2560 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: mu
2561 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: msf
2562 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: a_field
2563 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(IN ) :: field
2564 TYPE( grid_config_rec_type ) config_flags
2566 CHARACTER :: variable
2567 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf
2568 INTEGER :: b_dist, b_limit
2569 LOGICAL :: periodic_x
2571 periodic_x = config_flags%periodic_x
2573 variable = variable_in
2575 IF (variable == 'U') variable = 'u'
2576 IF (variable == 'V') variable = 'v'
2577 IF (variable == 'T') variable = 't'
2578 IF (variable == 'H') variable = 'h'
2579 IF (variable == 'W') variable = 'w'
2583 itf = min(ite,ide-1)
2586 jtf = min(jte,jde-1)
2588 IF (variable == 'u') ibe = ide
2589 IF (variable == 'u') itf = min(ite,ide)
2590 IF (variable == 'v') jbe = jde
2591 IF (variable == 'v') jtf = min(jte,jde)
2592 IF (variable == 'h') ktf = kte
2593 IF (variable == 'w') ktf = kte
2595 IF(.NOT.periodic_x)THEN
2596 IF (ibe - itf .lt. spec_zone) THEN
2598 DO i = max(its,ibe-spec_zone+1), itf
2601 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2602 if (variable == 't' .or. variable == 'h') then
2603 a_mu(i,j) = a_mu(i,j) + field(i,k,j)*a_field(i,k,j)
2604 a_field(i,k,j) = a_field(i,k,j)*mu(i,j)
2606 a_mu(i,j) = a_mu(i,j) + field(i,k,j)*a_field(i,k,j)/msf(i,j)
2607 a_field(i,k,j) = a_field(i,k,j)*mu(i,j)/msf(i,j)
2614 IF (its - ibs .lt. spec_zone) THEN
2616 DO i = its, min(itf,ibs+spec_zone-1)
2619 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2620 if (variable == 't' .or. variable == 'h') then
2621 a_mu(i,j) = a_mu(i,j) + field(i,k,j)*a_field(i,k,j)
2622 a_field(i,k,j) = a_field(i,k,j)*mu(i,j)
2624 a_mu(i,j) = a_mu(i,j) + field(i,k,j)*a_field(i,k,j)/msf(i,j)
2625 a_field(i,k,j) = a_field(i,k,j)*mu(i,j)/msf(i,j)
2633 IF (jbe - jtf .lt. spec_zone) THEN
2635 DO j = max(jts,jbe-spec_zone+1), jtf
2638 IF(periodic_x)b_limit = 0
2640 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2641 if (variable == 't' .or. variable == 'h') then
2642 a_mu(i,j) = a_mu(i,j) + field(i,k,j)*a_field(i,k,j)
2643 a_field(i,k,j) = a_field(i,k,j)*mu(i,j)
2645 a_mu(i,j) = a_mu(i,j) + field(i,k,j)*a_field(i,k,j)/msf(i,j)
2646 a_field(i,k,j) = a_field(i,k,j)*mu(i,j)/msf(i,j)
2653 IF (jts - jbs .lt. spec_zone) THEN
2655 DO j = jts, min(jtf,jbs+spec_zone-1)
2658 IF(periodic_x)b_limit = 0
2660 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2661 if (variable == 't' .or. variable == 'h') then
2662 a_mu(i,j) = a_mu(i,j) + field(i,k,j)*a_field(i,k,j)
2663 a_field(i,k,j) = a_field(i,k,j)*mu(i,j)
2665 a_mu(i,j) = a_mu(i,j) + field(i,k,j)*a_field(i,k,j)/msf(i,j)
2666 a_field(i,k,j) = a_field(i,k,j)*mu(i,j)/msf(i,j)
2673 END SUBROUTINE a_couple_bdy
2674 !------------------------------------------------------------------------
2676 SUBROUTINE a_uncouple_bdy( field, a_field, &
2677 variable_in, config_flags, &
2680 ids,ide, jds,jde, kds,kde, & ! domain dims
2681 ims,ime, jms,jme, kms,kme, & ! memory dims
2682 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
2683 its,ite, jts,jte, kts,kte )
2685 ! This subroutine adds the tendencies in the boundary specified region.
2686 ! spec_zone is the width of the outer specified b.c.s that are set here.
2691 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde
2692 INTEGER, INTENT(IN ) :: ims,ime, jms,jme, kms,kme
2693 INTEGER, INTENT(IN ) :: ips,ipe, jps,jpe, kps,kpe
2694 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
2695 INTEGER, INTENT(IN ) :: spec_zone
2696 CHARACTER, INTENT(IN ) :: variable_in
2697 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT) :: a_mu
2698 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: mu
2699 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ) :: msf
2700 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(INOUT) :: a_field
2701 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(IN ) :: field
2702 TYPE( grid_config_rec_type ) config_flags
2704 CHARACTER :: variable
2705 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf
2706 INTEGER :: b_dist, b_limit
2707 LOGICAL :: periodic_x
2709 periodic_x = config_flags%periodic_x
2711 variable = variable_in
2713 IF (variable == 'U') variable = 'u'
2714 IF (variable == 'V') variable = 'v'
2715 IF (variable == 'T') variable = 't'
2716 IF (variable == 'H') variable = 'h'
2717 IF (variable == 'W') variable = 'w'
2721 itf = min(ite,ide-1)
2724 jtf = min(jte,jde-1)
2726 IF (variable == 'u') ibe = ide
2727 IF (variable == 'u') itf = min(ite,ide)
2728 IF (variable == 'v') jbe = jde
2729 IF (variable == 'v') jtf = min(jte,jde)
2730 IF (variable == 'h') ktf = kte
2731 IF (variable == 'w') ktf = kte
2733 IF(.NOT.periodic_x)THEN
2734 IF (ibe - itf .lt. spec_zone) THEN
2736 DO i = max(its,ibe-spec_zone+1), itf
2739 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2740 if (variable == 't' .or. variable == 'h') then
2741 a_mu(i,j) = a_mu(i,j) &
2742 - field(i,k,j)/(mu(i,j)*mu(i,j)) * a_field(i,k,j)
2743 a_field(i,k,j) = a_field(i,k,j)/mu(i,j)
2745 a_mu(i,j) = a_mu(i,j) &
2746 - field(i,k,j)/(mu(i,j)*mu(i,j))*msf(i,j) * a_field(i,k,j)
2747 a_field(i,k,j) = a_field(i,k,j)/mu(i,j)*msf(i,j)
2754 IF (its - ibs .lt. spec_zone) THEN
2756 DO i = its, min(itf,ibs+spec_zone-1)
2759 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2760 if (variable == 't' .or. variable == 'h') then
2761 a_mu(i,j) = a_mu(i,j) &
2762 - field(i,k,j)/(mu(i,j)*mu(i,j)) * a_field(i,k,j)
2763 a_field(i,k,j) = a_field(i,k,j)/mu(i,j)
2765 a_mu(i,j) = a_mu(i,j) &
2766 - field(i,k,j)/(mu(i,j)*mu(i,j))*msf(i,j) * a_field(i,k,j)
2767 a_field(i,k,j) = a_field(i,k,j)/mu(i,j)*msf(i,j)
2776 IF (jbe - jtf .lt. spec_zone) THEN
2778 DO j = max(jts,jbe-spec_zone+1), jtf
2781 IF(periodic_x)b_limit = 0
2783 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2784 if (variable == 't' .or. variable == 'h') then
2785 a_mu(i,j) = a_mu(i,j) &
2786 - field(i,k,j)/(mu(i,j)*mu(i,j)) * a_field(i,k,j)
2787 a_field(i,k,j) = a_field(i,k,j)/mu(i,j)
2789 a_mu(i,j) = a_mu(i,j) &
2790 - field(i,k,j)/(mu(i,j)*mu(i,j))*msf(i,j) * a_field(i,k,j)
2791 a_field(i,k,j) = a_field(i,k,j)/mu(i,j)*msf(i,j)
2798 IF (jts - jbs .lt. spec_zone) THEN
2800 DO j = jts, min(jtf,jbs+spec_zone-1)
2803 IF(periodic_x)b_limit = 0
2805 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2806 if (variable == 't' .or. variable == 'h') then
2807 a_mu(i,j) = a_mu(i,j) &
2808 - field(i,k,j)/(mu(i,j)*mu(i,j)) * a_field(i,k,j)
2809 a_field(i,k,j) = a_field(i,k,j)/mu(i,j)
2811 a_mu(i,j) = a_mu(i,j) &
2812 - field(i,k,j)/(mu(i,j)*mu(i,j))*msf(i,j) * a_field(i,k,j)
2813 a_field(i,k,j) = a_field(i,k,j)/mu(i,j)*msf(i,j)
2820 END SUBROUTINE a_uncouple_bdy
2821 !------------------------------------------------------------------------
2823 SUBROUTINE a_flow_dep_bdy ( a_field, &
2824 u, v, config_flags, &
2826 ids,ide, jds,jde, kds,kde, & ! domain dims
2827 ims,ime, jms,jme, kms,kme, & ! memory dims
2828 ips,ipe, jps,jpe, kps,kpe, & ! patch dims
2829 its,ite, jts,jte, kts,kte )
2833 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde
2834 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme
2835 INTEGER, INTENT(IN) :: ips,ipe, jps,jpe, kps,kpe
2836 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte
2837 INTEGER, INTENT(IN) :: spec_zone
2840 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: a_field
2841 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN ) :: u
2842 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN ) :: v
2843 TYPE(grid_config_rec_type),INTENT(IN) :: config_flags
2845 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, i_inner, j_inner
2846 INTEGER :: b_dist, b_limit
2847 LOGICAL :: periodic_x
2853 periodic_x = config_flags%periodic_x
2857 itf = min(ite,ide-1)
2860 jtf = min(jte,jde-1)
2863 IF(.NOT.periodic_x)THEN
2864 IF (ibe - itf .lt. spec_zone) THEN
2866 DO i = max(its,ibe-spec_zone+1), itf
2869 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2870 j_inner = max(j,jbs+spec_zone)
2871 j_inner = min(j_inner,jbe-spec_zone)
2872 IF(u(i+1,k,j) .gt. 0.)THEN
2873 a_aux = a_aux + a_field(i,k,j)
2875 a_field(ibe-spec_zone,k,j_inner) = a_field(ibe-spec_zone,k,j_inner) + a_aux
2885 IF (its - ibs .lt. spec_zone) THEN
2887 DO i = its, min(itf,ibs+spec_zone-1)
2890 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
2891 j_inner = max(j,jbs+spec_zone)
2892 j_inner = min(j_inner,jbe-spec_zone)
2893 IF(u(i,k,j) .lt. 0.)THEN
2894 a_aux = a_aux + a_field(i,k,j)
2896 a_field(ibs+spec_zone,k,j_inner) = a_field(ibs+spec_zone,k,j_inner) + a_aux
2908 IF (jbe - jtf .lt. spec_zone) THEN
2910 DO j = max(jts,jbe-spec_zone+1), jtf
2913 IF(periodic_x)b_limit = 0
2915 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2916 i_inner = max(i,ibs+spec_zone)
2917 i_inner = min(i_inner,ibe-spec_zone)
2918 IF(periodic_x)i_inner = i
2919 IF(v(i,k,j+1) .gt. 0.)THEN
2920 a_aux = a_aux + a_field(i,k,j)
2922 a_field(i_inner,k,jbe-spec_zone) = a_field(i_inner,k,jbe-spec_zone) + a_aux
2932 IF (jts - jbs .lt. spec_zone) THEN
2934 DO j = jts, min(jtf,jbs+spec_zone-1)
2937 IF(periodic_x)b_limit = 0
2939 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
2940 i_inner = max(i,ibs+spec_zone)
2941 i_inner = min(i_inner,ibe-spec_zone)
2942 IF(periodic_x)i_inner = i
2943 IF(v(i,k,j) .lt. 0.)THEN
2944 a_aux = a_aux + a_field(i,k,j)
2946 a_field(i_inner,k,jbs+spec_zone) = a_field(i_inner,k,jbs+spec_zone) + a_aux
2956 END SUBROUTINE a_flow_dep_bdy
2958 ! Generated by TAPENADE (INRIA, Tropics team)
2959 ! Tapenade 3.6 (r4165) - 21 sep 2011 20:54
2961 ! Differentiation of flow_dep_bdy_qnn in reverse (adjoint) mode:
2962 ! gradient of useful results: field
2963 ! with respect to varying inputs: field
2964 ! RW status of diff variables: field:in-out
2968 SUBROUTINE A_FLOW_DEP_BDY_QNN(field, fieldb, u, v, config_flags, &
2969 & spec_zone, ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme&
2970 & , ips, ipe, jps, jpe, kps, kpe, its, ite, jts, jte, kts, kte)
2972 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde
2973 INTEGER, INTENT(IN) :: ims, ime, jms, jme, kms, kme
2974 INTEGER, INTENT(IN) :: ips, ipe, jps, jpe, kps, kpe
2975 INTEGER, INTENT(IN) :: its, ite, jts, jte, kts, kte
2976 INTEGER, INTENT(IN) :: spec_zone
2977 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: field
2978 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: fieldb
2979 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: u
2980 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: v
2981 TYPE(GRID_CONFIG_REC_TYPE) :: config_flags
2982 INTEGER :: i, j, k, ibs, ibe, jbs, jbe, itf, jtf, ktf, i_inner, &
2984 INTEGER :: b_dist, b_limit
2985 LOGICAL :: periodic_x
3017 periodic_x = config_flags%periodic_x
3020 IF (ite .GT. ide - 1) THEN
3027 IF (jte .GT. jde - 1) THEN
3033 IF (jts - jbs .LT. spec_zone) THEN
3034 IF (jtf .GT. jbs + spec_zone - 1) THEN
3035 min1 = jbs + spec_zone - 1
3043 IF (periodic_x) b_limit = 0
3045 IF (its .LT. b_limit + ibs) THEN
3046 max1 = b_limit + ibs
3050 IF (itf .GT. ibe - b_limit) THEN
3051 min3 = ibe - b_limit
3057 IF (i .LT. ibs + spec_zone) THEN
3058 CALL PUSHINTEGER4(i_inner)
3059 i_inner = ibs + spec_zone
3060 CALL PUSHCONTROL1B(0)
3062 CALL PUSHINTEGER4(i_inner)
3064 CALL PUSHCONTROL1B(1)
3066 IF (i_inner .GT. ibe - spec_zone) THEN
3067 i_inner = ibe - spec_zone
3071 IF (periodic_x) i_inner = i
3072 IF (v(i, k, j) .LT. 0.) THEN
3073 CALL PUSHCONTROL1B(1)
3075 CALL PUSHCONTROL1B(0)
3078 CALL PUSHINTEGER4(i - 1)
3079 CALL PUSHINTEGER4(ad_from)
3082 CALL PUSHCONTROL1B(0)
3084 CALL PUSHCONTROL1B(1)
3086 IF (jbe - jtf .LT. spec_zone) THEN
3087 IF (jts .LT. jbe - spec_zone + 1) THEN
3088 max2 = jbe - spec_zone + 1
3096 IF (periodic_x) b_limit = 0
3098 IF (its .LT. b_limit + ibs) THEN
3099 max3 = b_limit + ibs
3103 IF (itf .GT. ibe - b_limit) THEN
3104 min4 = ibe - b_limit
3110 IF (i .LT. ibs + spec_zone) THEN
3111 CALL PUSHINTEGER4(i_inner)
3112 i_inner = ibs + spec_zone
3113 CALL PUSHCONTROL1B(0)
3115 CALL PUSHINTEGER4(i_inner)
3117 CALL PUSHCONTROL1B(1)
3119 IF (i_inner .GT. ibe - spec_zone) THEN
3120 i_inner = ibe - spec_zone
3124 IF (periodic_x) i_inner = i
3125 IF (v(i, k, j+1) .GT. 0.) THEN
3126 CALL PUSHCONTROL1B(1)
3128 CALL PUSHCONTROL1B(0)
3131 CALL PUSHINTEGER4(i - 1)
3132 CALL PUSHINTEGER4(ad_from0)
3135 CALL PUSHCONTROL1B(0)
3137 CALL PUSHCONTROL1B(1)
3139 IF (.NOT.periodic_x) THEN
3140 IF (its - ibs .LT. spec_zone) THEN
3141 IF (itf .GT. ibs + spec_zone - 1) THEN
3142 min2 = ibs + spec_zone - 1
3150 IF (jts .LT. b_dist + jbs + 1) THEN
3151 max4 = b_dist + jbs + 1
3155 IF (jtf .GT. jbe - b_dist - 1) THEN
3156 min5 = jbe - b_dist - 1
3162 IF (j .LT. jbs + spec_zone) THEN
3163 CALL PUSHINTEGER4(j_inner)
3164 j_inner = jbs + spec_zone
3165 CALL PUSHCONTROL1B(0)
3167 CALL PUSHINTEGER4(j_inner)
3169 CALL PUSHCONTROL1B(1)
3171 IF (j_inner .GT. jbe - spec_zone) THEN
3172 j_inner = jbe - spec_zone
3176 IF (u(i, k, j) .LT. 0.) THEN
3177 CALL PUSHCONTROL1B(1)
3179 CALL PUSHCONTROL1B(0)
3182 CALL PUSHINTEGER4(j - 1)
3183 CALL PUSHINTEGER4(ad_from1)
3186 CALL PUSHCONTROL1B(0)
3188 CALL PUSHCONTROL1B(1)
3190 IF (ibe - itf .LT. spec_zone) THEN
3191 IF (its .LT. ibe - spec_zone + 1) THEN
3192 max5 = ibe - spec_zone + 1
3200 IF (jts .LT. b_dist + jbs + 1) THEN
3201 max6 = b_dist + jbs + 1
3205 IF (jtf .GT. jbe - b_dist - 1) THEN
3206 min6 = jbe - b_dist - 1
3212 IF (j .LT. jbs + spec_zone) THEN
3213 CALL PUSHINTEGER4(j_inner)
3214 j_inner = jbs + spec_zone
3215 CALL PUSHCONTROL1B(0)
3217 CALL PUSHINTEGER4(j_inner)
3219 CALL PUSHCONTROL1B(1)
3221 IF (j_inner .GT. jbe - spec_zone) THEN
3222 j_inner = jbe - spec_zone
3226 IF (u(i+1, k, j) .GT. 0.) THEN
3227 CALL PUSHCONTROL1B(1)
3229 CALL PUSHCONTROL1B(0)
3232 CALL PUSHINTEGER4(j - 1)
3233 CALL PUSHINTEGER4(ad_from2)
3238 CALL POPINTEGER4(ad_from2)
3239 CALL POPINTEGER4(ad_to2)
3240 DO j=ad_to2,ad_from2,-1
3241 CALL POPCONTROL1B(branch)
3242 IF (branch .EQ. 0) THEN
3243 fieldb(i, k, j) = 0.0
3245 tmp2b = fieldb(i, k, j)
3246 fieldb(i, k, j) = 0.0
3247 fieldb(ibe-spec_zone, k, j_inner) = fieldb(ibe-spec_zone, &
3248 & k, j_inner) + tmp2b
3250 CALL POPCONTROL1B(branch)
3251 IF (branch .EQ. 0) THEN
3252 CALL POPINTEGER4(j_inner)
3254 CALL POPINTEGER4(j_inner)
3260 CALL POPCONTROL1B(branch)
3261 IF (branch .EQ. 0) THEN
3264 CALL POPINTEGER4(ad_from1)
3265 CALL POPINTEGER4(ad_to1)
3266 DO j=ad_to1,ad_from1,-1
3267 CALL POPCONTROL1B(branch)
3268 IF (branch .EQ. 0) THEN
3269 fieldb(i, k, j) = 0.0
3271 tmp1b = fieldb(i, k, j)
3272 fieldb(i, k, j) = 0.0
3273 fieldb(ibs+spec_zone, k, j_inner) = fieldb(ibs+spec_zone, &
3274 & k, j_inner) + tmp1b
3276 CALL POPCONTROL1B(branch)
3277 IF (branch .EQ. 0) THEN
3278 CALL POPINTEGER4(j_inner)
3280 CALL POPINTEGER4(j_inner)
3287 CALL POPCONTROL1B(branch)
3288 IF (branch .EQ. 0) THEN
3291 CALL POPINTEGER4(ad_from0)
3292 CALL POPINTEGER4(ad_to0)
3293 DO i=ad_to0,ad_from0,-1
3294 CALL POPCONTROL1B(branch)
3295 IF (branch .EQ. 0) THEN
3296 fieldb(i, k, j) = 0.0
3298 tmp0b = fieldb(i, k, j)
3299 fieldb(i, k, j) = 0.0
3300 fieldb(i_inner, k, jbe-spec_zone) = fieldb(i_inner, k, jbe-&
3301 & spec_zone) + tmp0b
3303 CALL POPCONTROL1B(branch)
3304 IF (branch .EQ. 0) THEN
3305 CALL POPINTEGER4(i_inner)
3307 CALL POPINTEGER4(i_inner)
3313 CALL POPCONTROL1B(branch)
3314 IF (branch .EQ. 0) THEN
3317 CALL POPINTEGER4(ad_from)
3318 CALL POPINTEGER4(ad_to)
3319 DO i=ad_to,ad_from,-1
3320 CALL POPCONTROL1B(branch)
3321 IF (branch .EQ. 0) THEN
3322 fieldb(i, k, j) = 0.0
3324 tmpb = fieldb(i, k, j)
3325 fieldb(i, k, j) = 0.0
3326 fieldb(i_inner, k, jbs+spec_zone) = fieldb(i_inner, k, jbs+&
3329 CALL POPCONTROL1B(branch)
3330 IF (branch .EQ. 0) THEN
3331 CALL POPINTEGER4(i_inner)
3333 CALL POPINTEGER4(i_inner)
3339 END SUBROUTINE A_FLOW_DEP_BDY_QNN
3341 !---------------------------------------ntu3m-------------------------
3342 SUBROUTINE a_flow_dep_bdy_fixed_inflow(a_field,u,v,config_flags, &
3343 spec_zone,ids,ide,jds,jde,kds,kde, &
3344 ims,ime,jms,jme,kms,kme,ips,ipe,jps,&
3345 jpe,kps,kpe,its,ite,jts,jte,kts,kte)
3346 !---------------------------------------------------------------------
3348 INTEGER, INTENT(IN) :: ids,ide,jds,jde,kds,kde,ims,ime,jms,jme, &
3349 kms,kme,ips,ipe,jps,jpe,kps,kpe,its,ite, &
3350 jts,jte,kts,kte,spec_zone
3351 REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: &
3353 REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(IN) :: u,v
3354 TYPE(grid_config_rec_type),INTENT(IN) :: config_flags
3355 INTEGER :: i,j,k,ibs,ibe,jbs,jbe,itf,jtf,ktf,i_inner,j_inner, &
3357 LOGICAL :: periodic_x
3361 periodic_x = config_flags%periodic_x
3364 itf = min(ite,ide-1)
3367 jtf = min(jte,jde-1)
3370 IF (.NOT.periodic_x) THEN
3371 IF (ibe - itf .lt. spec_zone) THEN
3373 DO i = max(its,ibe-spec_zone+1), itf
3376 DO j = max(jts,b_dist+jbs+1), min(jtf,jbe-b_dist-1)
3377 j_inner = max(j,jbs+spec_zone)
3378 j_inner = min(j_inner,jbe-spec_zone)
3379 IF (u(i+1,k,j) .gt. 0.) THEN
3380 a_aux = a_aux+a_field(i,k,j)
3382 a_field(ibe-spec_zone,k,j_inner) = &
3383 a_field(ibe-spec_zone,k,j_inner)+a_aux
3386 a_field(i,k,j) = a_field(i,k,j)
3393 IF (its - ibs .lt. spec_zone) THEN
3395 DO i = its,min(itf,ibs+spec_zone-1)
3398 DO j = max(jts,b_dist+jbs+1),min(jtf,jbe-b_dist-1)
3399 j_inner = max(j,jbs+spec_zone)
3400 j_inner = min(j_inner,jbe-spec_zone)
3401 IF (u(i,k,j) .lt. 0.) THEN
3402 a_aux = a_aux+a_field(i,k,j)
3404 a_field(ibs+spec_zone,k,j_inner) = &
3405 a_field(ibs+spec_zone,k,j_inner)+a_aux
3408 a_field(i,k,j) = a_field(i,k,j)
3416 IF (jbe - jtf .lt. spec_zone) THEN
3418 DO j = max(jts,jbe-spec_zone+1), jtf
3421 IF (periodic_x) b_limit = 0
3423 DO i = max(its,b_limit+ibs),min(itf,ibe-b_limit)
3424 i_inner = max(i,ibs+spec_zone)
3425 i_inner = min(i_inner,ibe-spec_zone)
3426 IF (periodic_x) i_inner = i
3427 IF (v(i,k,j+1).gt.0.) THEN
3428 a_aux = a_aux+a_field(i,k,j)
3430 a_field(i_inner,k,jbe-spec_zone) = &
3431 a_field(i_inner,k,jbe-spec_zone)+a_aux
3434 a_field(i,k,j) = a_field(i,k,j)
3441 IF (jts - jbs .lt. spec_zone) THEN
3443 DO j = jts, min(jtf,jbs+spec_zone-1)
3446 IF (periodic_x) b_limit = 0
3448 DO i = max(its,b_limit+ibs), min(itf,ibe-b_limit)
3449 i_inner = max(i,ibs+spec_zone)
3450 i_inner = min(i_inner,ibe-spec_zone)
3451 IF (periodic_x) i_inner = i
3452 IF (v(i,k,j) .lt. 0.) THEN
3453 a_aux = a_aux+a_field(i,k,j)
3455 a_field(i_inner,k,jbs+spec_zone) = &
3456 a_field(i_inner,k,jbs+spec_zone)+a_aux
3459 a_field(i,k,j) = a_field(i,k,j)
3466 END SUBROUTINE a_flow_dep_bdy_fixed_inflow
3467 !--------------------------------------------------ntu3m-------------------------
3469 END MODULE a_module_bc