MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
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, input_fname, component_fname, nc_vars)
 factory function to create and setup model package static loader More...
 
class(staticpkgloadbasetype) function, pointer package_loader (source_type)
 allocate source model package static loader More...
 
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 More...
 
subroutine, public export_post_prepare ()
 model exports post prepare step actions More...
 
subroutine, public export_post_step ()
 model exports post step actions More...
 
subroutine, public export_da ()
 deallocate model export objects and list More...
 
subroutine, public nc_close (ncid, nc_fname)
 close an open netcdf file More...
 
type(ncfilevarstype) function, pointer, public netcdf_context (modeltype, component_type, modelname, modelfname, iout)
 create model netcdf context More...
 

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)  input_fname,
character(len=*), intent(in)  component_fname,
type(ncfilevarstype), intent(in), optional, pointer  nc_vars 
)

Definition at line 33 of file SourceLoad.F90.

39  character(len=*), intent(in) :: component_type
40  character(len=*), intent(in) :: subcomponent_type
41  character(len=*), intent(in) :: component_name
42  character(len=*), intent(in) :: subcomponent_name
43  character(len=*), intent(in) :: input_type
44  character(len=*), intent(in) :: input_fname
45  character(len=*), intent(in) :: component_fname
46  type(NCFileVarsType), pointer, optional, intent(in) :: nc_vars
47  class(StaticPkgLoadBaseType), pointer :: loader
48  type(ModflowInputType) :: mf6_input
49  character(len=LENPACKAGENAME) :: source_type
50  character(len=LENPACKAGENAME) :: sc_name
51 
52  ! set subcomponent name
53  sc_name = idm_subcomponent_name(component_type, subcomponent_type, &
54  subcomponent_name)
55  ! create description of input
56  mf6_input = getmodflowinput(input_type, component_type, subcomponent_type, &
57  component_name, sc_name, input_fname)
58  ! set package source
59  source_type = package_source_type(input_fname)
60 
61  ! set source loader for model package
62  loader => package_loader(source_type)
63 
64  ! initialize loader
65  call loader%init(mf6_input, component_name, component_fname, input_fname)
66 
67  ! initialize loader netcdf variables data structure
68  if (present(nc_vars)) then
69  call nc_vars%create_varlists(component_name, sc_name, loader%nc_vars)
70  else
71  call loader%nc_vars%init(component_name)
72  end if
This module contains the InputLoadTypeModule.
This module contains the SourceCommonModule.
Definition: SourceCommon.f90:7
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 300 of file SourceLoad.F90.

302 #if defined(__WITH_NETCDF__)
304 #endif
305  call modelexports_create(iout)
306  ! are netcdf exports elected
307  if (nc_export_active()) then
308 #if defined(__WITH_NETCDF__)
309  call nc_export_create()
310 #else
311  write (errmsg, '(a)') &
312  'Model namefile NETCDF_STUCTURED or NETCDF_MESH2D option configured &
313  &but NetCDF libraries are not available.'
314  call store_error(errmsg, .true.)
315 #endif
316  end if
This module contains the ModelExportModule.
Definition: ModelExport.f90:8
subroutine, public modelexports_create(iout)
create export container variable for all local models
Definition: ModelExport.f90:77
logical(lgp) function, public nc_export_active()
is netcdf export configured for any model
Definition: ModelExport.f90:60
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 335 of file SourceLoad.F90.

337  call modelexports_destroy()
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 321 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 328 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 124 of file SourceLoad.F90.

125  use simvariablesmodule, only: simfile
127  use idmmf6filemodule, only: input_load
128  character(len=*), intent(in) :: mtype
129  character(len=*), intent(in) :: mfname
130  character(len=*), intent(in) :: mname
131  integer(I4B), intent(in) :: iout
132  type(ModflowInputType) :: mf6_input
133  character(len=LENPACKAGENAME) :: source_type
134 
135  ! set source type
136  source_type = package_source_type(mfname)
137 
138  ! create description of input
139  mf6_input = getmodflowinput(mtype, idm_component_type(mtype), 'NAM', &
140  mname, 'NAM', mfname)
141  select case (source_type)
142  case ('MF6FILE')
143  call input_load(mfname, mf6_input, simfile, iout)
144  case default
145  end select
This module contains the IdmMf6FileModule.
Definition: IdmMf6File.f90:10
subroutine, public input_load(filename, mf6_input, component_filename, iout, nc_vars)
input load for traditional mf6 simulation static input file
Definition: IdmMf6File.f90:59
This module contains simulation variables.
Definition: SimVariables.f90:9
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 148 of file SourceLoad.F90.

149  use simvariablesmodule, only: simfile, iout
151  use messagemodule, only: write_message
152  use idmmf6filemodule, only: input_load
154  type(ModflowInputType) :: mf6_input, hpc_input
155  character(len=LINELENGTH) :: hpc6_filename
156  character(len=LINELENGTH) :: line
157  logical(LGP) :: lexist
158 
159  ! load mfsim.nam if it exists
160  inquire (file=trim(adjustl(simfile)), exist=lexist)
161 
162  if (lexist) then
163  ! write name of namfile to stdout
164  write (line, '(2(1x,a))') 'Using Simulation name file:', &
165  trim(adjustl(simfile))
166  call write_message(line, skipafter=1)
167  ! create description of input
168  mf6_input = getmodflowinput('NAM6', 'SIM', 'NAM', 'SIM', 'NAM', simfile)
169  ! open namfile and load to input context
170  call input_load(simfile, mf6_input, simfile, iout)
171  ! load optional HPC configuration file
172  if (filein_fname(hpc6_filename, 'HPC6_FILENAME', mf6_input%mempath, &
173  simfile)) then
174  hpc_input = getmodflowinput('HPC6', 'UTL', 'HPC', 'UTL', 'HPC')
175  call input_load(hpc6_filename, hpc_input, simfile, iout)
176  end if
177  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:210
integer(i4b) iout
file unit number for simulation output
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 180 of file SourceLoad.F90.

181  use simvariablesmodule, only: simfile, iout
186  use idmmf6filemodule, only: input_load
187  character(len=LENMEMPATH) :: input_mempath
188  type(ModflowInputType) :: mf6_input
189  character(len=LENPACKAGENAME) :: source_type
190  character(len=:), pointer :: tdis6
191  logical(LGP) :: lexist
192 
193  ! set input memory path
194  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
195 
196  ! set pointers to input context timing params
197  call mem_setptr(tdis6, 'TDIS6', input_mempath)
198 
199  ! create timing
200  if (tdis6 /= '') then
201  ! set source type
202  source_type = package_source_type(tdis6)
203  select case (source_type)
204  case ('MF6FILE')
205  inquire (file=trim(adjustl(tdis6)), exist=lexist)
206  if (lexist) then
207  ! create description of input
208  mf6_input = getmodflowinput('TDIS6', 'SIM', 'TDIS', &
209  'SIM', 'TDIS', simfile)
210  ! open namfile and load to input context
211  call input_load(tdis6, mf6_input, simfile, iout)
212  else
213  write (errmsg, '(a)') &
214  'Simulation TIMING input file "'//trim(tdis6)// &
215  '" does not exist.'
216  call store_error(errmsg)
217  call store_error_filename(simfile)
218  end if
219  case default
220  end select
221  end if
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
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 342 of file SourceLoad.F90.

343 #if defined(__WITH_NETCDF__)
344  use netcdfcommonmodule, only: nc_fclose
345 #endif
346  integer(I4B), intent(in) :: ncid
347  character(len=*), intent(in) :: nc_fname
348  if (ncid > 0) then
349 #if defined(__WITH_NETCDF__)
350  call nc_fclose(ncid, nc_fname)
351 #endif
352  end if
This module contains the NetCDFCommonModule.
Definition: NetCDFCommon.f90:6
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 357 of file SourceLoad.F90.

362 #if defined(__WITH_NETCDF__)
364 #endif
365  character(len=*), intent(in) :: modeltype
366  character(len=*), intent(in) :: component_type
367  character(len=*), intent(in) :: modelname
368  character(len=*), intent(in) :: modelfname
369  integer(I4B), intent(in) :: iout
370  type(NCFileVarsType), pointer :: nc_vars
371  character(len=LENMEMPATH) :: input_mempath
372  character(len=LINELENGTH) :: nc_fname
373  integer(I4B) :: ncid
374 
375  ! set input memory path
376  input_mempath = create_mem_path(modelname, 'NAM', idm_context)
377 
378  ! allocate context object
379  allocate (nc_vars)
380 
381  ! check if optional netcdf input file was provided
382  if (filein_fname(nc_fname, 'NETCDF_FNAME', input_mempath, modelfname)) then
383 #if defined(__WITH_NETCDF__)
384  ! open nc input file
385  ncid = open_ncfile(nc_fname, iout)
386  ! read the file and build the context
387  call create_netcdf_context(modeltype, modelname, modelfname, &
388  nc_vars, nc_fname, ncid, iout)
389 #else
390  write (errmsg, '(a)') &
391  'Cannot load model packages. NetCDF &
392  &keyword specified in input file but &
393  &NetCDF libraries are not available.'
394  call store_error(errmsg)
395  call store_error_filename(modelfname)
396 #endif
397  else
398  ncid = 0
399  call nc_vars%init(modelname, '', ncid, '')
400  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 101 of file SourceLoad.F90.

103  use idmmf6filemodule, only: open_mf6file
104  character(len=*), intent(in) :: pkgtype
105  character(len=*), intent(in) :: filename
106  character(len=*), intent(in) :: modelfname
107  integer(I4B), intent(in) :: iout
108  integer(I4B) :: fd
109  character(len=LENPACKAGENAME) :: source_type
110 
111  ! initialize
112  fd = 0
113 
114  ! set source type
115  source_type = package_source_type(filename)
116  !
117  select case (source_type)
118  case ('MF6FILE')
119  fd = open_mf6file(pkgtype, filename, modelfname, iout)
120  case default
121  end select
integer(i4b) function, public open_mf6file(filetype, filename, component_fname, iout)
open a model package files
Definition: IdmMf6File.f90:330
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)

Definition at line 77 of file SourceLoad.F90.

80  character(len=*), intent(inout) :: source_type
81  class(Mf6FileStaticPkgLoadType), pointer :: mf6file_loader
82  class(StaticPkgLoadBaseType), pointer :: loader
83 
84  ! initialize
85  nullify (loader)
86 
87  ! allocate derived object
88  select case (source_type)
89  case ('MF6FILE')
90  allocate (mf6file_loader)
91  loader => mf6file_loader
92  allocate (loader%nc_vars)
93  case default
94  write (errmsg, '(a)') &
95  'Simulation package input source type "'//trim(source_type)// &
96  '" not currently supported.'
97  call store_error(errmsg, .true.)
98  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 224 of file SourceLoad.F90.

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