MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
mf6filekeystringmodule Module Reference

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

Data Types

type  intarraytype
 Wraps an allocatable int array for a per-column cache table. More...
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 ts_advance (this)
subroutine rp (this, parser)
subroutine allocate_subindex (this)
 Allocate ctxsubindex_dependency targets (subindex params excluded from allocate_items), and cache everything apply_subindex needs every period.
subroutine allocate_permanent_array (this, name, nfeatures, init_value)
 Allocate a permanent per-feature array named name with init_value, unless already allocated.
subroutine allocate_items (this)
 Allocate a permanent array for every IDM-managed item, using the descriptor's per-item feature count and init value.
logical(lgp) function valid_address (this, ifno, nfeatures, ifno_tagname, row)
 Validate ifno against nfeatures, storing an error keyed by ifno_tagname (the leading column's public tag) if out of range.
subroutine apply_auxiliary (this)
 Apply PERIOD AUXILIARY settings to the permanent AUX array. TS-linked rows resolve via the struct array's own ts_strlocs; literal rows resolve AUXNAME here and clear any stale TS link.
subroutine apply_subindex (this)
 Apply PERIOD settings for ctxsubindex_dependency's targets, via ts_update_indexed – same mechanism as BEDK/MANNING, but each row's target index comes from a named subindex field through the cached offset table rather than the leading id column alone.
subroutine apply_items (this)
 Apply IDM-managed feature- and node-addressed settings to their permanent arrays; each row's address comes from resolve_row_addr. Indexed-body and AUX are handled in their own routines.
integer(i4b) function resolve_row_addr (this, item, irow, period_ifno, cellid, ndim, leading_tag)
 Resolve one row's target index for an item, dispatching on addr_mode. Returns 0 (skip) if out of range.
integer(i4b) function, dimension(:), allocatable resolve_subindex_offsets (this, dimname)
 Per-feature cumulative offset table from an array-valued dimension, permuted into feature-index order first. Indexed by feature (not the dimension's own summed total).
integer(i4b) function, dimension(:), allocatable resolve_subindex_address (this, id_mf6varname, head_mf6varname, subindex_icol, offsets, nfeatures, nbound)
 Row -> resolved feature index for an item whose local position comes from a subindex field, via the offset table.
subroutine reset (this)
subroutine destroy (this)
subroutine create_structarray (this)

Detailed Description

Each keystring item 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 body columns are read in order.

Function/Subroutine Documentation

◆ 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 )

Definition at line 87 of file Mf6FileKeystring.f90.

89 use inputoutputmodule, only: getunit
93 class(KeystringLoadType), intent(inout) :: this
94 type(ModflowInputType), intent(in) :: mf6_input
95 character(len=*), intent(in) :: component_name
96 character(len=*), intent(in) :: component_input_name
97 character(len=*), intent(in) :: input_name
98 integer(I4B), intent(in) :: iperblock
99 type(BlockParserType), pointer, intent(inout) :: parser
100 integer(I4B), intent(in) :: iout
101 type(CharacterStringType), dimension(:), pointer, contiguous :: ts_fnames
102 character(len=LINELENGTH) :: fname
103 character(len=LENVARNAME) :: named_bound
104 logical(LGP) :: has_named_bound
105 integer(I4B) :: n, isize
106
107 call this%DynamicPkgLoadType%init(mf6_input, component_name, &
108 component_input_name, input_name, &
109 iperblock, iout)
110 this%ts_active = .false.
111 this%nleading = 0
112
113 allocate (this%tsmanager)
114 call tsmanager_cr(this%tsmanager, iout)
115
116 ! load static input (TS6_FILENAME tag sets static_loader%ts_active)
117 call this%static_loader%load(parser, mf6_input, this%nc_vars, &
118 this%input_name, iout)
119
120 ! add declared TS files to tsmanager
121 if (this%static_loader%ts_active) then
122 this%ts_active = .true.
123 call get_isize('TS6_FILENAME', mf6_input%mempath, isize)
124 if (isize > 0) then
125 call mem_setptr(ts_fnames, 'TS6_FILENAME', mf6_input%mempath)
126 do n = 1, size(ts_fnames)
127 fname = ts_fnames(n)
128 call this%tsmanager%add_tsfile(fname, getunit())
129 end do
130 end if
131 end if
132
133 ! find a DIMENSIONS parameter to alias as maxbound (skipped for
134 ! advanced packages, which get their count from PACKAGEDATA)
135 has_named_bound = .false.
136 if (.not. is_advanced(mf6_input)) then
137 do n = 1, size(mf6_input%param_dfns)
138 if (mf6_input%param_dfns(n)%blockname == 'DIMENSIONS') then
139 named_bound = trim(mf6_input%param_dfns(n)%mf6varname)
140 has_named_bound = .true.
141 exit
142 end if
143 end do
144 end if
145
146 ! init load context
147 if (has_named_bound) then
148 call this%ctx%init(mf6_input, named_bound=named_bound)
149 else
150 call this%ctx%init(mf6_input)
151 end if
152
153 ! params is fully elaborated: leading cols + item names
154 this%param_names = this%ctx%params
155 this%nparam = size(this%ctx%params)
156 this%nleading = this%ctx%nleading
157 call this%ctx%check_developmode(this%input_name)
158
159 ! finalize context setup (allocates NBOUND, NODEULIST, etc.)
160 call this%ctx%allocate_arrays()
161
162 ! pre-allocate structarray; reused across all periods
163 call this%create_structarray()
164
integer(i4b) function, public getunit()
Get a free unit number.
This module contains the LoadMf6FileModule.
subroutine, public get_isize(name, mem_path, isize)
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 ...
Static parser based input loader.
Here is the call graph for this function:

◆ allocate_items()

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

Definition at line 348 of file Mf6FileKeystring.f90.

350 class(KeystringLoadType), intent(inout) :: this
351 integer(I4B) :: k
352
353 if (.not. allocated(this%ctx%keystring_items)) return
354
355 do k = 1, size(this%ctx%keystring_items)
356 if (.not. this%ctx%keystring_items(k)%idm_managed) cycle
357 ! subindex arrays are allocated in allocate_subindex (df-time
358 ! dimension); skip here
359 if (this%ctx%keystring_items(k)%addr_mode == addr_subindex) cycle
360 if (this%ctx%keystring_items(k)%nfeatures < 1) cycle
361 call this%allocate_permanent_array( &
362 this%ctx%keystring_items(k)%idt%mf6varname, &
363 this%ctx%keystring_items(k)%nfeatures, &
364 this%ctx%keystring_items(k)%init_value)
365 end do
366 if (count_errors() > 0) then
367 call store_error_filename(this%input_name)
368 end if
This module contains simulation methods.
Definition Sim.f90:10
integer(i4b) function, public count_errors()
Return number of errors.
Definition Sim.f90:60
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
Here is the call graph for this function:

◆ allocate_permanent_array()

subroutine mf6filekeystringmodule::allocate_permanent_array ( class(keystringloadtype), intent(inout) this,
character(len=*), intent(in) name,
integer(i4b), intent(in) nfeatures,
real(dp), intent(in) init_value )
private

Definition at line 330 of file Mf6FileKeystring.f90.

332 class(KeystringLoadType), intent(inout) :: this
333 character(len=*), intent(in) :: name
334 integer(I4B), intent(in) :: nfeatures
335 real(DP), intent(in) :: init_value
336 real(DP), dimension(:), pointer, contiguous :: featarr => null()
337 integer(I4B) :: isize
338
339 call get_isize(name, this%mf6_input%mempath, isize)
340 if (isize > 0) return ! already allocated (shouldn't happen; df() runs once)
341 call mem_allocate(featarr, nfeatures, name, this%mf6_input%mempath)
342 featarr = init_value
Here is the call graph for this function:

◆ allocate_subindex()

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

Definition at line 258 of file Mf6FileKeystring.f90.

260 class(KeystringLoadType), intent(inout) :: this
261 type(InputParamDefinitionType), pointer :: idt, id_idt
262 character(len=LENVARNAME) :: dimname, subindex_tagname
263 integer(I4B) :: icol, sa_icol, padj, nfeatures, n
264 logical(LGP) :: found
265
266 if (.not. allocated(this%subindex_nfeatures)) then
267 allocate (this%subindex_nfeatures(this%structarray%count()))
268 allocate (this%subindex_offsets(this%structarray%count()))
269 allocate (this%subindex_icol(this%structarray%count()))
270 allocate (this%subindex_head_icol(this%structarray%count()))
271 this%subindex_nfeatures = 0
272 this%subindex_icol = 0
273 this%subindex_head_icol = 0
274 end if
275
276 padj = 0
277 if (this%ctx%has_setting_dispatch) padj = 1
278
279 id_idt => get_param_definition_type(this%mf6_input%param_dfns, &
280 this%mf6_input%component_type, &
281 this%mf6_input%subcomponent_type, &
282 this%ctx%blockname, &
283 this%param_names(1), &
284 this%input_name)
285 this%subindex_id_varname = trim(id_idt%mf6varname)
286
287 do icol = this%nleading + 1, this%nparam
288 if (.not. this%ctx%keystring_items(icol - this%nleading)%is_body) cycle
289 idt => get_param_definition_type(this%mf6_input%param_dfns, &
290 this%mf6_input%component_type, &
291 this%mf6_input%subcomponent_type, &
292 this%ctx%blockname, &
293 this%param_names(icol), &
294 this%input_name)
295 found = this%ctx%subindex_dependency(idt%tagname, dimname, &
296 subindex_tagname)
297 if (.not. found) cycle
298
299 sa_icol = icol + padj
300 nfeatures = this%ctx%resolve_item_nfeatures(idt%tagname, dimname, 0)
301 if (nfeatures < 1) cycle
302 this%subindex_nfeatures(sa_icol) = nfeatures
303 this%subindex_offsets(sa_icol)%vals = &
304 this%resolve_subindex_offsets(dimname)
305 call this%allocate_permanent_array( &
306 trim(idt%mf6varname), nfeatures, dzero)
307
308 ! resolve the subindex column (by ctx-given tag) and this
309 ! target's subindex head, both structurally (body_start/head_nbody)
310 do n = 1, this%structarray%count()
311 if (trim(this%structarray%struct_vectors(n)%idt%tagname) == &
312 trim(subindex_tagname)) this%subindex_icol(sa_icol) = n
313 if (this%structarray%struct_vectors(n)%head_nbody > 0) then
314 if (sa_icol >= this%structarray%struct_vectors(n)%body_start .and. &
315 sa_icol < this%structarray%struct_vectors(n)%body_start + &
316 this%structarray%struct_vectors(n)%head_nbody) &
317 this%subindex_head_icol(sa_icol) = n
318 end if
319 end do
320 ! neither subindex nor head found (misconfigured ctx entry): not a target
321 if (this%subindex_icol(sa_icol) == 0 .or. &
322 this%subindex_head_icol(sa_icol) == 0) &
323 this%subindex_nfeatures(sa_icol) = 0
324 end do
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
Here is the call graph for this function:

◆ apply_auxiliary()

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

Definition at line 397 of file Mf6FileKeystring.f90.

401 class(KeystringLoadType), intent(inout) :: this
402 integer(I4B), pointer :: nbound => null()
403 integer(I4B), dimension(:), pointer, contiguous :: period_ifno => null()
404 type(CharacterStringType), dimension(:), pointer, contiguous :: &
405 period_setting => null()
406 type(CharacterStringType), dimension(:), pointer, contiguous :: &
407 period_auxname => null()
408 type(CharacterStringType), dimension(:), pointer, contiguous :: &
409 auxnames => null()
410 real(DP), dimension(:, :), pointer, contiguous :: aux => null()
411 real(DP), pointer :: bndElem
412 type(InputParamDefinitionType), pointer :: idt
413 type(TSStringLocType), pointer :: ts_strloc
414 integer(I4B) :: i, n, ifno, jj, isize, naux, nfeatures, sa_icol, k, nts
415 logical(LGP) :: found
416 logical(LGP), dimension(:), allocatable :: handled
417 character(len=LINELENGTH) :: setting, auxname, thisauxname
418 character(len=LENVARNAME) :: ifno_tagname
419
420 call get_isize('AUXILIARY', this%mf6_input%mempath, naux)
421 if (naux <= 0) return
422
423 call get_isize('NBOUND', this%mf6_input%mempath, isize)
424 if (isize < 1) return
425 call mem_setptr(nbound, 'NBOUND', this%mf6_input%mempath)
426 if (nbound <= 0) return
427
428 call get_isize('AUXNAME', this%mf6_input%mempath, isize)
429 if (isize < 1) return
430
431 ! leading column's public tag (e.g. MAWNO for MWE), for the error
432 ! message below -- its memory-manager key is always IFNO (MF6INTERNAL)
433 idt => get_param_definition_type(this%mf6_input%param_dfns, &
434 this%mf6_input%component_type, &
435 this%mf6_input%subcomponent_type, &
436 this%ctx%blockname, &
437 this%param_names(1), &
438 this%input_name)
439 ifno_tagname = trim(idt%tagname)
440
441 ! AUXILIARY dispatch keyword's own mf6varname (e.g. LAK's
442 ! PERIOD_AUXILIARY), since SETTING stores mf6varname, not tagname
443 idt => get_param_definition_type(this%mf6_input%param_dfns, &
444 this%mf6_input%component_type, &
445 this%mf6_input%subcomponent_type, &
446 this%ctx%blockname, 'AUXILIARY', &
447 this%input_name)
448
449 call mem_setptr(period_ifno, 'IFNO', this%mf6_input%mempath)
450 call mem_setptr(period_setting, 'SETTING', this%mf6_input%mempath)
451 call mem_setptr(period_auxname, 'AUXNAME', this%mf6_input%mempath)
452 call mem_setptr(auxnames, 'AUXILIARY', this%mf6_input%mempath)
453 call mem_setptr(aux, 'AUX', this%mf6_input%mempath)
454 nfeatures = size(aux, 2)
455
456 sa_icol = 0
457 do n = 1, this%structarray%count()
458 if (is_auxval(this%structarray%struct_vectors(n)%idt)) then
459 sa_icol = n
460 exit
461 end if
462 end do
463 if (sa_icol == 0) return
464
465 allocate (handled(nbound))
466 handled = .false.
467
468 ! TS-linked rows: resolve AUXNAME here too, same as literal rows
469 nts = this%structarray%struct_vectors(sa_icol)%ts_strlocs%count()
470 do k = 1, nts
471 ts_strloc => this%structarray%struct_vectors(sa_icol)%get_ts_strloc(k)
472 i = ts_strloc%row
473 ifno = period_ifno(i)
474 if (.not. this%valid_address(ifno, nfeatures, ifno_tagname, i)) cycle
475 auxname = period_auxname(i)
476 jj = find_auxname_index(auxname, auxnames, naux)
477 if (jj < 1) cycle
478 thisauxname = auxnames(jj)
479 bndelem => aux(jj, ifno)
480 call read_value_or_time_series_adv(ts_strloc%token, ifno, jj, bndelem, &
481 this%mf6_input%subcomponent_name, &
482 'AUX', this%tsmanager, &
483 this%ctx%iprpak, trim(thisauxname))
484 handled(i) = .true.
485 end do
486
487 ! literal rows: resolve AUXNAME here, clear any stale link, assign
488 do i = 1, nbound
489 if (handled(i)) cycle
490 setting = period_setting(i)
491 if (trim(setting) /= trim(idt%mf6varname)) cycle
492 ifno = period_ifno(i)
493 if (.not. this%valid_address(ifno, nfeatures, ifno_tagname, i)) cycle
494 auxname = period_auxname(i)
495 jj = find_auxname_index(auxname, auxnames, naux)
496 if (jj < 1) cycle
497 thisauxname = auxnames(jj)
498 found = remove_existing_link(this%tsmanager, ifno, jj, &
499 this%mf6_input%subcomponent_name, &
500 'AUX', trim(thisauxname))
501 aux(jj, ifno) = this%structarray%struct_vectors(sa_icol)%dbl1d(i)
502 end do
503 if (count_errors() > 0) then
504 call store_error_filename(this%input_name)
505 end if
506 deallocate (handled)
507 call this%structarray%struct_vectors(sa_icol)%clear()
This module contains the StructVectorModule.
derived type which describes time series string field
Here is the call graph for this function:

◆ apply_items()

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

Definition at line 558 of file Mf6FileKeystring.f90.

561 class(KeystringLoadType), intent(inout) :: this
562 integer(I4B), pointer :: nbound => null()
563 integer(I4B), dimension(:, :), pointer, contiguous :: cellid => null()
564 integer(I4B), dimension(:), pointer, contiguous :: period_ifno => null()
565 type(CharacterStringType), dimension(:), pointer, contiguous :: &
566 period_setting => null()
567 real(DP), dimension(:), pointer, contiguous :: featarr => null()
568 integer(I4B), dimension(:), allocatable :: row_addr
569 integer(I4B) :: i, k, isize, ndim
570 character(len=LINELENGTH) :: setting
571 character(len=LENVARNAME) :: dispatch_key
572 character(len=LENVARNAME) :: leading_tag
573 type(InputParamDefinitionType), pointer :: lead_idt
574
575 if (.not. allocated(this%ctx%keystring_items)) return
576
577 call get_isize('NBOUND', this%mf6_input%mempath, isize)
578 if (isize < 1) return
579 call mem_setptr(nbound, 'NBOUND', this%mf6_input%mempath)
580 if (nbound <= 0) return
581
582 call mem_setptr(period_setting, 'SETTING', this%mf6_input%mempath)
583
584 ! addressing sources, resolved once
585 ndim = 0
586 leading_tag = ''
587 if (this%ctx%keystring_by_node) then
588 if (.not. associated(this%ctx%mshape)) return
589 ndim = size(this%ctx%mshape)
590 call mem_setptr(cellid, 'CELLID', this%mf6_input%mempath)
591 else
592 call mem_setptr(period_ifno, this%ctx%feature_id_varname, &
593 this%mf6_input%mempath)
594 ! leading id column's public tag (e.g. MAWNO), for the out-of-range
595 ! message -- the invalid value is the row's leading id, not the
596 ! setting. Feature-addressed only; node loads validate via CELLID.
597 lead_idt => get_param_definition_type(this%mf6_input%param_dfns, &
598 this%mf6_input%component_type, &
599 this%mf6_input%subcomponent_type, &
600 this%ctx%blockname, &
601 this%param_names(1), &
602 this%input_name)
603 leading_tag = trim(lead_idt%tagname)
604 end if
605
606 do k = 1, size(this%ctx%keystring_items)
607 if (.not. this%ctx%keystring_items(k)%idm_managed) cycle
608 if (this%ctx%keystring_items(k)%addr_mode == addr_subindex) cycle ! separate path
609 if (this%ctx%keystring_items(k)%nfeatures < 1) cycle
610 call mem_setptr(featarr, this%ctx%keystring_items(k)%idt%mf6varname, &
611 this%mf6_input%mempath)
612
613 ! dispatch key: a RECORD body matches its owning head's SETTING
614 ! keyword (the token on the row); a standalone item matches its own
615 ! mf6varname. resolve_row_addr maps the matched row to a feature.
616 if (this%ctx%keystring_items(k)%is_body) then
617 dispatch_key = this%ctx%keystring_items(k)%head_setting_varname
618 else
619 dispatch_key = this%ctx%keystring_items(k)%idt%mf6varname
620 end if
621
622 allocate (row_addr(nbound))
623 do i = 1, nbound
624 row_addr(i) = 0
625 setting = period_setting(i)
626 if (trim(setting) /= trim(dispatch_key)) cycle
627 row_addr(i) = &
628 this%resolve_row_addr(this%ctx%keystring_items(k), i, period_ifno, &
629 cellid, ndim, leading_tag)
630 end do
631 call this%structarray%ts_update_indexed( &
632 this%ctx%keystring_items(k)%sa_icol, this%tsmanager, &
633 this%mf6_input%subcomponent_name, this%ctx%iprpak, nbound, row_addr, &
634 this%ctx%keystring_items(k)%idt%tagname, featarr)
635 deallocate (row_addr)
636 end do
637 if (count_errors() > 0) then
638 call store_error_filename(this%input_name)
639 end if
Here is the call graph for this function:

◆ apply_subindex()

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

Definition at line 515 of file Mf6FileKeystring.f90.

516 class(KeystringLoadType), intent(inout) :: this
517 type(InputParamDefinitionType), pointer :: idt, head_idt
518 real(DP), dimension(:), pointer, contiguous :: featarr => null()
519 integer(I4B), pointer :: nbound => null()
520 integer(I4B), dimension(:), allocatable :: row_addr
521 integer(I4B) :: icol, sa_icol, padj, isize
522
523 if (.not. allocated(this%subindex_nfeatures)) return
524
525 call get_isize('NBOUND', this%mf6_input%mempath, isize)
526 if (isize < 1) return
527 call mem_setptr(nbound, 'NBOUND', this%mf6_input%mempath)
528 if (nbound <= 0) return
529
530 padj = 0
531 if (this%ctx%has_setting_dispatch) padj = 1
532
533 do icol = this%nleading + 1, this%nparam
534 sa_icol = icol + padj
535 if (sa_icol > size(this%subindex_nfeatures)) cycle
536 if (this%subindex_nfeatures(sa_icol) < 1) cycle
537
538 idt => this%structarray%struct_vectors(sa_icol)%idt
539 head_idt => &
540 this%structarray%struct_vectors(this%subindex_head_icol(sa_icol))%idt
541 call mem_setptr(featarr, trim(idt%mf6varname), this%mf6_input%mempath)
542 row_addr = &
543 this%resolve_subindex_address( &
544 this%subindex_id_varname, trim(head_idt%mf6varname), &
545 this%subindex_icol(sa_icol), &
546 this%subindex_offsets(sa_icol)%vals, &
547 this%subindex_nfeatures(sa_icol), nbound)
548 call this%structarray%ts_update_indexed( &
549 sa_icol, this%tsmanager, this%mf6_input%subcomponent_name, &
550 this%ctx%iprpak, nbound, row_addr, trim(idt%tagname), featarr)
551 end do

◆ create_structarray()

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

Definition at line 813 of file Mf6FileKeystring.f90.

815 class(KeystringLoadType), intent(inout) :: this
816 type(InputParamDefinitionType), pointer :: idt
817 integer(I4B) :: icol, sa_icol, nrow_prealloc, nsub, padj
818 logical(LGP) :: has_setting
819
820 has_setting = this%ctx%has_setting_dispatch
821
822 ! use pre-allocated managed memory (maxbound = features * nkeystring_items);
823 ! fall back to deferred shape (-1) if maxbound is unavailable
824 if (associated(this%ctx%maxbound) .and. this%ctx%maxbound > 0) then
825 nrow_prealloc = this%ctx%maxbound
826 else
827 nrow_prealloc = -1
828 end if
829
830 ! SETTING column inserted at nleading+1 when has_setting
831 padj = 0
832 if (has_setting) padj = 1
833
834 if (has_setting .and. nrow_prealloc < 0) then
835 ! fallback for a genuinely unresolvable count (e.g. empty
836 ! PACKAGEDATA), when PACKAGEDATA/DIMENSIONS can't supply one
837 this%structarray => &
838 constructstructarray(this%mf6_input, this%nparam + padj, &
839 nrow_prealloc, 0, this%mf6_input%mempath, &
840 this%mf6_input%component_mempath, size_init=64)
841 else
842 this%structarray => &
843 constructstructarray(this%mf6_input, this%nparam + padj, &
844 nrow_prealloc, 0, this%mf6_input%mempath, &
845 this%mf6_input%component_mempath)
846 end if
847
848 ! create leading (pre-keystring) columns unchanged
849 do icol = 1, this%nleading
850 idt => get_param_definition_type(this%mf6_input%param_dfns, &
851 this%mf6_input%component_type, &
852 this%mf6_input%subcomponent_type, &
853 this%ctx%blockname, &
854 this%param_names(icol), this%input_name)
855 call this%structarray%mem_create_vector(icol, idt)
856 end do
857
858 ! create SETTING column (ctx owns setting_idt)
859 if (has_setting) then
860 sa_icol = this%nleading + 1
861 call this%structarray%mem_create_vector(sa_icol, this%ctx%setting_idt, &
862 charlen=lenvarname)
863 end if
864
865 ! create item columns
866 do icol = this%nleading + 1, this%nparam
867 sa_icol = icol + padj
868 idt => get_param_definition_type(this%mf6_input%param_dfns, &
869 this%mf6_input%component_type, &
870 this%mf6_input%subcomponent_type, &
871 this%ctx%blockname, &
872 this%param_names(icol), this%input_name)
873 ! nsub from descriptor: 0 = direct dispatch, N = KEYWORD compound with N body members
874 nsub = this%ctx%keystring_items(icol - this%nleading)%head_nbody
875 if (nsub > 0) then
876 ! metadata vector: no data allocated; body_start points to next SA col
877 call this%structarray%mem_create_metadata_vector(sa_icol, idt, &
878 sa_icol + 1, nsub)
879 else if (trim(idt%datatype) == 'STRING') then
880 ! string value columns (e.g. STATUS) stored at LENVARNAME
881 call this%structarray%mem_create_vector(sa_icol, idt, &
882 charlen=lenvarname)
883 else if (idt%datatype == 'DOUBLE' .and. &
884 (this%ctx%keystring_items(icol - this%nleading)%idm_managed .or. &
885 this%ctx%keystring_items(icol - this%nleading)%addr_mode == &
886 addr_subindex)) then
887 ! managed/subindex double: raw read array uses the suffixed input
888 ! name, leaving mf6varname for the permanent array the loader populates
889 call this%structarray%mem_create_vector(sa_icol, idt, &
890 varname=idm_input_varname(idt))
891 else
892 call this%structarray%mem_create_vector(sa_icol, idt)
893 end if
894 end do
Here is the call graph for this function:

◆ destroy()

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

Definition at line 796 of file Mf6FileKeystring.f90.

797 class(KeystringLoadType), intent(inout) :: this
798
799 call this%static_loader%cleanup()
800
801 call this%tsmanager%da()
802 deallocate (this%tsmanager)
803 nullify (this%tsmanager)
804
805 if (associated(this%structarray)) then
806 call destructstructarray(this%structarray)
807 end if
808
809 call this%ctx%destroy()
810 call this%DynamicPkgLoadType%destroy()

◆ df()

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

Definition at line 167 of file Mf6FileKeystring.f90.

171 class(KeystringLoadType), intent(inout) :: this
172 type(StructArrayType), pointer :: sa
173 type(CharacterStringType), dimension(:), pointer, contiguous :: &
174 auxnames => null()
175 integer(I4B), dimension(:), pointer, contiguous :: row_key => null()
176 integer(I4B) :: n, naux
177 ! init tsmanager (TDIS now available)
178 call this%tsmanager%tsmanager_df()
179 ! resolve aux names for PACKAGEDATA AUX TS registration
180 call get_isize('AUXILIARY', this%mf6_input%mempath, naux)
181 if (naux > 0) call mem_setptr(auxnames, 'AUXILIARY', this%mf6_input%mempath)
182 ! link static TS strlocs; preserve for re-registration after reset().
183 ! advanced packages address each link by its own block's key column,
184 ! not row position, so a later PERIOD override finds an AUX link and
185 ! listings report the key
186 do n = 1, this%static_loader%ts_sa_count()
187 sa => this%static_loader%get_ts_sa(n)
188 if (.not. associated(sa)) cycle
189 nullify (row_key)
190 if (this%ctx%is_advanced) then
191 ! key columns are hardcoded for now: PACKAGEDATA IFNO and LAK
192 ! OUTLETS OUTLETNO. TODO: look these up from DFN pk/fk metadata
193 select case (sa%struct_vectors(1)%idt%blockname)
194 case ('PACKAGEDATA')
195 call mem_setptr(row_key, 'PACKAGEDATA_IFNO', this%mf6_input%mempath)
196 case ('OUTLETS')
197 call mem_setptr(row_key, 'OUTLETS_OUTLETNO', this%mf6_input%mempath)
198 end select
199 end if
200 if (associated(row_key)) 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., auxname_cst=auxnames, &
205 ifno_map=row_key)
206 else
207 call sa%ts_update(this%tsmanager, &
208 this%mf6_input%subcomponent_name, &
209 this%ctx%iprpak, this%input_name, &
210 clear_strlocs=.false., auxname_cst=auxnames)
211 end if
212 end do
213 ! allocate feature-addressed (DZERO) and node-addressed (DNODATA) items
214 call this%allocate_items()
215 ! subindex df-time dimension fields + permanent arrays
216 if (this%ctx%is_advanced) call this%allocate_subindex()
This module contains the StructArrayModule.
type for structured array
Here is the call graph for this function:

◆ reset()

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

Definition at line 766 of file Mf6FileKeystring.f90.

770 class(KeystringLoadType), intent(inout) :: this
771 type(StructArrayType), pointer :: sa
772 type(CharacterStringType), dimension(:), pointer, contiguous :: &
773 auxnames => null()
774 integer(I4B) :: n, naux
775 ! every KEYSTRING subtype with SETTING dispatch: PERIOD settings
776 ! persist across periods unless reissued, so TS links never reset
777 if (this%ctx%has_setting_dispatch) return
778 ! clear TS links
779 call this%tsmanager%reset(this%mf6_input%subcomponent_name)
780 ! re-register static TS links (strlocs preserved in df)
781 if (this%ts_active) then
782 call get_isize('AUXILIARY', this%mf6_input%mempath, naux)
783 if (naux > 0) call mem_setptr(auxnames, 'AUXILIARY', this%mf6_input%mempath)
784 do n = 1, this%static_loader%ts_sa_count()
785 sa => this%static_loader%get_ts_sa(n)
786 if (associated(sa)) then
787 call sa%ts_update(this%tsmanager, &
788 this%mf6_input%subcomponent_name, &
789 this%ctx%iprpak, this%input_name, &
790 clear_strlocs=.false., auxname_cst=auxnames)
791 end if
792 end do
793 end if
Here is the call graph for this function:

◆ resolve_row_addr()

integer(i4b) function mf6filekeystringmodule::resolve_row_addr ( class(keystringloadtype), intent(inout) this,
type(keystringitemtype), intent(in) item,
integer(i4b), intent(in) irow,
integer(i4b), dimension(:), intent(in), pointer, contiguous period_ifno,
integer(i4b), dimension(:, :), intent(in), pointer, contiguous cellid,
integer(i4b), intent(in) ndim,
character(len=*), intent(in) leading_tag )
private
Parameters
[in]leading_tagleading id column's public tag (for the out-of-range message)

Definition at line 645 of file Mf6FileKeystring.f90.

648 use geomutilmodule, only: get_node
649 class(KeystringLoadType), intent(inout) :: this
650 type(KeystringItemType), intent(in) :: item
651 integer(I4B), intent(in) :: irow
652 integer(I4B), dimension(:), pointer, contiguous, intent(in) :: period_ifno
653 integer(I4B), dimension(:, :), pointer, contiguous, intent(in) :: cellid
654 integer(I4B), intent(in) :: ndim
655 character(len=*), intent(in) :: leading_tag !< leading id column's public tag (for the out-of-range message)
656 integer(I4B) :: addr
657 integer(I4B) :: ifno, nodeu
658
659 addr = 0
660 select case (item%addr_mode)
661 case (addr_feature)
662 ifno = period_ifno(irow)
663 if (.not. this%valid_address(ifno, item%nfeatures, leading_tag, irow)) &
664 return
665 addr = ifno
666 case (addr_node)
667 if (ndim == 1) then
668 nodeu = cellid(1, irow)
669 else if (ndim == 2) then
670 nodeu = get_node(cellid(1, irow), 1, cellid(2, irow), &
671 this%ctx%mshape(1), 1, this%ctx%mshape(2))
672 else
673 nodeu = get_node(cellid(1, irow), cellid(2, irow), cellid(3, irow), &
674 this%ctx%mshape(1), this%ctx%mshape(2), &
675 this%ctx%mshape(3))
676 end if
677 if (nodeu < 1 .or. nodeu > item%nfeatures) return
678 addr = nodeu
679 end select
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
Definition GeomUtil.f90:92
Here is the call graph for this function:

◆ resolve_subindex_address()

integer(i4b) function, dimension(:), allocatable mf6filekeystringmodule::resolve_subindex_address ( class(keystringloadtype), intent(inout) this,
character(len=*), intent(in) id_mf6varname,
character(len=*), intent(in) head_mf6varname,
integer(i4b), intent(in) subindex_icol,
integer(i4b), dimension(:), intent(in) offsets,
integer(i4b), intent(in) nfeatures,
integer(i4b), intent(in) nbound )
private
Parameters
[in]subindex_icolSA column holding the subindex (e.g. IDV)

Definition at line 717 of file Mf6FileKeystring.f90.

720 use simmodule, only: store_error
721 use simvariablesmodule, only: errmsg
722 class(KeystringLoadType), intent(inout) :: this
723 character(len=*), intent(in) :: id_mf6varname
724 character(len=*), intent(in) :: head_mf6varname
725 integer(I4B), intent(in) :: subindex_icol !< SA column holding the subindex (e.g. IDV)
726 integer(I4B), dimension(:), intent(in) :: offsets
727 integer(I4B), intent(in) :: nfeatures
728 integer(I4B), intent(in) :: nbound
729 integer(I4B), dimension(:), allocatable :: row_addr
730 integer(I4B), dimension(:), pointer, contiguous :: period_ifno => null()
731 type(CharacterStringType), dimension(:), pointer, contiguous :: &
732 period_setting => null()
733 integer(I4B) :: i, ifno, idx_local, nlocal
734 character(len=LINELENGTH) :: setting
735 character(len=LENVARNAME) :: id_tag, idx_tag
736
737 call mem_setptr(period_ifno, id_mf6varname, this%mf6_input%mempath)
738 call mem_setptr(period_setting, 'SETTING', this%mf6_input%mempath)
739 id_tag = trim(this%structarray%struct_vectors(1)%idt%tagname)
740 idx_tag = trim(this%structarray%struct_vectors(subindex_icol)%idt%tagname)
741 allocate (row_addr(nbound))
742 do i = 1, nbound
743 row_addr(i) = 0
744 setting = period_setting(i)
745 if (trim(setting) /= trim(head_mf6varname)) cycle
746 ifno = period_ifno(i)
747 if (ifno < 1 .or. ifno > size(offsets)) cycle
748 ! per-id local count from the cumulative offset table
749 if (ifno < size(offsets)) then
750 nlocal = offsets(ifno + 1) - offsets(ifno)
751 else
752 nlocal = nfeatures - offsets(ifno) + 1
753 end if
754 idx_local = this%structarray%struct_vectors(subindex_icol)%int1d(i)
755 if (idx_local < 1 .or. idx_local > nlocal) then
756 write (errmsg, '(a,1x,a,1x,i0,1x,a,1x,i0,1x,a,1x,a,1x,i0,a)') &
757 'index', trim(idx_tag), idx_local, 'must be between 1 and', nlocal, &
758 'for', trim(id_tag), ifno, '.'
759 call store_error(errmsg)
760 cycle
761 end if
762 row_addr(i) = offsets(ifno) + idx_local - 1
763 end do
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
Here is the call graph for this function:

◆ resolve_subindex_offsets()

integer(i4b) function, dimension(:), allocatable mf6filekeystringmodule::resolve_subindex_offsets ( class(keystringloadtype), intent(inout) this,
character(len=*), intent(in) dimname )
private

Definition at line 686 of file Mf6FileKeystring.f90.

687 class(KeystringLoadType), intent(inout) :: this
688 character(len=*), intent(in) :: dimname
689 integer(I4B), dimension(:), allocatable :: offsets
690 integer(I4B), dimension(:), pointer, contiguous :: counts_raw => null()
691 integer(I4B), dimension(:), pointer, contiguous :: pkg_ifno => null()
692 integer(I4B), dimension(:), allocatable :: counts
693 integer(I4B) :: i, n, running, ndomain
694
695 call mem_setptr(counts_raw, trim(dimname), this%mf6_input%mempath)
696 call mem_setptr(pkg_ifno, 'PACKAGEDATA_IFNO', this%mf6_input%mempath)
697 ndomain = size(counts_raw)
698 allocate (counts(ndomain))
699 counts = 0
700 do i = 1, size(counts_raw)
701 n = pkg_ifno(i)
702 if (n < 1 .or. n > ndomain) cycle
703 counts(n) = counts_raw(i)
704 end do
705
706 allocate (offsets(ndomain))
707 running = 1
708 do n = 1, ndomain
709 offsets(n) = running
710 running = running + counts(n)
711 end do

