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

This module contains the BoundInputContextModule. More...

Data Types

type  readstatevartype
 Pointer type for read state variable. More...
 
type  boundinputcontexttype
 derived type for boundary package input context More...
 

Functions/Subroutines

subroutine create (this, mf6_input, readasarrays)
 create boundary input context More...
 
subroutine allocate_scalars (this)
 create boundary input context More...
 
subroutine allocate_arrays (this)
 allocate_arrays More...
 
subroutine list_params_create (this, params, nparam, input_name)
 
subroutine array_params_create (this, params, nparam, input_name)
 allocate dfn array input period block parameters More...
 
subroutine destroy (this)
 destroy boundary input context More...
 
character(len=lenvarname) function rsv_alloc (this, mf6varname)
 allocate a read state variable More...
 
subroutine bound_params (this, params, nparam, input_name, create)
 allocate and set input array to filtered param set More...
 
character(len=lenvarname) function, public rsv_name (mf6varname)
 create read state variable name More...
 

Detailed Description

This module contains a type that stores and creates context relevant to stress package inputs.

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine boundinputcontextmodule::allocate_arrays ( class(boundinputcontexttype this)

allocate bound input context arrays

Definition at line 149 of file BoundInputContext.f90.

150  ! -- modules
153  ! -- dummy
154  class(BoundInputContextType) :: this
155  integer(I4B), dimension(:, :), pointer, contiguous :: cellid
156  ! -- local
157  !
158  ! -- set auxname_cst and iauxmultcol
159  if (this%naux > 0) then
160  call mem_setptr(this%auxname_cst, 'AUXILIARY', this%mf6_input%mempath)
161  else
162  call mem_allocate(this%auxname_cst, lenauxname, 0, &
163  'AUXILIARY', this%mf6_input%mempath)
164  end if
165  !
166  ! -- allocate cellid if this is not list input
167  if (this%readasarrays) then
168  call mem_allocate(cellid, 0, 0, 'CELLID', this%mf6_input%mempath)
169  end if
170  !
171  ! -- set pointer to BOUNDNAME
172  call mem_setptr(this%boundname_cst, 'BOUNDNAME', this%mf6_input%mempath)
173  !
174  ! -- set pointer to AUXVAR
175  call mem_setptr(this%auxvar, 'AUXVAR', this%mf6_input%mempath)
176  !
177  ! -- return
178  return
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
Here is the call graph for this function:

◆ allocate_scalars()

subroutine boundinputcontextmodule::allocate_scalars ( class(boundinputcontexttype this)
private

Definition at line 92 of file BoundInputContext.f90.

93  ! -- modules
96  ! -- dummy
97  class(BoundInputContextType) :: this
98  logical(LGP) :: found
99  !
100  ! -- set pointers to defined scalars
101  call mem_setptr(this%naux, 'NAUX', this%mf6_input%mempath)
102  !
103  ! -- allocate memory managed scalars
104  call mem_allocate(this%nbound, 'NBOUND', this%mf6_input%mempath)
105  call mem_allocate(this%ncpl, 'NCPL', this%mf6_input%mempath)
106  !
107  ! -- internally allocate package optional scalars
108  allocate (this%maxbound)
109  allocate (this%inamedbound)
110  allocate (this%iprpak)
111  !
112  ! -- initialize allocated and internal scalars
113  this%nbound = 0
114  this%ncpl = 0
115  this%maxbound = 0
116  this%inamedbound = 0
117  this%iprpak = 0
118  !
119  ! -- update optional scalars
120  call mem_set_value(this%inamedbound, 'BOUNDNAMES', this%mf6_input%mempath, &
121  found)
122  call mem_set_value(this%maxbound, 'MAXBOUND', this%mf6_input%mempath, found)
123  call mem_set_value(this%iprpak, 'IPRPAK', this%mf6_input%mempath, found)
124  !
125  ! -- set pointer to model shape
126  call mem_setptr(this%mshape, 'MODEL_SHAPE', &
127  this%mf6_input%component_mempath)
128  !
129  ! -- update ncpl from model shape
130  if (size(this%mshape) == 2) then
131  this%ncpl = this%mshape(2)
132  else if (size(this%mshape) == 3) then
133  this%ncpl = this%mshape(2) * this%mshape(3)
134  end if
135  !
136  ! -- initialize package params object
137  call this%package_params%init(this%mf6_input, 'PERIOD', this%readasarrays, &
138  this%naux, this%inamedbound)
139  !
140  ! -- return
141  return
Here is the call graph for this function:

◆ array_params_create()

subroutine boundinputcontextmodule::array_params_create ( class(boundinputcontexttype this,
character(len=*), dimension(:), intent(in), allocatable  params,
integer(i4b), intent(in)  nparam,
character(len=*), intent(in)  input_name 
)

Currently supports numeric (i.e. array based) params

Definition at line 259 of file BoundInputContext.f90.

260  ! -- modules
265  ! -- dummy
266  class(BoundInputContextType) :: this
267  character(len=*), dimension(:), allocatable, intent(in) :: params
268  integer(I4B), intent(in) :: nparam
269  character(len=*), intent(in) :: input_name
270  ! -- local
271  type(InputParamDefinitionType), pointer :: idt
272  integer(I4B) :: iparam
273  !
274  ! -- allocate dfn input params
275  do iparam = 1, nparam
276  !
277  ! -- assign param definition pointer
278  idt => get_param_definition_type(this%mf6_input%param_dfns, &
279  this%mf6_input%component_type, &
280  this%mf6_input%subcomponent_type, &
281  'PERIOD', params(iparam), '')
282  !
283  if (idt%blockname == 'PERIOD') then
284  select case (idt%datatype)
285  case ('INTEGER1D')
286  call allocate_param_int1d(this%ncpl, idt%mf6varname, &
287  this%mf6_input%mempath)
288  !
289  case ('DOUBLE1D')
290  call allocate_param_dbl1d(this%ncpl, idt%mf6varname, &
291  this%mf6_input%mempath)
292  !
293  case ('DOUBLE2D')
294  call allocate_param_dbl2d(this%naux, this%ncpl, idt%mf6varname, &
295  this%mf6_input%mempath)
296  !
297  case default
298  errmsg = 'IDM unimplemented. BoundInputContext::array_params_create &
299  &datatype='//trim(idt%datatype)
300  call store_error(errmsg)
301  call store_error_filename(input_name)
302  end select
303  end if
304  end do
305  !
306  ! -- return
307  return
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename)
Return parameter definition.
This module contains the DynamicPackageParamsModule.
subroutine, public allocate_param_int1d(nrow, varname, mempath)
allocate int1d
subroutine, public allocate_param_dbl1d(nrow, varname, mempath)
allocate dbl1d
subroutine, public allocate_param_dbl2d(ncol, nrow, varname, mempath)
allocate dbl2d
Here is the call graph for this function:

◆ bound_params()

subroutine boundinputcontextmodule::bound_params ( class(boundinputcontexttype this,
character(len=linelength), dimension(:), intent(inout), allocatable  params,
integer(i4b), intent(inout)  nparam,
character(len=*), intent(in)  input_name,
logical(lgp), intent(in), optional  create 
)

Definition at line 375 of file BoundInputContext.f90.

376  ! -- modules
377  ! -- dummy
378  class(BoundInputContextType) :: this
379  character(len=LINELENGTH), dimension(:), allocatable, &
380  intent(inout) :: params
381  integer(I4B), intent(inout) :: nparam
382  character(len=*), intent(in) :: input_name
383  logical(LGP), optional, intent(in) :: create
384  logical(LGP) :: allocate_params
385  integer(I4B) :: n
386  !
387  ! -- initialize allocate_params
388  allocate_params = .true.
389  !
390  ! -- override default if provided
391  if (present(create)) then
392  allocate_params = create
393  end if
394  !
395  if (allocated(params)) deallocate (params)
396  !
397  nparam = this%package_params%nparam
398  !
399  allocate (params(nparam))
400  !
401  do n = 1, nparam
402  params(n) = this%package_params%params(n)
403  end do
404  !
405  if (allocate_params) then
406  if (this%readasarrays) then
407  !
408  call this%array_params_create(params, nparam, input_name)
409  else
410  !
411  call this%list_params_create(params, nparam, input_name)
412  end if
413  end if
414  !
415  ! -- return
416  return

◆ create()

subroutine boundinputcontextmodule::create ( class(boundinputcontexttype this,
type(modflowinputtype), intent(in)  mf6_input,
logical(lgp), intent(in)  readasarrays 
)
private

Definition at line 72 of file BoundInputContext.f90.

73  ! -- modules
74  ! -- dummy
75  class(BoundInputContextType) :: this
76  type(ModflowInputType), intent(in) :: mf6_input
77  logical(LGP), intent(in) :: readasarrays
78  !
79  this%mf6_input = mf6_input
80  this%readasarrays = readasarrays
81  !
82  ! -- create the dynamic package input context
83  call this%allocate_scalars()
84  !
85  ! --return
86  return

◆ destroy()

subroutine boundinputcontextmodule::destroy ( class(boundinputcontexttype this)

Definition at line 313 of file BoundInputContext.f90.

314  ! -- modules
315  ! -- dummy
316  class(BoundInputContextType) :: this
317  !
318  ! -- destroy package params object
319  call this%package_params%destroy()
320  !
321  ! -- deallocate
322  deallocate (this%maxbound)
323  deallocate (this%inamedbound)
324  deallocate (this%iprpak)
325  !
326  ! -- nullify
327  nullify (this%naux)
328  nullify (this%nbound)
329  nullify (this%ncpl)
330  nullify (this%maxbound)
331  nullify (this%inamedbound)
332  nullify (this%iprpak)
333  nullify (this%auxname_cst)
334  nullify (this%boundname_cst)
335  nullify (this%auxvar)
336  nullify (this%mshape)
337  !
338  ! --return
339  return

◆ list_params_create()

subroutine boundinputcontextmodule::list_params_create ( class(boundinputcontexttype this,
character(len=*), dimension(:), intent(in), allocatable  params,
integer(i4b), intent(in)  nparam,
character(len=*), intent(in)  input_name 
)

Definition at line 181 of file BoundInputContext.f90.

182  ! -- modules
190  ! -- dummy
191  class(BoundInputContextType) :: this
192  character(len=*), dimension(:), allocatable, intent(in) :: params
193  integer(I4B), intent(in) :: nparam
194  character(len=*), intent(in) :: input_name
195  ! -- local
196  type(InputParamDefinitionType), pointer :: idt
197  integer(I4B) :: iparam
198  !
199  ! --
200  do iparam = 1, nparam
201  idt => get_param_definition_type(this%mf6_input%param_dfns, &
202  this%mf6_input%component_type, &
203  this%mf6_input%subcomponent_type, &
204  'PERIOD', params(iparam), '')
205  !
206  ! allocate based on dfn datatype
207  select case (idt%datatype)
208  case ('INTEGER')
209  call allocate_param_int1d(this%maxbound, idt%mf6varname, &
210  this%mf6_input%mempath)
211  !
212  case ('DOUBLE')
213  call allocate_param_dbl1d(this%maxbound, idt%mf6varname, &
214  this%mf6_input%mempath)
215  !
216  case ('STRING')
217  call allocate_param_charstr(lenboundname, this%maxbound, idt%mf6varname, &
218  this%mf6_input%mempath)
219  !
220  case ('INTEGER1D')
221  if (idt%shape == 'NCELLDIM') then
222  call allocate_param_int2d(size(this%mshape), this%maxbound, &
223  idt%mf6varname, this%mf6_input%mempath)
224  else
225  errmsg = 'IDM unimplemented. BoundInputContext::list_params_create &
226  &shape='//trim(idt%shape)
227  call store_error(errmsg)
228  call store_error_filename(input_name)
229  end if
230  !
231  case ('DOUBLE1D')
232  if (idt%shape == 'NAUX') then
233  call allocate_param_dbl2d(this%naux, this%maxbound, &
234  idt%mf6varname, this%mf6_input%mempath)
235  else
236  errmsg = 'IDM unimplemented. BoundInputContext::list_params_create &
237  &tagname='//trim(idt%tagname)
238  call store_error(errmsg)
239  call store_error_filename(input_name)
240  end if
241  !
242  case default
243  errmsg = 'IDM unimplemented. BoundInputContext::list_params_create &
244  &datatype='//trim(idt%datatype)
245  call store_error(errmsg)
246  call store_error_filename(input_name)
247  end select
248  end do
249  !
250  ! -- return
251  return
subroutine, public allocate_param_int2d(ncol, nrow, varname, mempath)
allocate int2d
subroutine, public allocate_param_charstr(strlen, nrow, varname, mempath)
allocate character string type array
This module contains the InputDefinitionModule.
Here is the call graph for this function:

◆ rsv_alloc()

character(len=lenvarname) function boundinputcontextmodule::rsv_alloc ( class(boundinputcontexttype this,
character(len=*), intent(in)  mf6varname 
)
private

Create and set a read state variable, e.g. 'INRECHARGE', which are updated per iper load as follows: -1: unset, not in use 0: not read in most recent period block 1: numeric input read in most recent period block 2: time series input read in most recent period block

Definition at line 352 of file BoundInputContext.f90.

353  ! -- modules
354  use constantsmodule, only: lenvarname
356  ! -- dummy
357  class(BoundInputContextType) :: this
358  character(len=*), intent(in) :: mf6varname
359  ! -- local
360  character(len=LENVARNAME) :: varname
361  integer(I4B), pointer :: intvar
362  !
363  varname = rsv_name(mf6varname)
364  !
365  call mem_allocate(intvar, varname, this%mf6_input%mempath)
366  intvar = -1
367  !
368  ! -- return
369  return
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
Here is the call graph for this function:

◆ rsv_name()

character(len=lenvarname) function, public boundinputcontextmodule::rsv_name ( character(len=*), intent(in)  mf6varname)

Definition at line 422 of file BoundInputContext.f90.

423  ! -- modules
424  use constantsmodule, only: lenvarname
425  ! -- dummy
426  character(len=*), intent(in) :: mf6varname
427  ! -- local
428  character(len=LENVARNAME) :: varname
429  integer(I4B) :: ilen
430  character(len=2) :: prefix = 'IN'
431  !
432  ilen = len_trim(mf6varname)
433  !
434  if (ilen > (lenvarname - len(prefix))) then
435  varname = prefix//mf6varname(1:(lenvarname - len(prefix)))
436  else
437  varname = prefix//trim(mf6varname)
438  end if
439  !
440  ! -- return
441  return
Here is the caller graph for this function: