Say you have a declared type dat1 which has a default numbers of members. Depending on run time, this dat1 may or may not be extended with other types. This is easy as you can use the extends feature. However, if you have an array of dat1 and some elements of that array may or may not want to inherit another type - how is this done most reasonably.
I have the following example:
type dat1
real :: x(3)
type(dat2), allocatable :: rnd
type(dat1), pointer :: next => dat1
end dat1
Now I used a linked list to do this. My question is basically if it is the correct way to declare the second type rnd as an allocatable, and then just allocate it whenever a node requests it.
The other option is to declare it as a pointer i.e. type(dat2), allocatable :: rnd, now is there any significant differences, despite the common Fortran differences with pointers vs alloctables like explicit/implicit deallocation, contiguous memory etc.
Note that no matter what, each dat1 node will always have either 0 or 1 rnd type attached to it.
I was considering during runtime that I would check if rnd was allocated or for pointer it would be associated.