MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
idmmf6filemodule Module Reference

This module contains the IdmMf6FileModule. More...

Data Types

type  mf6filestaticpkgloadtype
 MF6File static loader type. More...
 
type  mf6filedynamicpkgloadtype
 MF6File dynamic loader type. More...
 

Functions/Subroutines

subroutine, public input_load (filename, mf6_input, component_filename, iout, nc_vars)
 input load for traditional mf6 simulation static input file More...
 
subroutine static_init (this, mf6_input, component_name, component_input_name, input_name)
 static loader init More...
 
class(dynamicpkgloadbasetype) function, pointer static_load (this, iout)
 load routine for static loader More...
 
subroutine static_destroy (this)
 static loader destroy More...
 
subroutine dynamic_init (this, mf6_input, component_name, component_input_name, input_name, iperblock, iout)
 dynamic loader init More...
 
subroutine dynamic_df (this)
 define routine for dynamic loader More...
 
subroutine dynamic_ad (this)
 advance routine for dynamic loader More...
 
subroutine dynamic_rp (this)
 read and prepare routine for dynamic loader More...
 
subroutine dynamic_read_ionper (this)
 dynamic loader read ionper of next period block More...
 
subroutine dynamic_create_loader (this)
 allocate a dynamic loader based on load context More...
 
subroutine dynamic_destroy (this)
 dynamic loader destroy More...
 
integer(i4b) function, public open_mf6file (filetype, filename, component_fname, iout)
 open a model package files More...
 

Detailed Description

This module contains high-level routines for loading MODFLOW 6 ASCII source input. This module implements the loader types that the IdmLoadModule creates and invokes. It also creates and manages dynamic ASCII input loaders for all supported types of MODFLOW 6 ASCII dynamic input.

Function/Subroutine Documentation

◆ dynamic_ad()

subroutine idmmf6filemodule::dynamic_ad ( class(mf6filedynamicpkgloadtype), intent(inout)  this)
private

Definition at line 199 of file IdmMf6File.f90.

200  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
201  ! invoke loader advance
202  call this%rp_loader%ad()

◆ dynamic_create_loader()

subroutine idmmf6filemodule::dynamic_create_loader ( class(mf6filedynamicpkgloadtype), intent(inout)  this)

Definition at line 270 of file IdmMf6File.f90.

274  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
275  class(BoundListInputType), pointer :: bndlist_loader
276  class(BoundGridInputType), pointer :: bndgrid_loader
277  class(StoInputType), pointer :: sto_loader
278 
279  ! allocate and set loader
280  if (this%mf6_input%subcomponent_type == 'STO') then
281  allocate (sto_loader)
282  this%rp_loader => sto_loader
283  else if (this%readasarrays) then
284  allocate (bndgrid_loader)
285  this%rp_loader => bndgrid_loader
286  else
287  allocate (bndlist_loader)
288  this%rp_loader => bndlist_loader
289  end if
290 
291  ! set nc_vars pointer
292  this%rp_loader%nc_vars => this%nc_vars
293 
294  ! initialize loader
295  call this%rp_loader%ainit(this%mf6_input, &
296  this%component_name, &
297  this%component_input_name, &
298  this%input_name, &
299  this%iperblock, &
300  this%parser, &
301  this%iout)
This module contains the Mf6FileGridInputModule.
This module contains the Mf6FileListInputModule.
This module contains the Mf6FileStoInputModule.
Ascii grid based dynamic loader type.

◆ dynamic_destroy()

subroutine idmmf6filemodule::dynamic_destroy ( class(mf6filedynamicpkgloadtype), intent(inout)  this)

Definition at line 306 of file IdmMf6File.f90.

308  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
309 
310  ! deallocate scalars
311  call mem_deallocate(this%iper)
312  call mem_deallocate(this%ionper)
313 
314  ! deallocate loader
315  nullify (this%rp_loader%nc_vars)
316  call this%rp_loader%destroy()
317  deallocate (this%rp_loader)
318 
319  ! deallocate parser
320  call this%parser%clear()
321  deallocate (this%parser)
322 
323  ! deallocate input context
324  call this%DynamicPkgLoadType%destroy()

◆ dynamic_df()

subroutine idmmf6filemodule::dynamic_df ( class(mf6filedynamicpkgloadtype), intent(inout)  this)

Definition at line 189 of file IdmMf6File.f90.

190  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
191  ! invoke loader define
192  call this%rp_loader%df()
193  ! read first ionper
194  call this%read_ionper()

◆ dynamic_init()

subroutine idmmf6filemodule::dynamic_init ( class(mf6filedynamicpkgloadtype), 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,
integer(i4b), intent(in)  iout 
)
private

Definition at line 149 of file IdmMf6File.f90.

154  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
155  type(ModflowInputType), intent(in) :: mf6_input
156  character(len=*), intent(in) :: component_name
157  character(len=*), intent(in) :: component_input_name
158  character(len=*), intent(in) :: input_name
159  integer(I4B), intent(in) :: iperblock
160  integer(I4B), intent(in) :: iout
161  integer(I4B) :: inunit
162 
163  ! initialize base loader
164  call this%DynamicPkgLoadType%init(mf6_input, component_name, &
165  component_input_name, input_name, &
166  iperblock, iout)
167  ! allocate scalars
168  call mem_allocate(this%iper, 'IPER', mf6_input%mempath)
169  call mem_allocate(this%ionper, 'IONPER', mf6_input%mempath)
170 
171  ! initialize
172  this%iper = 0
173  this%ionper = 0
174 
175  ! open input file
176  inunit = open_mf6file(mf6_input%pkgtype, input_name, &
177  component_input_name, iout)
178 
179  ! allocate and initialize parser
180  allocate (this%parser)
181  call this%parser%Initialize(inunit, iout)
182 
183  ! allocate and initialize loader
184  call this%create_loader()
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.
This module contains the InputDefinitionModule.
Here is the call graph for this function:

◆ dynamic_read_ionper()

subroutine idmmf6filemodule::dynamic_read_ionper ( class(mf6filedynamicpkgloadtype), intent(inout)  this)

Definition at line 230 of file IdmMf6File.f90.

231  use tdismodule, only: kper, nper
232  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
233  character(len=LINELENGTH) :: line
234  logical(LGP) :: isblockfound
235  integer(I4B) :: ierr
236  character(len=*), parameter :: fmtblkerr = &
237  &"('Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
238 
239  call this%parser%GetBlock('PERIOD', isblockfound, ierr, &
240  supportopenclose=.true., &
241  blockrequired=.false.)
242  ! set first period block IPER
243  if (isblockfound) then
244  this%ionper = this%parser%GetInteger()
245  if (this%ionper <= this%iper) then
246  write (errmsg, '(a, i0, a, i0, a, i0, a)') &
247  'Error in stress period ', kper, &
248  '. Period numbers not increasing. Found ', this%ionper, &
249  ' but last period block was assigned ', this%iper, '.'
250  call store_error(errmsg)
251  call this%parser%StoreErrorUnit()
252  end if
253  else
254  ! PERIOD block not found
255  if (ierr < 0) then
256  ! End of file found; data applies for remainder of simulation.
257  this%ionper = nper + 1
258  else
259  ! Found invalid block
260  call this%parser%GetCurrentLine(line)
261  write (errmsg, fmtblkerr) adjustl(trim(line))
262  call store_error(errmsg)
263  call this%parser%StoreErrorUnit()
264  end if
265  end if
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:23
integer(i4b), pointer, public nper
number of stress period
Definition: tdis.f90:21
Here is the call graph for this function:

◆ dynamic_rp()

subroutine idmmf6filemodule::dynamic_rp ( class(mf6filedynamicpkgloadtype), intent(inout)  this)
private

Definition at line 207 of file IdmMf6File.f90.

208  use tdismodule, only: kper, nper
209  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
210 
211  ! check if ready to load
212  if (this%ionper /= kper) return
213 
214  ! dynamic load
215  call this%rp_loader%rp(this%parser)
216 
217  ! update loaded iper
218  this%iper = kper
219 
220  ! read next iper
221  if (kper < nper) then
222  call this%read_ionper()
223  else
224  this%ionper = nper + 1
225  end if

◆ input_load()

subroutine, public idmmf6filemodule::input_load ( character(len=*), intent(in)  filename,
type(modflowinputtype), intent(in)  mf6_input,
character(len=*), intent(in)  component_filename,
integer(i4b), intent(in)  iout,
type(ncpackagevarstype), intent(in), optional, pointer  nc_vars 
)
Parameters
[in]component_filenamecomponent (e.g. model) filename
[in]ioutunit number for output

Definition at line 58 of file IdmMf6File.f90.

