MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
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
subroutine static_init (this, mf6_input, component_name, component_input_name, input_name)
 static loader init
class(dynamicpkgloadbasetype) function, pointer static_load (this, iout)
 load routine for static loader
subroutine static_destroy (this)
 static loader destroy
subroutine dynamic_init (this, mf6_input, component_name, component_input_name, input_name, iperblock, iout)
 dynamic loader init
subroutine dynamic_df (this)
 define routine for dynamic loader
subroutine dynamic_ad (this)
 advance routine for dynamic loader
subroutine dynamic_rp (this)
 read and prepare routine for dynamic loader
subroutine dynamic_read_ionper (this)
 dynamic loader read ionper of next period block
subroutine dynamic_create_loader (this)
 allocate a dynamic loader based on load context
subroutine dynamic_destroy (this)
 dynamic loader destroy
integer(i4b) function, public open_mf6file (filetype, filename, component_fname, iout)
 open a model package files

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 202 of file IdmMf6File.f90.

203 class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
204 ! invoke loader advance
205 call this%rp_loader%ts_advance()

◆ dynamic_create_loader()

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

Definition at line 279 of file IdmMf6File.f90.

286 class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
287 class(ListLoadType), pointer :: list_loader
288 class(GridArrayLoadType), pointer :: arrgrid_loader
289 class(LayerArrayLoadType), pointer :: arrlayer_loader
290 class(SettingLoadType), pointer :: setting_loader
291 class(KeystringLoadType), pointer :: keystring_loader
292 class(StoInputType), pointer :: sto_loader
293
294 ! allocate and set loader
295 if (this%mf6_input%subcomponent_type == 'STO') then
296 allocate (sto_loader)
297 this%rp_loader => sto_loader
298 else if (this%mf6_input%subcomponent_type == 'OC' .or. &
299 this%mf6_input%subcomponent_type == 'PRP') then
300 allocate (setting_loader)
301 this%rp_loader => setting_loader
302 else if (this%has_keystring) then
303 allocate (keystring_loader)
304 this%rp_loader => keystring_loader
305 else if (this%readasarrays) then
306 allocate (arrlayer_loader)
307 this%rp_loader => arrlayer_loader
308 else if (this%readarraygrid) then
309 allocate (arrgrid_loader)
310 this%rp_loader => arrgrid_loader
311 else
312 allocate (list_loader)
313 this%rp_loader => list_loader
314 end if
315
316 ! set nc_vars pointer
317 this%rp_loader%nc_vars => this%nc_vars
318
319 ! initialize loader
320 call this%rp_loader%ainit(this%mf6_input, &
321 this%component_name, &
322 this%component_input_name, &
323 this%input_name, &
324 this%iperblock, &
325 this%parser, &
326 this%iout)
This module contains the GridArrayLoadModule.
This module contains the LayerArrayLoadModule.
This module contains the ListLoadModule.
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.

◆ dynamic_destroy()

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

Definition at line 331 of file IdmMf6File.f90.

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

◆ dynamic_df()

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

Definition at line 192 of file IdmMf6File.f90.

193 class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
194 ! invoke loader define
195 call this%rp_loader%df()
196 ! read first ionper
197 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 150 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 call mem_allocate(this%hasperiodblocks, 'HASPERIODBLOCKS', &
171 mf6_input%mempath)
172
173 ! initialize
174 this%iper = 0
175 this%ionper = 0
176 this%hasperiodblocks = .false.
177
178 ! open input file
179 inunit = open_mf6file(mf6_input%pkgtype, input_name, &
180 component_input_name, iout)
181
182 ! allocate and initialize parser
183 allocate (this%parser)
184 call this%parser%Initialize(inunit, iout)
185
186 ! allocate and initialize loader
187 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)
private

Definition at line 233 of file IdmMf6File.f90.

234 use tdismodule, only: kper, nper
235 class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
236 character(len=LINELENGTH) :: line
237 logical(LGP) :: isblockfound
238 integer(I4B) :: ierr
239 character(len=*), parameter :: fmtblkerr = &
240 &"('Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
241
242 call this%parser%GetBlock('PERIOD', isblockfound, ierr, &
243 supportopenclose=.true., &
244 blockrequired=.false.)
245 ! set first period block IPER
246 if (isblockfound) then
247 ! the file has a PERIOD block, whatever its number. only set
248 ! here: at end of file IONPER is nper + 1, the same value as
249 ! a block numbered nper + 1, so IONPER can't tell them apart.
250 ! never set false: later calls reach end of file after the
251 ! last block, which would clear it for a file that has blocks.
252 this%hasperiodblocks = .true.
253 this%ionper = this%parser%GetInteger()
254 if (this%ionper <= this%iper) then
255 write (errmsg, '(a, i0, a, i0, a, i0, a)') &
256 'Error in stress period ', kper, &
257 '. Period numbers not increasing. Found ', this%ionper, &
258 ' but last period block was assigned ', this%iper, '.'
259 call store_error(errmsg)
260 call this%parser%StoreErrorUnit()
261 end if
262 else
263 ! PERIOD block not found
264 if (ierr < 0) then
265 ! End of file found; data applies for remainder of simulation.
266 this%ionper = nper + 1
267 else
268 ! Found invalid block
269 call this%parser%GetCurrentLine(line)
270 write (errmsg, fmtblkerr) adjustl(trim(line))
271 call store_error(errmsg)
272 call this%parser%StoreErrorUnit()
273 end if
274 end if
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
integer(i4b), pointer, public nper
number of stress period
Definition tdis.f90:24
Here is the call graph for this function:

◆ dynamic_rp()

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

Definition at line 210 of file IdmMf6File.f90.

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

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

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

143 class(Mf6FileStaticPkgLoadType), intent(inout) :: this
144 ! deallocate base type
145 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 )
private

Definition at line 96 of file IdmMf6File.f90.

98 class(Mf6FileStaticPkgLoadType), intent(inout) :: this
99 type(ModflowInputType), intent(in) :: mf6_input
100 character(len=*), intent(in) :: component_name
101 character(len=*), intent(in) :: component_input_name
102 character(len=*), intent(in) :: input_name
103 ! initialize base type
104 call this%StaticPkgLoadType%init(mf6_input, component_name, &
105 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 110 of file IdmMf6File.f90.

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