This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Problem with procedure pointers passed as arguments
- From: Andrew Benson <abenson at its dot caltech dot edu>
- To: fortran at gcc dot gnu dot org
- Date: Thu, 11 Feb 2010 16:30:56 -0800
- Subject: Problem with procedure pointers passed as arguments
I'm experiencing a problem with procedure pointers passed as arguments to
subroutines (using v4.4.0). The subroutine associates the pointer with some
procedure. The calling unit then attempts to call the procedure pointed to by
this pointer. When I run this under OpenMP I sometimes get an unassociated
pointer returned, even though it is associated in the subroutine (and the code
therefore crashes).
subroutine Outer_Unit
implicit none
type(treeNode), pointer :: thisNode
logical :: procAssigned
procedure(), pointer :: assignedProc
call Get_Proc(thisNode,procAssigned,assignedProc)
if (procAssigned) call assignedProc(thisNode)
return
end Outer_Unit
subroutine Get_Proc(thisNode,procAssigned,assignedProc)
implicit none
type(treeNode), intent(inout), pointer :: thisNode
logical, intent(out) :: procAssigned
procedure(), pointer, intent(out) :: assignedProc
if (decide_if_to_set_the_pointer) then
assignedProc => Proc_To_Call
procAssigned=.true.
else
procASssigned=.false.
end if
return
end subroutine Get_Proc
Outer_Unit and Get_Proc are in two separate modules and Outer_Unit is called
within an OpenMP parallel region. This all seems to work OK when I compile and
run without OpenMP.
My question is, should this be possible (in which case I assume the issue is a
compiler bug), or am I trying to do something that just can't work?
-A.