title: MPI - Printing in an order
body: <p>I'm trying to write a function in C where every processor prints it's own data.
  Here is what i have:</p>
  
  <pre><code>void print_mesh(int p,int myid,int** U0,int X,int Y){
      int i,m,n;
      for(i=0;i&lt;p;i++){
          if(myid==i){
              printf("myid=%d\n",myid);
              for(n=0;n&lt;X;n++){
                  for(m=0;m&lt;Y;m++){
                      printf("%d ",U0[n][m]);
                  }
                  printf("\n");
              }
          }
          else MPI_Barrier(MPI_COMM_WORLD);
      }
  }
  </code></pre>
  
  <p>It doesn't work for some reason. The arrays are printed all mixed up.
  Do you have any insight as to why this doesn't work? Any other ideas that work?
  If possible, I don't want to send the whole array in a master process. Also I don't want to use precompiled functions.</p>