MODFLOW 6  version 6.8.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 204 of file Mf6FileGridArray.f90.

205  use tdismodule, only: kper
206  use constantsmodule, only: dnodata
207  use arrayhandlersmodule, only: ifind
213  use idmloggermodule, only: idm_log_var
214  class(GridArrayLoadType), intent(inout) :: this
215  type(BlockParserType), intent(in) :: parser
216  type(InputParamDefinitionType), intent(in) :: idt
217  character(len=*), intent(in) :: mempath
218  logical(LGP), intent(in) :: layered
219  logical(LGP), intent(in) :: netcdf
220  integer(I4B), intent(in) :: iaux
221  real(DP), dimension(:), pointer, contiguous :: dbl1d, nodes
222  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
223  integer(I4B), dimension(:), allocatable :: layer_shape
224  integer(I4B) :: iparam, n, nlay, nnode
225 
226  nnode = 0
227 
228  select case (idt%datatype)
229  case ('DOUBLE1D')
230  call mem_setptr(dbl1d, idt%mf6varname, mempath)
231  allocate (nodes(this%ctx%nodes))
232  if (netcdf) then
233  call netcdf_read_array(nodes, this%ctx%mshape, idt, &
234  this%mf6_input, this%nc_vars, this%input_name, &
235  this%iout, kper)
236  else if (layered) then
237  call get_layered_shape(this%ctx%mshape, nlay, layer_shape)
238  call read_dbl1d_layered(parser, nodes, idt%mf6varname, nlay, layer_shape)
239  else
240  call read_dbl1d(parser, nodes, idt%mf6varname)
241  end if
242 
243  call idm_log_var(nodes, idt%tagname, mempath, this%iout)
244 
245  if (this%ctx%nbound > 0) then
246  ! nodeulist already established: extract values at known positions
247  do n = 1, this%ctx%nbound
248  dbl1d(n) = nodes(this%nodeulist(n))
249  end do
250  else
251  ! first array: filter by DNODATA to establish nodeulist and nbound
252  do n = 1, this%ctx%nodes
253  if (nodes(n) /= dnodata) then
254  nnode = nnode + 1
255  dbl1d(nnode) = nodes(n)
256  this%nodeulist(nnode) = n
257  end if
258  end do
259  this%ctx%nbound = nnode
260  end if
261  deallocate (nodes)
262  case ('DOUBLE2D')
263  call mem_setptr(dbl2d, idt%mf6varname, mempath)
264  allocate (nodes(this%ctx%nodes))
265 
266  if (netcdf) then
267  call netcdf_read_array(nodes, this%ctx%mshape, idt, &
268  this%mf6_input, this%nc_vars, this%input_name, &
269  this%iout, kper, iaux)
270  else if (layered) then
271  call get_layered_shape(this%ctx%mshape, nlay, layer_shape)
272  call read_dbl1d_layered(parser, nodes, idt%mf6varname, nlay, layer_shape)
273  else
274  call read_dbl1d(parser, nodes, idt%mf6varname)
275  end if
276 
277  call idm_log_var(nodes, idt%tagname, mempath, this%iout)
278 
279  if (this%ctx%nbound > 0) then
280  ! nodeulist already established: extract values at known positions
281  do n = 1, this%ctx%nbound
282  dbl2d(iaux, n) = nodes(this%nodeulist(n))
283  end do
284  else
285  ! first array: filter by DNODATA to establish nodeulist and nbound
286  do n = 1, this%ctx%nodes
287  if (nodes(n) /= dnodata) then
288  nnode = nnode + 1
289  dbl2d(iaux, nnode) = nodes(n)
290  this%nodeulist(nnode) = n
291  end if
292  end do
293  this%ctx%nbound = nnode
294  end if
295  deallocate (nodes)
296  case default
297  errmsg = 'IDM unimplemented. GridArrayLoad::param_load &
298  &datatype='//trim(idt%datatype)
299  call store_error(errmsg)
300  call store_error_filename(this%input_name)
301  end select
302 
303  ! if param is tracked set read state
304  iparam = ifind(this%param_names, idt%tagname)
305  if (iparam > 0) then
306  this%param_reads(iparam)%invar = 1
307  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
187  call this%ctx%tags(this%param_names, this%nparam, this%input_name, &
188  create=.true.)
189  call this%ctx%allocate_arrays()
190 
191  ! allocate and set param_reads pointer array
192  allocate (this%param_reads(this%nparam))
193 
194  ! store read state variable pointers
195  do iparam = 1, this%nparam
196  ! allocate and store name of read state variable
197  rs_varname = this%ctx%rsv_alloc(this%param_names(iparam))
198  call mem_setptr(intvar, rs_varname, this%mf6_input%mempath)
199  this%param_reads(iparam)%invar => intvar
200  this%param_reads(iparam)%invar = 0
201  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