MODFLOW 6  version 6.8.0.dev0
USGS Modular Hydrologic Model
mf6filekeystringmodule Module Reference

Period block keystring-based input loader. More...

Data Types

type  keystringloadtype
 Keystring period block loader. More...
 

Functions/Subroutines

subroutine ainit (this, mf6_input, component_name, component_input_name, input_name, iperblock, parser, iout)
 
subroutine df (this)
 
subroutine ad (this)
 
subroutine rp (this, parser)
 
subroutine reset (this)
 
subroutine destroy (this)
 
subroutine create_structarray (this)
 

Detailed Description

Each keystring member maps to a typed column in a StructArrayType. A dispatch keyword on each input row selects the target column.

Simple dispatch: keyword matches a DOUBLE/STRING/INTEGER column; one value token is read into that column.

Compound dispatch: keyword matches a KEYWORD-type column (e.g. FLOWING_WELL). The keyword token is stored directly; subsequent non-KEYWORD sub-member columns are read in order.

Function/Subroutine Documentation

◆ ad()

subroutine mf6filekeystringmodule::ad ( class(keystringloadtype), intent(inout)  this)

Definition at line 159 of file Mf6FileKeystring.f90.

160  class(KeystringLoadType), intent(inout) :: this
161  call this%tsmanager%ad()

◆ ainit()

subroutine mf6filekeystringmodule::ainit ( class(keystringloadtype), intent(inout)  this,
type(modflowinputtype), intent(in)  mf6_input,
character(len=*), intent(in)  component_name,
character(len=*), intent(in)  component_input_name,
character(len=*), intent(in)  input_name,
integer(i4b), intent(in)  iperblock,
type(blockparsertype), intent(inout), pointer  parser,
integer(i4b), intent(in)  iout 
)
private

Definition at line 59 of file Mf6FileKeystring.f90.

61  use inputoutputmodule, only: getunit
66  class(KeystringLoadType), intent(inout) :: this
67  type(ModflowInputType), intent(in) :: mf6_input
68  character(len=*), intent(in) :: component_name
69  character(len=*), intent(in) :: component_input_name
70  character(len=*), intent(in) :: input_name
71  integer(I4B), intent(in) :: iperblock
72  type(BlockParserType), pointer, intent(inout) :: parser
73  integer(I4B), intent(in) :: iout
74  type(CharacterStringType), dimension(:), pointer, contiguous :: ts_fnames
75  character(len=LINELENGTH) :: fname
76  character(len=LENVARNAME), allocatable :: named_bound(:)
77  character(len=LINELENGTH), dimension(:), allocatable :: member_names
78  integer(I4B) :: n, nmembers, isize
79 
80  call this%DynamicPkgLoadType%init(mf6_input, component_name, &
81  component_input_name, input_name, &
82  iperblock, iout)
83  this%ts_active = .false.
84  this%nleading = 0
85 
86  allocate (this%tsmanager)
87  call tsmanager_cr(this%tsmanager, iout)
88 
89  ! load static input (TS6_FILENAME tag sets static_loader%ts_active)
90  call this%static_loader%load(parser, mf6_input, this%nc_vars, &
91  this%input_name, iout)
92 
93  ! add declared TS files to tsmanager
94  if (this%static_loader%ts_active) then
95  this%ts_active = .true.
96  call get_isize('TS6_FILENAME', mf6_input%mempath, isize)
97  if (isize > 0) then
98  call mem_setptr(ts_fnames, 'TS6_FILENAME', mf6_input%mempath)
99  do n = 1, size(ts_fnames)
100  fname = ts_fnames(n)
101  call this%tsmanager%add_tsfile(fname, getunit())
102  end do
103  end if
104  end if
105 
106  ! collect DIMENSIONS block parameter names for LoadContext;
107  ! absent for TVK/TVS — LoadContext falls back to nodes * nmembers
108  do n = 1, size(mf6_input%param_dfns)
109  if (mf6_input%param_dfns(n)%blockname == 'DIMENSIONS') then
110  call expandarray(named_bound)
111  named_bound(size(named_bound)) = trim(mf6_input%param_dfns(n)%mf6varname)
112  end if
113  end do
114 
115  ! init load context
116  if (allocated(named_bound)) then
117  call this%ctx%init(mf6_input, named_bound=named_bound)
118  else
119  call this%ctx%init(mf6_input)
120  end if
121 
122  call this%ctx%tags(this%param_names, this%nparam, this%input_name)
123  this%nleading = this%ctx%nleading
124 
125  ! append keystring member column names
126  call this%ctx%keystring_member_names(member_names, nmembers)
127  do n = 1, nmembers
128  this%nparam = this%nparam + 1
129  call expandarray(this%param_names)
130  this%param_names(this%nparam) = trim(member_names(n))
131  end do
132 
133  ! finalize context setup (allocates NBOUND, NODEULIST, etc.)
134  call this%ctx%allocate_arrays()
135 
136  ! pre-allocate structarray; reused across all periods
137  call this%create_structarray()
integer(i4b) function, public getunit()
Get a free unit number.
This module contains the LoadMf6FileModule.
Definition: LoadMf6File.f90:8
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
Static parser based input loader.
Definition: LoadMf6File.f90:54
Here is the call graph for this function:

