title: How to use lock array indices using OpenMP?
body: <p>I'm doing an n body simulation and I've an array which stores the acceleration of particles. Now I'm trying to parallelize my code and I've met with this problem, since the array is of type real,  I'm not able to lock it. Because the <code>init_lock</code> subroutine in OpenMP, the argument must be an integer.</p>
  
  <p>Is there a way around? I used the critical construct but it has no effect on the time of computation. Here I tried locking the array indices, but it is not working either.</p>
  
  <pre><code>    call omp_init_lock(i,j)
  
      !$omp parallel 
      !$omp do private(rx,ry,rz,rsqd,r2i,r6i,virij,ff,i,j) schedule(dynamic)
      do i=1,m-1
          do j=i+1,m
              rsqd = 0.0
                  rx = x(i,1) - x(j,1)
                  ry = x(i,2) - x(j,2)
                  rz = x(i,3) - x(j,3)                                    
                  rsqd = rsqd + rx*rx +ry*ry + rz*rz
                  !calculation of another variable ff
                  ! $omp critical
                  call omp_set_lock(i)
                      a(i,1) = a(i,1) + rx*ff
                      a(i,2) = a(i,2) + ry*ff
                      a(i,3) = a(i,3) + rz*ff
                  call omp_unset_lock(i)
                  call omp_set_lock(j)                                    
                      a(j,1) = a(j,1) - rx*ff
                      a(j,2) = a(j,2) - ry*ff
                      a(j,3) = a(j,3) - rz*ff 
                  call omp_unset_lock(j)  
                  ! $omp end critical         
          end do
      end do
  </code></pre>