title: Private Array that goes through recursion for each gang in openacc
body: <p>How to properly make an array private in openacc? for my use, i have declared an array that goes through a recursion function and updates itself. In C++ I did it this way,</p>
  
  <pre><code>int recursion(int array[],int i)
  {
     ....
     return array[i] = recursion(array,i);
  }
  int main()
  {
    ....
     for(int run=0;run&lt;N;++run)
     { 
      .... 
        for(int i=0;i&lt;some N;++i)
        int f = recursion(array,i);
     }
   .....
  }
  </code></pre>
  
  <p>Now the main problem begins when i try to do this in parallel using openacc directives. I want to copy this array into the parallel for loop region in such a way that each gang is going to have a copy of this array and will be able to change their own version of array[] and not the others using the recursion function. The way i tried doing this is </p>
  
  <pre><code>#pragma acc routine seq
  int recursion(int array[],int i)
  {
   ....
   return array[i] = recursion(array,i);
  }
  int main()
  {
   ....
   #pragma acc data copyin(array[0:N])
   #pragma acc parallel loop gang private(array[0:N])
  
   for(int run=0;run&lt;N;++run)
   {  
    ....
      for(int i=0;i&lt;N;++i)
      { 
       ....
       int f = recursion(array,i);
      }
    }
   }
  </code></pre>
  
  <p>But it seems that the array is not getting passed to the recursion function as i have checked that it does not change. What is the perfect way to do this?</p>
  
  <p>p.s. I also have tried <code>#pragma acc data pcreate(array[0:N])</code> with <code>#pragma acc parallel loop independent private(array[0:N])</code> but the result is the same</p>
  
  <p>you can find the whole code <a href="https://pastebin.com/mv3G0UeV" rel="nofollow noreferrer">here</a>. It works perfectly without the directives. only thing you need to change is comment the line with curand and un-comment the line with rand at 251 268 line. Please Help!</p>