fortran - MPI_Cart_创建错误

标签 fortran mpi openmpi

我在 Fortran 中使用基本的 mpi_cart_create() 函数时遇到了问题。

以下代码

  program main
  USE mpi
  implicit none
  integer :: old_comm, new_comm, ndims, ierr
  integer, DIMENSION(1) :: dim_size
  logical ::  reorder
  logical, DIMENSION(1) :: periods

  call MPI_INIT(ierr)
  old_comm = MPI_COMM_WORLD
  ndims = 1            
  dim_size(1) = 4   
  periods(1) = .true.  
  reorder = .true.
  call MPI_CART_CREATE(old_comm, ndims, dim_size, periods, reorder, new_comm, ierr)
  call MPI_Finalize(ierr)

  end program

编译

mpif90 mpitest.f90

运行时的产量,

An error occurred in MPI_Cart_create

on communicator MPI_COMM_WORLD

MPI_ERR_OTHER: known error not in list

MPI_ERRORS_ARE_FATAL: your MPI job will now abort

这看起来很简单,但是有人认识到这个问题吗?

编辑:我更新了代码(之前我有点仓促地削减了代码,感谢您指出这些)以纠正下面提到的问题。我想我可能搞砸了 MPI 安装,因为代码将在使用

编译时运行
 (when using `use mpi`)
 mpif90 mpitest3.f90
 mpirun  -np 4  ./a.out

或者

 (when using `include "mpif.h"`)
 mpifort mpitest.f90 
 orterun  -np 4  ./a.out

如果我尝试使用 mpifort 和 use mpi 进行编译我得到的声明

PI_CART_CREATE(old_comm, ndims, dim_size, periods, reorder, new_comm, ierr)

Error: There is no specific subroutine for the generic 'mpi_cart_create' at (1)

如果我混合编译器和运行调用(例如使用 mpif90 编译并使用 orterun 运行),我会得到

Fatal error in PMPI_Cart_create: Invalid argument, error stack: PMPI_Cart_create(315).....: MPI_Cart_create(MPI_COMM_WORLD, ndims=1, dims=0x7fff26671130, periods=0x1c6e300, reorder=1, comm_cart=0x7fff26671124) failed MPIR_Cart_create_impl(191): MPIR_Cart_create(55)......: Size of the communicator (1) is smaller than the size of the Cartesian topology (4)

尽管 openmpi 的文档规定命令(至少 orterun 和 mpirun)应该是同义的。

最佳答案

您的问题是您同时安装了 Open MPI 和 MPICH(或其他基于 MPICH 的实现)。 mpifort 是 Open MPI 中的通用 Fortran 编译器包装器,它似乎从 MPICH 中选取模块文件,因此在使用 use mpi 编译代码时出现错误。您的 mpirun 肯定来自 MPICH,它无法正确启动 Open MPI 可执行文件。来自 Open MPI 的 orterun 也是如此,它无法正确启动 MPICH 可执行文件。在这两种情况下,可执行文件都会变成单例,并且每个进程都有自己的大小为 1 的 MPI_COMM_WORLD,因此不可能创建具有 4 阶的笛卡尔虚拟拓扑。

解决方案是首先从系统中清除所有 MPI 实现,然后安装来自同一实现的运行时和开发包,例如打开 MPI。

关于fortran - MPI_Cart_创建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28205679/

相关文章:

file-io - 无需提前阅读免费格式

compilation - Fortran 错误 : type mismatch between two unrelated subroutine calls

MPI_Gather 可以用于从使用 MPI_Send 的线程接收数据吗?

c++ - 串行代码的并行 MPI 实现

c - 最大消息长度 MPI_Type_vector 和 MPI_Gather

mpi - MPI_Publish_name 可以用于两个单独启动的应用程序吗?

c++ - 从 Fortran 中读取 C++ 'Hello World'

Fortran findloc 内在

c - C 中未定义的 struct timeval 声明

multithreading - 消息传递任意对象图?