title: Fortran function: pointer as actual argument and target as formal
body: <p>I am trying to decipher a fortran code. It passes a pointer to a function as an actual argument, and the formal argument is instead a target. It defines and allocates a pointer of type globalDATA in the main program, then it calls a function passing that pointer:</p>
  
  <pre><code>module dataGLOBAL
   type globalDATA
     type (gl_1)      , pointer :: gl1
     type (gd_2)      , pointer :: gd2
     type (gdt_ok)    , pointer :: gdtok
     ...
     ...
   end type globalDATA
  end module dataGLOBAL
  
  
  Program main
  ....
  ....
  use dataGLOBAL   
  ...
  type(globalDATA),pointer :: GD
  
  allocate(GD)
  returnvalue = INIT(GD)
  ....
  ....
  end
  </code></pre>
  
  <p>The function reads:</p>
  
  <pre><code>integer function INIT(GD) result(returnvalue)
  ....
  ....
  use dataGLOBAL
  
  type(globalDATA)  , target   :: GD
  
  allocate (GD%gl1)
  allocate (GD%gd2)
  allocate (GD%gdtok)
  ....
  ....
  end function INIT
  </code></pre>
  
  <p>What is the meaning of doing this? And why do both the pointer in the main program and the single components of the target structure have to be allocated?
  thanks
  A.</p>