https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97589

--- Comment #22 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Hi Toon,

it took some time, but we finally figured out that it is actually
a bug in your program that is causing problems.

It has (shortened)

nxglobal = 72;

This sets the coarray nxglobal to 72 on every image, including image 2.

if (this_image() == 1) then
   read(*,config)

This optionally reads in nxglobal[1].

!     Why won't this work as nxglobal[:] = nx ?
   do i = 2, num_images()
      nxglobal[i] = nxglobal;

This sets nxglobal[2] on image 2 from image 1. This is a race
condition: It is not clear which store comes first.

To fix this, you would need a "sync all" before the
if (this_image() = 1) statement, or you could set the default
value on image 1 only.

(Incidentally, looking at this code led to finding a bug in
namelist handling, where the implied this_image() was not honored
(namelist I/O only worked on image 1), so the time looking at this
bug was not wasted :-)

By the way, there is also a segfault with GFORTRAN_NUM_IMAGES=64, which
will need to be investigated.

Reply via email to