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

assumed size final subroutine interface

A__Valle
Beginner
235 Views

Hello,

I have a question regarding the interface of the final subroutines. According to the Fortran 2003 standards, you can have multiple final bindings, with the following restriction: any two final subroutines for a type must differ in the rank of kind type paramters of the dummy argument. The same final subroutine may not be specified twice.

In the attached small fortran file, I have created an type:
TYPEDerivedQuantityType INTEGER,DIMENSION(:),POINTER::Unit=>null() CONTAINS FINAL::FreeDerivedQuantity FINAL::FreeDerivedQuantities
...
ENDTYPEDerivedQuantityType
Where the interface only differs in rank:
- FreeDerivedQuantities(:)
- FreeDerivedQuantity

This type is part of another type:
TYPEQuantityType TYPE(DerivedQuantityType),DIMENSION(:),POINTER::DerivedQuantity=>null()
CONTAINS
...
ENDTYPEQuantityTypeI use the generic assignment (=) for the derived type (see also the attached file),
NewQuantityType%DerivedQuantity(1)=OldQuantityType%DerivedQuantity(1) The generic assignment has an intent(out) attribute on the DerivedQuantity. The compiler then will deallocate the header argument when the routine is called.

I would have assumed that it is calling the FreeDerivedQuantity routine. However, when I debug the session, I notice that it does use the FreeDerivedQuantities routine, resulting in an access violation.

Does anyone has an explanation for this behavior?

Kind Regards,
Dirk van Meeuwen

0 Kudos
3 Replies
A__Valle
Beginner
235 Views
As a workaround putting the INTENT(inout) attribute for the assign routines can be used. In my opinion this should not be necessary.
0 Kudos
Steven_L_Intel1
Employee
235 Views
I agree that this behavior is not correct. I have escalated it to the developers as issue DPD200232729. I will update this thread when I have news.
0 Kudos
Steven_L_Intel1
Employee
235 Views

This has been fixed for a release later this year.

0 Kudos
Reply