MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
ncfilevarsmodule Module Reference

This module contains the NCFileVarsModule. More...

Data Types

type  ncpackagevarstype
 Type describing input variables for a package in NetCDF file. More...
 
type  ncfilemf6vartype
 Type which describes a modflow input variable in a netcdf file. More...
 
type  ncfilevarstype
 Type describing modflow6 input variables in model NetCDF file. More...
 

Functions/Subroutines

subroutine ncvars_init (this, modelname)
 create netcdf package variable lists More...
 
integer(i4b) function ncvars_varid (this, tagname, layer, period, iaux)
 return a netcdf variable id for a package tagname More...
 
subroutine ncvars_destroy (this)
 destroy netcdf package variable lists More...
 
subroutine fv_init (this, modelname, nc_fname, ncid, grid)
 initialize netcdf model variable description type More...
 
subroutine fv_add (this, pkgname, tagname, layer, period, iaux, varid)
 add netcdf modflow6 input variable to list More...
 
subroutine fv_destroy (this)
 destroy netcdf model variable description type More...
 
subroutine create_varlists (this, modelname, pkgname, nc_vars)
 create list of variables that correspond to a package More...
 
class(ncfilemf6vartype) function, pointer ncvar_get (nc_vars, idx)
 get modflow6 input variable description at position idx More...
 

Detailed Description

These data structures organize package input information associated with a single model netcdf input file.

Function/Subroutine Documentation

◆ create_varlists()

subroutine ncfilevarsmodule::create_varlists ( class(ncfilevarstype this,
character(len=*), intent(in)  modelname,
character(len=*), intent(in)  pkgname,
type(ncpackagevarstype), intent(inout), pointer  nc_vars 
)
private

Definition at line 269 of file NCFileVars.f90.

270  ! -- modules
271  ! -- dummy
272  class(NCFileVarsType) :: this
273  character(len=*), intent(in) :: modelname
274  character(len=*), intent(in) :: pkgname
275  type(NCPackageVarsType), pointer, intent(inout) :: nc_vars
276  integer(I4B) :: n
277  ! -- local
278  class(NCFileMf6VarType), pointer :: invar, nc_var
279  class(*), pointer :: obj
280  !
281  do n = 1, this%mf6invar%count()
282  invar => ncvar_get(this%mf6invar, n)
283  if (invar%pkgname == pkgname) then
284  ! -- create package variable description
285  allocate (nc_var)
286  nc_var%pkgname = invar%pkgname
287  nc_var%tagname = invar%tagname
288  nc_var%layer = invar%layer
289  nc_var%period = invar%period
290  nc_var%iaux = invar%iaux
291  nc_var%varid = invar%varid
292  obj => nc_var
293  call nc_vars%nc_vars%Add(obj)
294  end if
295  end do
296  !
297  ! -- set modelname
298  nc_vars%modelname = modelname
299  !
300  ! -- set file attribute pointers
301  nc_vars%ncid => this%ncid
302  nc_vars%nc_fname => this%nc_fname
303  nc_vars%grid => this%grid
304  !
305  ! -- return
306  return
Here is the call graph for this function:

◆ fv_add()

subroutine ncfilevarsmodule::fv_add ( class(ncfilevarstype this,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  tagname,
integer(i4b), intent(in)  layer,
integer(i4b), intent(in)  period,
integer(i4b), intent(in)  iaux,
integer(i4b), intent(in)  varid 
)

Definition at line 216 of file NCFileVars.f90.

217  ! -- modules
219  ! -- dummy variables
220  class(NCFileVarsType) :: this
221  character(len=*), intent(in) :: pkgname
222  character(len=*), intent(in) :: tagname
223  integer(I4B), intent(in) :: layer
224  integer(I4B), intent(in) :: period
225  integer(I4B), intent(in) :: iaux
226  integer(I4B), intent(in) :: varid
227  ! -- local variables
228  class(NCFileMf6VarType), pointer :: invar
229  class(*), pointer :: obj
230  !
231  ! -- add mf6 variable to file list
232  allocate (invar)
233  invar%pkgname = pkgname
234  invar%tagname = tagname
235  invar%layer = layer
236  invar%period = period
237  invar%iaux = iaux
238  invar%varid = varid
239  !
240  obj => invar
241  call this%mf6invar%Add(obj)
242  !
243  ! -- return
244  return

◆ fv_destroy()

subroutine ncfilevarsmodule::fv_destroy ( class(ncfilevarstype this)

Definition at line 249 of file NCFileVars.f90.

250  ! -- modules
251  ! -- dummy
252  class(NCFileVarsType) :: this
253  class(NCFileMf6VarType), pointer :: invar
254  integer(I4B) :: n
255  !
256  do n = 1, this%mf6invar%Count()
257  invar => ncvar_get(this%mf6invar, n)
258  deallocate (invar)
259  nullify (invar)
260  end do
261  !
262  call this%mf6invar%Clear()
263  !
264  return
Here is the call graph for this function:

◆ fv_init()

subroutine ncfilevarsmodule::fv_init ( class(ncfilevarstype this,
character(len=*), intent(in)  modelname,
character(len=*), intent(in)  nc_fname,
integer(i4b), intent(in)  ncid,
character(len=*), intent(in)  grid 
)
private

Definition at line 178 of file NCFileVars.f90.

179  ! -- modules
180  use constantsmodule, only: lenmempath
184  ! -- dummy variables
185  class(NCFileVarsType) :: this
186  character(len=*), intent(in) :: modelname
187  character(len=*), intent(in) :: nc_fname
188  integer(I4B), intent(in) :: ncid
189  character(len=*), intent(in) :: grid
190  ! -- local variables
191  character(len=LENMEMPATH) :: mempath
192  integer(I4B) :: ilen
193  !
194  ! -- set mempath
195  mempath = create_mem_path(component=modelname, &
196  context=idm_context)
197  ! -- initialize strlen
198  ilen = linelength
199  !
200  ! -- allocate managed memory
201  call mem_allocate(this%grid, ilen, 'NETCDF_GRID', mempath)
202  call mem_allocate(this%nc_fname, ilen, 'NETCDF_FNAME', mempath)
203  call mem_allocate(this%ncid, 'NCID', mempath)
204  !
205  ! -- set
206  this%grid = grid
207  this%nc_fname = nc_fname
208  this%ncid = ncid
209  !
210  ! -- return
211  return
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:27
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=linelength) idm_context
Here is the call graph for this function:

◆ ncvar_get()

class(ncfilemf6vartype) function, pointer ncfilevarsmodule::ncvar_get ( type(listtype nc_vars,
integer(i4b), intent(in)  idx 
)
private
Parameters
[in]idxpackage number

Definition at line 311 of file NCFileVars.f90.

312  ! -- dummy variables
313  type(ListType) :: nc_vars
314  integer(I4B), intent(in) :: idx !< package number
315  class(NCFileMf6VarType), pointer :: res
316  ! -- local variables
317  class(*), pointer :: obj
318  !
319  ! -- initialize res
320  res => null()
321  !
322  ! -- get the package from the list
323  obj => nc_vars%GetItem(idx)
324  if (associated(obj)) then
325  select type (obj)
326  class is (ncfilemf6vartype)
327  res => obj
328  end select
329  end if
330  !
331  ! -- return
332  return
Here is the caller graph for this function:

◆ ncvars_destroy()

subroutine ncfilevarsmodule::ncvars_destroy ( class(ncpackagevarstype this)
private

Definition at line 155 of file NCFileVars.f90.

156  ! -- modules
157  ! -- dummy
158  class(NCPackageVarsType) :: this
159  ! -- local
160  class(NCFileMf6VarType), pointer :: nc_var
161  integer(I4B) :: n
162  !
163  ! -- deallocate allocated memory
164  do n = 1, this%nc_vars%Count()
165  nc_var => ncvar_get(this%nc_vars, n)
166  deallocate (nc_var)
167  nullify (nc_var)
168  end do
169  !
170  call this%nc_vars%Clear()
171  !
172  ! -- return
173  return
Here is the call graph for this function:

◆ ncvars_init()

subroutine ncfilevarsmodule::ncvars_init ( class(ncpackagevarstype this,
character(len=*), intent(in)  modelname 
)
private

Definition at line 64 of file NCFileVars.f90.

65  ! -- modules
66  ! -- dummy
67  class(NCPackageVarsType) :: this
68  character(len=*), intent(in) :: modelname
69  ! -- local
70  !
71  ! -- set modelname
72  this%modelname = modelname
73  !
74  ! -- return
75  return

◆ ncvars_varid()

integer(i4b) function ncfilevarsmodule::ncvars_varid ( class(ncpackagevarstype this,
character(len=*), intent(in)  tagname,
integer(i4b), optional  layer,
integer(i4b), optional  period,
integer(i4b), optional  iaux 
)
private

Definition at line 80 of file NCFileVars.f90.

81  ! -- modules
82  ! -- dummy
83  class(NCPackageVarsType) :: this
84  character(len=*), intent(in) :: tagname
85  integer(I4B), optional :: layer
86  integer(I4B), optional :: period
87  integer(I4B), optional :: iaux
88  ! -- return
89  integer(I4B) :: varid
90  ! -- local
91  integer(I4B) :: n, l, p, a
92  class(NCFileMf6VarType), pointer :: nc_var
93  !
94  ! -- initialize
95  varid = -1
96  l = -1
97  p = -1
98  a = -1
99  !
100  ! -- set search layer if provided
101  if (present(layer)) then
102  l = layer
103  end if
104  !
105  ! -- set search period if provided
106  if (present(period)) then
107  p = period
108  end if
109  ! -- set search iaux if provided
110  if (present(iaux)) then
111  a = iaux
112  end if
113  !
114  do n = 1, this%nc_vars%Count()
115  nc_var => ncvar_get(this%nc_vars, n)
116  if (nc_var%tagname == tagname .and. &
117  nc_var%layer == l .and. &
118  nc_var%period == p .and. &
119  nc_var%iaux == a) then
120  varid = nc_var%varid
121  end if
122  end do
123  !
124  ! -- set error and exit if variable not in NetCDF input
125  if (varid == -1) then
126  if (this%nc_fname /= '') then
127  write (errmsg, '(a)') &
128  'NetCDF variable not found, tagname="'//trim(tagname)//'"'
129  if (present(layer)) then
130  write (errmsg, '(a,i0)') trim(errmsg)//', ilayer=', layer
131  end if
132  if (present(period)) then
133  write (errmsg, '(a,i0)') trim(errmsg)//', period=', period
134  end if
135  if (present(iaux)) then
136  write (errmsg, '(a,i0)') trim(errmsg)//', iaux=', iaux
137  end if
138  write (errmsg, '(a)') trim(errmsg)//'.'
139  call store_error(errmsg)
140  call store_error_filename(this%nc_fname)
141  else
142  write (errmsg, '(a)') &
143  'NetCDF variable not found, tagname="'//trim(tagname)// &
144  '". NetCDF input not provided for model "'//trim(this%modelname)//'".'
145  call store_error(errmsg, .true.)
146  end if
147  end if
148  !
149  ! -- return
150  return
Here is the call graph for this function: