subroutine createmasks use modglobal, only : libm, ib, ie, ih, ihc, jb, je, jh, jhc, kb, ke, kh, khc, itot, jtot, rslabs use modfields, only : IIc, IIu, IIv, IIw, IIuw, IIvw, IIuv, & IIcs, IIus, IIvs, IIws, IIuws, IIvws, IIuvs, & IIct, IIut, IIvt, IIwt, IIuwt, um, u0, vm, v0, wm, w0 use modmpi, only : myid, comm3d, mpierr, MY_REAL, nprocs use decomp_2d, only : zstart, exchange_halo_z integer :: IIcl(kb:ke + khc), IIul(kb:ke + khc), IIvl(kb:ke + khc), IIwl(kb:ke + khc), IIuwl(kb:ke + khc), IIvwl(kb:ke + khc), IIuvl(kb:ke + khc) integer :: IIcd(ib:ie, kb:ke) integer :: IIwd(ib:ie, kb:ke) integer :: IIuwd(ib:ie, kb:ke) integer :: IIud(ib:ie, kb:ke) integer :: IIvd(ib:ie, kb:ke) integer :: i, j, k, n, m ! II*l needn't be defined up to ke_khc, but for now would require large scale changes in modstatsdump so if works leave as is ! tg3315 04/07/18 if (.not. libm) then IIc(:, :, :) = 1 IIu(:, :, :) = 1 IIv(:, :, :) = 1 IIw(:, :, :) = 1 IIuw(:, :, :) = 1 IIvw(:, :, :) = 1 IIuv(:, :, :) = 1 IIcs(:) = nint(rslabs) IIus(:) = nint(rslabs) IIvs(:) = nint(rslabs) IIws(:) = nint(rslabs) IIuws(:) = nint(rslabs) IIvws(:) = nint(rslabs) IIuvs(:) = nint(rslabs) IIct(:, :) = jtot IIut(:, :) = jtot IIvt(:, :) = jtot IIwt(:, :) = jtot IIuwt(:, :) = jtot return end if ! Create masking matrices IIc = 1; IIu = 1; IIv = 1; IIct = 1; IIw = 1; IIuw = 1; IIvw = 1; IIuv = 1; IIwt = 1; IIut = 1; IIvt = 1; IIuwt = 1; IIcs = 1; IIus = 1; IIvs = 1; IIws = 1; IIuws = 1; IIvws = 1; IIuvs = 1 do n = 1,solid_info_u%nsolptsrank !n = solid_info_u%solptsrank(m) i = solid_info_u%solpts_loc(n,1) - zstart(1) + 1 j = solid_info_u%solpts_loc(n,2) - zstart(2) + 1 k = solid_info_u%solpts_loc(n,3) - zstart(3) + 1 IIu(i,j,k) = 0 end do do n = 1,solid_info_v%nsolptsrank !n = solid_info_v%solptsrank(m) i = solid_info_v%solpts_loc(n,1) - zstart(1) + 1 j = solid_info_v%solpts_loc(n,2) - zstart(2) + 1 k = solid_info_v%solpts_loc(n,3) - zstart(3) + 1 IIv(i,j,k) = 0 end do do n = 1,solid_info_w%nsolptsrank !n = solid_info_w%solptsrank(m) i = solid_info_w%solpts_loc(n,1) - zstart(1) + 1 j = solid_info_w%solpts_loc(n,2) - zstart(2) + 1 k = solid_info_w%solpts_loc(n,3) - zstart(3) + 1 IIw(i,j,k) = 0 end do do n = 1,solid_info_c%nsolptsrank !n = solid_info_c%solptsrank(m) i = solid_info_c%solpts_loc(n,1) - zstart(1) + 1 j = solid_info_c%solpts_loc(n,2) - zstart(2) + 1 k = solid_info_c%solpts_loc(n,3) - zstart(3) + 1 IIc(i,j,k) = 0 end do IIw(:, :, kb) = 0; IIuw(:, :, kb) = 0; IIvw(:, :, kb) = 0 do i=ib,ie do j=jb,je IIuv(i,j,kb) = IIu(i,j,kb) * IIu(i,j-1,kb) * IIv(i,j,kb) * IIv(i-1,j,kb) do k=kb+1,ke ! Classed as solid (set to zero) unless ALL points in the stencil are fluid IIuv(i,j,k) = IIu(i,j,k) * IIu(i,j-1,k) * IIv(i,j,k) * IIv(i-1,j,k) IIuw(i,j,k) = IIu(i,j,k) * IIu(i,j,k-1) * IIw(i,j,k) * IIw(i-1,j,k) IIvw(i,j,k) = IIv(i,j,k) * IIv(i,j,k-1) * IIw(i,j,k) * IIw(i,j-1,k) end do end do end do ! Can't do this because no interface for integers ! call exchange_halo_z(IIuv, opt_zlevel=(/ihc,jhc,0/)) ! call exchange_halo_z(IIuv, opt_zlevel=(/ihc,jhc,0/)) ! call exchange_halo_z(IIvw, opt_zlevel=(/ihc,jhc,0/)) do k = kb, ke + khc IIcl(k) = sum(IIc(ib:ie, jb:je, k)) IIul(k) = sum(IIu(ib:ie, jb:je, k)) IIvl(k) = sum(IIv(ib:ie, jb:je, k)) IIwl(k) = sum(IIw(ib:ie, jb:je, k)) IIuwl(k) = sum(IIuw(ib:ie, jb:je, k)) IIvwl(k) = sum(IIvw(ib:ie, jb:je, k)) IIuvl(k) = sum(IIuv(ib:ie, jb:je, k)) enddo call MPI_ALLREDUCE(IIcl, IIcs, ke + khc - kb + 1, MPI_INTEGER, & MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIul, IIus, ke + khc - kb + 1, MPI_INTEGER, & MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIvl, IIvs, ke + khc - kb + 1, MPI_INTEGER, & MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIwl, IIws, ke + khc - kb + 1, MPI_INTEGER, & MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIuwl, IIuws, ke + khc - kb + 1, MPI_INTEGER, & MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIvwl, IIvws, ke + khc - kb + 1, MPI_INTEGER, & MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIuvl, IIuvs, ke + khc - kb + 1, MPI_INTEGER, & MPI_SUM, comm3d, mpierr) IIcd(ib:ie, kb:ke) = sum(IIc(ib:ie, jb:je, kb:ke), DIM=2) IIwd(ib:ie, kb:ke) = sum(IIw(ib:ie, jb:je, kb:ke), DIM=2) IIuwd(ib:ie, kb:ke) = sum(IIuw(ib:ie, jb:je, kb:ke), DIM=2) IIud(ib:ie, kb:ke) = sum(IIu(ib:ie, jb:je, kb:ke), DIM=2) IIvd(ib:ie, kb:ke) = sum(IIv(ib:ie, jb:je, kb:ke), DIM=2) call MPI_ALLREDUCE(IIwd(ib:ie, kb:ke), IIwt(ib:ie, kb:ke), (ke - kb + 1)*(ie - ib + 1), MPI_INTEGER, MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIcd(ib:ie, kb:ke), IIct(ib:ie, kb:ke), (ke - kb + 1)*(ie - ib + 1), MPI_INTEGER, MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIuwd(ib:ie, kb:ke), IIuwt(ib:ie, kb:ke), (ke - kb + 1)*(ie - ib + 1), MPI_INTEGER, MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIud(ib:ie, kb:ke), IIut(ib:ie, kb:ke), (ke - kb + 1)*(ie - ib + 1), MPI_INTEGER, MPI_SUM, comm3d, mpierr) call MPI_ALLREDUCE(IIvd(ib:ie, kb:ke), IIvt(ib:ie, kb:ke), (ke - kb + 1)*(ie - ib + 1), MPI_INTEGER, MPI_SUM, comm3d, mpierr) end subroutine createmasks