MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
StructVector.f90
Go to the documentation of this file.
1 !> @brief This module contains the StructVectorModule
2 !!
3 !! This module contains a generic type for storing
4 !! different types of vectors.
5 !!
6 !<
8 
9  use kindmodule, only: i4b, dp, lgp
12  use listmodule, only: listtype
15  use stlvecintmodule, only: stlvecint
17 
18  implicit none
19  private
21 
22  !> @brief derived type which describes time series string field
23  !<
25  integer(I4B) :: structarray_col !< global SA column index
26  integer(I4B) :: col !< SV column (1 if 1d array)
27  integer(I4B) :: row !< SV row
28  character(LINELENGTH) :: token !< TS string token
29  contains
30  end type tsstringloctype
31 
32  !> @brief derived type for generic vector
33  !!
34  !! This derived type is used in the StructArrayType to
35  !! store any type of vector.
36  !!
37  !<
39  type(inputparamdefinitiontype), pointer :: idt !< input definition
40  ! SA vector attributes
41  integer(I4B) :: memtype = 0 !< SA memtype
42  integer(I4B) :: icol = 0 !< SA column
43  integer(I4B) :: size = 0 !< size of array
44  ! Data pointers
45  integer(I4B), dimension(:), pointer, contiguous :: int1d => null()
46  integer(I4B), dimension(:, :), pointer, contiguous :: int2d => null()
47  real(dp), dimension(:), pointer, contiguous :: dbl1d => null()
48  real(dp), dimension(:, :), pointer, contiguous :: dbl2d => null()
49  type(characterstringtype), dimension(:), pointer, contiguous :: &
50  charstr1d => null()
51  type(stlvecint), pointer :: intvector => null()
52  ! Shape data pointers
53  integer(I4B), pointer :: intshape => null()
54  integer(I4B), dimension(:), pointer, contiguous :: intvector_shape => null()
55  ! TimeSeries strings
56  type(listtype) :: ts_strlocs
57  contains
58  procedure :: clear => sv_clear
59  procedure :: read_token => sv_read_token
60  procedure :: add_ts_strloc => sv_add_ts_strloc
61  procedure :: get_ts_strloc => sv_get_ts_strloc
62  end type structvectortype
63 
64 contains
65 
66  function sv_read_token(this, token, structarray_col, col, row) result(val)
67  ! -- modules
68  ! -- dummy
69  class(structvectortype) :: this
70  character(len=*), intent(in) :: token
71  integer(I4B), intent(in) :: structarray_col
72  integer(I4B), intent(in) :: col
73  integer(I4B), intent(in) :: row
74  real(dp) :: val
75  ! -- local
76  integer(I4B) :: istat
77  real(dp) :: r
78  !
79  ! -- initialize
80  val = dnodata
81  !
82  read (token, *, iostat=istat) r
83  if (istat == 0) then
84  val = r
85  else
86  call this%add_ts_strloc(token, structarray_col, col, row)
87  end if
88  !
89  ! -- return
90  return
91  end function sv_read_token
92 
93  subroutine sv_add_ts_strloc(this, token, structarray_col, col, row)
94  ! -- dummy variables
95  class(structvectortype) :: this
96  character(len=*), intent(in) :: token
97  integer(I4B), intent(in) :: structarray_col
98  integer(I4B), intent(in) :: col
99  integer(I4B), intent(in) :: row
100  class(tsstringloctype), pointer :: str_field
101  ! -- local variables
102  class(*), pointer :: obj
103  !
104  ! --
105  allocate (str_field)
106  str_field%structarray_col = structarray_col
107  str_field%col = col
108  str_field%row = row
109  str_field%token = token
110  !
111  obj => str_field
112  call this%ts_strlocs%Add(obj)
113  !
114  ! -- return
115  return
116  end subroutine sv_add_ts_strloc
117 
118  function sv_get_ts_strloc(this, idx) result(res)
119  ! -- dummy variables
120  class(structvectortype) :: this
121  integer(I4B), intent(in) :: idx !< package number
122  class(tsstringloctype), pointer :: res
123  ! -- local variables
124  class(*), pointer :: obj
125  !
126  ! -- initialize res
127  res => null()
128  !
129  ! -- get the package from the list
130  obj => this%ts_strlocs%GetItem(idx)
131  if (associated(obj)) then
132  select type (obj)
133  class is (tsstringloctype)
134  res => obj
135  end select
136  end if
137  !
138  ! -- return
139  return
140  end function sv_get_ts_strloc
141 
142  !> @brief
143  !<
144  subroutine sv_clear(this)
145  ! -- modules
146  ! -- dummy
147  class(structvectortype) :: this
148  class(tsstringloctype), pointer :: ts_strloc
149  integer(I4B) :: n
150  !
151  do n = 1, this%ts_strlocs%Count()
152  ts_strloc => this%get_ts_strloc(n)
153  deallocate (ts_strloc)
154  nullify (ts_strloc)
155  end do
156  !
157  call this%ts_strlocs%Clear()
158  !
159  return
160  end subroutine sv_clear
161 
162 end module structvectormodule
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:44
real(dp), parameter dnodata
real no data constant
Definition: Constants.f90:94
integer(i4b), parameter lentimeseriesname
maximum length of a time series name
Definition: Constants.f90:41
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:26
This module contains the InputDefinitionModule.
This module defines variable data types.
Definition: kind.f90:8
This module contains the StructVectorModule.
Definition: StructVector.f90:7
class(tsstringloctype) function, pointer sv_get_ts_strloc(this, idx)
real(dp) function sv_read_token(this, token, structarray_col, col, row)
subroutine sv_add_ts_strloc(this, token, structarray_col, col, row)
subroutine sv_clear(this)
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
derived type for generic vector
derived type which describes time series string field