Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Finalisation of Abstract Type

$
0
0

 

So I have an abstract type with allocatable length strings

type, abstract:: firstType
   character(len=:), allocatable:: one, two
  contains
end type

I want to be able to include a final  subroutine:

type, abstract:: firstType
    character(len=:), allocatable:: one

  contains
    final:: destroyFirst
end type

contains

subroutine destroyFirst(typeIn)
end subroutine

Is it possible?   When I try to use type(firstType) then I get 

 error #8313: The TYPE(derived-type-spec) shall not specify an abstract type.

but when I try to use class(firstType) I get the error

error #8339: The dummy argument of a final subroutine must be a variable of the derived type being defined and cannot be optional, pointer, allocatable, or polymorphic.

Is it possible to finalise an abstract type?


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>