MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
mf6filegridinputmodule Module Reference

This module contains the Mf6FileGridInputModule. More...

Data Types

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

Functions/Subroutines

subroutine bndgrid_init (this, mf6_input, component_name, component_input_name, input_name, iperblock, parser, iout)
 
subroutine bndgrid_df (this)
 
subroutine bndgrid_ad (this)
 
subroutine bndgrid_rp (this, parser)
 
subroutine bndgrid_destroy (this)
 
subroutine bndgrid_reset (this)
 
subroutine init_charstr1d (this, varname, input_name)
 
subroutine bndgrid_params_alloc (this)
 
subroutine bndgrid_param_load (this, parser, idt, mempath, netcdf, iaux)
 
subroutine bndgrid_tas_arrays_alloc (this)
 
subroutine bndgrid_tas_links_create (this, inunit)
 

Detailed Description

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

Function/Subroutine Documentation

◆ bndgrid_ad()

subroutine mf6filegridinputmodule::bndgrid_ad ( class(boundgridinputtype), intent(inout)  this)
private
Parameters
[in,out]thisMf6FileGridInputType

Definition at line 134 of file Mf6FileGridInput.f90.

135  ! -- modules
136  class(BoundGridInputType), intent(inout) :: this !< Mf6FileGridInputType
137  !
138  call this%tasmanager%ad()
139  !
140  ! -- return
141  return

◆ bndgrid_destroy()

subroutine mf6filegridinputmodule::bndgrid_destroy ( class(boundgridinputtype), intent(inout)  this)
Parameters
[in,out]thisMf6FileGridInputType

Definition at line 255 of file Mf6FileGridInput.f90.

256  ! -- modules
257  class(BoundGridInputType), intent(inout) :: this !< Mf6FileGridInputType
258  !
259  deallocate (this%tasmanager)
260  !
261  ! -- return
262  return

◆ bndgrid_df()

subroutine mf6filegridinputmodule::bndgrid_df ( class(boundgridinputtype), intent(inout)  this)
Parameters
[in,out]thisMf6FileGridInputType

Definition at line 123 of file Mf6FileGridInput.f90.

124  ! -- modules
125  ! -- dummy
126  class(BoundGridInputType), intent(inout) :: this !< Mf6FileGridInputType
127  !
128  call this%tasmanager%tasmanager_df()
129  !
130  ! -- return
131  return

◆ bndgrid_init()

