title: Safely parallelizing a for loop containing fnctions of vectors
body: <p>In one part of my code, I have a slow for loop which I wish to paralleling. However, I'm not very experienced with using openmp and I afraid if there is any mistake in the way I have paralleled the loop. Could any experted guy tell me if there could be any mistake in this part of my code? Any help is HIGHLY appreciated.</p>
  
  <pre><code>#pragma omp parallel for num_threads(5)
  for(int i = 0; i &lt; N; i++)
              {
              double sum_sin = 0.0, sum_cos = 0.0;
  
              for (vector&lt;int&gt;::iterator it = box_neighbors[bx[i]].begin(); it != box_neighbors[bx[i]].end(); ++it)
                  {
                  for (vector&lt;int&gt;::iterator itp = box_particles[*it].begin(); itp != box_particles[*it].end(); ++itp)
                       {
                       if(dist(x[i], y[i], x[*itp], y[*itp], L) &lt; R0_two)
                          {
                          sum_sin+= sin(theta[*itp]);
                          sum_cos+= cos(theta[*itp]);  
                          }
                       }
                  }
              theta_new[i] = atan(sum_sin/sum_cos);
              if (sum_cos &lt; 0 &amp;&amp; sum_sin &lt; 0) //theta should be in (-pi,pi)
                  {
                  theta_new[i]-= pi;
                  }
              else if (sum_cos &lt; 0 &amp;&amp; sum_sin &gt; 0)
                  {
                  theta_new[i] = pi + theta_new[i];
                  }
              }
  </code></pre>