-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_finalisable.f90
More file actions
49 lines (32 loc) · 1.35 KB
/
base_finalisable.f90
File metadata and controls
49 lines (32 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
!> Base class for classes that can be wrapped with pyfgen.
!>
!> Such classes must always be finalisable, to help with memory management
!> across the Python-Fortran interface.
module fpyfgen_base_finalisable
implicit none(type, external)
private
integer, parameter, public :: INVALID_INSTANCE_INDEX = -1
!! Value that denotes an invalid model index
public :: BaseFinalisable
type, abstract :: BaseFinalisable
integer :: instance_index = INVALID_INSTANCE_INDEX
!! Unique identifier for the instance.
!!
!! Set to a value > 0 when the instance is in use,
!! set to `INVALID_INSTANCE_INDEX` (TODO xref) otherwise.
!! The value is linked to the position in a manager array stored elsewhere.
!! This value shouldn't be modified from outside the manager
!! unless you really know what you're doing.
contains
private
procedure(derived_type_finalise), public, deferred :: finalise
end type BaseFinalisable
interface
subroutine derived_type_finalise(self)
!! Finalise the instance (i.e. free/deallocate)
import :: BaseFinalisable
implicit none(type, external)
class(BaseFinalisable), intent(inout) :: self
end subroutine derived_type_finalise
end interface
end module fpyfgen_base_finalisable