subroutine mf6filegridinputmodule::bndgrid_init ( class(boundgridinputtype), 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 55 of file Mf6FileGridInput.f90.

61  class(BoundGridInputType), intent(inout) :: this
62  type(ModflowInputType), intent(in) :: mf6_input
63  character(len=*), intent(in) :: component_name
64  character(len=*), intent(in) :: component_input_name
65  character(len=*), intent(in) :: input_name
66  integer(I4B), intent(in) :: iperblock
67  type(BlockParserType), pointer, intent(inout) :: parser
68  integer(I4B), intent(in) :: iout
69  type(LoadMf6FileType) :: loader
70  type(CharacterStringType), dimension(:), pointer, &
71  contiguous :: tas_fnames
72  character(len=LINELENGTH) :: fname
73  integer(I4B) :: tas6_size, n
74  !
75  ! -- initialize base type
76  call this%DynamicPkgLoadType%init(mf6_input, component_name, &
77  component_input_name, &
78  input_name, iperblock, iout)
79  ! -- initialize
80  nullify (this%aux_tasnames)
81  nullify (this%param_tasnames)
82  this%tas_active = 0
83  this%iout = iout
84  !
85  ! -- load static input
86  call loader%load(parser, mf6_input, this%nc_vars, this%input_name, iout)
87  !
88  ! -- create tasmanager
89  allocate (this%tasmanager)
90  call tasmanager_cr(this%tasmanager, modelname=this%mf6_input%component_name, &
91  iout=this%iout)
92  !
93  ! -- determine if TAS6 files were provided in OPTIONS block
94  call get_isize('TAS6_FILENAME', this%mf6_input%mempath, tas6_size)
95  !
96  if (tas6_size > 0) then
97  !
98  this%tas_active = 1
99  !
100  call mem_setptr(tas_fnames, 'TAS6_FILENAME', this%mf6_input%mempath)
101  !
102  ! -- add files to tasmanager
103  do n = 1, size(tas_fnames)
104  fname = tas_fnames(n)
105  call this%tasmanager%add_tasfile(fname)
106  end do
107  !
108  end if
109  !
110  ! -- initialize input context memory
111  call this%bound_context%create(mf6_input, this%readasarrays)
112  !
113  ! -- allocate dfn params
114  call this%params_alloc()
115  !
116  ! -- allocate memory for storing TAS strings
117  call this%tas_arrays_alloc()
118  !
119  ! -- return
120  return
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:48
Here is the call graph for this function:

◆ bndgrid_param_load()

subroutine mf6filegridinputmodule::bndgrid_param_load ( class(boundgridinputtype), 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
Parameters
[in,out]thisBoundGridInputType

Definition at line 344 of file Mf6FileGridInput.f90.

345  ! -- modules
346  use tdismodule, only: kper
348  use arrayhandlersmodule, only: ifind
355  use idmloggermodule, only: idm_log_var
356  ! -- dummy
357  class(BoundGridInputType), intent(inout) :: this !< BoundGridInputType
358  type(BlockParserType), intent(in) :: parser
359  type(InputParamDefinitionType), intent(in) :: idt
360  character(len=*), intent(in) :: mempath
361  logical(LGP), intent(in) :: netcdf
362  integer(I4B), intent(in) :: iaux
363  ! -- local
364  integer(I4B), dimension(:), pointer, contiguous :: int1d
365  real(DP), dimension(:), pointer, contiguous :: dbl1d
366  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
367  integer(I4B) :: iparam, n
368  !
369  select case (idt%datatype)
370  case ('INTEGER1D')
371  !
372  call mem_setptr(int1d, idt%mf6varname, mempath)
373  if (netcdf) then
374  call netcdf_read_array(int1d, this%bound_context%mshape, idt, &
375  this%mf6_input, this%nc_vars, this%input_name, &
376  this%iout, kper)
377  else
378  call read_int1d(parser, int1d, idt%mf6varname)
379  end if
380  call idm_log_var(int1d, idt%tagname, mempath, this%iout)
381  !
382  case ('DOUBLE1D')
383  !
384  call mem_setptr(dbl1d, idt%mf6varname, mempath)
385  if (netcdf) then
386  call netcdf_read_array(dbl1d, this%bound_context%mshape, idt, &
387  this%mf6_input, this%nc_vars, this%input_name, &
388  this%iout, kper)
389  else
390  call read_dbl1d(parser, dbl1d, idt%mf6varname)
391  end if
392  call idm_log_var(dbl1d, idt%tagname, mempath, this%iout)
393  !
394  case ('DOUBLE2D')
395  !
396  call mem_setptr(dbl2d, idt%mf6varname, mempath)
397  allocate (dbl1d(this%bound_context%ncpl))
398  if (netcdf) then
399  call netcdf_read_array(dbl1d, this%bound_context%mshape, idt, &
400  this%mf6_input, this%nc_vars, this%input_name, &
401  this%iout, kper, iaux)
402  else
403  call read_dbl1d(parser, dbl1d, idt%mf6varname)
404  end if
405  do n = 1, this%bound_context%ncpl
406  dbl2d(iaux, n) = dbl1d(n)
407  end do
408  call idm_log_var(dbl1d, idt%tagname, mempath, this%iout)
409  deallocate (dbl1d)
410  !
411  case default
412  !
413  errmsg = 'IDM unimplemented. Mf6FileGridInput::param_load &
414  &datatype='//trim(idt%datatype)
415  call store_error(errmsg)
416  call store_error_filename(this%input_name)
417  !
418  end select
419  !
420  ! -- if param is tracked set read state
421  iparam = ifind(this%param_names, idt%tagname)
422  if (iparam > 0) then
423  this%param_reads(iparam)%invar = 1
424  end if
425  !
426  ! -- return
427  return
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename)
Return parameter definition.
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
This module contains the InputDefinitionModule.
subroutine, public read_int1d(parser, int1d, aname)
This module contains the LoadNCInputModule.
Definition: LoadNCInput.F90:7
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:23
Here is the call graph for this function:

◆ bndgrid_params_alloc()

subroutine mf6filegridinputmodule::bndgrid_params_alloc ( class(boundgridinputtype), intent(inout)  this)
Parameters
[in,out]thisBoundGridInputType

Definition at line 314 of file Mf6FileGridInput.f90.

315  ! -- modules
316  ! -- dummy
317  class(BoundGridInputType), intent(inout) :: this !< BoundGridInputType
318  character(len=LENVARNAME) :: rs_varname
319  integer(I4B), pointer :: intvar
320  integer(I4B) :: iparam
321  !
322  ! -- set in scope param names
323  call this%bound_context%bound_params(this%param_names, this%nparam, &
324  this%input_name)
325  !
326  call this%bound_context%allocate_arrays()
327  !
328  ! -- allocate and set param_reads pointer array
329  allocate (this%param_reads(this%nparam))
330  !
331  ! store read state variable pointers
332  do iparam = 1, this%nparam
333  ! -- allocate and store name of read state variable
334  rs_varname = this%bound_context%rsv_alloc(this%param_names(iparam))
335  call mem_setptr(intvar, rs_varname, this%mf6_input%mempath)
336  this%param_reads(iparam)%invar => intvar
337  this%param_reads(iparam)%invar = 0
338  end do
339  !
340  ! -- return
341  return

◆ bndgrid_reset()

subroutine mf6filegridinputmodule::bndgrid_reset ( class(boundgridinputtype), intent(inout)  this)
private
Parameters
[in,out]thisBoundGridInputType

Definition at line 265 of file Mf6FileGridInput.f90.

266  ! -- modules
267  class(BoundGridInputType), intent(inout) :: this !< BoundGridInputType
268  integer(I4B) :: n, m
269  !
270  if (this%tas_active /= 0) then
271  !
272  ! -- reset tasmanager
273  call this%tasmanager%reset(this%mf6_input%subcomponent_name)
274  !
275  ! -- reinitialize tas name arrays
276  call this%init_charstr1d('AUXTASNAME', this%input_name)
277  call this%init_charstr1d('PARAMTASNAME', this%input_name)
278  end if
279  !
280  do n = 1, this%nparam
281  ! -- reset read state
282  this%param_reads(n)%invar = 0
283  end do
284  !
285  ! -- explicitly reset auxvar array each period
286  do m = 1, this%bound_context%ncpl
287  do n = 1, this%bound_context%naux
288  this%bound_context%auxvar(n, m) = dzero
289  end do
290  end do
291  !
292  ! -- return
293  return

◆ bndgrid_rp()

subroutine mf6filegridinputmodule::bndgrid_rp ( class(boundgridinputtype), intent(inout)  this,
type(blockparsertype), intent(inout), pointer  parser 
)
private
Parameters
[in,out]thisMf6FileGridInputType

Definition at line 144 of file Mf6FileGridInput.f90.

145  ! -- modules
150  use arrayhandlersmodule, only: ifind
153  class(BoundGridInputType), intent(inout) :: this !< Mf6FileGridInputType
154  type(BlockParserType), pointer, intent(inout) :: parser
155  ! -- local
156  logical(LGP) :: endOfBlock, netcdf
157  character(len=LINELENGTH) :: keyword, param_tag
158  type(InputParamDefinitionType), pointer :: idt
159  integer(I4B) :: iaux, iparam
160  character(len=LENTIMESERIESNAME) :: tas_name
161  integer(I4B), dimension(:), pointer, contiguous :: int1d
162  !
163  ! -- reset for this period
164  call this%reset()
165  !
166  ! -- log lst file header
167  call idm_log_header(this%mf6_input%component_name, &
168  this%mf6_input%subcomponent_name, this%iout)
169  !
170  ! -- read array block
171  do
172  ! -- initialize
173  iaux = 0
174  netcdf = .false.
175  !
176  ! -- read next line
177  call parser%GetNextLine(endofblock)
178  if (endofblock) exit
179  !
180  ! -- read param_tag
181  call parser%GetStringCaps(param_tag)
182  !
183  ! -- is param tag an auxvar?
184  iaux = ifind_charstr(this%bound_context%auxname_cst, param_tag)
185  !
186  ! -- any auvxar corresponds to the definition tag 'AUX'
187  if (iaux > 0) param_tag = 'AUX'
188  !
189  ! -- set input definition
190  idt => get_param_definition_type(this%mf6_input%param_dfns, &
191  this%mf6_input%component_type, &
192  this%mf6_input%subcomponent_type, &
193  'PERIOD', param_tag, this%input_name)
194  !
195  ! -- look for TAS and NetCDF keywords
196  call parser%GetStringCaps(keyword)
197  !
198  if (keyword == 'TIMEARRAYSERIES') then
199  if (this%tas_active /= 0) then
200  !
201  call parser%GetStringCaps(tas_name)
202  !
203  if (param_tag == 'AUX') then
204  this%aux_tasnames(iaux) = tas_name
205  else
206  iparam = ifind(this%param_names, param_tag)
207  this%param_tasnames(iparam) = tas_name
208  this%param_reads(iparam)%invar = 2
209  end if
210  !
211  ! -- log variable
212  call idm_log_var(param_tag, this%mf6_input%mempath, this%iout, .true.)
213  !
214  ! -- cycle to next input param
215  cycle
216  else
217  ! TODO: throw error
218  end if
219  !
220  else if (keyword == 'NETCDF') then
221  netcdf = .true.
222  end if
223  !
224  ! -- read and load the parameter
225  call this%param_load(parser, idt, this%mf6_input%mempath, netcdf, iaux)
226  !
227  end do
228  !
229  ! -- check if layer index variable was read
230  ! TODO: assumes layer index variable is always in scope
231  if (this%param_reads(1)%invar == 0) then
232  ! -- set to default of 1 without updating invar
233  idt => get_param_definition_type(this%mf6_input%param_dfns, &
234  this%mf6_input%component_type, &
235  this%mf6_input%subcomponent_type, &
236  'PERIOD', this%param_names(1), &
237  this%input_name)
238  call mem_setptr(int1d, idt%mf6varname, this%mf6_input%mempath)
239  int1d = 1
240  end if
241  !
242  !
243  if (this%tas_active /= 0) then
244  call this%tas_links_create(parser%iuactive)
245  end if
246  !
247  ! -- log lst file header
248  call idm_log_close(this%mf6_input%component_name, &
249  this%mf6_input%subcomponent_name, this%iout)
250  !
251  ! -- return
252  return
subroutine, public idm_log_close(component, subcomponent, iout)
@ brief log the closing message
Definition: IdmLogger.f90:57
subroutine, public idm_log_header(component, subcomponent, iout)
@ brief log a header message
Definition: IdmLogger.f90:44
This module contains the SourceCommonModule.
Definition: SourceCommon.f90:7
integer(i4b) function, public ifind_charstr(array, str)
Here is the call graph for this function:

◆ bndgrid_tas_arrays_alloc()

subroutine mf6filegridinputmodule::bndgrid_tas_arrays_alloc ( class(boundgridinputtype), intent(inout)  this)
Parameters
[in,out]thisBoundGridInputType

Definition at line 430 of file Mf6FileGridInput.f90.

431  ! -- modules
433  class(BoundGridInputType), intent(inout) :: this !< BoundGridInputType
434  !
435  ! -- count params other than AUX
436  if (this%tas_active /= 0) then
437  !
438  call mem_allocate(this%aux_tasnames, lentimeseriesname, &
439  this%bound_context%naux, 'AUXTASNAME', &
440  this%mf6_input%mempath)
441  call mem_allocate(this%param_tasnames, lentimeseriesname, this%nparam, &
442  'PARAMTASNAME', this%mf6_input%mempath)
443  !
444  call this%init_charstr1d('AUXTASNAME', this%input_name)
445  call this%init_charstr1d('PARAMTASNAME', this%input_name)
446  !
447  else
448  !
449  call mem_allocate(this%aux_tasnames, lentimeseriesname, 0, &
450  'AUXTASNAME', this%mf6_input%mempath)
451  call mem_allocate(this%param_tasnames, lentimeseriesname, 0, &
452  'PARAMTASNAME', this%mf6_input%mempath)
453  !
454  end if
455  !
456  ! -- return
457  return

◆ bndgrid_tas_links_create()

subroutine mf6filegridinputmodule::bndgrid_tas_links_create ( class(boundgridinputtype), intent(inout)  this,
integer(i4b), intent(in)  inunit 
)
Parameters
[in,out]thisBoundGridInputType

Definition at line 461 of file Mf6FileGridInput.f90.

462  ! -- modules
465  ! -- dummy
466  class(BoundGridInputType), intent(inout) :: this !< BoundGridInputType
467  integer(I4B), intent(in) :: inunit
468  ! -- local
469  type(InputParamDefinitionType), pointer :: idt
470  ! -- non-contiguous because a slice of bound is passed
471  real(DP), dimension(:), pointer :: auxArrayPtr, bndArrayPtr
472  real(DP), dimension(:), pointer, contiguous :: bound
473  integer(I4B), dimension(:), pointer, contiguous :: nodelist
474  character(len=LENTIMESERIESNAME) :: tas_name
475  character(len=LENAUXNAME) :: aux_name
476  logical :: convertFlux
477  integer(I4B) :: n
478  !
479  ! -- initialize
480  nullify (auxarrayptr)
481  nullify (bndarrayptr)
482  nullify (nodelist)
483  convertflux = .false.
484  !
485  ! Create AUX Time Array Series links
486  do n = 1, this%bound_context%naux
487  tas_name = this%aux_tasnames(n)
488  !
489  if (tas_name /= '') then
490  ! -- set auxvar pointer
491  auxarrayptr => this%bound_context%auxvar(n, :)
492  aux_name = this%bound_context%auxname_cst(n)
493  call this%tasmanager%MakeTasLink(this%mf6_input%subcomponent_name, &
494  auxarrayptr, this%bound_context%iprpak, &
495  tas_name, aux_name, convertflux, &
496  nodelist, inunit)
497  end if
498  end do
499  !
500  ! Create BND Time Array Series links
501  do n = 1, this%nparam
502  ! -- assign param definition pointer
503  idt => get_param_definition_type(this%mf6_input%param_dfns, &
504  this%mf6_input%component_type, &
505  this%mf6_input%subcomponent_type, &
506  'PERIOD', this%param_names(n), &
507  this%input_name)
508  !
509  if (idt%timeseries) then
510  if (this%param_reads(n)%invar == 2) then
511  tas_name = this%param_tasnames(n)
512  call mem_setptr(bound, idt%mf6varname, this%mf6_input%mempath)
513  ! -- set bound pointer
514  bndarrayptr => bound(:)
515  call this%tasmanager%MakeTasLink(this%mf6_input%subcomponent_name, &
516  bndarrayptr, &
517  this%bound_context%iprpak, &
518  tas_name, idt%mf6varname, &
519  convertflux, nodelist, inunit)
520  end if
521  end if
522  end do
523  !
524  ! -- return
525  return
Here is the call graph for this function:

◆ init_charstr1d()

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

Definition at line 296 of file Mf6FileGridInput.f90.

297  ! -- modules
299  ! -- dummy
300  class(BoundGridInputType) :: this
301  character(len=*), intent(in) :: varname
302  character(len=*), intent(in) :: input_name
303  ! -- local
304  type(CharacterStringType), dimension(:), pointer, &
305  contiguous :: charstr1d
306  integer(I4B) :: n
307  !
308  call mem_setptr(charstr1d, varname, this%mf6_input%mempath)
309  do n = 1, size(charstr1d)
310  charstr1d(n) = ''
311  end do