title: MPI for loop in c
body: <p>I need to loop through a bi-dimensional array executing an operation on all the elements of the array, for some number of iterations.  Here is my code:</p>
  
  <pre><code>for (for_iters=0;for_iters&lt;ITERS;for_iters++) 
     { 
       diff = 0.0;
  
       for (i=1;i&lt;n;i++)
       {
         for (j=1;j&lt;n;j++)
         {
           tmp = A[i][j];
           A[i][j] = 0.3*(A[I][j] + A[i][j-1] + A[i-1][j] + A[i][j+1] + A[i+1][j]);
         }
  
       }
       iters++;
  
      } /*for*/
  }
  </code></pre>
  
  <p>The problem is to translate the above code to MPI. I think I could divide the elements of the array to make every process deal with a part of the array, but I have no idea how to make the outer loop if every line of the code its executed once per process? if I have 3 processes, would I create 3 external loops??</p>