MODFLOW 6  version 6.7.0.dev2
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_inputs
 

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

555  type(ListType), intent(inout) :: list !< package list
556  class(ModelDynamicPkgsType), pointer, intent(inout) :: model_dynamic
557  class(*), pointer :: obj
558  obj => model_dynamic
559  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 274 of file InputLoadType.f90.

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

408  class(DynamicPkgLoadType), intent(inout) :: this
409  ! override in derived type

◆ dynamic_destroy()

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

Definition at line 415 of file InputLoadType.f90.

419  class(DynamicPkgLoadType), intent(inout) :: this
420 
421  ! clean up netcdf variables structure
422  if (associated(this%nc_vars)) then
423  call this%nc_vars%destroy()
424  deallocate (this%nc_vars)
425  nullify (this%nc_vars)
426  end if
427 
428  ! deallocate package static and dynamic input context
429  call memorystore_remove(this%mf6_input%component_name, &
430  this%mf6_input%subcomponent_name, &
431  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 399 of file InputLoadType.f90.

400  class(DynamicPkgLoadType), intent(inout) :: this
401  ! 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 341 of file InputLoadType.f90.

343  use simvariablesmodule, only: errmsg
345  class(DynamicPkgLoadType), intent(inout) :: this
346  type(ModflowInputType), intent(in) :: mf6_input
347  character(len=*), intent(in) :: component_name
348  character(len=*), intent(in) :: component_input_name
349  character(len=*), intent(in) :: input_name
350  integer(I4B), intent(in) :: iperblock
351  integer(I4B), intent(in) :: iout
352  type(InputParamDefinitionType), pointer :: idt
353  integer(I4B) :: iparam
354 
355  this%mf6_input = mf6_input
356  this%component_name = component_name
357  this%component_input_name = component_input_name
358  this%input_name = input_name
359  this%readasarrays = .false.
360  this%readarraygrid = .false.
361  this%iperblock = iperblock
362  this%nparam = 0
363  this%iout = iout
364  nullify (idt)
365 
366  ! throw error and exit if not found
367  if (this%iperblock == 0) then
368  write (errmsg, '(a,a)') &
369  'Programming error. (IDM) PERIOD block not found in '&
370  &'dynamic package input block dfns: ', &
371  trim(mf6_input%subcomponent_name)
372  call store_error(errmsg)
373  call store_error_filename(this%input_name)
374  end if
375 
376  ! set readasarrays and readarraygrid
377  if (mf6_input%block_dfns(iperblock)%aggregate) then
378  ! no-op, list based input
379  else
380  do iparam = 1, size(mf6_input%param_dfns)
381  idt => mf6_input%param_dfns(iparam)
382  if (idt%blockname == 'OPTIONS') then
383  select case (idt%tagname)
384  case ('READASARRAYS')
385  this%readasarrays = .true.
386  case ('READARRAYGRID')
387  this%readarraygrid = .true.
388  case default
389  ! no-op
390  end select
391  end if
392  end do
393  end if
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 515 of file InputLoadType.f90.

516  class(ModelDynamicPkgsType), intent(inout) :: this
517  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
518  integer(I4B) :: n
519  do n = 1, this%pkglist%Count()
520  dynamic_pkg => this%get(n)
521  call dynamic_pkg%ad()
522  end do

◆ dynamicpkgs_add()

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

Definition at line 457 of file InputLoadType.f90.

458  class(ModelDynamicPkgsType), intent(inout) :: this
459  class(DynamicPkgLoadBaseType), pointer, intent(inout) :: dynamic_pkg
460  class(*), pointer :: obj
461  obj => dynamic_pkg
462  call this%pkglist%add(obj)

◆ dynamicpkgs_destroy()

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

Definition at line 537 of file InputLoadType.f90.

538  class(ModelDynamicPkgsType), intent(inout) :: this
539  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
540  integer(I4B) :: n
541  ! destroy dynamic loaders
542  do n = 1, this%pkglist%Count()
543  dynamic_pkg => this%get(n)
544  call dynamic_pkg%destroy()
545  deallocate (dynamic_pkg)
546  nullify (dynamic_pkg)
547  end do
548  call this%pkglist%Clear()

◆ dynamicpkgs_df()

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

Definition at line 502 of file InputLoadType.f90.

503  class(ModelDynamicPkgsType), intent(inout) :: this
504  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
505  integer(I4B) :: n
506  do n = 1, this%pkglist%Count()
507  dynamic_pkg => this%get(n)
508  call dynamic_pkg%df()
509  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 468 of file InputLoadType.f90.

469  class(ModelDynamicPkgsType), intent(inout) :: this
470  integer(I4B), intent(in) :: idx
471  class(DynamicPkgLoadBaseType), pointer :: res
472  class(*), pointer :: obj
473  nullify (res)
474  obj => this%pkglist%GetItem(idx)
475  if (associated(obj)) then
476  select type (obj)
477  class is (dynamicpkgloadbasetype)
478  res => obj
479  end select
480  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 437 of file InputLoadType.f90.

439  class(ModelDynamicPkgsType), intent(inout) :: this
440  character(len=*), intent(in) :: modeltype
441  character(len=*), intent(in) :: modelname
442  character(len=*), intent(in) :: modelfname
443  character(len=*), intent(in) :: nc_fname
444  integer(I4B), intent(in) :: ncid
445  integer(I4B), intent(in) :: iout
446  this%modeltype = modeltype
447  this%modelname = modelname
448  this%modelfname = modelfname
449  this%nc_fname = nc_fname
450  this%ncid = ncid
451  this%iout = iout

◆ dynamicpkgs_rp()

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

Definition at line 486 of file InputLoadType.f90.

488  class(ModelDynamicPkgsType), intent(inout) :: this
489  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
490  integer(I4B) :: n
491  call idm_log_period_header(this%modelname, this%iout)
492  do n = 1, this%pkglist%Count()
493  dynamic_pkg => this%get(n)
494  call dynamic_pkg%rp()
495  end do
496  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 528 of file InputLoadType.f90.

529  class(ModelDynamicPkgsType), intent(inout) :: this
530  integer(I4B) :: size
531  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 565 of file InputLoadType.f90.

566  type(ListType), intent(inout) :: list !< spd list
567  integer(I4B), intent(in) :: idx !< package number
568  class(ModelDynamicPkgsType), pointer :: res
569  class(*), pointer :: obj
570  ! initialize res
571  nullify (res)
572  ! get the object from the list
573  obj => list%GetItem(idx)
574  if (associated(obj)) then
575  select type (obj)
576  class is (modeldynamicpkgstype)
577  res => obj
578  end select
579  end if
Here is the caller graph for this function:

◆ static_destroy()

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

Definition at line 325 of file InputLoadType.f90.

326  class(StaticPkgLoadType), intent(inout) :: this
327  call this%subpkg_list%destroy()
328  if (associated(this%nc_vars)) then
329  call this%nc_vars%destroy()
330  deallocate (this%nc_vars)
331  nullify (this%nc_vars)
332  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 243 of file InputLoadType.f90.

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

178  class(SubPackageListType) :: this
179  character(len=*), intent(in) :: pkgtype
180  character(len=*), intent(in) :: component_type
181  character(len=*), intent(in) :: subcomponent_type
182  character(len=*), intent(in) :: tagname
183  character(len=*), intent(in) :: filename
184  character(len=LENVARNAME) :: mempath_tag
185  character(len=LENMEMPATH), pointer :: subpkg_mempath
186  character(len=LINELENGTH), pointer :: input_fname
187  integer(I4B) :: idx, trimlen
188 
189  ! reallocate
190  call expandarray(this%pkgtypes)
191  call expandarray(this%component_types)
192  call expandarray(this%subcomponent_types)
193  call expandarray(this%filenames)
194 
195  ! add new package instance
196  this%pnum = this%pnum + 1
197  this%pkgtypes(this%pnum) = pkgtype
198  this%component_types(this%pnum) = component_type
199  this%subcomponent_types(this%pnum) = subcomponent_type
200  this%filenames(this%pnum) = filename
201 
202  ! initialize mempath tag
203  mempath_tag = tagname
204  trimlen = len_trim(tagname)
205  idx = 0
206 
207  ! create mempath tagname
208  idx = index(tagname, '_')
209  if (idx > 0) then
210  if (tagname(idx + 1:trimlen) == 'FILENAME') then
211  write (mempath_tag, '(a)') tagname(1:idx)//'MEMPATH'
212  end if
213  end if
214 
215  ! allocate mempath variable for subpackage
216  call mem_allocate(subpkg_mempath, lenmempath, mempath_tag, &
217  this%mempath)
218 
219  ! create and set the mempath
220  subpkg_mempath = &
221  create_mem_path(this%component_name, &
222  subcomponent_type, idm_context)
223 
224  ! allocate and initialize filename for subpackage
225  call mem_allocate(input_fname, linelength, 'INPUT_FNAME', subpkg_mempath)
226  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 153 of file InputLoadType.f90.

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

◆ subpkg_destroy()

subroutine inputloadtypemodule::subpkg_destroy ( class(subpackagelisttype this)

Definition at line 231 of file InputLoadType.f90.

232  class(SubPackageListType) :: this
233  ! allocate arrays
234  deallocate (this%pkgtypes)
235  deallocate (this%component_types)
236  deallocate (this%subcomponent_types)
237  deallocate (this%filenames)

Variable Documentation

◆ model_inputs

type(listtype), public inputloadtypemodule::model_inputs

Definition at line 147 of file InputLoadType.f90.

147  type(ListType) :: model_inputs