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

Catching allocation errors when duplicating derived type structures

OP1
New Contributor II
180 Views
Is there a way to catch a potential memory allocation error when using the statement A = B, where A and Bare an allocatable, derived-type variable which has allocatable array components?

....

! Declare A and B.
TYPE MY_TYPE
REAL(KIND=8),ALLOCATABLE :: X(:,:)
END TYPE MY_TYPE
TYPE(MY_TYPE),ALLOCATABLE :: A(:),B(:)

! Theautomatic allocations performed implicitly herein might fail...
A = B

....

Or should I go through the minutiae of allocating one by one all of the array components?

Thanks,

Olivier
0 Kudos
1 Reply
Steven_L_Intel1
Employee
180 Views

If you want to catch the errors you will have to handle all of the ALLOCATEs yourself.
0 Kudos
Reply