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

This module contains common time-varying property functionality. More...

Data Types

type  tvbasetype
interface  ar_set_pointers
 Announce package and set pointers to variables. More...
interface  apply_row_changes
 Apply this node's current input value(s) to the model property array(s). More...
interface  set_changed_at
 Mark property changes as having occurred at (kper, kstp). More...
interface  reset_change_flags
 Clear all per-node change flags. More...
interface  validate_change
 Check that a given property value is valid. More...

Functions/Subroutines

subroutine init (this, name_model, pakname, ftype, mempath, inunit, iout)
 Initialize the TvBaseType object.
subroutine tvbase_allocate_scalars (this)
 Allocate scalar variables.
subroutine tvbase_source_options (this)
 Source common options from the input memory path.
subroutine tvbase_source_package_options (this)
 Source package-specific options from the input memory path.
subroutine ar (this, dis)
 Allocate and read static data for the package.
subroutine rp (this)
 Read and prepare stress period data for the package.
subroutine ad (this)
 Apply advanced values at each time step.
subroutine sync_node_changes (this)
 Sync every tracked node's current input value into the model property array(s) it belongs to (e.g. NPF's K11).
integer(i4b) function cellid_to_nodeu (this, n)
 Return the unreduced node number for CELLID row n.
subroutine, public tvbase_da (this)
 Deallocate package memory.

Detailed Description

This module contains methods implementing functionality common to both time-varying hydraulic conductivity (TVK) and time-varying storage (TVS) packages.

Function/Subroutine Documentation

◆ ad()

subroutine tvbasemodule::ad ( class(tvbasetype) this)
private

Definition at line 270 of file TvBase.f90.

271 ! -- dummy
272 class(TvBaseType) :: this
273 !
274 ! -- no-op when timeseries aren't active.
275 if (.not. this%ts_active) return
276 !
277 call this%sync_node_changes()

◆ ar()

subroutine tvbasemodule::ar ( class(tvbasetype) this,
class(disbasetype), intent(in), pointer dis )
private

Definition at line 212 of file TvBase.f90.

213 ! -- dummy
214 class(TvBaseType) :: this
215 class(DisBaseType), pointer, intent(in) :: dis
216 !
217 this%dis => dis
218 call this%ar_set_pointers()
219 !
220 call this%source_options()
221 !
222 ! -- set input mempath pointers
223 call mem_setptr(this%cellid, 'CELLID', this%input_mempath)
224 call this%tracked_nodeu%init()
225 !
226 if (count_errors() > 0) then
227 call store_error_filename(this%input_fname)
228 end if
Here is the call graph for this function:

◆ cellid_to_nodeu()

integer(i4b) function tvbasemodule::cellid_to_nodeu ( class(tvbasetype) this,
integer(i4b), intent(in) n )
private
Parameters
[in]nrow index in the period-data arrays

Definition at line 307 of file TvBase.f90.

308 ! -- dummy
309 class(TvBaseType) :: this
310 integer(I4B), intent(in) :: n !< row index in the period-data arrays
311 ! -- return
312 integer(I4B) :: nodeu
313 !
314 if (this%dis%ndim == 1) then
315 nodeu = this%cellid(1, n)
316 elseif (this%dis%ndim == 2) then
317 nodeu = get_node(this%cellid(1, n), 1, &
318 this%cellid(2, n), &
319 this%dis%mshape(1), 1, &
320 this%dis%mshape(2))
321 else
322 nodeu = get_node(this%cellid(1, n), &
323 this%cellid(2, n), &
324 this%cellid(3, n), &
325 this%dis%mshape(1), &
326 this%dis%mshape(2), &
327 this%dis%mshape(3))
328 end if
Here is the call graph for this function:

◆ init()

subroutine tvbasemodule::init ( class(tvbasetype) this,
character(len=*), intent(in) name_model,
character(len=*), intent(in) pakname,
character(len=*), intent(in) ftype,
character(len=*), intent(in) mempath,
integer(i4b), intent(in) inunit,
integer(i4b), intent(in) iout )
private

Allocate and initialize data members of the object.

Definition at line 136 of file TvBase.f90.

137 ! -- dummy
138 class(TvBaseType) :: this
139 character(len=*), intent(in) :: name_model
140 character(len=*), intent(in) :: pakname
141 character(len=*), intent(in) :: ftype
142 character(len=*), intent(in) :: mempath
143 integer(I4B), intent(in) :: inunit
144 integer(I4B), intent(in) :: iout
145 !
146 call this%set_names(1, name_model, pakname, ftype, mempath)
147 call this%tvbase_allocate_scalars()
148 this%inunit = inunit
149 this%iout = iout

◆ rp()

subroutine tvbasemodule::rp ( class(tvbasetype) this)
private

Definition at line 233 of file TvBase.f90.

234 ! -- dummy
235 class(TvBaseType) :: this
236 ! -- local variables
237 integer(I4B), pointer :: iper, nbound
238 integer(I4B) :: n, nodeu, nodeu_count
239 !
240 ! -- check last loaded input period
241 call mem_setptr(iper, 'IPER', this%input_mempath)
242 if (iper /= kper) return
243 !
244 ! -- record every node newly addressed by this period's own rows in
245 ! -- tracked_nodeu, so sync_node_changes never has to scan the full
246 ! -- node space to find which nodes have a live tracked value
247 call mem_setptr(nbound, 'NBOUND', this%input_mempath)
248 if (nbound > 0) then
249 nodeu_count = product(this%dis%mshape)
250 do n = 1, nbound
251 nodeu = this%cellid_to_nodeu(n)
252 if (nodeu < 1 .or. nodeu > nodeu_count) then
253 write (errmsg, '(a,i0,a)') &
254 'CELLID at PERIOD row ', n, ' is not in the active model domain.'
255 call store_error(errmsg)
256 cycle
257 end if
258 call this%tracked_nodeu%push_back_unique(nodeu)
259 end do
260 end if
261 !
262 ! -- When timeseries are active, ad applies values at every time step
263 if (this%ts_active) return
264 !
265 call this%sync_node_changes()
Here is the call graph for this function:

◆ sync_node_changes()

subroutine tvbasemodule::sync_node_changes ( class(tvbasetype) this)
private

Definition at line 283 of file TvBase.f90.

284 ! -- dummy
285 class(TvBaseType) :: this
286 ! -- local variables
287 integer(I4B) :: i, nodeu, node
288 !
289 if (this%tracked_nodeu%size <= 0) return
290 !
291 call this%set_changed_at(kper, kstp)
292 call this%reset_change_flags()
293 !
294 do i = 1, this%tracked_nodeu%size
295 nodeu = this%tracked_nodeu%at(i)
296 node = this%dis%get_nodenumber(nodeu, 1)
297 call this%apply_row_changes(nodeu, node)
298 end do
299 !
300 if (count_errors() > 0) then
301 call store_error_filename(this%input_fname)
302 end if
Here is the call graph for this function:

◆ tvbase_allocate_scalars()

subroutine tvbasemodule::tvbase_allocate_scalars ( class(tvbasetype) this)
private

Allocate scalar data members of the object.

Definition at line 156 of file TvBase.f90.

157 ! -- dummy
158 class(TvBaseType) :: this
159 !
160 ! -- Call standard NumericalPackageType allocate scalars
161 call this%NumericalPackageType%allocate_scalars()

◆ tvbase_da()

subroutine, public tvbasemodule::tvbase_da ( class(tvbasetype) this)

Deallocate package scalars and arrays.

Definition at line 335 of file TvBase.f90.

336 ! -- dummy
337 class(TvBaseType) :: this
338 !
339 nullify (this%cellid)
340 call this%tracked_nodeu%destroy()
341 call this%NumericalPackageType%da()
Here is the caller graph for this function:

◆ tvbase_source_options()

subroutine tvbasemodule::tvbase_source_options ( class(tvbasetype) this)
private

Source common options and call derived package routine to source and log any package-specific options within the same block.

Definition at line 169 of file TvBase.f90.

170 ! -- modules
172 ! -- dummy
173 class(TvBaseType) :: this
174 ! -- locals
175 integer(I4B) :: isize
176 logical(LGP) :: found_print_input
177 !
178 write (this%iout, '(1x,a)') &
179 'PROCESSING '//trim(adjustl(this%packName))//' OPTIONS'
180 !
181 call mem_set_value(this%iprpak, 'PRINT_INPUT', this%input_mempath, &
182 found_print_input)
183 !
184 if (found_print_input) then
185 write (this%iout, '(4x,a)') 'TIME-VARYING INPUT WILL BE PRINTED.'
186 end if
187 !
188 call get_isize('TS6_FILENAME', this%input_mempath, isize)
189 if (isize > 0) this%ts_active = .true.
190 !
191 ! -- source package-specific options
192 call this%source_package_options()
193 !
194 write (this%iout, '(1x,a)') &
195 'END OF '//trim(adjustl(this%packName))//' OPTIONS'
Here is the call graph for this function:

◆ tvbase_source_package_options()

subroutine tvbasemodule::tvbase_source_package_options ( class(tvbasetype) this)
private

Override in derived package to source and log package-specific options. Default implementation is a no-op.

Definition at line 203 of file TvBase.f90.

204 ! -- dummy
205 class(TvBaseType) :: this
206 !
207 ! -- no package-specific options in the base class