module test_communication_planes_m !! Test of module communication_planes_m use pfunit use MPI implicit none contains @test(npes = [4]) subroutine test_communication_planes(this) !! Tests communiacationa among planes with varying dimensions use precision_grillix_m, only : GP use helpers_m, only : almost_equal use communication_planes_m, only : start_comm_planes, & finalize_comm_planes class (MpiTestMethod), intent(inout) :: this integer :: comm_world, rank, nprocs, ierr logical :: fine integer :: i, k, shift, src integer, dimension(2) :: req integer :: ndim integer, dimension(:), allocatable :: ndim_halos real(GP), dimension(:), allocatable :: u, uh real(GP) :: rval comm_world = this%getMpiCommunicator() call MPI_comm_rank(comm_world, rank, ierr) call MPI_comm_size(comm_world, nprocs, ierr) if (rank == 0) then write(*,*)'' write(*,*)'' write(*,'(A80)')'test_communication_planes -------------------------------------------------' endif ! Create some dimensions ndim = 5 + rank*(-1)**rank allocate(ndim_halos(0:nprocs-1)) do k = 0, nprocs-1 ndim_halos(k) = 5 + k*(-1)**k enddo ! Creat some data allocate(u(ndim)) do i = 1, ndim u(i) = 1.0_GP*(10*rank + i) enddo ! Test communication with several planes do shift = -2*nprocs, 2*nprocs src = rank + shift src = modulo(src, nprocs) allocate(uh(ndim_halos(src))) call start_comm_planes(comm_world, ndim, ndim_halos(src), u, shift, uh, req) call finalize_comm_planes(req) do i = 1, ndim_halos(src) rval = 1.0_GP * (10 * src + i) fine = almost_equal(uh(i), rval, rtol = 0.0_GP, atol = 1.0E-10_GP) @assertTrue(fine) enddo deallocate(uh) enddo if (rank == 0) then write(*,'(A80)')'test_communication_planes complete ----------------------------------------' write(*,*)'' write(*,*)'' endif end subroutine end module