这是有罪的代码(它与我问的另一个问题有关,这里):
program foo
use mpi
implicit none
type double_st
sequence
real(kind(0.d0)) :: x,y,z
integer :: acc
end type double_st
integer, parameter :: n=8
INTEGER :: MPI_CADNA_DST
integer :: nproc, iprank
INTEGER :: IERR, STAT(MPI_STATUS_SIZE)
INTEGER :: MPI_CADNA_DST_TMP
INTEGER ::&
COUNT=4,&
BLOCKLENGTHS(4)=(/1,1,1,1/),&
TYPES(4)=(/MPI_DOUBLE_PRECISION,&
MPI_DOUBLE_PRECISION,&
MPI_DOUBLE_PRECISION,&
MPI_INTEGER/)
INTEGER(KIND=MPI_ADDRESS_KIND) :: DISPLS(4), LB, EXTENT
TYPE(DOUBLE_ST) :: DST
INTEGER :: I
type(double_st), allocatable :: bufs(:), bufr(:)
allocate(bufs(n), bufr(n))
CALL MPI_INIT(IERR)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, NPROC, IERR)
CALL MPI_COMM_RANK(MPI_COMM_WORLD, IPRANK, IERR)
CALL MPI_GET_ADDRESS(DST%X, DISPLS(1))
CALL MPI_GET_ADDRESS(DST%Y, DISPLS(2))
CALL MPI_GET_ADDRESS(DST%Z, DISPLS(3))
CALL MPI_GET_ADDRESS(DST%ACC, DISPLS(4))
DO I=4,1,-1
DISPLS(I)=DISPLS(I)-DISPLS(1)
ENDDO
CALL MPI_TYPE_CREATE_STRUCT(4,BLOCKLENGTHS,DISPLS,TYPES, MPI_CADNA_DST_TMP,IERR)
CALL MPI_TYPE_COMMIT(MPI_CADNA_DST_TMP,IERR)
CALL MPI_TYPE_GET_EXTENT(MPI_CADNA_DST_TMP, LB, EXTENT, IERR)
CALL MPI_TYPE_CREATE_RESIZED(MPI_CADNA_DST_TMP, LB, EXTENT, MPI_CADNA_DST, IERR)
CALL MPI_TYPE_COMMIT(MPI_CADNA_DST,IERR)
bufs(:)%x=iprank
bufs(:)%y=iprank
bufs(:)%z=iprank
bufs(:)%acc=iprank
call mpi_send(bufs(1), n, mpi_cadna_dst, 1-iprank, 0, mpi_comm_world, ierr)
call mpi_recv(bufr(1), n, mpi_cadna_dst, 1-iprank, 0, mpi_comm_world, stat, ierr)
deallocate(bufs, bufr)
end program foo
使用 intelMPI 版本 4.0 或 5.0 编译时,我在发送时使用 valgrind 或 dmalloc 收到无效的读/写错误。使用openMPI,这个最小示例还不是很清楚,但是我在从中提取它的大代码中遇到了类似的通信问题。
感谢您的帮助!