◆ create_structarray()

subroutine mf6filekeystringmodule::create_structarray ( class(keystringloadtype), intent(inout)  this)
private

Definition at line 227 of file Mf6FileKeystring.f90.

230  use inputoutputmodule, only: upcase
231  class(KeystringLoadType), intent(inout) :: this
232  type(InputParamDefinitionType), pointer :: idt, pidt
233  character(len=LINELENGTH), allocatable :: rec_cols(:)
234  character(len=LINELENGTH) :: kwname, first_col
235  integer(I4B) :: icol, nrow_prealloc, jparam, nrec_col, nsub
236 
237  ! use pre-allocated managed memory (maxbound = features * nmembers);
238  ! fall back to deferred shape (-1) if maxbound is unavailable
239  if (associated(this%ctx%maxbound) .and. this%ctx%maxbound > 0) then
240  nrow_prealloc = this%ctx%maxbound
241  else
242  nrow_prealloc = -1
243  end if
244 
245  this%structarray => constructstructarray(this%mf6_input, this%nparam, &
246  nrow_prealloc, 0, &
247  this%mf6_input%mempath, &
248  this%mf6_input%component_mempath)
249  do icol = 1, this%nparam
250  idt => get_param_definition_type(this%mf6_input%param_dfns, &
251  this%mf6_input%component_type, &
252  this%mf6_input%subcomponent_type, &
253  'PERIOD', &
254  this%param_names(icol), this%input_name)
255  call this%structarray%mem_create_vector(icol, idt)
256 
257  ! For KEYWORD member columns, store the compound sub-member count
258  ! from the RECORD definition so read_from_parser_keystring reads
259  ! exactly the right number of sub-values.
260  if (trim(idt%datatype) == 'KEYWORD' .and. icol > this%nleading) then
261  kwname = trim(idt%tagname)
262  call upcase(kwname)
263  nsub = 0
264  do jparam = 1, size(this%mf6_input%param_dfns)
265  pidt => this%mf6_input%param_dfns(jparam)
266  if (pidt%blockname /= 'PERIOD') cycle
267  if (pidt%datatype(1:6) /= 'RECORD') cycle
268  call idt_parse_rectype(pidt, rec_cols, nrec_col)
269  if (nrec_col >= 1) then
270  first_col = trim(rec_cols(1))
271  call upcase(first_col)
272  if (trim(first_col) == trim(kwname)) then
273  nsub = nrec_col - 1
274  if (allocated(rec_cols)) deallocate (rec_cols)
275  exit
276  end if
277  end if
278  if (allocated(rec_cols)) deallocate (rec_cols)
279  end do
280  this%structarray%struct_vectors(icol)%nsubmembers = nsub
281  end if
282  end do
This module contains the DefinitionSelectModule.
subroutine, public idt_parse_rectype(idt, cols, ncol)
allocate and set RECARRAY, KEYSTRING or RECORD param list
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
subroutine, public upcase(word)
Convert to upper case.
Here is the call graph for this function:

