回 帖 发 新 帖 刷新版面

主题:求高手指点fortran语法问题

我在module里声明的全局变量,同时也是指针的目标变量,应该如何声明?

我尝试了real(8),target,save:: 出现了一下错误:

error #6796: The variable must have the TARGET attribute or be a subobject of an object with the TARGET attribute, or it must have the POINTER attribute.

求高人指点!

回复列表 (共1个回复)

沙发

module GlobalVariable
  implicit none
  
  real, target, save:: RTS = 1.234567E0
!contains  
end module



subroutine ABC()
  use GlobalVariable
  implicit none
  
  real, pointer:: RP => Null()
  RP => RTS
  write(unit = *, fmt = *) RP
  
  return
end subroutine

我来回复

您尚未登录,请登录后再回复。点此登录或注册