Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
公告
Important Update: Community Platform Migration​. Learn more​>

Finalizer with allocatable components

Simon1
初学者
2,285 次查看

Hello,

I am trying to understand how finalizers work in Fortran.

I have written a minimal test program containing a derived type with just a final procedure and an allocatable component.

It appears that the finalizer is called more that once, and I don't understand why.

I noticed this behaviour only if the derived type contains an allocatable component, and if more than one object is instantiated from that class.

Here is the code :

module finalizer_module
implicit none
type :: obj
    real,allocatable :: var
    contains
        final :: clean
end type
contains
    subroutine clean(this)
    type(obj) :: this
        write(*,*) "in finalizer"
    end subroutine clean
end module finalizer_module
!
program test_finalizer
use :: finalizer_module
    call sub
contains
    subroutine sub
    type(obj) :: f1,f2
    end subroutine sub
end program test_finalizer

And here the output :

 in finalizer
 in finalizer
 in finalizer

I think I should have only two "in finalizer", as I have two objects (f1,f2) that are destroyed at "end subroutine sub"?

NB:

$ ifort --version
ifort (IFORT) 14.0.2 20140120

 

0 项奖励
1 解答
Steven_L_Intel1
2,285 次查看

At first glance this appears to be ether the same bug or a related one to the one reported in http://software.intel.com/en-us/forums/topic/487145 ; For now I'm going to assume it's the same but will add your test case to it - issue ID is DPD200249474.

在原帖中查看解决方案

0 项奖励
8 回复数
Steven_L_Intel1
2,286 次查看

At first glance this appears to be ether the same bug or a related one to the one reported in http://software.intel.com/en-us/forums/topic/487145 ; For now I'm going to assume it's the same but will add your test case to it - issue ID is DPD200249474.

0 项奖励
Simon1
初学者
2,285 次查看

Ok, I hadn't found this previous thread...

Is there a public website available to follow the evolution of ifort issues ?

0 项奖励
FortranFan
名誉分销商 III
2,285 次查看

Simon wrote:

Ok, I hadn't found this previous thread...

Is there a public website available to follow the evolution of ifort issues ?

Yes, it'll be nice if such a site were available..

0 项奖励
Steven_L_Intel1
2,285 次查看

This is the site. Any developments are added to the forum threads where the issue was reported.

0 项奖励
jimdempseyatthecove
名誉分销商 III
2,285 次查看

Steve,

What I think would be helpful would be to have a Sticky thread listing the Issue ID's, summary, status, what version fixed issue, and links back to the forum messages that relate to the issue. This would be immensely useful as a self-help tool.

Jim Dempsey

0 项奖励
Steven_L_Intel1
2,285 次查看

Jim, the "summary" is perhaps the hardest part of that. I know from my many years of writing release notes that it is sometimes difficult if not impossible to come up with a concise summary of a particular problem. (Especially when the symptom is Internal Compiler Error.) Even if one could write a summary, it can mislead people into thinking they have the same problem and they won't report it. We'd much rather you report a duplicate than decide you don't need to report a problem. Often new reports of what looks like the identical problem are in fact something else entirely.

0 项奖励
FortranFan
名誉分销商 III
2,285 次查看

Steve,

Perhaps you and Intel staff can look at this site which lists all the open issues with gfortran.  Something similar for Intel Fortran will be very helpful.  As Jim suggests, one good add would be links to any forum topics that connect to the issues.

Thanks,

0 项奖励
Steven_L_Intel1
2,285 次查看

The reported problem is fixed in 15.0.

0 项奖励
回复