title: array of pointers fortran
body: <p>Again, array of pointers in Fortran. So well, I've a derived type:</p>
  
  <pre><code>type :: t_context_pointer  
      type(t_context),pointer :: p_ctx  
  end type t_context_pointer
  </code></pre>
  
  <p>When I do in the main program:</p>
  
  <pre><code>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=&gt;ctx
  </code></pre>
  
  <p>it works. But when I use a function call:</p>
  
  <pre><code>type(t_context_pointer),allocatable,target :: tab_ctx_ptr(:)
  allocate(tab_ctx_ptr(n))
  call alloc_ctx(tab_ctx_ptr,n,1)
  </code></pre>
  
  <p>with elsewhere:</p>
  
  <pre><code>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=&gt;ctx
  end subroutine
  </code></pre>
  
  <p>it seg_fault later in the code. Is there something wrong here?</p>