allocation error




program pascal1
IMPLICIT NONE
integer :: n, i
integer, dimension(:), allocatable :: pascal
allocate(pascal(1:n))
write (*,'(a)', advance='no') 'give me an int'
read (*, '(i3)') n
do i=1, n
pascal(n) = i
write (*, '(i3)') pascal(i)
end do
end program pascal1
This program wants to dynamically allocate an array of rank 1. It
compiles and builds but has the following bug:
Run-time Error
*** Error 112, Reference to undefined variable, array element or
function result (/UNDEF)
PASCAL1 - in file pascal1.f95 at line 5 [+004e]
Ideas? LS

.



Relevant Pages

  • Re: allocation error
    ... end program pascal1 ... This program wants to dynamically allocate an array of rank 1. ... It isn't a bug. ... *** Error 112, Reference to undefined variable, array element or ...
    (comp.lang.fortran)
  • Re: allocation error
    ... That's because your allocate is before you read the value of n. ... is an executable statement. ... end program pascal1 ... get fortran output to look proper, but that was a different century.) ...
    (comp.lang.fortran)