# Automatic array allocation in Fortran 95?

• Fortran
The following code seems to run ok under fortran 95 (g95 compiler), but I was unsure about the exact nature of the array assignment. As you can see it is a variable sized array, without any explicit "allocate" command. The code works even when the array size could not be known at compile time, so I'm guessing that it's automatically allocated on the stack at run time. Just wondering if this legitimate Fortran 95 syntax (or something compiler specific)?

Code:
 subroutine test(n)
integer :: n
implicit none

integer :: a(n)     ! Is this automatic allocation?
integer :: k
do k=1,n
a(k)=k
end do
print *,a

end subroutine test

## Answers and Replies

gsal
It's legal, it is called Automatic Object.

...gotta run.