Is there anything wrong with passing an unallocated array to a routine without an explicit interface?
fortran, subroutine
Solution
You've almost answered your own question. Yes, by the standard, it is always illegal to pass an unallocated allocatable arrays as an actual argument if you don't have an interface in scope.
If you have an interface in scope it is only legal if the dummy argument is also allocatable.
And yes I've been bitten by it. My work around has been to allocate to zero size before the call.
Problem
Consider: ``` program main real, allocatable, dimension(:) :: foo integer n n=10 call dofoo(foo,n,1) allocate(foo(n)) call dofoo(foo,n,0) end program main subroutine dofoo(foo,n,mode) real foo(n) integer i,n,mode if(mode.eq.1)then n=6 return endif do i=1,n foo(i)=i enddo return end subroutine dofoo ``` Is there anything wrong with the above code? (It works with gfortran) I pass in an un-allocated array the first time, but I don't touch it -- Is there anything in the standard that could cause this to behave in a system dependent way?