MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
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 set_active (this)
 Set active user nodes from discretization IDOMAIN input.
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 )

Definition at line 49 of file Mf6FileGridArray.f90.

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

◆ destroy()

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

Definition at line 170 of file Mf6FileGridArray.f90.

172 class(GridArrayLoadType), intent(inout) :: this
173 call mem_deallocate(this%nodeulist)
174 if (allocated(this%active)) deallocate (this%active)

◆ df()

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

Definition at line 99 of file Mf6FileGridArray.f90.

100 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 279 of file Mf6FileGridArray.f90.

280 use tdismodule, only: kper
281 use constantsmodule, only: dnodata
282 use arrayhandlersmodule, only: ifind
289 class(GridArrayLoadType), intent(inout) :: this
290 type(BlockParserType), intent(in) :: parser
291 type(InputParamDefinitionType), intent(in) :: idt
292 character(len=*), intent(in) :: mempath
293 logical(LGP), intent(in) :: layered
294 logical(LGP), intent(in) :: netcdf
295 integer(I4B), intent(in) :: iaux
296 real(DP), dimension(:), pointer, contiguous :: dbl1d, nodes
297 real(DP), dimension(:, :), pointer, contiguous :: dbl2d
298 integer(I4B), dimension(:), allocatable :: layer_shape
299 integer(I4B) :: iparam, n, nlay, nnode
300
301 nnode = 0
302
303 select case (idt%datatype)
304 case ('DOUBLE1D')
305 call mem_setptr(dbl1d, idt%mf6varname, mempath)
306 allocate (nodes(this%ctx%nodes))
307 if (netcdf) then
308 call netcdf_read_array(nodes, this%ctx%mshape, idt, &
309 this%mf6_input, this%nc_vars, this%input_name, &
310 this%iout, kper)
311 else if (layered) then
312 call get_layered_shape(this%ctx%mshape, nlay, layer_shape)
313 call read_dbl1d_layered(parser, nodes, idt%mf6varname, nlay, layer_shape)
314 else
315 call read_dbl1d(parser, nodes, idt%mf6varname)
316 end if
317
318 call idm_log_var(nodes, idt%tagname, mempath, this%iout)
319
320 if (this%nodeulist_set) then
321 ! nodeulist already established: extract values at known positions
322 do n = 1, this%ctx%nbound
323 dbl1d(n) = nodes(this%nodeulist(n))
324 end do
325 else
326 ! first array sets nodeulist and nbound (defined, active cells)
327 do n = 1, this%ctx%nodes
328 if (nodes(n) /= dnodata .and. this%active(n)) then
329 nnode = nnode + 1
330 if (nnode > this%ctx%maxbound) then
331 write (errmsg, '(a,i0,a)') &
332 'Input error: number of defined (non-DNODATA) active cells &
333 &exceeds MAXBOUND=', this%ctx%maxbound, '.'
334 call store_error(errmsg)
335 call store_error_filename(this%input_name)
336 end if
337 dbl1d(nnode) = nodes(n)
338 this%nodeulist(nnode) = n
339 end if
340 end do
341 this%ctx%nbound = nnode
342 this%nodeulist_set = .true.
343 end if
344 deallocate (nodes)
345 case ('DOUBLE2D')
346 call mem_setptr(dbl2d, idt%mf6varname, mempath)
347 allocate (nodes(this%ctx%nodes))
348
349 if (netcdf) then
350 call netcdf_read_array(nodes, this%ctx%mshape, idt, &
351 this%mf6_input, this%nc_vars, this%input_name, &
352 this%iout, kper, iaux)
353 else if (layered) then
354 call get_layered_shape(this%ctx%mshape, nlay, layer_shape)
355 call read_dbl1d_layered(parser, nodes, idt%mf6varname, nlay, layer_shape)
356 else
357 call read_dbl1d(parser, nodes, idt%mf6varname)
358 end if
359
360 call idm_log_var(nodes, idt%tagname, mempath, this%iout)
361
362 if (this%nodeulist_set) then
363 ! nodeulist already established: extract values at known positions
364 do n = 1, this%ctx%nbound
365 dbl2d(iaux, n) = nodes(this%nodeulist(n))
366 end do
367 else
368 ! first array sets nodeulist and nbound (defined, active cells)
369 do n = 1, this%ctx%nodes
370 if (nodes(n) /= dnodata .and. this%active(n)) then
371 nnode = nnode + 1
372 if (nnode > this%ctx%maxbound) then
373 write (errmsg, '(a,i0,a)') &
374 'Input error: number of defined (non-DNODATA) active cells &
375 &exceeds MAXBOUND=', this%ctx%maxbound, '.'
376 call store_error(errmsg)
377 call store_error_filename(this%input_name)
378 end if
379 dbl2d(iaux, nnode) = nodes(n)
380 this%nodeulist(nnode) = n
381 end if
382 end do
383 this%ctx%nbound = nnode
384 this%nodeulist_set = .true.
385 end if
386 deallocate (nodes)
387 this%aux_reads(iaux) = merge(rs_netcdf, rs_values, netcdf)
388 case default
389 errmsg = 'IDM unimplemented. GridArrayLoad::param_load &
390 &datatype='//trim(idt%datatype)
391 call store_error(errmsg)
392 call store_error_filename(this%input_name)
393 end select
394
395 ! if param is tracked set read state
396 iparam = ifind(this%param_names, idt%tagname)
397 if (iparam > 0) then
398 this%param_reads(iparam)%invar = merge(rs_netcdf, rs_values, netcdf)
399 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.
This module contains the SourceCommonModule.
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 248 of file Mf6FileGridArray.f90.

