MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
ListNode.f90
Go to the documentation of this file.
2  implicit none
3  private
4 
5  public :: listnodetype
6 
7  type :: listnodetype
8  ! -- Public members
9  type(listnodetype), pointer, public :: nextnode => null()
10  type(listnodetype), pointer, public :: prevnode => null()
11  class(*), pointer, public :: Value => null()
12  contains
13  ! -- Public procedure
14  procedure, public :: getitem
15  procedure, public :: deallocvalue
16  end type listnodetype
17 
18 contains
19  ! -- Type-bound procedures for ListNodeType
20 
21  !> @brief Return a pointer to this node's value.
22  function getitem(this) result(valueObject)
23  class(listnodetype), intent(inout) :: this
24  class(*), pointer :: valueobject
25  valueobject => this%Value
26  end function getitem
27 
28  !> @brief Nullify (optionally deallocating) this node's value.
29  subroutine deallocvalue(this, destroy)
30  class(listnodetype), intent(inout) :: this
31  logical, intent(in), optional :: destroy
32 
33  if (associated(this%Value)) then
34  if (present(destroy)) then
35  if (destroy) then
36  deallocate (this%Value)
37  end if
38  end if
39  nullify (this%Value)
40  end if
41  end subroutine deallocvalue
42 
43 end module
class(*) function, pointer getitem(this)
Return a pointer to this node's value.
Definition: ListNode.f90:23
subroutine deallocvalue(this, destroy)
Nullify (optionally deallocating) this node's value.
Definition: ListNode.f90:30