title: What does "array cannot have a deferred shape" mean in fortran?
body: <p>I have a simple fortran function that computes the Kronecker product:</p>
  
  <pre><code>function kron(A, B)
      implicit none
      real, intent(in) :: A(:, :), B(:, :)
      integer :: i, j, ma, na, mb, nb
      real, dimension(:, :) :: kron
  
      ma = ubound(A, 1)
      na = ubound(A, 2)
      mb = ubound(b, 1)
      nb = ubound(b, 2)
      forall(i=1:ma, j=1:na)
          kron(mb*(i-1)+1:mb*i, nb*(j-1)+1:nb*j) = A(i,j)*B
      end forall
  end function kron
  </code></pre>
  
  <p>It's inside a module, but when I compile it with <code>gfortran -static -ffree-form -std=f2003 -Wall</code>, I get these errors:</p>
  
  <pre><code>function kron(A, B)
                  1
  Error: Array 'kron' at (1) cannot have a deferred shape
  </code></pre>
  
  <p>Is this error occurring because you're supposed to know the size of the array to be returned beforehand?</p>