“mpi_scatter”没有特定的子例程

No specific subroutine for ‘mpi_scatter’

我从 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

我做错了什么?

如评论中所述,您需要额外指定接收缓冲区的 MPI_Datatype

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