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 534 of file InputLoadType.f90.

535  type(ListType), intent(inout) :: list !< package list
536  class(ModelDynamicPkgsType), pointer, intent(inout) :: model_dynamic
537  class(*), pointer :: obj
538  obj => model_dynamic
539  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 273 of file InputLoadType.f90.

277  class(StaticPkgLoadType), intent(inout) :: this
278  character(len=16), dimension(:), pointer :: subpkgs
279  character(len=LINELENGTH) :: tag, fname, pkgtype
280  character(len=LENFTYPE) :: c_type, sc_type
281  character(len=16) :: subpkg
282  integer(I4B) :: idx, n
283 
284  ! set pointer to package (idm integrated) subpackage list
285  subpkgs => idm_subpackages(this%mf6_input%component_type, &
286  this%mf6_input%subcomponent_type)
287 
288  ! check if tag matches subpackage
289  do n = 1, size(subpkgs)
290  subpkg = subpkgs(n)
291  idx = index(subpkg, '-')
292  ! split sp string into component/subcomponent
293  if (idx > 0) then
294  ! split string in component/subcomponent types
295  c_type = subpkg(1:idx - 1)
296  sc_type = subpkg(idx + 1:len_trim(subpkg))
297  if (idm_integrated(c_type, sc_type)) then
298  ! set pkgtype and input filename tag
299  pkgtype = trim(sc_type)//'6'
300  tag = trim(pkgtype)//'_FILENAME'
301  ! support single instance of each subpackage
302  if (idm_multi_package(c_type, sc_type)) then
303  errmsg = 'Multi-instance subpackages not supported. Remove dfn &
304  &subpackage tagline for package "'//trim(subpkg)//'".'
305  call store_error(errmsg)
306  call store_error_filename(this%input_name)
307  else
308  if (filein_fname(fname, tag, this%mf6_input%mempath, &
309  this%input_name)) then
310  call this%subpkg_list%add(pkgtype, c_type, sc_type, &
311  trim(tag), trim(fname))
312  end if
313  end if
314  else
315  errmsg = 'Identified subpackage is not IDM integrated. Remove dfn &
316  &subpackage tagline for package "'//trim(subpkg)//'".'
317  call store_error(errmsg)
318  call store_error_filename(this%input_name)
319  end if
320  end if
321  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 387 of file InputLoadType.f90.

388  class(DynamicPkgLoadType), intent(inout) :: this
389  ! override in derived type

◆ dynamic_destroy()

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

Definition at line 395 of file InputLoadType.f90.

399  class(DynamicPkgLoadType), intent(inout) :: this
400 
401  ! clean up netcdf variables structure
402  if (associated(this%nc_vars)) then
403  call this%nc_vars%destroy()
404  deallocate (this%nc_vars)
405  nullify (this%nc_vars)
406  end if
407 
408  ! deallocate package static and dynamic input context
409  call memorystore_remove(this%mf6_input%component_name, &
410  this%mf6_input%subcomponent_name, &
411  idm_context)
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 379 of file InputLoadType.f90.

380  class(DynamicPkgLoadType), intent(inout) :: this
381  ! override in derived type

◆ 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 340 of file InputLoadType.f90.

342  use simvariablesmodule, only: errmsg
344  class(DynamicPkgLoadType), intent(inout) :: this
345  type(ModflowInputType), intent(in) :: mf6_input
346  character(len=*), intent(in) :: component_name
347  character(len=*), intent(in) :: component_input_name
348  character(len=*), intent(in) :: input_name
349  integer(I4B), intent(in) :: iperblock
350  integer(I4B), intent(in) :: iout
351  type(InputParamDefinitionType), pointer :: idt
352 
353  this%mf6_input = mf6_input
354  this%component_name = component_name
355  this%component_input_name = component_input_name
356  this%input_name = input_name
357  this%iperblock = iperblock
358  this%nparam = 0
359  this%iout = iout
360  nullify (idt)
361 
362  ! throw error and exit if not found
363  if (this%iperblock == 0) then
364  write (errmsg, '(a,a)') &
365  'Programming error. (IDM) PERIOD block not found in '&
366  &'dynamic package input block dfns: ', &
367  trim(mf6_input%subcomponent_name)
368  call store_error(errmsg)
369  call store_error_filename(this%input_name)
370  end if
371 
372  ! set readasarrays
373  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 495 of file InputLoadType.f90.

496  class(ModelDynamicPkgsType), intent(inout) :: this
497  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
498  integer(I4B) :: n
499  do n = 1, this%pkglist%Count()
500  dynamic_pkg => this%get(n)
501  call dynamic_pkg%ad()
502  end do

◆ dynamicpkgs_add()

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

Definition at line 437 of file InputLoadType.f90.

438  class(ModelDynamicPkgsType), intent(inout) :: this
439  class(DynamicPkgLoadBaseType), pointer, intent(inout) :: dynamic_pkg
440  class(*), pointer :: obj
441  obj => dynamic_pkg
442  call this%pkglist%add(obj)

◆ dynamicpkgs_destroy()

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

Definition at line 517 of file InputLoadType.f90.

518  class(ModelDynamicPkgsType), intent(inout) :: this
519  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
520  integer(I4B) :: n
521  ! destroy dynamic loaders
522  do n = 1, this%pkglist%Count()
523  dynamic_pkg => this%get(n)
524  call dynamic_pkg%destroy()
525  deallocate (dynamic_pkg)
526  nullify (dynamic_pkg)
527  end do
528  call this%pkglist%Clear()

◆ dynamicpkgs_df()

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

Definition at line 482 of file InputLoadType.f90.

483  class(ModelDynamicPkgsType), intent(inout) :: this
484  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
485  integer(I4B) :: n
486  do n = 1, this%pkglist%Count()
487  dynamic_pkg => this%get(n)
488  call dynamic_pkg%df()
489  end do

◆ dynamicpkgs_get()

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

Definition at line 448 of file InputLoadType.f90.

449  class(ModelDynamicPkgsType), intent(inout) :: this
450  integer(I4B), intent(in) :: idx
451  class(DynamicPkgLoadBaseType), pointer :: res
452  class(*), pointer :: obj
453  nullify (res)
454  obj => this%pkglist%GetItem(idx)
455  if (associated(obj)) then
456  select type (obj)
457  class is (dynamicpkgloadbasetype)
458  res => obj
459  end select
460  end if

◆ 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 417 of file InputLoadType.f90.

419  class(ModelDynamicPkgsType), intent(inout) :: this
420  character(len=*), intent(in) :: modeltype
421  character(len=*), intent(in) :: modelname
422  character(len=*), intent(in) :: modelfname
423  character(len=*), intent(in) :: nc_fname
424  integer(I4B), intent(in) :: ncid
425  integer(I4B), intent(in) :: iout
426  this%modeltype = modeltype
427  this%modelname = modelname
428  this%modelfname = modelfname
429  this%nc_fname = nc_fname
430  this%ncid = ncid
431  this%iout = iout

◆ dynamicpkgs_rp()

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

Definition at line 466 of file InputLoadType.f90.

468  class(ModelDynamicPkgsType), intent(inout) :: this
469  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
470  integer(I4B) :: n
471  call idm_log_period_header(this%modelname, this%iout)
472  do n = 1, this%pkglist%Count()
473  dynamic_pkg => this%get(n)
474  call dynamic_pkg%rp()
475  end do
476  call idm_log_period_close(this%iout)
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
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 508 of file InputLoadType.f90.

509  class(ModelDynamicPkgsType), intent(inout) :: this
510  integer(I4B) :: size
511  size = this%pkglist%Count()

◆ 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 545 of file InputLoadType.f90.

546  type(ListType), intent(inout) :: list !< spd list
547  integer(I4B), intent(in) :: idx !< package number
548  class(ModelDynamicPkgsType), pointer :: res
549  class(*), pointer :: obj
550  ! initialize res
551  nullify (res)
552  ! get the object from the list
553  obj => list%GetItem(idx)
554  if (associated(obj)) then
555  select type (obj)
556  class is (modeldynamicpkgstype)
557  res => obj
558  end select
559  end if
Here is the caller graph for this function:

◆ static_destroy()

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

Definition at line 324 of file InputLoadType.f90.

325  class(StaticPkgLoadType), intent(inout) :: this
326  call this%subpkg_list%destroy()
327  if (associated(this%nc_vars)) then
328  call this%nc_vars%destroy()
329  deallocate (this%nc_vars)
330  nullify (this%nc_vars)
331  end if

◆ 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 242 of file InputLoadType.f90.

244  class(StaticPkgLoadType), intent(inout) :: this
245  type(ModflowInputType), intent(in) :: mf6_input
246  character(len=*), intent(in) :: component_name
247  character(len=*), intent(in) :: component_input_name
248  character(len=*), intent(in) :: input_name
249  integer(I4B) :: iblock
250 
251  this%mf6_input = mf6_input
252  this%component_name = component_name
253  this%component_input_name = component_input_name
254  this%input_name = input_name
255  this%iperblock = 0
256 
257  ! create subpackage list
258  call this%subpkg_list%create(this%mf6_input%mempath, &
259  this%mf6_input%component_name)
260 
261  ! identify period block definition
262  do iblock = 1, size(mf6_input%block_dfns)
263  if (mf6_input%block_dfns(iblock)%blockname == 'PERIOD') then
264  this%iperblock = iblock
265  exit
266  end if
267  end do

◆ 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 171 of file InputLoadType.f90.

177  class(SubPackageListType) :: this
178  character(len=*), intent(in) :: pkgtype
179  character(len=*), intent(in) :: component_type
180  character(len=*), intent(in) :: subcomponent_type
181  character(len=*), intent(in) :: tagname
182  character(len=*), intent(in) :: filename
183  character(len=LENVARNAME) :: mempath_tag
184  character(len=LENMEMPATH), pointer :: subpkg_mempath
185  character(len=LINELENGTH), pointer :: input_fname
186  integer(I4B) :: idx, trimlen
187 
188  ! reallocate
189  call expandarray(this%pkgtypes)
190  call expandarray(this%component_types)
191  call expandarray(this%subcomponent_types)
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%filenames(this%pnum) = filename
200 
201  ! initialize mempath tag
202  mempath_tag = tagname
203  trimlen = len_trim(tagname)
204  idx = 0
205 
206  ! create mempath tagname
207  idx = index(tagname, '_')
208  if (idx > 0) then
209  if (tagname(idx + 1:trimlen) == 'FILENAME') then
210  write (mempath_tag, '(a)') tagname(1:idx)//'MEMPATH'
211  end if
212  end if
213 
214  ! allocate mempath variable for subpackage
215  call mem_allocate(subpkg_mempath, lenmempath, mempath_tag, &
216  this%mempath)
217 
218  ! create and set the mempath
219  subpkg_mempath = &
220  create_mem_path(this%component_name, &
221  subcomponent_type, idm_context)
222 
223  ! allocate and initialize filename for subpackage
224  call mem_allocate(input_fname, linelength, 'INPUT_FNAME', subpkg_mempath)
225  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  class(SubPackageListType) :: this
154  character(len=*), intent(in) :: mempath
155  character(len=*), intent(in) :: component_name
156 
157  ! initialize
158  this%pnum = 0
159  this%mempath = mempath
160  this%component_name = component_name
161 
162  ! allocate arrays
163  allocate (this%pkgtypes(0))
164  allocate (this%component_types(0))
165  allocate (this%subcomponent_types(0))
166  allocate (this%filenames(0))

◆ subpkg_destroy()

subroutine inputloadtypemodule::subpkg_destroy ( class(subpackagelisttype this)

Definition at line 230 of file InputLoadType.f90.

231  class(SubPackageListType) :: this
232  ! allocate arrays
233  deallocate (this%pkgtypes)
234  deallocate (this%component_types)
235  deallocate (this%subcomponent_types)
236  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