且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

mpi 改变了它不应该改变的变量

更新时间:2022-06-20 06:19:52

最可能的原因是您将 INTEGER 标量作为实际的 status 参数传递给 MPI_RECV 当它应该真正声明为具有特定于实现大小的数组时,可作为 MPI_STATUS_SIZE 常量使用:

The most probable cause is that you pass an INTEGER scalar as the actual status argument to MPI_RECV when it should be really declared as an array with an implementation-specific size, available as the MPI_STATUS_SIZE constant:

INTEGER, DIMENSION(MPI_STATUS_SIZE) :: status

INTEGER status(MPI_STATUS_SIZE)

消息标签由接收操作写入状态字段之一(其特定于实现的索引可作为 MPI_TAG 常量使用,并且字段值可以作为 status(MPI_TAG)) 并且如果您的 status 只是一个标量 INTEGER,那么其他几个局部变量将被覆盖.在您的情况下,它只是发生在 nstartg 刚好落在堆栈中的 status 之上.

The message tag is written to one of the status fields by the receive operation (its implementation-specific index is available as the MPI_TAG constant and the field value can be accessed as status(MPI_TAG)) and if your status is simply a scalar INTEGER, then several other local variables would get overwritten. In your case it simply happens so that nstartg falls just above status in the stack.

如果你不关心接收状态,你可以通过特殊常量MPI_STATUS_IGNORE代替.

If you do not care about the receive status, you can pass the special constant MPI_STATUS_IGNORE instead.