Problem with DEALLOCATE

Problem with DEALLOCATE

I have a user using ALLOCATABLE arrays in a FORTRAN DLL. As far as I can tell, he has set up the ALLOCATION correctly, but is having problems with DEALLOCATE at the end of the routine.

The first DEALLOCATE statement brings up the following message:

Debug Error!
Program: C:Program Fileslah blah
DAMAGE: After normal block (#63) at 0x025c2828

(Press Retry To Debug Application)

Abort Retry Ignore

The normal block number and memory address can change.
If I 'Ignore' execution proceeds without further errora but the following message is written to the debug output in devstudio:

memory check error at 0x025C2828 = 0x00 should be 0xfd

I've never had this problem using allocatable arrays before...any ideas anyone?

(Can avoid the error by not explicitly deallocating, but that isn't good form is it?)

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The user is passing the allocatable arrays and their sizes (n) to sub-functions, where the arrays are locally defined to be of size (n). Could this cause any problems?

This alone shouldn't; it all looks like array bounds violation. However, note that CVF cannot detect array out of bounds exceptions for assumed-size arrays. My guess is that the routines write into (most probably) array(0), which does not cause a run-time exception, but rather just silently corrupts the heap -- it gets detected just on DEALLOCATE.

If you convert the arguments to assumed-size (:) CVF will be able to detect array bounds exceeded (however, note that it requires having explicit interfaces to the callees).



It was an array-bounds problem. Well several actually. Once I turned array-bound checking on, everything worked out (i.e. the debugger 'exceptioned' in the right places)!



Leave a Comment

Please sign in to add a comment. Not a member? Join today