Fortran中两个不同声明之间的差异

时间:2018-12-16 15:45:28

标签: oop fortran intel-fortran

我有以下内容:

  type t_octree
     real                          :: box(2,3)
     type(t_octree), pointer       :: parent      => NULL()
     type(t_octree), pointer       :: children(:) => NULL()
     contains
     final                         :: DESTROY_OCTREE
  end type t_octree


  interface t_octree
     module procedure              :: INIT_OCTREE
  end interface t_octree

现在是我的构造函数或析构函数:

  subroutine INIT_OCTREE( this, num_points, box )

  implicit none

  class(t_octree)      :: this
  integer                :: num_points
  real                   :: box(2,3)
        (...)
  end subroutine INIT_OCTREE

  subroutine DESTROY_OCTREE( this )

  implicit none
  type(t_octree)         :: this
    (....)
  end subroutine DESTROY_OCTREE

有人可以解释为什么两者都起作用,即如果我用type(t_octree) :: thisclass(t_octree) :: this声明。 我整理了两个案例,它们都起作用了。那么这里的区别是什么?

什么时候应该使用哪个?

0 个答案:

没有答案