◆ destroy()

subroutine mf6filekeystringmodule::destroy ( class(keystringloadtype), intent(inout)  this)

Definition at line 210 of file Mf6FileKeystring.f90.

211  class(KeystringLoadType), intent(inout) :: this
212 
213  call this%static_loader%cleanup()
214 
215  call this%tsmanager%da()
216  deallocate (this%tsmanager)
217  nullify (this%tsmanager)
218 
219  if (associated(this%structarray)) then
220  call destructstructarray(this%structarray)
221  end if
222 
223  call this%ctx%destroy()
224  call this%DynamicPkgLoadType%destroy()
Here is the call graph for this function:

◆ df()

subroutine mf6filekeystringmodule::df ( class(keystringloadtype), intent(inout)  this)

Definition at line 140 of file Mf6FileKeystring.f90.

142  class(KeystringLoadType), intent(inout) :: this
143  type(StructArrayType), pointer :: sa
144  integer(I4B) :: n
145  ! init tsmanager (TDIS now available)
146  call this%tsmanager%tsmanager_df()
147  ! link static TS strlocs; preserve for re-registration after reset()
148  do n = 1, this%static_loader%ts_sa_count()
149  sa => this%static_loader%get_ts_sa(n)
150  if (associated(sa)) then
151  call sa%ts_update(this%tsmanager, &
152  this%mf6_input%subcomponent_name, &
153  this%ctx%iprpak, this%input_name, &
154  clear_strlocs=.false.)
155  end if
156  end do
This module contains the StructArrayModule.
Definition: StructArray.f90:8
type for structured array
Definition: StructArray.f90:41

◆ reset()

subroutine mf6filekeystringmodule::reset ( class(keystringloadtype), intent(inout)  this)

Definition at line 189 of file Mf6FileKeystring.f90.

191  class(KeystringLoadType), intent(inout) :: this
192  type(StructArrayType), pointer :: sa
193  integer(I4B) :: n
194  ! clear TS links
195  call this%tsmanager%reset(this%mf6_input%subcomponent_name)
196  ! re-register static TS links (strlocs preserved in df)
197  if (this%ts_active) then
198  do n = 1, this%static_loader%ts_sa_count()
199  sa => this%static_loader%get_ts_sa(n)
200  if (associated(sa)) then
201  call sa%ts_update(this%tsmanager, &
202  this%mf6_input%subcomponent_name, &
203  this%ctx%iprpak, this%input_name, &
204  clear_strlocs=.false.)
205  end if
206  end do
207  end if

◆ rp()

subroutine mf6filekeystringmodule::rp ( class(keystringloadtype), intent(inout)  this,
type(blockparsertype), intent(inout), pointer  parser 
)
private

Definition at line 164 of file Mf6FileKeystring.f90.

166  class(KeystringLoadType), intent(inout) :: this
167  type(BlockParserType), pointer, intent(inout) :: parser
168 
169  call this%reset()
170 
171  call idm_log_header(this%mf6_input%component_name, &
172  this%mf6_input%subcomponent_name, this%iout)
173 
174  this%ctx%nbound = &
175  this%structarray%read_from_parser_keystring(parser, this%ts_active, &
176  this%nleading, this%iout, &
177  this%input_name)
178 
179  if (this%ts_active) then
180  call this%structarray%ts_update(this%tsmanager, &
181  this%mf6_input%subcomponent_name, &
182  this%ctx%iprpak, this%input_name)
183  end if
184 
185  call idm_log_close(this%mf6_input%component_name, &
186  this%mf6_input%subcomponent_name, this%iout)
This module contains the Input Data Model Logger Module.
Definition: IdmLogger.f90:7
subroutine, public idm_log_close(component, subcomponent, iout)
@ brief log the closing message
Definition: IdmLogger.f90:56
subroutine, public idm_log_header(component, subcomponent, iout)
@ brief log a header message
Definition: IdmLogger.f90:44
Here is the call graph for this function: