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

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

◆ dynamic_create_loader()

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

Definition at line 269 of file IdmMf6File.f90.

272  use listloadmodule, only: listloadtype
277  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
278  class(ListLoadType), pointer :: list_loader
279  class(GridArrayLoadType), pointer :: arrgrid_loader
280  class(LayerArrayLoadType), pointer :: arrlayer_loader
281  class(SettingLoadType), pointer :: setting_loader
282  class(KeystringLoadType), pointer :: keystring_loader
283  class(StoInputType), pointer :: sto_loader
284 
285  ! allocate and set loader
286  if (this%mf6_input%subcomponent_type == 'STO') then
287  allocate (sto_loader)
288  this%rp_loader => sto_loader
289  else if (this%mf6_input%subcomponent_type == 'OC' .or. &
290  this%mf6_input%subcomponent_type == 'PRP') then
291  allocate (setting_loader)
292  this%rp_loader => setting_loader
293  else if (this%has_keystring) then
294  allocate (keystring_loader)
295  this%rp_loader => keystring_loader
296  else if (this%readasarrays) then
297  allocate (arrlayer_loader)
298  this%rp_loader => arrlayer_loader
299  else if (this%readarraygrid) then
300  call developmode('Input file "'//trim(this%input_name)// &
301  '" READARRAYGRID option is still under development, install the &
302  &nightly build or compile from source with IDEVELOPMODE = 1.', &
303  this%iout)
304  allocate (arrgrid_loader)
305  this%rp_loader => arrgrid_loader
306  else
307  allocate (list_loader)
308  this%rp_loader => list_loader
309  end if
310 
311  ! set nc_vars pointer
312  this%rp_loader%nc_vars => this%nc_vars
313 
314  ! initialize loader
315  call this%rp_loader%ainit(this%mf6_input, &
316  this%component_name, &
317  this%component_input_name, &
318  this%input_name, &
319  this%iperblock, &
320  this%parser, &
321  this%iout)
Disable development features in release mode.
Definition: FeatureFlags.f90:2
subroutine, public developmode(errmsg, iunit)
Terminate if in release mode (guard development features)
This module contains the GridArrayLoadModule.
This module contains the LayerArrayLoadModule.
This module contains the ListLoadModule.
Definition: Mf6FileList.f90:7
Period block keystring-based input loader.
This module contains the Mf6FileSettingLoadModule.
This module contains the Mf6FileStoInputModule.
Ascii grid based dynamic loader type.
Ascii array layer dynamic loader type.
list input loader for dynamic packages.
Definition: Mf6FileList.f90:31
Here is the call graph for this function:

◆ dynamic_destroy()

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

Definition at line 326 of file IdmMf6File.f90.

328  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
329 
330  ! deallocate scalars
331  call mem_deallocate(this%iper)
332  call mem_deallocate(this%ionper)
333 
334  ! deallocate loader
335  nullify (this%rp_loader%nc_vars)
336  call this%rp_loader%destroy()
337  deallocate (this%rp_loader)
338 
339  ! deallocate parser
340  call this%parser%clear()
341  deallocate (this%parser)
342 
343  ! deallocate input context
344  call this%DynamicPkgLoadType%destroy()

◆ dynamic_df()

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

Definition at line 188 of file IdmMf6File.f90.

189  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
190  ! invoke loader define
191  call this%rp_loader%df()
192  ! read first ionper
193  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.

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

◆ dynamic_read_ionper()

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

Definition at line 229 of file IdmMf6File.f90.

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

207  use tdismodule, only: kper, nper
208  class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
209 
210  ! check if ready to load
211  if (this%ionper /= kper) return
212 
213  ! dynamic load
214  call this%rp_loader%rp(this%parser)
215 
216  ! update loaded iper
217  this%iper = kper
218 
219  ! read next iper
220  if (kper < nper) then
221  call this%read_ionper()
222  else
223  this%ionper = nper + 1
224  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:54
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 349 of file IdmMf6File.f90.

351  character(len=*), intent(in) :: filetype
352  character(len=*), intent(in) :: filename
353  character(len=*), intent(in) :: component_fname
354  integer(I4B), intent(in) :: iout
355  integer(I4B) :: inunit
356 
357  ! initialize
358  inunit = 0
359 
360  if (filename /= '') then
361  ! get unit number and open file
362  inunit = getunit()
363  call openfile(inunit, iout, trim(adjustl(filename)), filetype, &
364  'FORMATTED', 'SEQUENTIAL', 'OLD')
365  else
366  write (errmsg, '(a,a,a)') &
367  'File unspecified, cannot load model or package &
368  &type "', trim(filetype), '".'
369  call store_error(errmsg)
370  call store_error_filename(component_fname)
371  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: