title: Dynamic array rank
body: <p>I have a few array variables in a module that are dynamic, and later allocated in one of two subroutines outside of the module. However, in one subroutine I want the array to be 1D, in the other subroutine I want it to be 2D.</p>
  
  <p>In principle I would want something like this in the module, but I don't believe this is possible in the declaration area?:</p>
  
  <pre><code>if (option1) then
    real (kind=8), allocatable :: arr1(:)
  else
    real (kind=8), allocatable :: arr1(:,:)
  endif
  </code></pre>
  
  <p>Is there a way in the allocatable declarations to have the dimension be dynamic? </p>
  
  <p><strong>Edit1:</strong> The reason I'm doing this is I'm adding a new subroutine to an existing codebase, but I want to be backwards compatible. arr1 is only used by the two separate subroutines, the main program doesn't use it at all. Here is some more complete code showing the idea:</p>
  
  <pre><code>program myprog
  use inputs
  
  call read_inputs
  
  if (option1) then
      call do1
  else
      call do2
  endif
  
  contains
      subroutine read_inputs
          use inputs
          use mymod
          !!!read from file .logical. option1, integers N1, N2
  
          !allocate arrays
          if (option1) then 
  
          else
  
          endif
      end subroutine read_inputs
  
      subroutine do1
          use inputs
          use mymod
  
          allocate(arr1(N1))
  
          !do stuff with arr1
      end subroutine do1
  
      subroutine do2
          use inputs
          use mymod
  
          allocate(arr1(N1,N2))
  
          !do stuff with arr1
      end subroutine do2
  
  end program
  
  module inputs
      logical :: option1
      integer :: N1, N2
  
  end module inputs
  
  module mymod
      use inputs
      !!!!can I do something here to make the rank of arr1 dynamic? I don't think the following will work
      if (option1)
          real (kind=8), allocatable :: arr1(:)
      else
          real (kind=8), allocatable :: arr1(:,:)
      endif
  end module mymod
  </code></pre>
  
  <p>I may just have two separate variable in mymod, arr1 and arr1_new. I was just hoping to avoid that.</p>