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
56 character(len=LENCOMPONENTNAME) :: component_name
57 character(len=LINELENGTH) :: component_input_name
58 character(len=LINELENGTH) :: input_name
59 integer(I4B) :: iperblock
85 character(len=LENCOMPONENTNAME) :: component_name
86 character(len=LINELENGTH) :: component_input_name
87 character(len=LINELENGTH) :: input_name
88 character(len=LINELENGTH),
dimension(:),
allocatable :: param_names
89 logical(LGP) :: readasarrays
90 logical(LGP) :: readarraygrid
91 logical(LGP) :: has_keystring
92 integer(I4B) :: iperblock
94 integer(I4B) :: nparam
115 function load_if(this, iout)
result(dynamic_loader)
118 integer(I4B),
intent(in) ::
iout
134 character(len=LENCOMPONENTNAME) :: modeltype
135 character(len=LENMODELNAME) :: modelname
136 character(len=LINELENGTH) :: modelfname
138 character(len=LINELENGTH) :: nc_fname
160 character(len=*),
intent(in) :: component_type
161 character(len=*),
intent(in) :: component_name
165 this%component_type = component_type
166 this%component_name = component_name
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))
178 subroutine subpkg_add(this, pkgtype, component_type, subcomponent_type, &
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
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
206 parent_mempath, modelfname)
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
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
227 if (
size(this%pkgtypes) == 0)
return
230 if (
idm_utl_type(this%component_type, parent_sctype))
return
234 this%component_name, parent_sctype, &
235 parent_scname, modelfname)
242 do n = 1,
size(subptypes)
244 mempath_key = trim(subptypes(n))//
'_MEMPATH'
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
251 write (this%subcomponent_names(m),
'(a,i0)') &
252 trim(subpkg_prefix)//trim(this%subcomponent_types(m)), subpkg_inst
255 this%subcomponent_names(m), &
257 mempaths(subpkg_inst) = mempath
260 input_fname = trim(this%filenames(m))
265 deallocate (subptypes)
266 deallocate (nsubptypes)
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
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
300 if (component_type ==
'EXG')
return
303 select case (parent_sctype)
304 case (
'EVTA',
'RCHA',
'SPCA',
'RIVG',
'CHDG',
'WELG',
'DRNG',
'GHBG')
305 parent_type = parent_sctype(1:3)
307 parent_type = parent_sctype
311 parent_ftype = trim(parent_type)//
'6'
324 call mem_setptr(pnames,
'PNAME', model_mempath)
325 call mem_setptr(ftypes,
'FTYPE', model_mempath)
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 ==
'') &
334 if (parent_name == parent_scname)
then
335 write (subpkg_prefix,
'(a,i0,a)') trim(parent_type), parent_inst,
'-'
341 if (subpkg_prefix ==
'')
then
343 'Internal IDM error: subpackage load cannot identify &
344 &package "'//trim(parent_scname)//
'" in model name file &
351 write (subpkg_prefix,
'(2a)') trim(parent_type),
'-'
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
367 allocate (subptypes(0))
368 allocate (nsubptypes(0))
371 do n = 1,
size(pkgtypes)
372 if (pkgtypes(n) /= prev)
then
377 subptypes(ntype) = prev
378 nsubptypes(ntype) = 1
380 nsubptypes(ntype) = nsubptypes(ntype) + 1
390 deallocate (this%pkgtypes)
391 deallocate (this%component_types)
392 deallocate (this%subcomponent_types)
393 deallocate (this%subcomponent_names)
394 deallocate (this%filenames)
400 subroutine static_init(this, mf6_input, component_name, component_input_name, &
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
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
416 call this%subpkg_list%create(this%mf6_input%component_type, &
417 this%mf6_input%component_name)
420 do iblock = 1,
size(mf6_input%block_dfns)
421 if (mf6_input%block_dfns(iblock)%blockname ==
'PERIOD')
then
422 this%iperblock = iblock
437 character(len=16),
dimension(:),
pointer :: subpkgs
440 character(len=LINELENGTH) :: tag, fname, pkgtype
441 character(len=6) :: c_type, sc_type
442 character(len=16) :: subpkg
443 integer(I4B) :: idx, n, m, isize
447 this%mf6_input%subcomponent_type)
450 do n = 1,
size(subpkgs)
453 idx = index(subpkg,
'-')
457 c_type = subpkg(1:idx - 1)
458 sc_type = subpkg(idx + 1:len_trim(subpkg))
462 pkgtype = trim(sc_type)//
'6'
463 tag = trim(pkgtype)//
'_FILENAME'
464 call get_isize(tag, this%mf6_input%mempath, isize)
467 call mem_setptr(fnames, tag, this%mf6_input%mempath)
468 do m = 1,
size(fnames)
470 call this%subpkg_list%add(pkgtype, c_type, sc_type, fname)
474 errmsg =
'Identified subpackage is not IDM integrated. Remove dfn &
475 &subpackage tagline for package "'//trim(subpkg)//
'".'
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)
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)
505 subroutine dynamic_init(this, mf6_input, component_name, component_input_name, &
506 input_name, iperblock, iout)
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
518 integer(I4B) :: iparam
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
533 if (this%iperblock == 0)
then
535 'Programming error. (IDM) PERIOD block not found in '&
536 &
'dynamic package input block dfns: ', &
537 trim(mf6_input%subcomponent_name)
543 if (mf6_input%block_dfns(iperblock)%aggregate)
then
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.
562 if (mf6_input%block_dfns(iperblock)%aggregate)
then
593 if (
associated(this%nc_vars))
then
594 call this%nc_vars%destroy()
595 deallocate (this%nc_vars)
596 nullify (this%nc_vars)
601 this%mf6_input%subcomponent_name, &
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
631 class(*),
pointer :: obj
633 call this%pkglist%add(obj)
641 integer(I4B),
intent(in) :: idx
643 class(*),
pointer :: obj
645 obj => this%pkglist%GetItem(idx)
646 if (
associated(obj))
then
663 do n = 1, this%pkglist%Count()
664 dynamic_pkg => this%get(n)
665 call dynamic_pkg%rp()
677 do n = 1, this%pkglist%Count()
678 dynamic_pkg => this%get(n)
679 call dynamic_pkg%df()
690 do n = 1, this%pkglist%Count()
691 dynamic_pkg => this%get(n)
692 call dynamic_pkg%ts_advance()
702 size = this%pkglist%Count()
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)
719 call this%pkglist%Clear()
726 type(
listtype),
intent(inout) :: list
728 class(*),
pointer :: obj
737 type(
listtype),
intent(inout) :: list
738 integer(I4B),
intent(in) :: idx
740 class(*),
pointer :: obj
744 obj => list%GetItem(idx)
745 if (
associated(obj))
then
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lencomponentname
maximum length of a component name
integer(i4b), parameter lenmodelname
maximum length of the model name
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenmempath
maximum length of the memory path
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.
subroutine, public idm_log_period_header(component, iout)
log a dynamic header message
subroutine, public idm_log_period_close(iout)
log the period closing message
This module defines variable data types.
subroutine add(this, objptr)
Append the given item to the list.
Load context for IDM generic dynamic loaders.
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)
Get the number of elements for this variable.
This module contains the NCFileVarsModule.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
integer(i4b) iout
file unit number for simulation output
This module contains the SourceCommonModule.
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 ...
A generic heterogeneous doubly-linked list.
Type describing input variables for a package in NetCDF file.