【发布时间】:2014-05-05 02:33:23
【问题描述】:
我在 fortran 中使用 MPI 来计算我的数据。我通过打印数据来验证,每个进程都在对所需范围执行计算,但是,master 无法整理数据。
这是我试图使其工作的代码: 编辑:为发送和接收创建了一个恒定的标签
integer :: tag
tag = 123
if(pid.ne.0) then
print *,'pid: ',pid,'sending'
DO j = start_index+1, end_index
CALL MPI_SEND(datapacket(j),1, MPI_REAL,0, tag, MPI_COMM_WORLD)
!print *,'sending'
END DO
print *,'send complete'
else
DO slave_id = 1, npe-1
rec_start_index = slave_id*population_size+1
rec_end_index = (slave_id + 1) * population_size;
IF (slave_id == npe-1) THEN
rec_end_index = total-1;
ENDIF
print *,'received 1',rec_start_index,rec_end_index
CALL MPI_RECV(datapacket(j),1,MPI_REAL,slave_id,tag,MPI_COMM_WORLD, &
& status)
!print *,'received 2',rec_start_index,rec_end_index
END DO
它从不打印received 或MPI_RECV 调用之后的任何内容,但是,我可以看到发送进行得很好但是,除了依赖打印语句之外,我无法验证它。
变量databpacket初始化如下:
real, dimension (:), allocatable :: datapacket
我在这里做错了什么吗?
编辑:对于测试设置,所有进程都在本地主机上运行。
【问题讨论】: