MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
layerarrayloadmodule Module Reference

This module contains the LayerArrayLoadModule. More...

Data Types

type  layerarrayloadtype
 Ascii array layer 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 init_charstr1d (this, varname, input_name)
subroutine params_alloc (this)
subroutine param_load (this, parser, idt, mempath, netcdf, iaux)
subroutine tas_arrays_alloc (this)
subroutine tas_links_create (this, inunit)

Detailed Description

This module contains the routines for reading period block array based input that is associated with a layer and an layer index array, such as with the EVTA and RCHA packages.

Function/Subroutine Documentation

◆ ainit()

subroutine layerarrayloadmodule::ainit ( class(layerarrayloadtype), 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 58 of file Mf6FileLayerArray.f90.

65 class(LayerArrayLoadType), intent(inout) :: this
66 type(ModflowInputType), intent(in) :: mf6_input
67 character(len=*), intent(in) :: component_name
68 character(len=*), intent(in) :: component_input_name
69 character(len=*), intent(in) :: input_name
70 integer(I4B), intent(in) :: iperblock
71 type(BlockParserType), pointer, intent(inout) :: parser
72 integer(I4B), intent(in) :: iout
73 type(LoadMf6FileType) :: loader
74 type(CharacterStringType), dimension(:), pointer, &
75 contiguous :: tas_fnames
76 type(InputParamDefinitionType), pointer :: idt
77 integer(I4B), dimension(:), pointer, contiguous :: int1d
78 character(len=LINELENGTH) :: fname
79 integer(I4B) :: tas6_size, n
80
81 ! initialize base type
82 call this%DynamicPkgLoadType%init(mf6_input, component_name, &
83 component_input_name, &
84 input_name, iperblock, iout)
85 ! initialize
86 nullify (this%aux_tasnames)
87 nullify (this%param_tasnames)
88 this%tas_active = 0
89 this%iout = iout
90
91 ! load static input
92 call loader%load(parser, mf6_input, this%nc_vars, this%input_name, iout)
93
94 ! create tasmanager
95 allocate (this%tasmanager)
96 call tasmanager_cr(this%tasmanager, modelname=this%mf6_input%component_name, &
97 iout=this%iout)
98
99 ! determine if TAS6 files were provided in OPTIONS block
100 call get_isize('TAS6_FILENAME', this%mf6_input%mempath, tas6_size)
101 if (tas6_size > 0) then
102 this%tas_active = 1
103 call mem_setptr(tas_fnames, 'TAS6_FILENAME', this%mf6_input%mempath)
104 ! add files to tasmanager
105 do n = 1, size(tas_fnames)
106 fname = tas_fnames(n)
107 call this%tasmanager%add_tasfile(fname)
108 end do
109 end if
110
111 ! initialize input context memory
112 call this%ctx%init(mf6_input)
113
114 ! allocate dfn params
115 call this%params_alloc()
116
117 ! allocate memory for storing TAS strings
118 call this%tas_arrays_alloc()
119
120 ! layer index variable (e.g. IRCH, IEVT) is 1 until it is specified
121 if (this%param_names(1) == &
122 'I'//trim(this%mf6_input%subcomponent_type(1:3))) then
123 idt => get_param_definition_type(this%mf6_input%param_dfns, &
124 this%mf6_input%component_type, &
125 this%mf6_input%subcomponent_type, &
126 'PERIOD', this%param_names(1), &
127 this%input_name)
128 call mem_setptr(int1d, idt%mf6varname, this%mf6_input%mempath)
129 int1d = 1
130 end if
This module contains block parser methods.
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.
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 layerarrayloadmodule::destroy ( class(layerarrayloadtype), intent(inout) this)
private

Definition at line 226 of file Mf6FileLayerArray.f90.

227 class(LayerArrayLoadType), intent(inout) :: this
228 !
229 ! nullify ctx pointers (including mshape) before deallocate
230 call this%ctx%destroy()
231 !
232 ! deallocate tasmanager
233 call this%tasmanager%da()
234 deallocate (this%tasmanager)
235 nullify (this%tasmanager)

◆ df()

subroutine layerarrayloadmodule::df ( class(layerarrayloadtype), intent(inout) this)
private

Definition at line 133 of file Mf6FileLayerArray.f90.

134 class(LayerArrayLoadType), intent(inout) :: this
135 call this%tasmanager%tasmanager_df()

◆ init_charstr1d()

subroutine layerarrayloadmodule::init_charstr1d ( class(layerarrayloadtype) this,
character(len=*), intent(in) varname,
character(len=*), intent(in) input_name )
private

Definition at line 258 of file Mf6FileLayerArray.f90.

260 class(LayerArrayLoadType) :: this
261 character(len=*), intent(in) :: varname
262 character(len=*), intent(in) :: input_name
263 type(CharacterStringType), dimension(:), pointer, &
264 contiguous :: charstr1d
265 integer(I4B) :: n
266 call mem_setptr(charstr1d, varname, this%mf6_input%mempath)
267 do n = 1, size(charstr1d)
268 charstr1d(n) = ''
269 end do

◆ param_load()

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

Definition at line 303 of file Mf6FileLayerArray.f90.

304 use tdismodule, only: kper
306 use arrayhandlersmodule, only: ifind
314 class(LayerArrayLoadType), intent(inout) :: this
315 type(BlockParserType), intent(in) :: parser
316 type(InputParamDefinitionType), intent(in) :: idt
317 character(len=*), intent(in) :: mempath
318 logical(LGP), intent(in) :: netcdf
319 integer(I4B), intent(in) :: iaux
320 integer(I4B), dimension(:), pointer, contiguous :: int1d
321 real(DP), dimension(:), pointer, contiguous :: dbl1d
322 real(DP), dimension(:, :), pointer, contiguous :: dbl2d
323 integer(I4B) :: iparam, n
324
325 select case (idt%datatype)
326 case ('INTEGER1D')
327 call mem_setptr(int1d, idt%mf6varname, mempath)
328 if (netcdf) then
329 call netcdf_read_array(int1d, this%ctx%mshape, idt, &
330 this%mf6_input, this%nc_vars, this%input_name, &
331 this%iout, kper)
332 else
333 call read_int1d(parser, int1d, idt%mf6varname)
334 end if
335 call idm_log_var(int1d, idt%tagname, mempath, this%iout)
336 case ('DOUBLE1D')
337 call mem_setptr(dbl1d, idt%mf6varname, mempath)
338 if (netcdf) then
339 call netcdf_read_array(dbl1d, this%ctx%mshape, idt, &
340 this%mf6_input, this%nc_vars, this%input_name, &
341 this%iout, kper)
342 else
343 call read_dbl1d(parser, dbl1d, idt%mf6varname)
344 end if
345 call idm_log_var(dbl1d, idt%tagname, mempath, this%iout)
346 case ('DOUBLE2D')
347 call mem_setptr(dbl2d, idt%mf6varname, mempath)
348 allocate (dbl1d(this%ctx%ncpl))
349 if (netcdf) then
350 call netcdf_read_array(dbl1d, this%ctx%mshape, idt, &
351 this%mf6_input, this%nc_vars, this%input_name, &
352 this%iout, kper, iaux)
353 else
354 call read_dbl1d(parser, dbl1d, idt%mf6varname)
355 end if
356 do n = 1, this%ctx%ncpl
357 dbl2d(iaux, n) = dbl1d(n)
358 end do
359 call idm_log_var(dbl1d, idt%tagname, mempath, this%iout)
360 deallocate (dbl1d)
361 this%aux_reads(iaux) = merge(rs_netcdf, rs_values, netcdf)
362 case default
363 errmsg = 'IDM unimplemented. LayerArrayLoad::param_load &
364 &datatype='//trim(idt%datatype)
365 call store_error(errmsg)
366 call store_error_filename(this%input_name)
367 end select
368
369 ! if param is tracked set read state
370 iparam = ifind(this%param_names, idt%tagname)
371 if (iparam > 0) then
372 this%param_reads(iparam)%invar = merge(rs_netcdf, rs_values, netcdf)
373 end if
subroutine, public read_dbl1d(parser, dbl1d, aname)
subroutine, public read_dbl2d(parser, dbl2d, aname)
This module contains the Input Data Model Logger Module.
Definition IdmLogger.f90:7
Input definition module.
subroutine, public read_int1d(parser, int1d, aname)
This module contains the LoadNCInputModule.
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 layerarrayloadmodule::params_alloc ( class(layerarrayloadtype), intent(inout) this)
private

Definition at line 272 of file Mf6FileLayerArray.f90.

273 class(LayerArrayLoadType), intent(inout) :: this
274 character(len=LENVARNAME) :: rs_varname
275 integer(I4B), pointer :: intvar
276 integer(I4B) :: iparam
277
278 ! set in-scope param names directly from context
279 this%param_names = this%ctx%params
280 this%nparam = size(this%ctx%params)
281 call this%ctx%allocate_params()
282 call this%ctx%check_developmode(this%input_name)
283 call this%ctx%allocate_arrays()
284
285 ! allocate and set param_reads pointer array
286 allocate (this%param_reads(this%nparam))
287
288 ! store read state variable pointers
289 do iparam = 1, this%nparam
290 ! allocate and store name of read state variable
291 rs_varname = this%ctx%rsv_alloc(this%param_names(iparam))
292 call mem_setptr(intvar, rs_varname, this%mf6_input%mempath)
293 this%param_reads(iparam)%invar => intvar
294 this%param_reads(iparam)%invar = rs_none
295 end do
296
297 ! read state of each auxiliary variable
298 call mem_allocate(this%aux_reads, this%ctx%naux, 'INAUXVARS', &
299 this%mf6_input%mempath)
300 this%aux_reads = rs_none

◆ reset()

subroutine layerarrayloadmodule::reset ( class(layerarrayloadtype), intent(inout) this)
private

Definition at line 238 of file Mf6FileLayerArray.f90.

239 class(LayerArrayLoadType), intent(inout) :: this
240 integer(I4B) :: n
241
242 if (this%tas_active /= 0) then
243 ! reset tasmanager
244 call this%tasmanager%reset(this%mf6_input%subcomponent_name)
245 ! reinitialize tas name arrays
246 call this%init_charstr1d('AUXTASNAME', this%input_name)
247 call this%init_charstr1d('PARAMTASNAME', this%input_name)
248 end if
249
250 do n = 1, this%nparam
251 ! reset read state
252 this%param_reads(n)%invar = rs_none
253 end do
254 this%aux_reads = rs_none
255

◆ rp()

subroutine layerarrayloadmodule::rp ( class(layerarrayloadtype), intent(inout) this,
type(blockparsertype), intent(inout), pointer parser )
private

Definition at line 143 of file Mf6FileLayerArray.f90.

148 use arrayhandlersmodule, only: ifind
151 class(LayerArrayLoadType), intent(inout) :: this
152 type(BlockParserType), pointer, intent(inout) :: parser
153 logical(LGP) :: endOfBlock, netcdf
154 character(len=LINELENGTH) :: keyword, param_tag
155 type(InputParamDefinitionType), pointer :: idt
156 integer(I4B) :: iaux, iparam
157 character(len=LENTIMESERIESNAME) :: tas_name
158
159 ! reset for this period
160 call this%reset()
161
162 ! log lst file header
163 call idm_log_header(this%mf6_input%component_name, &
164 this%mf6_input%subcomponent_name, this%iout)
165
166 ! read array block
167 do
168 ! initialize
169 iaux = 0
170 netcdf = .false.
171
172 ! read next line
173 call parser%GetNextLine(endofblock)
174 if (endofblock) exit
175 ! read param_tag
176 call parser%GetStringCaps(param_tag)
177
178 ! is param tag an auxvar?
179 iaux = ifind_charstr(this%ctx%auxname_cst, param_tag)
180 ! any auvxar corresponds to the definition tag 'AUX'
181 if (iaux > 0) param_tag = 'AUX'
182
183 ! set input definition
184 idt => get_param_definition_type(this%mf6_input%param_dfns, &
185 this%mf6_input%component_type, &
186 this%mf6_input%subcomponent_type, &
187 'PERIOD', param_tag, this%input_name)
188 ! look for TAS and NetCDF keywords
189 call parser%GetStringCaps(keyword)
190 if (keyword == 'TIMEARRAYSERIES') then
191 if (this%tas_active /= 0) then
192 call parser%GetStringCaps(tas_name)
193 if (param_tag == 'AUX') then
194 this%aux_tasnames(iaux) = tas_name
195 this%aux_reads(iaux) = rs_series
196 else
197 iparam = ifind(this%param_names, param_tag)
198 this%param_tasnames(iparam) = tas_name
199 this%param_reads(iparam)%invar = rs_series
200 end if
201 ! log variable
202 call idm_log_var(param_tag, this%mf6_input%mempath, this%iout, .true., &
203 trim(tas_name))
204 ! cycle to next input param
205 cycle
206 else
207 ! TODO: throw error
208 end if
209 else if (keyword == 'NETCDF') then
210 netcdf = .true.
211 end if
212
213 ! read and load the parameter
214 call this%param_load(parser, idt, this%mf6_input%mempath, netcdf, iaux)
215 end do
216
217 if (this%tas_active /= 0) then
218 call this%tas_links_create(parser%iuactive)
219 end if
220
221 ! log lst file header
222 call idm_log_close(this%mf6_input%component_name, &
223 this%mf6_input%subcomponent_name, this%iout)
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
This module contains the SourceCommonModule.
integer(i4b) function, public ifind_charstr(array, str)
Here is the call graph for this function:

◆ tas_arrays_alloc()

subroutine layerarrayloadmodule::tas_arrays_alloc ( class(layerarrayloadtype), intent(inout) this)
private

Definition at line 376 of file Mf6FileLayerArray.f90.

378 class(LayerArrayLoadType), intent(inout) :: this
379
380 ! count params other than AUX
381 if (this%tas_active /= 0) then
382 call mem_allocate(this%aux_tasnames, lentimeseriesname, &
383 this%ctx%naux, 'AUXTASNAME', &
384 this%mf6_input%mempath)
385 call mem_allocate(this%param_tasnames, lentimeseriesname, this%nparam, &
386 'PARAMTASNAME', this%mf6_input%mempath)
387 call this%init_charstr1d('AUXTASNAME', this%input_name)
388 call this%init_charstr1d('PARAMTASNAME', this%input_name)
389 else
390 call mem_allocate(this%aux_tasnames, lentimeseriesname, 0, &
391 'AUXTASNAME', this%mf6_input%mempath)
392 call mem_allocate(this%param_tasnames, lentimeseriesname, 0, &
393 'PARAMTASNAME', this%mf6_input%mempath)
394 end if

◆ tas_links_create()

subroutine layerarrayloadmodule::tas_links_create ( class(layerarrayloadtype), intent(inout) this,
integer(i4b), intent(in) inunit )
private

Definition at line 398 of file Mf6FileLayerArray.f90.

401 class(LayerArrayLoadType), intent(inout) :: this
402 integer(I4B), intent(in) :: inunit
403 type(InputParamDefinitionType), pointer :: idt
404 ! non-contiguous because a slice of bound is passed
405 real(DP), dimension(:), pointer :: auxArrayPtr, bndArrayPtr
406 real(DP), dimension(:), pointer, contiguous :: bound
407 integer(I4B), dimension(:), pointer, contiguous :: nodelist
408 character(len=LENTIMESERIESNAME) :: tas_name
409 character(len=LENAUXNAME) :: aux_name
410 logical :: convertFlux
411 integer(I4B) :: n
412
413 ! initialize
414 nullify (auxarrayptr)
415 nullify (bndarrayptr)
416 nullify (nodelist)
417 convertflux = .false.
418
419 ! Create AUX Time Array Series links
420 do n = 1, this%ctx%naux
421 tas_name = this%aux_tasnames(n)
422 if (tas_name /= '') then
423 ! set auxvar pointer
424 auxarrayptr => this%ctx%auxvar(n, :)
425 aux_name = this%ctx%auxname_cst(n)
426 call this%tasmanager%MakeTasLink(this%mf6_input%subcomponent_name, &
427 auxarrayptr, this%ctx%iprpak, &
428 tas_name, aux_name, convertflux, &
429 nodelist, inunit)
430 end if
431 end do
432
433 ! Create BND Time Array Series links
434 do n = 1, this%nparam
435 ! assign param definition pointer
436 idt => get_param_definition_type(this%mf6_input%param_dfns, &
437 this%mf6_input%component_type, &
438 this%mf6_input%subcomponent_type, &
439 'PERIOD', this%param_names(n), &
440 this%input_name)
441 if (idt%timeseries) then
442 if (this%param_reads(n)%invar == rs_series) then
443 tas_name = this%param_tasnames(n)
444 call mem_setptr(bound, idt%mf6varname, this%mf6_input%mempath)
445 ! set bound pointer
446 bndarrayptr => bound(:)
447 call this%tasmanager%MakeTasLink(this%mf6_input%subcomponent_name, &
448 bndarrayptr, &
449 this%ctx%iprpak, &
450 tas_name, idt%mf6varname, &
451 convertflux, nodelist, inunit)
452 end if
453 end if
454 end do
Here is the call graph for this function:

◆ ts_advance()

subroutine layerarrayloadmodule::ts_advance ( class(layerarrayloadtype), intent(inout) this)
private

Definition at line 138 of file Mf6FileLayerArray.f90.

139 class(LayerArrayLoadType), intent(inout) :: this
140 call this%tasmanager%ad()