Thanks to all replier.
I ewconsidered the problem in light of the whole project, coming with 2
possible solutions:
1) since data come from analysis of several files, which do not change
during program execution, I can do a 1st pass counting dimensions, then
allocate, then do a 2nd pass reading data into the data structure.
2) as suggested, I could do
type element
integer, allocatable :: element_core(:) ! an array of integers
end type
type element_pointer
type(element), pointer :: e_p => null() ! pointer to the above
end type element_pointer
type(element_pointer), allocatable :: array_of_elements(:)
allocate( array_of_elements(3) ) ! an array of 3 pointers
do i = 1, size(array_of_elements)
allocate (array_of_elements(i)%e_p%element_core(n))
! where n is the size required for the ith array of integers
end do
... ! loading integers
Now when reallocating
type(element_pointer), allocatable :: tmp(:)
allocate( tmp(new size for array of array of integers) )
! copying pointers:
tmp(1:size(array_of_elements))%e_p => array_of_elements%e_p
! during this copy, in my intention, the underlying element_cores will
not be moved
call move_alloc (from = tmp, to = array_of_elements)
However, at the moment I cannot test the above machinery, I will do it
as soon as I can restart my hobby project, which will happen in some days.
But I am still interested in the subject, and in your comments, if any.
Thanks
Gigi