◆ rp()

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

Definition at line 224 of file Mf6FileKeystring.f90.

226 class(KeystringLoadType), intent(inout) :: this
227 type(BlockParserType), pointer, intent(inout) :: parser
228
229 call this%reset()
230
231 call idm_log_header(this%mf6_input%component_name, &
232 this%mf6_input%subcomponent_name, this%iout)
233
234 this%ctx%nbound = &
235 this%structarray%read_from_parser_keystring(parser, this%ts_active, &
236 this%nleading, this%iout, &
237 this%input_name)
238
239 if (this%ctx%is_advanced) call this%apply_auxiliary()
240 if (this%ctx%is_advanced) call this%apply_subindex()
241 ! apply feature- and node-addressed items
242 call this%apply_items()
243
244 if (this%ts_active) then
245 call this%structarray%ts_update(this%tsmanager, &
246 this%mf6_input%subcomponent_name, &
247 this%ctx%iprpak, this%input_name)
248 end if
249
250 call idm_log_close(this%mf6_input%component_name, &
251 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)
log the closing message
Definition IdmLogger.f90:56
subroutine, public idm_log_header(component, subcomponent, iout)
log a header message
Definition IdmLogger.f90:44
Here is the call graph for this function:

◆ ts_advance()

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

Definition at line 219 of file Mf6FileKeystring.f90.

220 class(KeystringLoadType), intent(inout) :: this
221 call this%tsmanager%ad()

◆ valid_address()

logical(lgp) function mf6filekeystringmodule::valid_address ( class(keystringloadtype), intent(inout) this,
integer(i4b), intent(in) ifno,
integer(i4b), intent(in) nfeatures,
character(len=*), intent(in) ifno_tagname,
integer(i4b), intent(in) row )
private

Definition at line 374 of file Mf6FileKeystring.f90.

375 use simmodule, only: store_error
376 use simvariablesmodule, only: errmsg
377 class(KeystringLoadType), intent(inout) :: this
378 integer(I4B), intent(in) :: ifno
379 integer(I4B), intent(in) :: nfeatures
380 character(len=*), intent(in) :: ifno_tagname
381 integer(I4B), intent(in) :: row
382 logical(LGP) :: valid
383
384 valid = (ifno >= 1 .and. ifno <= nfeatures)
385 if (.not. valid) then
386 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,a)') &
387 trim(ifno_tagname), ifno, 'on row', row, &
388 'must be greater than 0 and less than or equal to', nfeatures, '.'
389 call store_error(errmsg)
390 end if
Here is the call graph for this function: