title: Reshape in Fortran90
body: <p>I need to reshape a 2D matrix (A) with dimension as 3*8 to matrix (B) with dimension as (6*4) in Fortran as the example below.</p>
  
  <pre><code>Matrix A 
  
  1 2 1 2 1 2 1 2
  5 6 5 6 5 6 5 6
  7 8 7 8 7 8 7 8
  
  Matrix B                       
      1 1 1 1
      2 2 2 2
      5 5 5 5
      6 6 6 6
      7 7 7 7
      8 8 8 8
  </code></pre>
  
  <p>I tried as the following with looping but seems to be very slow for large matrices. I was thinking if such reshaping is possible with <code>RESHAPE</code> function in Fortran 90.</p>
  
  <pre><code>        counter=1
          do i=1,size(A,2),2
              seq1(counter)=i
              counter=1+counter
          end do
  
          counter=1
          do i=2,size(A,2),2
            seq2(counter)=i
            counter=1+counter
          end do
  
          counter=1
          do i=1,size(A,1)*2,2
            S_1(counter)=i
            counter=1+counter
          end do
  
          counter=1
          do i=2,size(A,1)*2,2
            S_2(counter)=i
            counter=1+counter
          end do
  
          Do i=1,size(A,1)
            B(S_1(i),:)=A(i,seq1)
            B(S_2(i),:)=A(i,seq2)
          END DO
  </code></pre>