title: 2D array concatenation in fortran
body: <p>Fortran 2003 has square bracket syntax for array concatenation, Intel fortran compiler supports it too. I wrote a simple code here for matrix concatenation:</p>
  
  <pre><code>program matrix
  implicit none
  real,dimension (3,3) :: mat1,mat2
  real,dimension(3,6):: mat3
  integer i
  
  mat1=reshape( (/1,2,3,4,5,6,7,8,9/),(/3,3/))
  mat2=reshape( (/1,2,3,4,5,6,7,8,9/),(/3,3/))
  mat3=[mat1,mat2]
  
  !display
  do i=1,3,1
  write(*,10) mat3(i,:)
  10 format(F10.4)
  end do
  
  end program
  </code></pre>
  
  <p>But I get error as </p>
  
  <pre><code>mat3=[mat1,mat2]
  Error: Incompatible ranks 2 and 1 in assignment
  </code></pre>
  
  <p>I expect the output as</p>
  
  <pre><code>1 2 3 1 2 3
  4 5 6 4 5 6
  7 8 9 7 8 9
  </code></pre>
  
  <p>Can someone comment where am I going wrong? What is rank 2 and 1 here? I guess all arrays have rank 2.</p>