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 1238 of file LoadContext.f90.

1240  integer(I4B), intent(in) :: nrow !< integer array number of rows
1241  character(len=*), intent(in) :: varname !< variable name
1242  character(len=*), intent(in) :: mempath !< variable mempath
1243  real(DP), dimension(:), pointer, contiguous :: dbl1d
1244  integer(I4B) :: n
1245  call mem_allocate(dbl1d, nrow, varname, mempath)
1246  do n = 1, nrow
1247  dbl1d(n) = dzero
1248  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 1253 of file LoadContext.f90.

1255  integer(I4B), intent(in) :: ncol !< integer array number of cols
1256  integer(I4B), intent(in) :: nrow !< integer array number of rows
1257  character(len=*), intent(in) :: varname !< variable name
1258  character(len=*), intent(in) :: mempath !< variable mempath
1259  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
1260  integer(I4B) :: n, m
1261  call mem_allocate(dbl2d, ncol, nrow, varname, mempath)
1262  do m = 1, nrow
1263  do n = 1, ncol
1264  dbl2d(n, m) = dzero
1265  end do
1266  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 1223 of file LoadContext.f90.

1225  integer(I4B), intent(in) :: nrow !< integer array number of rows
1226  character(len=*), intent(in) :: varname !< variable name
1227  character(len=*), intent(in) :: mempath !< variable mempath
1228  integer(I4B), dimension(:), pointer, contiguous :: int1d
1229  integer(I4B) :: n
1230  call mem_allocate(int1d, nrow, varname, mempath)
1231  do n = 1, nrow
1232  int1d(n) = izero
1233  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 590 of file LoadContext.f90.

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

1181  use featureflagsmodule, only: developmode
1182  use simvariablesmodule, only: iout
1184  class(LoadContextType) :: this
1185  character(len=*), intent(in) :: input_name
1186  type(InputParamDefinitionType), pointer :: idt
1187  character(len=LINELENGTH) :: dev_msg
1188  integer(I4B) :: n
1189 
1190  do n = 1, size(this%params)
1191  idt => get_param_definition_type(this%mf6_input%param_dfns, &
1192  this%mf6_input%component_type, &
1193  this%mf6_input%subcomponent_type, &
1194  this%blockname, this%params(n), '')
1195  if (idt%developmode) then
1196  dev_msg = 'Input tag "'//trim(idt%tagname)// &
1197  &'" read from file "'//trim(input_name)// &
1198  &'" is still under development. Install the &
1199  &nightly build or compile from source with IDEVELOPMODE = 1.'
1200  call developmode(dev_msg, iout)
1201  end if
1202  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 919 of file LoadContext.f90.

920  class(LoadContextType) :: this
921 
922  if (associated(this%setting_idt)) then
923  deallocate (this%setting_idt)
924  nullify (this%setting_idt)
925  end if
926 
927  if (this%set_scalars) then
928  ! deallocate local
929  deallocate (this%naux)
930  deallocate (this%ncpl)
931  deallocate (this%nodes)
932  deallocate (this%maxbound)
933  deallocate (this%boundnames)
934  deallocate (this%iprpak)
935  end if
936 
937  ! nullify
938  nullify (this%naux)
939  nullify (this%nbound)
940  nullify (this%ncpl)
941  nullify (this%nodes)
942  nullify (this%maxbound)
943  nullify (this%boundnames)
944  nullify (this%iprpak)
945  nullify (this%auxname_cst)
946  nullify (this%boundname_cst)
947  nullify (this%auxvar)
948  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 985 of file LoadContext.f90.

986  use inputoutputmodule, only: upcase
989  type(ModflowInputType), intent(in) :: mf6_input
990  type(InputParamDefinitionType), pointer, intent(in) :: rec_idt
991  character(len=LINELENGTH), allocatable, intent(inout) :: item_names(:)
992  integer(I4B), intent(inout) :: nkeystring_items
993  type(InputParamDefinitionType), pointer :: sub_idt
994  character(len=LINELENGTH), allocatable :: sub_cols(:)
995  character(len=LINELENGTH) :: token, tagname
996  integer(I4B) :: k, j, nsub_col
997  call idt_parse_rectype(rec_idt, sub_cols, nsub_col)
998  do k = 1, nsub_col
999  token = trim(sub_cols(k))
1000  call upcase(token)
1001  do j = 1, size(mf6_input%param_dfns)
1002  sub_idt => mf6_input%param_dfns(j)
1003  if (sub_idt%blockname /= 'PERIOD') cycle
1004  tagname = sub_idt%tagname
1005  call upcase(tagname)
1006  if (trim(tagname) /= trim(token)) cycle
1007  if (idt_datatype(sub_idt) == 'RECORD') cycle
1008  nkeystring_items = nkeystring_items + 1
1009  call expandarray(item_names)
1010  item_names(nkeystring_items) = trim(sub_idt%tagname)
1011  exit
1012  end do
1013  end do
1014  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 953 of file LoadContext.f90.

954  use inputoutputmodule, only: upcase
956  type(ModflowInputType), intent(in) :: mf6_input
957  character(len=LINELENGTH), intent(in) :: rec_cols(:)
958  integer(I4B), intent(in) :: nrec_col
959  type(InputParamDefinitionType), pointer :: ks_aidt
960  character(len=LINELENGTH) :: token, tagname
961  integer(I4B) :: m, n, ilen
962  ks_aidt => null()
963  do m = 1, nrec_col
964  token = trim(rec_cols(m))
965  call upcase(token)
966  ilen = len_trim(token)
967  ! minimum 8 chars: a valid XSETTING token is at least 1 char prefix + 7 for 'SETTING'
968  if (ilen < 8) cycle
969  if (token(ilen - 6:ilen) /= 'SETTING') cycle
970  do n = 1, size(mf6_input%aggregate_dfns)
971  tagname = mf6_input%aggregate_dfns(n)%tagname
972  call upcase(tagname)
973  if (trim(tagname) == trim(token)) then
974  ks_aidt => mf6_input%aggregate_dfns(n)
975  if (idt_datatype(ks_aidt) /= 'KEYSTRING') ks_aidt => null()
976  exit
977  end if
978  end do
979  exit
980  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 ('LAKTAB')
533  ! BAREA present only for embedded lakes, whose table has 4 columns
534  if (tagname == 'BAREA') in_scope = this%option_check('NCOL', 3)
535  case default
536  ! unrecognized subcomponent with an optional param not handled
537  ! above is a development error -- abort so the gap is visible
538  errmsg = 'LoadContext in_scope needs new case for: '// &
539  trim(this%mf6_input%subcomponent_type)//'/'//trim(tagname)
540  call store_error(errmsg, .true.)
541  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 1087 of file LoadContext.f90.

1088  type(ModflowInputType), intent(in) :: mf6_input
1089  logical(LGP) :: res
1090  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 1051 of file LoadContext.f90.

1054  type(ModflowInputType), intent(in) :: mf6_input
1055  logical(LGP) :: res
1056  type(InputParamDefinitionType), pointer :: aidt
1057  character(len=LINELENGTH), allocatable :: cols(:)
1058  integer(I4B) :: ncol
1059  res = .false.
1060  if (.not. is_keystring_period(mf6_input)) return
1061  aidt => get_aggregate_definition_type(mf6_input%aggregate_dfns, &
1062  mf6_input%component_type, &
1063  mf6_input%subcomponent_type, &
1064  'PERIOD')
1065  call idt_parse_rectype(aidt, cols, ncol)
1066  res = is_feature_tag(cols(1))
1067  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 1074 of file LoadContext.f90.

1075  character(len=*), intent(in) :: tagname
1076  logical(LGP) :: res
1077  select case (tagname)
1078  case ('IFNO', 'NUMBER', 'BNDNO', 'RNO', 'LAKENO', 'MAWNO', 'UZFNO')
1079  res = .true.
1080  case default
1081  res = .false.
1082  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 1019 of file LoadContext.f90.

1022  type(ModflowInputType), intent(in) :: mf6_input
1023  logical(LGP) :: res, has_period
1024  type(InputParamDefinitionType), pointer :: aidt, ks_aidt
1025  character(len=LINELENGTH), allocatable :: cols(:)
1026  integer(I4B) :: n, ncol
1027  res = .false.
1028  has_period = .false.
1029  do n = 1, size(mf6_input%block_dfns)
1030  if (mf6_input%block_dfns(n)%blockname == 'PERIOD') then
1031  has_period = .true.
1032  end if
1033  end do
1034  if (.not. has_period) return
1035  aidt => get_aggregate_definition_type(mf6_input%aggregate_dfns, &
1036  mf6_input%component_type, &
1037  mf6_input%subcomponent_type, &
1038  'PERIOD')
1039  call idt_parse_rectype(aidt, cols, ncol)
1040  if (ncol >= 2) then
1041  ks_aidt => find_setting_aggregate(mf6_input, cols, ncol)
1042  if (associated(ks_aidt)) res = .true.
1043  end if
1044  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 1097 of file LoadContext.f90.

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

573  class(LoadContextType) :: this
574  character(len=*), intent(in) :: varname
575  integer(I4B), intent(in) :: threshold
576  logical(LGP) :: option_check
577  integer(I4B) :: isize
578  integer(I4B), pointer :: intptr
579  option_check = .false.
580  call get_isize(varname, this%mf6_input%mempath, isize)
581  if (isize > 0) then
582  call mem_setptr(intptr, varname, this%mf6_input%mempath)
583  if (intptr > threshold) option_check = .true.
584  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 741 of file LoadContext.f90.

744  use simmodule, only: store_error
745  class(LoadContextType) :: this
746  character(len=*), intent(in) :: item_tagname
747  character(len=*), intent(in) :: dimname
748  integer(I4B), intent(in) :: default_nfeatures
749  integer(I4B) :: nfeatures
750  integer(I4B), pointer :: shape_val => null()
751  integer(I4B), dimension(:), pointer, contiguous :: shape_arr => null()
752  integer(I4B) :: isize
753  character(len=LINELENGTH) :: errmsg
754 
755  nfeatures = default_nfeatures
756  if (dimname == '') return
757  call get_isize(trim(dimname), this%mf6_input%mempath, isize)
758  if (isize < 0) then
759  nfeatures = 0
760  return
761  else if (isize == 0) then
762  write (errmsg, '(a,1x,a,1x,a)') &
763  'item', trim(item_tagname)//': DIMENSION', &
764  trim(dimname)//' is not defined.'
765  call store_error(errmsg)
766  nfeatures = 0
767  return
768  else if (.not. this%shape_param_is_array(trim(dimname))) then
769  call mem_setptr(shape_val, trim(dimname), this%mf6_input%mempath)
770  nfeatures = shape_val
771  else
772  call mem_setptr(shape_arr, trim(dimname), this%mf6_input%mempath)
773  nfeatures = sum(shape_arr)
774  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 688 of file LoadContext.f90.

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

906  use constantsmodule, only: lenvarname
908  class(LoadContextType) :: this
909  character(len=*), intent(in) :: mf6varname
910  character(len=LENVARNAME) :: varname
911  integer(I4B), pointer :: intvar
912  varname = rsv_name(mf6varname)
913  call mem_allocate(intvar, varname, this%mf6_input%mempath)
914  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 1207 of file LoadContext.f90.

1208  use constantsmodule, only: lenvarname
1209  character(len=*), intent(in) :: mf6varname
1210  character(len=LENVARNAME) :: varname
1211  integer(I4B) :: ilen
1212  character(len=2) :: prefix = 'IN'
1213  ilen = len_trim(mf6varname)
1214  if (ilen > (lenvarname - len(prefix))) then
1215  varname = prefix//mf6varname(1:(lenvarname - len(prefix)))
1216  else
1217  varname = prefix//trim(mf6varname)
1218  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 803 of file LoadContext.f90.

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

1324  real(DP), dimension(:, :), pointer, &
1325  contiguous, intent(inout) :: auxvar
1326  character(len=*), intent(in) :: mempath
1327  integer(I4B) :: isize
1328  call get_isize('AUXVAR', mempath, isize)
1329  if (isize > -1) then
1330  call mem_setptr(auxvar, 'AUXVAR', mempath)
1331  else
1332  call mem_allocate(auxvar, 0, 0, 'AUXVAR', mempath)
1333  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 1303 of file LoadContext.f90.

1305  type(CharacterStringType), dimension(:), pointer, &
1306  contiguous, intent(inout) :: charstr1d
1307  character(len=*), intent(in) :: varname
1308  character(len=*), intent(in) :: mempath
1309  integer(I4B), intent(in) :: strlen
1310  integer(I4B) :: isize
1311  call get_isize(varname, mempath, isize)
1312  if (isize > -1) then
1313  call mem_setptr(charstr1d, varname, mempath)
1314  else
1315  call mem_allocate(charstr1d, strlen, 0, varname, mempath)
1316  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 1286 of file LoadContext.f90.

1288  integer(I4B), pointer, intent(inout) :: intptr
1289  character(len=*), intent(in) :: varname
1290  character(len=*), intent(in) :: mempath
1291  integer(I4B) :: isize
1292  call get_isize(varname, mempath, isize)
1293  if (isize > -1) then
1294  call mem_setptr(intptr, varname, mempath)
1295  else
1296  call mem_allocate(intptr, varname, mempath)
1297  intptr = 0
1298  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 1272 of file LoadContext.f90.

1274  integer(I4B), pointer, intent(inout) :: intptr
1275  character(len=*), intent(in) :: varname
1276  character(len=*), intent(in) :: mempath
1277  logical(LGP) :: found
1278  allocate (intptr)
1279  intptr = 0
1280  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 780 of file LoadContext.f90.

781  class(LoadContextType) :: this
782  character(len=*), intent(in) :: shape_varname
783  logical(LGP) :: is_array
784  integer(I4B) :: i
785 
786  is_array = .false.
787  do i = 1, size(this%mf6_input%param_dfns)
788  if (this%mf6_input%param_dfns(i)%component_type == &
789  this%mf6_input%component_type .and. &
790  this%mf6_input%param_dfns(i)%subcomponent_type == &
791  this%mf6_input%subcomponent_type .and. &
792  trim(this%mf6_input%param_dfns(i)%mf6varname) == &
793  trim(shape_varname)) then
794  is_array = &
795  (trim(this%mf6_input%param_dfns(i)%blockname) == 'PACKAGEDATA')
796  exit
797  end if
798  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 548 of file LoadContext.f90.

550  class(LoadContextType) :: this
551  character(len=*), intent(in) :: tagname
552  character(len=LENVARNAME), intent(out) :: dimname
553  character(len=LENVARNAME), intent(out) :: subindex_tagname
554  logical(LGP) :: found
555 
556  found = .false.
557  dimname = ''
558  subindex_tagname = ''
559  select case (this%mf6_input%subcomponent_type)
560  case ('SFR')
561  if (tagname == 'DIVFLOW') then
562  dimname = 'NDV'
563  subindex_tagname = 'IDV'
564  found = .true.
565  end if
566  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)