MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
StringList.f90
Go to the documentation of this file.
2 
3  use kindmodule, only: dp, i4b
4  use listmodule, only: listtype
6 
7  private
9 
10 contains
11 
12  subroutine constructcharactercontainer(newCharCont, text)
13  implicit none
14  type(characterstringtype), pointer, intent(out) :: newCharCont
15  character(len=*), intent(in) :: text
16  !
17  allocate (newcharcont)
18  newcharcont = text
19  return
20  end subroutine constructcharactercontainer
21 
22  function castascharacterstringtype(obj) result(res)
23  implicit none
24  class(*), pointer, intent(inout) :: obj
25  type(characterstringtype), pointer :: res
26  !
27  res => null()
28  if (.not. associated(obj)) return
29  !
30  select type (obj)
31  type is (characterstringtype)
32  res => obj
33  end select
34  return
35  end function castascharacterstringtype
36 
37  subroutine addstringtolist(list, string)
38  implicit none
39  ! -- dummy
40  type(listtype), intent(inout) :: list
41  character(len=*), intent(in) :: string
42  ! -- local
43  class(*), pointer :: obj
44  type(characterstringtype), pointer :: newcharactercontainer
45  !
46  newcharactercontainer => null()
47  call constructcharactercontainer(newcharactercontainer, string)
48  if (associated(newcharactercontainer)) then
49  obj => newcharactercontainer
50  call list%Add(obj)
51  end if
52  !
53  return
54  end subroutine addstringtolist
55 
56  function getstringfromlist(list, indx) result(string)
57  implicit none
58  ! -- dummy
59  type(listtype), intent(inout) :: list
60  integer(I4B), intent(in) :: indx
61  character(len=:), allocatable :: string
62  ! -- local
63  class(*), pointer :: obj
64  type(characterstringtype), pointer :: charcont
65  !
66  obj => list%GetItem(indx)
67  charcont => castascharacterstringtype(obj)
68  if (associated(charcont)) then
69  allocate (character(len=charcont%strlen()) :: string)
70  string(:) = charcont
71  else
72  string = ''
73  end if
74  !
75  return
76  end function getstringfromlist
77 
78 end module stringlistmodule
This module defines variable data types.
Definition: kind.f90:8
subroutine constructcharactercontainer(newCharCont, text)
Definition: StringList.f90:13
type(characterstringtype) function, pointer castascharacterstringtype(obj)
Definition: StringList.f90:23
character(len=:) function, allocatable, public getstringfromlist(list, indx)
Definition: StringList.f90:57
subroutine, public addstringtolist(list, string)
Definition: StringList.f90:38
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
A generic heterogeneous doubly-linked list.
Definition: List.f90:10