【发布时间】:2018-04-02 18:09:22
【问题描述】:
我尝试向this module 添加一个由@VladimirF 编写的过程,该过程在Fortran 2003 中实现了一个通用链表。为了方便起见,我希望能够将列表的内容输出为数组,所以我添加了在名为lists.f90 的文件中对列表模块执行以下过程:
subroutine list_as_array(self, arrayOut)
class(list),intent(inout) :: self
class(*),dimension(1:self%length),intent(out) :: arrayOut
integer :: i
type(list_node), pointer :: nodeIter
nodeIter = self%first
do i = 1,self%length
arrayOut(i) = nodeIter%item ! <---ERROR here
if (i<self%length) then
nodeIter = nodeIter%next
end if
end do
end subroutine list_as_array
ifort 18.0.0 给出以下错误:
lists.f90(324): error #8304: In an intrinsic assignment statement, variable shall not be a non-allocatable polymorphic. [ARRAYOUT]
arrayOut(i) = nodeIter%item
------^
我是 F2003+ 中的多态性新手,所以我不理解错误消息或其上下文。出了什么问题,如何解决?
【问题讨论】:
-
标记@VladimirF,因为他们是模块的作者。
-
顺便说一句,这不会做任何事情。他们之前必须与帖子进行过互动。
-
@francescalus:感谢您找到我的复制/粘贴错字。修复了错误信息。
标签: fortran polymorphism intel-fortran