MODFLOW 6  version 6.8.0.dev0
USGS Modular Hydrologic Model
InputLoadType.f90
Go to the documentation of this file.
1 !> @brief This module contains the InputLoadTypeModule
2 !!
3 !! This module defines types that support generic IDM
4 !! static and dynamic input loading.
5 !!
6 !<
8 
9  use kindmodule, only: dp, i4b, lgp
12  use simvariablesmodule, only: errmsg
15  use listmodule, only: listtype
18 
19  implicit none
20  private
21  public :: staticpkgloadbasetype
22  public :: dynamicpkgloadbasetype
23  public :: modeldynamicpkgstype
26  public :: subpackagelisttype
27  public :: model_inputs
28 
29  !> @brief type representing package subpackage list
31  character(len=LENCOMPONENTNAME), dimension(:), allocatable :: pkgtypes
32  character(len=LENCOMPONENTNAME), dimension(:), allocatable :: component_types
33  character(len=LENCOMPONENTNAME), dimension(:), &
34  allocatable :: subcomponent_types
35  character(len=LENCOMPONENTNAME), dimension(:), &
36  allocatable :: subcomponent_names
37  character(len=LINELENGTH), dimension(:), allocatable :: filenames
38  character(len=LENCOMPONENTNAME) :: component_type
39  character(len=LENCOMPONENTNAME) :: component_name
40  integer(I4B) :: pnum
41  contains
42  procedure :: create => subpkg_create
43  procedure :: add => subpkg_add
44  procedure :: set_names => subpkg_names
45  procedure :: destroy => subpkg_destroy
46  end type subpackagelisttype
47 
48  !> @brief Static loader type
49  !!
50  !! This type is a base concrete type for a static input loader
51  !!
52  !<
54  type(modflowinputtype) :: mf6_input !< description of modflow6 input
55  type(ncpackagevarstype), pointer :: nc_vars => null()
56  character(len=LENCOMPONENTNAME) :: component_name !< name of component
57  character(len=LINELENGTH) :: component_input_name !< component input name, e.g. model name file
58  character(len=LINELENGTH) :: input_name !< input name, e.g. package *.chd file
59  integer(I4B) :: iperblock !< index of period block on block definition list
60  type(subpackagelisttype) :: subpkg_list !< list of input subpackages
61  contains
62  procedure :: init => static_init
63  procedure :: create_subpkg_list
64  procedure :: destroy => static_destroy
65  end type staticpkgloadtype
66 
67  !> @brief Base abstract type for static input loader
68  !!
69  !! IDM sources should extend and implement this type
70  !!
71  !<
72  type, abstract, extends(staticpkgloadtype) :: staticpkgloadbasetype
73  contains
74  procedure(load_if), deferred :: load
75  end type staticpkgloadbasetype
76 
77  !> @brief Dynamic loader type
78  !!
79  !! This type is a base concrete type for a dynamic (period) input loader
80  !!
81  !<
83  type(modflowinputtype) :: mf6_input !< description of modflow6 input
84  type(ncpackagevarstype), pointer :: nc_vars => null()
85  character(len=LENCOMPONENTNAME) :: component_name !< name of component
86  character(len=LINELENGTH) :: component_input_name !< component input name, e.g. model name file
87  character(len=LINELENGTH) :: input_name !< input name, e.g. package *.chd file
88  character(len=LINELENGTH), dimension(:), allocatable :: param_names !< dynamic param tagnames
89  logical(LGP) :: readasarrays !< readasarrays style input package
90  logical(LGP) :: readarraygrid !< readarraygrid style input package
91  logical(LGP) :: has_keystring !< period block uses keystring-based dispatch
92  integer(I4B) :: iperblock !< index of period block on block definition list
93  integer(I4B) :: iout !< inunit number for logging
94  integer(I4B) :: nparam !< number of in scope params
95  contains
96  procedure :: init => dynamic_init
97  procedure :: df => dynamic_df
98  procedure :: ad => dynamic_ad
99  procedure :: destroy => dynamic_destroy
100  end type dynamicpkgloadtype
101 
102  !> @brief Base abstract type for dynamic input loader
103  !!
104  !! IDM sources should extend and implement this type
105  !!
106  !<
107  type, abstract, extends(dynamicpkgloadtype) :: dynamicpkgloadbasetype
108  contains
109  procedure(period_load_if), deferred :: rp
110  end type dynamicpkgloadbasetype
111 
112  !> @brief load interfaces for source static and dynamic types
113  !<
114  abstract interface
115  function load_if(this, iout) result(dynamic_loader)
117  class(staticpkgloadbasetype), intent(inout) :: this
118  integer(I4B), intent(in) :: iout
119  class(dynamicpkgloadbasetype), pointer :: dynamic_loader
120  end function load_if
121  subroutine period_load_if(this)
122  import dynamicpkgloadbasetype, i4b
123  class(dynamicpkgloadbasetype), intent(inout) :: this
124  end subroutine
125  end interface
126 
127  !> @brief type for storing a dynamic package load list
128  !!
129  !! This type is used to store a list of package
130  !! dynamic load types for a model
131  !!
132  !<
134  character(len=LENCOMPONENTNAME) :: modeltype !< type of model
135  character(len=LENMODELNAME) :: modelname !< name of model
136  character(len=LINELENGTH) :: modelfname !< name of model input file
137  type(listtype) :: pkglist !< model package list
138  character(len=LINELENGTH) :: nc_fname !< name of model netcdf input
139  integer(I4B) :: ncid !< netcdf file handle
140  integer(I4B) :: iout
141  contains
142  procedure :: init => dynamicpkgs_init
143  procedure :: add => dynamicpkgs_add
144  procedure :: get => dynamicpkgs_get
145  procedure :: rp => dynamicpkgs_rp
146  procedure :: df => dynamicpkgs_df
147  procedure :: ad => dynamicpkgs_ad
148  procedure :: size => dynamicpkgs_size
149  procedure :: destroy => dynamicpkgs_destroy
150  end type modeldynamicpkgstype
151 
153 
154 contains
155 
156  !> @brief initialize a SubPackageListType object
157  !<
158  subroutine subpkg_create(this, component_type, component_name)
159  class(subpackagelisttype) :: this
160  character(len=*), intent(in) :: component_type
161  character(len=*), intent(in) :: component_name
162 
163  ! initialize
164  this%pnum = 0
165  this%component_type = component_type
166  this%component_name = component_name
167 
168  ! allocate arrays
169  allocate (this%pkgtypes(0))
170  allocate (this%component_types(0))
171  allocate (this%subcomponent_types(0))
172  allocate (this%subcomponent_names(0))
173  allocate (this%filenames(0))
174  end subroutine subpkg_create
175 
176  !> @brief append one subpackage file instance to the list
177  !<
178  subroutine subpkg_add(this, pkgtype, component_type, subcomponent_type, &
179  filename)
181  class(subpackagelisttype) :: this
182  character(len=*), intent(in) :: pkgtype
183  character(len=*), intent(in) :: component_type
184  character(len=*), intent(in) :: subcomponent_type
185  character(len=*), intent(in) :: filename
186 
187  ! reallocate
188  call expandarray(this%pkgtypes)
189  call expandarray(this%component_types)
190  call expandarray(this%subcomponent_types)
191  call expandarray(this%subcomponent_names)
192  call expandarray(this%filenames)
193 
194  ! add new package instance
195  this%pnum = this%pnum + 1
196  this%pkgtypes(this%pnum) = pkgtype
197  this%component_types(this%pnum) = component_type
198  this%subcomponent_types(this%pnum) = subcomponent_type
199  this%subcomponent_names(this%pnum) = ''
200  this%filenames(this%pnum) = filename
201  end subroutine subpkg_add
202 
203  !> @brief Assign subpackage names and mempaths for IDM-integrated subpackages.
204  !<
205  subroutine subpkg_names(this, parent_sctype, parent_scname, &
206  parent_mempath, modelfname)
212  class(subpackagelisttype) :: this
213  character(len=*), intent(in) :: parent_sctype
214  character(len=*), intent(in) :: parent_scname
215  character(len=*), intent(in) :: parent_mempath
216  character(len=*), intent(in) :: modelfname
217  character(len=LINELENGTH), dimension(:), allocatable :: subptypes
218  integer(I4B), dimension(:), allocatable :: nsubptypes
219  type(characterstringtype), dimension(:), pointer, contiguous :: mempaths
220  character(len=LINELENGTH), pointer :: input_fname
221  character(len=LENVARNAME) :: mempath_key
222  character(len=LENVARNAME) :: subpkg_prefix
223  character(len=LENMEMPATH) :: mempath
224  integer(I4B) :: subpkg_inst, n, m
225 
226  ! nothing to do if no subpackages were added
227  if (size(this%pkgtypes) == 0) return
228 
229  ! UTL packages do not themselves have subpackages
230  if (idm_utl_type(this%component_type, parent_sctype)) return
231 
232  ! build subpkg_prefix from the parent package identity
233  subpkg_prefix = build_subpkg_prefix(this%component_type, &
234  this%component_name, parent_sctype, &
235  parent_scname, modelfname)
236 
237  ! deduplicate pkgtypes into unique list with per-type counts
238  call deduplicate_pkgtypes(this%pkgtypes, subptypes, nsubptypes)
239 
240  ! allocate mempath arrays for each subpackage type, create and
241  ! store the memory paths for package side access.
242  do n = 1, size(subptypes)
243  subpkg_inst = 0
244  mempath_key = trim(subptypes(n))//'_MEMPATH'
245  call mem_allocate(mempaths, lenmempath, nsubptypes(n), &
246  mempath_key, parent_mempath)
247  do m = 1, size(this%pkgtypes)
248  if (this%pkgtypes(m) == subptypes(n)) then
249  subpkg_inst = subpkg_inst + 1
250  ! set the subpackage name
251  write (this%subcomponent_names(m), '(a,i0)') &
252  trim(subpkg_prefix)//trim(this%subcomponent_types(m)), subpkg_inst
253  ! create and set mempath
254  mempath = create_mem_path(this%component_name, &
255  this%subcomponent_names(m), &
256  idm_context)
257  mempaths(subpkg_inst) = mempath
258  ! create and set INPUT_FNAME string in each new memory path.
259  call mem_allocate(input_fname, linelength, 'INPUT_FNAME', mempath)
260  input_fname = trim(this%filenames(m))
261  end if
262  end do
263  end do
264 
265  deallocate (subptypes)
266  deallocate (nsubptypes)
267  end subroutine subpkg_names
268 
269  !> @brief Build the subpackage name prefix for the given parent package.
270  !!
271  !! For single-instance parents (e.g. NPF), prefix is '<TYPE>-'.
272  !! For multi-instance parents (e.g. WEL), prefix includes the instance
273  !! number: '<TYPE><N>-' (e.g. 'WEL1-'). EXG packages return ''.
274  !<
275  function build_subpkg_prefix(component_type, component_name, &
276  parent_sctype, parent_scname, &
277  modelfname) result(subpkg_prefix)
285  character(len=*), intent(in) :: component_type
286  character(len=*), intent(in) :: component_name
287  character(len=*), intent(in) :: parent_sctype
288  character(len=*), intent(in) :: parent_scname
289  character(len=*), intent(in) :: modelfname
290  character(len=LENVARNAME) :: subpkg_prefix
291  type(characterstringtype), dimension(:), contiguous, pointer :: pnames, ftypes
292  character(len=LENVARNAME) :: parent_type, parent_ftype, parent_name
293  character(len=LENMEMPATH) :: model_mempath
294  integer(I4B) :: parent_inst, n
295  logical(LGP) :: multi
296 
297  subpkg_prefix = ''
298 
299  ! EXG (exchange) packages have no model NAM file and don't need a prefix
300  if (component_type == 'EXG') return
301 
302  ! resolve definition names to the namefile packages block type name
303  select case (parent_sctype)
304  case ('EVTA', 'RCHA', 'RIVG', 'CHDG', 'WELG', 'DRNG', 'GHBG')
305  parent_type = parent_sctype(1:3)
306  case default
307  parent_type = parent_sctype
308  end select
309 
310  ! build the filetype string used to match FTYPE in the NAM packages block
311  parent_ftype = trim(parent_type)//'6'
312 
313  ! determine if multi-package type
314  if (idm_integrated(component_type, parent_type)) then
315  multi = idm_multi_package(component_type, parent_type)
316  else
317  multi = multi_package_type(component_type, parent_type, parent_ftype)
318  end if
319 
320  if (multi) then
321  ! identify instance number of this package type in the namefile packages
322  ! block and use to set subpackage prefix
323  model_mempath = create_mem_path(component_name, 'NAM', idm_context)
324  call mem_setptr(pnames, 'PNAME', model_mempath)
325  call mem_setptr(ftypes, 'FTYPE', model_mempath)
326 
327  parent_inst = 0
328  do n = 1, size(pnames)
329  if (ftypes(n) == parent_ftype) then
330  parent_inst = parent_inst + 1
331  parent_name = pnames(n)
332  if (parent_name == '') &
333  parent_name = idm_pkg_instance_name(parent_type, parent_inst)
334  if (parent_name == parent_scname) then
335  write (subpkg_prefix, '(a,i0,a)') trim(parent_type), parent_inst, '-'
336  exit
337  end if
338  end if
339  end do
340 
341  if (subpkg_prefix == '') then
342  errmsg = &
343  'Internal IDM error: subpackage load cannot identify &
344  &package "'//trim(parent_scname)//'" in model name file &
345  &packages block.'
346  call store_error(errmsg)
347  call store_error_filename(modelfname)
348  end if
349  else
350  ! single-instance parent: prefix is '<TYPE>-', e.g. 'NPF-'
351  write (subpkg_prefix, '(2a)') trim(parent_type), '-'
352  end if
353  end function build_subpkg_prefix
354 
355  !> @brief Deduplicate pkgtypes into unique entries with counts (run-length encoding).
356  !!
357  !! INVARIANT: pkgtypes entries for the same type must be contiguous.
358  !<
359  subroutine deduplicate_pkgtypes(pkgtypes, subptypes, nsubptypes)
361  character(len=LENCOMPONENTNAME), intent(in) :: pkgtypes(:)
362  character(len=LINELENGTH), allocatable, intent(out) :: subptypes(:)
363  integer(I4B), allocatable, intent(out) :: nsubptypes(:)
364  character(len=LENCOMPONENTNAME) :: prev
365  integer(I4B) :: n, ntype
366 
367  allocate (subptypes(0))
368  allocate (nsubptypes(0))
369  prev = ''
370  ntype = 0
371  do n = 1, size(pkgtypes)
372  if (pkgtypes(n) /= prev) then
373  ntype = ntype + 1
374  prev = pkgtypes(n)
375  call expandarray(subptypes)
376  call expandarray(nsubptypes)
377  subptypes(ntype) = prev
378  nsubptypes(ntype) = 1
379  else
380  nsubptypes(ntype) = nsubptypes(ntype) + 1
381  end if
382  end do
383  end subroutine deduplicate_pkgtypes
384 
385  !> @brief destroy a SubPackageListType object
386  !<
387  subroutine subpkg_destroy(this)
388  class(subpackagelisttype) :: this
389  ! deallocate arrays
390  deallocate (this%pkgtypes)
391  deallocate (this%component_types)
392  deallocate (this%subcomponent_types)
393  deallocate (this%subcomponent_names)
394  deallocate (this%filenames)
395  end subroutine subpkg_destroy
396 
397  !> @brief initialize static package loader
398  !!
399  !<
400  subroutine static_init(this, mf6_input, component_name, component_input_name, &
401  input_name)
402  class(staticpkgloadtype), intent(inout) :: this
403  type(modflowinputtype), intent(in) :: mf6_input
404  character(len=*), intent(in) :: component_name
405  character(len=*), intent(in) :: component_input_name
406  character(len=*), intent(in) :: input_name
407  integer(I4B) :: iblock
408 
409  this%mf6_input = mf6_input
410  this%component_name = component_name
411  this%component_input_name = component_input_name
412  this%input_name = input_name
413  this%iperblock = 0
414 
415  ! create subpackage list
416  call this%subpkg_list%create(this%mf6_input%component_type, &
417  this%mf6_input%component_name)
418 
419  ! identify period block definition
420  do iblock = 1, size(mf6_input%block_dfns)
421  if (mf6_input%block_dfns(iblock)%blockname == 'PERIOD') then
422  this%iperblock = iblock
423  exit
424  end if
425  end do
426  end subroutine static_init
427 
428  !> @brief create the subpackage list
429  !!
430  !<
431  subroutine create_subpkg_list(this)
436  class(staticpkgloadtype), intent(inout) :: this
437  character(len=16), dimension(:), pointer :: subpkgs
438  type(characterstringtype), dimension(:), pointer, &
439  contiguous :: fnames
440  character(len=LINELENGTH) :: tag, fname, pkgtype
441  character(len=LENFTYPE) :: c_type, sc_type
442  character(len=16) :: subpkg
443  integer(I4B) :: idx, n, m, isize
444 
445  ! set pointer to package (idm integrated) subpackage list
446  subpkgs => idm_subpackages(this%mf6_input%component_type, &
447  this%mf6_input%subcomponent_type)
448 
449  ! check each subpackage type this package supports
450  do n = 1, size(subpkgs)
451  ! check for input matching this supported subpackage
452  subpkg = subpkgs(n)
453  idx = index(subpkg, '-')
454 
455  if (idx > 0) then
456  ! split string in component/subcomponent types
457  c_type = subpkg(1:idx - 1)
458  sc_type = subpkg(idx + 1:len_trim(subpkg))
459 
460  if (idm_integrated(c_type, sc_type)) then
461  ! construct FILEIN filename tag
462  pkgtype = trim(sc_type)//'6'
463  tag = trim(pkgtype)//'_FILENAME'
464  call get_isize(tag, this%mf6_input%mempath, isize)
465  if (isize > 0) then
466  ! add all input files of this type to subpackage type list
467  call mem_setptr(fnames, tag, this%mf6_input%mempath)
468  do m = 1, size(fnames)
469  fname = fnames(m)
470  call this%subpkg_list%add(pkgtype, c_type, sc_type, fname)
471  end do
472  end if
473  else
474  errmsg = 'Identified subpackage is not IDM integrated. Remove dfn &
475  &subpackage tagline for package "'//trim(subpkg)//'".'
476  call store_error(errmsg)
477  call store_error_filename(this%input_name)
478  end if
479  end if
480  end do
481 
482  ! create subpackage names and use to store mempaths in memory manager
483  call this%subpkg_list%set_names(this%mf6_input%subcomponent_type, &
484  this%mf6_input%subcomponent_name, &
485  this%mf6_input%mempath, &
486  this%component_input_name)
487  end subroutine create_subpkg_list
488 
489  subroutine static_destroy(this)
490  class(staticpkgloadtype), intent(inout) :: this
491  call this%subpkg_list%destroy()
492  if (associated(this%nc_vars)) then
493  call this%nc_vars%destroy()
494  deallocate (this%nc_vars)
495  nullify (this%nc_vars)
496  end if
497  end subroutine static_destroy
498 
499  !> @brief initialize dynamic package loader
500  !!
501  !! Any managed memory pointed to from model/package context
502  !! must be allocated when dynamic loader is initialized.
503  !!
504  !<
505  subroutine dynamic_init(this, mf6_input, component_name, component_input_name, &
506  input_name, iperblock, iout)
507  use simvariablesmodule, only: errmsg
510  class(dynamicpkgloadtype), intent(inout) :: this
511  type(modflowinputtype), intent(in) :: mf6_input
512  character(len=*), intent(in) :: component_name
513  character(len=*), intent(in) :: component_input_name
514  character(len=*), intent(in) :: input_name
515  integer(I4B), intent(in) :: iperblock
516  integer(I4B), intent(in) :: iout
517  type(inputparamdefinitiontype), pointer :: idt
518  integer(I4B) :: iparam
519 
520  this%mf6_input = mf6_input
521  this%component_name = component_name
522  this%component_input_name = component_input_name
523  this%input_name = input_name
524  this%readasarrays = .false.
525  this%readarraygrid = .false.
526  this%has_keystring = .false.
527  this%iperblock = iperblock
528  this%nparam = 0
529  this%iout = iout
530  nullify (idt)
531 
532  ! throw error and exit if not found
533  if (this%iperblock == 0) then
534  write (errmsg, '(a,a)') &
535  'Programming error. (IDM) PERIOD block not found in '&
536  &'dynamic package input block dfns: ', &
537  trim(mf6_input%subcomponent_name)
538  call store_error(errmsg)
539  call store_error_filename(this%input_name)
540  end if
541 
542  ! set readasarrays and readarraygrid
543  if (mf6_input%block_dfns(iperblock)%aggregate) then
544  ! no-op
545  else
546  do iparam = 1, size(mf6_input%param_dfns)
547  idt => mf6_input%param_dfns(iparam)
548  if (idt%blockname == 'OPTIONS') then
549  select case (idt%tagname)
550  case ('READASARRAYS')
551  this%readasarrays = .true.
552  case ('READARRAYGRID')
553  this%readarraygrid = .true.
554  case default
555  ! no-op
556  end select
557  end if
558  end do
559  end if
560 
561  ! detect keystring packages
562  if (mf6_input%block_dfns(iperblock)%aggregate) then
563  if (is_keystring_period(mf6_input)) this%has_keystring = .true.
564  end if
565  end subroutine dynamic_init
566 
567  !> @brief dynamic package loader define
568  !!
569  !<
570  subroutine dynamic_df(this)
571  class(dynamicpkgloadtype), intent(inout) :: this
572  ! override in derived type
573  end subroutine dynamic_df
574 
575  !> @brief dynamic package loader advance
576  !!
577  !<
578  subroutine dynamic_ad(this)
579  class(dynamicpkgloadtype), intent(inout) :: this
580  ! override in derived type
581  end subroutine dynamic_ad
582 
583  !> @brief dynamic package loader destroy
584  !!
585  !<
586  subroutine dynamic_destroy(this)
590  class(dynamicpkgloadtype), intent(inout) :: this
591 
592  ! clean up netcdf variables structure
593  if (associated(this%nc_vars)) then
594  call this%nc_vars%destroy()
595  deallocate (this%nc_vars)
596  nullify (this%nc_vars)
597  end if
598 
599  ! deallocate package static and dynamic input context
600  call memorystore_remove(this%mf6_input%component_name, &
601  this%mf6_input%subcomponent_name, &
602  idm_context)
603  end subroutine dynamic_destroy
604 
605  !> @brief model dynamic packages init
606  !!
607  !<
608  subroutine dynamicpkgs_init(this, modeltype, modelname, modelfname, nc_fname, &
609  ncid, iout)
610  class(modeldynamicpkgstype), intent(inout) :: this
611  character(len=*), intent(in) :: modeltype
612  character(len=*), intent(in) :: modelname
613  character(len=*), intent(in) :: modelfname
614  character(len=*), intent(in) :: nc_fname
615  integer(I4B), intent(in) :: ncid
616  integer(I4B), intent(in) :: iout
617  this%modeltype = modeltype
618  this%modelname = modelname
619  this%modelfname = modelfname
620  this%nc_fname = nc_fname
621  this%ncid = ncid
622  this%iout = iout
623  end subroutine dynamicpkgs_init
624 
625  !> @brief add package to model dynamic packages list
626  !!
627  !<
628  subroutine dynamicpkgs_add(this, dynamic_pkg)
629  class(modeldynamicpkgstype), intent(inout) :: this
630  class(dynamicpkgloadbasetype), pointer, intent(inout) :: dynamic_pkg
631  class(*), pointer :: obj
632  obj => dynamic_pkg
633  call this%pkglist%add(obj)
634  end subroutine dynamicpkgs_add
635 
636  !> @brief retrieve package from model dynamic packages list
637  !!
638  !<
639  function dynamicpkgs_get(this, idx) result(res)
640  class(modeldynamicpkgstype), intent(inout) :: this
641  integer(I4B), intent(in) :: idx
642  class(dynamicpkgloadbasetype), pointer :: res
643  class(*), pointer :: obj
644  nullify (res)
645  obj => this%pkglist%GetItem(idx)
646  if (associated(obj)) then
647  select type (obj)
648  class is (dynamicpkgloadbasetype)
649  res => obj
650  end select
651  end if
652  end function dynamicpkgs_get
653 
654  !> @brief read and prepare model dynamic packages
655  !!
656  !<
657  subroutine dynamicpkgs_rp(this)
659  class(modeldynamicpkgstype), intent(inout) :: this
660  class(dynamicpkgloadbasetype), pointer :: dynamic_pkg
661  integer(I4B) :: n
662  call idm_log_period_header(this%modelname, this%iout)
663  do n = 1, this%pkglist%Count()
664  dynamic_pkg => this%get(n)
665  call dynamic_pkg%rp()
666  end do
667  call idm_log_period_close(this%iout)
668  end subroutine dynamicpkgs_rp
669 
670  !> @brief define model dynamic packages
671  !!
672  !<
673  subroutine dynamicpkgs_df(this)
674  class(modeldynamicpkgstype), intent(inout) :: this
675  class(dynamicpkgloadbasetype), pointer :: dynamic_pkg
676  integer(I4B) :: n
677  do n = 1, this%pkglist%Count()
678  dynamic_pkg => this%get(n)
679  call dynamic_pkg%df()
680  end do
681  end subroutine dynamicpkgs_df
682 
683  !> @brief advance model dynamic packages
684  !!
685  !<
686  subroutine dynamicpkgs_ad(this)
687  class(modeldynamicpkgstype), intent(inout) :: this
688  class(dynamicpkgloadbasetype), pointer :: dynamic_pkg
689  integer(I4B) :: n
690  do n = 1, this%pkglist%Count()
691  dynamic_pkg => this%get(n)
692  call dynamic_pkg%ad()
693  end do
694  end subroutine dynamicpkgs_ad
695 
696  !> @brief get size of model dynamic packages list
697  !!
698  !<
699  function dynamicpkgs_size(this) result(size)
700  class(modeldynamicpkgstype), intent(inout) :: this
701  integer(I4B) :: size
702  size = this%pkglist%Count()
703  end function dynamicpkgs_size
704 
705  !> @brief destroy model dynamic packages object
706  !!
707  !<
708  subroutine dynamicpkgs_destroy(this)
709  class(modeldynamicpkgstype), intent(inout) :: this
710  class(dynamicpkgloadbasetype), pointer :: dynamic_pkg
711  integer(I4B) :: n
712  ! destroy dynamic loaders
713  do n = 1, this%pkglist%Count()
714  dynamic_pkg => this%get(n)
715  call dynamic_pkg%destroy()
716  deallocate (dynamic_pkg)
717  nullify (dynamic_pkg)
718  end do
719  call this%pkglist%Clear()
720  end subroutine dynamicpkgs_destroy
721 
722  !> @brief add model dynamic packages object to list
723  !!
724  !<
725  subroutine adddynamicmodeltolist(list, model_dynamic)
726  type(listtype), intent(inout) :: list !< package list
727  class(modeldynamicpkgstype), pointer, intent(inout) :: model_dynamic
728  class(*), pointer :: obj
729  obj => model_dynamic
730  call list%Add(obj)
731  end subroutine adddynamicmodeltolist
732 
733  !> @brief get model dynamic packages object from list
734  !!
735  !<
736  function getdynamicmodelfromlist(list, idx) result(res)
737  type(listtype), intent(inout) :: list !< spd list
738  integer(I4B), intent(in) :: idx !< package number
739  class(modeldynamicpkgstype), pointer :: res
740  class(*), pointer :: obj
741  ! initialize res
742  nullify (res)
743  ! get the object from the list
744  obj => list%GetItem(idx)
745  if (associated(obj)) then
746  select type (obj)
747  class is (modeldynamicpkgstype)
748  res => obj
749  end select
750  end if
751  end function getdynamicmodelfromlist
752 
753 end module inputloadtypemodule
subroutine init()
Definition: GridSorting.f90:25
load interfaces for source static and dynamic types
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 lencomponentname
maximum length of a component name
Definition: Constants.f90:18
integer(i4b), parameter lenmodelname
maximum length of the model name
Definition: Constants.f90:22
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
Definition: Constants.f90:39
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:27
logical function, public idm_integrated(component, subcomponent)
logical function, public idm_multi_package(component, subcomponent)
character(len=16) function, dimension(:), pointer, public idm_subpackages(component, subcomponent)
This module contains the Input Data Model Logger Module.
Definition: IdmLogger.f90:7
subroutine, public idm_log_period_header(component, iout)
@ brief log a dynamic header message
Definition: IdmLogger.f90:67
subroutine, public idm_log_period_close(iout)
@ brief log the period closing message
Definition: IdmLogger.f90:79
Input definition module.
This module contains the InputLoadTypeModule.
subroutine dynamic_ad(this)
dynamic package loader advance
subroutine static_init(this, mf6_input, component_name, component_input_name, input_name)
initialize static package loader
subroutine subpkg_destroy(this)
destroy a SubPackageListType object
subroutine dynamicpkgs_init(this, modeltype, modelname, modelfname, nc_fname, ncid, iout)
model dynamic packages init
class(modeldynamicpkgstype) function, pointer, public getdynamicmodelfromlist(list, idx)
get model dynamic packages object from list
subroutine create_subpkg_list(this)
create the subpackage list
integer(i4b) function dynamicpkgs_size(this)
get size of model dynamic packages list
subroutine dynamic_init(this, mf6_input, component_name, component_input_name, input_name, iperblock, iout)
initialize dynamic package loader
subroutine subpkg_add(this, pkgtype, component_type, subcomponent_type, filename)
append one subpackage file instance to the list
type(listtype), public model_inputs
subroutine, public adddynamicmodeltolist(list, model_dynamic)
add model dynamic packages object to list
subroutine dynamicpkgs_add(this, dynamic_pkg)
add package to model dynamic packages list
subroutine dynamicpkgs_rp(this)
read and prepare model dynamic packages
subroutine subpkg_create(this, component_type, component_name)
initialize a SubPackageListType object
subroutine static_destroy(this)
subroutine deduplicate_pkgtypes(pkgtypes, subptypes, nsubptypes)
Deduplicate pkgtypes into unique entries with counts (run-length encoding).
subroutine dynamicpkgs_destroy(this)
destroy model dynamic packages object
character(len=lenvarname) function build_subpkg_prefix(component_type, component_name, parent_sctype, parent_scname, modelfname)
Build the subpackage name prefix for the given parent package.
class(dynamicpkgloadbasetype) function, pointer dynamicpkgs_get(this, idx)
retrieve package from model dynamic packages list
subroutine dynamicpkgs_ad(this)
advance model dynamic packages
subroutine subpkg_names(this, parent_sctype, parent_scname, parent_mempath, modelfname)
Assign subpackage names and mempaths for IDM-integrated subpackages.
subroutine dynamic_destroy(this)
dynamic package loader destroy
subroutine dynamic_df(this)
dynamic package loader define
subroutine dynamicpkgs_df(this)
define model dynamic packages
This module defines variable data types.
Definition: kind.f90:8
This module contains the LoadContextModule.
Definition: LoadContext.f90:10
logical(lgp) function, public is_keystring_period(mf6_input)
Return .true. if mf6_input's PERIOD block uses keystring dispatch.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorystore_remove(component, subcomponent, context)
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains the ModelPackageInputModule.
logical(lgp) function, public multi_package_type(mtype_component, ptype_component, pkgtype)
Is the package multi-instance.
This module contains the ModflowInputModule.
Definition: ModflowInput.f90:9
This module contains the NCFileVarsModule.
Definition: NCFileVars.f90:7
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
character(len=linelength) idm_context
This module contains the SourceCommonModule.
Definition: SourceCommon.f90:7
character(len=lenpackagename) function, public idm_pkg_instance_name(pkg_type, inst)
default name for a multi-package instance
logical(lgp) function, public idm_utl_type(component, subcomponent)
is utility type
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
Input parameter definition. Describes an input parameter.
Base abstract type for dynamic input loader.
type for storing a dynamic package load list
Base abstract type for static input loader.
type representing package subpackage list
A generic heterogeneous doubly-linked list.
Definition: List.f90:14
derived type for storing input definition for a file
Type describing input variables for a package in NetCDF file.
Definition: NCFileVars.f90:22