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

            Bug ID: 121360
           Summary: Use of preliminary coarray with locks gives unexpected
                    results
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jvdelisle at gcc dot gnu.org
  Target Milestone: ---

Using the preliminary coarray implementation from devel/gfortran-test, the
following test case gives unexpected results.

program memain
   use, intrinsic :: iso_fortran_env, only : lock_type
   type(lock_type), codimension[*] :: lck
   integer, codimension[*] :: count
   integer :: i, j, s
   do j=0,5  ! To be adjusted, dunno how long this runs
     if (this_image() == 1) count = 0
     sync all
     do i=1,10**j
        lock (lck[1])
        count[1] = count[1] + 1
        unlock (lck[1])
     end do
     sync all
     if (this_image() == 1) then
        print *,"Expected: ",10**j*num_images(), "Found: ", count
     end if
     sync all
   end do
end program

On x86_64_linux_gnu I get the following:

$ echo $LD_LIBRARY_PATH
/home/jerry/dev/usrtest/lib64/:/home/jerry/dev/usrtest/lib/
$ echo $GFORTRAN_NUM_IMAGES
8
$ echo $FC
/home/jerry/dev/usrtest/bin/gfortran
$ $FC -fcoarray=lib locks.f90 -lcaf_shmem
$ ./a.out 
 Expected:            8 Found:            1
 Expected:           80 Found:            1
 Expected:          800 Found:            1
 Expected:         8000 Found:            1
 Expected:        80000 Found:            1
 Expected:       800000 Found:            1

Reply via email to