通过增加邮件大小

时间:2016-10-15 20:41:50

标签: fortran mpi

我遇到消息传递问题:通过增加以下程序中的n,它会挂起。该程序应该使用2个进程运行。任何意见表示赞赏。

  program test
  !
  implicit none
  !
  include 'mpif.h'
  !
  integer :: i, n, ierr, istat, rank, size
  integer, allocatable, dimension(:) :: a, b
  integer :: status(MPI_STATUS_SIZE), request
  !
  call MPI_INIT(ierr)
  call MPI_COMM_RANK( MPI_COMM_WORLD, rank, ierr ) 
  call MPI_COMM_SIZE( MPI_COMM_WORLD, size, ierr )  
  !
  n = 16364
  allocate(a(n), stat = istat)
  allocate(b(n), stat = istat)
  do i = 1, n
    a(i) = i
    b(i) = 0
  enddo
  !
  if (rank.eq.0) call MPI_ISEND(a, n, MPI_INTEGER4, 1, 0, MPI_COMM_WORLD, request, ierr)
  if (rank.eq.1) call MPI_IRECV(b, n, MPI_INTEGER4, 0, 0, MPI_COMM_WORLD, request, ierr)
  call MPI_WAIT(request, status, ierr)
  !
  if (rank.eq.1) then
    do i = 1, n
      if (b(i).ne.i) print*, 'error: ', i, b(i)
    enddo
  endif
  !
  deallocate(a, stat = istat)
  deallocate(b, stat = istat)
  call MPI_FINALIZE(ierr)
  !
endprogram test

0 个答案:

没有答案