“mpi_scatter”没有特定的子程序

时间:2016-03-31 20:01:25

标签: fortran mpi gfortran

我从Fortran的MPI开始,尝试从数组中进行分散。这是代码:

program test_scatter
  use mpi
  implicit none
  integer                      :: ierr, rank, size, comm, i, j
  integer, parameter           :: dim = 5, dim_nodos = 4
  real, dimension(dim, dim)    :: panel_pos
  real, dimension(dim_nodos)   :: nodos
  real                         :: rev_buf

  forall(i = 1:dim_nodos) nodos(i) = i
  comm = MPI_COMM_WORLD
  call MPI_INIT(ierr)
  call MPI_COMM_SIZE(comm, size, ierr)
  call MPI_COMM_RANK(comm, rank, ierr)

  call MPI_Bcast(panel_pos, dim*dim, MPI_REAL, 1, comm, ierr)
  call MPI_Scatter(nodos, 1, MPI_REAL, rev_buf, 1, 1, comm, ierr)
  print *, panel_pos, 'from rank', rank

  ! Finalizar MPI
  call MPI_FINALIZE(ierr)
end program test_scatter

我尝试使用:

进行编译
mpif90 test_scatter.F90 -o test_scatter.e

但是我收到了这个错误:

call MPI_Scatter(nodos, 1, MPI_REAL, rev_buf, 1, 1, comm, ierr)
                                                              1 
Error: There is no specific subroutine for the generic ‘mpi_scatter’ at (1)

我有Debian测试。该系统是最新的。我安装OpenMPI如:

$ sudo apt-get install openmpi-bin openmpi-common openmpi-doc libopenmpi-dev

我做错了什么?

1 个答案:

答案 0 :(得分:0)

如注释中所述,您还需要另外指定接收缓冲区的MPI_Datatype

call MPI_Scatter(nodos, 1, MPI_REAL, rev_buf, 1, MPI_REAL, 1, comm, ierr)