Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Finalizer with allocatable components

Simon1
Beginner
1,203 Views

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 Kudos
1 Solution
Steven_L_Intel1
Employee
1,203 Views

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.

View solution in original post

0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,204 Views

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 Kudos
Simon1
Beginner
1,203 Views

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

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

0 Kudos
FortranFan
Honored Contributor III
1,203 Views

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 Kudos
Steven_L_Intel1
Employee
1,203 Views

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

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,203 Views

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 Kudos
Steven_L_Intel1
Employee
1,203 Views

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 Kudos
FortranFan
Honored Contributor III
1,203 Views

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 Kudos
Steven_L_Intel1
Employee
1,203 Views

The reported problem is fixed in 15.0.

0 Kudos
Reply