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

This module contains the base numerical package type. More...

Data Types

type  numericalpackagetype
 

Functions/Subroutines

subroutine set_names (this, ibcnum, name_model, pakname, ftype, input_mempath)
 @ brief Set package names More...
 
subroutine allocate_scalars (this)
 @ brief Allocate package scalars More...
 
subroutine da (this)
 @ brief Deallocate package scalars More...
 
subroutine read_check_ionper (this)
 @ brief Check ionper More...
 
subroutine get_block_data (this, tags, lfound, varinames)
 @ brief Read griddata block for a package More...
 

Detailed Description

This module contains the base model package class that is extended by all model packages.

Function/Subroutine Documentation

◆ allocate_scalars()

subroutine numericalpackagemodule::allocate_scalars ( class(numericalpackagetype this)
private

Allocate and initialize base numerical package scalars.

Parameters
thisNumericalPackageType object

Definition at line 105 of file NumericalPackage.f90.

106  ! -- modules
109  ! -- dummy variables
110  class(NumericalPackageType) :: this !< NumericalPackageType object
111  ! -- local variables
112  integer(I4B), pointer :: imodelnewton => null()
113  integer(I4B), pointer :: imodelprpak => null()
114  integer(I4B), pointer :: imodelprflow => null()
115  integer(I4B), pointer :: imodelpakcb => null()
116  logical(LGP) :: found
117  !
118  ! -- allocate scalars
119  call mem_allocate(this%input_fname, linelength, 'INPUT_FNAME', &
120  this%memoryPath)
121  call mem_allocate(this%package_type, lenftype, 'PACKAGE_TYPE', &
122  this%memoryPath)
123  call mem_allocate(this%id, 'ID', this%memoryPath)
124  call mem_allocate(this%inunit, 'INUNIT', this%memoryPath)
125  call mem_allocate(this%iout, 'IOUT', this%memoryPath)
126  call mem_allocate(this%inewton, 'INEWTON', this%memoryPath)
127  call mem_allocate(this%iasym, 'IASYM', this%memoryPath)
128  call mem_allocate(this%iprpak, 'IPRPAK', this%memoryPath)
129  call mem_allocate(this%iprflow, 'IPRFLOW', this%memoryPath)
130  call mem_allocate(this%ipakcb, 'IPAKCB', this%memoryPath)
131  !
132  call mem_allocate(this%ionper, 'IONPER', this%memoryPath)
133  call mem_allocate(this%lastonper, 'LASTONPER', this%memoryPath)
134  !
135  ! -- set pointer to model variables
136  call mem_setptr(imodelnewton, 'INEWTON', this%memoryPathModel)
137  call mem_setptr(imodelprpak, 'IPRPAK', this%memoryPathModel)
138  call mem_setptr(imodelprflow, 'IPRFLOW', this%memoryPathModel)
139  call mem_setptr(imodelpakcb, 'IPAKCB', this%memoryPathModel)
140  !
141  ! -- initialize
142  this%input_fname = ''
143  this%package_type = this%filtyp
144  this%id = 0
145  this%inunit = 0
146  this%iout = 0
147  this%inewton = imodelnewton
148  this%iasym = 0
149  this%iprpak = imodelprpak
150  this%iprflow = imodelprflow
151  this%ipakcb = imodelpakcb
152  this%ionper = 0
153  this%lastonper = 0
154  !
155  ! -- nullify unneeded pointers
156  imodelnewton => null()
157  imodelprpak => null()
158  imodelprflow => null()
159  imodelpakcb => null()
160  !
161  ! -- update input filename
162  if (this%input_mempath /= '') then
163  call mem_set_value(this%input_fname, 'INPUT_FNAME', &
164  this%input_mempath, found)
165  end if

◆ da()

subroutine numericalpackagemodule::da ( class(numericalpackagetype this)

Deallocate and initialize base numerical package scalars.

Parameters
thisNumericalPackageType object

Definition at line 173 of file NumericalPackage.f90.

174  ! -- modules
176  ! -- dummy variables
177  class(NumericalPackageType) :: this !< NumericalPackageType object
178  !
179  ! -- deallocate
180  call mem_deallocate(this%input_fname, 'INPUT_FNAME', this%memoryPath)
181  call mem_deallocate(this%package_type, 'PACKAGE_TYPE', this%memoryPath)
182  call mem_deallocate(this%id)
183  call mem_deallocate(this%inunit)
184  call mem_deallocate(this%iout)
185  call mem_deallocate(this%inewton)
186  call mem_deallocate(this%iasym)
187  call mem_deallocate(this%iprpak)
188  call mem_deallocate(this%iprflow)
189  call mem_deallocate(this%ipakcb)
190  call mem_deallocate(this%ionper)
191  call mem_deallocate(this%lastonper)

◆ get_block_data()

subroutine numericalpackagemodule::get_block_data ( class(numericalpackagetype this,
character(len=24), dimension(:), intent(in)  tags,
logical, dimension(:), intent(inout)  lfound,
character(len=24), dimension(:), intent(in), optional  varinames 
)

Generic method to read data in the GRIDDATA block for a package.

Parameters
thisNumericalPackageType object
[in]tagsvector with variable tags
[in,out]lfoundboolean vector indicating of a variable tag was found
[in]varinamesoptional vector of variable names

Definition at line 228 of file NumericalPackage.f90.

229  ! -- modules
231  ! -- dummy variables
232  class(NumericalPackageType) :: this !< NumericalPackageType object
233  character(len=24), dimension(:), intent(in) :: tags !< vector with variable tags
234  logical, dimension(:), intent(inout) :: lfound !< boolean vector indicating of a variable tag was found
235  character(len=24), dimension(:), intent(in), optional :: varinames !< optional vector of variable names
236  ! -- local variables
237  logical :: lkeyword
238  logical :: endOfBlock
239  integer(I4B) :: nsize
240  integer(I4B) :: j
241  character(len=24) :: tmpvar
242  character(len=LENVARNAME) :: varname
243  character(len=LINELENGTH) :: keyword
244  character(len=:), allocatable :: line
245  integer(I4B) :: istart, istop, lloc
246  integer(I4B), dimension(:), pointer, contiguous :: aint
247  real(DP), dimension(:), pointer, contiguous :: adbl
248  !
249  ! -- initialize nsize
250  nsize = size(tags)
251  do
252  call this%parser%GetNextLine(endofblock)
253  if (endofblock) exit
254  call this%parser%GetStringCaps(keyword)
255  call this%parser%GetRemainingLine(line)
256  lkeyword = .false.
257  lloc = 1
258  tag_iter: do j = 1, nsize
259  if (trim(adjustl(keyword)) == trim(adjustl(tags(j)))) then
260  lkeyword = .true.
261  lfound(j) = .true.
262  if (present(varinames)) then
263  tmpvar = adjustl(varinames(j))
264  else
265  tmpvar = adjustl(tags(j))
266  end if
267  varname = tmpvar(1:lenvarname)
268  if (keyword(1:1) == 'I') then
269  call mem_setptr(aint, trim(varname), trim(this%memoryPath))
270  call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
271  this%parser%iuactive, aint, tags(j))
272  else
273  call mem_setptr(adbl, trim(varname), trim(this%memoryPath))
274  call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
275  this%parser%iuactive, adbl, tags(j))
276  end if
277  exit tag_iter
278  end if
279  end do tag_iter
280  if (.not. lkeyword) then
281  write (errmsg, '(a,a)') 'Unknown GRIDDATA tag: ', &
282  trim(keyword)
283  call store_error(errmsg)
284  call this%parser%StoreErrorUnit()
285  end if
286  end do
Here is the call graph for this function:

◆ read_check_ionper()

subroutine numericalpackagemodule::read_check_ionper ( class(numericalpackagetype), intent(inout)  this)

Generic method to read and check ionperiod, which is used to determine if new period data should be read from the input file. The check of ionperiod also makes sure periods are increasing in subsequent period data blocks.

Parameters
[in,out]thisNumericalPackageType object

Definition at line 202 of file NumericalPackage.f90.

203  ! -- modules
204  use tdismodule, only: kper
205  ! -- dummy variables
206  class(NumericalPackageType), intent(inout) :: this !< NumericalPackageType object
207  !
208  ! -- save last value and read period number
209  this%lastonper = this%ionper
210  this%ionper = this%parser%GetInteger()
211  !
212  ! -- make check
213  if (this%ionper <= this%lastonper) then
214  write (errmsg, '(a, i0, a, i0, a, i0, a)') &
215  'Error in stress period ', kper, &
216  '. Period numbers not increasing. Found ', this%ionper, &
217  ' but last period block was assigned ', this%lastonper, '.'
218  call store_error(errmsg)
219  call this%parser%StoreErrorUnit()
220  end if
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:23
Here is the call graph for this function:

◆ set_names()

subroutine numericalpackagemodule::set_names ( class(numericalpackagetype), intent(inout)  this,
integer(i4b), intent(in)  ibcnum,
character(len=*), intent(in)  name_model,
character(len=*), intent(in)  pakname,
character(len=*), intent(in)  ftype,
character(len=*), intent(in), optional  input_mempath 
)
private

Method to assign the filtyp (ftype), the model name, and package name for a package. This method also creates the memoryPath and memoryPathModel that is used by the memory manager when variables are allocated.

Parameters
[in,out]thisNumericalPackageType object
[in]ibcnumunique package number
[in]name_modelname of the model
[in]paknamename of the package
[in]ftypepackage type

Definition at line 69 of file NumericalPackage.f90.

70  ! -- dummy variables
71  class(NumericalPackageType), intent(inout) :: this !< NumericalPackageType object
72  integer(I4B), intent(in) :: ibcnum !< unique package number
73  character(len=*), intent(in) :: name_model !< name of the model
74  character(len=*), intent(in) :: pakname !< name of the package
75  character(len=*), intent(in) :: ftype !< package type
76  character(len=*), optional, intent(in) :: input_mempath !< input_mempath
77  !
78  ! -- set names
79  this%filtyp = ftype
80  this%name_model = name_model
81  if (present(input_mempath)) this%input_mempath = input_mempath
82  if (pakname == '') then
83  write (this%packName, '(a, i0)') trim(ftype)//'-', ibcnum
84  else
85  !
86  ! -- Ensure pakname has no spaces
87  if (index(trim(pakname), ' ') > 0) then
88  errmsg = 'Package name contains spaces: '//trim(pakname)
89  call store_error(errmsg)
90  errmsg = 'Remove spaces from name.'
91  call store_error(errmsg, terminate=.true.)
92  end if
93  !
94  this%packName = pakname
95  end if
96  this%memoryPath = create_mem_path(name_model, this%packName)
97  this%memoryPathModel = create_mem_path(name_model)
Here is the call graph for this function: