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

This module contains the ListLoadModule. More...

Data Types

type  listloadtype
 list input loader for dynamic packages. 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 reset (this)
 
subroutine rp (this, parser)
 
subroutine destroy (this)
 
subroutine create_structarray (this)
 
subroutine apply_persistent_settings (this)
 Resolve this period's rows for an advanced package's TS-capable fields into their permanent, feature-indexed backing arrays. More...
 

Detailed Description

This module contains the routines for reading period block list based input.

Function/Subroutine Documentation

◆ ainit()

subroutine listloadmodule::ainit ( class(listloadtype), 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 51 of file Mf6FileList.f90.

53  use inputoutputmodule, only: getunit
57  class(ListLoadType), intent(inout) :: this
58  type(ModflowInputType), intent(in) :: mf6_input
59  character(len=*), intent(in) :: component_name
60  character(len=*), intent(in) :: component_input_name
61  character(len=*), intent(in) :: input_name
62  integer(I4B), intent(in) :: iperblock
63  type(BlockParserType), pointer, intent(inout) :: parser
64  integer(I4B), intent(in) :: iout
65  type(CharacterStringType), dimension(:), pointer, contiguous :: ts_fnames
66  character(len=LINELENGTH) :: fname
67  integer(I4B) :: ts6_size, n
68 
69  ! init loader
70  call this%DynamicPkgLoadType%init(mf6_input, component_name, &
71  component_input_name, input_name, &
72  iperblock, iout)
73  ! initialize scalars
74  this%ts_active = .false.
75 
76  ! create tsmanager
77  allocate (this%tsmanager)
78  call tsmanager_cr(this%tsmanager, iout)
79 
80  ! load static input (TS6_FILENAME tag sets static_loader%ts_active)
81  call this%static_loader%load(parser, mf6_input, this%nc_vars, &
82  this%input_name, iout)
83 
84  ! if TS files were declared, add them to our tsmanager now
85  if (this%static_loader%ts_active) then
86  this%ts_active = .true.
87  call get_isize('TS6_FILENAME', mf6_input%mempath, ts6_size)
88  if (ts6_size > 0) then
89  call mem_setptr(ts_fnames, 'TS6_FILENAME', mf6_input%mempath)
90  do n = 1, size(ts_fnames)
91  fname = ts_fnames(n)
92  call this%tsmanager%add_tsfile(fname, getunit())
93  end do
94  end if
95  end if
96 
97  ! initialize package input context
98  call this%ctx%init(mf6_input)
99 
100  ! set in-scope param names directly from context
101  this%param_names = this%ctx%params
102  this%nparam = size(this%ctx%params)
103  call this%ctx%check_developmode(this%input_name)
104 
105  ! construct and set up the struct array object
106  call this%create_structarray()
107 
108  ! finalize input context setup
109  call this%ctx%allocate_arrays()
This module contains block parser methods.
Definition: BlockParser.f90:7
integer(i4b) function, public getunit()
Get a free unit number.
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
Here is the call graph for this function:

◆ apply_persistent_settings()

subroutine listloadmodule::apply_persistent_settings ( class(listloadtype), intent(inout)  this)

Every row's IFNO is validated against maxbound before use.

Definition at line 284 of file Mf6FileList.f90.

287  use simvariablesmodule, only: errmsg
288  class(ListLoadType), intent(inout) :: this
289  type(InputParamDefinitionType), pointer :: idt
290  integer(I4B), dimension(:), pointer, contiguous :: ifno
291  integer(I4B), dimension(:), allocatable :: row_ifno
292  real(DP), dimension(:), pointer, contiguous :: featarr
293  real(DP), dimension(:, :), pointer, contiguous :: featarr2d
294  integer(I4B), pointer :: naux
295  integer(I4B) :: icol, n, i, j, nfeatures
296 
297  if (.not. this%ctx%is_advanced) return
298 
299  ! leading column's own name/tag (e.g. IFNO), resolved from the
300  ! recarray definition rather than hardcoded
301  idt => get_param_definition_type(this%mf6_input%param_dfns, &
302  this%mf6_input%component_type, &
303  this%mf6_input%subcomponent_type, &
304  'PERIOD', this%param_names(1), &
305  this%input_name)
306  call mem_setptr(ifno, trim(idt%mf6varname), this%mf6_input%mempath)
307 
308  nfeatures = this%ctx%maxbound
309  allocate (row_ifno(this%ctx%nbound))
310  do n = 1, this%ctx%nbound
311  if (ifno(n) >= 1 .and. ifno(n) <= nfeatures) then
312  row_ifno(n) = ifno(n)
313  else
314  write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,a)') &
315  trim(idt%tagname), ifno(n), 'on row', n, &
316  'must be greater than 0 and less than or equal to', nfeatures, '.'
317  call store_error(errmsg)
318  row_ifno(n) = 0
319  end if
320  end do
321 
322  if (count_errors() > 0) then
323  call store_error_filename(this%input_name)
324  end if
325 
326  do icol = 1, this%nparam
327  idt => get_param_definition_type(this%mf6_input%param_dfns, &
328  this%mf6_input%component_type, &
329  this%mf6_input%subcomponent_type, &
330  'PERIOD', &
331  this%param_names(icol), this%input_name)
332  if (idt%datatype == 'DOUBLE' .and. idt%timeseries) then
333  call mem_setptr(featarr, trim(idt%mf6varname), this%mf6_input%mempath)
334  if (this%ts_active) then
335  call this%structarray%ts_update_indexed( &
336  icol, this%tsmanager, this%mf6_input%subcomponent_name, &
337  this%ctx%iprpak, this%ctx%nbound, row_ifno, &
338  varname=trim(idt%tagname), featarr=featarr)
339  else
340  do n = 1, this%ctx%nbound
341  i = row_ifno(n)
342  if (i < 1) cycle
343  if (this%structarray%struct_vectors(icol)%dbl1d(n) == dnodata) cycle
344  featarr(i) = this%structarray%struct_vectors(icol)%dbl1d(n)
345  end do
346  end if
347  else if (idt%datatype == 'DOUBLE1D' .and. idt%timeseries) then
348  call mem_setptr(featarr2d, trim(idt%tagname)//'VAR', &
349  this%mf6_input%mempath)
350  if (this%ts_active) then
351  call this%structarray%ts_update_adv( &
352  icol, this%tsmanager, this%mf6_input%subcomponent_name, &
353  this%ctx%iprpak, this%ctx%nbound, row_ifno, &
354  auxname_cst=this%ctx%auxname_cst, featarr2d=featarr2d)
355  else
356  call mem_setptr(naux, trim(idt%shape), this%mf6_input%mempath)
357  do n = 1, this%ctx%nbound
358  i = row_ifno(n)
359  if (i < 1) cycle
360  do j = 1, naux
361  if (this%structarray%struct_vectors(icol)%dbl2d(j, n) == dnodata) &
362  cycle
363  featarr2d(j, i) = &
364  this%structarray%struct_vectors(icol)%dbl2d(j, n)
365  end do
366  end do
367  end if
368  end if
369  end do
370  deallocate (row_ifno)
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 simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
integer(i4b) function, public count_errors()
Return number of errors.
Definition: Sim.f90:59
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition: Sim.f90:204
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=maxcharlen) errmsg
error message string
Here is the call graph for this function:

◆ create_structarray()

subroutine listloadmodule::create_structarray ( class(listloadtype), intent(inout)  this)
private

Definition at line 223 of file Mf6FileList.f90.

226  class(ListLoadType), intent(inout) :: this
227  type(InputParamDefinitionType), pointer :: idt
228  real(DP), dimension(:), pointer, contiguous :: featarr
229  real(DP), dimension(:, :), pointer, contiguous :: featarr2d
230  integer(I4B), pointer :: naux
231  integer(I4B) :: icol, isize
232 
233  ! construct and set up the struct array object
234  this%structarray => constructstructarray(this%mf6_input, this%nparam, &
235  this%ctx%maxbound, 0, &
236  this%mf6_input%mempath, &
237  this%mf6_input%component_mempath)
238  ! set up struct array
239  do icol = 1, this%nparam
240  idt => get_param_definition_type(this%mf6_input%param_dfns, &
241  this%mf6_input%component_type, &
242  this%mf6_input%subcomponent_type, &
243  'PERIOD', &
244  this%param_names(icol), this%input_name)
245  ! persistent array allocated under mf6varname; raw column below
246  ! uses IDM's derived input name instead
247  if (this%ctx%is_advanced .and. idt%datatype == 'DOUBLE' .and. &
248  idt%timeseries) then
249  call get_isize(trim(idt%mf6varname), this%mf6_input%mempath, isize)
250  if (isize <= 0) then
251  call mem_allocate(featarr, this%ctx%maxbound, trim(idt%mf6varname), &
252  this%mf6_input%mempath)
253  featarr = dzero
254  end if
255  else if (this%ctx%is_advanced .and. idt%datatype == 'DOUBLE1D' .and. &
256  idt%timeseries) then
257  ! AUX is NAUX-gated, so its bare tag can't be reclaimed the
258  ! same way; it keeps its own synthetic tag
259  call get_isize(trim(idt%tagname)//'VAR', this%mf6_input%mempath, &
260  isize)
261  if (isize <= 0) then
262  call mem_setptr(naux, trim(idt%shape), this%mf6_input%mempath)
263  call mem_allocate(featarr2d, naux, this%ctx%maxbound, &
264  trim(idt%tagname)//'VAR', this%mf6_input%mempath)
265  featarr2d = dzero
266  end if
267  end if
268  ! allocate variable in memory manager
269  if (this%ctx%is_advanced .and. idt%datatype == 'DOUBLE' .and. &
270  idt%timeseries) then
271  call this%structarray%mem_create_vector(icol, idt, &
272  varname=idm_input_varname(idt))
273  else
274  call this%structarray%mem_create_vector(icol, idt)
275  end if
276  end do
Input definition module.
Input parameter definition. Describes an input parameter.
Here is the call graph for this function:

◆ destroy()

subroutine listloadmodule::destroy ( class(listloadtype), intent(inout)  this)

Definition at line 207 of file Mf6FileList.f90.

208  class(ListLoadType), intent(inout) :: this
209  !
210  ! clean up saved static structarrays
211  call this%static_loader%cleanup()
212  !
213  ! deallocate tsmanager
214  call this%tsmanager%da()
215  deallocate (this%tsmanager)
216  nullify (this%tsmanager)
217  !
218  ! deallocate StructArray
219  call destructstructarray(this%structarray)
220  call this%ctx%destroy()
Here is the call graph for this function:

◆ df()

subroutine listloadmodule::df ( class(listloadtype), intent(inout)  this)

Definition at line 112 of file Mf6FileList.f90.

114  class(ListLoadType), intent(inout) :: this
115  type(StructArrayType), pointer :: sa
116  integer(I4B) :: n
117  ! define tsmanager (TDIS is now available)
118  call this%tsmanager%tsmanager_df()
119  ! link static TS strlocs; preserve for re-registration after reset()
120  do n = 1, this%static_loader%ts_sa_count()
121  sa => this%static_loader%get_ts_sa(n)
122  if (associated(sa)) then
123  call sa%ts_update(this%tsmanager, &
124  this%mf6_input%subcomponent_name, &
125  this%ctx%iprpak, this%input_name, &
126  this%ctx%auxname_cst, &
127  clear_strlocs=.false.)
128  end if
129  end do
This module contains the StructArrayModule.
Definition: StructArray.f90:8
type for structured array
Definition: StructArray.f90:47

◆ reset()

subroutine listloadmodule::reset ( class(listloadtype), intent(inout)  this)
private

Definition at line 138 of file Mf6FileList.f90.

140  class(ListLoadType), intent(inout) :: this
141  type(StructArrayType), pointer :: sa
142  integer(I4B) :: n
143  ! clear TS links, unless persistent (unmentioned rows keep their link)
144  if (.not. this%ctx%is_advanced) then
145  call this%tsmanager%reset(this%mf6_input%subcomponent_name)
146  end if
147  ! re-register static TS links (strlocs preserved in df)
148  if (this%ts_active) then
149  do n = 1, this%static_loader%ts_sa_count()
150  sa => this%static_loader%get_ts_sa(n)
151  if (associated(sa)) then
152  call sa%ts_update(this%tsmanager, &
153  this%mf6_input%subcomponent_name, &
154  this%ctx%iprpak, this%input_name, &
155  this%ctx%auxname_cst, &
156  clear_strlocs=.false.)
157  end if
158  end do
159  end if

◆ rp()

subroutine listloadmodule::rp ( class(listloadtype), intent(inout)  this,
type(blockparsertype), intent(inout), pointer  parser 
)

Definition at line 162 of file Mf6FileList.f90.

167  class(ListLoadType), intent(inout) :: this
168  type(BlockParserType), pointer, intent(inout) :: parser
169  integer(I4B) :: ibinary
170  integer(I4B) :: oc_inunit
171 
172  call this%reset()
173  ibinary = read_control_record(parser, oc_inunit, this%iout)
174 
175  ! log lst file header
176  call idm_log_header(this%mf6_input%component_name, &
177  this%mf6_input%subcomponent_name, this%iout)
178 
179  if (ibinary == 1) then
180  this%ctx%nbound = &
181  this%structarray%read_from_binary(oc_inunit, this%iout)
182  call parser%terminateblock()
183  close (oc_inunit)
184  else
185  this%ctx%nbound = &
186  this%structarray%read_from_parser(parser, this%ts_active, this%iout, &
187  this%input_name)
188  end if
189 
190  ! must run before ts_update below, so AUX's ts_strlocs are claimed
191  ! by ts_update_adv first, not consumed into the transient array
192  call this%apply_persistent_settings()
193 
194  ! update ts links for all other columns
195  if (this%ts_active) then
196  call this%structarray%ts_update(this%tsmanager, &
197  this%mf6_input%subcomponent_name, &
198  this%ctx%iprpak, this%input_name, &
199  this%ctx%auxname_cst)
200  end if
201 
202  ! close logging statement
203  call idm_log_close(this%mf6_input%component_name, &
204  this%mf6_input%subcomponent_name, this%iout)
This module contains the Input Data Model Logger Module.
Definition: IdmLogger.f90:7
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
This module contains the LoadMf6FileModule.
Definition: LoadMf6File.f90:8
integer(i4b) function, public read_control_record(parser, oc_inunit, iout)
This module contains the StructVectorModule.
Definition: StructVector.f90:7
derived type for generic vector
Here is the call graph for this function:

◆ ts_advance()

subroutine listloadmodule::ts_advance ( class(listloadtype), intent(inout)  this)

Definition at line 132 of file Mf6FileList.f90.

133  class(ListLoadType), intent(inout) :: this
134  ! advance timeseries
135  call this%tsmanager%ad()