title: Sending 2D arrays in Fortran with MPI_Gather
body: <p>I want to send 2d chunks of data using <code>MPI_GATHER</code>. For example: I have 2x3 arrays on each node and I want 8x3 array on root, if I have 4 nodes. For 1d arrays, <code>MPI_GATHER</code> sorts data according to MPI ranks, but for 2d data it creates a mess!</p>
  
  <p>What is the clean way to put chunks in order?</p>
  
  <p>I expected the output of this code: </p>
  
  <pre><code>program testmpi
    use mpi
    implicit none
    integer :: send (2,3)
    integer :: rec (4,3)
    integer :: ierror,my_rank,i,j
  
    call MPI_Init(ierror)
    MPI_DATA_TYPE type_col
    ! find out process rank
    call MPI_Comm_rank(MPI_COMM_WORLD, my_rank, ierror)
    if (my_rank==0) then
      send=1
      do i=1,2
        print*,(send(i,j),j=1,3)
      enddo
    endif
    if (my_rank==1) then
      send=5
      ! do 1,2
      !   print*,(send(i,j),j=1,3)
      ! enddo
    endif
    call MPI_GATHER(send,6,MPI_INTEGER,rec,6,MPI_INTEGER,0,MPI_COMM_WORLD,ierror)
    if (my_rank==0) then
      print*,'&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;rec'
      do i=1,4
        print*,(rec(i,j),j=1,3)
      enddo
    endif
    call MPI_Finalize(ierror)
  end program testmpi
  </code></pre>
  
  <p>to be something like this : </p>
  
  <pre><code>   1           1           1
     1           1           1
     5           5           5
     5           5           5
  </code></pre>
  
  <p>but it looks like this:</p>
  
  <pre><code>   1           1           5
     1           1           5
     1           5           5
     1           5           5
  </code></pre>