Re: allocation error



lane straatman <grumpy196884@xxxxxxxxxxx> wrote:

allocate(pascal(1:n))
write (*,'(a)', advance='no') 'give me an int'
read (*, '(i3)') n
....
*** Error 112, Reference to undefined variable, array element or
function result (/UNDEF)

That's because your allocate is before you read the value of n. Allocate
is an executable statement. It does its thing when it is executed, which
in this case is before n is defined. My guess is that you are thinking
it does something more complicated like make the array size track the
value of n as n changes. Nope, it is much simpler than that.

Put the allocate after the read.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: allocation error
    ... write ', advance='no') 'give me an int' ... That's because your allocate is before you read the value of n. ... is an executable statement. ... Or is the undefined status of n a non-required error ...
    (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)
  • Re: allocation error
    ... That's because your allocate is before you read the value of n. ... is an executable statement. ... I have made the OP's error of allocating an array to a size specified ... is randomly set to some very large value, ...
    (comp.lang.fortran)
  • [PATCH] bigphysarea for 2.6.10 en 2.6.11
    ... +contineous memory for the entire runtime of Linux. ... +The big physical area is mainly managed by two functions. ... +caddr_t bigphysarea_alloc_pages(int count, int align, int priority) ... second it is not possible to allocate some memory ...
    (Linux-Kernel)
  • Suspend 2 merge: 41/51: Ranges (extents).
    ... +int nr_unused_ranges = 0; ... * Returns a whole chain of ranges to the unused pool. ... +void put_range_chain ... * be able to allocate contiguous pages. ...
    (Linux-Kernel)