title: changing array dimensions in fortran
body: <p>There are basically two ways to pass arrays to a subroutine in Fortran 90/95:</p>
  
  <pre><code>PROGRAM ARRAY
  INTEGER, ALLOCATABLE :: A(:,:)
  INTEGER :: N
  ALLOCATE(A(N,N))
  CALL ARRAY_EXPLICIT(A,N)
  ! or
  CALL ARRAY_ASSUMED(A)
  END PROGRAM ARRAY
  
  SUBROUTINE ARRAY_EXPLICIT(A,N)
  INTEGER :: N
  INTEGER :: A(N,N)
  ! bla bla
  END SUBROUTINE ARRAY_EXPLICIT
  
  SUBROUTINE ARRAY_ASSUMED(A)
  INTEGER, ALLOCATABLE :: A(:,:)
  N=SIZE(A,1)
  ! bla bla
  END SUBROUTINE ARRAY_ASSUMED
  </code></pre>
  
  <p>where you need an explicit interface for the second, usually through the use of a module.</p>
  
  <p>From FORTRAN77, I'm used to the first alternative, and I read this is also the most efficient if you pass the whole array.</p>
  
  <p>The nice thing with the explicit shape is that I can also call a subroutine and treat the array as a vector instead of a matrix:</p>
  
  <pre><code>SUBROUTINE ARRAY_EXPLICIT(A,N)
  INTEGER :: N
  INTEGER :: A(N**2)
  ! bla bla
  END SUBROUTINE ARRAY_EXPLICIT
  </code></pre>
  
  <p>I wondered if there is a nice way to do that kind of thing using the second, assumed shape interface, without copying it.</p>