I hope this is right place to post this question.
I would like to know if it is possible to define allocatable derived types with allocatable members.
I give an example in the code below. I would expect that this would not work because at the time of the first allocate() call it is not yet known how much memory is needed, since the size of member is not yet known. Nevertheless, this seems to work in PGI VF (F95). But I’m afraid that there may be an out-of-bounds problem here, that’s going unnoticed.
If this is correct programming then my next question is: can one do this with deeper levels of nesting, e.g. allocatable derived types with allocable derived-type-members, with allocatable members, etc.
Thanks in advance.
program prog implicit none integer :: i type test_type real, allocatable :: member(:) end type type(test_type), allocatable :: test(:) allocate(test(10)) do i=1,10 allocate(test(i)%member(10)) end do end program prog