[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