fortranfortran-coarrays

derived types coarrays with opencoarray compiler


I am having some trouble using coarrays of a derived type with opencoarrays. My minimal working example is ("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

I compile this with

caf main.f90 -o run

and run with

cafrun -n 2 ./run

and get the following error

*** 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.

As far as I can tell, my code does not violate the Fortran standards for coarrays. I do not get the error message if I run with "cafrun -n 1 ./run". I am using Ubuntu (20) and a laptop with four cores.

EDIT: I am using OpenCoarrays version 2.9.0, Debian OpenMPI, version 4.0.3, and gfortran version 9.3.0


Solution

  • It looks like the problem had to do with using OpenMPI (in particular, I was using Debian OpenMPI, version 4.0.3). I uninstalled OpenMPI (I am using Ubuntu 20):

    sudo apt purge openmpi-bin
    

    and installed MPICH

    sudo apt-get install mpich
    

    I then reinstalled opencoarrays. The code I posted now compiles and runs without any apparent problems.

    I should mention that I installed MPICH version 3.3.2