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

Syntax of DEALLOCATE

OP1
New Contributor III
930 Views

Let's consider the statement "DEALLOCATE(MY_ARRAY,STAT=ERROR)".

In what cases would a memory deallocation attempt would be unsuccessful (and therefore justifying the STAT=ERROR part of the statement) ?

Thanks!

Olivier

0 Kudos
3 Replies
Les_Neilson
Valued Contributor II
930 Views
Quoting - opmkl

Let's consider the statement "DEALLOCATE(MY_ARRAY,STAT=ERROR)".

In what cases would a memory deallocation attempt would be unsuccessful (and therefore justifying the STAT=ERROR part of the statement) ?

Thanks!

Olivier

From the help :
"If the DEALLOCATE statement specifies an array that is not currently allocated, an error occurs."

also

"If no STAT variable is specified and an error condition occurs, program execution terminates."

Thatmeans you can code your program defensively to ignore this error if it occurs by specifying STAT and testing or ignoring it. If STAT is not there, then the program stops if an error occurs.

Les

0 Kudos
Steven_L_Intel1
Employee
930 Views

If MY_ARRAY is a POINTER that is not pointing to a whole, allocated array then you'd get an error as well.

0 Kudos
OP1
New Contributor III
930 Views

If MY_ARRAY is a POINTER that is not pointing to a whole, allocated array then you'd get an error as well.

Oh, I see. I forgot about the pointer case for an array subsection.

Thanks a lot!

Olivier

0 Kudos
Reply