是否可以在Fortran中重载指针赋值?即给出类型
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
你可以创建一个这种类型的数组并关联像这样的元素
...
type(pointerType), dimension(50) :: example
real, target :: realvalue
...
example(3)=>realvalue
而不是喜欢这个
...
example(3)%value=>realvalue
答案 0 :(得分:2)
没有
相反,只需直接或通过绑定调用子例程。如果您的编译器支持F2008的相关部分,请考虑将另一个参数作为指针。