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

Derived data type copy for reallocation

François-Xavier
Beginner
517 Views
Dear all,

I come to you today with a question related to derived data types.

I wish to allocate and reallocatedynamically derived types arrayswhich are currently allocated statically.

I am used to make use of the "move alloc" function in order to make temporary arrays for reallocations.

This solution includes a copy of original type array.

My question sounds simple, how do you manage reallocating efficientlytype arrays?

Sincerely yours and thank you,

F-Xavier
0 Kudos
3 Replies
Steven_L_Intel1
Employee
517 Views
Perhaps it would be helpful if you show a short example of what you want to do. I am uncertain about what you are looking for. Do you mean arrays of derived type, where the derived type has allocatable components?
0 Kudos
François-Xavier
Beginner
517 Views
Yes this is exactly the point.

I tried to investigate polymorphic functionnalities in a generic function, but i am not sure that IFORT 11.1 embeds all what is needed. I have also the next compiler generation( composer X12), in that case, what can i do more?

I will send you an example if needed.

Sincerely yours.
0 Kudos
Steven_L_Intel1
Employee
517 Views
If you have an array of derived type with allocatable components, and wish to reallocate those components, you have to do it individually. There is no way to process all the reallocations in a single statement. You might write a loop that goes through the array and does the necessary reallocations.

I will comment that if you have another array of these derived types, and want to copy one to the other even though the allocatable components are of different shapes, you can do that with a simple assignment. The components on the left side will automatically get reallocated to match the shape of the corresponding components of the right side.

If this does not explain things enough, please provide a short example showing what you would like to happen.
0 Kudos
Reply