title: Different behaviour between scalar and parallel code
body: <p>I'm wondering why the following code produces different results in its scalar and parallel variants:</p>
  
  <pre><code>#define N 10
  double P[N][N];
  // zero the matrix just to be sure...
  for (int i=0; i&lt;N; i++)
      for(int j=0; j&lt;N; j++)
          P[i][j]=0.0;
  
  
  double xmin=-5.0,ymin=-5.0,xmax=5.0,ymax=5.0;
  double x=xmin,y=ymin;
  double step= abs(xmax-xmin)/(double)(N - 1 );
  for (int i=0; i&lt;N; i++)
  {
      #pragma omp parallel for ordered schedule(dynamic)
      for ( int j=0; j&lt;N; j++)
      {
          x = i*step+xmin;
          y = j*step+ymin;
          P[i][j]=x+y;
      }
  }
  </code></pre>
  
  <p>This code produces not completely equal results in its two version (the scalar version has just the <code>#pragma ...</code> part commented out).
  What I've noticed is that a very small percentual of the elements of <code>P[i][j]</code> in the parallel version are different from those of the scalar version, but I'm wondering why... </p>
  
  <p>Putting the <code>#pragma</code> on the outer loop as suggested is mess...completely wrong results.</p>
  
  <p>P.S.
  g++-4.4, intel i7, linux</p>