MODFLOW 6  version 6.7.0.dev2
USGS Modular Hydrologic Model
LoadContext.f90
Go to the documentation of this file.
1 !> @brief This module contains the LoadContextModule
2 !!
3 !! This module creates a load context for IDM generic
4 !! loaders (ListLoadType, LayerArrayLoadType, GridArrayLoadType)
5 !! that supports consistent package side access. It also
6 !! determines in scope parameters for the generic dynamic
7 !! loaders and all structarray based static loads.
8 !!
9 !<
11 
12  use kindmodule, only: dp, i4b, lgp
15  use simvariablesmodule, only: errmsg
20 
21  implicit none
22  private
23  public :: loadcontexttype
24  public :: readstatevartype
25  public :: rsv_name
26 
27  enum, bind(C)
28  enumerator :: load_undef = 0 !< undefined load type
29  enumerator :: list = 1 !< list (structarray) based load
30  enumerator :: layerarray = 2 !< readasarrays load
31  enumerator :: gridarray = 3 !< readarraygrid load
32  end enum
33 
34  enum, bind(C)
35  enumerator :: context_undef = 0 !< undefined context type
36  enumerator :: root = 1 !< root context type
37  enumerator :: sim = 2 !< sim context type
38  enumerator :: model = 3 !< model context type
39  enumerator :: modelpkg = 4 !< model package context type
40  enumerator :: stresspkg = 5 !< model stress package context type
41  enumerator :: exchange = 6 !< exchange context type
42  end enum
43 
44  !> @brief Pointer type for read state variable
45  !<
47  integer(I4B), pointer :: invar
48  end type readstatevartype
49 
50  interface setptr
51  module procedure setptr_int, setptr_charstr1d, &
53  end interface setptr
54 
55  !> @brief derived type for boundary package input context
56  !!
57  !! Input Load Context for generic dynamic loaders and
58  !! StructArray based static loads
59  !!
60  !<
62  character(len=LENVARNAME) :: blockname !< load block name
63  character(len=LENVARNAME) :: named_bound !< name of dimensions relevant to load
64  integer(I4B), pointer :: naux => null() !< number of auxiliary variables
65  integer(I4B), pointer :: maxbound => null() !< value associated with named_bound
66  integer(I4B), pointer :: boundnames => null() !< are bound names optioned
67  integer(I4B), pointer :: iprpak => null() ! print input option
68  integer(I4B), pointer :: nbound => null() !< number of bounds in period
69  integer(I4B), pointer :: ncpl => null() !< ncpl associated with model shape
70  integer(I4B), pointer :: nodes => null() !< nodes associated with model shape
71  integer(I4B) :: loadtype !< enum load type
72  integer(I4B) :: ctxtype !< enum context type
73  logical(LGP) :: readarray !< is this an array based load
74  type(characterstringtype), dimension(:), pointer, &
75  contiguous :: auxname_cst => null() !< array of auxiliary names
76  type(characterstringtype), dimension(:), pointer, &
77  contiguous :: boundname_cst => null() !< array of bound names
78  real(dp), dimension(:, :), pointer, &
79  contiguous :: auxvar => null() !< auxiliary variable array
80  integer(I4B), dimension(:), pointer, contiguous :: mshape => null() !< model shape
81  character(len=LINELENGTH), dimension(:), allocatable :: params !< in scope param tags
82  type(modflowinputtype) :: mf6_input !< description of input
83  contains
84  procedure :: init
85  procedure :: allocate_scalars
86  procedure :: allocate_arrays
87  procedure :: allocate_param
88  procedure :: tags
89  procedure :: in_scope
90  procedure :: set_params
91  procedure :: rsv_alloc
92  procedure :: destroy
93  end type loadcontexttype
94 
95 contains
96 
97  !> @brief init loader context object
98  !<
99  subroutine init(this, mf6_input, blockname, named_bound)
100  use inputoutputmodule, only: upcase
102  class(loadcontexttype) :: this
103  type(modflowinputtype), intent(in) :: mf6_input
104  character(len=*), optional, intent(in) :: blockname
105  character(len=*), optional, intent(in) :: named_bound
106  type(inputparamdefinitiontype), pointer :: idt
107  integer(I4B) :: n
108 
109  this%mf6_input = mf6_input
110  this%readarray = .false.
111  this%loadtype = load_undef
112  this%ctxtype = context_undef
113 
114  select case (mf6_input%load_scope)
115  case ('ROOT')
116  this%ctxtype = root
117  case ('SIM')
118  if (mf6_input%subcomponent_type == 'NAM') then
119  this%ctxtype = model
120  else if (mf6_input%subcomponent_type == 'TDIS' .or. &
121  mf6_input%subcomponent_type == 'HPC') then
122  this%ctxtype = sim
123  else if (mf6_input%component_type == 'EXG') then
124  this%ctxtype = exchange
125  end if
126  case ('MODEL')
127  if (mf6_input%subcomponent_type == 'OC' .or. &
128  mf6_input%subcomponent_type == 'STO') then
129  this%ctxtype = modelpkg
130  else
131  this%ctxtype = stresspkg
132  end if
133  case default
134  end select
135 
136  if (this%ctxtype == context_undef) then
137  errmsg = 'LoadContext unidentified context for mempath: '// &
138  trim(mf6_input%mempath)
139  call store_error(errmsg, .true.)
140  end if
141 
142  if (present(blockname)) then
143  this%blockname = blockname
144  call upcase(this%blockname)
145  else
146  this%blockname = 'PERIOD'
147  end if
148 
149  if (present(named_bound)) then
150  this%named_bound = named_bound
151  call upcase(this%named_bound)
152  else
153  this%named_bound = 'MAXBOUND'
154  end if
155 
156  ! determine if list based load
157  do n = 1, size(mf6_input%block_dfns)
158  if (mf6_input%block_dfns(n)%blockname == this%blockname) then
159  if (mf6_input%block_dfns(n)%aggregate) then
160  this%loadtype = list
161  end if
162  end if
163  end do
164 
165  ! determine if array based load
166  if (this%loadtype == load_undef) then
167  do n = 1, size(mf6_input%param_dfns)
168  idt => mf6_input%param_dfns(n)
169  if (idt%blockname == 'OPTIONS') then
170  select case (idt%tagname)
171  case ('READASARRAYS')
172  this%loadtype = layerarray
173  this%readarray = .true.
174  case ('READARRAYGRID')
175  this%loadtype = gridarray
176  this%readarray = .true.
177  case default
178  ! no-op
179  end select
180  end if
181  end do
182  end if
183 
184  ! set in scope params for load
185  call this%set_params()
186 
187  ! allocate load context scalars
188  call this%allocate_scalars()
189  end subroutine init
190 
191  !> @brief allocate scalars
192  !<
193  subroutine allocate_scalars(this)
195  class(loadcontexttype) :: this
196 
197  if (this%ctxtype == exchange .or. &
198  this%ctxtype == modelpkg .or. &
199  this%ctxtype == stresspkg) then
200 
201  call setptr(this%nbound, 'NBOUND', this%mf6_input%mempath)
202  call setval(this%naux, 'NAUX', this%mf6_input%mempath)
203  call setval(this%ncpl, 'NCPL', this%mf6_input%mempath)
204  call setval(this%nodes, 'NODES', this%mf6_input%mempath)
205  call setval(this%maxbound, this%named_bound, this%mf6_input%mempath)
206  call setval(this%boundnames, 'BOUNDNAMES', this%mf6_input%mempath)
207  call setval(this%iprpak, 'IPRPAK', this%mf6_input%mempath)
208 
209  ! reset nbound
210  this%nbound = 0
211  end if
212 
213  if (this%ctxtype == stresspkg .and. &
214  this%blockname == 'PERIOD') then
215  call mem_setptr(this%mshape, 'MODEL_SHAPE', &
216  this%mf6_input%component_mempath)
217 
218  if (this%ncpl == 0) then
219  if (size(this%mshape) == 2) then
220  this%ncpl = this%mshape(2)
221  else if (size(this%mshape) == 3) then
222  this%ncpl = this%mshape(2) * this%mshape(3)
223  end if
224  end if
225 
226  if (this%nodes == 0) this%nodes = product(this%mshape)
227  end if
228  end subroutine allocate_scalars
229 
230  !> @brief allocate arrays
231  !!
232  !! call this routine after input parameters have been allocated,
233  !! e.g. after load_params() with create has been called for array
234  !! based loaders or after all mem_create_vector() calls have
235  !! been made for list based load.
236  !!
237  !<
238  subroutine allocate_arrays(this)
240  class(loadcontexttype) :: this
241  integer(I4B), dimension(:, :), pointer, contiguous :: cellid
242  integer(I4B), dimension(:), pointer, contiguous :: nodeulist
243 
244  if (this%ctxtype == stresspkg .and. &
245  this%blockname == 'PERIOD') then
246  ! allocate cellid if this is not list input
247  if (this%readarray) then
248  call mem_allocate(cellid, 0, 0, 'CELLID', this%mf6_input%mempath)
249  end if
250 
251  ! allocate nodeulist
252  if (this%loadtype /= gridarray) then
253  call mem_allocate(nodeulist, 0, 'NODEULIST', this%mf6_input%mempath)
254  end if
255 
256  ! set pointers to arrays
257  call setptr(this%auxname_cst, 'AUXILIARY', &
258  this%mf6_input%mempath, lenauxname)
259  call setptr(this%boundname_cst, 'BOUNDNAME', &
260  this%mf6_input%mempath, lenboundname)
261  call setptr(this%auxvar, this%mf6_input%mempath)
262 
263  else if (this%ctxtype == exchange) then
264  ! set pointers to arrays
265  call setptr(this%auxname_cst, 'AUXILIARY', &
266  this%mf6_input%mempath, lenauxname)
267  call setptr(this%boundname_cst, 'BOUNDNAME', &
268  this%mf6_input%mempath, lenboundname)
269  call setptr(this%auxvar, this%mf6_input%mempath)
270  end if
271  end subroutine allocate_arrays
272 
273  !> @brief allocate a package dynamic input parameter
274  !<
275  subroutine allocate_param(this, idt)
277  class(loadcontexttype) :: this
278  type(inputparamdefinitiontype), pointer :: idt
279  integer(I4B) :: dimsize
280 
281  ! initialize
282  dimsize = 0
283 
284  if (this%readarray) then
285  select case (idt%shape)
286  case ('NCPL', 'NAUX NCPL')
287  dimsize = this%ncpl
288  case ('NODES', 'NAUX NODES')
289  dimsize = this%maxbound
290  case default
291  end select
292  end if
293 
294  select case (idt%datatype)
295  case ('INTEGER')
296  if (this%loadtype == list) then
297  call allocate_int1d(this%maxbound, idt%mf6varname, &
298  this%mf6_input%mempath)
299  end if
300  case ('DOUBLE')
301  if (this%loadtype == list) then
302  call allocate_dbl1d(this%maxbound, idt%mf6varname, &
303  this%mf6_input%mempath)
304  end if
305  case ('STRING')
306  if (this%loadtype == list) then
307  call allocate_charstr1d(lenboundname, this%maxbound, idt%mf6varname, &
308  this%mf6_input%mempath)
309  end if
310  case ('INTEGER1D')
311  if (this%loadtype == list) then
312  if (idt%shape == 'NCELLDIM') then
313  call allocate_int2d(size(this%mshape), this%maxbound, &
314  idt%mf6varname, this%mf6_input%mempath)
315  end if
316  else if (this%readarray) then
317  call allocate_int1d(dimsize, idt%mf6varname, &
318  this%mf6_input%mempath)
319  end if
320  case ('DOUBLE1D')
321  if (idt%shape == 'NAUX') then
322  call allocate_dbl2d(this%naux, this%maxbound, &
323  idt%mf6varname, this%mf6_input%mempath)
324  else if (this%readarray) then
325  call allocate_dbl1d(dimsize, idt%mf6varname, &
326  this%mf6_input%mempath)
327  end if
328  case ('DOUBLE2D')
329  if (this%readarray) then
330  call allocate_dbl2d(this%naux, dimsize, idt%mf6varname, &
331  this%mf6_input%mempath)
332  end if
333  case default
334  end select
335  end subroutine allocate_param
336 
337  !> @brief get in scope package params
338  !!
339  !! set input array to tagnames of in scope params, optionally
340  !! allocate the parameters based on datatype.
341  !!
342  !<
343  subroutine tags(this, params, nparam, input_name, create)
345  class(loadcontexttype) :: this
346  character(len=LINELENGTH), dimension(:), allocatable, &
347  intent(inout) :: params
348  integer(I4B), intent(inout) :: nparam
349  character(len=*), intent(in) :: input_name
350  logical(LGP), optional, intent(in) :: create
351  type(inputparamdefinitiontype), pointer :: idt
352  logical(LGP) :: allocate_params
353  integer(I4B) :: n
354 
355  ! initialize allocate_params
356  allocate_params = .false.
357 
358  ! override default if provided
359  if (present(create)) then
360  allocate_params = create
361  end if
362 
363  if (allocated(params)) deallocate (params)
364  nparam = size(this%params)
365  allocate (params(nparam))
366  do n = 1, nparam
367  params(n) = this%params(n)
368  end do
369 
370  if (allocate_params) then
371  ! allocate dfn input params
372  do n = 1, nparam
373  idt => &
374  get_param_definition_type(this%mf6_input%param_dfns, &
375  this%mf6_input%component_type, &
376  this%mf6_input%subcomponent_type, &
377  this%blockname, params(n), '')
378  call this%allocate_param(idt)
379  end do
380  end if
381  end subroutine tags
382 
383  !> @brief establish if input parameter is in scope for package load
384  !<
385  function in_scope(this, mf6_input, blockname, tagname)
388  class(loadcontexttype) :: this
389  type(modflowinputtype), intent(in) :: mf6_input
390  character(len=*), intent(in) :: blockname
391  character(len=*), intent(in) :: tagname
392  logical(LGP) :: in_scope
393  type(inputparamdefinitiontype), pointer :: idt
394  character(len=LENVARNAME) :: checkname
395  character(len=LINELENGTH) :: datatype
396  integer(I4B) :: isize, checksize
397  integer(I4B), pointer :: intptr
398 
399  idt => &
400  get_param_definition_type(mf6_input%param_dfns, &
401  mf6_input%component_type, &
402  mf6_input%subcomponent_type, &
403  blockname, tagname, '')
404  if (idt%required) then
405  in_scope = .true.
406  return
407  else
408  in_scope = .false.
409  datatype = idt_datatype(idt)
410  if (datatype == 'KEYSTRING' .or. &
411  datatype == 'RECARRAY' .or. &
412  datatype == 'RECORD') return
413  end if
414 
415  ! initialize
416  checkname = ''
417  checksize = 0
418 
419  if (tagname == 'AUXVAR' .or. &
420  tagname == 'AUX') then
421  checkname = 'NAUX'
422  else if (tagname == 'BOUNDNAME') then
423  checkname = 'BOUNDNAMES'
424  else if (tagname == 'I'//trim(mf6_input%subcomponent_type(1:3))) then
425  if (this%loadtype == layerarray) in_scope = .true.
426  else
427  select case (mf6_input%subcomponent_type)
428  case ('EVT')
429  if (tagname == 'PXDP' .or. tagname == 'PETM') then
430  checkname = 'NSEG'
431  checksize = 1
432  else if (tagname == 'PETM0') then
433  checkname = 'SURFRATESPEC'
434  end if
435  case ('MVR', 'MVT', 'MVE')
436  if (tagname == 'MNAME' .or. &
437  tagname == 'MNAME1' .or. &
438  tagname == 'MNAME2') then
439  checkname = 'MODELNAMES'
440  end if
441  case ('NAM')
442  in_scope = .true.
443  case ('SSM')
444  if (tagname == 'MIXED') in_scope = .true.
445  case default
446  errmsg = 'LoadContext in_scope needs new check for: '// &
447  trim(idt%tagname)
448  call store_error(errmsg, .true.)
449  end select
450  end if
451 
452  ! apply checks
453  if (.not. in_scope) then
454  call get_isize(checkname, mf6_input%mempath, isize)
455  if (isize > 0) then
456  call mem_setptr(intptr, checkname, mf6_input%mempath)
457  if (intptr > checksize) in_scope = .true.
458  end if
459  end if
460  end function in_scope
461 
462  !> @brief set set of in scope parameters for package
463  !<
464  subroutine set_params(this)
469  class(loadcontexttype) :: this
470  type(inputparamdefinitiontype), pointer :: idt, aidt
471  character(len=LINELENGTH), dimension(:), allocatable :: tags
472  character(len=LINELENGTH), dimension(:), allocatable :: cols
473  integer(I4B) :: keepcnt, iparam, nparam
474  logical(LGP) :: keep
475 
476  ! initialize
477  keepcnt = 0
478 
479  if (this%loadtype == list) then
480  ! get aggregate param definition for period block
481  aidt => &
482  get_aggregate_definition_type(this%mf6_input%aggregate_dfns, &
483  this%mf6_input%component_type, &
484  this%mf6_input%subcomponent_type, &
485  this%blockname)
486  ! split recarray definition
487  call idt_parse_rectype(aidt, cols, nparam)
488  else
489  nparam = size(this%mf6_input%param_dfns)
490  end if
491 
492  ! allocate dfn input params
493  do iparam = 1, nparam
494  if (this%loadtype == list) then
495  idt => get_param_definition_type(this%mf6_input%param_dfns, &
496  this%mf6_input%component_type, &
497  this%mf6_input%subcomponent_type, &
498  this%blockname, cols(iparam), '')
499  else
500  idt => this%mf6_input%param_dfns(iparam)
501  end if
502 
503  if (idt%blockname /= this%blockname) then
504  keep = .false.
505  else
506  keep = this%in_scope(this%mf6_input, this%blockname, idt%tagname)
507  end if
508 
509  if (keep) then
510  keepcnt = keepcnt + 1
511  call expandarray(tags)
512  tags(keepcnt) = trim(idt%tagname)
513  end if
514  end do
515 
516  ! update nparam
517  nparam = keepcnt
518 
519  ! allocate filtcols
520  allocate (this%params(nparam))
521 
522  ! set filtcols
523  do iparam = 1, nparam
524  this%params(iparam) = trim(tags(iparam))
525  end do
526 
527  ! cleanup
528  if (allocated(tags)) deallocate (tags)
529  end subroutine set_params
530 
531  !> @brief allocate a read state variable
532  !!
533  !! Create and set a read state variable, e.g. 'INRECHARGE',
534  !! which are updated per iper load as follows:
535  !! -1: unset, not in use
536  !! 0: not read in most recent period block
537  !! 1: numeric input read in most recent period block
538  !! 2: time series input read in most recent period block
539  !!
540  !<
541  function rsv_alloc(this, mf6varname) result(varname)
542  use constantsmodule, only: lenvarname
544  class(loadcontexttype) :: this
545  character(len=*), intent(in) :: mf6varname
546  character(len=LENVARNAME) :: varname
547  integer(I4B), pointer :: intvar
548  varname = rsv_name(mf6varname)
549  call mem_allocate(intvar, varname, this%mf6_input%mempath)
550  intvar = -1
551  end function rsv_alloc
552 
553  !> @brief destroy input context object
554  !<
555  subroutine destroy(this)
556  class(loadcontexttype) :: this
557 
558  if (this%ctxtype == exchange .or. &
559  this%ctxtype == stresspkg) then
560  ! deallocate local
561  deallocate (this%naux)
562  deallocate (this%ncpl)
563  deallocate (this%nodes)
564  deallocate (this%maxbound)
565  deallocate (this%boundnames)
566  deallocate (this%iprpak)
567  end if
568 
569  ! nullify
570  nullify (this%naux)
571  nullify (this%nbound)
572  nullify (this%ncpl)
573  nullify (this%nodes)
574  nullify (this%maxbound)
575  nullify (this%boundnames)
576  nullify (this%iprpak)
577  nullify (this%auxname_cst)
578  nullify (this%boundname_cst)
579  nullify (this%auxvar)
580  nullify (this%mshape)
581  end subroutine destroy
582 
583  !> @brief create read state variable name
584  !<
585  function rsv_name(mf6varname) result(varname)
586  use constantsmodule, only: lenvarname
587  character(len=*), intent(in) :: mf6varname
588  character(len=LENVARNAME) :: varname
589  integer(I4B) :: ilen
590  character(len=2) :: prefix = 'IN'
591  ilen = len_trim(mf6varname)
592  if (ilen > (lenvarname - len(prefix))) then
593  varname = prefix//mf6varname(1:(lenvarname - len(prefix)))
594  else
595  varname = prefix//trim(mf6varname)
596  end if
597  end function rsv_name
598 
599  !> @brief allocate character string type array
600  !<
601  subroutine allocate_charstr1d(strlen, nrow, varname, mempath)
603  integer(I4B), intent(in) :: strlen !< string number of characters
604  integer(I4B), intent(in) :: nrow !< integer array number of rows
605  character(len=*), intent(in) :: varname !< variable name
606  character(len=*), intent(in) :: mempath !< variable mempath
607  type(characterstringtype), dimension(:), pointer, &
608  contiguous :: charstr1d
609  integer(I4B) :: n
610  call mem_allocate(charstr1d, strlen, nrow, varname, mempath)
611  do n = 1, nrow
612  charstr1d(n) = ''
613  end do
614  end subroutine allocate_charstr1d
615 
616  !> @brief allocate int1d
617  !<
618  subroutine allocate_int1d(nrow, varname, mempath)
620  integer(I4B), intent(in) :: nrow !< integer array number of rows
621  character(len=*), intent(in) :: varname !< variable name
622  character(len=*), intent(in) :: mempath !< variable mempath
623  integer(I4B), dimension(:), pointer, contiguous :: int1d
624  integer(I4B) :: n
625  call mem_allocate(int1d, nrow, varname, mempath)
626  do n = 1, nrow
627  int1d(n) = izero
628  end do
629  end subroutine allocate_int1d
630 
631  !> @brief allocate int2d
632  !<
633  subroutine allocate_int2d(ncol, nrow, varname, mempath)
635  integer(I4B), intent(in) :: ncol !< integer array number of cols
636  integer(I4B), intent(in) :: nrow !< integer array number of rows
637  character(len=*), intent(in) :: varname !< variable name
638  character(len=*), intent(in) :: mempath !< variable mempath
639  integer(I4B), dimension(:, :), pointer, contiguous :: int2d
640  integer(I4B) :: n, m
641  call mem_allocate(int2d, ncol, nrow, varname, mempath)
642  do m = 1, nrow
643  do n = 1, ncol
644  int2d(n, m) = izero
645  end do
646  end do
647  end subroutine allocate_int2d
648 
649  !> @brief allocate dbl1d
650  !<
651  subroutine allocate_dbl1d(nrow, varname, mempath)
653  integer(I4B), intent(in) :: nrow !< integer array number of rows
654  character(len=*), intent(in) :: varname !< variable name
655  character(len=*), intent(in) :: mempath !< variable mempath
656  real(DP), dimension(:), pointer, contiguous :: dbl1d
657  integer(I4B) :: n
658  call mem_allocate(dbl1d, nrow, varname, mempath)
659  do n = 1, nrow
660  dbl1d(n) = dzero
661  end do
662  end subroutine allocate_dbl1d
663 
664  !> @brief allocate dbl2d
665  !<
666  subroutine allocate_dbl2d(ncol, nrow, varname, mempath)
668  integer(I4B), intent(in) :: ncol !< integer array number of cols
669  integer(I4B), intent(in) :: nrow !< integer array number of rows
670  character(len=*), intent(in) :: varname !< variable name
671  character(len=*), intent(in) :: mempath !< variable mempath
672  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
673  integer(I4B) :: n, m
674  call mem_allocate(dbl2d, ncol, nrow, varname, mempath)
675  do m = 1, nrow
676  do n = 1, ncol
677  dbl2d(n, m) = dzero
678  end do
679  end do
680  end subroutine allocate_dbl2d
681 
682  !> @brief allocate intptr and update from input contextset intptr to varname
683  !!
684  !<
685  subroutine setval(intptr, varname, mempath)
687  integer(I4B), pointer, intent(inout) :: intptr
688  character(len=*), intent(in) :: varname
689  character(len=*), intent(in) :: mempath
690  logical(LGP) :: found
691  allocate (intptr)
692  intptr = 0
693  call mem_set_value(intptr, varname, mempath, found)
694  end subroutine setval
695 
696  !> @brief set intptr to varname
697  !!
698  !<
699  subroutine setptr_int(intptr, varname, mempath)
701  integer(I4B), pointer, intent(inout) :: intptr
702  character(len=*), intent(in) :: varname
703  character(len=*), intent(in) :: mempath
704  integer(I4B) :: isize
705  call get_isize(varname, mempath, isize)
706  if (isize > -1) then
707  call mem_setptr(intptr, varname, mempath)
708  else
709  call mem_allocate(intptr, varname, mempath)
710  intptr = 0
711  end if
712  end subroutine setptr_int
713 
714  !> @brief set charstr1d pointer to varname
715  !<
716  subroutine setptr_charstr1d(charstr1d, varname, mempath, strlen)
718  type(characterstringtype), dimension(:), pointer, &
719  contiguous, intent(inout) :: charstr1d
720  character(len=*), intent(in) :: varname
721  character(len=*), intent(in) :: mempath
722  integer(I4B), intent(in) :: strlen
723  integer(I4B) :: isize
724  call get_isize(varname, mempath, isize)
725  if (isize > -1) then
726  call mem_setptr(charstr1d, varname, mempath)
727  else
728  call mem_allocate(charstr1d, strlen, 0, varname, mempath)
729  end if
730  end subroutine setptr_charstr1d
731 
732  !> @brief set auxvar pointer
733  !!
734  !<
735  subroutine setptr_auxvar(auxvar, mempath)
737  real(DP), dimension(:, :), pointer, &
738  contiguous, intent(inout) :: auxvar
739  character(len=*), intent(in) :: mempath
740  integer(I4B) :: isize
741  call get_isize('AUXVAR', mempath, isize)
742  if (isize > -1) then
743  call mem_setptr(auxvar, 'AUXVAR', mempath)
744  else
745  call mem_allocate(auxvar, 0, 0, 'AUXVAR', mempath)
746  end if
747  end subroutine setptr_auxvar
748 
749 end module loadcontextmodule
subroutine init()
Definition: GridSorting.f90:24
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:45
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
integer(i4b), parameter lenauxname
maximum length of a aux variable
Definition: Constants.f90:35
integer(i4b), parameter lenboundname
maximum length of a bound name
Definition: Constants.f90:36
integer(i4b), parameter izero
integer constant zero
Definition: Constants.f90:51
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename)
Return parameter definition.
type(inputparamdefinitiontype) function, pointer, public get_aggregate_definition_type(input_definition_types, component_type, subcomponent_type, blockname)
Return aggregate definition.
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
This module contains the InputDefinitionModule.
subroutine, public upcase(word)
Convert to upper case.
This module defines variable data types.
Definition: kind.f90:8
This module contains the LoadContextModule.
Definition: LoadContext.f90:10
subroutine set_params(this)
set set of in scope parameters for package
subroutine allocate_dbl2d(ncol, nrow, varname, mempath)
allocate dbl2d
subroutine tags(this, params, nparam, input_name, create)
get in scope package params
subroutine setptr_auxvar(auxvar, mempath)
set auxvar pointer
subroutine allocate_charstr1d(strlen, nrow, varname, mempath)
allocate character string type array
subroutine allocate_int1d(nrow, varname, mempath)
allocate int1d
@ load_undef
undefined load type
Definition: LoadContext.f90:28
@ gridarray
readarraygrid load
Definition: LoadContext.f90:31
@ layerarray
readasarrays load
Definition: LoadContext.f90:30
@ list
list (structarray) based load
Definition: LoadContext.f90:29
subroutine allocate_dbl1d(nrow, varname, mempath)
allocate dbl1d
@ stresspkg
model stress package context type
Definition: LoadContext.f90:40
@ exchange
exchange context type
Definition: LoadContext.f90:41
@ model
model context type
Definition: LoadContext.f90:38
@ root
root context type
Definition: LoadContext.f90:36
@ modelpkg
model package context type
Definition: LoadContext.f90:39
@ sim
sim context type
Definition: LoadContext.f90:37
@ context_undef
undefined context type
Definition: LoadContext.f90:35
subroutine setval(intptr, varname, mempath)
allocate intptr and update from input contextset intptr to varname
subroutine allocate_scalars(this)
allocate scalars
subroutine allocate_param(this, idt)
allocate a package dynamic input parameter
subroutine allocate_arrays(this)
allocate arrays
subroutine setptr_int(intptr, varname, mempath)
set intptr to varname
subroutine allocate_int2d(ncol, nrow, varname, mempath)
allocate int2d
subroutine destroy(this)
destroy input context object
character(len=lenvarname) function, public rsv_name(mf6varname)
create read state variable name
logical(lgp) function in_scope(this, mf6_input, blockname, tagname)
establish if input parameter is in scope for package load
character(len=lenvarname) function rsv_alloc(this, mf6varname)
allocate a read state variable
subroutine setptr_charstr1d(charstr1d, varname, mempath, strlen)
set charstr1d pointer to varname
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains the ModelPackageInputsModule.
logical(lgp) function, public supported_model(ctype)
is this a supported MODFLOW 6 model type
This module contains the ModflowInputModule.
Definition: ModflowInput.f90:9
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition: Sim.f90:203
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=maxcharlen) errmsg
error message string
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
derived type for boundary package input context
Definition: LoadContext.f90:61
Pointer type for read state variable.
Definition: LoadContext.f90:46
derived type for storing input definition for a file