title: Fortran 90 rank mismatch in attempting to extract a vector from an array
body: <p>In my Fortran 90 code, I have created the following array (called <strong>array</strong>) of integers:</p>
  
  <pre><code> 1     2     3     4     5     6     7     8     9    10
  11    12    13    14    15    16    17    18    19    20
  21    22    23    24    25    26    27    28    29    30
  31    32    33    34    35    36    37    38    39    40
  </code></pre>
  
  <p>I wish to extract the first column, and save it in a four-element vector called <strong>time</strong>.  I have the following code:</p>
  
  <pre><code>PROGRAM test
    IMPLICIT NONE
    INTEGER, PARAMETER :: numrows=4, numcols=10
    INTEGER :: i, j, k
    INTEGER, DIMENSION(:,:), ALLOCATABLE :: array, time
  
    ALLOCATE(array(numrows,numcols))
    ALLOCATE(time(numrows))
  
    k=1
    DO i=1,numrows
      DO j=1,numcols
        array(i,j)=k
        k=k+1
      END DO
    END DO
  
    DO i=1,numrows
      WRITE(*,"(100(3X,I3))") (array(i,j), j=1,numcols)
    END DO
  
    time=array(:,1)
  END PROGRAM test
  </code></pre>
  
  <p>But, I get the following error message (when compiling in gfortran):</p>
  
  <pre><code>test.f90:8.15:
  
    ALLOCATE(time(numrows))
                 1
  Error: Rank mismatch in array reference at (1) (1/2)
  test.f90:22.2:
  
    time=array(:,1)
    1
  Error: Incompatible ranks 2 and 1 in assignment at (1)
  </code></pre>
  
  <p>Why is this the case?  The error message seems to suggest that the array <code>array(:,1)</code> is of rank 2, not rank 1.  Is there any way that I can convert <code>array(:,1)</code> to an array of rank 1?  Do I need to use <code>RESHAPE</code> to somehow squeeze the array?  Or is the problem that by using <code>array(:,1)</code>, I am specifying a column vector rather than a row vector?  Thank you very much for your time.</p>