Hi,

I have a problem with an array inside a double loop. I want to update this array but i don’t know if it is possible to do this in parallel.

```
!$acc kernels reduction(+:k)
do j=1,N
do i= 1,M
!In the beginning SOME INDEPENDENT CALCULATIONS
!and now the part with the reduction variable and the array
k = k +1
array(1,k) = i
array(2,k) = j
enddo
enddo
```

After the 2D loop my array should look like

k = 4

array(1,1) = 2 | array(1,2) = 3 | array(1,3) = 5 | array(1,4) = 5

array(2,1) = 3 | array(2,2) = 4 | array(2,3) = 160 | array(2,4) = 300

The problem is that with openACC my results are like

k=4 (CORRECT RESULT)

array(1,1) = 5 | array(1,2) = 0 | array(1,3) = 0 | array(1,4) = 0

array(2,1) = 160 | array(2,2) = 0 | array(2,3) = 0 | array(2,4) = 0

I’m familiar with the reason of this behaviour but i want to know if there is a way to solve this.

In CUDA i solved this problem using ATOMIC operations.

Thank you,

Sotiris