Reputation: 119
Is it possible to overload the pointer assignment in Fortran? i.e. given a type
Module test
type :: pointerType
real, pointer :: value
contains
generic :: assignment(=>) => ptToValue !This is not legitimate syntax, (I've tried it using ifort) but does suggest the intent of question
...
end type
contains
subroutine ptToValue(self,other)
type(pointerType), intent(inout) :: self
real, target, intent(in) :: other
self%value=>other
end subroutine
end module
you could create an array of that type and associate elements like this
...
type(pointerType), dimension(50) :: example
real, target :: realvalue
...
example(3)=>realvalue
rather than like this
...
example(3)%value=>realvalue
Upvotes: 2
Views: 396
Reputation: 21431
No.
Instead, simply invoke the subroutine directly or through a binding. If your compiler supports the relevant parts of F2008, consider making the other argument a pointer.
Upvotes: 2