MODFLOW 6  version 6.7.0.dev3
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 570 of file InputLoadType.f90.

571  type(ListType), intent(inout) :: list !< package list
572  class(ModelDynamicPkgsType), pointer, intent(inout) :: model_dynamic
573  class(*), pointer :: obj
574  obj => model_dynamic
575  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 275 of file InputLoadType.f90.

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

424  class(DynamicPkgLoadType), intent(inout) :: this
425  ! override in derived type

◆ dynamic_destroy()

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

Definition at line 431 of file InputLoadType.f90.

435  class(DynamicPkgLoadType), intent(inout) :: this
436 
437  ! clean up netcdf variables structure
438  if (associated(this%nc_vars)) then
439  call this%nc_vars%destroy()
440  deallocate (this%nc_vars)
441  nullify (this%nc_vars)
442  end if
443 
444  ! deallocate package static and dynamic input context
445  call memorystore_remove(this%mf6_input%component_name, &
446  this%mf6_input%subcomponent_name, &
447  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 415 of file InputLoadType.f90.

416  class(DynamicPkgLoadType), intent(inout) :: this
417  ! 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 342 of file InputLoadType.f90.

344  use simvariablesmodule, only: errmsg
347  class(DynamicPkgLoadType), intent(inout) :: this
348  type(ModflowInputType), intent(in) :: mf6_input
349  character(len=*), intent(in) :: component_name
350  character(len=*), intent(in) :: component_input_name
351  character(len=*), intent(in) :: input_name
352  integer(I4B), intent(in) :: iperblock
353  integer(I4B), intent(in) :: iout
354  type(InputParamDefinitionType), pointer :: idt
355  integer(I4B) :: iparam, ilen
356 
357  this%mf6_input = mf6_input
358  this%component_name = component_name
359  this%component_input_name = component_input_name
360  this%input_name = input_name
361  this%readasarrays = .false.
362  this%readarraygrid = .false.
363  this%has_setting = .false.
364  this%iperblock = iperblock
365  this%nparam = 0
366  this%iout = iout
367  nullify (idt)
368 
369  ! throw error and exit if not found
370  if (this%iperblock == 0) then
371  write (errmsg, '(a,a)') &
372  'Programming error. (IDM) PERIOD block not found in '&
373  &'dynamic package input block dfns: ', &
374  trim(mf6_input%subcomponent_name)
375  call store_error(errmsg)
376  call store_error_filename(this%input_name)
377  end if
378 
379  ! set readasarrays and readarraygrid
380  if (mf6_input%block_dfns(iperblock)%aggregate) then
381  ! no-op
382  else
383  do iparam = 1, size(mf6_input%param_dfns)
384  idt => mf6_input%param_dfns(iparam)
385  if (idt%blockname == 'OPTIONS') then
386  select case (idt%tagname)
387  case ('READASARRAYS')
388  this%readasarrays = .true.
389  case ('READARRAYGRID')
390  this%readarraygrid = .true.
391  case default
392  ! no-op
393  end select
394  end if
395  end do
396  end if
397 
398  ! determine if has setting type
399  do iparam = 1, size(mf6_input%param_dfns)
400  idt => mf6_input%param_dfns(iparam)
401  if (idt%blockname == 'PERIOD') then
402  if (idt_datatype(idt) == 'KEYSTRING') then
403  ilen = len_trim(idt%tagname)
404  if (idt%tagname(ilen - 6:ilen) == 'SETTING') then
405  this%has_setting = .true.
406  end if
407  end if
408  end if
409  end do
This module contains the DefinitionSelectModule.
character(len=linelength) function, public idt_datatype(idt)
return input definition type datatype
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 531 of file InputLoadType.f90.

532  class(ModelDynamicPkgsType), intent(inout) :: this
533  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
534  integer(I4B) :: n
535  do n = 1, this%pkglist%Count()
536  dynamic_pkg => this%get(n)
537  call dynamic_pkg%ad()
538  end do

◆ dynamicpkgs_add()

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

Definition at line 473 of file InputLoadType.f90.

474  class(ModelDynamicPkgsType), intent(inout) :: this
475  class(DynamicPkgLoadBaseType), pointer, intent(inout) :: dynamic_pkg
476  class(*), pointer :: obj
477  obj => dynamic_pkg
478  call this%pkglist%add(obj)

◆ dynamicpkgs_destroy()

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

Definition at line 553 of file InputLoadType.f90.

554  class(ModelDynamicPkgsType), intent(inout) :: this
555  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
556  integer(I4B) :: n
557  ! destroy dynamic loaders
558  do n = 1, this%pkglist%Count()
559  dynamic_pkg => this%get(n)
560  call dynamic_pkg%destroy()
561  deallocate (dynamic_pkg)
562  nullify (dynamic_pkg)
563  end do
564  call this%pkglist%Clear()

◆ dynamicpkgs_df()

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

Definition at line 518 of file InputLoadType.f90.

519  class(ModelDynamicPkgsType), intent(inout) :: this
520  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
521  integer(I4B) :: n
522  do n = 1, this%pkglist%Count()
523  dynamic_pkg => this%get(n)
524  call dynamic_pkg%df()
525  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 484 of file InputLoadType.f90.

485  class(ModelDynamicPkgsType), intent(inout) :: this
486  integer(I4B), intent(in) :: idx
487  class(DynamicPkgLoadBaseType), pointer :: res
488  class(*), pointer :: obj
489  nullify (res)
490  obj => this%pkglist%GetItem(idx)
491  if (associated(obj)) then
492  select type (obj)
493  class is (dynamicpkgloadbasetype)
494  res => obj
495  end select
496  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 453 of file InputLoadType.f90.

455  class(ModelDynamicPkgsType), intent(inout) :: this
456  character(len=*), intent(in) :: modeltype
457  character(len=*), intent(in) :: modelname
458  character(len=*), intent(in) :: modelfname
459  character(len=*), intent(in) :: nc_fname
460  integer(I4B), intent(in) :: ncid
461  integer(I4B), intent(in) :: iout
462  this%modeltype = modeltype
463  this%modelname = modelname
464  this%modelfname = modelfname
465  this%nc_fname = nc_fname
466  this%ncid = ncid
467  this%iout = iout

◆ dynamicpkgs_rp()

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

Definition at line 502 of file InputLoadType.f90.

504  class(ModelDynamicPkgsType), intent(inout) :: this
505  class(DynamicPkgLoadBaseType), pointer :: dynamic_pkg
506  integer(I4B) :: n
507  call idm_log_period_header(this%modelname, this%iout)
508  do n = 1, this%pkglist%Count()
509  dynamic_pkg => this%get(n)
510  call dynamic_pkg%rp()
511  end do
512  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 544 of file InputLoadType.f90.

545  class(ModelDynamicPkgsType), intent(inout) :: this
546  integer(I4B) :: size
547  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 581 of file InputLoadType.f90.

582  type(ListType), intent(inout) :: list !< spd list
583  integer(I4B), intent(in) :: idx !< package number
584  class(ModelDynamicPkgsType), pointer :: res
585  class(*), pointer :: obj
586  ! initialize res
587  nullify (res)
588  ! get the object from the list
589  obj => list%GetItem(idx)
590  if (associated(obj)) then
591  select type (obj)
592  class is (modeldynamicpkgstype)
593  res => obj
594  end select
595  end if
Here is the caller graph for this function:

◆ static_destroy()

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

Definition at line 326 of file InputLoadType.f90.

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

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

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

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

◆ subpkg_destroy()

subroutine inputloadtypemodule::subpkg_destroy ( class(subpackagelisttype this)

Definition at line 232 of file InputLoadType.f90.

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

Variable Documentation

◆ model_inputs

type(listtype), public inputloadtypemodule::model_inputs

Definition at line 148 of file InputLoadType.f90.

148  type(ListType) :: model_inputs