FOR006 array-of-finalizable-type-not-finalised
warning enabled by defaultAn array of a derived type with final procedures, none of which finalises arrays of that rank.
Why
A final procedure runs only for objects whose rank matches its dummy argument: a final subroutine with a scalar dummy finalises scalars, not the elements of an array. When an array of the type is deallocated or goes out of scope, nothing is finalised and the resources the finaliser releases (allocations, files, device memory) leak. Make the final subroutine elemental (or impure elemental), or add one for each array rank in use.
Reported
fortran
type :: field
contains
final :: field_free ! subroutine field_free(self); type(field) :: self
end type
type(field), allocatable :: blocks(:)Preferred
fortran
impure elemental subroutine field_free(self)
type(field), intent(inout) :: selfSuppressing
For one occurrence, with the reason on the same line (or alone on the line before the statement):
fortran
! fobis: ignore[FOR006] <why this occurrence is fine>For the whole project, ignore = FOR006 in the fobos [lint] section.
References
Sections of the shipped knowledge packs behind this rule:
hpc-practice:fortran-practice#finalisers-final-for-arrays-of-types(fobis kb show hpc-practice:fortran-practice#finalisers-final-for-arrays-of-types)