Skip to content

RFE: support nested allocatable derived-type array components inside derived-type coarrays #700

Closed
@rouson

Description

@rouson

The transcript below demonstrates the runtime error message that the OpenCoarrays function libcaf_mpi::caf_get_by_ref() produces in a simple scenario wherein a derived-type coarray has an allocatable, derived-type array component. A cumbersome workaround is to flatten such coarray data structures so that the components of derived type coarrays are intrinsic types. Even with this workaround, a source allocation will fail. A workaround for the lack of source allocation is to use mold allocation followed by element-by-element copying of the component array.

The following are the results of compiling the code below with the gfortran versions cited in bold:

  • 8.3.0: the final allocation generates the runtime error message below.
  • 9.2.0: the allocation completes without error but the subsequent component access generates a segmentation fault - invalid memory reference.
  • 10.0.0: same as 8.3.0.
$ cat opencoarrays-missing-feature.f90 
  implicit none

  type package
    integer, allocatable :: surface_fluxes(:)
  end type

  type outbox
    type(package), allocatable :: block_surfaces(:)
  end type

  type(outbox), save :: halo[*]

  integer, parameter :: source_image = 1
  integer, parameter :: message(1)=[99]

  if (this_image() == source_image) then
    allocate(halo%block_surfaces(1))
    allocate(halo%block_surfaces(1)%surface_fluxes, source = message)
  end if

  sync all

  if (this_image() /= source_image) then
    allocate(halo%block_surfaces(1))
    allocate(halo%block_surfaces(1)%surface_fluxes, mold = halo[source_image]%block_surfaces(1)%surface_fluxes)
    halo%block_surfaces(1)%surface_fluxes(1) = halo[source_image]%block_surfaces(1)%surface_fluxes(1)
  end if

end
$ caf opencoarrays-missing-feature.f90 

$ cafrun -n 2 ./a.out
Fortran runtime error on image 2: libcaf_mpi::caf_get_by_ref(): two or more array part references are not supported.

Error: Command:
   `/usr/local/Cellar/mpich-3.2-gnu-8.3.0/bin/mpiexec -n 2 ./a.out`
failed to run.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions