MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
inputloadtypemodule Module Reference

This module contains the InputLoadTypeModule. More...

Data Types

type  subpackagelisttype
 type representing package subpackage list More...
 
type  staticpkgloadtype
 Static loader type. More...
 
type  staticpkgloadbasetype
 Base abstract type for static input loader. More...
 
type  dynamicpkgloadtype
 Dynamic loader type. More...
 
type  dynamicpkgloadbasetype
 Base abstract type for dynamic input loader. More...
 
interface  load_if
 load interfaces for source static and dynamic types More...
 
interface  period_load_if
 
type  modeldynamicpkgstype
 type for storing a dynamic package load list More...
 

Functions/Subroutines

subroutine subpkg_create (this, mempath, component_name)
 create a new package type More...
 
subroutine subpkg_add (this, pkgtype, component_type, subcomponent_type, tagname, filename)
 create a new package type More...
 
subroutine subpkg_destroy (this)
 create a new package type More...
 
subroutine static_init (this, mf6_input, component_name, component_input_name, input_name)
 initialize static package loader More...
 
subroutine create_subpkg_list (this)
 create the subpackage list More...
 
subroutine static_destroy (this)
 
subroutine dynamic_init (this, mf6_input, component_name, component_input_name, input_name, iperblock, iout)
 initialize dynamic package loader More...
 
subroutine dynamic_df (this)
 dynamic package loader define More...
 
subroutine dynamic_ad (this)
 dynamic package loader advance More...
 
subroutine dynamic_destroy (this)
 dynamic package loader destroy More...
 
subroutine dynamicpkgs_init (this, modeltype, modelname, modelfname, nc_fname, ncid, iout)
 model dynamic packages init More...
 
subroutine dynamicpkgs_add (this, dynamic_pkg)
 add package to model dynamic packages list More...
 
class(dynamicpkgloadbasetype) function, pointer dynamicpkgs_get (this, idx)
 retrieve package from model dynamic packages list More...
 
subroutine dynamicpkgs_rp (this)
 read and prepare model dynamic packages More...
 
subroutine dynamicpkgs_df (this)
 define model dynamic packages More...
 
subroutine dynamicpkgs_ad (this)
 advance model dynamic packages More...
 
integer(i4b) function dynamicpkgs_size (this)
 get size of model dynamic packages list More...
 
subroutine dynamicpkgs_destroy (this)
 destroy model dynamic packages object More...
 
subroutine, public adddynamicmodeltolist (list, model_dynamic)
 add model dynamic packages object to list More...
 
class(modeldynamicpkgstype) function, pointer, public getdynamicmodelfromlist (list, idx)
 get model dynamic packages object from list More...
 

Variables

type(listtype), public model_dynamic_pkgs
 

Detailed Description

This module defines types that support generic IDM static and dynamic input loading.

Function/Subroutine Documentation

◆ adddynamicmodeltolist()

subroutine, public inputloadtypemodule::adddynamicmodeltolist ( type(listtype), intent(inout)  list,
class(modeldynamicpkgstype), intent(inout), pointer  model_dynamic 
)
Parameters
[in,out]listpackage list

Definition at line 591 of file InputLoadType.f90.

592  ! -- dummy variables
593  type(ListType), intent(inout) :: list !< package list
594  class(ModelDynamicPkgsType), pointer, intent(inout) :: model_dynamic
595  ! -- local variables
596  class(*), pointer :: obj
597  !
598  obj => model_dynamic
599  call list%Add(obj)
Here is the caller graph for this function:

◆ create_subpkg_list()

subroutine inputloadtypemodule::create_subpkg_list ( class(staticpkgloadtype), intent(inout)  this)
private

Definition at line 286 of file InputLoadType.f90.