60  character(len=*), intent(in) :: filename
61  type(ModflowInputType), intent(in) :: mf6_input
62  character(len=*), intent(in) :: component_filename !< component (e.g. model) filename
63  integer(I4B), intent(in) :: iout !< unit number for output
64  type(NCPackageVarsType), pointer, optional, intent(in) :: nc_vars
65  type(BlockParserType), allocatable, target :: parser !< block parser
66  type(NCPackageVarsType), pointer :: netcdf_vars
67  type(LoadMf6FileType) :: loader
68  integer(I4B) :: inunit
69 
70  if (present(nc_vars)) then
71  netcdf_vars => nc_vars
72  else
73  nullify (netcdf_vars)
74  end if
75 
76  ! open input file
77  inunit = open_mf6file(mf6_input%pkgtype, filename, component_filename, iout)
78 
79  ! allocate and initialize parser
80  allocate (parser)
81  call parser%Initialize(inunit, iout)
82 
83  ! invoke the load routine
84  call loader%load(parser, mf6_input, netcdf_vars, filename, iout)
85 
86  ! clear parser file handles
87  call parser%clear()
88 
89  ! cleanup
90  deallocate (parser)
This module contains the LoadMf6FileModule.
Definition: LoadMf6File.f90:8
Static parser based input loader.
Definition: LoadMf6File.f90:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_mf6file()

integer(i4b) function, public idmmf6filemodule::open_mf6file ( character(len=*), intent(in)  filetype,
character(len=*), intent(in)  filename,
character(len=*), intent(in)  component_fname,
integer(i4b), intent(in)  iout 
)

Definition at line 329 of file IdmMf6File.f90.

331  character(len=*), intent(in) :: filetype
332  character(len=*), intent(in) :: filename
333  character(len=*), intent(in) :: component_fname
334  integer(I4B), intent(in) :: iout
335  integer(I4B) :: inunit
336 
337  ! initialize
338  inunit = 0
339 
340  if (filename /= '') then
341  ! get unit number and open file
342  inunit = getunit()
343  call openfile(inunit, iout, trim(adjustl(filename)), filetype, &
344  'FORMATTED', 'SEQUENTIAL', 'OLD')
345  else
346  write (errmsg, '(a,a,a)') &
347  'File unspecified, cannot load model or package &
348  &type "', trim(filetype), '".'
349  call store_error(errmsg)
350  call store_error_filename(component_fname)
351  end if
integer(i4b) function, public getunit()
Get a free unit number.
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
Definition: InputOutput.f90:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ static_destroy()

subroutine idmmf6filemodule::static_destroy ( class(mf6filestaticpkgloadtype), intent(inout)  this)
private

Definition at line 141 of file IdmMf6File.f90.

142  class(Mf6FileStaticPkgLoadType), intent(inout) :: this
143  ! deallocate base type
144  call this%StaticPkgLoadType%destroy()

◆ static_init()

subroutine idmmf6filemodule::static_init ( class(mf6filestaticpkgloadtype), 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 
)

Definition at line 95 of file IdmMf6File.f90.

97  class(Mf6FileStaticPkgLoadType), intent(inout) :: this
98  type(ModflowInputType), intent(in) :: mf6_input
99  character(len=*), intent(in) :: component_name
100  character(len=*), intent(in) :: component_input_name
101  character(len=*), intent(in) :: input_name
102  ! initialize base type
103  call this%StaticPkgLoadType%init(mf6_input, component_name, &
104  component_input_name, input_name)

◆ static_load()

class(dynamicpkgloadbasetype) function, pointer idmmf6filemodule::static_load ( class(mf6filestaticpkgloadtype), intent(inout)  this,
integer(i4b), intent(in)  iout 
)
private

Definition at line 109 of file IdmMf6File.f90.

110  class(Mf6FileStaticPkgLoadType), intent(inout) :: this
111  integer(I4B), intent(in) :: iout
112  class(DynamicPkgLoadBaseType), pointer :: rp_loader
113  class(Mf6FileDynamicPkgLoadType), pointer :: mf6_loader
114 
115  ! initialize return pointer
116  nullify (rp_loader)
117 
118  ! load model package to input context
119  if (this%iperblock > 0) then
120  ! allocate dynamic loader
121  allocate (mf6_loader)
122  ! point to nc_vars structure
123  mf6_loader%nc_vars => this%nc_vars
124  ! nullify nc_vars pointer so it isn't deallocated
125  nullify (this%nc_vars)
126  ! initialize dynamic loader
127  call mf6_loader%init(this%mf6_input, this%component_name, &
128  this%component_input_name, this%input_name, &
129  this%iperblock, iout)
130  ! set return pointer to base dynamic loader
131  rp_loader => mf6_loader
132  else
133  ! load static input
134  call input_load(this%input_name, this%mf6_input, &
135  this%component_input_name, iout, this%nc_vars)
136  end if
Here is the call graph for this function: