0: DEALLOCATE: memory at 1abfbbaO not allocated

I’m seeing the following error during the execution of my code.

0: DEALLOCATE: memory at 1abfbbaO not allocated

This confuses me b/c I trap all of my deallocate statments with code like:

deallocate( dyn_arr, stat=err)
if( err /= 0 )then
  stop "Deallocation Error"
endif

Is there something I’m missing? The problem occurs w -O4 and -g. Any ideas?

Hi,

What happens when you check to see if the array is allocated (through a call to the inquiry function ALLOCATED)? Does it indicate that the array is allocated? The array is not a dummy argument or a function result, correct? What is the declaration for dyn_arr and how is it assigned?

-Mark

I was checking each w/ the allocated() statement. And, they all passed.

As it turns out, the real problem occurred nowhere near any deallocate statement.

The bug was that my code was attempting to access an array at element -1, which is obviously an error. I don’t know why I got that deallocation error, but you can see why I focused in on all deallocate() statements to find the bug.

Thanks for the reply, though.

  • Lee

Hi Lee,

Seeing that you were accessing an invalid array element, it is possible that memory got clobbered at some point during execution. This can cause weird memory errors like the one you mentioned.

I wonder if the -Mbounds switch would have helped. -Mbounds generates bounds checking for arrays and should only be used for debugging purposes.

Regards,

Mark

Ah ha! I am having this problem as well, and also track my allocate/deallocate statements like that. I shall start looking for negative array elements…
Thanks :)