290  class(StaticPkgLoadType), intent(inout) :: this
291  character(len=16), dimension(:), pointer :: subpkgs
292  character(len=LINELENGTH) :: tag, fname, pkgtype
293  character(len=LENFTYPE) :: c_type, sc_type
294  character(len=16) :: subpkg
295  integer(I4B) :: idx, n
296  !
297  ! -- set pointer to package (idm integrated) subpackage list
298  subpkgs => idm_subpackages(this%mf6_input%component_type, &
299  this%mf6_input%subcomponent_type)
300  !
301  ! -- check if tag matches subpackage
302  do n = 1, size(subpkgs)
303  subpkg = subpkgs(n)
304  idx = index(subpkg, '-')
305  ! -- split sp string into component/subcomponent
306  if (idx > 0) then
307  ! -- split string in component/subcomponent types
308  c_type = subpkg(1:idx - 1)
309  sc_type = subpkg(idx + 1:len_trim(subpkg))
310  !
311  if (idm_integrated(c_type, sc_type)) then
312  !
313  ! -- set pkgtype and input filename tag
314  pkgtype = trim(sc_type)//'6'
315  tag = trim(pkgtype)//'_FILENAME'
316  !
317  ! -- support single instance of each subpackage
318  if (idm_multi_package(c_type, sc_type)) then
319  errmsg = 'Multi-instance subpackages not supported. Remove dfn &
320  &subpackage tagline for package "'//trim(subpkg)//'".'
321  call store_error(errmsg)
322  call store_error_filename(this%input_name)
323  else
324  if (filein_fname(fname, tag, this%mf6_input%mempath, &
325  this%input_name)) then
326  call this%subpkg_list%add(pkgtype, c_type, sc_type, &
327  trim(tag), trim(fname))
328  end if
329  end if
330  else
331  errmsg = 'Identified subpackage is not IDM integrated. Remove dfn &
332  &subpackage tagline for package "'//trim(subpkg)//'".'
333  call store_error(errmsg)
334  call store_error_filename(this%input_name)
335  end if
336  end if
337  end do
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 SourceCommonModule.
Definition: SourceCommon.f90:7
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
Here is the call graph for this function:

◆ dynamic_ad()

subroutine inputloadtypemodule::dynamic_ad ( class(dynamicpkgloadtype), intent(inout)  this)
private

Definition at line 411 of file InputLoadType.f90.

412  class(DynamicPkgLoadType), intent(inout) :: this
413  !
414  ! override in derived type
415  !
416  return

◆ dynamic_destroy()

subroutine inputloadtypemodule::dynamic_destroy ( class(dynamicpkgloadtype), intent(inout)  this)
private

Definition at line 422 of file InputLoadType.f90.

426  class(DynamicPkgLoadType), intent(inout) :: this
427  !
428  ! -- clean up netcdf variables structure
429  if (associated(this%nc_vars)) then
430  call this%nc_vars%destroy()
431  deallocate (this%nc_vars)
432  nullify (this%nc_vars)
433  end if
434  !
435  ! -- deallocate package static and dynamic input context
436  call memorystore_remove(this%mf6_input%component_name, &
437  this%mf6_input%subcomponent_name, &
438  idm_context)
439  !
440  return
subroutine, public memorystore_remove(component, subcomponent, context)
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=linelength) idm_context
Here is the call graph for this function:

◆ dynamic_df()

subroutine inputloadtypemodule::dynamic_df ( class(dynamicpkgloadtype), intent(inout)  this)

Definition at line 400 of file InputLoadType.f90.

401  class(DynamicPkgLoadType), intent(inout) :: this
402  !
403  ! override in derived type
404  !
405  return

◆ dynamic_init()

subroutine inputloadtypemodule::dynamic_init ( class(dynamicpkgloadtype), intent(inout)  this,
type(modflowinputtype), intent(in)  mf6_input,
character(len=*), intent(in)  component_name,
character(len=*), intent(in)  component_input_name,
character(len=*), intent(in)  input_name,
integer(i4b), intent(in)  iperblock,
integer(i4b), intent(in)  iout 
)
private

Any managed memory pointed to from model/package context must be allocated when dynamic loader is initialized.

Definition at line 360 of file InputLoadType.f90.

