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

how to initialize allocatable data

martymike
Novice
475 Views
I'd like to have a list that could grow during execution that would also start with an initial set of values. I could create a static array, but then there's a hard upper bound. I could use an allocatable array, with logic to reallocate if needed, but I can't initialize it at compile time. I could create a linked list, but I can't initialize the next pointers at compile time.Does anyone have any ideas?
0 Kudos
3 Replies
mecej4
Honored Contributor III
475 Views
You can use a derived type as the basic element of your list, and then specify default initializations for the components of that derived type. For example, zero for a counter, blank for a string and NULL() for pointers.
0 Kudos
Steven_L_Intel1
Employee
475 Views
That wouldn't allow initialization of "next" pointers to point to the next in the list. This is something you'll have to write code to do.
0 Kudos
Arjen_Markus
Honored Contributor II
475 Views
You may want to have a look at the linked list module in my Flibs project at http://flibs.sf.net.
(I should take a closer look at it one of these days, but it is functional andmay give you an
idea of how to go about.)

Regards,

Arjen
0 Kudos
Reply