MODFLOW 6  version 6.7.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 139 of file BoundInputContext.f90.

142  class(BoundInputContextType) :: this
143  integer(I4B), dimension(:, :), pointer, contiguous :: cellid
144 
145  ! set auxname_cst and iauxmultcol
146  if (this%naux > 0) then
147  call mem_setptr(this%auxname_cst, 'AUXILIARY', this%mf6_input%mempath)
148  else
149  call mem_allocate(this%auxname_cst, lenauxname, 0, &
150  'AUXILIARY', this%mf6_input%mempath)
151  end if
152 
153  ! allocate cellid if this is not list input
154  if (this%readasarrays) then
155  call mem_allocate(cellid, 0, 0, 'CELLID', this%mf6_input%mempath)
156  end if
157 
158  ! set pointer to BOUNDNAME
159  call mem_setptr(this%boundname_cst, 'BOUNDNAME', this%mf6_input%mempath)
160 
161  ! set pointer to AUXVAR
162  call mem_setptr(this%auxvar, 'AUXVAR', this%mf6_input%mempath)
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 87 of file BoundInputContext.f90.

90  class(BoundInputContextType) :: this
91  logical(LGP) :: found
92 
93  ! set pointers to defined scalars
94  call mem_setptr(this%naux, 'NAUX', this%mf6_input%mempath)
95 
96  ! allocate memory managed scalars
97  call mem_allocate(this%nbound, 'NBOUND', this%mf6_input%mempath)
98  call mem_allocate(this%ncpl, 'NCPL', this%mf6_input%mempath)
99 
100  ! internally allocate package optional scalars
101  allocate (this%maxbound)
102  allocate (this%inamedbound)
103  allocate (this%iprpak)
104 
105  ! initialize allocated and internal scalars
106  this%nbound = 0
107  this%ncpl = 0
108  this%maxbound = 0
109  this%inamedbound = 0
110  this%iprpak = 0
111 
112  ! update optional scalars
113  call mem_set_value(this%inamedbound, 'BOUNDNAMES', this%mf6_input%mempath, &
114  found)
115  call mem_set_value(this%maxbound, 'MAXBOUND', this%mf6_input%mempath, found)
116  call mem_set_value(this%iprpak, 'IPRPAK', this%mf6_input%mempath, found)
117 
118  ! set pointer to model shape
119  call mem_setptr(this%mshape, 'MODEL_SHAPE', &
120  this%mf6_input%component_mempath)
121 
122  ! update ncpl from model shape
123  if (size(this%mshape) == 2) then
124  this%ncpl = this%mshape(2)
125  else if (size(this%mshape) == 3) then
126  this%ncpl = this%mshape(2) * this%mshape(3)
127  end if
128 
129  ! initialize package params object
130  call this%package_params%init(this%mf6_input, 'PERIOD', this%readasarrays, &
131  this%naux, this%inamedbound)
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 230 of file BoundInputContext.f90.

235  class(BoundInputContextType) :: this
236  character(len=*), dimension(:), allocatable, intent(in) :: params
237  integer(I4B), intent(in) :: nparam
238  character(len=*), intent(in) :: input_name
239  type(InputParamDefinitionType), pointer :: idt
240  integer(I4B) :: iparam
241 
242  ! allocate dfn input params
243  do iparam = 1, nparam
244 
245  ! assign param definition pointer
246  idt => get_param_definition_type(this%mf6_input%param_dfns, &
247  this%mf6_input%component_type, &
248  this%mf6_input%subcomponent_type, &
249  'PERIOD', params(iparam), '')
250  if (idt%blockname == 'PERIOD') then
251  select case (idt%datatype)
252  case ('INTEGER1D')
253  call allocate_param_int1d(this%ncpl, idt%mf6varname, &
254  this%mf6_input%mempath)
255  case ('DOUBLE1D')
256  call allocate_param_dbl1d(this%ncpl, idt%mf6varname, &
257  this%mf6_input%mempath)
258  case ('DOUBLE2D')
259  call allocate_param_dbl2d(this%naux, this%ncpl, idt%mf6varname, &
260  this%mf6_input%mempath)
261  case default
262  errmsg = 'IDM unimplemented. BoundInputContext::array_params_create &
263  &datatype='//trim(idt%datatype)
264  call store_error(errmsg)
265  call store_error_filename(input_name)
266  end select
267  end if
268  end do
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 324 of file BoundInputContext.f90.

325  class(BoundInputContextType) :: this
326  character(len=LINELENGTH), dimension(:), allocatable, &
327  intent(inout) :: params
328  integer(I4B), intent(inout) :: nparam
329  character(len=*), intent(in) :: input_name
330  logical(LGP), optional, intent(in) :: create
331  logical(LGP) :: allocate_params
332  integer(I4B) :: n
333 
334  ! initialize allocate_params
335  allocate_params = .true.
336 
337  ! override default if provided
338  if (present(create)) then
339  allocate_params = create
340  end if
341 
342  if (allocated(params)) deallocate (params)
343  nparam = this%package_params%nparam
344  allocate (params(nparam))
345  do n = 1, nparam
346  params(n) = this%package_params%params(n)
347  end do
348 
349  if (allocate_params) then
350  if (this%readasarrays) then
351  call this%array_params_create(params, nparam, input_name)
352  else
353  call this%list_params_create(params, nparam, input_name)
354  end if
355  end if

