Again, array of pointers in Fortran. So well, I've a derived type:
type :: t_context_pointer
type(t_context),pointer :: p_ctx
end type t_context_pointer
When I do in the main program:
type(t_context_pointer),allocatable :: tab_ctx_ptr(:)
type(t_context),allocatable,target :: ctx
allocate(tab_ctx_ptr(1))
allocate(ctx)
tab_ctx_ptr(1)%p_ctx=>ctx
it works. But when I use a function call:
type(t_context_pointer),allocatable,target :: tab_ctx_ptr(:)
allocate(tab_ctx_ptr(n))
call alloc_ctx(tab_ctx_ptr,n,1)
with elsewhere:
subroutine alloc_ctx(tab_ctx_ptr,n,i)
integer,intent(in) :: n,i
type(t_context_pointer),intent(inout) :: tab_ctx_ptr(n)
type(t_context),allocatable,target :: ctx
allocate(ctx)
tab_ctx_ptr(i)%p_ctx=>ctx
end subroutine
it seg_fault later in the code. Is there something wrong here?