Reputation: 25818
In the example available here, I try to define a type that has a procedure pointer component f. I also have the PASS option active, which means that the first argument of f is the passed-object argument.
In the program, f is associated with a subroutine called proc1, which changes the component i to 999. However, if I run the program, i is not changed and instead stays 123.
What is my mistake?
Thanks
Upvotes: 1
Views: 225
Reputation: 21
I am not an expert, but I think that when you use the PASS attribute, you have to specify the argument that is being passed. At least that is the way I've been using it. for example
... pass(self) :: foo
function foo(self, baz) return(bar)
type(mytype), intent(in) :: self
real, intent(in) :: baz
...
Then the way to call this procedure would be: instanceOfMyType%foo(baz)
Cheers.
Upvotes: 2
Reputation: 6659
I get an error when I try to compile that code. It goes away when I change the declaration of argument A in subroutine proc1 from type(derivedType)
to class(derivedType)
.
Upvotes: 2