Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未按预期方式调用Fortran最终过程_Fortran_Destructor_Finalize - Fatal编程技术网

未按预期方式调用Fortran最终过程

未按预期方式调用Fortran最终过程,fortran,destructor,finalize,Fortran,Destructor,Finalize,我有一个容器类型,它具有另一种类型的可分配数组。在容器类型上调用final过程并且释放可分配数组时,它不会触发数组中每个单独对象上的final过程,这是我所期望的。下面是一些演示我的问题的示例代码 Module AType implicit none Type A_T real :: x End Type A_T Type Inner_T Class(A_T), allocatable :: A contains final :: inner_destroy End

我有一个容器类型,它具有另一种类型的可分配数组。在容器类型上调用final过程并且释放可分配数组时,它不会触发数组中每个单独对象上的final过程,这是我所期望的。下面是一些演示我的问题的示例代码

Module AType
implicit none

Type A_T
    real :: x
End Type A_T

Type Inner_T
    Class(A_T), allocatable :: A
contains
    final :: inner_destroy
End Type Inner_T

Type Container_T
    type(Inner_T), dimension(:), allocatable :: inners
contains
    final :: container_destroy
End Type Container_T
  
contains

subroutine inner_destroy(this)
    type(Inner_T), intent(inout) :: this
    if(allocated(this%A)) deallocate(this%A)
end subroutine inner_destroy

subroutine container_destroy(this)
    type(Container_T), intent(inout) :: this
    if(allocated(this%inners)) deallocate(this%inners)
end subroutine container_destroy

End Module AType

当容器final方法在
container\u T
移出范围时被调用,而
internal\u T
的final方法不会从包含数组的释放中调用。是否有方便的方法触发这最后一个方法,或者我必须为
internal\T
创建一个包装器类型?或者这是不正确的行为?

组件
inners
是一个数组,但您尚未为
Inner\t
类型的数组提供最终子例程,或为
Inner\t
类型的标量提供基本最终子例程。您可以在链接的问题及其答案中找到这方面的详细信息。非常好,谢谢。组件
inners
是一个数组,但是您没有为
Inner\t
类型的数组提供最终子例程,也没有为
Inner\t
类型的标量提供基本最终子例程。您可以在链接的问题及其答案中找到这方面的详细信息。太好了,谢谢。