MODFLOW 6  version 6.9.0.dev0
USGS Modular Hydrologic Model
loadcontextmodule Module Reference

Load context for IDM generic dynamic loaders. More...

Data Types

type  readstatevartype
 Pointer type for read state variable. More...
 
interface  setptr
 
type  keystringitemtype
 One descriptor per expanded keystring item, so loaders iterate uniformly instead of re-deriving per-mode state. More...
 
type  loadcontexttype
 Input load context for generic dynamic loaders and StructArray based static loads. Classifies the input, determines in-scope parameters, and manages memory-manager scalars and array pointers. More...
 

Enumerations

enum  {
  load_undef = 0 , list = 1 , layerarray = 2 , gridarray = 3 ,
  keystring = 4
}
 

Functions/Subroutines

subroutine init (this, mf6_input, blockname, named_bound)
 Initialize the load context. More...
 
subroutine resolve_context (this)
 Set context flags from input load_scope and component metadata. More...
 
subroutine resolve_loadtype (this)
 Determine loadtype from block and param definitions. More...
 
subroutine resolve_dimensions (this)
 Resolve dimension scalars and scale keystring maxbound. More...
 
subroutine scale_keystring_maxbound (this)
 Scale maxbound (a feature or node count) by the number of KEYSTRING items, so every feature can use every setting in one period. More...
 
subroutine allocate_arrays (this)
 allocate arrays More...
 
subroutine allocate_param (this, idt)
 allocate a package dynamic input parameter More...
 
subroutine allocate_params (this)
 Allocate each in-scope parameter in the memory manager. More...
 
logical(lgp) function in_scope (this, tagname)
 Return .true. if an optional parameter is active for this load. Required/structural params are handled by the caller; generic conditions are checked first, then package-specific ones by subcomponent_type. More...
 
logical(lgp) function subindex_dependency (this, tagname, dimname, subindex_tagname)
 Hardcoded per-package dependency for a subindex param with no SHAPE of its own – same category of special-casing as in_scope, for a dimension name and subindex field instead. More...
 
logical(lgp) function option_check (this, varname, threshold)
 Return .true. if a memory-manager integer option variable exceeds a threshold. More...
 
subroutine build_keystring_items (this)
 Build the per-item descriptor table, the single source of truth for how each keystring item is allocated and applied. More...
 
integer(i4b) function resolve_nfeatures (this)
 Resolve the permanent array's feature count. The explicit DIMENSIONS dimension (named_bound) is authoritative when present; PACKAGEDATA row count is the fallback. Both present and disagreeing is an error. More...
 
integer(i4b) function resolve_item_nfeatures (this, item_tagname, dimname, default_nfeatures)
 Per-item feature count from a named dimension, falling back to default_nfeatures if unset. Populated-then-released is an error. More...
 
logical(lgp) function shape_param_is_array (this, shape_varname)
 Is shape_varname a per-feature array (PACKAGEDATA) rather than a package-wide scalar (DIMENSIONS)? More...
 
subroutine set_params (this)
 set set of in scope parameters for package More...
 
character(len=lenvarname) function rsv_alloc (this, mf6varname)
 allocate a read state variable More...
 
subroutine destroy (this)
 destroy input context object More...
 
type(inputparamdefinitiontype) function, pointer find_setting_aggregate (mf6_input, rec_cols, nrec_col)
 Return the KEYSTRING aggregate for the SETTING token in rec_cols, or null(). More...
 
subroutine expand_record_body (mf6_input, rec_idt, item_names, nkeystring_items)
 Append body column names from a RECORD compound entry to item_names. More...
 
logical(lgp) function, public is_keystring_period (mf6_input)
 Return .true. if mf6_input's PERIOD block uses keystring dispatch. More...
 
logical(lgp) function, public is_feature_keystring (mf6_input)
 .true. if mf6_input's PERIOD block is feature-addressed (see is_feature_tag). Block-independent, unlike LoadContextType's own keystring_by_feature, which is only valid for a PERIOD-scoped instance. More...
 
logical(lgp) function is_feature_tag (tagname)
 .true. if tagname is a record's leading id column (IFNO and its legacy package-specific aliases). Single source for both resolve_loadtype and is_feature_keystring. More...
 
logical(lgp) function, public is_advanced (mf6_input)
 Return .true. if mf6_input is an advanced package. More...
 
subroutine keystring_item_names (this, item_names, head_nbody, item_is_body, nkeystring_items)
 Return keystring item column names, per-head body counts, and body flags. A RECORD group's trailing columns are body members; its head and any direct-dispatch param are not. More...
 
subroutine check_developmode (this, input_name)
 Check whether any in-scope parameter is a development-mode feature. More...
 
character(len=lenvarname) function, public rsv_name (mf6varname)
 create read state variable name More...
 
subroutine allocate_int1d (nrow, varname, mempath)
 allocate int1d More...
 
subroutine allocate_dbl1d (nrow, varname, mempath)
 allocate dbl1d More...
 
subroutine allocate_dbl2d (ncol, nrow, varname, mempath)
 allocate dbl2d More...
 
subroutine setval (intptr, varname, mempath)
 allocate intptr and update from input context More...
 
subroutine setptr_int (intptr, varname, mempath)
 set intptr to varname More...
 
subroutine setptr_charstr1d (charstr1d, varname, mempath, strlen)
 set charstr1d pointer to varname More...
 
subroutine setptr_auxvar (auxvar, mempath)
 set auxvar pointer More...
 

Variables

integer(i4b), parameter, public addr_none = 0
 not an applied setting More...
 
integer(i4b), parameter, public addr_feature = 1
 addressed by leading id (IFNO/BNDNO) More...
 
integer(i4b), parameter, public addr_node = 2
 addressed by CELLID More...
 
integer(i4b), parameter, public addr_subindex = 3
 addressed by (id, subindex) More...
 

Detailed Description

LoadContextType classifies each input, builds the in-scope parameter list for the active block, and manages memory-manager dimension scalars and array pointers. It is used by all dynamic loaders: ListLoadType, KeystringLoadType, LayerArrayLoadType, GridArrayLoadType, and StructArray-based static loads.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
load_undef 

undefined load type

list 

list load

layerarray 

readasarrays load

gridarray 

readarraygrid load

keystring 

keystring period block load

Definition at line 31 of file LoadContext.f90.

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine loadcontextmodule::allocate_arrays ( class(loadcontexttype)  this)
private

Call after input parameters are allocated: after load_params() with create for array-based loaders, or after all mem_create_vector() calls for list-based load.

Definition at line 343 of file LoadContext.f90.

345  class(LoadContextType) :: this
346  integer(I4B), dimension(:, :), pointer, contiguous :: cellid
347  integer(I4B), dimension(:), pointer, contiguous :: nodeulist
348 
349  if (this%set_mshape .and. &
350  this%blockname == 'PERIOD') then
351  ! allocate cellid if this is not list input
352  if (this%loadtype == layerarray .or. &
353  this%loadtype == gridarray) then
354  call mem_allocate(cellid, 0, 0, 'CELLID', this%mf6_input%mempath)
355  end if
356 
357  ! allocate nodeulist for list and layerarray packages only;
358  ! keystring and advanced packages do not use a flat nodeulist
359  if (this%loadtype /= gridarray .and. &
360  this%loadtype /= keystring) then
361  call mem_allocate(nodeulist, 0, 'NODEULIST', this%mf6_input%mempath)
362  end if
363 
364  ! set pointers to aux/bound arrays for non-keystring packages;
365  ! keystring packages manage aux through struct array columns
366  if (this%loadtype /= keystring) then
367  call setptr(this%auxname_cst, 'AUXILIARY', &
368  this%mf6_input%mempath, lenauxname)
369  call setptr(this%boundname_cst, 'BOUNDNAME', &
370  this%mf6_input%mempath, lenboundname)
371  call setptr(this%auxvar, this%mf6_input%mempath)
372  end if
373 
374  else if (this%is_exchange) then
375  ! set pointers to arrays
376  call setptr(this%auxname_cst, 'AUXILIARY', &
377  this%mf6_input%mempath, lenauxname)
378  call setptr(this%boundname_cst, 'BOUNDNAME', &
379  this%mf6_input%mempath, lenboundname)
380  call setptr(this%auxvar, this%mf6_input%mempath)
381  end if
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
Here is the call graph for this function:

◆ allocate_dbl1d()

subroutine loadcontextmodule::allocate_dbl1d ( integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  mempath 
)
Parameters
[in]nrowinteger array number of rows
[in]varnamevariable name
[in]mempathvariable mempath

Definition at line 1235 of file LoadContext.f90.

1237  integer(I4B), intent(in) :: nrow !< integer array number of rows
1238  character(len=*), intent(in) :: varname !< variable name
1239  character(len=*), intent(in) :: mempath !< variable mempath
1240  real(DP), dimension(:), pointer, contiguous :: dbl1d
1241  integer(I4B) :: n
1242  call mem_allocate(dbl1d, nrow, varname, mempath)
1243  do n = 1, nrow
1244  dbl1d(n) = dzero
1245  end do
Here is the caller graph for this function:

◆ allocate_dbl2d()

subroutine loadcontextmodule::allocate_dbl2d ( integer(i4b), intent(in)  ncol,
integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  mempath 
)
Parameters
[in]ncolinteger array number of cols
[in]nrowinteger array number of rows
[in]varnamevariable name
[in]mempathvariable mempath

Definition at line 1250 of file LoadContext.f90.

1252  integer(I4B), intent(in) :: ncol !< integer array number of cols
1253  integer(I4B), intent(in) :: nrow !< integer array number of rows
1254  character(len=*), intent(in) :: varname !< variable name
1255  character(len=*), intent(in) :: mempath !< variable mempath
1256  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
1257  integer(I4B) :: n, m
1258  call mem_allocate(dbl2d, ncol, nrow, varname, mempath)
1259  do m = 1, nrow
1260  do n = 1, ncol
1261  dbl2d(n, m) = dzero
1262  end do
1263  end do
Here is the caller graph for this function:

◆ allocate_int1d()

subroutine loadcontextmodule::allocate_int1d ( integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  mempath 
)
Parameters
[in]nrowinteger array number of rows
[in]varnamevariable name
[in]mempathvariable mempath

Definition at line 1220 of file LoadContext.f90.

1222  integer(I4B), intent(in) :: nrow !< integer array number of rows
1223  character(len=*), intent(in) :: varname !< variable name
1224  character(len=*), intent(in) :: mempath !< variable mempath
1225  integer(I4B), dimension(:), pointer, contiguous :: int1d
1226  integer(I4B) :: n
1227  call mem_allocate(int1d, nrow, varname, mempath)
1228  do n = 1, nrow
1229  int1d(n) = izero
1230  end do
Here is the caller graph for this function:

◆ allocate_param()

subroutine loadcontextmodule::allocate_param ( class(loadcontexttype)  this,
type(inputparamdefinitiontype), pointer  idt 
)

Called only from allocate_params(), itself called only by the LAYERARRAY/GRIDARRAY loaders – thisloadtype is never LIST here.

Definition at line 389 of file LoadContext.f90.

391  class(LoadContextType) :: this
392  type(InputParamDefinitionType), pointer :: idt
393  integer(I4B) :: dimsize
394 
395  ! initialize
396  dimsize = 0
397 
398  if (this%loadtype == layerarray .or. &
399  this%loadtype == gridarray) then
400  select case (idt%shape)
401  case ('NCPL', 'NAUX NCPL')
402  dimsize = this%ncpl
403  case ('NODES', 'NAUX NODES')
404  dimsize = this%maxbound
405  case default
406  end select
407  end if
408 
409  select case (idt%datatype)
410  case ('INTEGER1D')
411  if (this%loadtype == layerarray .or. &
412  this%loadtype == gridarray) then
413  call allocate_int1d(dimsize, idt%mf6varname, &
414  this%mf6_input%mempath)
415  end if
416  case ('DOUBLE1D')
417  if (idt%shape == 'NAUX') then
418  call allocate_dbl2d(this%naux, this%maxbound, &
419  idt%mf6varname, this%mf6_input%mempath)
420  else if (this%loadtype == layerarray .or. &
421  this%loadtype == gridarray) then
422  call allocate_dbl1d(dimsize, idt%mf6varname, &
423  this%mf6_input%mempath)
424  end if
425  case ('DOUBLE2D')
426  if (this%loadtype == layerarray .or. &
427  this%loadtype == gridarray) then
428  call allocate_dbl2d(this%naux, dimsize, idt%mf6varname, &
429  this%mf6_input%mempath)
430  end if
431  case default
432  end select
Input definition module.
Input parameter definition. Describes an input parameter.
Here is the call graph for this function:

◆ allocate_params()

subroutine loadcontextmodule::allocate_params ( class(loadcontexttype)  this)

Call after init() for array-based loaders (LAYERARRAY, GRIDARRAY) that need memory-manager storage allocated for every in-scope parameter. Loaders access thisparams and size(thisparams) directly.

Definition at line 441 of file LoadContext.f90.

443  class(LoadContextType) :: this
444  type(InputParamDefinitionType), pointer :: idt
445  integer(I4B) :: n
446  do n = 1, size(this%params)
447  idt => get_param_definition_type(this%mf6_input%param_dfns, &
448  this%mf6_input%component_type, &
449  this%mf6_input%subcomponent_type, &
450  this%blockname, this%params(n), '')
451  call this%allocate_param(idt)
452  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:

◆ build_keystring_items()

subroutine loadcontextmodule::build_keystring_items ( class(loadcontexttype)  this)

Definition at line 587 of file LoadContext.f90.

589  class(LoadContextType) :: this
590  type(InputParamDefinitionType), pointer :: idt
591  integer(I4B) :: icol, k, padj, nfeatures, nkeystring_items
592  character(len=LENVARNAME) :: dimname, subindex_tagname
593  logical(LGP) :: found, node
594  character(len=LINELENGTH), allocatable :: item_names(:)
595  integer(I4B), allocatable :: head_nbody(:)
596  logical(LGP), allocatable :: item_is_body(:)
597  character(len=LENVARNAME) :: cur_head !< most recent head's SETTING keyword
598 
599  if (.not. this%has_setting_dispatch) return
600 
601  ! derive per-item metadata (single computation; not stored as ctx state)
602  call this%keystring_item_names(item_names, head_nbody, item_is_body, &
603  nkeystring_items)
604  if (nkeystring_items < 1) return
605 
606  ! generic leading-id address varname (feature-addressed packages,
607  ! advanced or not, e.g. SPC): the leading column's mf6varname.
608  if (this%keystring_by_feature) then
609  idt => get_param_definition_type(this%mf6_input%param_dfns, &
610  this%mf6_input%component_type, &
611  this%mf6_input%subcomponent_type, &
612  this%blockname, this%params(1), '')
613  this%feature_id_varname = trim(idt%mf6varname)
614  end if
615 
616  padj = 1 ! SETTING column present whenever has_setting_dispatch
617  node = this%keystring_by_node
618 
619  allocate (this%keystring_items(nkeystring_items))
620  nfeatures = this%resolve_nfeatures()
621  cur_head = ''
622 
623  do icol = this%nleading + 1, size(this%params)
624  k = icol - this%nleading
625  idt => get_param_definition_type(this%mf6_input%param_dfns, &
626  this%mf6_input%component_type, &
627  this%mf6_input%subcomponent_type, &
628  this%blockname, this%params(icol), '')
629  this%keystring_items(k)%idt => idt
630  this%keystring_items(k)%sa_icol = icol + padj
631  this%keystring_items(k)%is_body = item_is_body(k)
632  this%keystring_items(k)%head_nbody = head_nbody(k)
633 
634  ! track the current record head's SETTING keyword; a body dispatches
635  ! on its owning head's keyword (the SETTING token on the input row),
636  ! not on its own mf6varname.
637  if (.not. this%keystring_items(k)%is_body) then
638  if (this%keystring_items(k)%head_nbody > 0) then
639  cur_head = trim(idt%mf6varname) ! opening a RECORD
640  else
641  cur_head = '' ! standalone item; not a record head
642  end if
643  else
644  this%keystring_items(k)%head_setting_varname = trim(cur_head)
645  end if
646 
647  ! managed only for DOUBLE + timeseries standalone settings, which
648  ! require a permanent array for cross-period timeseries persistence.
649  this%keystring_items(k)%idm_managed = &
650  (idt%datatype == 'DOUBLE' .and. idt%timeseries .and. &
651  .not. this%keystring_items(k)%is_body)
652 
653  if (this%keystring_items(k)%idm_managed) then
654  if (node) then
655  this%keystring_items(k)%addr_mode = addr_node
656  this%keystring_items(k)%init_value = dnodata
657  if (associated(this%nodes)) &
658  this%keystring_items(k)%nfeatures = this%nodes
659  else
660  this%keystring_items(k)%addr_mode = addr_feature
661  this%keystring_items(k)%init_value = dzero
662  this%keystring_items(k)%nfeatures = &
663  this%resolve_item_nfeatures(idt%tagname, idt%shape, nfeatures)
664  end if
665  end if
666 
667  ! subindex (SFR DIVFLOW): classify here; df-time fields
668  ! (index_icol/head_icol/offsets/nfeatures) are completed in df().
669  if (this%is_advanced .and. this%keystring_items(k)%is_body) then
670  found = this%subindex_dependency(idt%tagname, dimname, &
671  subindex_tagname)
672  if (found) then
673  this%keystring_items(k)%addr_mode = addr_subindex
674  this%keystring_items(k)%idm_managed = .true.
675  end if
676  end if
677  end do
Here is the call graph for this function:

◆ check_developmode()

subroutine loadcontextmodule::check_developmode ( class(loadcontexttype)  this,
character(len=*), intent(in)  input_name 
)

Definition at line 1177 of file LoadContext.f90.

1178  use featureflagsmodule, only: developmode
1179  use simvariablesmodule, only: iout
1181  class(LoadContextType) :: this
1182  character(len=*), intent(in) :: input_name
1183  type(InputParamDefinitionType), pointer :: idt
1184  character(len=LINELENGTH) :: dev_msg
1185  integer(I4B) :: n
1186 
1187  do n = 1, size(this%params)
1188  idt => get_param_definition_type(this%mf6_input%param_dfns, &
1189  this%mf6_input%component_type, &
1190  this%mf6_input%subcomponent_type, &
1191  this%blockname, this%params(n), '')
1192  if (idt%developmode) then
1193  dev_msg = 'Input tag "'//trim(idt%tagname)// &
1194  &'" read from file "'//trim(input_name)// &
1195  &'" is still under development. Install the &
1196  &nightly build or compile from source with IDEVELOPMODE = 1.'
1197  call developmode(dev_msg, iout)
1198  end if
1199  end do
Disable development features in release mode.
Definition: FeatureFlags.f90:2
subroutine, public developmode(errmsg, iunit)
Terminate if in release mode (guard development features)
This module contains simulation variables.
Definition: SimVariables.f90:9
integer(i4b) iout
file unit number for simulation output
Here is the call graph for this function:

◆ destroy()

subroutine loadcontextmodule::destroy ( class(loadcontexttype)  this)

Definition at line 916 of file LoadContext.f90.

917  class(LoadContextType) :: this
918 
919  if (associated(this%setting_idt)) then
920  deallocate (this%setting_idt)
921  nullify (this%setting_idt)
922  end if
923 
924  if (this%set_scalars) then
925  ! deallocate local
926  deallocate (this%naux)
927  deallocate (this%ncpl)
928  deallocate (this%nodes)
929  deallocate (this%maxbound)
930  deallocate (this%boundnames)
931  deallocate (this%iprpak)
932  end if
933 
934  ! nullify
935  nullify (this%naux)
936  nullify (this%nbound)
937  nullify (this%ncpl)
938  nullify (this%nodes)
939  nullify (this%maxbound)
940  nullify (this%boundnames)
941  nullify (this%iprpak)
942  nullify (this%auxname_cst)
943  nullify (this%boundname_cst)
944  nullify (this%auxvar)
945  nullify (this%mshape)

◆ expand_record_body()

subroutine loadcontextmodule::expand_record_body ( type(modflowinputtype), intent(in)  mf6_input,
type(inputparamdefinitiontype), intent(in), pointer  rec_idt,
character(len=linelength), dimension(:), intent(inout), allocatable  item_names,
integer(i4b), intent(inout)  nkeystring_items 
)

Definition at line 982 of file LoadContext.f90.

983  use inputoutputmodule, only: upcase
986  type(ModflowInputType), intent(in) :: mf6_input
987  type(InputParamDefinitionType), pointer, intent(in) :: rec_idt
988  character(len=LINELENGTH), allocatable, intent(inout) :: item_names(:)
989  integer(I4B), intent(inout) :: nkeystring_items
990  type(InputParamDefinitionType), pointer :: sub_idt
991  character(len=LINELENGTH), allocatable :: sub_cols(:)
992  character(len=LINELENGTH) :: token, tagname
993  integer(I4B) :: k, j, nsub_col
994  call idt_parse_rectype(rec_idt, sub_cols, nsub_col)
995  do k = 1, nsub_col
996  token = trim(sub_cols(k))
997  call upcase(token)
998  do j = 1, size(mf6_input%param_dfns)
999  sub_idt => mf6_input%param_dfns(j)
1000  if (sub_idt%blockname /= 'PERIOD') cycle
1001  tagname = sub_idt%tagname
1002  call upcase(tagname)
1003  if (trim(tagname) /= trim(token)) cycle
1004  if (idt_datatype(sub_idt) == 'RECORD') cycle
1005  nkeystring_items = nkeystring_items + 1
1006  call expandarray(item_names)
1007  item_names(nkeystring_items) = trim(sub_idt%tagname)
1008  exit
1009  end do
1010  end do
1011  if (allocated(sub_cols)) deallocate (sub_cols)
subroutine, public idt_parse_rectype(idt, cols, ncol)
allocate and set RECARRAY, KEYSTRING or RECORD param list
character(len=linelength) function, public idt_datatype(idt)
return input definition type datatype
subroutine, public upcase(word)
Convert to upper case.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_setting_aggregate()

type(inputparamdefinitiontype) function, pointer loadcontextmodule::find_setting_aggregate ( type(modflowinputtype), intent(in)  mf6_input,
character(len=linelength), dimension(:), intent(in)  rec_cols,
integer(i4b), intent(in)  nrec_col 
)
private

Definition at line 950 of file LoadContext.f90.

951  use inputoutputmodule, only: upcase
953  type(ModflowInputType), intent(in) :: mf6_input
954  character(len=LINELENGTH), intent(in) :: rec_cols(:)
955  integer(I4B), intent(in) :: nrec_col
956  type(InputParamDefinitionType), pointer :: ks_aidt
957  character(len=LINELENGTH) :: token, tagname
958  integer(I4B) :: m, n, ilen
959  ks_aidt => null()
960  do m = 1, nrec_col
961  token = trim(rec_cols(m))
962  call upcase(token)
963  ilen = len_trim(token)
964  ! minimum 8 chars: a valid XSETTING token is at least 1 char prefix + 7 for 'SETTING'
965  if (ilen < 8) cycle
966  if (token(ilen - 6:ilen) /= 'SETTING') cycle
967  do n = 1, size(mf6_input%aggregate_dfns)
968  tagname = mf6_input%aggregate_dfns(n)%tagname
969  call upcase(tagname)
970  if (trim(tagname) == trim(token)) then
971  ks_aidt => mf6_input%aggregate_dfns(n)
972  if (idt_datatype(ks_aidt) /= 'KEYSTRING') ks_aidt => null()
973  exit
974  end if
975  end do
976  exit
977  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ in_scope()

logical(lgp) function loadcontextmodule::in_scope ( class(loadcontexttype)  this,
character(len=*), intent(in)  tagname 
)

Definition at line 460 of file LoadContext.f90.

462  class(LoadContextType) :: this
463  character(len=*), intent(in) :: tagname
464  logical(LGP) :: in_scope
465  type(InputParamDefinitionType), pointer :: idt
466  character(len=LINELENGTH) :: datatype
467 
468  idt => get_param_definition_type(this%mf6_input%param_dfns, &
469  this%mf6_input%component_type, &
470  this%mf6_input%subcomponent_type, &
471  this%blockname, tagname, '')
472  ! required params are always in scope
473  if (idt%required) then
474  in_scope = .true.
475  return
476  else
477  in_scope = .false.
478  end if
479 
480  ! structural container types are never loaded as leaf params
481  datatype = idt_datatype(idt)
482  if (datatype == 'KEYSTRING' .or. &
483  datatype == 'RECARRAY' .or. &
484  datatype == 'RECORD') return
485 
486  ! advanced packages: every optional leaf param is in scope
487  if (this%is_advanced) then
488  in_scope = .true.
489  return
490  end if
491 
492  ! --- generic conditions ---
493  if (tagname == 'AUXVAR' .or. tagname == 'AUX') then
494  in_scope = this%option_check('NAUX', 0)
495  return
496  end if
497 
498  if (tagname == 'BOUNDNAME') then
499  in_scope = this%option_check('BOUNDNAMES', 0)
500  return
501  end if
502 
503  ! readarray indicator variable (e.g. IRCH, IRET): in scope for LAYERARRAY only
504  if (tagname == 'I'//trim(this%mf6_input%subcomponent_type(1:3))) then
505  in_scope = (this%loadtype == layerarray)
506  return
507  end if
508 
509  ! --- package-specific conditions ---
510  select case (this%mf6_input%subcomponent_type)
511  case ('EVT')
512  if (tagname == 'PXDP' .or. tagname == 'PETM') then
513  in_scope = this%option_check('NSEG', 1)
514  else if (tagname == 'PETM0') then
515  in_scope = this%option_check('SURFRATESPEC', 0)
516  end if
517  case ('MVR', 'MVT', 'MVE')
518  if (tagname == 'MNAME' .or. &
519  tagname == 'MNAME1' .or. &
520  tagname == 'MNAME2') then
521  in_scope = this%option_check('MODELNAMES', 0)
522  end if
523  case ('NAM')
524  in_scope = .true.
525  case ('SSM')
526  if (tagname == 'MIXED') in_scope = .true.
527  case ('SPC', 'SPCA')
528  in_scope = .true.
529  case ('SFRTAB')
530  ! MANFRACTION present only when NCOL=3 (2 base columns otherwise)
531  if (tagname == 'MANFRACTION') in_scope = this%option_check('NCOL', 2)
532  case default
533  ! unrecognized subcomponent with an optional param not handled
534  ! above is a development error -- abort so the gap is visible
535  errmsg = 'LoadContext in_scope needs new case for: '// &
536  trim(this%mf6_input%subcomponent_type)//'/'//trim(tagname)
537  call store_error(errmsg, .true.)
538  end select
Here is the call graph for this function:

◆ init()

subroutine loadcontextmodule::init ( class(loadcontexttype)  this,
type(modflowinputtype), intent(in)  mf6_input,
character(len=*), intent(in), optional  blockname,
character(len=*), intent(in), optional  named_bound 
)
private

Classifies the input, builds the in-scope parameter list, and resolves memory-manager dimension scalars.

Definition at line 143 of file LoadContext.f90.

144  use inputoutputmodule, only: upcase
145  class(LoadContextType) :: this
146  type(ModflowInputType), intent(in) :: mf6_input
147  character(len=*), optional, intent(in) :: blockname
148  character(len=*), optional, intent(in) :: named_bound
149 
150  this%mf6_input = mf6_input
151 
152  if (present(blockname)) then
153  this%blockname = blockname
154  call upcase(this%blockname)
155  else
156  this%blockname = 'PERIOD'
157  end if
158 
159  if (present(named_bound)) then
160  this%named_bound = named_bound
161  call upcase(this%named_bound)
162  else
163  this%named_bound = 'MAXBOUND'
164  end if
165 
166  call this%resolve_context()
167  call this%resolve_loadtype()
168  call this%set_params()
169  call this%resolve_dimensions()
170  ! build the per-item descriptor table (keystring only)
171  if (this%loadtype == keystring) call this%build_keystring_items()
Here is the call graph for this function:

◆ is_advanced()

logical(lgp) function, public loadcontextmodule::is_advanced ( type(modflowinputtype), intent(in)  mf6_input)

Definition at line 1084 of file LoadContext.f90.

1085  type(ModflowInputType), intent(in) :: mf6_input
1086  logical(LGP) :: res
1087  res = idm_is_advanced(mf6_input%component_type, mf6_input%subcomponent_type)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_feature_keystring()

logical(lgp) function, public loadcontextmodule::is_feature_keystring ( type(modflowinputtype), intent(in)  mf6_input)

Definition at line 1048 of file LoadContext.f90.

1051  type(ModflowInputType), intent(in) :: mf6_input
1052  logical(LGP) :: res
1053  type(InputParamDefinitionType), pointer :: aidt
1054  character(len=LINELENGTH), allocatable :: cols(:)
1055  integer(I4B) :: ncol
1056  res = .false.
1057  if (.not. is_keystring_period(mf6_input)) return
1058  aidt => get_aggregate_definition_type(mf6_input%aggregate_dfns, &
1059  mf6_input%component_type, &
1060  mf6_input%subcomponent_type, &
1061  'PERIOD')
1062  call idt_parse_rectype(aidt, cols, ncol)
1063  res = is_feature_tag(cols(1))
1064  if (allocated(cols)) deallocate (cols)
type(inputparamdefinitiontype) function, pointer, public get_aggregate_definition_type(input_definition_types, component_type, subcomponent_type, blockname)
Return aggregate definition.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_feature_tag()

logical(lgp) function loadcontextmodule::is_feature_tag ( character(len=*), intent(in)  tagname)

Definition at line 1071 of file LoadContext.f90.

1072  character(len=*), intent(in) :: tagname
1073  logical(LGP) :: res
1074  select case (tagname)
1075  case ('IFNO', 'NUMBER', 'BNDNO', 'RNO', 'LAKENO', 'MAWNO', 'UZFNO')
1076  res = .true.
1077  case default
1078  res = .false.
1079  end select
Here is the caller graph for this function:

◆ is_keystring_period()

logical(lgp) function, public loadcontextmodule::is_keystring_period ( type(modflowinputtype), intent(in)  mf6_input)

Definition at line 1016 of file LoadContext.f90.

1019  type(ModflowInputType), intent(in) :: mf6_input
1020  logical(LGP) :: res, has_period
1021  type(InputParamDefinitionType), pointer :: aidt, ks_aidt
1022  character(len=LINELENGTH), allocatable :: cols(:)
1023  integer(I4B) :: n, ncol
1024  res = .false.
1025  has_period = .false.
1026  do n = 1, size(mf6_input%block_dfns)
1027  if (mf6_input%block_dfns(n)%blockname == 'PERIOD') then
1028  has_period = .true.
1029  end if
1030  end do
1031  if (.not. has_period) return
1032  aidt => get_aggregate_definition_type(mf6_input%aggregate_dfns, &
1033  mf6_input%component_type, &
1034  mf6_input%subcomponent_type, &
1035  'PERIOD')
1036  call idt_parse_rectype(aidt, cols, ncol)
1037  if (ncol >= 2) then
1038  ks_aidt => find_setting_aggregate(mf6_input, cols, ncol)
1039  if (associated(ks_aidt)) res = .true.
1040  end if
1041  if (allocated(cols)) deallocate (cols)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ keystring_item_names()

subroutine loadcontextmodule::keystring_item_names ( class(loadcontexttype)  this,
character(len=linelength), dimension(:), intent(out), allocatable  item_names,
integer(i4b), dimension(:), intent(out), allocatable  head_nbody,
logical(lgp), dimension(:), intent(out), allocatable  item_is_body,
integer(i4b), intent(out)  nkeystring_items 
)
private

Definition at line 1094 of file LoadContext.f90.

1096  use inputoutputmodule, only: upcase
1097  use arrayhandlersmodule, only: expandarray
1100  class(LoadContextType) :: this
1101  character(len=LINELENGTH), allocatable, intent(out) :: item_names(:)
1102  integer(I4B), allocatable, intent(out) :: head_nbody(:)
1103  logical(LGP), allocatable, intent(out) :: item_is_body(:)
1104  integer(I4B), intent(out) :: nkeystring_items
1105  type(InputParamDefinitionType), pointer :: aidt, ks_aidt, idt
1106  character(len=LINELENGTH), allocatable :: rec_cols(:), ks_cols(:)
1107  character(len=LINELENGTH) :: rec_token, tagname
1108  integer(I4B) :: m, n, nrec_col, nks_col, nitems0, k
1109 
1110  nkeystring_items = 0
1111 
1112  ! get RECARRAY aggregate for period block and parse its column tokens
1113  aidt => get_aggregate_definition_type(this%mf6_input%aggregate_dfns, &
1114  this%mf6_input%component_type, &
1115  this%mf6_input%subcomponent_type, &
1116  this%blockname)
1117  call idt_parse_rectype(aidt, rec_cols, nrec_col)
1118 
1119  ! find the KEYSTRING aggregate for the SETTING token
1120  ks_aidt => find_setting_aggregate(this%mf6_input, rec_cols, nrec_col)
1121  if (allocated(rec_cols)) deallocate (rec_cols)
1122  if (.not. associated(ks_aidt)) return
1123 
1124  ! parse the KEYSTRING aggregate to get item token list — canonical order
1125  call idt_parse_rectype(ks_aidt, ks_cols, nks_col)
1126 
1127  ! walk the keystring token list in aggregate order
1128  do m = 1, nks_col
1129  rec_token = trim(ks_cols(m))
1130  call upcase(rec_token)
1131 
1132  ! locate matching param_dfns entry for this token
1133  do n = 1, size(this%mf6_input%param_dfns)
1134  if (this%mf6_input%param_dfns(n)%blockname /= this%blockname) cycle
1135  tagname = this%mf6_input%param_dfns(n)%tagname
1136  call upcase(tagname)
1137  if (trim(tagname) /= trim(rec_token)) cycle
1138 
1139  idt => this%mf6_input%param_dfns(n)
1140  if (idt_datatype(idt) == 'RECORD') then
1141  ! compound group: expand body members in RECORD type order
1142  nitems0 = nkeystring_items
1143  call expand_record_body(this%mf6_input, idt, item_names, &
1144  nkeystring_items)
1145  ! first added entry is the KEYWORD head; remaining are body members
1146  do k = nitems0 + 1, nkeystring_items
1147  call expandarray(head_nbody)
1148  call expandarray(item_is_body)
1149  if (k == nitems0 + 1) then
1150  head_nbody(k) = nkeystring_items - nitems0 - 1
1151  item_is_body(k) = .false.
1152  else
1153  head_nbody(k) = 0
1154  item_is_body(k) = .true.
1155  end if
1156  end do
1157  else
1158  ! direct-dispatch param
1159  nkeystring_items = nkeystring_items + 1
1160  call expandarray(item_names)
1161  call expandarray(head_nbody)
1162  call expandarray(item_is_body)
1163  item_names(nkeystring_items) = &
1164  trim(this%mf6_input%param_dfns(n)%tagname)
1165  head_nbody(nkeystring_items) = 0
1166  item_is_body(nkeystring_items) = .false.
1167  end if
1168  exit
1169  end do
1170  end do
1171 
1172  if (allocated(ks_cols)) deallocate (ks_cols)
Here is the call graph for this function:

◆ option_check()

logical(lgp) function loadcontextmodule::option_check ( class(loadcontexttype)  this,
character(len=*), intent(in)  varname,
integer(i4b), intent(in)  threshold 
)
private

Definition at line 568 of file LoadContext.f90.

570  class(LoadContextType) :: this
571  character(len=*), intent(in) :: varname
572  integer(I4B), intent(in) :: threshold
573  logical(LGP) :: option_check
574  integer(I4B) :: isize
575  integer(I4B), pointer :: intptr
576  option_check = .false.
577  call get_isize(varname, this%mf6_input%mempath, isize)
578  if (isize > 0) then
579  call mem_setptr(intptr, varname, this%mf6_input%mempath)
580  if (intptr > threshold) option_check = .true.
581  end if
Here is the call graph for this function:

◆ resolve_context()

subroutine loadcontextmodule::resolve_context ( class(loadcontexttype)  this)

Definition at line 176 of file LoadContext.f90.

177  class(LoadContextType) :: this
178 
179  this%set_scalars = .false.
180  this%set_mshape = .false.
181  this%is_exchange = .false.
182 
183  select case (this%mf6_input%load_scope)
184  case ('ROOT')
185  ! no memory setup needed for root context
186  case ('SIM')
187  ! only exchange inputs need scalar setup under SIM scope
188  if (this%mf6_input%component_type == 'EXG') then
189  this%set_scalars = .true.
190  this%is_exchange = .true.
191  end if
192  case ('MODEL')
193  this%set_scalars = .true.
194  ! OC and STO are model packages without period block stress data
195  if (this%mf6_input%subcomponent_type /= 'OC' .and. &
196  this%mf6_input%subcomponent_type /= 'STO') then
197  this%set_mshape = .true.
198  end if
199  case default
200  errmsg = 'LoadContext unrecognized load_scope for mempath: '// &
201  trim(this%mf6_input%mempath)
202  call store_error(errmsg, .true.)
203  end select
Here is the call graph for this function:

◆ resolve_dimensions()

subroutine loadcontextmodule::resolve_dimensions ( class(loadcontexttype)  this)

Definition at line 279 of file LoadContext.f90.

281  class(LoadContextType) :: this
282 
283  if (this%set_scalars) then
284 
285  call setptr(this%nbound, 'NBOUND', this%mf6_input%mempath)
286  call setval(this%naux, 'NAUX', this%mf6_input%mempath)
287  call setval(this%ncpl, 'NCPL', this%mf6_input%mempath)
288  call setval(this%nodes, 'NODES', this%mf6_input%mempath)
289  call setval(this%boundnames, 'BOUNDNAMES', this%mf6_input%mempath)
290  call setval(this%iprpak, 'IPRPAK', this%mf6_input%mempath)
291  call setval(this%maxbound, this%named_bound, this%mf6_input%mempath)
292 
293  ! reset nbound
294  this%nbound = 0
295  end if
296 
297  if (this%set_mshape .and. &
298  this%blockname == 'PERIOD') then
299  call mem_setptr(this%mshape, 'MODEL_SHAPE', &
300  this%mf6_input%component_mempath)
301 
302  if (this%ncpl == 0) then
303  if (size(this%mshape) == 2) then
304  this%ncpl = this%mshape(2)
305  else if (size(this%mshape) == 3) then
306  this%ncpl = this%mshape(2) * this%mshape(3)
307  end if
308  end if
309 
310  if (this%nodes == 0) this%nodes = product(this%mshape)
311  if (this%loadtype == keystring) call this%scale_keystring_maxbound()
312  end if
Here is the call graph for this function:

◆ resolve_item_nfeatures()

integer(i4b) function loadcontextmodule::resolve_item_nfeatures ( class(loadcontexttype)  this,
character(len=*), intent(in)  item_tagname,
character(len=*), intent(in)  dimname,
integer(i4b), intent(in)  default_nfeatures 
)

Definition at line 738 of file LoadContext.f90.

741  use simmodule, only: store_error
742  class(LoadContextType) :: this
743  character(len=*), intent(in) :: item_tagname
744  character(len=*), intent(in) :: dimname
745  integer(I4B), intent(in) :: default_nfeatures
746  integer(I4B) :: nfeatures
747  integer(I4B), pointer :: shape_val => null()
748  integer(I4B), dimension(:), pointer, contiguous :: shape_arr => null()
749  integer(I4B) :: isize
750  character(len=LINELENGTH) :: errmsg
751 
752  nfeatures = default_nfeatures
753  if (dimname == '') return
754  call get_isize(trim(dimname), this%mf6_input%mempath, isize)
755  if (isize < 0) then
756  nfeatures = 0
757  return
758  else if (isize == 0) then
759  write (errmsg, '(a,1x,a,1x,a)') &
760  'item', trim(item_tagname)//': DIMENSION', &
761  trim(dimname)//' is not defined.'
762  call store_error(errmsg)
763  nfeatures = 0
764  return
765  else if (.not. this%shape_param_is_array(trim(dimname))) then
766  call mem_setptr(shape_val, trim(dimname), this%mf6_input%mempath)
767  nfeatures = shape_val
768  else
769  call mem_setptr(shape_arr, trim(dimname), this%mf6_input%mempath)
770  nfeatures = sum(shape_arr)
771  end if
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
Here is the call graph for this function:

◆ resolve_loadtype()

subroutine loadcontextmodule::resolve_loadtype ( class(loadcontexttype)  this)
private

Definition at line 208 of file LoadContext.f90.

211  class(LoadContextType) :: this
212  type(InputParamDefinitionType), pointer :: idt, aidt
213  character(len=LINELENGTH), dimension(:), allocatable :: cols
214  integer(I4B) :: n, nparam
215 
216  this%loadtype = load_undef
217 
218  ! detect aggregate (list/keystring) load type
219  do n = 1, size(this%mf6_input%block_dfns)
220  if (this%mf6_input%block_dfns(n)%blockname == this%blockname) then
221  if (this%mf6_input%block_dfns(n)%aggregate) then
222  if (this%blockname == 'PERIOD' .and. &
223  is_keystring_period(this%mf6_input)) then
224  this%loadtype = keystring
225  else
226  this%loadtype = list
227  end if
228  exit
229  end if
230  end if
231  end do
232 
233  this%is_advanced = is_advanced(this%mf6_input)
234 
235  ! classify by the KEYSTRING aggregate's own leading column
236  if (this%loadtype == keystring) then
237  aidt => &
238  get_aggregate_definition_type(this%mf6_input%aggregate_dfns, &
239  this%mf6_input%component_type, &
240  this%mf6_input%subcomponent_type, &
241  this%blockname)
242  call idt_parse_rectype(aidt, cols, nparam)
243  if (is_feature_tag(cols(1))) then
244  this%keystring_by_feature = .true.
245  else if (cols(1) == 'CELLID') then
246  this%keystring_by_node = .true.
247  end if
248  if (allocated(cols)) deallocate (cols)
249  this%has_setting_dispatch = &
250  this%keystring_by_feature .or. this%keystring_by_node
251  if (this%has_setting_dispatch) then
252  this%setting_idt => &
253  idt_default(this%mf6_input%component_type, &
254  this%mf6_input%subcomponent_type, &
255  this%blockname, 'SETTING', 'SETTING', 'STRING')
256  end if
257  end if
258 
259  ! detect array-based load
260  if (this%loadtype == load_undef) then
261  do n = 1, size(this%mf6_input%param_dfns)
262  idt => this%mf6_input%param_dfns(n)
263  if (idt%blockname == 'OPTIONS') then
264  select case (idt%tagname)
265  case ('READASARRAYS')
266  this%loadtype = layerarray
267  case ('READARRAYGRID')
268  this%loadtype = gridarray
269  case default
270  ! no-op
271  end select
272  end if
273  end do
274  end if
type(inputparamdefinitiontype) function, pointer, public idt_default(component_type, subcomponent_type, blockname, tagname, mf6varname, datatype)
return allocated input definition type
Here is the call graph for this function:

◆ resolve_nfeatures()

integer(i4b) function loadcontextmodule::resolve_nfeatures ( class(loadcontexttype)  this)

Definition at line 685 of file LoadContext.f90.

686  use memorymanagermodule, only: get_isize
688  use simmodule, only: store_error
689  class(LoadContextType) :: this
690  integer(I4B) :: nfeatures
691  integer(I4B) :: isize, nkeystring_items, nrow, ndim
692  integer(I4B), pointer :: dimval
693  logical(LGP) :: have_dim, have_nrow
694  character(len=LINELENGTH) :: errmsg
695 
696  ! read the RAW dimension scalar from the memory manager, not
697  ! this%maxbound (a scaled copy used only for read-array sizing)
698  ndim = 0
699  have_dim = .false.
700  allocate (dimval)
701  dimval = 0
702  call mem_set_value(dimval, this%named_bound, this%mf6_input%mempath, &
703  have_dim, release=.false.)
704  if (have_dim) ndim = dimval
705  deallocate (dimval)
706 
707  call get_isize('PACKAGEDATA_IFNO', this%mf6_input%mempath, isize)
708  have_nrow = (isize > 0)
709  nrow = isize
710 
711  if (have_dim .and. have_nrow .and. ndim /= nrow) then
712  write (errmsg, '(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
713  'IDM dimension mismatch:', trim(this%named_bound), ndim, &
714  'does not match the PACKAGEDATA row count', nrow, '.'
715  call store_error(errmsg)
716  end if
717 
718  if (have_dim) then
719  nfeatures = ndim
720  return
721  else if (have_nrow) then
722  nfeatures = nrow
723  return
724  end if
725 
726  ! defensive: only if neither an explicit dimension nor PACKAGEDATA
727  ! is available (not expected for current packages)
728  nfeatures = 0
729  nkeystring_items = this%nkeystring_items
730  if (nkeystring_items > 0 .and. associated(this%maxbound)) then
731  if (this%maxbound > 0) nfeatures = this%maxbound / nkeystring_items
732  end if
Here is the call graph for this function:

◆ rsv_alloc()

character(len=lenvarname) function loadcontextmodule::rsv_alloc ( class(loadcontexttype)  this,
character(len=*), intent(in)  mf6varname 
)

Create and set a read state variable, e.g. 'INRECHARGE', which are updated per iper load as follows: -1: unset, not in use 0: not read in most recent period block 1: numeric input read in most recent period block 2: time series input read in most recent period block

Definition at line 902 of file LoadContext.f90.

903  use constantsmodule, only: lenvarname
905  class(LoadContextType) :: this
906  character(len=*), intent(in) :: mf6varname
907  character(len=LENVARNAME) :: varname
908  integer(I4B), pointer :: intvar
909  varname = rsv_name(mf6varname)
910  call mem_allocate(intvar, varname, this%mf6_input%mempath)
911  intvar = -1
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
Here is the call graph for this function:

◆ rsv_name()

character(len=lenvarname) function, public loadcontextmodule::rsv_name ( character(len=*), intent(in)  mf6varname)

Definition at line 1204 of file LoadContext.f90.

1205  use constantsmodule, only: lenvarname
1206  character(len=*), intent(in) :: mf6varname
1207  character(len=LENVARNAME) :: varname
1208  integer(I4B) :: ilen
1209  character(len=2) :: prefix = 'IN'
1210  ilen = len_trim(mf6varname)
1211  if (ilen > (lenvarname - len(prefix))) then
1212  varname = prefix//mf6varname(1:(lenvarname - len(prefix)))
1213  else
1214  varname = prefix//trim(mf6varname)
1215  end if
Here is the caller graph for this function:

◆ scale_keystring_maxbound()

subroutine loadcontextmodule::scale_keystring_maxbound ( class(loadcontexttype)  this)

Definition at line 319 of file LoadContext.f90.

320  class(LoadContextType) :: this
321  integer(I4B) :: nkeystring_items
322 
323  nkeystring_items = this%nkeystring_items
324 
325  if (nkeystring_items > 0) then
326  if (this%maxbound == 0) then
327  if (.not. this%keystring_by_feature) then
328  this%maxbound = this%nodes * nkeystring_items
329  end if
330  ! else: feature-addressed, genuinely zero stays 0
331  else
332  this%maxbound = this%maxbound * nkeystring_items
333  end if
334  end if

◆ set_params()

subroutine loadcontextmodule::set_params ( class(loadcontexttype)  this)
private

Definition at line 800 of file LoadContext.f90.

805  class(LoadContextType) :: this
806  type(InputParamDefinitionType), pointer :: idt, aidt
807  character(len=LINELENGTH), dimension(:), allocatable :: param_buf
808  character(len=LINELENGTH), dimension(:), allocatable :: cols
809  character(len=LINELENGTH), allocatable :: item_names(:)
810  integer(I4B), allocatable :: head_nbody(:)
811  logical(LGP), allocatable :: item_is_body(:)
812  integer(I4B) :: keepcnt, iparam, nparam, nkeystring_items, n
813  logical(LGP) :: keep, tag_found
814 
815  ! initialize
816  keepcnt = 0
817 
818  if (this%loadtype == list .or. &
819  this%loadtype == keystring) then
820  ! get aggregate param definition for period block
821  aidt => &
822  get_aggregate_definition_type(this%mf6_input%aggregate_dfns, &
823  this%mf6_input%component_type, &
824  this%mf6_input%subcomponent_type, &
825  this%blockname)
826  ! split recarray definition
827  call idt_parse_rectype(aidt, cols, nparam)
828  else
829  nparam = size(this%mf6_input%param_dfns)
830  end if
831 
832  ! allocate dfn input params
833  do iparam = 1, nparam
834  if (this%loadtype == list .or. &
835  this%loadtype == keystring) then
836  ! use found so keystring placeholders are silently skipped
837  idt => get_param_definition_type(this%mf6_input%param_dfns, &
838  this%mf6_input%component_type, &
839  this%mf6_input%subcomponent_type, &
840  this%blockname, cols(iparam), '', &
841  found=tag_found)
842  else
843  tag_found = .true.
844  idt => this%mf6_input%param_dfns(iparam)
845  end if
846 
847  if (.not. tag_found) then
848  keep = .false.
849  else if (idt%blockname /= this%blockname) then
850  keep = .false.
851  else
852  keep = this%in_scope(idt%tagname)
853  end if
854 
855  if (keep) then
856  keepcnt = keepcnt + 1
857  call expandarray(param_buf)
858  param_buf(keepcnt) = trim(idt%tagname)
859  end if
860  end do
861 
862  ! record leading-column count before item expansion
863  if (this%loadtype == list .or. &
864  this%loadtype == keystring) this%nleading = keepcnt
865 
866  ! for keystring packages: append item names (metadata head_nbody/
867  ! item_is_body is derived into the descriptor by build_keystring_items)
868  if (this%loadtype == keystring) then
869  call this%keystring_item_names(item_names, head_nbody, &
870  item_is_body, nkeystring_items)
871  this%nkeystring_items = nkeystring_items
872  do n = 1, nkeystring_items
873  keepcnt = keepcnt + 1
874  call expandarray(param_buf)
875  param_buf(keepcnt) = trim(item_names(n))
876  end do
877  end if
878 
879  ! update nparam to total (leading + items)
880  nparam = keepcnt
881 
882  ! allocate and fill params
883  allocate (this%params(nparam))
884  do iparam = 1, nparam
885  this%params(iparam) = trim(param_buf(iparam))
886  end do
887 
888  ! cleanup
889  if (allocated(param_buf)) deallocate (param_buf)
Here is the call graph for this function:

◆ setptr_auxvar()

subroutine loadcontextmodule::setptr_auxvar ( real(dp), dimension(:, :), intent(inout), pointer, contiguous  auxvar,
character(len=*), intent(in)  mempath 
)

Definition at line 1319 of file LoadContext.f90.

1321  real(DP), dimension(:, :), pointer, &
1322  contiguous, intent(inout) :: auxvar
1323  character(len=*), intent(in) :: mempath
1324  integer(I4B) :: isize
1325  call get_isize('AUXVAR', mempath, isize)
1326  if (isize > -1) then
1327  call mem_setptr(auxvar, 'AUXVAR', mempath)
1328  else
1329  call mem_allocate(auxvar, 0, 0, 'AUXVAR', mempath)
1330  end if

◆ setptr_charstr1d()

subroutine loadcontextmodule::setptr_charstr1d ( type(characterstringtype), dimension(:), intent(inout), pointer, contiguous  charstr1d,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  mempath,
integer(i4b), intent(in)  strlen 
)

Definition at line 1300 of file LoadContext.f90.

1302  type(CharacterStringType), dimension(:), pointer, &
1303  contiguous, intent(inout) :: charstr1d
1304  character(len=*), intent(in) :: varname
1305  character(len=*), intent(in) :: mempath
1306  integer(I4B), intent(in) :: strlen
1307  integer(I4B) :: isize
1308  call get_isize(varname, mempath, isize)
1309  if (isize > -1) then
1310  call mem_setptr(charstr1d, varname, mempath)
1311  else
1312  call mem_allocate(charstr1d, strlen, 0, varname, mempath)
1313  end if

◆ setptr_int()

subroutine loadcontextmodule::setptr_int ( integer(i4b), intent(inout), pointer  intptr,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  mempath 
)

Definition at line 1283 of file LoadContext.f90.

1285  integer(I4B), pointer, intent(inout) :: intptr
1286  character(len=*), intent(in) :: varname
1287  character(len=*), intent(in) :: mempath
1288  integer(I4B) :: isize
1289  call get_isize(varname, mempath, isize)
1290  if (isize > -1) then
1291  call mem_setptr(intptr, varname, mempath)
1292  else
1293  call mem_allocate(intptr, varname, mempath)
1294  intptr = 0
1295  end if

◆ setval()

subroutine loadcontextmodule::setval ( integer(i4b), intent(inout), pointer  intptr,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  mempath 
)

Definition at line 1269 of file LoadContext.f90.

1271  integer(I4B), pointer, intent(inout) :: intptr
1272  character(len=*), intent(in) :: varname
1273  character(len=*), intent(in) :: mempath
1274  logical(LGP) :: found
1275  allocate (intptr)
1276  intptr = 0
1277  call mem_set_value(intptr, varname, mempath, found, release=.false.)
Here is the caller graph for this function:

◆ shape_param_is_array()

logical(lgp) function loadcontextmodule::shape_param_is_array ( class(loadcontexttype)  this,
character(len=*), intent(in)  shape_varname 
)

Definition at line 777 of file LoadContext.f90.

778  class(LoadContextType) :: this
779  character(len=*), intent(in) :: shape_varname
780  logical(LGP) :: is_array
781  integer(I4B) :: i
782 
783  is_array = .false.
784  do i = 1, size(this%mf6_input%param_dfns)
785  if (this%mf6_input%param_dfns(i)%component_type == &
786  this%mf6_input%component_type .and. &
787  this%mf6_input%param_dfns(i)%subcomponent_type == &
788  this%mf6_input%subcomponent_type .and. &
789  trim(this%mf6_input%param_dfns(i)%mf6varname) == &
790  trim(shape_varname)) then
791  is_array = &
792  (trim(this%mf6_input%param_dfns(i)%blockname) == 'PACKAGEDATA')
793  exit
794  end if
795  end do

◆ subindex_dependency()

logical(lgp) function loadcontextmodule::subindex_dependency ( class(loadcontexttype)  this,
character(len=*), intent(in)  tagname,
character(len=lenvarname), intent(out)  dimname,
character(len=lenvarname), intent(out)  subindex_tagname 
)

Definition at line 545 of file LoadContext.f90.

547  class(LoadContextType) :: this
548  character(len=*), intent(in) :: tagname
549  character(len=LENVARNAME), intent(out) :: dimname
550  character(len=LENVARNAME), intent(out) :: subindex_tagname
551  logical(LGP) :: found
552 
553  found = .false.
554  dimname = ''
555  subindex_tagname = ''
556  select case (this%mf6_input%subcomponent_type)
557  case ('SFR')
558  if (tagname == 'DIVFLOW') then
559  dimname = 'NDV'
560  subindex_tagname = 'IDV'
561  found = .true.
562  end if
563  end select

Variable Documentation

◆ addr_feature

integer(i4b), parameter, public loadcontextmodule::addr_feature = 1

Definition at line 52 of file LoadContext.f90.

52  integer(I4B), parameter, public :: ADDR_FEATURE = 1 !< addressed by leading id (IFNO/BNDNO)

◆ addr_node

integer(i4b), parameter, public loadcontextmodule::addr_node = 2

Definition at line 53 of file LoadContext.f90.

53  integer(I4B), parameter, public :: ADDR_NODE = 2 !< addressed by CELLID

◆ addr_none

integer(i4b), parameter, public loadcontextmodule::addr_none = 0

Definition at line 51 of file LoadContext.f90.

51  integer(I4B), parameter, public :: ADDR_NONE = 0 !< not an applied setting

◆ addr_subindex

integer(i4b), parameter, public loadcontextmodule::addr_subindex = 3

Definition at line 54 of file LoadContext.f90.

54  integer(I4B), parameter, public :: ADDR_SUBINDEX = 3 !< addressed by (id, subindex)