MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
sourceloadmodule Module Reference

This module contains the SourceLoadModule. More...

Functions/Subroutines

class(staticpkgloadbasetype) function, pointer, public create_input_loader (component_type, subcomponent_type, component_name, subcomponent_name, input_type, load_scope, input_fname, component_fname, nc_vars)
 factory function to create and setup model package static loader
class(staticpkgloadbasetype) function, pointer package_loader (source_type)
 allocate source model package static loader
integer(i4b) function, public open_source_file (pkgtype, filename, modelfname, iout)
subroutine, public load_modelnam (mtype, mfname, mname, iout)
subroutine, public load_simnam ()
subroutine, public load_simtdis ()
integer(i4b) function, public remote_model_ndim (mtype, mfname)
subroutine, public export_cr ()
 create model exports list
subroutine, public export_post_prepare ()
 model exports post prepare step actions
subroutine, public export_post_step ()
 model exports post step actions
subroutine, public export_da ()
 deallocate model export objects and list
subroutine, public nc_close (ncid, nc_fname)
 close an open netcdf file
type(ncfilevarstype) function, pointer, public netcdf_context (modeltype, component_type, modelname, modelfname, iout)
 create model netcdf context

Detailed Description

This module contains the routines needed to generate a loader object for an input source and routines that distribute processing to a particular source.

Function/Subroutine Documentation

◆ create_input_loader()

class(staticpkgloadbasetype) function, pointer, public sourceloadmodule::create_input_loader ( character(len=*), intent(in) component_type,
character(len=*), intent(in) subcomponent_type,
character(len=*), intent(in) component_name,
character(len=*), intent(in) subcomponent_name,
character(len=*), intent(in) input_type,
character(len=*), intent(in) load_scope,
character(len=*), intent(in) input_fname,
character(len=*), intent(in) component_fname,
type(ncfilevarstype), intent(in), optional, pointer nc_vars )

Definition at line 33 of file SourceLoad.F90.

40 character(len=*), intent(in) :: component_type
41 character(len=*), intent(in) :: subcomponent_type
42 character(len=*), intent(in) :: component_name
43 character(len=*), intent(in) :: subcomponent_name
44 character(len=*), intent(in) :: input_type
45 character(len=*), intent(in) :: load_scope
46 character(len=*), intent(in) :: input_fname
47 character(len=*), intent(in) :: component_fname
48 type(NCFileVarsType), pointer, optional, intent(in) :: nc_vars
49 class(StaticPkgLoadBaseType), pointer :: loader
50 type(ModflowInputType) :: mf6_input
51 character(len=LENPACKAGENAME) :: source_type
52 character(len=LENPACKAGENAME) :: sc_name
53
54 ! set subcomponent name
55 sc_name = idm_subcomponent_name(component_type, subcomponent_type, &
56 subcomponent_name)
57 ! create description of input
58 mf6_input = getmodflowinput(input_type, component_type, subcomponent_type, &
59 component_name, sc_name, load_scope, &
60 input_fname)
61 ! set package source
62 source_type = package_source_type(input_fname)
63
64 ! set source loader for model package
65 loader => package_loader(source_type)
66
67 ! initialize loader
68 call loader%init(mf6_input, component_name, component_fname, input_fname)
69
70 ! initialize loader netcdf variables data structure
71 if (present(nc_vars)) then
72 call nc_vars%create_varlists(component_name, sc_name, loader%nc_vars)
73 else
74 call loader%nc_vars%init(component_name)
75 end if
This module contains the InputLoadTypeModule.
This module contains the SourceCommonModule.
character(len=lenpackagename) function, public package_source_type(sourcename)
source identifier from model namfile FNAME array
character(len=lenpackagename) function, public idm_subcomponent_name(component_type, subcomponent_type, sc_name)
model package subcomponent name
Base abstract type for static input loader.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_cr()

subroutine, public sourceloadmodule::export_cr

Definition at line 304 of file SourceLoad.F90.

306#if defined(__WITH_NETCDF__)
308#endif
309 call modelexports_create(iout)
310 ! are netcdf exports elected
311 if (nc_export_active()) then
312#if defined(__WITH_NETCDF__)
313 call nc_export_create()
314#else
315 write (errmsg, '(a)') &
316 'Model namefile NETCDF_STUCTURED or NETCDF_MESH2D option configured &
317 &but NetCDF libraries are not available.'
318 call store_error(errmsg, .true.)
319#endif
320 end if
This module contains the ModelExportModule.
subroutine, public modelexports_create(iout)
create export container variable for all local models
logical(lgp) function, public nc_export_active()
is netcdf export configured for any model
This module contains the NCExportCreateModule.
subroutine, public nc_export_create()
initialize netcdf model export type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_da()

subroutine, public sourceloadmodule::export_da

Definition at line 339 of file SourceLoad.F90.

subroutine, public modelexports_destroy()
destroy export model list
Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_post_prepare()

subroutine, public sourceloadmodule::export_post_prepare

Definition at line 325 of file SourceLoad.F90.

subroutine, public modelexports_post_prepare()
export model list post prepare step
Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_post_step()

subroutine, public sourceloadmodule::export_post_step

Definition at line 332 of file SourceLoad.F90.

subroutine, public modelexports_post_step()
export model list post step
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_modelnam()

subroutine, public sourceloadmodule::load_modelnam ( character(len=*), intent(in) mtype,
character(len=*), intent(in) mfname,
character(len=*), intent(in) mname,
integer(i4b), intent(in) iout )

Definition at line 127 of file SourceLoad.F90.

128 use simvariablesmodule, only: simfile
131 character(len=*), intent(in) :: mtype
132 character(len=*), intent(in) :: mfname
133 character(len=*), intent(in) :: mname
134 integer(I4B), intent(in) :: iout
135 type(ModflowInputType) :: mf6_input
136 character(len=LENPACKAGENAME) :: source_type
137
138 ! set source type
139 source_type = package_source_type(mfname)
140
141 ! create description of input
142 mf6_input = getmodflowinput(mtype, idm_component_type(mtype), 'NAM', &
143 mname, 'NAM', 'SIM', mfname)
144 select case (source_type)
145 case ('MF6FILE')
146 call input_load(mfname, mf6_input, simfile, iout)
147 case default
148 end select
This module contains the IdmMf6FileModule.
subroutine, public input_load(filename, mf6_input, component_filename, iout, nc_vars)
input load for traditional mf6 simulation static input file
This module contains simulation variables.
integer(i4b) iout
file unit number for simulation output
character(len=linelength) simfile
simulation name file
character(len=lencomponentname) function, public idm_component_type(component)
component from package or model type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_simnam()

subroutine, public sourceloadmodule::load_simnam

Definition at line 151 of file SourceLoad.F90.

157 type(ModflowInputType) :: mf6_input, hpc_input
158 character(len=LINELENGTH) :: hpc6_filename
159 character(len=LINELENGTH) :: line
160 logical(LGP) :: lexist
161
162 ! load mfsim.nam if it exists
163 inquire (file=trim(adjustl(simfile)), exist=lexist)
164
165 if (lexist) then
166 ! write name of namfile to stdout
167 write (line, '(2(1x,a))') 'Using Simulation name file:', &
168 trim(adjustl(simfile))
169 call write_message(line, skipafter=1)
170 ! create description of input
171 mf6_input = getmodflowinput('NAM6', 'SIM', 'NAM', 'SIM', 'NAM', 'ROOT', &
172 simfile)
173 ! open namfile and load to input context
174 call input_load(simfile, mf6_input, simfile, iout)
175 ! load optional HPC configuration file
176 if (filein_fname(hpc6_filename, 'HPC6_FILENAME', mf6_input%mempath, &
177 simfile)) then
178 hpc_input = getmodflowinput('HPC6', 'UTL', 'HPC', 'UTL', 'HPC', 'SIM')
179 call input_load(hpc6_filename, hpc_input, simfile, iout)
180 end if
181 end if
Store and issue logging messages to output units.
Definition Message.f90:2
subroutine, public write_message(text, iunit, fmt, skipbefore, skipafter, advance)
Write a message to an output unit.
Definition Message.f90:212
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_simtdis()

subroutine, public sourceloadmodule::load_simtdis

Definition at line 184 of file SourceLoad.F90.

191 character(len=LENMEMPATH) :: input_mempath
192 type(ModflowInputType) :: mf6_input
193 character(len=LENPACKAGENAME) :: source_type
194 character(len=:), pointer :: tdis6
195 logical(LGP) :: lexist
196
197 ! set input memory path
198 input_mempath = create_mem_path('SIM', 'NAM', idm_context)
199
200 ! set pointers to input context timing params
201 call mem_setptr(tdis6, 'TDIS6', input_mempath)
202
203 ! create timing
204 if (tdis6 /= '') then
205 ! set source type
206 source_type = package_source_type(tdis6)
207 select case (source_type)
208 case ('MF6FILE')
209 inquire (file=trim(adjustl(tdis6)), exist=lexist)
210 if (lexist) then
211 ! create description of input
212 mf6_input = getmodflowinput('TDIS6', 'SIM', 'TDIS', &
213 'SIM', 'TDIS', 'SIM', simfile)
214 ! open namfile and load to input context
215 call input_load(tdis6, mf6_input, simfile, iout)
216 else
217 write (errmsg, '(a)') &
218 'Simulation TIMING input file "'//trim(tdis6)// &
219 '" does not exist.'
220 call store_error(errmsg)
221 call store_error_filename(simfile)
222 end if
223 case default
224 end select
225 end if
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nc_close()

subroutine, public sourceloadmodule::nc_close ( integer(i4b), intent(in) ncid,
character(len=*), intent(in) nc_fname )

Definition at line 346 of file SourceLoad.F90.

347#if defined(__WITH_NETCDF__)
349#endif
350 integer(I4B), intent(in) :: ncid
351 character(len=*), intent(in) :: nc_fname
352 if (ncid > 0) then
353#if defined(__WITH_NETCDF__)
354 call nc_fclose(ncid, nc_fname)
355#endif
356 end if
This module contains the NetCDFCommonModule.
subroutine, public nc_fclose(ncid, nc_fname)
Close netcdf file.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netcdf_context()

type(ncfilevarstype) function, pointer, public sourceloadmodule::netcdf_context ( character(len=*), intent(in) modeltype,
character(len=*), intent(in) component_type,
character(len=*), intent(in) modelname,
character(len=*), intent(in) modelfname,
integer(i4b), intent(in) iout )

Definition at line 361 of file SourceLoad.F90.

366#if defined(__WITH_NETCDF__)
368#endif
369 character(len=*), intent(in) :: modeltype
370 character(len=*), intent(in) :: component_type
371 character(len=*), intent(in) :: modelname
372 character(len=*), intent(in) :: modelfname
373 integer(I4B), intent(in) :: iout
374 type(NCFileVarsType), pointer :: nc_vars
375 character(len=LENMEMPATH) :: input_mempath
376 character(len=LINELENGTH) :: nc_fname
377 integer(I4B) :: ncid
378
379 ! set input memory path
380 input_mempath = create_mem_path(modelname, 'NAM', idm_context)
381
382 ! allocate context object
383 allocate (nc_vars)
384
385 ! check if optional netcdf input file was provided
386 if (filein_fname(nc_fname, 'NETCDF_FNAME', input_mempath, modelfname)) then
387#if defined(__WITH_NETCDF__)
388 ! open nc input file
389 ncid = open_ncfile(nc_fname, iout)
390 ! read the file and build the context
391 call create_netcdf_context(modeltype, modelname, modelfname, &
392 nc_vars, nc_fname, ncid, iout)
393#else
394 write (errmsg, '(a)') &
395 'Cannot load model packages. NetCDF &
396 &keyword specified in input file but &
397 &NetCDF libraries are not available.'
398 call store_error(errmsg)
399 call store_error_filename(modelfname)
400#endif
401 else
402 ncid = 0
403 call nc_vars%init(modelname, '', ncid, '')
404 end if
This module contains the NCContextBuildModule.
integer(i4b) function, public open_ncfile(nc_fname, iout)
open netcdf file
subroutine, public create_netcdf_context(modeltype, modelname, input_name, nc_vars, nc_fname, ncid, iout)
create internal description of modflow6 input variables in netcdf file
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_source_file()

integer(i4b) function, public sourceloadmodule::open_source_file ( character(len=*), intent(in) pkgtype,
character(len=*), intent(in) filename,
character(len=*), intent(in) modelfname,
integer(i4b), intent(in) iout )

Definition at line 104 of file SourceLoad.F90.

107 character(len=*), intent(in) :: pkgtype
108 character(len=*), intent(in) :: filename
109 character(len=*), intent(in) :: modelfname
110 integer(I4B), intent(in) :: iout
111 integer(I4B) :: fd
112 character(len=LENPACKAGENAME) :: source_type
113
114 ! initialize
115 fd = 0
116
117 ! set source type
118 source_type = package_source_type(filename)
119 !
120 select case (source_type)
121 case ('MF6FILE')
122 fd = open_mf6file(pkgtype, filename, modelfname, iout)
123 case default
124 end select
integer(i4b) function, public open_mf6file(filetype, filename, component_fname, iout)
open a model package files
Here is the call graph for this function:
Here is the caller graph for this function:

◆ package_loader()

class(staticpkgloadbasetype) function, pointer sourceloadmodule::package_loader ( character(len=*), intent(inout) source_type)
private

Definition at line 80 of file SourceLoad.F90.

83 character(len=*), intent(inout) :: source_type
84 class(Mf6FileStaticPkgLoadType), pointer :: mf6file_loader
85 class(StaticPkgLoadBaseType), pointer :: loader
86
87 ! initialize
88 nullify (loader)
89
90 ! allocate derived object
91 select case (source_type)
92 case ('MF6FILE')
93 allocate (mf6file_loader)
94 loader => mf6file_loader
95 allocate (loader%nc_vars)
96 case default
97 write (errmsg, '(a)') &
98 'Simulation package input source type "'//trim(source_type)// &
99 '" not currently supported.'
100 call store_error(errmsg, .true.)
101 end select
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remote_model_ndim()

integer(i4b) function, public sourceloadmodule::remote_model_ndim ( character(len=*), intent(in) mtype,
character(len=*), intent(in) mfname )

Definition at line 228 of file SourceLoad.F90.

230 use constantsmodule, only: linelength
233 character(len=*), intent(in) :: mtype
234 character(len=*), intent(in) :: mfname
235 integer(I4B) :: ncelldim
236 character(len=LENPACKAGENAME) :: source_type
237 type(BlockParserType) :: parser
238 integer(I4B) :: ierr, inunit
239 logical(LGP) :: isfound, endOfBlock
240 character(len=LINELENGTH) :: ptype
241
242 ! initialize
243 ncelldim = 0
244
245 ! set source type
246 source_type = package_source_type(mfname)
247 select case (source_type)
248 case ('MF6FILE')
249 ! open name file
250 inunit = getunit()
251 call openfile(inunit, 0, trim(adjustl(mfname)), mtype, &
252 'FORMATTED', 'SEQUENTIAL', 'OLD')
253 ! initialize parser
254 call parser%Initialize(inunit, 0)
255 ! get options block
256 call parser%GetBlock('OPTIONS', isfound, ierr, &
257 supportopenclose=.true., blockrequired=.false.)
258 ! iterate through options
259 if (isfound) then
260 do
261 call parser%GetNextLine(endofblock)
262 if (endofblock) exit
263 end do
264 end if
265 ! get packages block
266 call parser%GetBlock('PACKAGES', isfound, ierr, &
267 supportopenclose=.true., blockrequired=.true.)
268 if (isfound) then
269 ! read through packages
270 do
271 call parser%GetNextLine(endofblock)
272 if (endofblock) exit
273 call parser%GetStringCaps(ptype)
274
275 select case (ptype)
276 case ('DIS6')
277 ncelldim = 3
278 exit
279 case ('DIS2D6')
280 ncelldim = 2
281 exit
282 case ('DISV6')
283 ncelldim = 2
284 exit
285 case ('DISU6')
286 ncelldim = 1
287 exit
288 case default
289 write (errmsg, '(a)') &
290 'Unknown discretization type "'//trim(ptype)// &
291 '" not currently supported.'
292 call store_error(errmsg, .true.)
293 end select
294 end do
295 end if
296
297 call parser%clear()
298 case default
299 end select
This module contains block parser methods.
integer(i4b) function getunit(this)
Get the unit number.
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
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: