|
[Fortran] 纯文本查看 复制代码 program main
use mpi
implicit none
integer::ierr,myid,nprocs
integer::msize=6, bsize
real(8)::buffer(6),b(6)
real(8),allocatable::tmbuff(:)
integer, parameter :: MAX_BUFFER_SIZE = 1024
call MPI_init(ierr)
call MPI_comm_size(MPI_comm_world,nprocs,ierr)
call MPI_comm_rank(MPI_comm_world,myid,ierr)
if(myid==0)then
buffer(1:6)=(/1.0,2.0,3.0,4.0,5.0,6.0/)
allocate(tmbuff(MAX_BUFFER_SIZE))
call MPI_Buffer_attach(tmbuff, size(tmbuff)*8, ierr)
call MPI_bsend(buffer,msize-1,MPI_double_precision,1,2000,MPI_comm_world,ierr)
call MPI_bsend(buffer,1, MPI_double_precision,1,2001,MPI_comm_world,ierr)
call MPI_buffer_detach(tmbuff, size(tmbuff)*8, ierr)
else if (myid==1) then
call MPI_recv(b,msize-1,MPI_double_precision,0,2000,MPI_comm_world,ierr)
print *,'b1 = ',b
call MPI_recv(b,1, MPI_double_precision,0,2001,MPI_comm_world,ierr)
print *,'b2 = ',b
end if
call MPI_finalize(ierr)
end program
请问这段代码的这一部分如何修改正确?
[Fortran] 纯文本查看 复制代码 allocate(tmbuff(MAX_BUFFER_SIZE))
call MPI_Buffer_attach(tmbuff, size(tmbuff)*8, ierr)
call MPI_bsend(buffer,msize-1,MPI_double_precision,1,2000,MPI_comm_world,ierr)
call MPI_bsend(buffer,1, MPI_double_precision,1,2001,MPI_comm_world,ierr)
运行时候有错误
|
|