22 use fv_mp_nlm_mod,
only:
ng, isc,jsc,iec,jec, isd,jsd,ied,jed, is,js,ie,je, is_master
72 integer,
intent(in) :: istag, jstag, npx, npy
73 real,
intent(inout),
dimension(bd%isd:bd%ied+istag, bd%jsd:bd%jed+jstag) :: q
74 logical,
intent(in),
OPTIONAL :: pd_in, debug_in
76 integer :: i,j, istart, iend, jstart, jend
79 integer :: is, ie, js, je
80 integer :: isd, ied, jsd, jed
97 if (
present(pd_in))
then 103 if (
present(debug_in))
then 113 do j = jstart,jend+jstag
116 if (
real(i) <= 1. - q(1,j)/(q(2,j) - q(1,j) + 1.e-12) .and. q(1,j) < q(2,j))
then 119 q(i,j) =
real(2-i)*q(1,j) -
real(1-i)*q(2,j)
127 do j = jstart,jend+jstag
130 q(i,j) =
real(2-i)*q(1,j) -
real(1-i)*q(2,j)
144 do i = istart,iend+istag
146 if (
real(j) <= 1. - q(i,1)/(q(i,2) - q(i,1) + 1.e-12) .and. q(i,1) < q(i,2))
then 149 q(i,j) =
real(2-j)*q(i,1) -
real(1-j)*q(i,2)
158 do i = istart,iend+istag
160 q(i,j) =
real(2-j)*q(i,1) -
real(1-j)*q(i,2)
169 if (ie == npx - 1)
then 173 do j=jstart,jend+jstag
174 do i=ie+1+istag,ied+istag
176 if (
real(i) >= ie+istag + q(ie+istag,j)/(q(ie+istag-1,j)-q(ie+istag,j)+1.e-12) .and. &
177 q(ie+istag,j) < q(ie+istag-1,j))
then 180 q(i,j) =
real(i - (ie+istag-1))*q(ie+istag,j) +
real((ie+istag) - i)*q(ie+istag-1,j)
188 do j=jstart,jend+jstag
189 do i=ie+1+istag,ied+istag
191 q(i,j) =
real(i - (ie+istag-1))*q(ie+istag,j) +
real((ie+istag) - i)*q(ie+istag-1,j)
200 if (je == npy - 1)
then 204 do j=je+1+jstag,jed+jstag
205 do i=istart,iend+istag
207 if (
real(j) >= je+jstag + q(i,je+jstag)/(q(i,je+jstag-1)-q(i,je+jstag)+1.e-12) .and. &
208 q(i,je+jstag-1) > q(i,je+jstag))
then 211 q(i,j) =
real(j - (je+jstag-1))*q(i,je+jstag) +
real((je+jstag) - j)*q(i,je+jstag-1)
219 do j=je+1+jstag,jed+jstag
220 do i=istart,iend+istag
222 q(i,j) =
real(j - (je+jstag-1))*q(i,je+jstag) +
real((je+jstag) - j)*q(i,je+jstag-1)
234 if (is == 1 .and. js == 1)
then 241 if (
real(i) <= 1. - q(1,j)/(q(2,j) - q(1,j) + 1.e-12) .and. q(2,j) > q(1,j))
then 242 q(i,j) = 0.5*q(i+1,j)
244 q(i,j) = 0.5*(
real(2-i)*q(1,j) -
real(1-i)*q(2,j) )
247 if (
real(j) <= 1. - q(i,1)/(q(i,2) - q(i,1) + 1.e-12) .and. q(i,2) > q(i,1))
then 248 q(i,j) = q(i,j) + 0.5*q(i,j+1)
251 q(i,j) = q(i,j) + 0.5*(
real(2-j)*q(i,1) -
real(1-j)*q(i,2))
262 q(i,j) = 0.5*(
real(2-i)*q(1,j) -
real(1-i)*q(2,j) ) + &
263 0.5*(
real(2-j)*q(i,1) -
real(1-j)*q(i,2) )
272 if (is == 1 .and. je == npy-1)
then 276 do j=je+1+jstag,jed+jstag
279 if (
real(i) <= 1. - q(1,j)/(q(2,j) - q(1,j) + 1.e-12) .and. q(2,j) > q(1,j))
then 280 q(i,j) = 0.5*q(i+1,j)
282 q(i,j) = 0.5*(
real(2-i)*q(1,j) -
real(1-i)*q(2,j) )
287 if (
real(j) >= je+jstag - q(i,je+jstag)/(q(i,je+jstag-1)-q(i,je+jstag)+1.e-12) .and. &
288 q(i,je+jstag-1) > q(i,je+jstag) )
then 289 q(i,j) = q(i,j) + 0.5*q(i,j-1)
291 q(i,j) = q(i,j) + 0.5*(
real(j - (je+jstag-1))*q(i,je+jstag) +
real((je+jstag) - j)*q(i,je+jstag-1) )
299 do j=je+1+jstag,jed+jstag
302 q(i,j) = 0.5*(
real(2-i)*q(1,j) -
real(1-i)*q(2,j) ) + &
303 0.5*(
real(j - (je+jstag-1))*q(i,je+jstag) +
real((je+jstag) - j)*q(i,je+jstag-1) )
312 if (ie == npx-1 .and. je == npy-1)
then 316 do j=je+1+jstag,jed+jstag
317 do i=ie+1+istag,ied+istag
320 if (
real(i) >= ie+istag + q(ie+istag,j)/(q(ie+istag-1,j)-q(ie+istag,j)+1.e-12) .and. &
321 q(ie+istag-1,j) > q(ie+istag,j))
then 322 q(i,j) = 0.5*q(i-1,j)
324 q(i,j) = 0.5*(
real(i - (ie+istag-1))*q(ie+istag,j) +
real((ie+istag) - i)*q(ie+istag-1,j))
327 if (
real(j) >= je+jstag + q(i,je+jstag)/(q(i,je+jstag-1)-q(i,je+jstag)+1.e-12) .and. &
328 q(i,je+jstag-1) > q(i,je+jstag))
then 329 q(i,j) = q(i,j) + 0.5*q(i,j-1)
331 q(i,j) = q(i,j) + 0.5*(
real(j - (je+jstag-1))*q(i,je+jstag) +
real((je+jstag) - j)*q(i,je+jstag-1) )
339 do j=je+1+jstag,jed+jstag
340 do i=ie+1+istag,ied+istag
342 q(i,j) = 0.5*(
real(i - (ie+istag-1))*q(ie+istag,j) +
real((ie+istag) - i)*q(ie+istag-1,j) ) + &
343 0.5*(
real(j - (je+jstag-1))*q(i,je+jstag) +
real((je+jstag) - j)*q(i,je+jstag-1) )
352 if (ie == npx-1 .and. js == 1)
then 357 do i=ie+1+istag,ied+istag
360 if (
real(i) >= ie+istag + q(ie+istag,j)/(q(ie+istag-1,j)-q(ie+istag,j)+1.e-12) .and. &
361 q(ie+istag-1,j) > q(ie+istag,j))
then 362 q(i,j) = 0.5*q(i-1,j)
364 q(i,j) = 0.5*(
real(i - (ie+istag-1))*q(ie+istag,j) +
real((ie+istag) - i)*q(ie+istag-1,j))
367 if (
real(j) <= 1. - q(i,1)/(q(i,2) - q(i,1) + 1.e-12) .and. &
368 q(i,2) > q(i,1))
then 369 q(i,j) = q(i,j) + 0.5*q(i,j+1)
371 q(i,j) = q(i,j) + 0.5*(
real(2-j)*q(i,1) -
real(1-j)*q(i,2))
381 do i=ie+1+istag,ied+istag
383 q(i,j) = 0.5*(
real(i - (ie+istag-1))*q(ie+istag,j) +
real((ie+istag) - i)*q(ie+istag-1,j) ) + &
384 0.5*(
real(2-j)*q(i,1) -
real(1-j)*q(i,2) )
397 isg, ieg, jsg, jeg, bd, istart_in, iend_in, jstart_in, jend_in)
399 type(fv_grid_bounds_type),
intent(IN) :: bd
400 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag),
intent(INOUT) :: var_nest
401 real,
dimension(isg:ieg+istag,jsg:jeg+jstag),
intent(IN) :: var_coarse
402 integer,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,2),
intent(IN) :: ind
403 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,4),
intent(IN) :: wt
404 integer,
intent(IN) :: istag, jstag, isg, ieg, jsg, jeg
405 integer,
intent(IN),
OPTIONAL :: istart_in, iend_in, jstart_in, jend_in
407 integer :: i,j, ic, jc
408 integer :: istart, iend, jstart, jend
410 integer :: is, ie, js, je
411 integer :: isd, ied, jsd, jed
422 if (
present(istart_in))
then 427 if (
present(iend_in))
then 433 if (
present(jstart_in))
then 438 if (
present(jend_in))
then 451 wt(i,j,1)*var_coarse(ic, jc) + &
452 wt(i,j,2)*var_coarse(ic, jc+1) + &
453 wt(i,j,3)*var_coarse(ic+1,jc+1) + &
454 wt(i,j,4)*var_coarse(ic+1,jc)
462 isg, ieg, jsg, jeg, npz, bd, istart_in, iend_in, jstart_in, jend_in)
464 type(fv_grid_bounds_type),
intent(IN) :: bd
465 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,npz),
intent(INOUT) :: var_nest
466 real,
dimension(isg:ieg+istag,jsg:jeg+jstag,npz),
intent(IN) :: var_coarse
467 integer,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,2),
intent(IN) :: ind
468 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,4),
intent(IN) :: wt
469 integer,
intent(IN) :: istag, jstag, isg, ieg, jsg, jeg, npz
470 integer,
intent(IN),
OPTIONAL :: istart_in, iend_in, jstart_in, jend_in
472 integer :: i,j, ic, jc, k
473 integer :: istart, iend, jstart, jend
475 integer :: is, ie, js, je
476 integer :: isd, ied, jsd, jed
487 if (
present(istart_in))
then 492 if (
present(iend_in))
then 498 if (
present(jstart_in))
then 503 if (
present(jend_in))
then 518 wt(i,j,1)*var_coarse(ic, jc, k) + &
519 wt(i,j,2)*var_coarse(ic, jc+1,k) + &
520 wt(i,j,3)*var_coarse(ic+1,jc+1,k) + &
521 wt(i,j,4)*var_coarse(ic+1,jc, k)
530 subroutine nested_grid_bc_mpp(var_nest, var_coarse, nest_domain, ind, wt, istag, jstag, &
531 npx, npy, npz, bd, isg, ieg, jsg, jeg, nstep_in, nsplit_in, proc_in)
533 type(fv_grid_bounds_type),
intent(IN) :: bd
534 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,npz),
intent(INOUT) :: var_nest
535 real,
dimension(isg:ieg+istag,jsg:jeg+jstag,npz),
intent(IN) :: var_coarse
536 type(nest_domain_type),
intent(INOUT) :: nest_domain
537 integer,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,2),
intent(IN) :: ind
538 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,4),
intent(IN) :: wt
539 integer,
intent(IN) :: istag, jstag, npx, npy, npz, isg, ieg, jsg, jeg
540 integer,
intent(IN),
OPTIONAL :: nstep_in, nsplit_in
541 logical,
intent(IN),
OPTIONAL :: proc_in
543 integer :: isw_f, iew_f, jsw_f, jew_f, isw_c, iew_c, jsw_c, jew_c
544 integer :: ise_f, iee_f, jse_f, jee_f, ise_c, iee_c, jse_c, jee_c
545 integer :: iss_f, ies_f, jss_f, jes_f, iss_c, ies_c, jss_c, jes_c
546 integer :: isn_f, ien_f, jsn_f, jen_f, isn_c, ien_c, jsn_c, jen_c
547 real,
allocatable :: wbuffer(:,:,:)
548 real,
allocatable :: ebuffer(:,:,:)
549 real,
allocatable :: sbuffer(:,:,:)
550 real,
allocatable :: nbuffer(:,:,:)
552 integer :: i,j, ic, jc, istart, iend, k
557 integer :: is, ie, js, je
558 integer :: isd, ied, jsd, jed
569 if (
PRESENT(proc_in))
then 575 if (istag == 1 .and. jstag == 1)
then 577 else if (istag == 0 .and. jstag == 1)
then 579 else if (istag == 1 .and. jstag == 0)
then 585 call mpp_get_c2f_index(nest_domain, isw_f, iew_f, jsw_f, jew_f, isw_c, iew_c, jsw_c, jew_c, &
586 west, position=position)
587 call mpp_get_c2f_index(nest_domain, ise_f, iee_f, jse_f, jee_f, ise_c, iee_c, jse_c, jee_c, &
588 east, position=position)
589 call mpp_get_c2f_index(nest_domain, iss_f, ies_f, jss_f, jes_f, iss_c, ies_c, jss_c, jes_c, &
590 south, position=position)
591 call mpp_get_c2f_index(nest_domain, isn_f, ien_f, jsn_f, jen_f, isn_c, ien_c, jsn_c, jen_c, &
592 north, position=position)
594 if( iew_c .GE. isw_c .AND. jew_c .GE. jsw_c )
then 595 allocate(wbuffer(isw_c:iew_c, jsw_c:jew_c,npz))
597 allocate(wbuffer(1,1,1))
601 if( iee_c .GE. ise_c .AND. jee_c .GE. jse_c )
then 602 allocate(ebuffer(ise_c:iee_c, jse_c:jee_c,npz))
604 allocate(ebuffer(1,1,1))
608 if( ies_c .GE. iss_c .AND. jes_c .GE. jss_c )
then 609 allocate(sbuffer(iss_c:ies_c, jss_c:jes_c,npz))
611 allocate(sbuffer(1,1,1))
615 if( ien_c .GE. isn_c .AND. jen_c .GE. jsn_c )
then 616 allocate(nbuffer(isn_c:ien_c, jsn_c:jen_c,npz))
618 allocate(nbuffer(1,1,1))
624 call mpp_update_nest_fine(var_coarse, nest_domain, wbuffer, sbuffer, ebuffer, nbuffer, position=position)
638 wt(i,j,1)*wbuffer(ic, jc, k) + &
639 wt(i,j,2)*wbuffer(ic, jc+1,k) + &
640 wt(i,j,3)*wbuffer(ic+1,jc+1,k) + &
641 wt(i,j,4)*wbuffer(ic+1,jc, k)
656 if (ie == npx-1)
then 664 do i=istart,iend+istag
670 wt(i,j,1)*sbuffer(ic, jc, k) + &
671 wt(i,j,2)*sbuffer(ic, jc+1,k) + &
672 wt(i,j,3)*sbuffer(ic+1,jc+1,k) + &
673 wt(i,j,4)*sbuffer(ic+1,jc, k)
681 if (ie == npx-1)
then 684 do i=npx+istag,ied+istag
690 wt(i,j,1)*ebuffer(ic, jc, k) + &
691 wt(i,j,2)*ebuffer(ic, jc+1,k) + &
692 wt(i,j,3)*ebuffer(ic+1,jc+1,k) + &
693 wt(i,j,4)*ebuffer(ic+1,jc, k)
700 if (je == npy-1)
then 708 if (ie == npx-1)
then 715 do j=npy+jstag,jed+jstag
716 do i=istart,iend+istag
722 wt(i,j,1)*nbuffer(ic, jc, k) + &
723 wt(i,j,2)*nbuffer(ic, jc+1,k) + &
724 wt(i,j,3)*nbuffer(ic+1,jc+1,k) + &
725 wt(i,j,4)*nbuffer(ic+1,jc, k)
734 deallocate(wbuffer, ebuffer, sbuffer, nbuffer)
740 real,
dimension(:,:,:),
intent(IN) :: var_coarse
741 type(nest_domain_type),
intent(INOUT) :: nest_domain
742 integer,
intent(IN) :: istag, jstag
744 real,
allocatable :: wbuffer(:,:,:)
745 real,
allocatable :: ebuffer(:,:,:)
746 real,
allocatable :: sbuffer(:,:,:)
747 real,
allocatable :: nbuffer(:,:,:)
749 integer :: i,j, ic, jc, istart, iend, k
754 if (istag == 1 .and. jstag == 1)
then 756 else if (istag == 0 .and. jstag == 1)
then 758 else if (istag == 1 .and. jstag == 0)
then 765 allocate(wbuffer(1,1,1))
767 allocate(ebuffer(1,1,1))
769 allocate(sbuffer(1,1,1))
771 allocate(nbuffer(1,1,1))
775 call mpp_update_nest_fine(var_coarse, nest_domain, wbuffer, sbuffer, ebuffer, nbuffer, position=position)
779 deallocate(wbuffer, ebuffer, sbuffer, nbuffer)
784 npx, npy, bd, isg, ieg, jsg, jeg, nstep_in, nsplit_in, proc_in)
786 type(fv_grid_bounds_type),
intent(IN) :: bd
787 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag),
intent(INOUT) :: var_nest
788 real,
dimension(isg:ieg+istag,jsg:jeg+jstag),
intent(IN) :: var_coarse
789 type(nest_domain_type),
intent(INOUT) :: nest_domain
790 integer,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,2),
intent(IN) :: ind
791 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,4),
intent(IN) :: wt
792 integer,
intent(IN) :: istag, jstag, npx, npy, isg, ieg, jsg, jeg
793 integer,
intent(IN),
OPTIONAL :: nstep_in, nsplit_in
794 logical,
intent(IN),
OPTIONAL :: proc_in
796 integer :: isw_f, iew_f, jsw_f, jew_f, isw_c, iew_c, jsw_c, jew_c
797 integer :: ise_f, iee_f, jse_f, jee_f, ise_c, iee_c, jse_c, jee_c
798 integer :: iss_f, ies_f, jss_f, jes_f, iss_c, ies_c, jss_c, jes_c
799 integer :: isn_f, ien_f, jsn_f, jen_f, isn_c, ien_c, jsn_c, jen_c
800 real,
allocatable :: wbuffer(:,:)
801 real,
allocatable :: ebuffer(:,:)
802 real,
allocatable :: sbuffer(:,:)
803 real,
allocatable :: nbuffer(:,:)
805 integer :: i,j, ic, jc, istart, iend, k
810 integer :: is, ie, js, je
811 integer :: isd, ied, jsd, jed
822 if (
PRESENT(proc_in))
then 828 if (istag == 1 .and. jstag == 1)
then 830 else if (istag == 0 .and. jstag == 1)
then 832 else if (istag == 1 .and. jstag == 0)
then 838 call mpp_get_c2f_index(nest_domain, isw_f, iew_f, jsw_f, jew_f, isw_c, iew_c, jsw_c, jew_c, &
839 west, position=position)
840 call mpp_get_c2f_index(nest_domain, ise_f, iee_f, jse_f, jee_f, ise_c, iee_c, jse_c, jee_c, &
841 east, position=position)
842 call mpp_get_c2f_index(nest_domain, iss_f, ies_f, jss_f, jes_f, iss_c, ies_c, jss_c, jes_c, &
843 south, position=position)
844 call mpp_get_c2f_index(nest_domain, isn_f, ien_f, jsn_f, jen_f, isn_c, ien_c, jsn_c, jen_c, &
845 north, position=position)
847 if( iew_c .GE. isw_c .AND. jew_c .GE. jsw_c )
then 848 allocate(wbuffer(isw_c:iew_c, jsw_c:jew_c))
850 allocate(wbuffer(1,1))
854 if( iee_c .GE. ise_c .AND. jee_c .GE. jse_c )
then 855 allocate(ebuffer(ise_c:iee_c, jse_c:jee_c))
857 allocate(ebuffer(1,1))
861 if( ies_c .GE. iss_c .AND. jes_c .GE. jss_c )
then 862 allocate(sbuffer(iss_c:ies_c, jss_c:jes_c))
864 allocate(sbuffer(1,1))
868 if( ien_c .GE. isn_c .AND. jen_c .GE. jsn_c )
then 869 allocate(nbuffer(isn_c:ien_c, jsn_c:jen_c))
871 allocate(nbuffer(1,1))
876 call mpp_update_nest_fine(var_coarse, nest_domain, wbuffer, sbuffer, ebuffer, nbuffer, position=position)
889 wt(i,j,1)*wbuffer(ic, jc) + &
890 wt(i,j,2)*wbuffer(ic, jc+1) + &
891 wt(i,j,3)*wbuffer(ic+1,jc+1) + &
892 wt(i,j,4)*wbuffer(ic+1,jc)
906 if (ie == npx-1)
then 913 do i=istart,iend+istag
919 wt(i,j,1)*sbuffer(ic, jc) + &
920 wt(i,j,2)*sbuffer(ic, jc+1) + &
921 wt(i,j,3)*sbuffer(ic+1,jc+1) + &
922 wt(i,j,4)*sbuffer(ic+1,jc)
929 if (ie == npx-1)
then 931 do i=npx+istag,ied+istag
937 wt(i,j,1)*ebuffer(ic, jc) + &
938 wt(i,j,2)*ebuffer(ic, jc+1) + &
939 wt(i,j,3)*ebuffer(ic+1,jc+1) + &
940 wt(i,j,4)*ebuffer(ic+1,jc)
946 if (je == npy-1)
then 954 if (ie == npx-1)
then 960 do j=npy+jstag,jed+jstag
961 do i=istart,iend+istag
967 wt(i,j,1)*nbuffer(ic, jc) + &
968 wt(i,j,2)*nbuffer(ic, jc+1) + &
969 wt(i,j,3)*nbuffer(ic+1,jc+1) + &
970 wt(i,j,4)*nbuffer(ic+1,jc)
978 deallocate(wbuffer, ebuffer, sbuffer, nbuffer)
983 npx, npy, bd, isg, ieg, jsg, jeg, nstep_in, nsplit_in)
985 type(fv_grid_bounds_type),
intent(IN) :: bd
986 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag),
intent(INOUT) :: var_nest
987 real,
dimension(isg:ieg+istag,jsg:jeg+jstag),
intent(IN) :: var_coarse
988 integer,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,2),
intent(IN) :: ind
989 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,4),
intent(IN) :: wt
990 integer,
intent(IN) :: istag, jstag, npx, npy, isg, ieg, jsg, jeg
991 integer,
intent(IN),
OPTIONAL :: nstep_in, nsplit_in
993 integer :: nstep, nsplit
995 integer :: i,j, ic, jc, istart, iend
997 integer :: is, ie, js, je
998 integer :: isd, ied, jsd, jed
1009 if ( .not.
present(nstep_in) .or. .not.
present(nsplit_in) )
then 1025 wt(i,j,1)*var_coarse(ic, jc) + &
1026 wt(i,j,2)*var_coarse(ic, jc+1) + &
1027 wt(i,j,3)*var_coarse(ic+1,jc+1) + &
1028 wt(i,j,4)*var_coarse(ic+1,jc)
1042 if (ie == npx-1)
then 1049 do i=istart,iend+istag
1055 wt(i,j,1)*var_coarse(ic, jc) + &
1056 wt(i,j,2)*var_coarse(ic, jc+1) + &
1057 wt(i,j,3)*var_coarse(ic+1,jc+1) + &
1058 wt(i,j,4)*var_coarse(ic+1,jc)
1065 if (ie == npx-1)
then 1067 do i=npx+istag,ied+istag
1073 wt(i,j,1)*var_coarse(ic, jc) + &
1074 wt(i,j,2)*var_coarse(ic, jc+1) + &
1075 wt(i,j,3)*var_coarse(ic+1,jc+1) + &
1076 wt(i,j,4)*var_coarse(ic+1,jc)
1082 if (je == npy-1)
then 1090 if (ie == npx-1)
then 1097 do j=npy+jstag,jed+jstag
1098 do i=istart,iend+istag
1104 wt(i,j,1)*var_coarse(ic, jc) + &
1105 wt(i,j,2)*var_coarse(ic, jc+1) + &
1106 wt(i,j,3)*var_coarse(ic+1,jc+1) + &
1107 wt(i,j,4)*var_coarse(ic+1,jc)
1118 npx, npy, npz, bd, isg, ieg, jsg, jeg, nstep_in, nsplit_in)
1120 type(fv_grid_bounds_type),
intent(IN) :: bd
1121 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,npz),
intent(INOUT) :: var_nest
1122 real,
dimension(isg:ieg+istag,jsg:jeg+jstag,npz),
intent(IN) :: var_coarse
1123 integer,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,2),
intent(IN) :: ind
1124 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,4),
intent(IN) :: wt
1125 integer,
intent(IN) :: istag, jstag, npx, npy, isg, ieg, jsg, jeg, npz
1126 integer,
intent(IN),
OPTIONAL :: nstep_in, nsplit_in
1128 integer :: nstep, nsplit
1130 integer :: i,j, ic, jc, istart, iend, k
1132 integer :: is, ie, js, je
1133 integer :: isd, ied, jsd, jed
1144 if ( .not.
present(nstep_in) .or. .not.
present(nsplit_in) )
then 1161 wt(i,j,1)*var_coarse(ic, jc, k) + &
1162 wt(i,j,2)*var_coarse(ic, jc+1,k) + &
1163 wt(i,j,3)*var_coarse(ic+1,jc+1,k) + &
1164 wt(i,j,4)*var_coarse(ic+1,jc, k)
1179 if (ie == npx-1)
then 1187 do i=istart,iend+istag
1193 wt(i,j,1)*var_coarse(ic, jc, k) + &
1194 wt(i,j,2)*var_coarse(ic, jc+1,k) + &
1195 wt(i,j,3)*var_coarse(ic+1,jc+1,k) + &
1196 wt(i,j,4)*var_coarse(ic+1,jc, k)
1204 if (ie == npx-1)
then 1207 do i=npx+istag,ied+istag
1213 wt(i,j,1)*var_coarse(ic, jc, k) + &
1214 wt(i,j,2)*var_coarse(ic, jc+1,k) + &
1215 wt(i,j,3)*var_coarse(ic+1,jc+1,k) + &
1216 wt(i,j,4)*var_coarse(ic+1,jc, k)
1223 if (je == npy-1)
then 1231 if (ie == npx-1)
then 1238 do j=npy+jstag,jed+jstag
1239 do i=istart,iend+istag
1245 wt(i,j,1)*var_coarse(ic, jc, k) + &
1246 wt(i,j,2)*var_coarse(ic, jc+1,k) + &
1247 wt(i,j,3)*var_coarse(ic+1,jc+1,k) + &
1248 wt(i,j,4)*var_coarse(ic+1,jc, k)
1261 real,
dimension(:,:,:),
intent(IN) :: var_coarse
1263 integer,
intent(IN) :: istag, jstag
1267 real :: wbuffer(1,1,1)
1268 real :: ebuffer(1,1,1)
1269 real :: sbuffer(1,1,1)
1270 real :: nbuffer(1,1,1)
1273 if (istag == 1 .and. jstag == 1)
then 1275 else if (istag == 0 .and. jstag == 1)
then 1277 else if (istag == 1 .and. jstag == 0)
then 1284 call mpp_update_nest_fine(var_coarse, nest_domain, wbuffer, sbuffer, ebuffer, nbuffer, position=position)
1290 bd, nest_BC_buffers)
1294 integer,
intent(IN) :: istag, jstag, npz
1298 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,npz) :: var_coarse_dummy
1302 integer :: isw_f, iew_f, jsw_f, jew_f, isw_c, iew_c, jsw_c, jew_c
1303 integer :: ise_f, iee_f, jse_f, jee_f, ise_c, iee_c, jse_c, jee_c
1304 integer :: iss_f, ies_f, jss_f, jes_f, iss_c, ies_c, jss_c, jes_c
1305 integer :: isn_f, ien_f, jsn_f, jen_f, isn_c, ien_c, jsn_c, jen_c
1309 if (istag == 1 .and. jstag == 1)
then 1311 else if (istag == 0 .and. jstag == 1)
then 1313 else if (istag == 1 .and. jstag == 0)
then 1319 if (.not.
allocated(nest_bc_buffers%west_t1) )
then 1321 call mpp_get_c2f_index(nest_domain, isw_f, iew_f, jsw_f, jew_f, isw_c, iew_c, jsw_c, jew_c, &
1322 west, position=position)
1323 call mpp_get_c2f_index(nest_domain, ise_f, iee_f, jse_f, jee_f, ise_c, iee_c, jse_c, jee_c, &
1324 east, position=position)
1325 call mpp_get_c2f_index(nest_domain, iss_f, ies_f, jss_f, jes_f, iss_c, ies_c, jss_c, jes_c, &
1326 south, position=position)
1327 call mpp_get_c2f_index(nest_domain, isn_f, ien_f, jsn_f, jen_f, isn_c, ien_c, jsn_c, jen_c, &
1328 north, position=position)
1330 if( iew_c .GE. isw_c .AND. jew_c .GE. jsw_c )
then 1331 If (.not.
allocated(nest_bc_buffers%west_t1))
allocate(nest_bc_buffers%west_t1(isw_c:iew_c, jsw_c:jew_c,npz))
1336 nest_bc_buffers%west_t1(i,j,k) = 0.
1341 allocate(nest_bc_buffers%west_t1(1,1,1))
1342 nest_bc_buffers%west_t1(1,1,1) = 0.
1345 if( iee_c .GE. ise_c .AND. jee_c .GE. jse_c )
then 1346 If (.not.
allocated(nest_bc_buffers%east_t1))
allocate(nest_bc_buffers%east_t1(ise_c:iee_c, jse_c:jee_c,npz))
1350 nest_bc_buffers%east_t1(i,j,k) = 0.
1355 allocate(nest_bc_buffers%east_t1(1,1,1))
1356 nest_bc_buffers%east_t1(1,1,1) = 0.
1359 if( ies_c .GE. iss_c .AND. jes_c .GE. jss_c )
then 1360 If (.not.
allocated(nest_bc_buffers%south_t1))
allocate(nest_bc_buffers%south_t1(iss_c:ies_c, jss_c:jes_c,npz))
1364 nest_bc_buffers%south_t1(i,j,k) = 0.
1369 allocate(nest_bc_buffers%south_t1(1,1,1))
1370 nest_bc_buffers%south_t1(1,1,1) = 0.
1373 if( ien_c .GE. isn_c .AND. jen_c .GE. jsn_c )
then 1374 If (.not.
allocated(nest_bc_buffers%north_t1))
allocate(nest_bc_buffers%north_t1(isn_c:ien_c, jsn_c:jen_c,npz))
1378 nest_bc_buffers%north_t1(i,j,k) = 0.
1383 allocate(nest_bc_buffers%north_t1(1,1,1))
1384 nest_bc_buffers%north_t1(1,1,1) = 0
1390 call mpp_update_nest_fine(var_coarse_dummy, nest_domain, nest_bc_buffers%west_t1, nest_bc_buffers%south_t1, nest_bc_buffers%east_t1, nest_bc_buffers%north_t1, position=position)
1396 npx, npy, npz, bd, nest_BC, nest_BC_buffers, pd_in)
1400 integer,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,2),
intent(IN) :: ind
1401 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,4),
intent(IN) :: wt
1402 integer,
intent(IN) :: istag, jstag, npx, npy, npz
1403 logical,
intent(IN),
OPTIONAL :: pd_in
1409 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag,npz) :: var_coarse_dummy
1411 real,
dimension(:,:,:),
pointer :: var_east, var_west, var_south, var_north
1412 real,
dimension(:,:,:),
pointer :: buf_east, buf_west, buf_south, buf_north
1417 integer :: i,j, k, ic, jc, istart, iend
1418 logical :: process, pd = .false.
1420 integer :: is, ie, js, je
1421 integer :: isd, ied, jsd, jed
1433 if (
present(pd_in))
then 1440 var_east => nest_bc%east_t1
1441 var_west => nest_bc%west_t1
1442 var_north => nest_bc%north_t1
1443 var_south => nest_bc%south_t1
1445 buf_east => nest_bc_buffers%east_t1
1446 buf_west => nest_bc_buffers%west_t1
1447 buf_north => nest_bc_buffers%north_t1
1448 buf_south => nest_bc_buffers%south_t1
1463 wt(i,j,1)*buf_west(ic, jc,k) + &
1464 wt(i,j,2)*buf_west(ic, jc+1,k) + &
1465 wt(i,j,3)*buf_west(ic+1,jc+1,k) + &
1466 wt(i,j,4)*buf_west(ic+1,jc,k)
1478 var_west(i,j,k) =
max(var_west(i,j,k), 0.5*nest_bc%west_t0(i,j,k))
1494 if (ie == npx-1)
then 1503 do i=istart,iend+istag
1509 var_south(i,j,k) = &
1510 wt(i,j,1)*buf_south(ic, jc,k) + &
1511 wt(i,j,2)*buf_south(ic, jc+1,k) + &
1512 wt(i,j,3)*buf_south(ic+1,jc+1,k) + &
1513 wt(i,j,4)*buf_south(ic+1,jc,k)
1523 do i=istart,iend+istag
1525 var_south(i,j,k) =
max(var_south(i,j,k), 0.5*nest_bc%south_t0(i,j,k))
1535 if (ie == npx-1 )
then 1540 do i=npx+istag,ied+istag
1547 wt(i,j,1)*buf_east(ic, jc,k) + &
1548 wt(i,j,2)*buf_east(ic, jc+1,k) + &
1549 wt(i,j,3)*buf_east(ic+1,jc+1,k) + &
1550 wt(i,j,4)*buf_east(ic+1,jc,k)
1560 do i=npx+istag,ied+istag
1562 var_east(i,j,k) =
max(var_east(i,j,k), 0.5*nest_bc%east_t0(i,j,k))
1571 if (je == npy-1 )
then 1579 if (ie == npx-1)
then 1587 do j=npy+jstag,jed+jstag
1588 do i=istart,iend+istag
1594 var_north(i,j,k) = &
1595 wt(i,j,1)*buf_north(ic, jc,k) + &
1596 wt(i,j,2)*buf_north(ic, jc+1,k) + &
1597 wt(i,j,3)*buf_north(ic+1,jc+1,k) + &
1598 wt(i,j,4)*buf_north(ic+1,jc,k)
1607 do j=npy+jstag,jed+jstag
1608 do i=istart,iend+istag
1610 var_north(i,j,k) =
max(var_north(i,j,k), 0.5*nest_bc%north_t0(i,j,k))
1627 npx, npy, npz, bd, step, split, &
1631 real,
dimension(bd%isd:bd%ied+istag,bd%jsd:bd%jed+jstag, npz),
intent(INOUT) :: var_nest
1632 integer,
intent(IN) :: istag, jstag, npx, npy, npz
1633 real,
intent(IN) :: split, step
1634 integer,
intent(IN) :: bctype
1637 real,
pointer,
dimension(:,:,:) :: var_t0, var_t1
1639 integer :: i,j, istart, iend, k
1642 logical,
save :: printdiag = .true.
1644 integer :: is, ie, js, je
1645 integer :: isd, ied, jsd, jed
1658 var_t0 => bc%west_t0
1659 var_t1 => bc%west_t1
1663 var_nest(i,j,k) = (var_t0(i,j,k)*(split-step) + step*var_t1(i,j,k))*denom
1678 if (ie == npx-1)
then 1684 var_t0 => bc%south_t0
1685 var_t1 => bc%south_t1
1688 do i=istart,iend+istag
1690 var_nest(i,j,k) = (var_t0(i,j,k)*(split-step) + step*var_t1(i,j,k))*denom
1697 if (ie == npx-1 )
then 1698 var_t0 => bc%east_t0
1699 var_t1 => bc%east_t1
1702 do i=npx+istag,ied+istag
1703 var_nest(i,j,k) = (var_t0(i,j,k)*(split-step) + step*var_t1(i,j,k))*denom
1711 if (je == npy-1 )
then 1719 if (ie == npx-1)
then 1725 var_t0 => bc%north_t0
1726 var_t1 => bc%north_t1
1728 do j=npy+jstag,jed+jstag
1729 do i=istart,iend+istag
1731 var_nest(i,j,k) = (var_t0(i,j,k)*(split-step) + step*var_t1(i,j,k))*denom
1743 isd_p, ied_p, jsd_p, jed_p, is_n, ie_n, js_n, je_n, isu, ieu, jsu, jeu, npx, npy, &
1744 istag, jstag, r, nestupdate, upoff, nsponge, parent_proc, child_proc, parent_grid)
1746 integer,
intent(IN) :: isd_p, ied_p, jsd_p, jed_p, is_n, ie_n, js_n, je_n
1747 integer,
intent(IN) :: isu, ieu, jsu, jeu
1748 integer,
intent(IN) :: istag, jstag, r, nestupdate, upoff, nsponge
1749 integer,
intent(IN) :: ind_update(isd_p:ied_p+1,jsd_p:jed_p+1,2)
1750 integer,
intent(IN) :: npx, npy
1751 real,
intent(IN) :: var_nest(is_n:ie_n+istag,js_n:je_n+jstag)
1752 real,
intent(INOUT) :: var_coarse(isd_p:ied_p+istag,jsd_p:jed_p+jstag)
1753 real,
intent(IN) :: dx(isd:ied,jsd:jed+1)
1754 real,
intent(IN) :: dy(isd:ied+1,jsd:jed)
1755 real,
intent(IN) :: area(isd:ied,jsd:jed)
1756 logical,
intent(IN) :: parent_proc, child_proc
1757 type(fv_atmos_type),
intent(INOUT) :: parent_grid
1758 type(nest_domain_type),
intent(INOUT) :: nest_domain
1760 real :: var_nest_3d(is_n:ie_n+istag,js_n:je_n+jstag,1)
1761 real :: var_coarse_3d(isd_p:ied_p+istag,jsd_p:jed_p+jstag,1)
1763 if (child_proc .and.
size(var_nest) > 1) var_nest_3d(is_n:ie_n+istag,js_n:je_n+jstag,1) = var_nest(is_n:ie_n+istag,js_n:je_n+jstag)
1764 if (parent_proc .and.
size(var_coarse) > 1) var_coarse_3d(isd_p:ied_p+istag,jsd_p:jed_p,1) = var_coarse(isd_p:ied_p+istag,jsd_p:jed_p+jstag)
1767 nest_domain, ind_update, dx, dy, area, &
1768 isd_p, ied_p, jsd_p, jed_p, is_n, ie_n, js_n, je_n, &
1769 isu, ieu, jsu, jeu, npx, npy, 1, &
1770 istag, jstag, r, nestupdate, upoff, nsponge, &
1771 parent_proc, child_proc, parent_grid)
1773 if (
size(var_coarse) > 1 .and. parent_proc) var_coarse(isd_p:ied_p+istag,jsd_p:jed_p+jstag) = var_coarse_3d(isd_p:ied_p+istag,jsd_p:jed_p,1)
1779 isd_p, ied_p, jsd_p, jed_p, is_n, ie_n, js_n, je_n, &
1780 isu, ieu, jsu, jeu, npx, npy, npz, &
1781 istag, jstag, r, nestupdate, upoff, nsponge, parent_proc, child_proc, parent_grid)
1787 integer,
intent(IN) :: isd_p, ied_p, jsd_p, jed_p, is_n, ie_n, js_n, je_n
1788 integer,
intent(IN) :: isu, ieu, jsu, jeu
1789 integer,
intent(IN) :: istag, jstag, npx, npy, npz, r, nestupdate, upoff, nsponge
1790 integer,
intent(IN) :: ind_update(isd_p:ied_p+1,jsd_p:jed_p+1,2)
1791 real,
intent(IN) :: var_nest(is_n:ie_n+istag,js_n:je_n+jstag,npz)
1792 real,
intent(INOUT) :: var_coarse(isd_p:ied_p+istag,jsd_p:jed_p+jstag,npz)
1793 real,
intent(IN) :: area(isd:ied,jsd:jed)
1794 real,
intent(IN) :: dx(isd:ied,jsd:jed+1)
1795 real,
intent(IN) :: dy(isd:ied+1,jsd:jed)
1796 logical,
intent(IN) :: parent_proc, child_proc
1797 type(fv_atmos_type),
intent(INOUT) :: parent_grid
1799 type(nest_domain_type),
intent(INOUT) :: nest_domain
1801 integer :: in, jn, ini, jnj, s, qr
1802 integer :: is_c, ie_c, js_c, je_c, is_f, ie_f, js_f, je_f
1803 integer :: istart, istop, jstart, jstop, ishift, jshift, j, i, k
1805 real,
allocatable,
dimension(:,:,:) :: nest_dat
1806 real :: var_nest_send(is_n:ie_n+istag,js_n:je_n+jstag,npz)
1809 if (istag == 1 .and. jstag == 1)
then 1811 else if (istag == 0 .and. jstag == 1)
then 1813 else if (istag == 1 .and. jstag == 0)
then 1819 call mpp_get_f2c_index(nest_domain, is_c, ie_c, js_c, je_c, is_f, ie_f, js_f, je_f, position=position)
1820 if (ie_f > is_f .and. je_f > js_f)
then 1821 allocate(nest_dat(is_f:ie_f, js_f:je_f,npz))
1823 allocate(nest_dat(1,1,1))
1827 if (child_proc)
then 1829 if (istag == 0 .and. jstag == 0)
then 1830 select case (nestupdate)
1839 var_nest_send(i,j,k) = var_nest(i,j,k)*area(i,j)
1846 else if (istag == 0 .and. jstag > 0)
then 1848 select case (nestupdate)
1857 var_nest_send(i,j,k) = var_nest(i,j,k)*dx(i,j)
1865 call mpp_error(fatal,
'nestupdate type not implemented')
1869 else if (istag > 0 .and. jstag == 0)
then 1870 select case (nestupdate)
1879 var_nest_send(i,j,k) = var_nest(i,j,k)*dy(i,j)
1887 call mpp_error(fatal,
'nestupdate type not implemented')
1893 call mpp_error(fatal,
"Cannot have both nonzero istag and jstag.")
1903 qr = r*upoff + nsponge - s
1905 if (parent_proc .and. .not. (ieu < isu .or. jeu < jsu))
then 1906 if (istag == 0 .and. jstag == 0)
then 1908 select case (nestupdate)
1917 in = ind_update(i,j,1)
1918 jn = ind_update(i,j,2)
1929 val = val + nest_dat(ini,jnj,k)
1937 var_coarse(i,j,k) = val*parent_grid%gridstruct%rarea(i,j)
1946 call mpp_error(fatal,
'nestupdate type not implemented')
1951 else if (istag == 0 .and. jstag > 0)
then 1954 select case (nestupdate)
1963 in = ind_update(i,j,1)
1964 jn = ind_update(i,j,2)
1974 val = val + nest_dat(ini,jn,k)
1978 var_coarse(i,j,k) = val*parent_grid%gridstruct%rdx(i,j)
1986 call mpp_error(fatal,
'nestupdate type not implemented')
1990 else if (istag > 0 .and. jstag == 0)
then 1992 select case (nestupdate)
2001 in = ind_update(i,j,1)
2002 jn = ind_update(i,j,2)
2012 val = val + nest_dat(in,jnj,k)
2016 var_coarse(i,j,k) = val*parent_grid%gridstruct%rdy(i,j)
2024 call mpp_error(fatal,
'nestupdate type not implemented')
2032 deallocate(nest_dat)
subroutine, public nested_grid_bc_apply_intt(var_nest, istag, jstag, npx, npy, npz, bd, step, split, BC, bctype)
subroutine fill_nested_grid_3d(var_nest, var_coarse, ind, wt, istag, jstag, isg, ieg, jsg, jeg, npz, bd, istart_in, iend_in, jstart_in, jend_in)
subroutine nested_grid_bc_3d(var_nest, var_coarse, ind, wt, istag, jstag, npx, npy, npz, bd, isg, ieg, jsg, jeg, nstep_in, nsplit_in)
subroutine nested_grid_bc_2d(var_nest, var_coarse, ind, wt, istag, jstag, npx, npy, bd, isg, ieg, jsg, jeg, nstep_in, nsplit_in)
subroutine, public nested_grid_bc_recv(nest_domain, istag, jstag, npz, bd, nest_BC_buffers)
subroutine nested_grid_bc_2d_mpp(var_nest, var_coarse, nest_domain, ind, wt, istag, jstag, npx, npy, bd, isg, ieg, jsg, jeg, nstep_in, nsplit_in, proc_in)
subroutine nested_grid_bc_mpp(var_nest, var_coarse, nest_domain, ind, wt, istag, jstag, npx, npy, npz, bd, isg, ieg, jsg, jeg, nstep_in, nsplit_in, proc_in)
integer, parameter, public ng
subroutine timing_on(blk_name)
subroutine, public extrapolation_bc(q, istag, jstag, npx, npy, bd, pd_in, debug_in)
subroutine fill_nested_grid_2d(var_nest, var_coarse, ind, wt, istag, jstag, isg, ieg, jsg, jeg, bd, istart_in, iend_in, jstart_in, jend_in)
subroutine, public nested_grid_bc_send(var_coarse, nest_domain, istag, jstag)
real, parameter, public grav
Acceleration due to gravity [m/s^2].
subroutine, public nested_grid_bc_save_proc(nest_domain, ind, wt, istag, jstag, npx, npy, npz, bd, nest_BC, nest_BC_buffers, pd_in)
subroutine update_coarse_grid_mpp_2d(var_coarse, var_nest, nest_domain, ind_update, dx, dy, area, isd_p, ied_p, jsd_p, jed_p, is_n, ie_n, js_n, je_n, isu, ieu, jsu, jeu, npx, npy, istag, jstag, r, nestupdate, upoff, nsponge, parent_proc, child_proc, parent_grid)
subroutine nested_grid_bc_mpp_send(var_coarse, nest_domain, istag, jstag)
subroutine update_coarse_grid_mpp(var_coarse, var_nest, nest_domain, ind_update, dx, dy, area, isd_p, ied_p, jsd_p, jed_p, is_n, ie_n, js_n, je_n, isu, ieu, jsu, jeu, npx, npy, npz, istag, jstag, r, nestupdate, upoff, nsponge, parent_proc, child_proc, parent_grid)
subroutine timing_off(blk_name)