MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
tsp-apt.f90
Go to the documentation of this file.
1! -- Advanced Package Transport Module
2! -- This module contains most of the routines for simulating transport
3! -- through the advanced packages.
4! -- Future work:
5! * support decay, sorption
6! * dispersion in SFT and UZT?
7!
8! AFP flows (flowbudptr) index var ATP term Transport Type
9!---------------------------------------------------------------------------------
10
11! -- specialized terms in the flow budget
12! FLOW-JA-FACE idxbudfjf FLOW-JA-FACE cv2cv
13! GWF (aux FLOW-AREA) idxbudgwf GWF cv2gwf
14! STORAGE (aux VOLUME) idxbudsto none used for cv volumes
15! FROM-MVR idxbudfmvr FROM-MVR q * cext = this%qfrommvr(:) ! rhow*cpw is applied to various terms for heat transport
16! TO-MVR idxbudtmvr TO-MVR q * cfeat
17
18! -- generalized source/sink terms (except ET?)
19! RAINFALL idxbudrain RAINFALL q * crain
20! EVAPORATION idxbudevap EVAPORATION cfeat<cevap: q*cfeat, else: q*cevap ! latent heat may be applied for evaporative cooling
21! RUNOFF idxbudroff RUNOFF q * croff
22! EXT-INFLOW idxbudiflw EXT-INFLOW q * ciflw
23! WITHDRAWAL idxbudwdrl WITHDRAWAL q * cfeat
24! EXT-OUTFLOW idxbudoutf EXT-OUTFLOW q * cfeat
25
26! -- terms from a flow file that should be skipped
27! CONSTANT none none none
28! AUXILIARY none none none
29
30! -- terms that are written to the transport budget file
31! none none STORAGE (aux MASS) dM/dt
32! none none AUXILIARY none
33! none none CONSTANT accumulate
34!
35!
37
38 use kindmodule, only: dp, i4b, lgp
46 use simvariablesmodule, only: errmsg
47 use bndmodule, only: bndtype
48 use bndextmodule, only: bndexttype
49 use tspfmimodule, only: tspfmitype
53 use observemodule, only: observetype
56 use openspecmodule, only: access, form
57 use basedismodule, only: disbasetype
63
64 implicit none
65
66 public :: tspapttype
67 public :: apt_process_obsid
68 public :: apt_process_obsid12
69
70 character(len=LENFTYPE) :: ftype = 'APT'
71 character(len=LENVARNAME) :: text = ' APT'
72
73 type, extends(bndexttype) :: tspapttype
74
75 character(len=LENPACKAGENAME) :: flowpackagename = '' !< name of corresponding flow package
76 character(len=8), &
77 dimension(:), pointer, contiguous :: status => null() !< active, inactive, constant
78 character(len=LENAUXNAME) :: cauxfpconc = '' !< name of aux column in flow package auxvar array for concentration (or temperature)
79 integer(I4B), pointer :: iauxfpconc => null() !< column in flow package bound array to insert concs
80 integer(I4B), pointer :: imatrows => null() !< if active, add new rows to matrix
81 integer(I4B), pointer :: iprconc => null() !< print conc to listing file
82 integer(I4B), pointer :: iconcout => null() !< unit number for conc output file
83 integer(I4B), pointer :: ibudgetout => null() !< unit number for budget output file
84 integer(I4B), pointer :: ibudcsv => null() !< unit number for csv budget output file
85 integer(I4B), pointer :: ncv => null() !< number of control volumes
86 integer(I4B), pointer :: igwfaptpak => null() !< package number of corresponding this package
87 integer(I4B), pointer :: idxprepak => null() !< budget-object index that precedes package-specific budget objects
88 integer(I4B), pointer :: idxlastpak => null() !< budget-object index of last package-specific budget object
89 real(dp), dimension(:), pointer, contiguous :: strt => null() !< starting feature concentration (or temperature)
90 integer(I4B), dimension(:), pointer, contiguous :: idxlocnode => null() !< map position in global rhs and x array of pack entry
91 integer(I4B), dimension(:), pointer, contiguous :: idxpakdiag => null() !< map diag position of feature in global amat
92 integer(I4B), dimension(:), pointer, contiguous :: idxdglo => null() !< map position in global array of package diagonal row entries
93 integer(I4B), dimension(:), pointer, contiguous :: idxoffdglo => null() !< map position in global array of package off diagonal row entries
94 integer(I4B), dimension(:), pointer, contiguous :: idxsymdglo => null() !< map position in global array of package diagonal entries to model rows
95 integer(I4B), dimension(:), pointer, contiguous :: idxsymoffdglo => null() !< map position in global array of package off diagonal entries to model rows
96 integer(I4B), dimension(:), pointer, contiguous :: idxfjfdglo => null() !< map diagonal feature to feature in global amat
97 integer(I4B), dimension(:), pointer, contiguous :: idxfjfoffdglo => null() !< map off diagonal feature to feature in global amat
98 integer(I4B), dimension(:), pointer, contiguous :: iboundpak => null() !< package ibound
99 real(dp), dimension(:), pointer, contiguous :: xnewpak => null() !< feature concentration (or temperature) for current time step
100 real(dp), dimension(:), pointer, contiguous :: xoldpak => null() !< feature concentration (or temperature) from previous time step
101 real(dp), dimension(:), pointer, contiguous :: dbuff => null() !< temporary storage array
102 character(len=LENBOUNDNAME), &
103 dimension(:), pointer, contiguous :: featname => null()
104 real(dp), dimension(:), pointer, contiguous :: concfeat => null() !< concentration (or temperature) of the feature
105 type(tspfmitype), pointer :: fmi => null() !< pointer to fmi object
106 real(dp), dimension(:), pointer, contiguous :: qsto => null() !< mass (or energy) flux due to storage change
107 real(dp), dimension(:), pointer, contiguous :: ccterm => null() !< mass (or energy) flux required to maintain constant concentration (or temperature)
108 integer(I4B), pointer :: idxbudfjf => null() !< index of flow ja face in flowbudptr
109 integer(I4B), pointer :: idxbudgwf => null() !< index of gwf terms in flowbudptr
110 integer(I4B), pointer :: idxbudsto => null() !< index of storage terms in flowbudptr
111 integer(I4B), pointer :: idxbudtmvr => null() !< index of to mover terms in flowbudptr
112 integer(I4B), pointer :: idxbudfmvr => null() !< index of from mover terms in flowbudptr
113 integer(I4B), pointer :: idxbudaux => null() !< index of auxiliary terms in flowbudptr
114 integer(I4B), dimension(:), pointer, contiguous :: idxbudssm => null() !< flag that flowbudptr%buditem is a general solute source/sink
115 integer(I4B), pointer :: nconcbudssm => null() !< number of concbudssm terms (columns)
116 real(dp), dimension(:, :), pointer, contiguous :: concbudssm => null() !< user specified concentrations (or temperatures) for flow terms
117 real(dp), dimension(:), pointer, contiguous :: qmfrommvr => null() !< a mass or energy flow coming from the mover that needs to be added
118 real(dp), pointer :: eqnsclfac => null() !< governing equation scale factor; =1. for solute; =rhow*cpw for energy
119 character(len=LENVARNAME) :: depvartype = '' !< stores string identifying dependent variable type, depending on model type
120 character(len=LENVARNAME) :: depvarunit = '' !< "mass" or "energy"
121 character(len=LENVARNAME) :: depvarunitabbrev = '' !< "M" or "E"
122 !
123 ! -- pointer to flow package boundary
124 type(bndtype), pointer :: flowpackagebnd => null()
125 !
126 ! -- budget objects
127 type(budgetobjecttype), pointer :: budobj => null() !< apt solute budget object
128 type(budgetobjecttype), pointer :: flowbudptr => null() !< GWF flow budget object
129 !
130 ! -- table objects
131 type(tabletype), pointer :: dvtab => null()
132
133 contains
134
136 procedure :: bnd_ac => apt_ac
137 procedure :: bnd_mc => apt_mc
138 procedure :: bnd_ar => apt_ar
139 procedure :: bnd_rp => apt_rp
140 procedure :: bnd_ad => apt_ad
141 procedure, public :: apt_ad_resync !< made public for sft/sfe
142 procedure :: bnd_reset => apt_reset
143 procedure :: bnd_fc => apt_fc
144 procedure, public :: apt_fc_expanded ! Made public for uze
145 procedure, public :: apt_ad_chk
146 procedure :: pak_fc_expanded
147 procedure, private :: apt_fc_nonexpanded
148 procedure, public :: apt_cfupdate ! Made public for uze
149 procedure :: apt_check_valid
150 procedure :: apt_setting_value
151 procedure :: apt_ad_ts
153 procedure :: bnd_cq => apt_cq
155 procedure :: bnd_ot_dv => apt_ot_dv
157 procedure :: bnd_da => apt_da
158 procedure :: allocate_scalars
162 procedure :: find_apt_package
163 procedure :: apt_solve
164 procedure :: pak_solve
167 procedure :: apt_source_cvs
168 procedure :: read_initial_attr => apt_read_initial_attr
169 procedure :: define_listlabel
170 ! -- methods for observations
172 procedure :: bnd_df_obs => apt_df_obs
173 procedure :: pak_df_obs
174 procedure :: pak_rp_obs
175 procedure :: bnd_rp_obs => apt_rp_obs
176 procedure :: rp_obs_byfeature
177 procedure :: rp_obs_budterm
178 procedure :: rp_obs_flowjaface
179 procedure :: bnd_bd_obs => apt_bd_obs
180 procedure :: pak_bd_obs
181 procedure :: pak_get_nbudterms
182 procedure :: apt_setup_budobj
183 procedure :: pak_setup_budobj
184 procedure :: apt_fill_budobj
185 procedure :: pak_fill_budobj
186 procedure, public :: apt_get_volumes !< made public for sft/sfe
187 procedure, public :: apt_stor_term
188 procedure, public :: apt_tmvr_term
189 procedure, public :: apt_fmvr_term !< made public for uze
190 procedure, public :: apt_fjf_term !< made public for uze
191 procedure, private :: apt_copy2flowp
192 procedure, private :: apt_setup_tableobj
193 procedure, public :: get_mvr_depvar
194
195 end type tspapttype
196
197contains
198
199 !> @brief Add package connection to matrix
200 !<
201 subroutine apt_ac(this, moffset, sparse)
203 use sparsemodule, only: sparsematrix
204 ! -- dummy
205 class(tspapttype), intent(inout) :: this
206 integer(I4B), intent(in) :: moffset
207 type(sparsematrix), intent(inout) :: sparse
208 ! -- local
209 integer(I4B) :: i, n
210 integer(I4B) :: jj, jglo
211 integer(I4B) :: nglo
212 ! -- format
213 !
214 ! -- Add package rows to sparse
215 if (this%imatrows /= 0) then
216 !
217 ! -- diagonal
218 do n = 1, this%ncv
219 nglo = moffset + this%dis%nodes + this%ioffset + n
220 call sparse%addconnection(nglo, nglo, 1)
221 end do
222 !
223 ! -- apt-gwf connections
224 do i = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
225 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(i)
226 jj = this%flowbudptr%budterm(this%idxbudgwf)%id2(i)
227 nglo = moffset + this%dis%nodes + this%ioffset + n
228 jglo = jj + moffset
229 call sparse%addconnection(nglo, jglo, 1)
230 call sparse%addconnection(jglo, nglo, 1)
231 end do
232 !
233 ! -- apt-apt connections
234 if (this%idxbudfjf /= 0) then
235 do i = 1, this%flowbudptr%budterm(this%idxbudfjf)%maxlist
236 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(i)
237 jj = this%flowbudptr%budterm(this%idxbudfjf)%id2(i)
238 nglo = moffset + this%dis%nodes + this%ioffset + n
239 jglo = moffset + this%dis%nodes + this%ioffset + jj
240 call sparse%addconnection(nglo, jglo, 1)
241 end do
242 end if
243 end if
244 end subroutine apt_ac
245
246 !> @brief Advanced package transport map package connections to matrix
247 !<
248 subroutine apt_mc(this, moffset, matrix_sln)
249 use sparsemodule, only: sparsematrix
250 ! -- dummy
251 class(tspapttype), intent(inout) :: this
252 integer(I4B), intent(in) :: moffset
253 class(matrixbasetype), pointer :: matrix_sln
254 ! -- local
255 integer(I4B) :: n, j, iglo, jglo
256 integer(I4B) :: ipos
257 ! -- format
258 !
259 ! -- allocate memory for index arrays
260 call this%apt_allocate_index_arrays()
261 !
262 ! -- store index positions
263 if (this%imatrows /= 0) then
264 !
265 ! -- Find the position of each connection in the global ia, ja structure
266 ! and store them in idxglo. idxglo allows this model to insert or
267 ! retrieve values into or from the global A matrix
268 ! -- apt rows
269 do n = 1, this%ncv
270 this%idxlocnode(n) = this%dis%nodes + this%ioffset + n
271 iglo = moffset + this%dis%nodes + this%ioffset + n
272 this%idxpakdiag(n) = matrix_sln%get_position_diag(iglo)
273 end do
274 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
275 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
276 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
277 iglo = moffset + this%dis%nodes + this%ioffset + n
278 jglo = j + moffset
279 this%idxdglo(ipos) = matrix_sln%get_position_diag(iglo)
280 this%idxoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
281 end do
282 !
283 ! -- apt contributions to gwf portion of global matrix
284 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
285 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
286 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
287 iglo = j + moffset
288 jglo = moffset + this%dis%nodes + this%ioffset + n
289 this%idxsymdglo(ipos) = matrix_sln%get_position_diag(iglo)
290 this%idxsymoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
291 end do
292 !
293 ! -- apt-apt contributions to gwf portion of global matrix
294 if (this%idxbudfjf /= 0) then
295 do ipos = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
296 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(ipos)
297 j = this%flowbudptr%budterm(this%idxbudfjf)%id2(ipos)
298 iglo = moffset + this%dis%nodes + this%ioffset + n
299 jglo = moffset + this%dis%nodes + this%ioffset + j
300 this%idxfjfdglo(ipos) = matrix_sln%get_position_diag(iglo)
301 this%idxfjfoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
302 end do
303 end if
304 end if
305 end subroutine apt_mc
306
307 !> @brief Advanced package transport allocate and read (ar) routine
308 !<
309 subroutine apt_ar(this)
310 ! -- modules
311 ! -- dummy
312 class(tspapttype), intent(inout) :: this
313 ! -- local
314 integer(I4B) :: j
315 logical :: found
316 ! -- formats
317 character(len=*), parameter :: fmtapt = &
318 "(1x,/1x,'APT -- ADVANCED PACKAGE TRANSPORT, VERSION 1, 3/5/2020', &
319 &' INPUT READ FROM UNIT ', i0, //)"
320 !
321 ! -- Get obs setup
322 call this%obs%obs_ar()
323 !
324 ! --print a message identifying the apt package.
325 write (this%iout, fmtapt) this%inunit
326 !
327 ! -- Allocate arrays
328 call this%apt_allocate_arrays()
329 !
330 ! -- alias deprecated variable names
331 call this%apt_checkin_deprecated_names()
332 !
333 ! -- read optional initial package parameters
334 call this%read_initial_attr()
335 !
336 ! -- Find the package index in the GWF model or GWF budget file
337 ! for the corresponding apt flow package
338 call this%fmi%get_package_index(this%flowpackagename, this%igwfaptpak)
339 !
340 ! -- Tell fmi that this package is being handled by APT, otherwise
341 ! SSM would handle the flows into GWT from this pack. Then point the
342 ! fmi data for an advanced package to xnewpak and qmfrommvr
343 this%fmi%iatp(this%igwfaptpak) = 1
344 this%fmi%datp(this%igwfaptpak)%concpack => this%get_mvr_depvar()
345 this%fmi%datp(this%igwfaptpak)%qmfrommvr => this%qmfrommvr
346 !
347 ! -- If there is an associated flow package and the user wishes to put
348 ! simulated concentrations (or temperatures) into a aux variable
349 ! column, then find the column number.
350 if (associated(this%flowpackagebnd)) then
351 if (this%cauxfpconc /= '') then
352 found = .false.
353 do j = 1, this%flowpackagebnd%naux
354 if (this%flowpackagebnd%auxname(j) == this%cauxfpconc) then
355 this%iauxfpconc = j
356 found = .true.
357 exit
358 end if
359 end do
360 if (this%iauxfpconc == 0) then
361 errmsg = 'Could not find auxiliary variable '// &
362 trim(adjustl(this%cauxfpconc))//' in flow package '// &
363 trim(adjustl(this%flowpackagename))
364 call store_error(errmsg)
365 call store_error_filename(this%input_fname)
366 else
367 ! -- tell package not to update this auxiliary variable
368 this%flowpackagebnd%noupdateauxvar(this%iauxfpconc) = 1
369 call this%apt_copy2flowp()
370 end if
371 end if
372 end if
373 end subroutine apt_ar
374
375 !> @brief Advanced package transport read and prepare (rp) routine
376 !!
377 !! This subroutine calls the attached packages' read and prepare routines.
378 !<
379 subroutine apt_rp(this)
380 use tdismodule, only: kper
381 use constantsmodule, only: lenvarname
382 ! -- dummy
383 class(tspapttype), intent(inout) :: this
384 ! -- local
385 integer(I4B) :: n, itemno, igwfnode, isize
386 integer(I4B), pointer :: nbound => null()
387 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
388 type(characterstringtype), dimension(:), pointer, contiguous :: &
389 setting => null()
390 type(characterstringtype), dimension(:), pointer, contiguous :: &
391 status => null()
392 type(characterstringtype), dimension(:), pointer, contiguous :: &
393 auxname => null()
394 real(DP), dimension(:), pointer, contiguous :: auxval => null()
395 character(len=LINELENGTH) :: str
396 character(len=LENVARNAME) :: key
397 character(len=LINELENGTH) :: title
398 character(len=LINELENGTH) :: text
399 character(len=LENVARNAME) :: auxnamestr
400 character(len=*), parameter :: fmtlsp = &
401 "(1X,/1X,'REUSING ',A,'S FROM LAST &
402 &STRESS PERIOD')"
403 !
404 ! -- set nbound to maxbound
405 this%nbound = this%maxbound
406 !
407 ! -- check if the input context has data for this stress period
408 if (this%iper == kper) then
409 !
410 ! -- get period data arrays
411 call mem_setptr(nbound, 'NBOUND', this%input_mempath)
412 !
413 ! -- setup table to echo period data
414 if (this%iprpak /= 0) then
415 title = trim(adjustl(this%text))//' PACKAGE ('// &
416 trim(adjustl(this%packName))//') DATA FOR PERIOD'
417 write (title, '(a,1x,i6)') trim(adjustl(title)), kper
418 call table_cr(this%inputtab, this%packName, title)
419 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
420 text = 'NUMBER'
421 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
422 text = 'KEYWORD'
423 call this%inputtab%initialize_column(text, 20, alignment=tableft)
424 do n = 1, 2
425 write (text, '(a,1x,i6)') 'VALUE', n
426 call this%inputtab%initialize_column(text, 15, alignment=tabcenter)
427 end do
428 end if
429 !
430 if (nbound > 0) then
431 call mem_setptr(ifno, 'IFNO', this%input_mempath)
432 call mem_setptr(setting, 'SETTING', this%input_mempath)
433 call mem_setptr(status, 'STATUS', this%input_mempath)
434 if (this%naux > 0) then
435 call get_isize('AUXVAL', this%input_mempath, isize)
436 if (isize > 0) then
437 call mem_setptr(auxname, 'AUXNAME', this%input_mempath)
438 call mem_setptr(auxval, 'AUXVAL', this%input_mempath)
439 end if
440 end if
441 !
442 do n = 1, nbound
443 itemno = ifno(n)
444 if (this%apt_check_valid(itemno) /= 0) cycle
445 key = setting(n)
446 !
447 ! -- STATUS (string; not TS-capable)
448 if (trim(key) == 'STATUS') then
449 str = status(n)
450 select case (trim(str))
451 case ('CONSTANT')
452 this%iboundpak(itemno) = -1
453 case ('INACTIVE')
454 this%iboundpak(itemno) = 0
455 case ('ACTIVE')
456 this%iboundpak(itemno) = 1
457 case default
458 write (errmsg, '(a,a)') &
459 'Unknown '//trim(this%text)//' status keyword: ', &
460 trim(str)//'.'
461 call store_error(errmsg)
462 end select
463 this%status(itemno) = trim(str)
464 if (this%iprpak /= 0) then
465 call this%inputtab%add_term(itemno)
466 call this%inputtab%add_term(trim(key))
467 call this%inputtab%add_term(trim(str))
468 call this%inputtab%add_term(' ')
469 end if
470 !
471 ! -- CONCENTRATION/TEMPERATURE: value already resolved by the
472 ! input context; echo it directly
473 else if (trim(key) == trim(this%depvartype)) then
474 if (this%iprpak /= 0) then
475 call this%inputtab%add_term(itemno)
476 call this%inputtab%add_term(trim(key))
477 call this%inputtab%add_term(this%concfeat(itemno))
478 call this%inputtab%add_term(' ')
479 end if
480 !
481 ! -- AUXILIARY: value already resolved by the input context;
482 ! echo the raw auxname and resolved auxval for this row
483 else if (trim(key) == 'PERIOD_AUXILIARY') then
484 if (this%iprpak /= 0) then
485 auxnamestr = auxname(n)
486 call this%inputtab%add_term(itemno)
487 call this%inputtab%add_term('AUXILIARY')
488 call this%inputtab%add_term(trim(auxnamestr))
489 call this%inputtab%add_term(auxval(n))
490 end if
491 !
492 ! -- package-specific setting; value already resolved by the
493 ! input context, package supplies it for the table
494 else
495 if (this%iprpak /= 0) then
496 call this%inputtab%add_term(itemno)
497 call this%inputtab%add_term(trim(key))
498 call this%inputtab%add_term(this%apt_setting_value(itemno, key))
499 call this%inputtab%add_term(' ')
500 end if
501 end if
502 end do
503 end if
504 !
505 if (this%iprpak /= 0) then
506 call this%inputtab%finalize_table()
507 end if
508 !
509 else
510 write (this%iout, fmtlsp) trim(this%filtyp)
511 end if
512 !
513 ! -- write summary of stress period error messages
514 if (count_errors() > 0) then
515 call store_error_filename(this%input_fname)
516 end if
517 !
518 ! -- fill nodelist every period; non-vertical connections are not updated
519 ! by cf so must be set here
520 do n = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
521 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
522 this%nodelist(n) = igwfnode
523 end do
524 end subroutine apt_rp
525
526 subroutine apt_ad_chk(this)
527 ! -- dummy
528 class(tspapttype), intent(inout) :: this
529 ! function available for override by packages
530 end subroutine apt_ad_chk
531
532 !> @brief Advanced package transport routine
533 !!
534 !! Determine if a valid feature number has been specified.
535 !<
536 function apt_check_valid(this, itemno) result(ierr)
537 ! -- return
538 integer(I4B) :: ierr
539 ! -- dummy
540 class(tspapttype), intent(inout) :: this
541 integer(I4B), intent(in) :: itemno
542 ! -- formats
543 ierr = 0
544 if (itemno < 1 .or. itemno > this%ncv) then
545 write (errmsg, '(a,1x,i6,1x,a,1x,i6)') &
546 'Featureno ', itemno, 'must be > 0 and <= ', this%ncv
547 call store_error(errmsg)
548 ierr = 1
549 end if
550 end function apt_check_valid
551
552 !> @brief Advanced package transport utility function
553 !!
554 !! Set the concentration (or temperature) to be used by either MVT or MVE
555 !<
556 function get_mvr_depvar(this)
557 ! -- dummy
558 class(tspapttype) :: this
559 ! -- return
560 real(dp), dimension(:), contiguous, pointer :: get_mvr_depvar
561 !
562 get_mvr_depvar => this%xnewpak
563 end function get_mvr_depvar
564
565 !> @brief Advanced package transport routine
566 !!
567 !! Add package connections to matrix
568 !<
569 subroutine apt_ad(this)
570 ! -- dummy
571 class(tspapttype) :: this
572 !
573 ! -- sync PACKAGEDATA AUX TS and advance observations
574 call this%BndExtType%bnd_ad()
575 !
576 call this%apt_ad_resync()
577 end subroutine apt_ad
578
579 !> @brief Per-timestep TS re-sync and state update
580 !!
581 !! Called directly by packages that override bnd_ad (e.g. SFT/SFE) so
582 !! apt_ad_ts/apt_ad_chk still dispatch to their own overrides.
583 !<
584 subroutine apt_ad_resync(this)
585 ! -- modules
587 use tdismodule, only: kstp
588 ! -- dummy
589 class(tspapttype) :: this
590 ! -- local
591 integer(I4B) :: n
592 integer(I4B) :: j, iaux
593 !
594 ! -- re-sync period TS; package-specific fields via apt_ad_ts
595 if (this%ts_active) then
596 call this%apt_ad_ts()
597 end if
598 !
599 ! -- update auxiliary variables by copying from featureauxvar into
600 ! bndpackage auxvar for GWF budget file output; featureauxvar can
601 ! only have changed at period start (kstp==1) or, when TS-active,
602 ! this timestep's apt_ad_ts() call above
603 if (this%naux > 0 .and. (kstp == 1 .or. this%ts_active)) then
604 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
605 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
606 do iaux = 1, this%naux
607 this%auxvar(iaux, j) = this%featureauxvar(iaux, n)
608 end do
609 end do
610 end if
611 !
612 ! -- copy xnew into xold and set xnewpak to specified concentration (or
613 ! temperature) for constant concentration/temperature features
614 if (ifailedstepretry == 0) then
615 do n = 1, this%ncv
616 this%xoldpak(n) = this%xnewpak(n)
617 if (this%iboundpak(n) < 0) then
618 this%xnewpak(n) = this%concfeat(n)
619 end if
620 end do
621 else
622 do n = 1, this%ncv
623 this%xnewpak(n) = this%xoldpak(n)
624 if (this%iboundpak(n) < 0) then
625 this%xnewpak(n) = this%concfeat(n)
626 end if
627 end do
628 end if
629 !
630 ! -- run package-specific checks
631 call this%apt_ad_chk()
632 end subroutine apt_ad_resync
633
634 !> @brief Virtual hook: called every timestep, after the time series
635 !! manager advances, before apt_ad_chk. No-op extension point for
636 !! packages to override.
637 !<
638 subroutine apt_ad_ts(this)
639 ! -- dummy
640 class(tspapttype), intent(inout) :: this
641 end subroutine apt_ad_ts
642
643 !> @brief Virtual hook: value for a package-specific PERIOD setting.
644 !! Override in individual packages to supply the already-resolved value
645 !! for a PERIOD field beyond STATUS, CONCENTRATION/TEMPERATURE, and
646 !! AUXILIARY, so the shared apt_rp table echo can print it.
647 !<
648 function apt_setting_value(this, itemno, key) result(val)
649 ! -- dummy
650 class(tspapttype), intent(inout) :: this
651 integer(I4B), intent(in) :: itemno !< feature number
652 character(len=*), intent(in) :: key !< SETTING dispatch key
653 real(dp) :: val
654 val = dzero
655 end function apt_setting_value
656
657 !> @brief Override bnd reset for custom mover logic
658 subroutine apt_reset(this)
659 class(tspapttype) :: this !< GwtAptType object
660 ! local
661 integer(I4B) :: i
662 !
663 do i = 1, size(this%qmfrommvr)
664 this%qmfrommvr(i) = dzero
665 end do
666 end subroutine apt_reset
667
668 subroutine apt_fc(this, rhs, ia, idxglo, matrix_sln)
669 ! -- modules
670 ! -- dummy
671 class(tspapttype) :: this
672 real(DP), dimension(:), intent(inout) :: rhs
673 integer(I4B), dimension(:), intent(in) :: ia
674 integer(I4B), dimension(:), intent(in) :: idxglo
675 class(matrixbasetype), pointer :: matrix_sln
676 ! -- local
677 !
678 ! -- Call fc depending on whether or not a matrix is expanded or not
679 if (this%imatrows == 0) then
680 call this%apt_fc_nonexpanded(rhs, ia, idxglo, matrix_sln)
681 else
682 call this%apt_fc_expanded(rhs, ia, idxglo, matrix_sln)
683 end if
684 end subroutine apt_fc
685
686 !> @brief Advanced package transport fill coefficient (fc) method
687 !!
688 !! Routine to formulate the nonexpanded matrix case in which feature
689 !! concentrations (or temperatures) are solved explicitly
690 !<
691 subroutine apt_fc_nonexpanded(this, rhs, ia, idxglo, matrix_sln)
692 ! -- modules
693 ! -- dummy
694 class(tspapttype) :: this
695 real(DP), dimension(:), intent(inout) :: rhs
696 integer(I4B), dimension(:), intent(in) :: ia
697 integer(I4B), dimension(:), intent(in) :: idxglo
698 class(matrixbasetype), pointer :: matrix_sln
699 ! -- local
700 integer(I4B) :: j, igwfnode, idiag
701 !
702 ! -- solve for concentration (or temperatures) in the features
703 call this%apt_solve()
704 !
705 ! -- add hcof and rhs terms (from apt_solve) to the gwf matrix
706 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
707 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
708 if (this%ibound(igwfnode) < 1) cycle
709 idiag = idxglo(ia(igwfnode))
710 call matrix_sln%add_value_pos(idiag, this%hcof(j))
711 rhs(igwfnode) = rhs(igwfnode) + this%rhs(j)
712 end do
713 end subroutine apt_fc_nonexpanded
714
715 !> @brief Advanced package transport fill coefficient (fc) method
716 !!
717 !! Routine to formulate the expanded matrix case in which new rows are added
718 !! to the system of equations for each advanced package transport feature
719 !<
720 subroutine apt_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
721 ! -- modules
722 ! -- dummy
723 class(tspapttype) :: this
724 real(DP), dimension(:), intent(inout) :: rhs
725 integer(I4B), dimension(:), intent(in) :: ia
726 integer(I4B), dimension(:), intent(in) :: idxglo
727 class(matrixbasetype), pointer :: matrix_sln
728 ! -- local
729 integer(I4B) :: j, n, n1, n2
730 integer(I4B) :: iloc
731 integer(I4B) :: iposd, iposoffd
732 integer(I4B) :: ipossymd, ipossymoffd
733 real(DP) :: cold
734 real(DP) :: qbnd, qbnd_scaled
735 real(DP) :: omega
736 real(DP) :: rrate
737 real(DP) :: rhsval
738 real(DP) :: hcofval
739 !
740 ! -- call the specific method for the advanced transport package, such as
741 ! what would be overridden by
742 ! GwtLktType, GwtSftType, GwtMwtType, GwtUztType
743 ! This routine will add terms for rainfall, runoff, or other terms
744 ! specific to the package
745 call this%pak_fc_expanded(rhs, ia, idxglo, matrix_sln)
746 !
747 ! -- mass (or energy) storage in features
748 do n = 1, this%ncv
749 cold = this%xoldpak(n)
750 iloc = this%idxlocnode(n)
751 iposd = this%idxpakdiag(n)
752 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
753 call matrix_sln%add_value_pos(iposd, hcofval)
754 rhs(iloc) = rhs(iloc) + rhsval
755 end do
756 !
757 ! -- add to mover contribution
758 if (this%idxbudtmvr /= 0) then
759 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
760 call this%apt_tmvr_term(j, n1, n2, rrate, rhsval, hcofval)
761 iloc = this%idxlocnode(n1)
762 iposd = this%idxpakdiag(n1)
763 call matrix_sln%add_value_pos(iposd, hcofval)
764 rhs(iloc) = rhs(iloc) + rhsval
765 end do
766 end if
767 !
768 ! -- add from mover contribution
769 if (this%idxbudfmvr /= 0) then
770 do n = 1, this%ncv
771 rhsval = this%qmfrommvr(n) ! this will already be in terms of energy for heat transport
772 iloc = this%idxlocnode(n)
773 rhs(iloc) = rhs(iloc) - rhsval
774 end do
775 end if
776 !
777 ! -- go through each apt-gwf connection
778 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
779 !
780 ! -- set n to feature number and process if active feature
781 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
782 if (this%iboundpak(n) /= 0) then
783 !
784 ! -- set acoef and rhs to negative so they are relative to apt and not gwt
785 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
786 omega = dzero
787 if (qbnd < dzero) omega = done
788 qbnd_scaled = qbnd * this%eqnsclfac
789 !
790 ! -- add to apt row
791 iposd = this%idxdglo(j)
792 iposoffd = this%idxoffdglo(j)
793 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
794 call matrix_sln%add_value_pos(iposoffd, (done - omega) * qbnd_scaled)
795 !
796 ! -- add to gwf row for apt connection
797 ipossymd = this%idxsymdglo(j)
798 ipossymoffd = this%idxsymoffdglo(j)
799 call matrix_sln%add_value_pos(ipossymd, -(done - omega) * qbnd_scaled)
800 call matrix_sln%add_value_pos(ipossymoffd, -omega * qbnd_scaled)
801 end if
802 end do
803 !
804 ! -- go through each apt-apt connection
805 if (this%idxbudfjf /= 0) then
806 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
807 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(j)
808 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(j)
809 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(j)
810 if (qbnd <= dzero) then
811 omega = done
812 else
813 omega = dzero
814 end if
815 qbnd_scaled = qbnd * this%eqnsclfac
816 iposd = this%idxfjfdglo(j)
817 iposoffd = this%idxfjfoffdglo(j)
818 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
819 call matrix_sln%add_value_pos(iposoffd, (done - omega) * qbnd_scaled)
820 end do
821 end if
822 end subroutine apt_fc_expanded
823
824 !> @brief Advanced package transport fill coefficient (fc) method
825 !!
826 !! Routine to allow a subclass advanced transport package to inject
827 !! terms into the matrix assembly. This method must be overridden.
828 !<
829 subroutine pak_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
830 ! -- modules
831 ! -- dummy
832 class(tspapttype) :: this
833 real(DP), dimension(:), intent(inout) :: rhs
834 integer(I4B), dimension(:), intent(in) :: ia
835 integer(I4B), dimension(:), intent(in) :: idxglo
836 class(matrixbasetype), pointer :: matrix_sln
837 ! -- local
838 !
839 ! -- this routine should never be called
840 call store_error('Program error: pak_fc_expanded not implemented.', &
841 terminate=.true.)
842 end subroutine pak_fc_expanded
843
844 !> @brief Advanced package transport routine
845 !!
846 !! Calculate advanced package transport hcof and rhs so transport budget is
847 !! calculated.
848 !<
849 subroutine apt_cfupdate(this)
850 ! -- modules
851 ! -- dummy
852 class(tspapttype) :: this
853 ! -- local
854 integer(I4B) :: j, n
855 real(DP) :: qbnd
856 real(DP) :: omega
857 !
858 ! -- Calculate hcof and rhs terms so GWF exchanges are calculated correctly
859 ! -- go through each apt-gwf connection and calculate
860 ! rhs and hcof terms for gwt/gwe matrix rows
861 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
862 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
863 this%hcof(j) = dzero
864 this%rhs(j) = dzero
865 if (this%iboundpak(n) /= 0) then
866 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
867 omega = dzero
868 if (qbnd < dzero) omega = done
869 this%hcof(j) = -(done - omega) * qbnd * this%eqnsclfac
870 this%rhs(j) = omega * qbnd * this%xnewpak(n) * this%eqnsclfac
871 end if
872 end do
873 end subroutine apt_cfupdate
874
875 !> @brief Advanced package transport calculate flows (cq) routine
876 !!
877 !! Calculate flows for the advanced package transport feature
878 !<
879 subroutine apt_cq(this, x, flowja, iadv)
880 ! -- modules
881 ! -- dummy
882 class(tspapttype), intent(inout) :: this
883 real(DP), dimension(:), intent(in) :: x
884 real(DP), dimension(:), contiguous, intent(inout) :: flowja
885 integer(I4B), optional, intent(in) :: iadv
886 ! -- local
887 integer(I4B) :: n, n1, n2
888 real(DP) :: rrate
889 !
890 ! -- Solve the feature concentrations (or temperatures) again or update
891 ! the feature hcof and rhs terms
892 if (this%imatrows == 0) then
893 call this%apt_solve()
894 else
895 call this%apt_cfupdate()
896 end if
897 !
898 ! -- call base functionality in bnd_cq
899 call this%BndType%bnd_cq(x, flowja)
900 !
901 ! -- calculate storage term
902 do n = 1, this%ncv
903 rrate = dzero
904 if (this%iboundpak(n) > 0) then
905 call this%apt_stor_term(n, n1, n2, rrate)
906 end if
907 this%qsto(n) = rrate
908 end do
909 !
910 ! -- Copy concentrations (or temperatures) into the flow package auxiliary variable
911 call this%apt_copy2flowp()
912 !
913 ! -- fill the budget object
914 call this%apt_fill_budobj(x, flowja)
915 end subroutine apt_cq
916
917 !> @brief Save advanced package flows routine
918 !<
919 subroutine apt_ot_package_flows(this, icbcfl, ibudfl)
920 use tdismodule, only: kstp, kper, delt, pertim, totim
921 class(tspapttype) :: this
922 integer(I4B), intent(in) :: icbcfl
923 integer(I4B), intent(in) :: ibudfl
924 integer(I4B) :: ibinun
925 !
926 ! -- write the flows from the budobj
927 ibinun = 0
928 if (this%ibudgetout /= 0) then
929 ibinun = this%ibudgetout
930 end if
931 if (icbcfl == 0) ibinun = 0
932 if (ibinun > 0) then
933 call this%budobj%save_flows(this%dis, ibinun, kstp, kper, delt, &
934 pertim, totim, this%iout)
935 end if
936 !
937 ! -- Print lake flows table
938 if (ibudfl /= 0 .and. this%iprflow /= 0) then
939 call this%budobj%write_flowtable(this%dis, kstp, kper)
940 end if
941 end subroutine apt_ot_package_flows
942
943 subroutine apt_ot_dv(this, idvsave, idvprint)
944 ! -- modules
945 use constantsmodule, only: lenbudtxt
946 use tdismodule, only: kstp, kper, pertim, totim
948 use inputoutputmodule, only: ulasav
949 ! -- dummy
950 class(tspapttype) :: this
951 integer(I4B), intent(in) :: idvsave
952 integer(I4B), intent(in) :: idvprint
953 ! -- local
954 integer(I4B) :: ibinun
955 integer(I4B) :: n
956 real(DP) :: c
957 character(len=LENBUDTXT) :: text
958 !
959 ! -- set unit number for binary dependent variable output
960 ibinun = 0
961 if (this%iconcout /= 0) then
962 ibinun = this%iconcout
963 end if
964 if (idvsave == 0) ibinun = 0
965 !
966 ! -- write binary output
967 if (ibinun > 0) then
968 do n = 1, this%ncv
969 c = this%xnewpak(n)
970 if (this%iboundpak(n) == 0) then
971 c = dhnoflo
972 end if
973 this%dbuff(n) = c
974 end do
975 write (text, '(a)') str_pad_left(this%depvartype, lenvarname)
976 call ulasav(this%dbuff, text, kstp, kper, pertim, totim, &
977 this%ncv, 1, 1, ibinun)
978 end if
979 !
980 ! -- write apt conc table
981 if (idvprint /= 0 .and. this%iprconc /= 0) then
982 !
983 ! -- set table kstp and kper
984 call this%dvtab%set_kstpkper(kstp, kper)
985 !
986 ! -- fill concentration data
987 do n = 1, this%ncv
988 if (this%inamedbound == 1) then
989 call this%dvtab%add_term(this%featname(n))
990 end if
991 call this%dvtab%add_term(n)
992 call this%dvtab%add_term(this%xnewpak(n))
993 end do
994 end if
995 end subroutine apt_ot_dv
996
997 !> @brief Print advanced package transport dependent variables
998 !<
999 subroutine apt_ot_bdsummary(this, kstp, kper, iout, ibudfl)
1000 ! -- module
1001 use tdismodule, only: totim, delt
1002 ! -- dummy
1003 class(tspapttype) :: this !< TspAptType object
1004 integer(I4B), intent(in) :: kstp !< time step number
1005 integer(I4B), intent(in) :: kper !< period number
1006 integer(I4B), intent(in) :: iout !< flag and unit number for the model listing file
1007 integer(I4B), intent(in) :: ibudfl !< flag indicating budget should be written
1008 !
1009 call this%budobj%write_budtable(kstp, kper, iout, ibudfl, totim, delt)
1010 end subroutine apt_ot_bdsummary
1011
1012 !> @brief Allocate scalars
1013 !!
1014 !! Allocate scalar variables for an advanced package
1015 !<
1016 subroutine allocate_scalars(this)
1017 ! -- modules
1019 ! -- dummy
1020 class(tspapttype) :: this
1021 ! -- local
1022 !
1023 ! -- allocate scalars in BndExtType
1024 call this%BndExtType%allocate_scalars()
1025 !
1026 ! -- Allocate
1027 call mem_allocate(this%iauxfpconc, 'IAUXFPCONC', this%memoryPath)
1028 call mem_allocate(this%imatrows, 'IMATROWS', this%memoryPath)
1029 call mem_allocate(this%iprconc, 'IPRCONC', this%memoryPath)
1030 call mem_allocate(this%iconcout, 'ICONCOUT', this%memoryPath)
1031 call mem_allocate(this%ibudgetout, 'IBUDGETOUT', this%memoryPath)
1032 call mem_allocate(this%ibudcsv, 'IBUDCSV', this%memoryPath)
1033 call mem_allocate(this%igwfaptpak, 'IGWFAPTPAK', this%memoryPath)
1034 call mem_allocate(this%ncv, 'NCV', this%memoryPath)
1035 call mem_allocate(this%idxbudfjf, 'IDXBUDFJF', this%memoryPath)
1036 call mem_allocate(this%idxbudgwf, 'IDXBUDGWF', this%memoryPath)
1037 call mem_allocate(this%idxbudsto, 'IDXBUDSTO', this%memoryPath)
1038 call mem_allocate(this%idxbudtmvr, 'IDXBUDTMVR', this%memoryPath)
1039 call mem_allocate(this%idxbudfmvr, 'IDXBUDFMVR', this%memoryPath)
1040 call mem_allocate(this%idxbudaux, 'IDXBUDAUX', this%memoryPath)
1041 call mem_allocate(this%nconcbudssm, 'NCONCBUDSSM', this%memoryPath)
1042 call mem_allocate(this%idxprepak, 'IDXPREPAK', this%memoryPath)
1043 call mem_allocate(this%idxlastpak, 'IDXLASTPAK', this%memoryPath)
1044 !
1045 ! -- Initialize
1046 this%iauxfpconc = 0
1047 this%imatrows = 1
1048 this%iprconc = 0
1049 this%iconcout = 0
1050 this%ibudgetout = 0
1051 this%ibudcsv = 0
1052 this%igwfaptpak = 0
1053 this%ncv = 0
1054 this%idxbudfjf = 0
1055 this%idxbudgwf = 0
1056 this%idxbudsto = 0
1057 this%idxbudtmvr = 0
1058 this%idxbudfmvr = 0
1059 this%idxbudaux = 0
1060 this%nconcbudssm = 0
1061 this%idxprepak = 0
1062 this%idxlastpak = 0
1063 !
1064 ! -- set this package as causing asymmetric matrix terms
1065 this%iasym = 1
1066 end subroutine allocate_scalars
1067
1068 !> @brief Allocate index arrays
1069 !!
1070 !! Allocate arrays that map to locations in the numerical solution
1071 !<
1073 ! -- modules
1075 ! -- dummy
1076 class(tspapttype), intent(inout) :: this
1077 ! -- local
1078 integer(I4B) :: n
1079 !
1080 if (this%imatrows /= 0) then
1081 !
1082 ! -- count number of flow-ja-face connections
1083 n = 0
1084 if (this%idxbudfjf /= 0) then
1085 n = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1086 end if
1087 !
1088 ! -- allocate pointers to global matrix
1089 call mem_allocate(this%idxlocnode, this%ncv, 'IDXLOCNODE', &
1090 this%memoryPath)
1091 call mem_allocate(this%idxpakdiag, this%ncv, 'IDXPAKDIAG', &
1092 this%memoryPath)
1093 call mem_allocate(this%idxdglo, this%maxbound, 'IDXGLO', &
1094 this%memoryPath)
1095 call mem_allocate(this%idxoffdglo, this%maxbound, 'IDXOFFDGLO', &
1096 this%memoryPath)
1097 call mem_allocate(this%idxsymdglo, this%maxbound, 'IDXSYMDGLO', &
1098 this%memoryPath)
1099 call mem_allocate(this%idxsymoffdglo, this%maxbound, 'IDXSYMOFFDGLO', &
1100 this%memoryPath)
1101 call mem_allocate(this%idxfjfdglo, n, 'IDXFJFDGLO', &
1102 this%memoryPath)
1103 call mem_allocate(this%idxfjfoffdglo, n, 'IDXFJFOFFDGLO', &
1104 this%memoryPath)
1105 else
1106 call mem_allocate(this%idxlocnode, 0, 'IDXLOCNODE', &
1107 this%memoryPath)
1108 call mem_allocate(this%idxpakdiag, 0, 'IDXPAKDIAG', &
1109 this%memoryPath)
1110 call mem_allocate(this%idxdglo, 0, 'IDXGLO', &
1111 this%memoryPath)
1112 call mem_allocate(this%idxoffdglo, 0, 'IDXOFFDGLO', &
1113 this%memoryPath)
1114 call mem_allocate(this%idxsymdglo, 0, 'IDXSYMDGLO', &
1115 this%memoryPath)
1116 call mem_allocate(this%idxsymoffdglo, 0, 'IDXSYMOFFDGLO', &
1117 this%memoryPath)
1118 call mem_allocate(this%idxfjfdglo, 0, 'IDXFJFDGLO', &
1119 this%memoryPath)
1120 call mem_allocate(this%idxfjfoffdglo, 0, 'IDXFJFOFFDGLO', &
1121 this%memoryPath)
1122 end if
1123 end subroutine apt_allocate_index_arrays
1124
1125 !> @brief Allocate arrays
1126 !!
1127 !! Allocate advanced package transport arrays
1128 !<
1129 subroutine apt_allocate_arrays(this)
1130 ! -- modules
1132 ! -- dummy
1133 class(tspapttype), intent(inout) :: this
1134 ! -- local
1135 integer(I4B) :: n
1136 !
1137 ! -- call standard BndExtType allocate arrays
1138 call this%BndExtType%allocate_arrays()
1139 !
1140 ! -- Allocate
1141 !
1142 ! -- allocate and initialize dbuff
1143 if (this%iconcout > 0) then
1144 call mem_allocate(this%dbuff, this%ncv, 'DBUFF', this%memoryPath)
1145 do n = 1, this%ncv
1146 this%dbuff(n) = dzero
1147 end do
1148 else
1149 call mem_allocate(this%dbuff, 0, 'DBUFF', this%memoryPath)
1150 end if
1151 !
1152 ! -- allocate character array for status
1153 allocate (this%status(this%ncv))
1154 !
1155 ! -- alias into the input context's permanent, feature-indexed
1156 ! CONCENTRATION/TEMPERATURE array (allocated and DZERO-initialized by
1157 ! the input context)
1158 call mem_setptr(this%concfeat, trim(this%depvartype), this%input_mempath)
1159 !
1160 ! -- budget terms
1161 call mem_allocate(this%qsto, this%ncv, 'QSTO', this%memoryPath)
1162 call mem_allocate(this%ccterm, this%ncv, 'CCTERM', this%memoryPath)
1163 !
1164 ! -- concentration for budget terms
1165 call mem_allocate(this%concbudssm, this%nconcbudssm, this%ncv, &
1166 'CONCBUDSSM', this%memoryPath)
1167 !
1168 ! -- mass (or energy) added from the mover transport package
1169 call mem_allocate(this%qmfrommvr, this%ncv, 'QMFROMMVR', this%memoryPath)
1170 !
1171 ! -- initialize arrays
1172 do n = 1, this%ncv
1173 this%status(n) = 'ACTIVE'
1174 this%qsto(n) = dzero
1175 this%ccterm(n) = dzero
1176 this%qmfrommvr(n) = dzero
1177 this%concbudssm(:, n) = dzero
1178 end do
1179 end subroutine apt_allocate_arrays
1180
1181 !> @brief Alias deprecated advanced transport variable names
1182 !!
1183 !! IDM integration moved the feature concentration (or temperature) and
1184 !! auxiliary arrays into the input context, renaming both. These aliases
1185 !! share memory with the relocated variables so that programs addressing
1186 !! them through the API by their old package-path names continue to resolve;
1187 !! each use is reported as deprecated. Each package overrides this routine
1188 !! to alias its own deprecated names and must call this base routine first;
1189 !! a package without an override only gets the names aliased here.
1190 !<
1192 ! -- modules
1195 ! -- dummy
1196 class(tspapttype), intent(inout) :: this
1197 ! -- local
1198 real(DP), dimension(:, :), pointer, contiguous :: aux => null()
1199 integer(I4B) :: isize
1200 ! -- code
1201 !
1202 ! -- feature concentration (GWT) or temperature (GWE)
1203 call mem_alias_deprecated(this%concfeat, 'CONCFEAT', this%memoryPath, &
1204 trim(this%depvartype), this%input_mempath, &
1205 '6.8.2')
1206 !
1207 ! -- feature auxiliary values, present (possibly empty) in the input context
1208 call get_isize('AUX', this%input_mempath, isize)
1209 if (isize >= 0) then
1210 call mem_setptr(aux, 'AUX', this%input_mempath)
1211 call mem_alias_deprecated(aux, 'LAUXVAR', this%memoryPath, &
1212 'AUX', this%input_mempath, '6.8.2')
1213 end if
1214 end subroutine apt_checkin_deprecated_names
1215
1216 !> @brief Deallocate memory
1217 !!
1218 !! Deallocate memory associated with this package
1219 !<
1220 subroutine apt_da(this)
1221 ! -- modules
1223 ! -- dummy
1224 class(tspapttype) :: this
1225 ! -- local
1226 !
1227 ! -- deallocate arrays
1228 call mem_deallocate(this%dbuff)
1229 call mem_deallocate(this%qsto)
1230 call mem_deallocate(this%ccterm)
1231 call mem_deallocate(this%strt)
1232 call mem_deallocate(this%xoldpak)
1233 if (this%imatrows == 0) then
1234 call mem_deallocate(this%iboundpak)
1235 call mem_deallocate(this%xnewpak)
1236 end if
1237 call mem_deallocate(this%concbudssm)
1238 nullify (this%concfeat) ! input-context-owned alias, not package-allocated
1239 call mem_deallocate(this%qmfrommvr)
1240 deallocate (this%status)
1241 deallocate (this%featname)
1242 !
1243 ! -- budobj
1244 call this%budobj%budgetobject_da()
1245 deallocate (this%budobj)
1246 nullify (this%budobj)
1247 !
1248 ! -- conc table
1249 if (this%iprconc > 0) then
1250 call this%dvtab%table_da()
1251 deallocate (this%dvtab)
1252 nullify (this%dvtab)
1253 end if
1254 !
1255 ! -- index pointers
1256 call mem_deallocate(this%idxlocnode)
1257 call mem_deallocate(this%idxpakdiag)
1258 call mem_deallocate(this%idxdglo)
1259 call mem_deallocate(this%idxoffdglo)
1260 call mem_deallocate(this%idxsymdglo)
1261 call mem_deallocate(this%idxsymoffdglo)
1262 call mem_deallocate(this%idxfjfdglo)
1263 call mem_deallocate(this%idxfjfoffdglo)
1264 !
1265 ! -- deallocate scalars
1266 call mem_deallocate(this%iauxfpconc)
1267 call mem_deallocate(this%imatrows)
1268 call mem_deallocate(this%iprconc)
1269 call mem_deallocate(this%iconcout)
1270 call mem_deallocate(this%ibudgetout)
1271 call mem_deallocate(this%ibudcsv)
1272 call mem_deallocate(this%igwfaptpak)
1273 call mem_deallocate(this%ncv)
1274 call mem_deallocate(this%idxbudfjf)
1275 call mem_deallocate(this%idxbudgwf)
1276 call mem_deallocate(this%idxbudsto)
1277 call mem_deallocate(this%idxbudtmvr)
1278 call mem_deallocate(this%idxbudfmvr)
1279 call mem_deallocate(this%idxbudaux)
1280 call mem_deallocate(this%idxbudssm)
1281 call mem_deallocate(this%nconcbudssm)
1282 call mem_deallocate(this%idxprepak)
1283 call mem_deallocate(this%idxlastpak)
1284 !
1285 ! -- deallocate scalars in BndExtType
1286 call this%BndExtType%bnd_da()
1287 end subroutine apt_da
1288
1289 !> @brief Find corresponding advanced package transport package
1290 !<
1291 subroutine find_apt_package(this)
1292 ! -- modules
1294 ! -- dummy
1295 class(tspapttype) :: this
1296 ! -- local
1297 !
1298 ! -- this routine should never be called
1299 call store_error('Program error: pak_solve not implemented.', &
1300 terminate=.true.)
1301 end subroutine find_apt_package
1302
1303 !> @brief Source OPTIONS block from the input context
1304 !<
1305 subroutine apt_source_options(this)
1306 ! -- dummy
1307 class(tspapttype), intent(inout) :: this
1308 ! -- local
1309 character(len=LINELENGTH) :: fname
1310 logical :: found
1311 ! -- formats
1312 character(len=*), parameter :: fmtaptbin = &
1313 "(4x, a, 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, &
1314 &/4x, 'OPENED ON UNIT: ', I0)"
1315 !
1316 ! -- call base class for AUXILIARY/BOUNDNAMES/PRINT_INPUT/PRINT_FLOWS/
1317 ! SAVE_FLOWS/OBS6/TS6 options
1318 call this%BndExtType%source_options()
1319 !
1320 write (this%iout, '(1x,a)') &
1321 'PROCESSING '//trim(adjustl(this%text))//' OPTIONS'
1322 !
1323 ! -- FLOW_PKG_NAME (DFN: flow_package_name)
1324 call mem_set_value(this%flowpackagename, 'FLOW_PKG_NAME', &
1325 this%input_mempath, found)
1326 if (found) then
1327 write (this%iout, '(4x,a)') &
1328 'THIS '//trim(adjustl(this%text))//' PACKAGE CORRESPONDS TO A GWF &
1329 &PACKAGE WITH THE NAME '//trim(adjustl(this%flowpackagename))
1330 end if
1331 !
1332 ! -- FP_AUX_NAME (DFN: flow_package_auxiliary_name)
1333 call mem_set_value(this%cauxfpconc, 'FP_AUX_NAME', &
1334 this%input_mempath, found)
1335 if (found) then
1336 write (this%iout, '(4x,a)') &
1337 'SIMULATED CONCENTRATIONS WILL BE COPIED INTO THE FLOW PACKAGE &
1338 &AUXILIARY VARIABLE WITH THE NAME '//trim(adjustl(this%cauxfpconc))
1339 end if
1340 !
1341 ! -- DEV_NONEXPANDING_MATRIX is intentionally not sourced: this
1342 ! package's imatrows=0 solve path divides by a per-feature
1343 ! storage term that is zero without a stage-volume table.
1344 !
1345 ! -- IPRCONC (DFN: print_concentration or print_temperature)
1346 call mem_set_value(this%iprconc, 'IPRCONC', this%input_mempath, found)
1347 if (found) then
1348 write (this%iout, '(4x,a)') trim(adjustl(this%text))// &
1349 ' '//trim(adjustl(this%depvartype))//'S WILL BE PRINTED TO LISTING FILE.'
1350 end if
1351 !
1352 ! -- concentration/temperature output file: 'CONCFILE' (GWT) or 'TEMPFILE' (GWE)
1353 if (this%depvartype == 'CONCENTRATION') then
1354 call mem_set_value(fname, 'CONCFILE', this%input_mempath, found)
1355 else
1356 call mem_set_value(fname, 'TEMPFILE', this%input_mempath, found)
1357 end if
1358 if (found) then
1359 call assign_iounit(this%iconcout, this%inunit, &
1360 trim(this%depvartype)//" fileout")
1361 call openfile(this%iconcout, this%iout, fname, 'DATA(BINARY)', &
1362 form, access, 'REPLACE', mode_opt=mnormal)
1363 write (this%iout, fmtaptbin) trim(adjustl(this%text)), &
1364 trim(adjustl(this%depvartype)), trim(fname), this%iconcout
1365 end if
1366 !
1367 ! -- BUDGET FILEOUT
1368 call mem_set_value(fname, 'BUDGETFILE', this%input_mempath, found)
1369 if (found) then
1370 call assign_iounit(this%ibudgetout, this%inunit, "BUDGET fileout")
1371 call openfile(this%ibudgetout, this%iout, fname, 'DATA(BINARY)', &
1372 form, access, 'REPLACE', mode_opt=mnormal)
1373 write (this%iout, fmtaptbin) trim(adjustl(this%text)), 'BUDGET', &
1374 trim(fname), this%ibudgetout
1375 end if
1376 !
1377 ! -- BUDGETCSV FILEOUT
1378 call mem_set_value(fname, 'BUDGETCSVFILE', this%input_mempath, found)
1379 if (found) then
1380 call assign_iounit(this%ibudcsv, this%inunit, "BUDGETCSV fileout")
1381 call openfile(this%ibudcsv, this%iout, fname, 'CSV', filstat_opt='REPLACE')
1382 write (this%iout, fmtaptbin) trim(adjustl(this%text)), 'BUDGET CSV', &
1383 trim(fname), this%ibudcsv
1384 end if
1385 !
1386 write (this%iout, '(1x,a)') &
1387 'END OF '//trim(adjustl(this%text))//' OPTIONS'
1388 end subroutine apt_source_options
1389
1390 !> @brief Source DIMENSIONS from the flow package; allocate package arrays
1391 !<
1392 subroutine apt_source_dimensions(this)
1393 ! -- dummy
1394 class(tspapttype), intent(inout) :: this
1395 ! -- local
1396 integer(I4B) :: ierr
1397 !
1398 ! -- default flow package name to package name if not specified in OPTIONS
1399 if (this%flowpackagename == '') then
1400 this%flowpackagename = this%packName
1401 write (this%iout, '(4x,a)') &
1402 'THE FLOW PACKAGE NAME FOR '//trim(adjustl(this%text))//' WAS NOT &
1403 &SPECIFIED. SETTING FLOW PACKAGE NAME TO '// &
1404 trim(adjustl(this%flowpackagename))
1405 end if
1406 call this%find_apt_package()
1407 !
1408 ! -- derive dimensions from the corresponding GWF advanced package
1409 this%ncv = this%flowbudptr%ncv
1410 this%maxbound = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
1411 this%nbound = this%maxbound
1412 write (this%iout, '(a, a)') 'SETTING DIMENSIONS FOR PACKAGE ', this%packName
1413 write (this%iout, '(2x,a,i0)') 'NUMBER OF CONTROL VOLUMES = ', this%ncv
1414 write (this%iout, '(2x,a,i0)') 'MAXBOUND = ', this%maxbound
1415 write (this%iout, '(2x,a,i0)') 'NBOUND = ', this%nbound
1416 if (this%imatrows /= 0) then
1417 this%npakeq = this%ncv
1418 write (this%iout, '(2x,a)') trim(adjustl(this%text))// &
1419 ' SOLVED AS PART OF GWT MATRIX EQUATIONS'
1420 else
1421 write (this%iout, '(2x,a)') trim(adjustl(this%text))// &
1422 ' SOLVED SEPARATELY FROM GWT MATRIX EQUATIONS '
1423 end if
1424 write (this%iout, '(a, //)') 'DONE SETTING DIMENSIONS FOR '// &
1425 trim(adjustl(this%text))
1426 !
1427 if (this%ncv < 0) then
1428 write (errmsg, '(a)') &
1429 'Number of control volumes could not be determined correctly.'
1430 call store_error(errmsg)
1431 end if
1432 ierr = count_errors()
1433 if (ierr > 0) call store_error_filename(this%input_fname)
1434 !
1435 ! -- source packagedata from the input context
1436 call this%apt_source_cvs()
1437 !
1438 call this%define_listlabel()
1439 call this%apt_setup_budobj()
1440 call this%apt_setup_tableobj()
1441 end subroutine apt_source_dimensions
1442
1443 !> @brief Source PACKAGEDATA feature information from the input context
1444 !<
1445 subroutine apt_source_cvs(this)
1446 ! -- dummy
1447 class(tspapttype), intent(inout) :: this
1448 ! -- local
1449 character(len=LENBOUNDNAME) :: bndName
1450 character(len=9) :: cno
1451 integer(I4B) :: n, itemno, isize, nfeat
1452 integer(I4B), allocatable, dimension(:) :: nboundchk
1453 real(DP), dimension(:), pointer, contiguous :: strt_ptr => null()
1454 type(characterstringtype), dimension(:), pointer, contiguous :: &
1455 boundname_ptr => null()
1456 !
1457 ! -- allocate package simulation arrays
1458 call mem_allocate(this%strt, this%ncv, 'STRT', this%memoryPath)
1459 if (this%imatrows == 0) then
1460 call mem_allocate(this%iboundpak, this%ncv, 'IBOUND', this%memoryPath)
1461 call mem_allocate(this%xnewpak, this%ncv, 'XNEWPAK', this%memoryPath)
1462 end if
1463 call mem_allocate(this%xoldpak, this%ncv, 'XOLDPAK', this%memoryPath)
1464 allocate (this%featname(this%ncv))
1465 !
1466 ! -- initialize arrays
1467 do n = 1, this%ncv
1468 this%strt(n) = dep20
1469 this%xoldpak(n) = dep20
1470 if (this%imatrows == 0) then
1471 this%iboundpak(n) = 1
1472 this%xnewpak(n) = dep20
1473 end if
1474 end do
1475 !
1476 ! -- set up featureauxvar; allocate_featureauxvar also sets pkg_ifno
1477 ! from PACKAGEDATA_IFNO
1478 call this%allocate_featureauxvar()
1479 !
1480 ! -- validate PACKAGEDATA specifies IFNO exactly once for every feature
1481 nfeat = size(this%pkg_ifno)
1482 allocate (nboundchk(this%ncv))
1483 nboundchk = 0
1484 do n = 1, nfeat
1485 itemno = this%validate_ifno(this%pkg_ifno(n), this%ncv, nboundchk, 'IFNO', &
1486 trim(adjustl(this%text))//' PACKAGEDATA')
1487 end do
1488 call this%report_ifno_coverage(nboundchk, this%ncv, 'feature', &
1489 trim(adjustl(this%text))//' PACKAGEDATA')
1490 deallocate (nboundchk)
1491 if (count_errors() > 0) then
1492 call store_error_filename(this%input_fname)
1493 end if
1494 !
1495 ! -- source STRT from the input context
1496 call mem_setptr(strt_ptr, 'STRT', this%input_mempath)
1497 do n = 1, nfeat
1498 itemno = this%pkg_ifno(n)
1499 this%strt(itemno) = strt_ptr(n)
1500 end do
1501 call memorystore_release('STRT', this%input_mempath)
1502 !
1503 ! -- set default feature names then override with BOUNDNAME if present
1504 do n = 1, this%ncv
1505 write (cno, '(i9.9)') n
1506 this%featname(n) = 'Feature'//cno
1507 end do
1508 if (this%inamedbound /= 0) then
1509 call get_isize('BOUNDNAME', this%input_mempath, isize)
1510 if (isize > 0) then
1511 call mem_setptr(boundname_ptr, 'BOUNDNAME', this%input_mempath)
1512 do n = 1, nfeat
1513 itemno = this%pkg_ifno(n)
1514 if (itemno < 1 .or. itemno > this%ncv) cycle
1515 bndname = boundname_ptr(n)
1516 if (trim(bndname) /= '') this%featname(itemno) = trim(bndname)
1517 end do
1518 end if
1519 end if
1520 call memorystore_release('BOUNDNAME', this%input_mempath)
1521 !
1522 write (this%iout, '(/1x,a)') 'END OF '//trim(adjustl(this%text))// &
1523 ' PACKAGEDATA'
1524 end subroutine apt_source_cvs
1525
1526 !> @brief Read the initial parameters for an advanced package
1527 !<
1528 subroutine apt_read_initial_attr(this)
1529 use constantsmodule, only: linelength
1530 use budgetmodule, only: budget_cr
1531 ! -- dummy
1532 class(tspapttype), intent(inout) :: this
1533 ! -- local
1534 !character(len=LINELENGTH) :: text
1535 integer(I4B) :: j, n
1536
1537 !
1538 ! -- initialize xnewpak and set feature concentration (or temperature)
1539 ! -- todo: this should be a time series?
1540 do n = 1, this%ncv
1541 this%xnewpak(n) = this%strt(n)
1542 !
1543 ! -- todo: read aux
1544 !
1545 ! -- todo: read boundname
1546 end do
1547 !
1548 ! -- initialize status (iboundpak) of lakes to active
1549 do n = 1, this%ncv
1550 if (this%status(n) == 'CONSTANT') then
1551 this%iboundpak(n) = -1
1552 else if (this%status(n) == 'INACTIVE') then
1553 this%iboundpak(n) = 0
1554 else if (this%status(n) == 'ACTIVE ') then
1555 this%iboundpak(n) = 1
1556 end if
1557 end do
1558 !
1559 ! -- set boundname for each connection
1560 if (this%inamedbound /= 0) then
1561 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1562 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1563 this%boundname(j) = this%featname(n)
1564 end do
1565 end if
1566 !
1567 ! -- copy boundname into boundname_cst
1568 call this%copy_boundname()
1569 end subroutine apt_read_initial_attr
1570
1571 !> @brief Add terms specific to advanced package transport to the explicit
1572 !! solve
1573 !!
1574 !! Explicit solve for concentration (or temperature) in advaced package
1575 !! features, which is an alternative to the iterative implicit solve.
1576 !<
1577 subroutine apt_solve(this)
1578 use constantsmodule, only: linelength
1579 ! -- dummy
1580 class(tspapttype) :: this
1581 ! -- local
1582 integer(I4B) :: n, j, igwfnode
1583 integer(I4B) :: n1, n2
1584 real(DP) :: rrate
1585 real(DP) :: ctmp
1586 real(DP) :: c1, qbnd
1587 real(DP) :: hcofval, rhsval
1588 !
1589 ! -- initialize dbuff
1590 do n = 1, this%ncv
1591 this%dbuff(n) = dzero
1592 end do
1593 !
1594 ! -- call the individual package routines to add terms specific to the
1595 ! advanced transport package
1596 call this%pak_solve()
1597 !
1598 ! -- add to mover contribution
1599 if (this%idxbudtmvr /= 0) then
1600 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
1601 call this%apt_tmvr_term(j, n1, n2, rrate)
1602 this%dbuff(n1) = this%dbuff(n1) + rrate
1603 end do
1604 end if
1605 !
1606 ! -- add from mover contribution
1607 if (this%idxbudfmvr /= 0) then
1608 do n1 = 1, size(this%qmfrommvr)
1609 rrate = this%qmfrommvr(n1) ! Will be in terms of energy for heat transport
1610 this%dbuff(n1) = this%dbuff(n1) + rrate
1611 end do
1612 end if
1613 !
1614 ! -- go through each gwf connection and accumulate
1615 ! total mass (or energy) in dbuff mass
1616 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1617 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1618 this%hcof(j) = dzero
1619 this%rhs(j) = dzero
1620 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
1621 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
1622 if (qbnd <= dzero) then
1623 ctmp = this%xnewpak(n)
1624 this%rhs(j) = qbnd * ctmp * this%eqnsclfac
1625 else
1626 ctmp = this%xnew(igwfnode)
1627 this%hcof(j) = -qbnd * this%eqnsclfac
1628 end if
1629 c1 = qbnd * ctmp * this%eqnsclfac
1630 this%dbuff(n) = this%dbuff(n) + c1
1631 end do
1632 !
1633 ! -- go through each "within apt-apt" connection (e.g., lak-lak) and
1634 ! accumulate total mass (or energy) in dbuff mass
1635 if (this%idxbudfjf /= 0) then
1636 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
1637 call this%apt_fjf_term(j, n1, n2, rrate)
1638 c1 = rrate
1639 this%dbuff(n1) = this%dbuff(n1) + c1
1640 end do
1641 end if
1642 !
1643 ! -- calculate the feature concentration/temperature
1644 do n = 1, this%ncv
1645 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
1646 !
1647 ! -- at this point, dbuff has q * c for all sources, so now
1648 ! add Vold / dt * Cold
1649 this%dbuff(n) = this%dbuff(n) - rhsval
1650 !
1651 ! -- Now to calculate c, need to divide dbuff by hcofval
1652 c1 = -this%dbuff(n) / hcofval
1653 if (this%iboundpak(n) > 0) then
1654 this%xnewpak(n) = c1
1655 end if
1656 end do
1657 end subroutine apt_solve
1658
1659 !> @brief Add terms specific to advanced package transport features to the
1660 !! explicit solve routine
1661 !!
1662 !! This routine must be overridden by the specific apt package
1663 !<
1664 subroutine pak_solve(this)
1665 ! -- dummy
1666 class(tspapttype) :: this
1667 ! -- local
1668 !
1669 ! -- this routine should never be called
1670 call store_error('Program error: pak_solve not implemented.', &
1671 terminate=.true.)
1672 end subroutine pak_solve
1673
1674 !> @brief Accumulate constant concentration (or temperature) terms for budget
1675 !<
1676 subroutine apt_accumulate_ccterm(this, ilak, rrate, ccratin, ccratout)
1677 ! -- dummy
1678 class(tspapttype) :: this
1679 integer(I4B), intent(in) :: ilak
1680 real(DP), intent(in) :: rrate
1681 real(DP), intent(inout) :: ccratin
1682 real(DP), intent(inout) :: ccratout
1683 ! -- locals
1684 real(DP) :: q
1685 ! format
1686 ! code
1687 !
1688 if (this%iboundpak(ilak) < 0) then
1689 q = -rrate
1690 this%ccterm(ilak) = this%ccterm(ilak) + q
1691 !
1692 ! -- See if flow is into lake or out of lake.
1693 if (q < dzero) then
1694 !
1695 ! -- Flow is out of lake subtract rate from ratout.
1696 ccratout = ccratout - q
1697 else
1698 !
1699 ! -- Flow is into lake; add rate to ratin.
1700 ccratin = ccratin + q
1701 end if
1702 end if
1703 end subroutine apt_accumulate_ccterm
1704
1705 !> @brief Define the list heading that is written to iout when PRINT_INPUT
1706 !! option is used.
1707 !<
1708 subroutine define_listlabel(this)
1709 class(tspapttype), intent(inout) :: this
1710 !
1711 ! -- create the header list label
1712 this%listlabel = trim(this%filtyp)//' NO.'
1713 if (this%dis%ndim == 3) then
1714 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
1715 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'ROW'
1716 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'COL'
1717 elseif (this%dis%ndim == 2) then
1718 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
1719 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'CELL2D'
1720 else
1721 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'NODE'
1722 end if
1723 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'STRESS RATE'
1724 if (this%inamedbound == 1) then
1725 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'BOUNDARY NAME'
1726 end if
1727 end subroutine define_listlabel
1728
1729 !> @brief Set pointers to model arrays and variables so that a package has
1730 !! access to these items.
1731 !<
1732 subroutine apt_set_pointers(this, neq, ibound, xnew, xold, flowja)
1733 class(tspapttype) :: this
1734 integer(I4B), pointer :: neq
1735 integer(I4B), dimension(:), pointer, contiguous :: ibound
1736 real(DP), dimension(:), pointer, contiguous :: xnew
1737 real(DP), dimension(:), pointer, contiguous :: xold
1738 real(DP), dimension(:), pointer, contiguous :: flowja
1739 ! -- local
1740 integer(I4B) :: istart, iend
1741 !
1742 ! -- call base BndType set_pointers
1743 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
1744 !
1745 ! -- Set the pointers
1746 !
1747 ! -- set package pointers
1748 if (this%imatrows /= 0) then
1749 istart = this%dis%nodes + this%ioffset + 1
1750 iend = istart + this%ncv - 1
1751 this%iboundpak => this%ibound(istart:iend)
1752 this%xnewpak => this%xnew(istart:iend)
1753 end if
1754 end subroutine apt_set_pointers
1755
1756 !> @brief Return the feature new volume and old volume
1757 !<
1758 subroutine apt_get_volumes(this, icv, vnew, vold, delt)
1759 ! -- modules
1760 ! -- dummy
1761 class(tspapttype) :: this
1762 integer(I4B), intent(in) :: icv
1763 real(DP), intent(inout) :: vnew, vold
1764 real(DP), intent(in) :: delt
1765 ! -- local
1766 real(DP) :: qss
1767 !
1768 ! -- get volumes
1769 vold = dzero
1770 vnew = vold
1771 if (this%idxbudsto /= 0) then
1772 qss = this%flowbudptr%budterm(this%idxbudsto)%flow(icv)
1773 vnew = this%flowbudptr%budterm(this%idxbudsto)%auxvar(1, icv)
1774 vold = vnew + qss * delt
1775 end if
1776 end subroutine apt_get_volumes
1777
1778 !> @brief Function to return the number of budget terms just for this package
1779 !!
1780 !! This function must be overridden.
1781 !<
1782 function pak_get_nbudterms(this) result(nbudterms)
1783 ! -- modules
1784 ! -- dummy
1785 class(tspapttype) :: this
1786 ! -- return
1787 integer(I4B) :: nbudterms
1788 ! -- local
1789 !
1790 ! -- this routine should never be called
1791 call store_error('Program error: pak_get_nbudterms not implemented.', &
1792 terminate=.true.)
1793 nbudterms = 0
1794 end function pak_get_nbudterms
1795
1796 !> @brief Set up the budget object that stores advanced package flow terms
1797 !<
1798 subroutine apt_setup_budobj(this)
1799 ! -- modules
1800 use constantsmodule, only: lenbudtxt
1801 ! -- dummy
1802 class(tspapttype) :: this
1803 ! -- local
1804 integer(I4B) :: nbudterm
1805 integer(I4B) :: n, n1, n2
1806 integer(I4B) :: maxlist, naux
1807 integer(I4B) :: idx
1808 logical :: ordered_id1
1809 real(DP) :: q
1810 character(len=LENBUDTXT) :: bddim_opt
1811 character(len=LENBUDTXT) :: text, textt
1812 character(len=LENBUDTXT), dimension(1) :: auxtxt
1813 !
1814 ! -- initialize nbudterm
1815 nbudterm = 0
1816 !
1817 ! -- Determine the number of budget terms associated with apt.
1818 ! These are fixed for the simulation and cannot change
1819 !
1820 ! -- add one if flow-ja-face present
1821 if (this%idxbudfjf /= 0) nbudterm = nbudterm + 1
1822 !
1823 ! -- All the APT packages have GWF, STORAGE, and CONSTANT
1824 nbudterm = nbudterm + 3
1825 !
1826 ! -- add terms for the specific package
1827 nbudterm = nbudterm + this%pak_get_nbudterms()
1828 !
1829 ! -- add for mover terms and auxiliary
1830 if (this%idxbudtmvr /= 0) nbudterm = nbudterm + 1
1831 if (this%idxbudfmvr /= 0) nbudterm = nbudterm + 1
1832 if (this%naux > 0) nbudterm = nbudterm + 1
1833 !
1834 ! -- set up budobj
1835 call budgetobject_cr(this%budobj, this%packName)
1836 !
1837 bddim_opt = this%depvarunitabbrev
1838 call this%budobj%budgetobject_df(this%ncv, nbudterm, 0, 0, &
1839 bddim_opt=bddim_opt, ibudcsv=this%ibudcsv)
1840 idx = 0
1841 !
1842 ! -- Go through and set up each budget term. Flow-ja-face is set up
1843 ! even if there are no connections (e.g., a single reach) so that
1844 ! the header is written to the budget file with zero entries.
1845 if (this%idxbudfjf /= 0) then
1846 text = ' FLOW-JA-FACE'
1847 idx = idx + 1
1848 maxlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1849 naux = 0
1850 ordered_id1 = this%flowbudptr%budterm(this%idxbudfjf)%ordered_id1
1851 call this%budobj%budterm(idx)%initialize(text, &
1852 this%name_model, &
1853 this%packName, &
1854 this%name_model, &
1855 this%packName, &
1856 maxlist, .false., .false., &
1857 naux, ordered_id1=ordered_id1)
1858 !
1859 ! -- store outlet connectivity
1860 call this%budobj%budterm(idx)%reset(maxlist)
1861 q = dzero
1862 do n = 1, maxlist
1863 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(n)
1864 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(n)
1865 call this%budobj%budterm(idx)%update_term(n1, n2, q)
1866 end do
1867 end if
1868 !
1869 ! --
1870 text = ' GWF'
1871 idx = idx + 1
1872 maxlist = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
1873 naux = 0
1874 call this%budobj%budterm(idx)%initialize(text, &
1875 this%name_model, &
1876 this%packName, &
1877 this%name_model, &
1878 this%name_model, &
1879 maxlist, .false., .true., &
1880 naux)
1881 call this%budobj%budterm(idx)%reset(maxlist)
1882 q = dzero
1883 do n = 1, maxlist
1884 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(n)
1885 n2 = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
1886 call this%budobj%budterm(idx)%update_term(n1, n2, q)
1887 end do
1888 !
1889 ! -- Reserve space for the package specific terms
1890 this%idxprepak = idx
1891 call this%pak_setup_budobj(idx)
1892 this%idxlastpak = idx
1893 !
1894 ! --
1895 text = ' STORAGE'
1896 idx = idx + 1
1897 maxlist = this%flowbudptr%budterm(this%idxbudsto)%maxlist
1898 naux = 1
1899 write (textt, '(a)') str_pad_left(this%depvarunit, 16)
1900 auxtxt(1) = textt ! ' MASS' or ' ENERGY'
1901 call this%budobj%budterm(idx)%initialize(text, &
1902 this%name_model, &
1903 this%packName, &
1904 this%name_model, &
1905 this%packName, &
1906 maxlist, .false., .false., &
1907 naux, auxtxt)
1908 if (this%idxbudtmvr /= 0) then
1909 !
1910 ! --
1911 text = ' TO-MVR'
1912 idx = idx + 1
1913 maxlist = this%flowbudptr%budterm(this%idxbudtmvr)%maxlist
1914 naux = 0
1915 ordered_id1 = this%flowbudptr%budterm(this%idxbudtmvr)%ordered_id1
1916 call this%budobj%budterm(idx)%initialize(text, &
1917 this%name_model, &
1918 this%packName, &
1919 this%name_model, &
1920 this%packName, &
1921 maxlist, .false., .false., &
1922 naux, ordered_id1=ordered_id1)
1923 end if
1924 if (this%idxbudfmvr /= 0) then
1925 !
1926 ! --
1927 text = ' FROM-MVR'
1928 idx = idx + 1
1929 maxlist = this%ncv
1930 naux = 0
1931 call this%budobj%budterm(idx)%initialize(text, &
1932 this%name_model, &
1933 this%packName, &
1934 this%name_model, &
1935 this%packName, &
1936 maxlist, .false., .false., &
1937 naux)
1938 end if
1939 !
1940 ! --
1941 text = ' CONSTANT'
1942 idx = idx + 1
1943 maxlist = this%ncv
1944 naux = 0
1945 call this%budobj%budterm(idx)%initialize(text, &
1946 this%name_model, &
1947 this%packName, &
1948 this%name_model, &
1949 this%packName, &
1950 maxlist, .false., .false., &
1951 naux)
1952
1953 !
1954 ! --
1955 naux = this%naux
1956 if (naux > 0) then
1957 !
1958 ! --
1959 text = ' AUXILIARY'
1960 idx = idx + 1
1961 maxlist = this%ncv
1962 call this%budobj%budterm(idx)%initialize(text, &
1963 this%name_model, &
1964 this%packName, &
1965 this%name_model, &
1966 this%packName, &
1967 maxlist, .false., .false., &
1968 naux, this%auxname)
1969 end if
1970 !
1971 ! -- if flow for each control volume are written to the listing file
1972 if (this%iprflow /= 0) then
1973 call this%budobj%flowtable_df(this%iout)
1974 end if
1975 end subroutine apt_setup_budobj
1976
1977 !> @brief Set up a budget object that stores an advanced package flows
1978 !!
1979 !! Individual packages set up their budget terms. Must be overridden.
1980 !<
1981 subroutine pak_setup_budobj(this, idx)
1982 ! -- modules
1983 ! -- dummy
1984 class(tspapttype) :: this
1985 integer(I4B), intent(inout) :: idx
1986 ! -- local
1987 !
1988 ! -- this routine should never be called
1989 call store_error('Program error: pak_setup_budobj not implemented.', &
1990 terminate=.true.)
1991 end subroutine pak_setup_budobj
1992
1993 !> @brief Copy flow terms into this%budobj
1994 !<
1995 subroutine apt_fill_budobj(this, x, flowja)
1996 ! -- modules
1997 use tdismodule, only: delt
1998 ! -- dummy
1999 class(tspapttype) :: this
2000 real(DP), dimension(:), intent(in) :: x
2001 real(DP), dimension(:), contiguous, intent(inout) :: flowja
2002 ! -- local
2003 integer(I4B) :: naux
2004 real(DP), dimension(:), allocatable :: auxvartmp
2005 integer(I4B) :: i, j, n1, n2
2006 integer(I4B) :: idx
2007 integer(I4B) :: nlist
2008 integer(I4B) :: igwfnode
2009 real(DP) :: q
2010 real(DP) :: v0, v1
2011 real(DP) :: ccratin, ccratout
2012 ! -- formats
2013 !
2014 ! -- initialize counter
2015 idx = 0
2016 !
2017 ! -- initialize ccterm, which is used to sum up all mass (or energy) flows
2018 ! into a constant concentration (or temperature) cell
2019 ccratin = dzero
2020 ccratout = dzero
2021 do n1 = 1, this%ncv
2022 this%ccterm(n1) = dzero
2023 end do
2024 !
2025 ! -- FLOW JA FACE
2026 if (this%idxbudfjf /= 0) then
2027 idx = idx + 1
2028 nlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2029 call this%budobj%budterm(idx)%reset(nlist)
2030 q = dzero
2031 do j = 1, nlist
2032 call this%apt_fjf_term(j, n1, n2, q)
2033 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2034 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2035 end do
2036 end if
2037 !
2038 ! -- GWF (LEAKAGE)
2039 idx = idx + 1
2040 call this%budobj%budterm(idx)%reset(this%maxbound)
2041 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2042 q = dzero
2043 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2044 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
2045 if (this%iboundpak(n1) /= 0) then
2046 q = this%hcof(j) * x(igwfnode) - this%rhs(j)
2047 q = -q ! flip sign so relative to advanced package feature
2048 end if
2049 call this%budobj%budterm(idx)%update_term(n1, igwfnode, q)
2050 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2051 end do
2052 !
2053 ! -- skip individual package terms for now and process them last
2054 ! -- in case they depend on the other terms (as for uze)
2055 idx = this%idxlastpak
2056 !
2057 ! -- STORAGE
2058 idx = idx + 1
2059 call this%budobj%budterm(idx)%reset(this%ncv)
2060 allocate (auxvartmp(1))
2061 do n1 = 1, this%ncv
2062 call this%apt_get_volumes(n1, v1, v0, delt)
2063 auxvartmp(1) = v1 * this%xnewpak(n1) ! Note: When GWE is added, check if this needs a factor of eqnsclfac
2064 q = this%qsto(n1)
2065 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2066 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2067 end do
2068 deallocate (auxvartmp)
2069 !
2070 ! -- TO MOVER
2071 if (this%idxbudtmvr /= 0) then
2072 idx = idx + 1
2073 nlist = this%flowbudptr%budterm(this%idxbudtmvr)%nlist
2074 call this%budobj%budterm(idx)%reset(nlist)
2075 do j = 1, nlist
2076 call this%apt_tmvr_term(j, n1, n2, q)
2077 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2078 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2079 end do
2080 end if
2081 !
2082 ! -- FROM MOVER
2083 if (this%idxbudfmvr /= 0) then
2084 idx = idx + 1
2085 nlist = this%ncv
2086 call this%budobj%budterm(idx)%reset(nlist)
2087 do j = 1, nlist
2088 call this%apt_fmvr_term(j, n1, n2, q)
2089 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2090 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2091 end do
2092 end if
2093 !
2094 ! -- CONSTANT FLOW
2095 idx = idx + 1
2096 call this%budobj%budterm(idx)%reset(this%ncv)
2097 do n1 = 1, this%ncv
2098 q = this%ccterm(n1)
2099 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2100 end do
2101 !
2102 ! -- AUXILIARY VARIABLES
2103 naux = this%naux
2104 if (naux > 0) then
2105 idx = idx + 1
2106 allocate (auxvartmp(naux))
2107 call this%budobj%budterm(idx)%reset(this%ncv)
2108 do n1 = 1, this%ncv
2109 q = dzero
2110 do i = 1, naux
2111 auxvartmp(i) = this%featureauxvar(i, n1)
2112 end do
2113 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2114 end do
2115 deallocate (auxvartmp)
2116 end if
2117 !
2118 ! -- individual package terms processed last
2119 idx = this%idxprepak
2120 call this%pak_fill_budobj(idx, x, flowja, ccratin, ccratout)
2121 !
2122 ! --Terms are filled, now accumulate them for this time step
2123 call this%budobj%accumulate_terms()
2124 end subroutine apt_fill_budobj
2125
2126 !> @brief Copy flow terms into this%budobj, must be overridden
2127 !<
2128 subroutine pak_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
2129 ! -- modules
2130 ! -- dummy
2131 class(tspapttype) :: this
2132 integer(I4B), intent(inout) :: idx
2133 real(DP), dimension(:), intent(in) :: x
2134 real(DP), dimension(:), contiguous, intent(inout) :: flowja
2135 real(DP), intent(inout) :: ccratin
2136 real(DP), intent(inout) :: ccratout
2137 ! -- local
2138 ! -- formats
2139 !
2140 ! -- this routine should never be called
2141 call store_error('Program error: pak_fill_budobj not implemented.', &
2142 terminate=.true.)
2143 end subroutine pak_fill_budobj
2144
2145 !> @brief Account for mass or energy storage in advanced package features
2146 !<
2147 subroutine apt_stor_term(this, ientry, n1, n2, rrate, &
2148 rhsval, hcofval)
2149 use tdismodule, only: delt
2150 class(tspapttype) :: this
2151 integer(I4B), intent(in) :: ientry
2152 integer(I4B), intent(inout) :: n1
2153 integer(I4B), intent(inout) :: n2
2154 real(DP), intent(inout), optional :: rrate
2155 real(DP), intent(inout), optional :: rhsval
2156 real(DP), intent(inout), optional :: hcofval
2157 real(DP) :: v0, v1
2158 real(DP) :: c0, c1
2159 !
2160 n1 = ientry
2161 n2 = ientry
2162 call this%apt_get_volumes(n1, v1, v0, delt)
2163 c0 = this%xoldpak(n1)
2164 c1 = this%xnewpak(n1)
2165 if (present(rrate)) then
2166 rrate = (-c1 * v1 / delt + c0 * v0 / delt) * this%eqnsclfac
2167 end if
2168 !
2169 if (present(rhsval)) rhsval = -c0 * v0 * this%eqnsclfac / delt
2170 if (present(hcofval)) hcofval = -v1 * this%eqnsclfac / delt
2171 end subroutine apt_stor_term
2172
2173 !> @brief Account for mass or energy transferred to the MVR package
2174 !<
2175 subroutine apt_tmvr_term(this, ientry, n1, n2, rrate, &
2176 rhsval, hcofval)
2177 ! -- modules
2178 ! -- dummy
2179 class(tspapttype) :: this
2180 integer(I4B), intent(in) :: ientry
2181 integer(I4B), intent(inout) :: n1
2182 integer(I4B), intent(inout) :: n2
2183 real(DP), intent(inout), optional :: rrate
2184 real(DP), intent(inout), optional :: rhsval
2185 real(DP), intent(inout), optional :: hcofval
2186 ! -- local
2187 real(DP) :: qbnd
2188 real(DP) :: ctmp
2189 !
2190 ! -- Calculate MVR-related terms
2191 n1 = this%flowbudptr%budterm(this%idxbudtmvr)%id1(ientry)
2192 n2 = this%flowbudptr%budterm(this%idxbudtmvr)%id2(ientry)
2193 qbnd = this%flowbudptr%budterm(this%idxbudtmvr)%flow(ientry)
2194 ctmp = this%xnewpak(n1)
2195 if (present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2196 if (present(rhsval)) rhsval = dzero
2197 if (present(hcofval)) hcofval = qbnd * this%eqnsclfac
2198 end subroutine apt_tmvr_term
2199
2200 !> @brief Account for mass or energy transferred to this package from the
2201 !! MVR package
2202 !<
2203 subroutine apt_fmvr_term(this, ientry, n1, n2, rrate, &
2204 rhsval, hcofval)
2205 ! -- modules
2206 ! -- dummy
2207 class(tspapttype) :: this
2208 integer(I4B), intent(in) :: ientry
2209 integer(I4B), intent(inout) :: n1
2210 integer(I4B), intent(inout) :: n2
2211 real(DP), intent(inout), optional :: rrate
2212 real(DP), intent(inout), optional :: rhsval
2213 real(DP), intent(inout), optional :: hcofval
2214 !
2215 ! -- Calculate MVR-related terms
2216 n1 = ientry
2217 n2 = n1
2218 if (present(rrate)) rrate = this%qmfrommvr(n1) ! NOTE: When bringing in GWE, ensure this is in terms of energy. Might need to apply eqnsclfac here.
2219 if (present(rhsval)) rhsval = this%qmfrommvr(n1)
2220 if (present(hcofval)) hcofval = dzero
2221 end subroutine apt_fmvr_term
2222
2223 !> @brief Go through each "within apt-apt" connection (e.g., lkt-lkt, or
2224 !! sft-sft) and accumulate total mass (or energy) in dbuff mass
2225 !<
2226 subroutine apt_fjf_term(this, ientry, n1, n2, rrate, &
2227 rhsval, hcofval)
2228 ! -- modules
2229 ! -- dummy
2230 class(tspapttype) :: this
2231 integer(I4B), intent(in) :: ientry
2232 integer(I4B), intent(inout) :: n1
2233 integer(I4B), intent(inout) :: n2
2234 real(DP), intent(inout), optional :: rrate
2235 real(DP), intent(inout), optional :: rhsval
2236 real(DP), intent(inout), optional :: hcofval
2237 ! -- local
2238 real(DP) :: qbnd
2239 real(DP) :: ctmp
2240 !
2241 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(ientry)
2242 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(ientry)
2243 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(ientry)
2244 if (qbnd <= 0) then
2245 ctmp = this%xnewpak(n1)
2246 else
2247 ctmp = this%xnewpak(n2)
2248 end if
2249 if (present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2250 if (present(rhsval)) rhsval = -rrate * this%eqnsclfac
2251 if (present(hcofval)) hcofval = dzero
2252 end subroutine apt_fjf_term
2253
2254 !> @brief Copy concentrations (or temperatures) into flow package aux
2255 !! variable
2256 !<
2257 subroutine apt_copy2flowp(this)
2258 ! -- modules
2259 ! -- dummy
2260 class(tspapttype) :: this
2261 ! -- local
2262 integer(I4B) :: n, j
2263 !
2264 ! -- copy
2265 if (this%iauxfpconc /= 0) then
2266 !
2267 ! -- go through each apt-gwf connection
2268 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2269 !
2270 ! -- set n to feature number and process if active feature
2271 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2272 this%flowpackagebnd%auxvar(this%iauxfpconc, j) = this%xnewpak(n)
2273 end do
2274 end if
2275 end subroutine apt_copy2flowp
2276
2277 !> @brief Determine whether an obs type is supported
2278 !!
2279 !! This function:
2280 !! - returns true if APT package supports named observation.
2281 !! - overrides BndType%bnd_obs_supported()
2282 !<
2283 logical function apt_obs_supported(this)
2284 ! -- modules
2285 ! -- dummy
2286 class(tspapttype) :: this
2287 !
2288 ! -- Set to true
2289 apt_obs_supported = .true.
2290 end function apt_obs_supported
2291
2292 !> @brief Define observation type
2293 !!
2294 !! This routine:
2295 !! - stores observation types supported by APT package.
2296 !! - overrides BndType%bnd_df_obs
2297 !<
2298 subroutine apt_df_obs(this)
2299 ! -- modules
2300 ! -- dummy
2301 class(tspapttype) :: this
2302 ! -- local
2303 !
2304 ! -- call additional specific observations for lkt, sft, mwt, and uzt
2305 call this%pak_df_obs()
2306 end subroutine apt_df_obs
2307
2308 !> @brief Define apt observation type
2309 !!
2310 !! This routine:
2311 !! - stores observations supported by the APT package
2312 !! - must be overridden by child class
2313 subroutine pak_df_obs(this)
2314 ! -- modules
2315 ! -- dummy
2316 class(tspapttype) :: this
2317 ! -- local
2318 !
2319 ! -- this routine should never be called
2320 call store_error('Program error: pak_df_obs not implemented.', &
2321 terminate=.true.)
2322 end subroutine pak_df_obs
2323
2324 !> @brief Process package specific obs
2325 !!
2326 !! Method to process specific observations for this package.
2327 !<
2328 subroutine pak_rp_obs(this, obsrv, found)
2329 ! -- dummy
2330 class(tspapttype), intent(inout) :: this !< package class
2331 type(observetype), intent(inout) :: obsrv !< observation object
2332 logical, intent(inout) :: found !< indicate whether observation was found
2333 ! -- local
2334 !
2335 ! -- this routine should never be called
2336 call store_error('Program error: pak_rp_obs not implemented.', &
2337 terminate=.true.)
2338 end subroutine pak_rp_obs
2339
2340 !> @brief Prepare observation
2341 !!
2342 !! Find the indices for this observation assuming they are indexed by
2343 !! feature number
2344 !<
2345 subroutine rp_obs_byfeature(this, obsrv)
2346 class(tspapttype), intent(inout) :: this !< object
2347 type(observetype), intent(inout) :: obsrv !< observation
2348 integer(I4B) :: nn1
2349 integer(I4B) :: j
2350 logical :: jfound
2351 character(len=*), parameter :: fmterr = &
2352 "('Boundary ', a, ' for observation ', a, &
2353 &' is invalid in package ', a)"
2354 nn1 = obsrv%NodeNumber
2355 if (nn1 == namedboundflag) then
2356 jfound = .false.
2357 do j = 1, this%ncv
2358 if (this%featname(j) == obsrv%FeatureName) then
2359 jfound = .true.
2360 call obsrv%AddObsIndex(j)
2361 end if
2362 end do
2363 if (.not. jfound) then
2364 write (errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2365 trim(this%packName)
2366 call store_error(errmsg)
2367 end if
2368 else
2369 !
2370 ! -- ensure nn1 is > 0 and <= ncv
2371 if (nn1 < 1 .or. nn1 > this%ncv) then
2372 write (errmsg, '(7a, i0, a, i0, a)') &
2373 'Observation ', trim(obsrv%Name), ' of type ', &
2374 trim(adjustl(obsrv%ObsTypeId)), ' in package ', &
2375 trim(this%packName), ' was assigned ID = ', nn1, &
2376 '. ID must be >= 1 and <= ', this%ncv, '.'
2377 call store_error(errmsg)
2378 end if
2379 call obsrv%AddObsIndex(nn1)
2380 end if
2381 end subroutine rp_obs_byfeature
2382
2383 !> @brief Prepare observation
2384 !!
2385 !! Find the indices for this observation assuming they are first indexed
2386 !! by feature number and secondly by a connection number
2387 !<
2388 subroutine rp_obs_budterm(this, obsrv, budterm)
2389 class(tspapttype), intent(inout) :: this !< object
2390 type(observetype), intent(inout) :: obsrv !< observation
2391 type(budgettermtype), intent(in) :: budterm !< budget term
2392 integer(I4B) :: nn1
2393 integer(I4B) :: iconn
2394 integer(I4B) :: icv
2395 integer(I4B) :: idx
2396 integer(I4B) :: j
2397 logical :: jfound
2398 character(len=*), parameter :: fmterr = &
2399 "('Boundary ', a, ' for observation ', a, &
2400 &' is invalid in package ', a)"
2401 nn1 = obsrv%NodeNumber
2402 if (nn1 == namedboundflag) then
2403 jfound = .false.
2404 do j = 1, budterm%nlist
2405 icv = budterm%id1(j)
2406 if (this%featname(icv) == obsrv%FeatureName) then
2407 jfound = .true.
2408 call obsrv%AddObsIndex(j)
2409 end if
2410 end do
2411 if (.not. jfound) then
2412 write (errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2413 trim(this%packName)
2414 call store_error(errmsg)
2415 end if
2416 else
2417 !
2418 ! -- ensure nn1 is > 0 and <= ncv
2419 if (nn1 < 1 .or. nn1 > this%ncv) then
2420 write (errmsg, '(7a, i0, a, i0, a)') &
2421 'Observation ', trim(obsrv%Name), ' of type ', &
2422 trim(adjustl(obsrv%ObsTypeId)), ' in package ', &
2423 trim(this%packName), ' was assigned ID = ', nn1, &
2424 '. ID must be >= 1 and <= ', this%ncv, '.'
2425 call store_error(errmsg)
2426 end if
2427 iconn = obsrv%NodeNumber2
2428 ! -- idx stays 0 if the feature has no rows in this budget term
2429 idx = 0
2430 do j = 1, budterm%nlist
2431 if (budterm%id1(j) == nn1) then
2432 ! -- Look for the first occurrence of nn1, then set indxbnds
2433 ! to the iconn record after that
2434 idx = j + iconn - 1
2435 call obsrv%AddObsIndex(idx)
2436 exit
2437 end if
2438 end do
2439 if (idx < 1 .or. idx > budterm%nlist) then
2440 write (errmsg, '(7a, i0, a, i0, a)') &
2441 'Observation ', trim(obsrv%Name), ' of type ', &
2442 trim(adjustl(obsrv%ObsTypeId)), ' in package ', &
2443 trim(this%packName), ' specifies iconn = ', iconn, &
2444 ', but this is not a valid connection for ID ', nn1, '.'
2445 call store_error(errmsg)
2446 else if (budterm%id1(idx) /= nn1) then
2447 write (errmsg, '(7a, i0, a, i0, a)') &
2448 'Observation ', trim(obsrv%Name), ' of type ', &
2449 trim(adjustl(obsrv%ObsTypeId)), ' in package ', &
2450 trim(this%packName), ' specifies iconn = ', iconn, &
2451 ', but this is not a valid connection for ID ', nn1, '.'
2452 call store_error(errmsg)
2453 end if
2454 end if
2455 end subroutine rp_obs_budterm
2456
2457 !> @brief Prepare observation
2458 !!
2459 !! Find the indices for this observation assuming they are first indexed
2460 !! by a feature number and secondly by a second feature number
2461 !<
2462 subroutine rp_obs_flowjaface(this, obsrv, budterm)
2463 class(tspapttype), intent(inout) :: this !< object
2464 type(observetype), intent(inout) :: obsrv !< observation
2465 type(budgettermtype), intent(in) :: budterm !< budget term
2466 integer(I4B) :: nn1
2467 integer(I4B) :: nn2
2468 integer(I4B) :: icv
2469 integer(I4B) :: j
2470 logical :: jfound
2471 character(len=*), parameter :: fmterr = &
2472 "('Boundary ', a, ' for observation ', a, &
2473 &' is invalid in package ', a)"
2474 nn1 = obsrv%NodeNumber
2475 if (nn1 == namedboundflag) then
2476 jfound = .false.
2477 do j = 1, budterm%nlist
2478 icv = budterm%id1(j)
2479 if (this%featname(icv) == obsrv%FeatureName) then
2480 jfound = .true.
2481 call obsrv%AddObsIndex(j)
2482 end if
2483 end do
2484 if (.not. jfound) then
2485 write (errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2486 trim(this%packName)
2487 call store_error(errmsg)
2488 end if
2489 else
2490 !
2491 ! -- ensure nn1 is > 0 and <= ncv
2492 if (nn1 < 1 .or. nn1 > this%ncv) then
2493 write (errmsg, '(7a, i0, a, i0, a)') &
2494 'Observation ', trim(obsrv%Name), ' of type ', &
2495 trim(adjustl(obsrv%ObsTypeId)), ' in package ', &
2496 trim(this%packName), ' was assigned ID = ', nn1, &
2497 '. ID must be >= 1 and <= ', this%ncv, '.'
2498 call store_error(errmsg)
2499 end if
2500 nn2 = obsrv%NodeNumber2
2501 !
2502 ! -- ensure nn2 is > 0 and <= ncv
2503 if (nn2 < 1 .or. nn2 > this%ncv) then
2504 write (errmsg, '(7a, i0, a, i0, a)') &
2505 'Observation ', trim(obsrv%Name), ' of type ', &
2506 trim(adjustl(obsrv%ObsTypeId)), ' in package ', &
2507 trim(this%packName), ' was assigned ID2 = ', nn2, &
2508 '. ID must be >= 1 and <= ', this%ncv, '.'
2509 call store_error(errmsg)
2510 end if
2511 ! -- Look for nn1 and nn2 in id1 and id2
2512 jfound = .false.
2513 do j = 1, budterm%nlist
2514 if (budterm%id1(j) == nn1 .and. budterm%id2(j) == nn2) then
2515 call obsrv%AddObsIndex(j)
2516 jfound = .true.
2517 end if
2518 end do
2519 if (.not. jfound) then
2520 write (errmsg, '(7a, i0, a, i0, a)') &
2521 'Observation ', trim(obsrv%Name), ' of type ', &
2522 trim(adjustl(obsrv%ObsTypeId)), ' in package ', &
2523 trim(this%packName), &
2524 ' specifies a connection between feature ', nn1, &
2525 ' feature ', nn2, ', but these features are not connected.'
2526 call store_error(errmsg)
2527 end if
2528 end if
2529 end subroutine rp_obs_flowjaface
2530
2531 !> @brief Read and prepare apt-related observations
2532 !!
2533 !! Method to process specific observations for an apt package
2534 !<
2535 subroutine apt_rp_obs(this)
2536 ! -- modules
2537 use tdismodule, only: kper
2538 ! -- dummy
2539 class(tspapttype), intent(inout) :: this
2540 ! -- local
2541 integer(I4B) :: i
2542 logical :: found
2543 class(observetype), pointer :: obsrv => null()
2544 !
2545 if (kper == 1) then
2546 do i = 1, this%obs%npakobs
2547 obsrv => this%obs%pakobs(i)%obsrv
2548 select case (obsrv%ObsTypeId)
2549 case ('CONCENTRATION', 'TEMPERATURE')
2550 call this%rp_obs_byfeature(obsrv)
2551 !
2552 ! -- catch non-cumulative observation assigned to observation defined
2553 ! by a boundname that is assigned to more than one element
2554 if (obsrv%indxbnds_count > 1) then
2555 write (errmsg, '(a, a, a, a)') &
2556 trim(adjustl(this%depvartype))// &
2557 ' for observation', trim(adjustl(obsrv%Name)), &
2558 ' must be assigned to a feature with a unique boundname.'
2559 call store_error(errmsg)
2560 end if
2561 case ('LKT', 'SFT', 'MWT', 'UZT', 'LKE', 'SFE', 'MWE', 'UZE')
2562 call this%rp_obs_budterm(obsrv, &
2563 this%flowbudptr%budterm(this%idxbudgwf))
2564 case ('FLOW-JA-FACE')
2565 if (this%idxbudfjf > 0) then
2566 call this%rp_obs_flowjaface(obsrv, &
2567 this%flowbudptr%budterm(this%idxbudfjf))
2568 else
2569 write (errmsg, '(7a)') &
2570 'Observation ', trim(obsrv%Name), ' of type ', &
2571 trim(adjustl(obsrv%ObsTypeId)), ' in package ', &
2572 trim(this%packName), &
2573 ' cannot be processed because there are no flow connections.'
2574 call store_error(errmsg)
2575 end if
2576 case ('STORAGE')
2577 call this%rp_obs_byfeature(obsrv)
2578 case ('CONSTANT')
2579 call this%rp_obs_byfeature(obsrv)
2580 case ('FROM-MVR')
2581 call this%rp_obs_byfeature(obsrv)
2582 case default
2583 !
2584 ! -- check the child package for any specific obs
2585 found = .false.
2586 call this%pak_rp_obs(obsrv, found)
2587 !
2588 ! -- if none found then terminate with an error
2589 if (.not. found) then
2590 errmsg = 'Unrecognized observation type "'// &
2591 trim(obsrv%ObsTypeId)//'" for '// &
2592 trim(adjustl(this%text))//' package '// &
2593 trim(this%packName)
2594 call store_error(errmsg, terminate=.true.)
2595 end if
2596 end select
2597
2598 end do
2599 !
2600 ! -- check for errors
2601 if (count_errors() > 0) then
2602 call store_error_unit(this%obs%inunitobs)
2603 end if
2604 end if
2605 end subroutine apt_rp_obs
2606
2607 !> @brief Calculate observation values
2608 !!
2609 !! Routine calculates observations common to SFT/LKT/MWT/UZT
2610 !! (or SFE/LKE/MWE/UZE) for as many TspAptType observations that are common
2611 !! among the advanced transport packages
2612 !<
2613 subroutine apt_bd_obs(this)
2614 ! -- modules
2615 ! -- dummy
2616 class(tspapttype) :: this
2617 ! -- local
2618 integer(I4B) :: i
2619 integer(I4B) :: igwfnode
2620 integer(I4B) :: j
2621 integer(I4B) :: jj
2622 integer(I4B) :: n
2623 integer(I4B) :: n1
2624 integer(I4B) :: n2
2625 real(DP) :: v
2626 type(observetype), pointer :: obsrv => null()
2627 logical :: found
2628 !
2629 ! -- Write simulated values for all Advanced Package observations
2630 if (this%obs%npakobs > 0) then
2631 call this%obs%obs_bd_clear()
2632 do i = 1, this%obs%npakobs
2633 obsrv => this%obs%pakobs(i)%obsrv
2634 do j = 1, obsrv%indxbnds_count
2635 v = dnodata
2636 jj = obsrv%indxbnds(j)
2637 select case (obsrv%ObsTypeId)
2638 case ('CONCENTRATION', 'TEMPERATURE')
2639 if (this%iboundpak(jj) /= 0) then
2640 v = this%xnewpak(jj)
2641 end if
2642 case ('LKT', 'SFT', 'MWT', 'UZT', 'LKE', 'SFE', 'MWE', 'UZE')
2643 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(jj)
2644 if (this%iboundpak(n) /= 0) then
2645 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(jj)
2646 v = this%hcof(jj) * this%xnew(igwfnode) - this%rhs(jj)
2647 v = -v
2648 end if
2649 case ('FLOW-JA-FACE')
2650 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(jj)
2651 if (this%iboundpak(n) /= 0) then
2652 call this%apt_fjf_term(jj, n1, n2, v)
2653 end if
2654 case ('STORAGE')
2655 if (this%iboundpak(jj) /= 0) then
2656 v = this%qsto(jj)
2657 end if
2658 case ('CONSTANT')
2659 if (this%iboundpak(jj) /= 0) then
2660 v = this%ccterm(jj)
2661 end if
2662 case ('FROM-MVR')
2663 if (this%iboundpak(jj) /= 0 .and. this%idxbudfmvr > 0) then
2664 call this%apt_fmvr_term(jj, n1, n2, v)
2665 end if
2666 case ('TO-MVR')
2667 if (this%idxbudtmvr > 0) then
2668 n = this%flowbudptr%budterm(this%idxbudtmvr)%id1(jj)
2669 if (this%iboundpak(n) /= 0) then
2670 call this%apt_tmvr_term(jj, n1, n2, v)
2671 end if
2672 end if
2673 case default
2674 found = .false.
2675 !
2676 ! -- check the child package for any specific obs
2677 call this%pak_bd_obs(obsrv%ObsTypeId, jj, v, found)
2678 !
2679 ! -- if none found then terminate with an error
2680 if (.not. found) then
2681 errmsg = 'Unrecognized observation type "'// &
2682 trim(obsrv%ObsTypeId)//'" for '// &
2683 trim(adjustl(this%text))//' package '// &
2684 trim(this%packName)
2685 call store_error(errmsg, terminate=.true.)
2686 end if
2687 end select
2688 call this%obs%SaveOneSimval(obsrv, v)
2689 end do
2690 end do
2691 !
2692 ! -- write summary of error messages
2693 if (count_errors() > 0) then
2694 call store_error_unit(this%obs%inunitobs)
2695 end if
2696 end if
2697 end subroutine apt_bd_obs
2698
2699 !> @brief Check if observation exists in an advanced package
2700 !<
2701 subroutine pak_bd_obs(this, obstypeid, jj, v, found)
2702 ! -- dummy
2703 class(tspapttype), intent(inout) :: this
2704 character(len=*), intent(in) :: obstypeid
2705 integer(I4B), intent(in) :: jj
2706 real(DP), intent(inout) :: v
2707 logical, intent(inout) :: found
2708 ! -- local
2709 !
2710 ! -- set found = .false. because obstypeid is not known
2711 found = .false.
2712 end subroutine pak_bd_obs
2713
2714 !> @brief Process observation IDs for an advanced package
2715 !!
2716 !! Method to process observation ID strings for an APT package.
2717 !! This processor is only for observation types that support ID1
2718 !! and not ID2.
2719 !<
2720 subroutine apt_process_obsid(obsrv, dis, inunitobs, iout)
2721 ! -- dummy variables
2722 type(observetype), intent(inout) :: obsrv !< Observation object
2723 class(disbasetype), intent(in) :: dis !< Discretization object
2724 integer(I4B), intent(in) :: inunitobs !< file unit number for the package observation file
2725 integer(I4B), intent(in) :: iout !< model listing file unit number
2726 ! -- local variables
2727 integer(I4B) :: nn1
2728 integer(I4B) :: icol
2729 integer(I4B) :: istart
2730 integer(I4B) :: istop
2731 character(len=LINELENGTH) :: string
2732 character(len=LENBOUNDNAME) :: bndname
2733 !
2734 ! -- initialize local variables
2735 string = obsrv%IDstring
2736 !
2737 ! -- Extract reach number from string and store it.
2738 ! If 1st item is not an integer(I4B), it should be a
2739 ! boundary name--deal with it.
2740 icol = 1
2741 !
2742 ! -- get reach number or boundary name
2743 call extract_idnum_or_bndname(string, icol, istart, istop, nn1, bndname)
2744 if (nn1 == namedboundflag) then
2745 obsrv%FeatureName = bndname
2746 end if
2747 !
2748 ! -- store reach number (NodeNumber)
2749 obsrv%NodeNumber = nn1
2750 !
2751 ! -- store NodeNumber2 as 1 so that this can be used
2752 ! as the iconn value for SFT. This works for SFT
2753 ! because there is only one reach per GWT connection.
2754 obsrv%NodeNumber2 = 1
2755 end subroutine apt_process_obsid
2756
2757 !> @brief Process observation IDs for a package
2758 !!
2759 !! Method to process observation ID strings for an APT package. This
2760 !! processor is for the case where if ID1 is an integer then ID2 must be
2761 !! provided.
2762 !<
2763 subroutine apt_process_obsid12(obsrv, dis, inunitobs, iout)
2764 ! -- dummy variables
2765 type(observetype), intent(inout) :: obsrv !< Observation object
2766 class(disbasetype), intent(in) :: dis !< Discretization object
2767 integer(I4B), intent(in) :: inunitobs !< file unit number for the package observation file
2768 integer(I4B), intent(in) :: iout !< model listing file unit number
2769 ! -- local variables
2770 integer(I4B) :: nn1
2771 integer(I4B) :: iconn
2772 integer(I4B) :: icol
2773 integer(I4B) :: istart
2774 integer(I4B) :: istop
2775 character(len=LINELENGTH) :: string
2776 character(len=LENBOUNDNAME) :: bndname
2777 !
2778 ! -- initialize local variables
2779 string = obsrv%IDstring
2780 !
2781 ! -- Extract reach number from string and store it.
2782 ! If 1st item is not an integer(I4B), it should be a
2783 ! boundary name--deal with it.
2784 icol = 1
2785 !
2786 ! -- get reach number or boundary name
2787 call extract_idnum_or_bndname(string, icol, istart, istop, nn1, bndname)
2788 if (nn1 == namedboundflag) then
2789 obsrv%FeatureName = bndname
2790 else
2791 call extract_idnum_or_bndname(string, icol, istart, istop, iconn, bndname)
2792 if (len_trim(bndname) < 1 .and. iconn < 0) then
2793 write (errmsg, '(a,1x,a,a,1x,a,1x,a)') &
2794 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
2795 ', ID given as an integer and not as boundname,', &
2796 'but ID2 is missing. Either change ID to valid', &
2797 'boundname or supply valid entry for ID2.'
2798 call store_error(errmsg)
2799 end if
2800 obsrv%NodeNumber2 = iconn
2801 end if
2802 !
2803 ! -- store reach number (NodeNumber)
2804 obsrv%NodeNumber = nn1
2805 end subroutine apt_process_obsid12
2806
2807 !> @brief Setup a table object an advanced package
2808 !!
2809 !! Set up the table object that is used to write the apt concentration
2810 !! (or temperature) data. The terms listed here must correspond in the
2811 !! apt_ot method.
2812 !<
2813 subroutine apt_setup_tableobj(this)
2814 ! -- modules
2816 ! -- dummy
2817 class(tspapttype) :: this
2818 ! -- local
2819 integer(I4B) :: nterms
2820 character(len=LINELENGTH) :: title
2821 character(len=LINELENGTH) :: text_temp
2822 !
2823 ! -- setup well head table
2824 if (this%iprconc > 0) then
2825 !
2826 ! -- Determine the number of head table columns
2827 nterms = 2
2828 if (this%inamedbound == 1) nterms = nterms + 1
2829 !
2830 ! -- set up table title
2831 title = trim(adjustl(this%text))//' PACKAGE ('// &
2832 trim(adjustl(this%packName))// &
2833 ') '//trim(adjustl(this%depvartype))// &
2834 &' FOR EACH CONTROL VOLUME'
2835 !
2836 ! -- set up dv tableobj
2837 call table_cr(this%dvtab, this%packName, title)
2838 call this%dvtab%table_df(this%ncv, nterms, this%iout, &
2839 transient=.true.)
2840 !
2841 ! -- Go through and set up table budget term
2842 if (this%inamedbound == 1) then
2843 text_temp = 'NAME'
2844 call this%dvtab%initialize_column(text_temp, 20, alignment=tableft)
2845 end if
2846 !
2847 ! -- feature number
2848 text_temp = 'NUMBER'
2849 call this%dvtab%initialize_column(text_temp, 10, alignment=tabcenter)
2850 !
2851 ! -- feature conc
2852 text_temp = this%depvartype(1:4)
2853 call this%dvtab%initialize_column(text_temp, 12, alignment=tabcenter)
2854 end if
2855 end subroutine apt_setup_tableobj
2856
2857end module tspaptmodule
This module contains the extended boundary package.
subroutine source_dimensions(this)
Source package dimensions from input context.
subroutine source_options(this)
Source package options from input context.
This module contains the base boundary package.
logical(lgp) function bnd_obs_supported(this)
Determine if observations are supported.
subroutine bnd_ar(this)
Allocate and read method for boundary package.
subroutine bnd_rp(this)
Allocate and read method for package.
subroutine allocate_scalars(this)
Allocate package scalars.
subroutine bnd_ot_dv(this, idvsave, idvprint)
Output advanced package dependent-variable terms.
subroutine bnd_ot_package_flows(this, icbcfl, ibudfl)
Output advanced package flow terms.
subroutine bnd_bd_obs(this)
Save observations for the package.
subroutine bnd_da(this)
Deallocate package memory.
subroutine bnd_mc(this, moffset, matrix_sln)
Map boundary package connection to matrix.
subroutine bnd_fc(this, rhs, ia, idxglo, matrix_sln)
Copy hcof and rhs terms into solution.
subroutine bnd_ac(this, moffset, sparse)
Add boundary package connection to matrix.
subroutine bnd_ot_bdsummary(this, kstp, kper, iout, ibudfl)
Output advanced package budget summary.
subroutine bnd_df_obs(this)
Define the observation types available in the package.
subroutine bnd_reset(this)
Reset bnd package before formulating.
subroutine set_pointers(this, neq, ibound, xnew, xold, flowja)
Set pointers to model variables.
subroutine bnd_rp_obs(this)
Read and prepare observations for a package.
subroutine bnd_ad(this)
Advance the boundary package.
subroutine bnd_cq(this, x, flowja, iadv)
Calculate advanced package flows.
subroutine define_listlabel(this)
Define the list label for the package.
This module contains the BudgetModule.
Definition Budget.f90:20
subroutine, public budget_cr(this, name_model)
Create a new budget object.
Definition Budget.f90:85
subroutine, public budgetobject_cr(this, name)
Create a new budget object.
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
real(dp), parameter dhdry
real dry cell constant
Definition Constants.f90:94
@ tabcenter
centered table column
@ tabright
right justified table column
@ tableft
left justified table column
@ mnormal
normal output mode
@ tabucstring
upper case string table data
@ tabstring
string table data
@ tabreal
real table data
@ tabinteger
integer table data
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition Constants.f90:23
integer(i4b), parameter namedboundflag
named bound flag
Definition Constants.f90:49
real(dp), parameter dnodata
real no data constant
Definition Constants.f90:95
real(dp), parameter dhnoflo
real no flow constant
Definition Constants.f90:93
real(dp), parameter dep20
real constant 1e20
Definition Constants.f90:91
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition Constants.f90:17
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
Definition Constants.f90:39
integer(i4b), parameter lenauxname
maximum length of a aux variable
Definition Constants.f90:35
integer(i4b), parameter lenboundname
maximum length of a bound name
Definition Constants.f90:36
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition Constants.f90:37
real(dp), parameter done
real constant 1
Definition Constants.f90:76
subroutine, public assign_iounit(iounit, errunit, description)
assign io unit number
subroutine, public extract_idnum_or_bndname(line, icol, istart, istop, idnum, bndname)
Starting at position icol, define string as line(istart:istop).
character(len=max(len_trim(str), width)) function, public str_pad_left(str, width)
Function for string manipulation.
subroutine, public ulasav(buf, text, kstp, kper, pertim, totim, ncol, nrow, ilay, ichn)
Save 1 layer array on disk.
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
This module defines variable data types.
Definition kind.f90:8
Previous variable names checked in as deprecated aliases.
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
subroutine, public get_isize(name, mem_path, isize)
Get the number of elements for this variable.
This module contains the derived types ObserveType and ObsDataType.
Definition Observe.f90:15
character(len=20) access
Definition OpenSpec.f90:7
character(len=20) form
Definition OpenSpec.f90:7
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
integer(i4b) function, public count_errors()
Return number of errors.
Definition Sim.f90:60
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
Definition Sim.f90:172
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
integer(i4b) ifailedstepretry
current retry for this time step
subroutine finalize(this)
Definition Table.f90:407
subroutine, public table_cr(this, name, title)
Definition Table.f90:87
real(dp), pointer, public pertim
time relative to start of stress period
Definition tdis.f90:33
real(dp), pointer, public totim
time relative to start of simulation
Definition tdis.f90:35
integer(i4b), pointer, public kstp
current time step number
Definition tdis.f90:27
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
real(dp), pointer, public delt
length of the current time step
Definition tdis.f90:32
subroutine apt_ot_bdsummary(this, kstp, kper, iout, ibudfl)
Print advanced package transport dependent variables.
Definition tsp-apt.f90:1000
subroutine apt_cfupdate(this)
Advanced package transport routine.
Definition tsp-apt.f90:850
subroutine apt_checkin_deprecated_names(this)
Alias deprecated advanced transport variable names.
Definition tsp-apt.f90:1192
subroutine pak_setup_budobj(this, idx)
Set up a budget object that stores an advanced package flows.
Definition tsp-apt.f90:1982
subroutine apt_ar(this)
Advanced package transport allocate and read (ar) routine.
Definition tsp-apt.f90:310
subroutine pak_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
Copy flow terms into thisbudobj, must be overridden.
Definition tsp-apt.f90:2129
subroutine apt_ad_resync(this)
Per-timestep TS re-sync and state update.
Definition tsp-apt.f90:585
subroutine rp_obs_flowjaface(this, obsrv, budterm)
Prepare observation.
Definition tsp-apt.f90:2463
subroutine pak_bd_obs(this, obstypeid, jj, v, found)
Check if observation exists in an advanced package.
Definition tsp-apt.f90:2702
subroutine apt_source_options(this)
Source OPTIONS block from the input context.
Definition tsp-apt.f90:1306
subroutine apt_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
Advanced package transport fill coefficient (fc) method.
Definition tsp-apt.f90:721
subroutine pak_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
Advanced package transport fill coefficient (fc) method.
Definition tsp-apt.f90:830
subroutine apt_fjf_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Go through each "within apt-apt" connection (e.g., lkt-lkt, or sft-sft) and accumulate total mass (or...
Definition tsp-apt.f90:2228
subroutine rp_obs_budterm(this, obsrv, budterm)
Prepare observation.
Definition tsp-apt.f90:2389
subroutine apt_read_initial_attr(this)
Read the initial parameters for an advanced package.
Definition tsp-apt.f90:1529
subroutine apt_setup_budobj(this)
Set up the budget object that stores advanced package flow terms.
Definition tsp-apt.f90:1799
subroutine apt_allocate_index_arrays(this)
Allocate index arrays.
Definition tsp-apt.f90:1073
subroutine apt_rp_obs(this)
Read and prepare apt-related observations.
Definition tsp-apt.f90:2536
character(len=lenvarname) text
Definition tsp-apt.f90:71
subroutine apt_ot_package_flows(this, icbcfl, ibudfl)
Save advanced package flows routine.
Definition tsp-apt.f90:920
real(dp) function, dimension(:), pointer, contiguous get_mvr_depvar(this)
Advanced package transport utility function.
Definition tsp-apt.f90:557
subroutine apt_allocate_arrays(this)
Allocate arrays.
Definition tsp-apt.f90:1130
integer(i4b) function pak_get_nbudterms(this)
Function to return the number of budget terms just for this package.
Definition tsp-apt.f90:1783
subroutine apt_df_obs(this)
Define observation type.
Definition tsp-apt.f90:2299
character(len=lenftype) ftype
Definition tsp-apt.f90:70
subroutine apt_fmvr_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Account for mass or energy transferred to this package from the MVR package.
Definition tsp-apt.f90:2205
subroutine apt_da(this)
Deallocate memory.
Definition tsp-apt.f90:1221
subroutine apt_ad_ts(this)
Virtual hook: called every timestep, after the time series manager advances, before apt_ad_chk....
Definition tsp-apt.f90:639
subroutine apt_mc(this, moffset, matrix_sln)
Advanced package transport map package connections to matrix.
Definition tsp-apt.f90:249
real(dp) function apt_setting_value(this, itemno, key)
Virtual hook: value for a package-specific PERIOD setting. Override in individual packages to supply ...
Definition tsp-apt.f90:649
subroutine apt_fill_budobj(this, x, flowja)
Copy flow terms into thisbudobj.
Definition tsp-apt.f90:1996
subroutine pak_rp_obs(this, obsrv, found)
Process package specific obs.
Definition tsp-apt.f90:2329
logical function apt_obs_supported(this)
Determine whether an obs type is supported.
Definition tsp-apt.f90:2284
subroutine apt_bd_obs(this)
Calculate observation values.
Definition tsp-apt.f90:2614
subroutine apt_solve(this)
Add terms specific to advanced package transport to the explicit solve.
Definition tsp-apt.f90:1578
subroutine apt_tmvr_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Account for mass or energy transferred to the MVR package.
Definition tsp-apt.f90:2177
subroutine apt_get_volumes(this, icv, vnew, vold, delt)
Return the feature new volume and old volume.
Definition tsp-apt.f90:1759
subroutine apt_source_cvs(this)
Source PACKAGEDATA feature information from the input context.
Definition tsp-apt.f90:1446
subroutine apt_set_pointers(this, neq, ibound, xnew, xold, flowja)
Set pointers to model arrays and variables so that a package has access to these items.
Definition tsp-apt.f90:1733
subroutine apt_accumulate_ccterm(this, ilak, rrate, ccratin, ccratout)
Accumulate constant concentration (or temperature) terms for budget.
Definition tsp-apt.f90:1677
subroutine apt_setup_tableobj(this)
Setup a table object an advanced package.
Definition tsp-apt.f90:2814
subroutine find_apt_package(this)
Find corresponding advanced package transport package.
Definition tsp-apt.f90:1292
subroutine apt_rp(this)
Advanced package transport read and prepare (rp) routine.
Definition tsp-apt.f90:380
subroutine apt_stor_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Account for mass or energy storage in advanced package features.
Definition tsp-apt.f90:2149
subroutine apt_source_dimensions(this)
Source DIMENSIONS from the flow package; allocate package arrays.
Definition tsp-apt.f90:1393
subroutine rp_obs_byfeature(this, obsrv)
Prepare observation.
Definition tsp-apt.f90:2346
subroutine apt_copy2flowp(this)
Copy concentrations (or temperatures) into flow package aux variable.
Definition tsp-apt.f90:2258
subroutine apt_cq(this, x, flowja, iadv)
Advanced package transport calculate flows (cq) routine.
Definition tsp-apt.f90:880
subroutine apt_ac(this, moffset, sparse)
Add package connection to matrix.
Definition tsp-apt.f90:202
subroutine, public apt_process_obsid(obsrv, dis, inunitobs, iout)
Process observation IDs for an advanced package.
Definition tsp-apt.f90:2721
subroutine apt_ad(this)
Advanced package transport routine.
Definition tsp-apt.f90:570
integer(i4b) function apt_check_valid(this, itemno)
Advanced package transport routine.
Definition tsp-apt.f90:537
subroutine apt_ad_chk(this)
Definition tsp-apt.f90:527
subroutine pak_solve(this)
Add terms specific to advanced package transport features to the explicit solve routine.
Definition tsp-apt.f90:1665
subroutine apt_fc_nonexpanded(this, rhs, ia, idxglo, matrix_sln)
Advanced package transport fill coefficient (fc) method.
Definition tsp-apt.f90:692
subroutine apt_reset(this)
Override bnd reset for custom mover logic.
Definition tsp-apt.f90:659
subroutine apt_fc(this, rhs, ia, idxglo, matrix_sln)
Definition tsp-apt.f90:669
subroutine apt_ot_dv(this, idvsave, idvprint)
Definition tsp-apt.f90:944
subroutine pak_df_obs(this)
Define apt observation type.
Definition tsp-apt.f90:2314
subroutine, public apt_process_obsid12(obsrv, dis, inunitobs, iout)
Process observation IDs for a package.
Definition tsp-apt.f90:2764
This class is used to store a single deferred-length character string. It was designed to work in an ...