[Fortran] 纯文本查看 复制代码 module MNodeElement
implicit none
type,public :: CElementNode
integer :: ChannelLabel = 0
type(CElementNodeArray),dimension(:),pointer :: pAdditionalNode => null()
contains
procedure,public :: initNodeElement
end type CElementNode
type,public :: CElementNodeArray
type(CElementNode),pointer :: pElementNode
end type CElementNodeArray
contains
subroutine initNodeElement(this)
class(CElementNode) :: this
integer :: istat
this%ChannelLabel = 0
allocate(this%pAdditionalNode(6),stat=istat)
if (istat /= 0) then
print*,"creat pAdditionalNode failed,istat =",istat
end if
end subroutine initNodeElement
end module
program main
use MNodeElement
implicit none
logical :: flag = .false.
type(CElementNode) :: pNode
call pNode%initNodeElement()
! 生成了pAdditionalNode的指针
! pAdditionalNode=>null()
! 但是 flag 显示为 .ture.
flag = associated (pNode%pAdditionalNode(1)%pElementNode)
end program
编译环境visual2010+ivf2013:
调试过程值:[Fortran] 纯文本查看 复制代码
pNode%PADDITIONALNODE(1)%PELEMENTNODE%CHANNELLABEL Undefined address INTEGER(4)
pNode%PADDITIONALNODE(1)%PELEMENTNODE%PADDITIONALNODE Undefined address TYPE(CELEMENTNODE_mp_CELEMENTNODEARRAY)
pNode%PADDITIONALNODE(1)%PELEMENTNODE%INITNODEELEMENT #BAADF00D PROCEDURE
问题
pAdditionalNode指针初始化为空,但associated(pNode%pAdditionalNode%pElement)为.true.,
其中pNode%PADDITIONALNODE(1)%PELEMENTNODE%INITNODEELEMENT过程未初始化,赋值为一个十六进制数
求教,如何将pNode%PADDITIONALNODE(1)%PELEMENTNODE置空
ps:gfortran中这样执行后,pNode%PADDITIONALNODE(1)%PELEMENTNODE是空的
|