assumed size final subroutine interface

assumed size final subroutine interface

Portrait de D.W. van Meeuwen

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

Fichier attachéTaille
Téléchargement testprogram.f903.56 Ko
4 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de D.W. van Meeuwen

As a workaround putting the INTENT(inout) attribute for the assign routines can be used. In my opinion this should not be necessary.

Portrait de Steve Lionel (Intel)

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.

Steve
Portrait de Steve Lionel (Intel)

This has been fixed for a release later this year.

Steve

Connectez-vous pour laisser un commentaire.