[flang-commits] [flang] [Flang] Make a private copy for the common block variables in copyin clause (PR #111359)
Thirumalai Shaktivel via flang-commits
flang-commits at lists.llvm.org
Thu Mar 27 04:55:19 PDT 2025
Thirumalai-Shaktivel wrote:
I have updated the branch.
I'm getting the following output:
```console
$ ./a.out
sub : b( 1 ) = 1. a( 1 ) = 1.
sub : b( 2 ) = 3. a( 2 ) = 2.
OK
```
, for the following example:
```fortran
program main
integer err
real,dimension(2):: a, b, c
common /blk/ a, b
!$omp threadprivate(/blk/)
a = (/(i,i=1,2)/)
b = (/(i*(i+1)/2,i=1,2)/)
c = 0
!$omp parallel do private(sum), copyin(/blk/)
do i=1, 2
sum = i
call sub(sum, i, c(i))
end do
!$omp end parallel do
err = 0
do i=1, 2
if(c(i) .ne. b(i)) err = err+1
end do
if(err .ne. 0) then
write(6,*) "NG"
else
write(6,*) "OK"
end if
end program main
subroutine sub(sum, i, c)
real,dimension(2):: a, b
common /blk/ a, b
real c
!$omp threadprivate(/blk/)
c = b(i)-a(i)+sum
write(6,*) "sub : b(",i,") = ",b(i), " a(",i,") = ", a(i)
end subroutine sub
```
https://github.com/llvm/llvm-project/pull/111359
More information about the flang-commits
mailing list