I have some problems with old and new Fortran code. The new part is object-oriented, the old part works with function pointers.
My problem is, that I want to a assign a member function to a function pointer, so that the function works with this special object. Here is an example code with the same error:
module test
! abstract class
type, abstract :: base
contains
procedure (doSth), deferred :: doSomething
end type base
! deferred function
abstract interface
subroutine doSth(this)
import :: base
class(base) :: this
end subroutine
end interface
! derived class
type, extends(base) :: child
contains
procedure :: doSomething => do_Sth
end type child
contains
! deferred function implemented by child
subroutine do_Sth(this)
class(child) :: this
! ...
! ...
end subroutine
! function pointer to member function
subroutine get_functionPointer()
procedure() , pointer :: funcPtr
type (child), pointer :: childPtr
allocate (childPtr)
funcPtr => childPtr%doSomething
! ... This does not work
end subroutine
end module
This gives me the error message:
error #8191: The procedure target must be a procedure or a procedure pointer.
Is there any possibility to overcome this problem?