Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parallel processing MPI程序浮点异常Fortran_Parallel Processing_Fortran_Mpi - Fatal编程技术网

Parallel processing MPI程序浮点异常Fortran

Parallel processing MPI程序浮点异常Fortran,parallel-processing,fortran,mpi,Parallel Processing,Fortran,Mpi,我需要编写一个程序,将特定列发送到另一个进程。 我尝试了一个包含两个进程的简单算法,但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

我需要编写一个程序,将特定列发送到另一个进程。 我尝试了一个包含两个进程的简单算法,但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

我没有立即看到您报告的错误的来源,但我看到了MPI程序中经常出现的错误来源。将包含“mpif.h”的
替换为
使用mpi
,并相应地调整编译过程。通过使用该模块,编译器可以在编译时检查提供给
mpi
例程的参数在种类、类型和维度上是否正确。问题涉及
status
。事实上,-status是一个数组,使用mpi可能会发现这一点。Include'mpif.h'是20世纪90年代的产物,不应该使用today@IanBush不幸的是,官方OpenMPI文档甚至在2018年的示例中也将此作为默认值显示。但是无论如何,我自己也被这个错误击中了,即使我确实使用了mpi模块。不仅是在2012年,甚至是最近的mor。@High Performance Mark非常感谢,使用mpi解决了这个问题。我没有立即看到您报告的错误的来源,但我在mpi程序中看到了一些通常是错误来源的东西。将包含“mpif.h”的
替换为
使用mpi
,并相应地调整编译过程。通过使用该模块,编译器可以在编译时检查提供给
mpi
例程的参数在种类、类型和维度上是否正确。问题涉及
status
。事实上,-status是一个数组,使用mpi可能会发现这一点。Include'mpif.h'是20世纪90年代的产物,不应该使用today@IanBush不幸的是,官方OpenMPI文档甚至在2018年的示例中也将此作为默认值显示。但是无论如何,我自己也被这个错误击中了,即使我确实使用了mpi模块。不仅是在2012年,甚至是最近的mor。@High Performance Mark非常感谢,使用mpi解决了这个问题