Given the following code
type t1
integer :: dum
type(aop), alloctable :: bc(:)
end type t1
type aop
procedure(A_INT), pass(t1), pointer :: ptr => null()
end type aop
abstract interface
subroutine A_INT ( this )
import t1
class(t1) , intent(in) :: this
end subroutine
end interface
Can someone explain why this is illegal? At least the compiler says
error #8170: The passed-object dummy argument is missing from the procedure interface. [A_INT]
procedure(A_INT), pass(t1),
-------------------^
UPDATED
When I do this instead
type t1
integer :: dum
type(aop), alloctable :: bc(:)
end type t1
type aop
procedure(A_INT), pass(this), pointer :: ptr => null()
end type aop
abstract interface
subroutine A_INT ( this )
import t1
class(t1) , intent(in) :: this
end subroutine
end interface
I get following error
error #8262: For a type-bound procedure that has the PASS binding attribute, the first dummy argument must have the same declared type as the type being defined. [THIS]
subroutine A_INT( this
which I guess this means that the compiler expects the first argument to be of aop
type? Is it not possible to have this
being of t1
type?
You are using pass(t1)
bu there is no dummy argument t1
, there is only the argument this
which is of type t1
.
With a single dummy argument I would typically not use any explicit pass
here at all. A passed dummy argument makes sense only when it is of the same type as the type in which the pointer is defined. Otherwise, for arguments of other types, just use nopass
.