249 class(GridArrayLoadType), intent(inout) :: this
250 character(len=LENVARNAME) :: rs_varname
251 integer(I4B), pointer :: intvar
252 integer(I4B) :: iparam
253
254 ! set in-scope param names directly from context
255 this%param_names = this%ctx%params
256 this%nparam = size(this%ctx%params)
257 call this%ctx%allocate_params()
258 call this%ctx%check_developmode(this%input_name)
259 call this%ctx%allocate_arrays()
260
261 ! allocate and set param_reads pointer array
262 allocate (this%param_reads(this%nparam))
263
264 ! store read state variable pointers
265 do iparam = 1, this%nparam
266 ! allocate and store name of read state variable
267 rs_varname = this%ctx%rsv_alloc(this%param_names(iparam))
268 call mem_setptr(intvar, rs_varname, this%mf6_input%mempath)
269 this%param_reads(iparam)%invar => intvar
270 this%param_reads(iparam)%invar = rs_none
271 end do
272
273 ! read state of each auxiliary variable
274 call mem_allocate(this%aux_reads, this%ctx%naux, 'INAUXVARS', &
275 this%mf6_input%mempath)
276 this%aux_reads = rs_none

◆ reset()

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

Definition at line 234 of file Mf6FileGridArray.f90.

235 class(GridArrayLoadType), intent(inout) :: this
236 integer(I4B) :: n
237
238 this%ctx%nbound = 0
239 this%nodeulist_set = .false.
240
241 do n = 1, this%nparam
242 ! reset read state
243 this%param_reads(n)%invar = rs_none
244 end do
245 this%aux_reads = rs_none

◆ rp()

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

Definition at line 107 of file Mf6FileGridArray.f90.

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

◆ set_active()

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

Cells with IDOMAIN less than one are not boundaries. All cells are active if IDOMAIN is not given.

Definition at line 182 of file Mf6FileGridArray.f90.

187 class(GridArrayLoadType), intent(inout) :: this
188 character(len=LENMEMPATH) :: model_mempath, dis_mempath
189 integer(I4B), pointer :: disenum
190 integer(I4B), dimension(:), pointer, contiguous :: int1d
191 integer(I4B), dimension(:, :), pointer, contiguous :: int2d
192 integer(I4B), dimension(:, :, :), pointer, contiguous :: int3d
193 integer(I4B) :: isize
194
195 allocate (this%active(this%ctx%nodes))
196 this%active = .true.
197
198 ! set discretization input mempath
199 model_mempath = create_mem_path(component=this%mf6_input%component_name, &
200 context=idm_context)
201 call mem_setptr(disenum, 'DISENUM', model_mempath)
202 select case (disenum)
203 case (dis)
204 dis_mempath = create_mem_path(this%mf6_input%component_name, 'DIS', &
206 case (disv)
207 dis_mempath = create_mem_path(this%mf6_input%component_name, 'DISV', &
209 case (disu)
210 dis_mempath = create_mem_path(this%mf6_input%component_name, 'DISU', &
212 case default
213 return
214 end select
215
216 ! IDOMAIN is optional; read before the discretization package
217 ! releases its input
218 call get_isize('IDOMAIN', dis_mempath, isize)
219 if (isize /= this%ctx%nodes) return
220
221 select case (disenum)
222 case (dis)
223 call mem_setptr(int3d, 'IDOMAIN', dis_mempath)
224 this%active = reshape(int3d, [this%ctx%nodes]) > 0
225 case (disv)
226 call mem_setptr(int2d, 'IDOMAIN', dis_mempath)
227 this%active = reshape(int2d, [this%ctx%nodes]) > 0
228 case (disu)
229 call mem_setptr(int1d, 'IDOMAIN', dis_mempath)
230 this%active = int1d > 0
231 end select
@ disu
DISV6 discretization.
@ dis
DIS6 discretization.
@ disv
DISU6 discretization.
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition Constants.f90:27
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains simulation variables.
character(len=linelength) idm_context
Here is the call graph for this function:

◆ ts_advance()

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

Definition at line 103 of file Mf6FileGridArray.f90.

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