362  use simvariablesmodule, only: errmsg
364  ! -- dummy
365  class(DynamicPkgLoadType), intent(inout) :: this
366  type(ModflowInputType), intent(in) :: mf6_input
367  character(len=*), intent(in) :: component_name
368  character(len=*), intent(in) :: component_input_name
369  character(len=*), intent(in) :: input_name
370  integer(I4B), intent(in) :: iperblock
371  integer(I4B), intent(in) :: iout
372  type(InputParamDefinitionType), pointer :: idt
373  !
374  this%mf6_input = mf6_input
375  this%component_name = component_name
376  this%component_input_name = component_input_name
377  this%input_name = input_name
378  this%iperblock = iperblock
379  this%nparam = 0
380  this%iout = iout
381  nullify (idt)
382  !
383  ! -- throw error and exit if not found
384  if (this%iperblock == 0) then
385  write (errmsg, '(a,a)') &
386  'Programming error. (IDM) PERIOD block not found in '&
387  &'dynamic package input block dfns: ', &
388  trim(mf6_input%subcomponent_name)
389  call store_error(errmsg)
390  call store_error_filename(this%input_name)
391  end if
392  !
393  ! -- set readasarrays
394  this%readasarrays = (.not. mf6_input%block_dfns(iperblock)%aggregate)
This module contains the InputDefinitionModule.
character(len=maxcharlen) errmsg
error message string
Here is the call graph for this function:

◆ dynamicpkgs_ad()

subroutine inputloadtypemodule::dynamicpkgs_ad ( class(modeldynamicpkgstype), intent(inout)  this)
private

Definition at line 542 of file InputLoadType.f90.

543  class(ModelDynamicPkgsType), intent(inout) :: this
544  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
545  integer(I4B) :: n
546  !
547  do n = 1, this%pkglist%Count()
548  dynamic_pkg => this%get(n)
549  call dynamic_pkg%ad()
550  end do
551  !
552  return

◆ dynamicpkgs_add()

subroutine inputloadtypemodule::dynamicpkgs_add ( class(modeldynamicpkgstype), intent(inout)  this,
class(dynamicpkgloadbasetype), intent(inout), pointer  dynamic_pkg 
)
private

Definition at line 469 of file InputLoadType.f90.

470  class(ModelDynamicPkgsType), intent(inout) :: this
471  class(DynamicPkgLoadBaseType), pointer, intent(inout) :: dynamic_pkg
472  class(*), pointer :: obj
473  !
474  obj => dynamic_pkg
475  call this%pkglist%add(obj)
476  !
477  return

◆ dynamicpkgs_destroy()

subroutine inputloadtypemodule::dynamicpkgs_destroy ( class(modeldynamicpkgstype), intent(inout)  this)
private

Definition at line 570 of file InputLoadType.f90.

571  class(ModelDynamicPkgsType), intent(inout) :: this
572  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
573  integer(I4B) :: n
574  !
575  ! -- destroy dynamic loaders
576  do n = 1, this%pkglist%Count()
577  dynamic_pkg => this%get(n)
578  call dynamic_pkg%destroy()
579  deallocate (dynamic_pkg)
580  nullify (dynamic_pkg)
581  end do
582  !
583  call this%pkglist%Clear()
584  !
585  return

◆ dynamicpkgs_df()

subroutine inputloadtypemodule::dynamicpkgs_df ( class(modeldynamicpkgstype), intent(inout)  this)

Definition at line 526 of file InputLoadType.f90.

527  class(ModelDynamicPkgsType), intent(inout) :: this
528  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
529  integer(I4B) :: n
530  !
531  do n = 1, this%pkglist%Count()
532  dynamic_pkg => this%get(n)
533  call dynamic_pkg%df()
534  end do
535  !
536  return

◆ dynamicpkgs_get()

class(dynamicpkgloadbasetype) function, pointer inputloadtypemodule::dynamicpkgs_get ( class(modeldynamicpkgstype), intent(inout)  this,
integer(i4b), intent(in)  idx 
)
private

Definition at line 483 of file InputLoadType.f90.

484  class(ModelDynamicPkgsType), intent(inout) :: this
485  integer(I4B), intent(in) :: idx
486  class(DynamicPkgLoadBaseType), pointer :: res
487  class(*), pointer :: obj
488  !
489  nullify (res)
490  obj => this%pkglist%GetItem(idx)
491  !
492  if (associated(obj)) then
493  select type (obj)
494  class is (dynamicpkgloadbasetype)
495  res => obj
496  end select
497  end if
498  !
499  return

◆ dynamicpkgs_init()

subroutine inputloadtypemodule::dynamicpkgs_init ( class(modeldynamicpkgstype), intent(inout)  this,
character(len=*), intent(in)  modeltype,
character(len=*), intent(in)  modelname,
character(len=*), intent(in)  modelfname,
character(len=*), intent(in)  nc_fname,
integer(i4b), intent(in)  ncid,
integer(i4b), intent(in)  iout 
)

Definition at line 446 of file InputLoadType.f90.

448  class(ModelDynamicPkgsType), intent(inout) :: this
449  character(len=*), intent(in) :: modeltype
450  character(len=*), intent(in) :: modelname
451  character(len=*), intent(in) :: modelfname
452  character(len=*), intent(in) :: nc_fname
453  integer(I4B), intent(in) :: ncid
454  integer(I4B), intent(in) :: iout
455  !
456  this%modeltype = modeltype
457  this%modelname = modelname
458  this%modelfname = modelfname
459  this%nc_fname = nc_fname
460  this%ncid = ncid
461  this%iout = iout
462  !
463  return

◆ dynamicpkgs_rp()

subroutine inputloadtypemodule::dynamicpkgs_rp ( class(modeldynamicpkgstype), intent(inout)  this)
private

Definition at line 505 of file InputLoadType.f90.

507  class(ModelDynamicPkgsType), intent(inout) :: this
508  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
509  integer(I4B) :: n
510  !
511  call idm_log_period_header(this%modelname, this%iout)
512  !
513  do n = 1, this%pkglist%Count()
514  dynamic_pkg => this%get(n)
515  call dynamic_pkg%rp()
516  end do
517  !
518  call idm_log_period_close(this%iout)
519  !
520  return
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:69
subroutine, public idm_log_period_close(iout)
@ brief log the period closing message
Definition: IdmLogger.f90:82
Here is the call graph for this function:

◆ dynamicpkgs_size()

integer(i4b) function inputloadtypemodule::dynamicpkgs_size ( class(modeldynamicpkgstype), intent(inout)  this)
private

Definition at line 558 of file InputLoadType.f90.

559  class(ModelDynamicPkgsType), intent(inout) :: this
560  integer(I4B) :: size
561  !
562  size = this%pkglist%Count()
563  !
564  return

◆ getdynamicmodelfromlist()

class(modeldynamicpkgstype) function, pointer, public inputloadtypemodule::getdynamicmodelfromlist ( type(listtype), intent(inout)  list,
integer(i4b), intent(in)  idx 
)
Parameters
[in,out]listspd list
[in]idxpackage number

Definition at line 605 of file InputLoadType.f90.

606  ! -- dummy variables
607  type(ListType), intent(inout) :: list !< spd list
608  integer(I4B), intent(in) :: idx !< package number
609  class(ModelDynamicPkgsType), pointer :: res
610  ! -- local variables
611  class(*), pointer :: obj
612  !
613  ! -- initialize res
614  nullify (res)
615  !
616  ! -- get the object from the list
617  obj => list%GetItem(idx)
618  if (associated(obj)) then
619  select type (obj)
620  class is (modeldynamicpkgstype)
621  res => obj
622  end select
623  end if
Here is the caller graph for this function:

◆ static_destroy()

subroutine inputloadtypemodule::static_destroy ( class(staticpkgloadtype), intent(inout)  this)

Definition at line 340 of file InputLoadType.f90.

341  class(StaticPkgLoadType), intent(inout) :: this
342  !
343  call this%subpkg_list%destroy()
344  !
345  if (associated(this%nc_vars)) then
346  call this%nc_vars%destroy()
347  deallocate (this%nc_vars)
348  nullify (this%nc_vars)
349  end if
350  !
351  return

◆ static_init()

subroutine inputloadtypemodule::static_init ( class(staticpkgloadtype), intent(inout)  this,
type(modflowinputtype), intent(in)  mf6_input,
character(len=*), intent(in)  component_name,
character(len=*), intent(in)  component_input_name,
character(len=*), intent(in)  input_name 
)
private

Definition at line 252 of file InputLoadType.f90.

254  class(StaticPkgLoadType), intent(inout) :: this
255  type(ModflowInputType), intent(in) :: mf6_input
256  character(len=*), intent(in) :: component_name
257  character(len=*), intent(in) :: component_input_name
258  character(len=*), intent(in) :: input_name
259  integer(I4B) :: iblock
260  !
261  this%mf6_input = mf6_input
262  this%component_name = component_name
263  this%component_input_name = component_input_name
264  this%input_name = input_name
265  this%iperblock = 0
266  !
267  ! -- create subpackage list
268  call this%subpkg_list%create(this%mf6_input%mempath, &
269  this%mf6_input%component_name)
270  !
271  ! -- identify period block definition
272  do iblock = 1, size(mf6_input%block_dfns)
273  !
274  if (mf6_input%block_dfns(iblock)%blockname == 'PERIOD') then
275  this%iperblock = iblock
276  exit
277  end if
278  end do
279  !
280  return

◆ subpkg_add()

subroutine inputloadtypemodule::subpkg_add ( class(subpackagelisttype this,
character(len=*), intent(in)  pkgtype,
character(len=*), intent(in)  component_type,
character(len=*), intent(in)  subcomponent_type,
character(len=*), intent(in)  tagname,
character(len=*), intent(in)  filename 
)
private

Definition at line 174 of file InputLoadType.f90.

176  ! -- modules
181  ! -- dummy
182  class(SubPackageListType) :: this
183  character(len=*), intent(in) :: pkgtype
184  character(len=*), intent(in) :: component_type
185  character(len=*), intent(in) :: subcomponent_type
186  character(len=*), intent(in) :: tagname
187  character(len=*), intent(in) :: filename
188  ! -- local
189  character(len=LENVARNAME) :: mempath_tag
190  character(len=LENMEMPATH), pointer :: subpkg_mempath
191  character(len=LINELENGTH), pointer :: input_fname
192  integer(I4B) :: idx, trimlen
193  !
194  ! -- reallocate
195  call expandarray(this%pkgtypes)
196  call expandarray(this%component_types)
197  call expandarray(this%subcomponent_types)
198  call expandarray(this%filenames)
199  !
200  ! -- add new package instance
201  this%pnum = this%pnum + 1
202  this%pkgtypes(this%pnum) = pkgtype
203  this%component_types(this%pnum) = component_type
204  this%subcomponent_types(this%pnum) = subcomponent_type
205  this%filenames(this%pnum) = filename
206  !
207  ! -- initialize mempath tag
208  mempath_tag = tagname
209  trimlen = len_trim(tagname)
210  idx = 0
211  !
212  ! -- create mempath tagname
213  idx = index(tagname, '_')
214  if (idx > 0) then
215  if (tagname(idx + 1:trimlen) == 'FILENAME') then
216  write (mempath_tag, '(a)') tagname(1:idx)//'MEMPATH'
217  end if
218  end if
219  !
220  ! -- allocate mempath variable for subpackage
221  call mem_allocate(subpkg_mempath, lenmempath, mempath_tag, &
222  this%mempath)
223  !
224  ! -- create and set the mempath
225  subpkg_mempath = &
226  create_mem_path(this%component_name, &
227  subcomponent_type, idm_context)
228  !
229  ! -- allocate and initialize filename for subpackage
230  call mem_allocate(input_fname, linelength, 'INPUT_FNAME', subpkg_mempath)
231  input_fname = filename
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
Here is the call graph for this function:

◆ subpkg_create()

subroutine inputloadtypemodule::subpkg_create ( class(subpackagelisttype this,
character(len=*), intent(in)  mempath,
character(len=*), intent(in)  component_name 
)
private

Definition at line 152 of file InputLoadType.f90.

153  ! -- modules
154  ! -- dummy
155  class(SubPackageListType) :: this
156  character(len=*), intent(in) :: mempath
157  character(len=*), intent(in) :: component_name
158  ! -- local
159  !
160  ! -- initialize
161  this%pnum = 0
162  this%mempath = mempath
163  this%component_name = component_name
164  !
165  ! -- allocate arrays
166  allocate (this%pkgtypes(0))
167  allocate (this%component_types(0))
168  allocate (this%subcomponent_types(0))
169  allocate (this%filenames(0))

◆ subpkg_destroy()

subroutine inputloadtypemodule::subpkg_destroy ( class(subpackagelisttype this)

Definition at line 236 of file InputLoadType.f90.

237  ! -- modules
238  ! -- dummy
239  class(SubPackageListType) :: this
240  ! -- local
241  !
242  ! -- allocate arrays
243  deallocate (this%pkgtypes)
244  deallocate (this%component_types)
245  deallocate (this%subcomponent_types)
246  deallocate (this%filenames)

Variable Documentation

◆ model_dynamic_pkgs

type(listtype), public inputloadtypemodule::model_dynamic_pkgs

Definition at line 146 of file InputLoadType.f90.

146  type(ListType) :: model_dynamic_pkgs