◆ 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  class(BoundInputContextType) :: this
74  type(ModflowInputType), intent(in) :: mf6_input
75  logical(LGP), intent(in) :: readasarrays
76 
77  this%mf6_input = mf6_input
78  this%readasarrays = readasarrays
79 
80  ! create the dynamic package input context
81  call this%allocate_scalars()

◆ destroy()

subroutine boundinputcontextmodule::destroy ( class(boundinputcontexttype this)

Definition at line 274 of file BoundInputContext.f90.

275  class(BoundInputContextType) :: this
276 
277  ! destroy package params object
278  call this%package_params%destroy()
279 
280  ! deallocate
281  deallocate (this%maxbound)
282  deallocate (this%inamedbound)
283  deallocate (this%iprpak)
284 
285  ! nullify
286  nullify (this%naux)
287  nullify (this%nbound)
288  nullify (this%ncpl)
289  nullify (this%maxbound)
290  nullify (this%inamedbound)
291  nullify (this%iprpak)
292  nullify (this%auxname_cst)
293  nullify (this%boundname_cst)
294  nullify (this%auxvar)
295  nullify (this%mshape)

◆ 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 165 of file BoundInputContext.f90.

173  class(BoundInputContextType) :: this
174  character(len=*), dimension(:), allocatable, intent(in) :: params
175  integer(I4B), intent(in) :: nparam
176  character(len=*), intent(in) :: input_name
177  type(InputParamDefinitionType), pointer :: idt
178  integer(I4B) :: iparam
179 
180  do iparam = 1, nparam
181  idt => get_param_definition_type(this%mf6_input%param_dfns, &
182  this%mf6_input%component_type, &
183  this%mf6_input%subcomponent_type, &
184  'PERIOD', params(iparam), '')
185  ! allocate based on dfn datatype
186  select case (idt%datatype)
187  case ('INTEGER')
188  call allocate_param_int1d(this%maxbound, idt%mf6varname, &
189  this%mf6_input%mempath)
190  case ('DOUBLE')
191  call allocate_param_dbl1d(this%maxbound, idt%mf6varname, &
192  this%mf6_input%mempath)
193  case ('STRING')
194  call allocate_param_charstr(lenboundname, this%maxbound, idt%mf6varname, &
195  this%mf6_input%mempath)
196  case ('INTEGER1D')
197  if (idt%shape == 'NCELLDIM') then
198  call allocate_param_int2d(size(this%mshape), this%maxbound, &
199  idt%mf6varname, this%mf6_input%mempath)
200  else
201  errmsg = 'IDM unimplemented. BoundInputContext::list_params_create &
202  &shape='//trim(idt%shape)
203  call store_error(errmsg)
204  call store_error_filename(input_name)
205  end if
206  case ('DOUBLE1D')
207  if (idt%shape == 'NAUX') then
208  call allocate_param_dbl2d(this%naux, this%maxbound, &
209  idt%mf6varname, this%mf6_input%mempath)
210  else
211  errmsg = 'IDM unimplemented. BoundInputContext::list_params_create &
212  &tagname='//trim(idt%tagname)
213  call store_error(errmsg)
214  call store_error_filename(input_name)
215  end if
216  case default
217  errmsg = 'IDM unimplemented. BoundInputContext::list_params_create &
218  &datatype='//trim(idt%datatype)
219  call store_error(errmsg)
220  call store_error_filename(input_name)
221  end select
222  end do
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 308 of file BoundInputContext.f90.

309  use constantsmodule, only: lenvarname
311  class(BoundInputContextType) :: this
312  character(len=*), intent(in) :: mf6varname
313  character(len=LENVARNAME) :: varname
314  integer(I4B), pointer :: intvar
315 
316  varname = rsv_name(mf6varname)
317  call mem_allocate(intvar, varname, this%mf6_input%mempath)
318  intvar = -1
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 361 of file BoundInputContext.f90.

362  use constantsmodule, only: lenvarname
363  character(len=*), intent(in) :: mf6varname
364  character(len=LENVARNAME) :: varname
365  integer(I4B) :: ilen
366  character(len=2) :: prefix = 'IN'
367 
368  ilen = len_trim(mf6varname)
369  if (ilen > (lenvarname - len(prefix))) then
370  varname = prefix//mf6varname(1:(lenvarname - len(prefix)))
371  else
372  varname = prefix//trim(mf6varname)
373  end if
Here is the caller graph for this function: