首页 > 解决方案 > 使用 opencoarray 编译器的派生类型 coarray

问题描述

我在使用带有 opencoarrays 的派生类型的 coarray 时遇到了一些麻烦。我最小的工作示例是(“main.f90”):

module mod_parallel
 implicit none
 type :: array_type
   real, allocatable :: d(:)
 end type
 contains
 subroutine init_arr(arr)
  type(array_type), intent(inout) :: arr
  allocate(arr%d(5))
 end subroutine init_arr
end module mod_parallel

program main
   use mod_parallel
   implicit none
   type(array_type) :: array[*]
   call init_arr(array)
   array%d = 1.5*this_image()
   sync all
   if (this_image()==1) then
    if (num_images()>1) then
     array[1]%d(:) = array[2]%d(:)
    endif
   endif
end program main

我编译这个

caf main.f90 -o run

并运行

cafrun -n 2 ./run

并得到以下错误

*** An error occurred in MPI_Put
*** reported by process [3592486913,0]
*** on win rdma window 5
*** MPI_ERR_RMA_RANGE: invalid RMA address range
*** MPI_ERRORS_ARE_FATAL (processes in this win will now abort,
***    and potentially your MPI job)
Error: Command:
   `/usr/bin/mpiexec -n 2 ./run`
failed to run.

据我所知,我的代码没有违反 Coarray 的 Fortran 标准。如果我使用“cafrun -n 1 ./run”运行,我不会收到错误消息。我正在使用 Ubuntu (20) 和一台有四核的笔记本电脑。

编辑:我正在使用 OpenCoarrays 2.9.0 版、Debian OpenMPI、4.0.3 版和 gfortran 9.3.0 版

标签: fortranfortran-coarrays

解决方案


看起来问题与使用 OpenMPI 有关(特别是,我使用的是 Debian OpenMPI,版本 4.0.3)。我卸载了 OpenMPI(我使用的是 Ubuntu 20):

sudo apt purge openmpi-bin

并安装了 MPICH

sudo apt-get install mpich

然后我重新安装了opencoarrays。我现在发布的代码可以编译并运行,没有任何明显的问题。

我应该提到我安装了 MPICH 版本 3.3.2


推荐阅读