sendrecv.f90 Source File


This file depends on

sourcefile~~sendrecv.f90~2~~EfferentGraph sourcefile~sendrecv.f90~2 sendrecv.f90 sourcefile~common.f90~3 common.f90 sourcefile~sendrecv.f90~2->sourcefile~common.f90~3 sourcefile~logger.f90 logger.f90 sourcefile~sendrecv.f90~2->sourcefile~logger.f90 sourcefile~common.f90~3->sourcefile~logger.f90

Files dependent on this one

sourcefile~~sendrecv.f90~2~~AfferentGraph sourcefile~sendrecv.f90~2 sendrecv.f90 sourcefile~backend.f90 backend.f90 sourcefile~backend.f90->sourcefile~sendrecv.f90~2 sourcefile~exec_dist.f90~3 exec_dist.f90 sourcefile~backend.f90->sourcefile~exec_dist.f90~3 sourcefile~exec_dist.f90~3->sourcefile~sendrecv.f90~2 sourcefile~setup.f90 setup.f90 sourcefile~setup.f90->sourcefile~backend.f90 sourcefile~build.f90 build.f90 sourcefile~build.f90->sourcefile~setup.f90 sourcefile~poisson_solver.f90 poisson_solver.f90 sourcefile~poisson_solver.f90->sourcefile~setup.f90 sourcefile~xcompact.f90 xcompact.f90 sourcefile~xcompact.f90->sourcefile~setup.f90 sourcefile~memcheck.f90 memcheck.f90 sourcefile~memcheck.f90->sourcefile~build.f90

Source Code

module m_omp_sendrecv
  use m_mpi, only: MPI_COMM_WORLD, MPI_STATUSES_IGNORE, MPI_Irecv, MPI_Isend, &
                   MPI_Waitall

  use m_common, only: dp, MPI_X3D2_DP
  use m_logger, only: check_mpi

  implicit none

contains

  subroutine sendrecv_fields(f_recv_s, f_recv_e, f_send_s, f_send_e, &
                             n_data, nproc, prev, next)
    implicit none

    real(dp), dimension(:, :, :), intent(out) :: f_recv_s, f_recv_e
    real(dp), dimension(:, :, :), intent(in) :: f_send_s, f_send_e
    integer, intent(in) :: n_data, nproc, prev, next

    integer :: req(4), err(4), ierr, i, tag = 1234

    if (nproc == 1) then
      f_recv_s = f_send_e
      f_recv_e = f_send_s
    else
      call MPI_Isend(f_send_s, n_data, MPI_X3D2_DP, &
                     prev, tag, MPI_COMM_WORLD, req(1), err(1))
      call MPI_Irecv(f_recv_e, n_data, MPI_X3D2_DP, &
                     next, tag, MPI_COMM_WORLD, req(2), err(2))
      call MPI_Isend(f_send_e, n_data, MPI_X3D2_DP, &
                     next, tag, MPI_COMM_WORLD, req(3), err(3))
      call MPI_Irecv(f_recv_s, n_data, MPI_X3D2_DP, &
                     prev, tag, MPI_COMM_WORLD, req(4), err(4))

      do i = 1, 4
        call check_mpi(err(i), 'MPI_Isend/MPI_Irecv in sendrecv_fields')
      end do

      call MPI_Waitall(4, req, MPI_STATUSES_IGNORE, ierr)
      call check_mpi(ierr, 'MPI_Waitall in sendrecv_fields')
    end if

  end subroutine sendrecv_fields

end module m_omp_sendrecv