Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Allocate

dannycat
New Contributor I
736 Views

CVF Version 6.6c

I have a program that dynamically allocates a user defined data structure that itself contains allocatable components, some of which are also user defined. When the program attempts to allocate the data structure and it is too large for the available memory the STAT status correctly flags an error but there appears to be no memory available for the program to continue. It seems that the memory is allocated until there is none left butthen is not released upon failure thus causing the program to hang. Is this behaviour correct? AlsoI'm not sure whether thisapplies tosimpler allocatable data structures or standard FORTRAN data types.

To avoid this I would have to somehow calculate the size of the proposed data structure and then obtain the amount of available memory before trying to allocate.

I've also noticed that if an allocation fails any subsequent

if(allocated(array)) deallocate(array)

statementswill crash the program.

Any advice on these metterswould be appreciated.

0 Kudos
1 Reply
Steven_L_Intel1
Employee
736 Views
The only way that the ALLOCATE can fail due to insufficient memory is if the OS routine it calls returns an error. In this case, the memory was not allocated. I do not see how it is possible for "some" memory to remain allocated from a failed ALLOCATE call.

That said, CVF 6.6C was left with many bugs in its support for allocatable arrays. Some of these bugs might cause the behavior you note.
0 Kudos
Reply