我需要编写一个程序,该程序将特定的列发送到另一个进程。 我尝试了一个具有两个进程的简单算法,但是mpi在send或recv中给了我浮点异常(无法确定位置)。为什么会发生?
program main
implicit none
include 'mpif.h'
integer :: myid, nprocs, isend,ierr,i,nx, j, status
INTEGER ,dimension(:,:), allocatable:: u
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierr)
nx = 1
if (myid .eq. 0) then
allocate(u(0:nx,myid*2/nprocs:(myid+1)*2/nprocs))
else
allocate(u(0:nx,myid*2/nprocs-1:(myid+1)*2/nprocs-1))
end if
u(:,:)=myid+1
call MPI_BARRIER(MPI_COMM_WORLD,ierr )
if (myid .eq. 0) then
isend = nx+1
CALL MPI_SEND(u(:,int((myid+1)*2/nprocs-1)),isend,MPI_INT ,myid+1,1,MPI_COMM_WORLD,ierr)
CALL MPI_RECV(u(:,int((myid+1)*2/nprocs)),isend,MPI_INT ,myid+1,1,MPI_COMM_WORLD,status,ierr)
else
isend = nx+1
CALL MPI_RECV(u(:,int((myid)*2/nprocs-1)),isend,MPI_INT ,myid-1,1,MPI_COMM_WORLD,status,ierr)
CALL MPI_SEND(u(:,int((myid)*2/nprocs)),isend,MPI_INT ,myid-1,1,MPI_COMM_WORLD,ierr)
END IF
call MPI_BARRIER(MPI_COMM_WORLD,ierr )
call MPI_FINALIZE(ierr)
end
错误:
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.
unable to read the cmd header on the pmi context, Error = -1