-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathitem_mod.F90
More file actions
executable file
·70 lines (58 loc) · 2 KB
/
item_mod.F90
File metadata and controls
executable file
·70 lines (58 loc) · 2 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
!-----------------------------------------------------------------------
! SPBM is free software: you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the Free
! Software Foundation (https://www.gnu.org/licenses/gpl.html).
! It is distributed in the hope that it will be useful, but WITHOUT ANY
! WARRANTY; without even the implied warranty of MERCHANTABILITY or
! FITNESS FOR A PARTICULAR PURPOSE. A copy of the license is provided in
! the COPYING file at the root of the SPBM distribution.
!-----------------------------------------------------------------------
! Original author(s): Shamil Yakubov
!-----------------------------------------------------------------------
module item_mod
implicit none
private
public:: item,delete
type item
private
class(*),pointer:: var => null()
type(item),pointer:: next => null()
contains
procedure,non_overridable:: next_item
procedure,non_overridable:: get_item
procedure,non_overridable:: set_item
end type
interface item
module procedure item_constructor
end interface
contains
function item_constructor(var,next)
class(*),intent(in):: var
class(item),pointer,intent(in):: next
class(item),pointer:: item_constructor
allocate(item_constructor)
allocate(item_constructor%var,source=var)
item_constructor%next => next
end function
function next_item(self)
class(item),intent(in):: self
class(item),pointer:: next_item
next_item => self%next
end function
function get_item(self)
class(item),intent(in):: self
class(*),pointer:: get_item
get_item => self%var
end function
subroutine set_item(self,new_var)
class(item),intent(inout):: self
class(*),intent(in):: new_var
deallocate(self%var)
allocate(self%var,source=new_var)
end subroutine
!non type-bound procedure because of pointer
subroutine delete(any_item)
class(item),pointer,intent(inout):: any_item
deallocate(any_item)
end subroutine
end module