MODFLOW 6  version 6.6.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 213 of file IdmMf6File.f90.

214  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
215  !
216  ! -- invoke loader advance
217  call this%rp_loader%ad()

◆ dynamic_create_loader()

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

Definition at line 296 of file IdmMf6File.f90.

300  ! -- dummy
301  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
302  class(BoundListInputType), pointer :: bndlist_loader
303  class(BoundGridInputType), pointer :: bndgrid_loader
304  class(StoInputType), pointer :: sto_loader
305  !
306  ! -- allocate and set loader
307  if (this%mf6_input%subcomponent_type == 'STO') then
308  allocate (sto_loader)
309  this%rp_loader => sto_loader
310  else if (this%readasarrays) then
311  allocate (bndgrid_loader)
312  this%rp_loader => bndgrid_loader
313  else
314  allocate (bndlist_loader)
315  this%rp_loader => bndlist_loader
316  end if
317  !
318  ! -- set nc_vars pointer
319  this%rp_loader%nc_vars => this%nc_vars
320  !
321  ! -- initialize loader
322  call this%rp_loader%ainit(this%mf6_input, &
323  this%component_name, &
324  this%component_input_name, &
325  this%input_name, &
326  this%iperblock, &
327  this%parser, &
328  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 333 of file IdmMf6File.f90.

335  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
336  !
337  ! -- deallocate scalars
338  call mem_deallocate(this%iper)
339  call mem_deallocate(this%ionper)
340  !
341  ! -- deallocate loader
342  nullify (this%rp_loader%nc_vars)
343  call this%rp_loader%destroy()
344  deallocate (this%rp_loader)
345  !
346  ! -- deallocate parser
347  call this%parser%clear()
348  deallocate (this%parser)
349  !
350  ! -- deallocate input context
351  call this%DynamicPkgLoadType%destroy()

◆ dynamic_df()

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

Definition at line 201 of file IdmMf6File.f90.

202  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
203  !
204  ! -- invoke loader define
205  call this%rp_loader%df()
206  !
207  ! -- read first ionper
208  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 160 of file IdmMf6File.f90.

165  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
166  type(ModflowInputType), intent(in) :: mf6_input
167  character(len=*), intent(in) :: component_name
168  character(len=*), intent(in) :: component_input_name
169  character(len=*), intent(in) :: input_name
170  integer(I4B), intent(in) :: iperblock
171  integer(I4B), intent(in) :: iout
172  integer(I4B) :: inunit
173  !
174  ! -- initialize base loader
175  call this%DynamicPkgLoadType%init(mf6_input, component_name, &
176  component_input_name, input_name, &
177  iperblock, iout)
178  !
179  ! -- allocate scalars
180  call mem_allocate(this%iper, 'IPER', mf6_input%mempath)
181  call mem_allocate(this%ionper, 'IONPER', mf6_input%mempath)
182  !
183  ! -- initialize
184  this%iper = 0
185  this%ionper = 0
186  !
187  ! -- open input file
188  inunit = open_mf6file(mf6_input%pkgtype, input_name, &
189  component_input_name, iout)
190  !
191  ! -- allocate and initialize parser
192  allocate (this%parser)
193  call this%parser%Initialize(inunit, iout)
194  !
195  ! -- allocate and initialize loader
196  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 248 of file IdmMf6File.f90.

249  ! -- modules
250  use tdismodule, only: kper, nper
251  ! -- dummy
252  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
253  ! -- local
254  character(len=LINELENGTH) :: line
255  logical(LGP) :: isblockfound
256  integer(I4B) :: ierr
257  character(len=*), parameter :: fmtblkerr = &
258  &"('Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
259  !
260  call this%parser%GetBlock('PERIOD', isblockfound, ierr, &
261  supportopenclose=.true., &
262  blockrequired=.false.)
263  !
264  ! -- set first period block IPER
265  if (isblockfound) then
266  !
267  this%ionper = this%parser%GetInteger()
268  !
269  if (this%ionper <= this%iper) then
270  write (errmsg, '(a, i0, a, i0, a, i0, a)') &
271  'Error in stress period ', kper, &
272  '. Period numbers not increasing. Found ', this%ionper, &
273  ' but last period block was assigned ', this%iper, '.'
274  call store_error(errmsg)
275  call this%parser%StoreErrorUnit()
276  end if
277  !
278  else
279  !
280  ! -- PERIOD block not found
281  if (ierr < 0) then
282  ! -- End of file found; data applies for remainder of simulation.
283  this%ionper = nper + 1
284  else
285  ! -- Found invalid block
286  call this%parser%GetCurrentLine(line)
287  write (errmsg, fmtblkerr) adjustl(trim(line))
288  call store_error(errmsg)
289  call this%parser%StoreErrorUnit()
290  end if
291  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 222 of file IdmMf6File.f90.

223  ! -- modules
224  use tdismodule, only: kper, nper
225  ! -- dummy
226  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
227  ! -- local
228  !
229  ! -- check if ready to load
230  if (this%ionper /= kper) return
231  !
232  ! -- dynamic load
233  call this%rp_loader%rp(this%parser)
234  !
235  ! -- update loaded iper
236  this%iper = kper
237  !
238  ! -- read next iper
239  if (kper < nper) then
240  call this%read_ionper()
241  else
242  this%ionper = nper + 1
243  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 356 of file IdmMf6File.f90.

357  ! -- modules
359  ! -- dummy
360  character(len=*), intent(in) :: filetype
361  character(len=*), intent(in) :: filename
362  character(len=*), intent(in) :: component_fname
363  integer(I4B), intent(in) :: iout
364  ! -- return
365  integer(I4B) :: inunit
366  ! -- local
367  !
368  ! -- initialize
369  inunit = 0
370  !
371  if (filename /= '') then
372  !
373  ! -- get unit number and open file
374  inunit = getunit()
375  call openfile(inunit, iout, trim(adjustl(filename)), filetype, &
376  'FORMATTED', 'SEQUENTIAL', 'OLD')
377  else
378  write (errmsg, '(a,a,a)') &
379  'File unspecified, cannot load model or package &
380  &type "', trim(filetype), '".'
381  call store_error(errmsg)
382  call store_error_filename(component_fname)
383  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 150 of file IdmMf6File.f90.

151  class(Mf6FileStaticPkgLoadType), intent(inout) :: this
152  !
153  ! -- deallocate base type
154  call this%StaticPkgLoadType%destroy()
155  !

◆ 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  !
103  ! -- initialize base type
104  call this%StaticPkgLoadType%init(mf6_input, component_name, &
105  component_input_name, input_name)
106  !

◆ static_load()

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

Definition at line 111 of file IdmMf6File.f90.

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