MODFLOW 6  version 6.9.0.dev0
USGS Modular Hydrologic Model
gridarrayloadmodule Module Reference

This module contains the GridArrayLoadModule. More...

Data Types

type  gridarrayloadtype
 Ascii grid based dynamic loader type. More...
 

Functions/Subroutines

subroutine ainit (this, mf6_input, component_name, component_input_name, input_name, iperblock, parser, iout)
 
subroutine df (this)
 
subroutine ts_advance (this)
 
subroutine rp (this, parser)
 
subroutine destroy (this)
 
subroutine reset (this)
 
subroutine params_alloc (this)
 
subroutine param_load (this, parser, idt, mempath, layered, netcdf, iaux)
 

Detailed Description

This module contains the routines for reading period block grid array-based input for stress packages that use the READARRAYGRID option (CHD, WEL, DRN, RIV, GHB).

Function/Subroutine Documentation

◆ ainit()

subroutine gridarrayloadmodule::ainit ( class(gridarrayloadtype), 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,
type(blockparsertype), intent(inout), pointer  parser,
integer(i4b), intent(in)  iout 
)
private

Definition at line 44 of file Mf6FileGridArray.f90.

50  class(GridArrayLoadType), intent(inout) :: this
51  type(ModflowInputType), intent(in) :: mf6_input
52  character(len=*), intent(in) :: component_name
53  character(len=*), intent(in) :: component_input_name
54  character(len=*), intent(in) :: input_name
55  integer(I4B), intent(in) :: iperblock
56  type(BlockParserType), pointer, intent(inout) :: parser
57  integer(I4B), intent(in) :: iout
58  type(LoadMf6FileType) :: loader
59  integer(I4B) :: isize
60  integer(I4B), pointer :: maxbound
61 
62  ! initialize base type
63  call this%DynamicPkgLoadType%init(mf6_input, component_name, &
64  component_input_name, &
65  input_name, iperblock, iout)
66  ! initialize
67  this%iout = iout
68 
69  ! load static input
70  call loader%load(parser, mf6_input, this%nc_vars, this%input_name, iout)
71 
72  ! maxbound is optional
73  call get_isize('MAXBOUND', mf6_input%mempath, isize)
74  if (isize < 0) then
75  ! set maxbound to grid nodes
76  call mem_allocate(maxbound, 'MAXBOUND', mf6_input%mempath)
77  maxbound = product(loader%mshape)
78  end if
79 
80  ! initialize input context memory
81  call this%ctx%init(mf6_input)
82 
83  ! allocate user nodelist
84  call mem_allocate(this%nodeulist, this%ctx%maxbound, &
85  'NODEULIST', mf6_input%mempath)
86 
87  ! allocate dfn params
88  call this%params_alloc()
This module contains block parser methods.
Definition: BlockParser.f90:7
This module contains the LoadMf6FileModule.
Definition: LoadMf6File.f90:8
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
Static parser based input loader.
Definition: LoadMf6File.f90:54
Here is the call graph for this function:

◆ destroy()

subroutine gridarrayloadmodule::destroy ( class(gridarrayloadtype), intent(inout)  this)

Definition at line 162 of file Mf6FileGridArray.f90.

164  class(GridArrayLoadType), intent(inout) :: this
165  call mem_deallocate(this%nodeulist)

◆ df()

subroutine gridarrayloadmodule::df ( class(gridarrayloadtype), intent(inout)  this)

Definition at line 91 of file Mf6FileGridArray.f90.

92  class(GridArrayLoadType), intent(inout) :: this

◆ param_load()

subroutine gridarrayloadmodule::param_load ( class(gridarrayloadtype), intent(inout)  this,
type(blockparsertype), intent(in)  parser,
type(inputparamdefinitiontype), intent(in)  idt,
character(len=*), intent(in)  mempath,
logical(lgp), intent(in)  layered,
logical(lgp), intent(in)  netcdf,
integer(i4b), intent(in)  iaux 
)
private

Definition at line 206 of file Mf6FileGridArray.f90.

207  use tdismodule, only: kper
208  use constantsmodule, only: dnodata
209  use arrayhandlersmodule, only: ifind
215  use idmloggermodule, only: idm_log_var
216  class(GridArrayLoadType), intent(inout) :: this
217  type(BlockParserType), intent(in) :: parser
218  type(InputParamDefinitionType), intent(in) :: idt
219  character(len=*), intent(in) :: mempath
220  logical(LGP), intent(in) :: layered
221  logical(LGP), intent(in) :: netcdf
222  integer(I4B), intent(in) :: iaux
223  real(DP), dimension(:), pointer, contiguous :: dbl1d, nodes
224  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
225  integer(I4B), dimension(:), allocatable :: layer_shape
226  integer(I4B) :: iparam, n, nlay, nnode
227 
228  nnode = 0
229 
230  select case (idt%datatype)
231  case ('DOUBLE1D')
232  call mem_setptr(dbl1d, idt%mf6varname, mempath)
233  allocate (nodes(this%ctx%nodes))
234  if (netcdf) then
235  call netcdf_read_array(nodes, this%ctx%mshape, idt, &
236  this%mf6_input, this%nc_vars, this%input_name, &
237  this%iout, kper)
238  else if (layered) then
239  call get_layered_shape(this%ctx%mshape, nlay, layer_shape)
240  call read_dbl1d_layered(parser, nodes, idt%mf6varname, nlay, layer_shape)
241  else
242  call read_dbl1d(parser, nodes, idt%mf6varname)
243  end if
244 
245  call idm_log_var(nodes, idt%tagname, mempath, this%iout)
246 
247  if (this%ctx%nbound > 0) then
248  ! nodeulist already established: extract values at known positions
249  do n = 1, this%ctx%nbound
250  dbl1d(n) = nodes(this%nodeulist(n))
251  end do
252  else
253  ! first array: filter by DNODATA to establish nodeulist and nbound
254  do n = 1, this%ctx%nodes
255  if (nodes(n) /= dnodata) then
256  nnode = nnode + 1
257  if (nnode > this%ctx%maxbound) then
258  write (errmsg, '(a,i0,a)') &
259  'Input error: number of defined (non-DNODATA) cells &
260  &exceeds MAXBOUND=', this%ctx%maxbound, '.'
261  call store_error(errmsg)
262  call store_error_filename(this%input_name)
263  end if
264  dbl1d(nnode) = nodes(n)
265  this%nodeulist(nnode) = n
266  end if
267  end do
268  this%ctx%nbound = nnode
269  end if
270  deallocate (nodes)
271  case ('DOUBLE2D')
272  call mem_setptr(dbl2d, idt%mf6varname, mempath)
273  allocate (nodes(this%ctx%nodes))
274 
275  if (netcdf) then
276  call netcdf_read_array(nodes, this%ctx%mshape, idt, &
277  this%mf6_input, this%nc_vars, this%input_name, &
278  this%iout, kper, iaux)
279  else if (layered) then
280  call get_layered_shape(this%ctx%mshape, nlay, layer_shape)
281  call read_dbl1d_layered(parser, nodes, idt%mf6varname, nlay, layer_shape)
282  else
283  call read_dbl1d(parser, nodes, idt%mf6varname)
284  end if
285 
286  call idm_log_var(nodes, idt%tagname, mempath, this%iout)
287 
288  if (this%ctx%nbound > 0) then
289  ! nodeulist already established: extract values at known positions
290  do n = 1, this%ctx%nbound
291  dbl2d(iaux, n) = nodes(this%nodeulist(n))
292  end do
293  else
294  ! first array: filter by DNODATA to establish nodeulist and nbound
295  do n = 1, this%ctx%nodes
296  if (nodes(n) /= dnodata) then
297  nnode = nnode + 1
298  if (nnode > this%ctx%maxbound) then
299  write (errmsg, '(a,i0,a)') &
300  'Input error: number of defined (non-DNODATA) cells &
301  &exceeds MAXBOUND=', this%ctx%maxbound, '.'
302  call store_error(errmsg)
303  call store_error_filename(this%input_name)
304  end if
305  dbl2d(iaux, nnode) = nodes(n)
306  this%nodeulist(nnode) = n
307  end if
308  end do
309  this%ctx%nbound = nnode
310  end if
311  deallocate (nodes)
312  case default
313  errmsg = 'IDM unimplemented. GridArrayLoad::param_load &
314  &datatype='//trim(idt%datatype)
315  call store_error(errmsg)
316  call store_error_filename(this%input_name)
317  end select
318 
319  ! if param is tracked set read state
320  iparam = ifind(this%param_names, idt%tagname)
321  if (iparam > 0) then
322  this%param_reads(iparam)%invar = 1
323  end if
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dnodata
real no data constant
Definition: Constants.f90:95
subroutine, public read_dbl1d(parser, dbl1d, aname)
This module contains the Input Data Model Logger Module.
Definition: IdmLogger.f90:7
Input definition module.
subroutine, public read_dbl1d_layered(parser, dbl1d, aname, nlay, layer_shape)
This module contains the LoadNCInputModule.
Definition: LoadNCInput.F90:7
This module contains the SourceCommonModule.
Definition: SourceCommon.f90:7
subroutine, public get_layered_shape(mshape, nlay, layer_shape)
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:26
Input parameter definition. Describes an input parameter.
Here is the call graph for this function:

◆ params_alloc()

subroutine gridarrayloadmodule::params_alloc ( class(gridarrayloadtype), intent(inout)  this)
private

Definition at line 180 of file Mf6FileGridArray.f90.

181  class(GridArrayLoadType), intent(inout) :: this
182  character(len=LENVARNAME) :: rs_varname
183  integer(I4B), pointer :: intvar
184  integer(I4B) :: iparam
185 
186  ! set in-scope param names directly from context
187  this%param_names = this%ctx%params
188  this%nparam = size(this%ctx%params)
189  call this%ctx%allocate_params()
190  call this%ctx%check_developmode(this%input_name)
191  call this%ctx%allocate_arrays()
192 
193  ! allocate and set param_reads pointer array
194  allocate (this%param_reads(this%nparam))
195 
196  ! store read state variable pointers
197  do iparam = 1, this%nparam
198  ! allocate and store name of read state variable
199  rs_varname = this%ctx%rsv_alloc(this%param_names(iparam))
200  call mem_setptr(intvar, rs_varname, this%mf6_input%mempath)
201  this%param_reads(iparam)%invar => intvar
202  this%param_reads(iparam)%invar = 0
203  end do

◆ reset()

subroutine gridarrayloadmodule::reset ( class(gridarrayloadtype), intent(inout)  this)

Definition at line 168 of file Mf6FileGridArray.f90.

169  class(GridArrayLoadType), intent(inout) :: this
170  integer(I4B) :: n
171 
172  this%ctx%nbound = 0
173 
174  do n = 1, this%nparam
175  ! reset read state
176  this%param_reads(n)%invar = 0
177  end do

◆ rp()

subroutine gridarrayloadmodule::rp ( class(gridarrayloadtype), intent(inout)  this,
type(blockparsertype), intent(inout), pointer  parser 
)
private

Definition at line 99 of file Mf6FileGridArray.f90.

103  use arrayhandlersmodule, only: ifind
106  class(GridArrayLoadType), intent(inout) :: this
107  type(BlockParserType), pointer, intent(inout) :: parser
108  logical(LGP) :: endOfBlock, netcdf, layered
109  character(len=LINELENGTH) :: keyword, param_tag
110  type(InputParamDefinitionType), pointer :: idt
111  integer(I4B) :: iaux
112 
113  ! reset for this period
114  call this%reset()
115 
116  ! log lst file header
117  call idm_log_header(this%mf6_input%component_name, &
118  this%mf6_input%subcomponent_name, this%iout)
119 
120  ! read array block
121  do
122  ! initialize
123  iaux = 0
124  netcdf = .false.
125  layered = .false.
126 
127  ! read next line
128  call parser%GetNextLine(endofblock)
129  if (endofblock) exit
130  ! read param_tag
131  call parser%GetStringCaps(param_tag)
132 
133  ! is param tag an auxvar?
134  iaux = ifind_charstr(this%ctx%auxname_cst, param_tag)
135 
136  ! any auxvar corresponds to the definition tag 'AUX'
137  if (iaux > 0) param_tag = 'AUX'
138 
139  ! set input definition
140  idt => get_param_definition_type(this%mf6_input%param_dfns, &
141  this%mf6_input%component_type, &
142  this%mf6_input%subcomponent_type, &
143  'PERIOD', param_tag, this%input_name)
144  ! look for Layered and NetCDF keywords
145  call parser%GetStringCaps(keyword)
146  if (keyword == 'LAYERED' .and. idt%layered) then
147  layered = .true.
148  else if (keyword == 'NETCDF') then
149  netcdf = .true.
150  end if
151 
152  ! read and load the parameter
153  call this%param_load(parser, idt, this%mf6_input%mempath, layered, &
154  netcdf, iaux)
155  end do
156 
157  ! log lst file header
158  call idm_log_close(this%mf6_input%component_name, &
159  this%mf6_input%subcomponent_name, this%iout)
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
subroutine, public idm_log_close(component, subcomponent, iout)
@ brief log the closing message
Definition: IdmLogger.f90:56
subroutine, public idm_log_header(component, subcomponent, iout)
@ brief log a header message
Definition: IdmLogger.f90:44
integer(i4b) function, public ifind_charstr(array, str)
Here is the call graph for this function:

◆ ts_advance()

subroutine gridarrayloadmodule::ts_advance ( class(gridarrayloadtype), intent(inout)  this)
private

Definition at line 95 of file Mf6FileGridArray.f90.

96  class(GridArrayLoadType), intent(inout) :: this