MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
definitionselectmodule Module Reference

This module contains the DefinitionSelectModule. More...

Functions/Subroutines

subroutine, public idt_parse_rectype (idt, cols, ncol)
 allocate and set RECARRAY, KEYSTRING or RECORD param list More...
 
character(len=linelength) function, public idt_datatype (idt)
 return input definition type datatype More...
 
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type (input_definition_types, component_type, subcomponent_type, blockname, tagname, filename)
 Return parameter definition. More...
 
type(inputparamdefinitiontype) function, pointer, public get_aggregate_definition_type (input_definition_types, component_type, subcomponent_type, blockname)
 Return aggregate definition. More...
 
subroutine, public split_record_definition (input_definition_types, component_type, subcomponent_type, tagname, nwords, words)
 Return aggregate definition. More...
 

Detailed Description

This module contains the routines for getting parameter definitions, aggregate definitions, and block definitions for the different package types.

Function/Subroutine Documentation

◆ get_aggregate_definition_type()

type(inputparamdefinitiontype) function, pointer, public definitionselectmodule::get_aggregate_definition_type ( type(inputparamdefinitiontype), dimension(:), intent(in), target  input_definition_types,
character(len=*), intent(in)  component_type,
character(len=*), intent(in)  subcomponent_type,
character(len=*), intent(in)  blockname 
)
Parameters
[in]component_typecomponent type, such as GWF or GWT
[in]subcomponent_typesubcomponent type, such as DIS or NPF
[in]blocknamename of the block
Returns
corresponding InputParameterDefinitionType for this block

Definition at line 124 of file DefinitionSelect.f90.

126  type(InputParamDefinitionType), dimension(:), intent(in), target :: &
127  input_definition_types
128  character(len=*), intent(in) :: component_type !< component type, such as GWF or GWT
129  character(len=*), intent(in) :: subcomponent_type !< subcomponent type, such as DIS or NPF
130  character(len=*), intent(in) :: blockname !< name of the block
131  type(InputParamDefinitionType), pointer :: idt !< corresponding InputParameterDefinitionType for this block
132  type(InputParamDefinitionType), pointer :: tmp_ptr
133  integer(I4B) :: i
134 
135  nullify (idt)
136  do i = 1, size(input_definition_types)
137  tmp_ptr => input_definition_types(i)
138  if (tmp_ptr%component_type == component_type .and. &
139  tmp_ptr%subcomponent_type == subcomponent_type .and. &
140  tmp_ptr%blockname == blockname) then
141  idt => input_definition_types(i)
142  exit
143  end if
144  end do
145 
146  if (.not. associated(idt)) then
147  write (errmsg, '(a,a,a,a,a,a,a)') &
148  'Idm aggregate definition not found: ', trim(blockname), &
149  '. Component="', trim(component_type), &
150  '", subcomponent="', trim(subcomponent_type), '".'
151  call store_error(errmsg, .true.)
152  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_param_definition_type()

type(inputparamdefinitiontype) function, pointer, public definitionselectmodule::get_param_definition_type ( type(inputparamdefinitiontype), dimension(:), intent(in), target  input_definition_types,
character(len=*), intent(in)  component_type,
character(len=*), intent(in)  subcomponent_type,
character(len=*), intent(in)  blockname,
character(len=*), intent(in)  tagname,
character(len=*), intent(in)  filename 
)
Parameters
[in]component_typecomponent type, such as GWF or GWT
[in]subcomponent_typesubcomponent type, such as DIS or NPF
[in]blocknamename of the block
[in]tagnamename of the input tag
[in]filenameinput filename
Returns
corresponding InputParameterDefinitionType for this tag

Definition at line 85 of file DefinitionSelect.f90.

89  type(InputParamDefinitionType), dimension(:), intent(in), target :: &
90  input_definition_types
91  character(len=*), intent(in) :: component_type !< component type, such as GWF or GWT
92  character(len=*), intent(in) :: subcomponent_type !< subcomponent type, such as DIS or NPF
93  character(len=*), intent(in) :: blockname !< name of the block
94  character(len=*), intent(in) :: tagname !< name of the input tag
95  character(len=*), intent(in) :: filename !< input filename
96  type(InputParamDefinitionType), pointer :: idt !< corresponding InputParameterDefinitionType for this tag
97  type(InputParamDefinitionType), pointer :: tmp_ptr
98  integer(I4B) :: i
99 
100  nullify (idt)
101  do i = 1, size(input_definition_types)
102  tmp_ptr => input_definition_types(i)
103  if (tmp_ptr%component_type == component_type .and. &
104  tmp_ptr%subcomponent_type == subcomponent_type .and. &
105  tmp_ptr%blockname == blockname .and. &
106  tmp_ptr%tagname == tagname) then
107  idt => input_definition_types(i)
108  exit
109  end if
110  end do
111 
112  if (.not. associated(idt)) then
113  write (errmsg, '(a,a,a,a,a)') &
114  'Input file tag not found: "', trim(tagname), &
115  '" in block "', trim(blockname), &
116  '".'
117  call store_error(errmsg)
118  call store_error_filename(filename)
119  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ idt_datatype()

character(len=linelength) function, public definitionselectmodule::idt_datatype ( type(inputparamdefinitiontype), intent(in), pointer  idt)

Definition at line 68 of file DefinitionSelect.f90.

69  use constantsmodule, only: linelength
70  type(InputParamDefinitionType), pointer, intent(in) :: idt
71  character(len=LINELENGTH) :: datatype
72  if (idt%datatype(1:9) == 'KEYSTRING') then
73  datatype = 'KEYSTRING'
74  else if (idt%datatype(1:8) == 'RECARRAY') then
75  datatype = 'RECARRAY'
76  else if (idt%datatype(1:6) == 'RECORD') then
77  datatype = 'RECORD'
78  else
79  datatype = idt%datatype
80  end if
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:45
Here is the caller graph for this function:

◆ idt_parse_rectype()

subroutine, public definitionselectmodule::idt_parse_rectype ( type(inputparamdefinitiontype), intent(in), pointer  idt,
character(len=linelength), dimension(:), intent(inout), allocatable  cols,
integer(i4b), intent(inout)  ncol 
)

Definition at line 28 of file DefinitionSelect.f90.

29  use constantsmodule, only: linelength
30  use inputoutputmodule, only: parseline
31  type(InputParamDefinitionType), pointer, intent(in) :: idt
32  character(len=LINELENGTH), dimension(:), allocatable, &
33  intent(inout) :: cols
34  integer(I4B), intent(inout) :: ncol
35  character(len=:), allocatable :: parse_str
36  character(len=LINELENGTH), dimension(:), allocatable :: param_cols
37  integer(I4B) :: param_ncol, n
38 
39  ! initialize
40  if (allocated(cols)) deallocate (cols)
41  ncol = 0
42 
43  ! split definition
44  parse_str = trim(idt%datatype)//' '
45  call parseline(parse_str, param_ncol, param_cols)
46 
47  if (param_ncol > 1) then
48  if (param_cols(1) == 'RECARRAY' .or. &
49  param_cols(1) == 'KEYSTRING' .or. &
50  param_cols(1) == 'RECORD') then
51  ! exclude 1st column
52  allocate (cols(param_ncol - 1))
53  do n = 2, param_ncol
54  cols(n - 1) = param_cols(n)
55  end do
56  ! set ncol
57  ncol = param_ncol - 1
58  end if
59  end if
60 
61  ! cleanup
62  if (allocated(param_cols)) deallocate (param_cols)
63  if (allocated(parse_str)) deallocate (parse_str)
subroutine, public parseline(line, nwords, words, inunit, filename)
Parse a line into words.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ split_record_definition()

subroutine, public definitionselectmodule::split_record_definition ( type(inputparamdefinitiontype), dimension(:), intent(in), target  input_definition_types,
character(len=*), intent(in)  component_type,
character(len=*), intent(in)  subcomponent_type,
character(len=*), intent(in)  tagname,
integer(i4b), intent(inout)  nwords,
character(len=40), dimension(:), intent(inout), allocatable  words 
)

Split a component RECORD datatype definition whose second element matches tagname into an array of character tokens

Parameters
[in]component_typecomponent type, such as GWF or GWT
[in]subcomponent_typesubcomponent type, such as DIS or NPF
[in]tagnamename of the input tag

Definition at line 160 of file DefinitionSelect.f90.

162  use inputoutputmodule, only: parseline
163  type(InputParamDefinitionType), dimension(:), intent(in), target :: &
164  input_definition_types
165  character(len=*), intent(in) :: component_type !< component type, such as GWF or GWT
166  character(len=*), intent(in) :: subcomponent_type !< subcomponent type, such as DIS or NPF
167  character(len=*), intent(in) :: tagname !< name of the input tag
168  integer(I4B), intent(inout) :: nwords
169  character(len=40), dimension(:), allocatable, intent(inout) :: words
170  type(InputParamDefinitionType), pointer :: tmp_ptr
171  integer(I4B) :: i
172  character(len=:), allocatable :: parse_str
173 
174  ! initialize to deallocated
175  if (allocated(words)) deallocate (words)
176 
177  ! return all tokens of multi-record type that matches the first
178  ! tag following the expected first token "RECORD"
179  do i = 1, size(input_definition_types)
180 
181  ! initialize
182  nwords = 0
183 
184  ! set ptr to current definition
185  tmp_ptr => input_definition_types(i)
186 
187  ! match for definition to split
188  if (tmp_ptr%component_type == component_type .and. &
189  tmp_ptr%subcomponent_type == subcomponent_type .and. &
190  idt_datatype(tmp_ptr) == 'RECORD') then
191 
192  ! set split string
193  parse_str = trim(input_definition_types(i)%datatype)//' '
194 
195  ! split
196  call parseline(parse_str, nwords, words)
197 
198  ! check for match and manage memory
199  if (nwords >= 2) then
200  if (words(1) == 'RECORD' .and. words(2) == tagname) then
201  exit
202  end if
203  end if
204 
205  ! deallocate
206  if (allocated(parse_str)) deallocate (parse_str)
207  if (allocated(words)) deallocate (words)
208  end if
209  end do
Here is the call graph for this function:
Here is the caller graph for this function: