MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
gwf-uzf.f90
Go to the documentation of this file.
1! -- Uzf module
3
4 use kindmodule, only: dp, i4b
5 use constantsmodule, only: dzero, dem6, dem4, dem2, dem1, dhalf, &
10 dhnoflo, dhdry, &
17 use sparsemodule, only: sparsematrix
18 use bndmodule, only: bndtype
19 use bndextmodule, only: bndexttype
23 use basedismodule, only: disbasetype
24 use observemodule, only: observetype
25 use obsmodule, only: obstype
34
35 implicit none
36
37 character(len=LENFTYPE) :: ftype = 'UZF'
38 character(len=LENPACKAGENAME) :: text = ' UZF CELLS'
39
40 private
41 public :: uzf_create
42 public :: uzftype
43
44 type, extends(bndexttype) :: uzftype
45 ! output integers
46 integer(I4B), pointer :: iprwcont => null()
47 integer(I4B), pointer :: iwcontout => null()
48 integer(I4B), pointer :: ibudgetout => null()
49 integer(I4B), pointer :: ibudcsv => null() !< unit number for csv budget output file
50 integer(I4B), pointer :: ipakcsv => null()
51 !
52 type(budgetobjecttype), pointer :: budobj => null()
53 integer(I4B), pointer :: bditems => null() !< number of budget items
54 integer(I4B), pointer :: nbdtxt => null() !< number of budget text items
55 character(len=LENBUDTXT), dimension(:), pointer, &
56 contiguous :: bdtxt => null() !< budget items written to cbc file
57 character(len=LENBOUNDNAME), dimension(:), pointer, &
58 contiguous :: uzfname => null()
59 !
60 ! -- uzf table objects
61 type(tabletype), pointer :: pakcsvtab => null()
62 !
63 ! -- uzf kinematic object
64 type(uzfcellgrouptype), pointer :: uzfobj => null()
65 !
66 ! -- pointer to gwf variables
67 integer(I4B), pointer :: gwfiss => null()
68 real(dp), dimension(:), pointer, contiguous :: gwfhcond => null()
69 !
70 ! -- uzf data
71 integer(I4B), pointer :: ntrail_input => null() !< NTRAILWAVES
72 integer(I4B), pointer :: nwavesets => null() !< NWAVESETS
73 integer(I4B), pointer :: nodes => null()
74 integer(I4B), pointer :: readflag => null()
75 integer(I4B), pointer :: ietflag => null() !< et flag, 0 is off, 1 or 2 are different types
76 integer(I4B), pointer :: igwetflag => null()
77 integer(I4B), pointer :: iseepflag => null()
78 integer(I4B), pointer :: imaxcellcnt => null()
79 integer(I4B), pointer :: iuzf2uzf => null()
80 ! -- integer vectors
81 integer(I4B), dimension(:), pointer, contiguous :: igwfnode => null()
82 integer(I4B), dimension(:), pointer, contiguous :: ia => null()
83 integer(I4B), dimension(:), pointer, contiguous :: ja => null()
84 ! -- double precision output vectors
85 real(dp), dimension(:), pointer, contiguous :: appliedinf => null()
86 real(dp), dimension(:), pointer, contiguous :: rejinf => null()
87 real(dp), dimension(:), pointer, contiguous :: rejinf0 => null()
88 real(dp), dimension(:), pointer, contiguous :: rejinftomvr => null()
89 real(dp), dimension(:), pointer, contiguous :: infiltration => null()
90 real(dp), dimension(:), pointer, contiguous :: uzet => null()
91 real(dp), dimension(:), pointer, contiguous :: gwd => null()
92 real(dp), dimension(:), pointer, contiguous :: gwd0 => null()
93 real(dp), dimension(:), pointer, contiguous :: gwdtomvr => null()
94 real(dp), dimension(:), pointer, contiguous :: rch => null()
95 real(dp), dimension(:), pointer, contiguous :: rch0 => null()
96 real(dp), dimension(:), pointer, contiguous :: qsto => null() !< change in stored mobile water per time for this time step
97 real(dp), dimension(:), pointer, contiguous :: wcnew => null() !< water content for this time step
98 real(dp), dimension(:), pointer, contiguous :: wcold => null() !< water content for previous time step
99 !
100 ! -- PERIOD input context arrays, each shadowing a uzfobj array of the same
101 ! meaning. The duplication is deliberate and cannot be removed by
102 ! copying the input straight into the uzfobj arrays. uzf_ad walks the
103 ! cells in order and the set routines write both the current cell and the
104 ! cell below it, so a cell that is the cell_below of another has its
105 ! uzfobj value overwritten before the loop reaches it. These arrays hold
106 ! the value the user supplied for each cell, untouched by that
107 ! propagation, and are the source uzf_ad reads from every time step.
108 real(dp), dimension(:), pointer, contiguous :: finf_input => null() !< FINF
109 real(dp), dimension(:), pointer, contiguous :: pet_input => null() !< PET
110 real(dp), dimension(:), pointer, contiguous :: extdp_input => null() !< EXTDP
111 real(dp), dimension(:), pointer, contiguous :: extwc_input => null() !< EXTWC
112 real(dp), dimension(:), pointer, contiguous :: ha_input => null() !< HA
113 real(dp), dimension(:), pointer, contiguous :: hroot_input => null() !< HROOT
114 real(dp), dimension(:), pointer, contiguous :: rootact_input => null() !< ROOTACT
115 !
116 ! -- aux variable
117 real(dp), dimension(:, :), pointer, contiguous :: uauxvar => null()
118 !
119 ! -- convergence check
120 integer(I4B), pointer :: iconvchk => null()
121 !
122 ! formulate variables
123 real(dp), dimension(:), pointer, contiguous :: deriv => null()
124 !
125 ! budget variables
126 real(dp), pointer :: totfluxtot => null()
127 integer(I4B), pointer :: issflag => null()
128 integer(I4B), pointer :: issflagold => null()
129 integer(I4B), pointer :: istocb => null()
130 !
131 ! -- uzf cbc budget items
132 integer(I4B), pointer :: cbcauxitems => null()
133 character(len=16), dimension(:), pointer, contiguous :: cauxcbc => null()
134 real(dp), dimension(:), pointer, contiguous :: qauxcbc => null()
135
136 contains
137
143 procedure :: bnd_ar => uzf_ar
144 procedure :: bnd_rp => uzf_rp
145 procedure :: bnd_ad => uzf_ad
146 procedure :: bnd_cf => uzf_cf
147 procedure :: bnd_cc => uzf_cc
148 procedure :: bnd_cq => uzf_cq
149 procedure :: bnd_bd => uzf_bd
152 procedure :: bnd_ot_dv => uzf_ot_dv
154 procedure :: bnd_fc => uzf_fc
155 procedure :: bnd_fn => uzf_fn
156 procedure :: bnd_da => uzf_da
157 procedure :: define_listlabel
158 !
159 ! -- methods for observations
160 procedure, public :: bnd_obs_supported => uzf_obs_supported
161 procedure, public :: bnd_df_obs => uzf_df_obs
162 procedure, public :: bnd_rp_obs => uzf_rp_obs
163 procedure, public :: bnd_bd_obs => uzf_bd_obs
164 !
165 ! -- methods specific for uzf
166 procedure, private :: uzf_solve
167 procedure, private :: uzf_source_packagedata
168 procedure, private :: print_cell_properties
169 procedure, private :: check_cell_area
170 !
171 ! -- budget
172 procedure, private :: uzf_setup_budobj
173 procedure, private :: uzf_fill_budobj
174
175 end type uzftype
176
177 interface
178
179 module subroutine uzf_source_packagedata(this)
180 class(uzftype), intent(inout) :: this
181 end subroutine uzf_source_packagedata
182
183 module subroutine print_cell_properties(this)
184 class(uzftype), intent(inout) :: this
185 end subroutine print_cell_properties
186
187 module subroutine check_cell_area(this)
188 class(uzftype) :: this
189 end subroutine check_cell_area
190
191 module logical function uzf_obs_supported(this)
192 class(uzftype) :: this
193 end function uzf_obs_supported
194
195 module subroutine uzf_df_obs(this)
196 class(uzftype) :: this
197 end subroutine uzf_df_obs
198
199 module subroutine uzf_rp_obs(this)
200 class(uzftype), intent(inout) :: this
201 end subroutine uzf_rp_obs
202
203 module subroutine uzf_bd_obs(this)
204 class(uzftype) :: this
205 end subroutine uzf_bd_obs
206
207 module subroutine uzf_setup_budobj(this)
208 class(uzftype) :: this
209 end subroutine uzf_setup_budobj
210
211 module subroutine uzf_fill_budobj(this)
212 class(uzftype) :: this
213 end subroutine uzf_fill_budobj
214
215 end interface
216
217contains
218
219 !> @brief Create a New UZF Package and point packobj to the new package
220 !<
221 subroutine uzf_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, &
222 mempath)
223 ! -- modules
225 ! -- dummy
226 class(bndtype), pointer :: packobj
227 integer(I4B), intent(in) :: id
228 integer(I4B), intent(in) :: ibcnum
229 integer(I4B), intent(in) :: inunit
230 integer(I4B), intent(in) :: iout
231 character(len=*), intent(in) :: namemodel
232 character(len=*), intent(in) :: pakname
233 character(len=*), intent(in) :: mempath
234 ! -- local
235 type(uzftype), pointer :: uzfobj
236 !
237 ! -- allocate the object and assign values to object variables
238 allocate (uzfobj)
239 packobj => uzfobj
240 !
241 ! -- create name and memory path
242 call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
243 packobj%text = text
244 !
245 ! -- allocate scalars
246 call uzfobj%uzf_allocate_scalars()
247 !
248 ! -- initialize package
249 call packobj%pack_initialize()
250 !
251 packobj%inunit = inunit
252 packobj%iout = iout
253 packobj%id = id
254 packobj%ibcnum = ibcnum
255 packobj%ncolbnd = 1
256 packobj%iscloc = 0 ! not supported
257 packobj%isadvpak = 1
258 packobj%ictMemPath = create_mem_path(namemodel, 'NPF')
259 end subroutine uzf_create
260
261 !> @brief Allocate and Read
262 !<
263 subroutine uzf_ar(this)
264 ! -- modules
266 ! -- dummy
267 class(uzftype), intent(inout) :: this
268 ! -- local
269 integer(I4B) :: n !< uzf cell number
270 integer(I4B) :: node !< gwf node number
271 real(DP) :: hgwf
272 !
273 call this%obs%obs_ar()
274 !
275 ! -- call standard BndExtType allocate scalars
276 call this%BndExtType%allocate_arrays()
277 !
278 ! -- set pointers now that data is available
279 call mem_setptr(this%gwfhcond, 'CONDSAT', create_mem_path(this%name_model, &
280 'NPF'))
281 call mem_setptr(this%gwfiss, 'ISS', create_mem_path(this%name_model))
282 !
283 ! -- set boundname for each connection
284 if (this%inamedbound /= 0) then
285 do n = 1, this%nodes
286 this%boundname(n) = this%uzfname(n)
287 end do
288 end if
289 !
290 ! -- copy boundname into boundname_cst
291 call this%copy_boundname()
292 !
293 ! -- copy igwfnode into nodelist and set water table
294 do n = 1, this%nodes
295 this%nodelist(n) = this%igwfnode(n)
296 node = this%igwfnode(n)
297 hgwf = this%xnew(node)
298 call this%uzfobj%sethead(n, hgwf)
299 end do
300 !
301 ! -- setup pakmvrobj
302 if (this%imover /= 0) then
303 allocate (this%pakmvrobj)
304 call this%pakmvrobj%ar(this%maxbound, this%maxbound, this%memoryPath)
305 end if
306 end subroutine uzf_ar
307
308 !> @brief Allocate arrays used for uzf
309 !<
310 subroutine uzf_allocate_arrays(this)
311 ! -- dummy
312 class(uzftype), intent(inout) :: this
313 ! -- local
314 integer(I4B) :: n !< uzf cell number
315 integer(I4B) :: node !< gwf node number
316 integer(I4B) :: j
317 !
318 ! -- call standard BndType allocate scalars (now done from AR)
319 !call this%BndType%allocate_arrays()
320 !
321 ! -- allocate uzf specific arrays
322 call mem_allocate(this%igwfnode, this%nodes, 'IGWFNODE', this%memoryPath)
323 call mem_allocate(this%appliedinf, this%nodes, 'APPLIEDINF', this%memoryPath)
324 call mem_allocate(this%rejinf, this%nodes, 'REJINF', this%memoryPath)
325 call mem_allocate(this%rejinf0, this%nodes, 'REJINF0', this%memoryPath)
326 call mem_allocate(this%rejinftomvr, this%nodes, 'REJINFTOMVR', &
327 this%memoryPath)
328 call mem_allocate(this%infiltration, this%nodes, 'INFILTRATION', &
329 this%memoryPath)
330 call mem_allocate(this%uzet, this%nodes, 'UZET', this%memoryPath)
331 call mem_allocate(this%gwd, this%nodes, 'GWD', this%memoryPath)
332 call mem_allocate(this%gwd0, this%nodes, 'GWD0', this%memoryPath)
333 call mem_allocate(this%gwdtomvr, this%nodes, 'GWDTOMVR', this%memoryPath)
334 call mem_allocate(this%rch, this%nodes, 'RCH', this%memoryPath)
335 call mem_allocate(this%rch0, this%nodes, 'RCH0', this%memoryPath)
336 call mem_allocate(this%qsto, this%nodes, 'QSTO', this%memoryPath)
337 call mem_allocate(this%deriv, this%nodes, 'DERIV', this%memoryPath)
338 !
339 ! -- integer vectors
340 call mem_allocate(this%ia, this%dis%nodes + 1, 'IA', this%memoryPath)
341 call mem_allocate(this%ja, this%nodes, 'JA', this%memoryPath)
342 !
343 ! -- input context pointers
344 call mem_setptr(this%finf_input, 'FINF', this%input_mempath)
345 call mem_setptr(this%pet_input, 'PET', this%input_mempath)
346 call mem_setptr(this%extdp_input, 'EXTDP', this%input_mempath)
347 call mem_setptr(this%extwc_input, 'EXTWC', this%input_mempath)
348 call mem_setptr(this%ha_input, 'HA', this%input_mempath)
349 call mem_setptr(this%hroot_input, 'HROOT', this%input_mempath)
350 call mem_setptr(this%rootact_input, 'ROOTACT', this%input_mempath)
351 call mem_setptr(this%uauxvar, 'AUXVAR', this%input_mempath)
352 !
353 ! -- initialize
354 do n = 1, this%nodes
355 this%appliedinf(n) = dzero
356 this%rejinf(n) = dzero
357 this%rejinf0(n) = dzero
358 this%rejinftomvr(n) = dzero
359 this%uzet(n) = dzero
360 this%gwd(n) = dzero
361 this%gwd0(n) = dzero
362 this%gwdtomvr(n) = dzero
363 this%rch(n) = dzero
364 this%rch0(n) = dzero
365 this%qsto(n) = dzero
366 this%deriv(n) = dzero
367 ! -- integer variables
368 this%ja(n) = 0
369 ! -- finf_input/pet_input/extdp_input/extwc_input/ha_input/
370 ! -- hroot_input/rootact_input are input context pointers
371 do j = 1, this%naux
372 if (this%iauxmultcol > 0 .and. j == this%iauxmultcol) then
373 this%uauxvar(j, n) = done
374 else
375 this%uauxvar(j, n) = dzero
376 end if
377 end do
378 end do
379 do node = 1, this%dis%nodes + 1
380 this%ia(node) = 0
381 end do
382 !
383 ! -- allocate and initialize character array for budget text
384 allocate (this%bdtxt(this%nbdtxt))
385 this%bdtxt(1) = ' UZF-INF'
386 this%bdtxt(2) = ' UZF-GWRCH'
387 this%bdtxt(3) = ' UZF-GWD'
388 this%bdtxt(4) = ' UZF-GWET'
389 this%bdtxt(5) = ' UZF-GWD TO-MVR'
390 !
391 ! -- allocate and initialize watercontent arrays
392 call mem_allocate(this%wcnew, this%nodes, 'WCNEW', this%memoryPath)
393 call mem_allocate(this%wcold, this%nodes, 'WCOLD', this%memoryPath)
394 do n = 1, this%nodes
395 this%wcnew(n) = dzero
396 this%wcold(n) = dzero
397 end do
398 !
399 ! -- allocate character array for aux budget text
400 allocate (this%cauxcbc(this%cbcauxitems))
401 allocate (this%uzfname(this%nodes))
402 !
403 ! -- allocate and initialize qauxcbc
404 call mem_allocate(this%qauxcbc, this%cbcauxitems, 'QAUXCBC', this%memoryPath)
405 do n = 1, this%cbcauxitems
406 this%qauxcbc(n) = dzero
407 end do
408 end subroutine uzf_allocate_arrays
409
410 !> @brief Alias deprecated UZF variable names to their current storage
411 !!
412 !! The aliases share memory with the current variables so that programs
413 !! using the previous names through the API still resolve them; each use is
414 !! reported as deprecated.
415 !<
416 subroutine uzf_checkin_deprecated_names(this)
417 ! -- modules
419 ! -- dummy
420 class(uzftype), intent(inout) :: this
421 ! -- code
422 !
423 ! -- time-series aware cell variables and auxiliary values moved to the
424 ! input context by the input data model integration
425 call mem_alias_deprecated(this%finf_input, 'SINF_PVAR', this%memoryPath, &
426 'FINF', this%input_mempath, '6.8.2')
427 call mem_alias_deprecated(this%pet_input, 'PET_PVAR', this%memoryPath, &
428 'PET', this%input_mempath, '6.8.2')
429 call mem_alias_deprecated(this%extdp_input, 'EXDP_PVAR', this%memoryPath, &
430 'EXTDP', this%input_mempath, '6.8.2')
431 call mem_alias_deprecated(this%extwc_input, 'EXTWC_PVAR', &
432 this%memoryPath, 'EXTWC', this%input_mempath, &
433 '6.8.2')
434 call mem_alias_deprecated(this%ha_input, 'HA_PVAR', this%memoryPath, &
435 'HA', this%input_mempath, '6.8.2')
436 call mem_alias_deprecated(this%hroot_input, 'HROOT_PVAR', &
437 this%memoryPath, 'HROOT', this%input_mempath, &
438 '6.8.2')
439 call mem_alias_deprecated(this%rootact_input, 'ROOTACT_PVAR', &
440 this%memoryPath, 'ROOTACT', this%input_mempath, &
441 '6.8.2')
442 call mem_alias_deprecated(this%uauxvar, 'UAUXVAR', this%memoryPath, &
443 'AUXVAR', this%input_mempath, '6.8.2')
444 !
445 ! -- renamed package variables
446 call mem_alias_deprecated(this%ntrail_input, 'NTRAIL_PVAR', &
447 this%memoryPath, 'NTRAIL_INPUT', &
448 this%memoryPath, '6.9.0')
449 call mem_alias_deprecated(this%nwavesets, 'NSETS', this%memoryPath, &
450 'NWAVESETS', this%memoryPath, '6.9.0')
451 end subroutine uzf_checkin_deprecated_names
452
453 !> @brief Source OPTIONS block from input context
454 !!
455 !! Overrides BndExtType%source_options
456 !<
457 subroutine uzf_source_options(this)
458 ! -- modules
459 use openspecmodule, only: access, form
461 ! -- dummy
462 class(uzftype), intent(inout) :: this
463 ! -- local
464 type(gwfuzfparamfoundtype) :: found
465 integer(I4B), pointer :: ikw => null()
466 character(len=LINELENGTH) :: fname
467 ! -- formats
468 character(len=*), parameter :: fmtet = &
469 "(4x, 'ET WILL BE SIMULATED WITHIN UZ AND GW ZONES, WITH LINEAR ', &
470 &'GWET IF OPTION NOT SPECIFIED OTHERWISE.')"
471 character(len=*), parameter :: fmtgwetlin = &
472 &"(4x, 'GROUNDWATER ET FUNCTION WILL BE LINEAR.')"
473 character(len=*), parameter :: fmtgwetsquare = &
474 &"(4x, 'GROUNDWATER ET FUNCTION WILL BE SQUARE WITH SMOOTHING.')"
475 character(len=*), parameter :: fmtgwseepout = &
476 &"(4x, 'GROUNDWATER DISCHARGE TO LAND SURFACE WILL BE SIMULATED.')"
477 character(len=*), parameter :: fmtuzetwc = &
478 &"(4x, 'UNSATURATED ET FUNCTION OF WATER CONTENT.')"
479 character(len=*), parameter :: fmtuzetae = &
480 &"(4x, 'UNSATURATED ET FUNCTION OF AIR ENTRY PRESSURE.')"
481 character(len=*), parameter :: fmtuzfbin = &
482 "(4x, 'UZF ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', &
483 &a, /4x, 'OPENED ON UNIT: ', I0)"
484 !
485 ! -- call base class to handle AUXILIARY/NAUX, BOUNDNAMES, PRINT_INPUT,
486 ! PRINT_FLOWS, SAVE_FLOWS, OBS6_FILENAME, AUXMULTNAME
487 call this%BndExtType%source_options()
488 !
489 write (this%iout, '(1x,a)') &
490 'PROCESSING '//trim(adjustl(this%text))//' OPTIONS'
491 !
492 ! -- WATER_CONTENT FILEOUT
493 call mem_set_value(fname, 'WCFILE', this%input_mempath, found%wcfile)
494 if (found%wcfile) then
495 this%iwcontout = getunit()
496 call openfile(this%iwcontout, this%iout, fname, 'DATA(BINARY)', &
497 form, access, 'REPLACE', mode_opt=mnormal)
498 write (this%iout, fmtuzfbin) 'WATER-CONTENT', trim(adjustl(fname)), &
499 this%iwcontout
500 end if
501 !
502 ! -- BUDGET FILEOUT
503 call mem_set_value(fname, 'BUDGETFILE', this%input_mempath, found%budgetfile)
504 if (found%budgetfile) then
505 call assign_iounit(this%ibudgetout, this%inunit, "BUDGET fileout")
506 call openfile(this%ibudgetout, this%iout, fname, 'DATA(BINARY)', &
507 form, access, 'REPLACE', mode_opt=mnormal)
508 write (this%iout, fmtuzfbin) 'BUDGET', trim(adjustl(fname)), &
509 this%ibudgetout
510 end if
511 !
512 ! -- BUDGETCSV FILEOUT
513 call mem_set_value(fname, 'BUDGETCSVFILE', this%input_mempath, &
514 found%budgetcsvfile)
515 if (found%budgetcsvfile) then
516 call assign_iounit(this%ibudcsv, this%inunit, "BUDGETCSV fileout")
517 call openfile(this%ibudcsv, this%iout, fname, 'CSV', filstat_opt='REPLACE')
518 write (this%iout, fmtuzfbin) 'BUDGET CSV', trim(adjustl(fname)), &
519 this%ibudcsv
520 end if
521 !
522 ! -- PACKAGE_CONVERGENCE FILEOUT
523 call mem_set_value(fname, 'PKGCONVFNAME', &
524 this%input_mempath, found%pkgconvfname)
525 if (found%pkgconvfname) then
526 this%ipakcsv = getunit()
527 call openfile(this%ipakcsv, this%iout, fname, 'CSV', &
528 filstat_opt='REPLACE', mode_opt=mnormal)
529 write (this%iout, fmtuzfbin) 'PACKAGE_CONVERGENCE', &
530 trim(adjustl(fname)), this%ipakcsv
531 end if
532 allocate (ikw)
533 !
534 ! -- SIMULATE_ET
535 call mem_set_value(ikw, 'SIMULATE_ET', this%input_mempath, found%simulate_et)
536 if (found%simulate_et) then
537 this%ietflag = 1
538 this%igwetflag = 0
539 write (this%iout, fmtet)
540 end if
541 !
542 ! -- LINEAR_GWET
543 call mem_set_value(ikw, 'LINEAR_GWET', this%input_mempath, found%linear_gwet)
544 if (found%linear_gwet) then
545 this%igwetflag = 1
546 write (this%iout, fmtgwetlin)
547 end if
548 !
549 ! -- SQUARE_GWET
550 call mem_set_value(ikw, 'SQUARE_GWET', this%input_mempath, found%square_gwet)
551 if (found%square_gwet) then
552 this%igwetflag = 2
553 write (this%iout, fmtgwetsquare)
554 end if
555 !
556 ! -- SIMULATE_GWSEEP (deprecated)
557 call mem_set_value(ikw, 'SIMULATE_GWSEEP', this%input_mempath, &
558 found%simulate_gwseep)
559 if (found%simulate_gwseep) then
560 this%iseepflag = 1
561 write (this%iout, fmtgwseepout)
562 write (warnmsg, '(a)') &
563 'USE DRN PACKAGE TO SIMULATE GROUNDWATER DISCHARGE TO LAND SURFACE '// &
564 'INSTEAD'
565 call deprecation_warning('OPTIONS', 'SIMULATE_GWSEEP', '6.5.0', &
566 warnmsg, this%inunit)
567 end if
568 !
569 ! -- UNSAT_ETWC
570 call mem_set_value(ikw, 'UNSAT_ETWC', this%input_mempath, found%unsat_etwc)
571 if (found%unsat_etwc) then
572 this%ietflag = 1
573 write (this%iout, fmtuzetwc)
574 end if
575 !
576 ! -- UNSAT_ETAE
577 call mem_set_value(ikw, 'UNSAT_ETAE', this%input_mempath, found%unsat_etae)
578 if (found%unsat_etae) then
579 this%ietflag = 2
580 write (this%iout, fmtuzetae)
581 end if
582 !
583 ! -- MOVER
584 call mem_set_value(ikw, 'MOVER', this%input_mempath, found%mover)
585 if (found%mover) then
586 this%imover = 1
587 end if
588 !
589 ! -- DEV_NO_FINAL_CHECK (mf6internal: iconvchk)
590 call mem_set_value(ikw, 'ICONVCHK', this%input_mempath, found%iconvchk)
591 if (found%iconvchk) then
592 this%iconvchk = 0
593 write (this%iout, '(4x,a)') &
594 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN UZF RECHARGE '// &
595 'WILL NOT BE MADE'
596 end if
597 !
598 deallocate (ikw)
599 !
600 write (this%iout, '(1x,a)') &
601 'END OF '//trim(adjustl(this%text))//' OPTIONS'
602 end subroutine uzf_source_options
603
604 !> @brief Source DIMENSIONS block from input context
605 !!
606 !! Overrides BndExtType%source_dimensions
607 !<
608 subroutine uzf_source_dimensions(this)
609 ! -- modules
611 ! -- dummy
612 class(uzftype), intent(inout) :: this
613 ! -- local
614 type(gwfuzfparamfoundtype) :: found
615 !
616 ! -- initialize dimensions
617 this%nodes = -1
618 this%ntrail_input = 0
619 this%nwavesets = 0
620 !
621 write (this%iout, '(/1x,a)') &
622 'PROCESSING '//trim(adjustl(this%text))//' DIMENSIONS'
623 !
624 ! -- NUZFCELLS (mf6internal: maxbound)
625 call mem_set_value(this%nodes, 'MAXBOUND', this%input_mempath, &
626 found%maxbound)
627 if (found%maxbound) then
628 write (this%iout, '(4x,a,i0)') 'NUZFCELLS = ', this%nodes
629 end if
630 !
631 ! -- NTRAILWAVES
632 call mem_set_value(this%ntrail_input, 'NTRAILWAVES', this%input_mempath, &
633 found%ntrailwaves)
634 if (found%ntrailwaves) then
635 write (this%iout, '(4x,a,i0)') 'NTRAILWAVES = ', this%ntrail_input
636 end if
637 !
638 ! -- NWAVESETS
639 call mem_set_value(this%nwavesets, 'NWAVESETS', this%input_mempath, &
640 found%nwavesets)
641 if (found%nwavesets) then
642 write (this%iout, '(4x,a,i0)') 'NTRAILSETS = ', this%nwavesets
643 end if
644 !
645 write (this%iout, '(1x,a)') &
646 'END OF '//trim(adjustl(this%text))//' DIMENSIONS'
647 !
648 ! -- increment maxbound
649 this%maxbound = this%maxbound + this%nodes
650 this%nbound = this%maxbound
651 !
652 ! -- verify dimensions were set
653 if (this%nodes <= 0) then
654 write (errmsg, '(a)') &
655 'NUZFCELLS (MAXBOUND) was not specified or was specified incorrectly.'
656 call store_error(errmsg)
657 end if
658 if (this%ntrail_input <= 1) then
659 write (errmsg, '(a)') &
660 'NTRAILWAVES must be greater than 1. A value of 7 is recommended.'
661 call store_error(errmsg)
662 end if
663 if (this%nwavesets <= 0) then
664 write (errmsg, '(a)') &
665 'NWAVESETS was not specified or was specified incorrectly.'
666 call store_error(errmsg)
667 end if
668 if (count_errors() > 0) then
669 call store_error_filename(this%input_fname)
670 end if
671 !
672 ! -- set the number of waves
673 !
674 ! -- Call define_listlabel to construct the list label that is written
675 ! when PRINT_INPUT option is used.
676 call this%define_listlabel()
677 !
678 ! -- Allocate arrays in package superclass
679 call this%uzf_allocate_arrays()
680 !
681 ! -- alias deprecated variable names
682 call this%uzf_checkin_deprecated_names()
683 !
684 ! -- initialize uzf group object
685 allocate (this%uzfobj)
686 call this%uzfobj%init(this%nodes, this%ntrail_input * this%nwavesets, &
687 this%memoryPath)
688 !
689 !-- Read uzf cell properties
690 call this%uzf_source_packagedata()
691 !
692 ! -- print cell data
693 if (this%iprpak /= 0) then
694 call this%print_cell_properties()
695 end if
696 !
697 ! -- setup the budget object
698 call this%uzf_setup_budobj()
699 end subroutine uzf_source_dimensions
700
701 !> @brief Read stress data from input context
702 !<
703 subroutine uzf_rp(this)
704 ! -- modules
705 use tdismodule, only: kper
707 ! -- dummy
708 class(uzftype), intent(inout) :: this
709 ! -- local
710 integer(I4B), pointer :: nlist => null()
711 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
712 integer(I4B) :: i
713 integer(I4B) :: n !< uzf cell number
714 ! -- table output
715 character(len=20) :: cellid
716 character(len=LINELENGTH) :: title
717 character(len=LINELENGTH) :: tag
718 integer(I4B) :: ntabrows
719 integer(I4B) :: ntabcols
720 integer(I4B) :: node
721 !-- formats
722 character(len=*), parameter :: fmtlsp = &
723 &"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
724 !
725 ! -- set nbound to maxbound
726 this%nbound = this%maxbound
727 !
728 ! -- set steady-state flag based on gwfiss
729 this%issflag = this%gwfiss
730 !
731 ! -- check if input has loaded data for this stress period
732 if (this%iper == kper) then
733 !
734 ! -- get PERIOD data arrays
735 call mem_setptr(nlist, 'NBOUND', this%input_mempath)
736 call mem_setptr(ifno, 'IFNO', this%input_mempath)
737 !
738 ! -- setup inputtab tableobj if PRINT_INPUT
739 if (this%iprpak /= 0) then
740 ntabrows = 1
741 ntabcols = 3
742 if (this%ietflag /= 0) then
743 ntabcols = ntabcols + 3
744 if (this%ietflag == 2) then
745 ntabcols = ntabcols + 3
746 end if
747 end if
748 if (this%inamedbound == 1) then
749 ntabcols = ntabcols + 1
750 end if
751 title = trim(adjustl(this%text))//' PACKAGE ('// &
752 trim(adjustl(this%packName))//') DATA FOR PERIOD'
753 write (title, '(a,1x,i6)') trim(adjustl(title)), kper
754 call table_cr(this%inputtab, this%packName, title)
755 call this%inputtab%table_df(ntabrows, ntabcols, this%iout, &
756 finalize=.false.)
757 tag = 'NUMBER'
758 call this%inputtab%initialize_column(tag, 10)
759 tag = 'CELLID'
760 call this%inputtab%initialize_column(tag, 20, alignment=tableft)
761 tag = 'FINF'
762 call this%inputtab%initialize_column(tag, 12)
763 if (this%ietflag /= 0) then
764 tag = 'PET'
765 call this%inputtab%initialize_column(tag, 12)
766 tag = 'EXTDEP'
767 call this%inputtab%initialize_column(tag, 12)
768 tag = 'EXTWC'
769 call this%inputtab%initialize_column(tag, 12)
770 if (this%ietflag == 2) then
771 tag = 'HA'
772 call this%inputtab%initialize_column(tag, 12)
773 tag = 'HROOT'
774 call this%inputtab%initialize_column(tag, 12)
775 tag = 'ROOTACT'
776 call this%inputtab%initialize_column(tag, 12)
777 end if
778 end if
779 if (this%inamedbound == 1) then
780 tag = 'BOUNDNAME'
781 call this%inputtab%initialize_column(tag, lenboundname, &
782 alignment=tableft)
783 end if
784 end if
785 !
786 ! -- loop over period data
787 do i = 1, nlist
788 n = ifno(i)
789 if (n < 1 .or. n > this%nodes) then
790 tag = trim(adjustl(this%text))//' PACKAGE ('// &
791 trim(adjustl(this%packName))//') DATA FOR PERIOD'
792 write (tag, '(a,1x,i0)') trim(adjustl(tag)), kper
793 write (errmsg, '(a,a,i0,1x,a,i0,a)') &
794 trim(adjustl(tag)), ': UZFNO ', n, &
795 'must be greater than 0 and less than or equal to ', this%nodes, '.'
796 call store_error(errmsg)
797 cycle
798 end if
799 !
800 ! -- finf_input/pet_input/extdp_input/extwc_input/ha_input/
801 ! -- hroot_input/rootact_input/uauxvar alias finf/pet/extdp/extwc/ha/hroot/
802 ! -- rootact/AUX directly; nothing to merge
803 !
804 ! -- write table output
805 if (this%iprpak /= 0) then
806 node = this%igwfnode(n)
807 if (node > 0) then
808 call this%dis%noder_to_string(node, cellid)
809 else
810 cellid = 'none'
811 end if
812 call this%inputtab%add_term(n)
813 call this%inputtab%add_term(cellid)
814 call this%inputtab%add_term(this%finf_input(n))
815 if (this%ietflag /= 0) then
816 call this%inputtab%add_term(this%pet_input(n))
817 call this%inputtab%add_term(this%extdp_input(n))
818 call this%inputtab%add_term(this%extwc_input(n))
819 if (this%ietflag == 2) then
820 call this%inputtab%add_term(this%ha_input(n))
821 call this%inputtab%add_term(this%hroot_input(n))
822 call this%inputtab%add_term(this%rootact_input(n))
823 end if
824 end if
825 if (this%inamedbound == 1) then
826 call this%inputtab%add_term(this%boundname(n))
827 end if
828 end if
829 end do
830 !
831 if (this%iprpak /= 0) then
832 call this%inputtab%finalize_table()
833 end if
834 !
835 if (count_errors() > 0) then
836 call store_error_filename(this%input_fname)
837 end if
838 !
839 else
840 write (this%iout, fmtlsp) trim(this%filtyp)
841 end if
842 !
843 ! -- set wave data for first stress period and second that follows SS;
844 ! must run every period (not just when iper==kper) so that the reuse
845 ! case (kper==2, no new PERIOD block, issflagold==1) still initializes
846 ! wave data for the SS->TR transition.
847 if ((this%issflag == 0 .AND. kper == 1) .or. &
848 (kper == 2 .AND. this%issflagold == 1)) then
849 do n = 1, this%nodes
850 call this%uzfobj%setwaves(n)
851 end do
852 end if
853 !
854 ! -- Initialize the water content
855 if (kper == 1) then
856 do n = 1, this%nodes
857 this%wcnew(n) = this%uzfobj%get_wcnew(n)
858 end do
859 end if
860 !
861 ! -- Save old ss flag
862 this%issflagold = this%issflag
863 end subroutine uzf_rp
864
865 !> @brief Advance UZF Package
866 !<
867 subroutine uzf_ad(this)
868 ! -- modules
870 ! -- dummy
871 class(uzftype) :: this
872 ! -- locals
873 integer(I4B) :: n !< uzf cell number
874 integer(I4B) :: ivertflag
875 integer(I4B) :: iaux
876 real(DP) :: rval1, rval2, rval3
877 !
878 ! -- advance observations
879 call this%BndExtType%bnd_ad()
880 !
881 ! -- finf_input/pet_input/extdp_input/extwc_input/ha_input/hroot_input/
882 ! -- rootact_input/uauxvar alias finf/pet/extdp/extwc/ha/hroot/
883 ! -- rootact/AUX directly; nothing to re-sync
884 !
885 ! -- update auxiliary variables by copying from the derived-type time
886 ! series variable into the bndpackage auxvar variable so that this
887 ! information is properly written to the GWF budget file
888 if (this%naux > 0) then
889 do n = 1, this%maxbound
890 do iaux = 1, this%naux
891 if (this%noupdateauxvar(iaux) /= 0) cycle
892 this%auxvar(iaux, n) = this%uauxvar(iaux, n)
893 end do
894 end do
895 end if
896 !
897 ! -- Update or restore state
898 if (ifailedstepretry == 0) then
899 !
900 ! -- reset old water content to new water content
901 do n = 1, this%nodes
902 this%wcold(n) = this%wcnew(n)
903 end do
904 else
905 !
906 ! -- Copy wcold back into wcnew as this is a retry of this time step.
907 ! Note that there is no need to reset the waves as they are not
908 ! advanced to their new state until the _ot() method is called,
909 ! and that doesn't happen until a successful solution is obtained.
910 do n = 1, this%nodes
911 this%wcnew(n) = this%wcold(n)
912 end do
913 end if
914 !
915 ! -- advance each uzf obj
916 do n = 1, this%nodes
917 call this%uzfobj%advance(n)
918 end do
919 !
920 ! -- update uzf objects with timeseries aware variables
921 do n = 1, this%nodes
922 !
923 ! -- Set ivertflag
924 ivertflag = this%uzfobj%cell_below(n)
925 !
926 ! -- recalculate uzfarea
927 if (this%iauxmultcol > 0) then
928 rval1 = this%uauxvar(this%iauxmultcol, n)
929 call this%uzfobj%setdatauzfarea(n, rval1)
930 end if
931 !
932 ! -- FINF
933 rval1 = this%finf_input(n)
934 call this%uzfobj%setdatafinf(n, rval1)
935 !
936 ! -- PET, EXTDP
937 rval1 = this%pet_input(n)
938 rval2 = this%extdp_input(n)
939 call this%uzfobj%setdataet(n, ivertflag, rval1, rval2)
940 !
941 ! -- ETWC
942 rval1 = this%extwc_input(n)
943 call this%uzfobj%setdataetwc(n, ivertflag, rval1)
944 !
945 ! -- HA, HROOT, ROOTACT
946 rval1 = this%ha_input(n)
947 rval2 = this%hroot_input(n)
948 rval3 = this%rootact_input(n)
949 call this%uzfobj%setdataetha(n, ivertflag, rval1, rval2, rval3)
950 end do
951 !
952 ! -- check uzfarea
953 if (this%iauxmultcol > 0) then
954 call this%check_cell_area()
955 end if
956 !
957 ! -- pakmvrobj ad
958 if (this%imover == 1) then
959 call this%pakmvrobj%ad()
960 end if
961 end subroutine uzf_ad
962
963 !> @brief Formulate the HCOF and RHS terms
964 !!
965 !! - skip if no UZF cells
966 !! - calculate hcof and rhs
967 !<
968 subroutine uzf_cf(this)
969 ! -- modules
970 ! -- dummy
971 class(uzftype) :: this
972 ! -- locals
973 integer(I4B) :: n
974 !
975 ! -- Return if no UZF cells
976 if (this%nodes == 0) return
977 !
978 ! -- Store values at start of outer iteration to compare with calculated
979 ! values for convergence check
980 do n = 1, this%maxbound
981 this%rejinf0(n) = this%rejinf(n)
982 this%rch0(n) = this%rch(n)
983 this%gwd0(n) = this%gwd(n)
984 end do
985 end subroutine uzf_cf
986
987 !> @brief Copy rhs and hcof into solution rhs and amat
988 !<
989 subroutine uzf_fc(this, rhs, ia, idxglo, matrix_sln)
990 ! -- dummy
991 class(uzftype) :: this
992 real(DP), dimension(:), intent(inout) :: rhs
993 integer(I4B), dimension(:), intent(in) :: ia
994 integer(I4B), dimension(:), intent(in) :: idxglo
995 class(matrixbasetype), pointer :: matrix_sln
996 ! -- local
997 integer(I4B) :: n, node, ipos
998 !
999 ! -- pakmvrobj fc
1000 if (this%imover == 1) then
1001 call this%pakmvrobj%fc()
1002 end if
1003 !
1004 ! -- Solve UZF; set reset_state to true so that waves are reset back to
1005 ! initial position for each outer iteration
1006 call this%uzf_solve(reset_state=.true.)
1007 !
1008 ! -- Copy package rhs and hcof into solution rhs and amat
1009 do n = 1, this%nodes
1010 node = this%nodelist(n)
1011 rhs(node) = rhs(node) + this%rhs(n)
1012 ipos = ia(node)
1013 call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(n))
1014 end do
1015 end subroutine uzf_fc
1016
1017 !> @brief Fill newton terms
1018 !<
1019 subroutine uzf_fn(this, rhs, ia, idxglo, matrix_sln)
1020 ! -- dummy
1021 class(uzftype) :: this
1022 real(DP), dimension(:), intent(inout) :: rhs
1023 integer(I4B), dimension(:), intent(in) :: ia
1024 integer(I4B), dimension(:), intent(in) :: idxglo
1025 class(matrixbasetype), pointer :: matrix_sln
1026 ! -- local
1027 integer(I4B) :: n, node
1028 integer(I4B) :: ipos
1029 !
1030 ! -- Add derivative terms to rhs and amat
1031 do n = 1, this%nodes
1032 node = this%nodelist(n)
1033 ipos = ia(node)
1034 call matrix_sln%add_value_pos(idxglo(ipos), this%deriv(n))
1035 rhs(node) = rhs(node) + this%deriv(n) * this%xnew(node)
1036 end do
1037 end subroutine uzf_fn
1038
1039 !> @brief Final convergence check for package
1040 !<
1041 subroutine uzf_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
1042 ! -- modules
1043 use tdismodule, only: totim, kstp, kper, delt
1044 ! -- dummy
1045 class(uzftype), intent(inout) :: this
1046 integer(I4B), intent(in) :: innertot
1047 integer(I4B), intent(in) :: kiter
1048 integer(I4B), intent(in) :: icnvgmod
1049 integer(I4B), intent(in) :: iend
1050 character(len=LENPAKLOC), intent(inout) :: cpak
1051 integer(I4B), intent(inout) :: ipak
1052 real(DP), intent(inout) :: dpak
1053 ! -- local
1054 character(len=LENPAKLOC) :: cloc
1055 character(len=LINELENGTH) :: tag
1056 integer(I4B) :: icheck
1057 integer(I4B) :: ipakfail
1058 integer(I4B) :: locdrejinfmax
1059 integer(I4B) :: locdrchmax
1060 integer(I4B) :: locdseepmax
1061 integer(I4B) :: locdqfrommvrmax
1062 integer(I4B) :: ntabrows
1063 integer(I4B) :: ntabcols
1064 integer(I4B) :: n
1065 real(DP) :: q
1066 real(DP) :: q0
1067 real(DP) :: qtolfact
1068 real(DP) :: drejinf
1069 real(DP) :: drejinfmax
1070 real(DP) :: drch
1071 real(DP) :: drchmax
1072 real(DP) :: dseep
1073 real(DP) :: dseepmax
1074 real(DP) :: dqfrommvr
1075 real(DP) :: dqfrommvrmax
1076 !
1077 ! -- initialize local variables
1078 icheck = this%iconvchk
1079 ipakfail = 0
1080 locdrejinfmax = 0
1081 locdrchmax = 0
1082 locdseepmax = 0
1083 locdqfrommvrmax = 0
1084 drejinfmax = dzero
1085 drchmax = dzero
1086 dseepmax = dzero
1087 dqfrommvrmax = dzero
1088 !
1089 ! -- if not saving package convergence data on check convergence if
1090 ! the model is considered converged
1091 if (this%ipakcsv == 0) then
1092 if (icnvgmod == 0) then
1093 icheck = 0
1094 end if
1095 else
1096 !
1097 ! -- header for package csv
1098 if (.not. associated(this%pakcsvtab)) then
1099 !
1100 ! -- determine the number of columns and rows
1101 ntabrows = 1
1102 ntabcols = 9
1103 if (this%iseepflag == 1) then
1104 ntabcols = ntabcols + 2
1105 end if
1106 if (this%imover == 1) then
1107 ntabcols = ntabcols + 2
1108 end if
1109 !
1110 ! -- setup table
1111 call table_cr(this%pakcsvtab, this%packName, '')
1112 call this%pakcsvtab%table_df(ntabrows, ntabcols, this%ipakcsv, &
1113 lineseparator=.false., separator=',', &
1114 finalize=.false.)
1115 !
1116 ! -- add columns to package csv
1117 tag = 'total_inner_iterations'
1118 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
1119 tag = 'totim'
1120 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
1121 tag = 'kper'
1122 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
1123 tag = 'kstp'
1124 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
1125 tag = 'nouter'
1126 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
1127 tag = 'drejinfmax'
1128 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
1129 tag = 'drejinfmax_loc'
1130 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
1131 tag = 'drchmax'
1132 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
1133 tag = 'drchmax_loc'
1134 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
1135 if (this%iseepflag == 1) then
1136 tag = 'dseepmax'
1137 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
1138 tag = 'dseepmax_loc'
1139 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
1140 end if
1141 if (this%imover == 1) then
1142 tag = 'dqfrommvrmax'
1143 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
1144 tag = 'dqfrommvrmax_loc'
1145 call this%pakcsvtab%initialize_column(tag, 16, alignment=tableft)
1146 end if
1147 end if
1148 end if
1149 !
1150 ! -- perform package convergence check
1151 if (icheck /= 0) then
1152 final_check: do n = 1, this%nodes
1153 !
1154 ! -- set the Q to length factor
1155 qtolfact = delt / this%uzfobj%uzfarea(n)
1156 !
1157 ! -- rejected infiltration
1158 drejinf = qtolfact * (this%rejinf0(n) - this%rejinf(n))
1159 !
1160 ! -- groundwater recharge
1161 drch = qtolfact * (this%rch0(n) - this%rch(n))
1162 !
1163 ! -- groundwater seepage to the land surface
1164 dseep = dzero
1165 if (this%iseepflag == 1) then
1166 dseep = qtolfact * (this%gwd0(n) - this%gwd(n))
1167 end if
1168 !
1169 ! -- q from mvr
1170 dqfrommvr = dzero
1171 if (this%imover == 1) then
1172 q = this%pakmvrobj%get_qfrommvr(n)
1173 q0 = this%pakmvrobj%get_qfrommvr0(n)
1174 dqfrommvr = qtolfact * (q0 - q)
1175 end if
1176 !
1177 ! -- evaluate magnitude of differences
1178 if (n == 1) then
1179 drejinfmax = drejinf
1180 locdrejinfmax = n
1181 drchmax = drch
1182 locdrchmax = n
1183 dseepmax = dseep
1184 locdseepmax = n
1185 dqfrommvrmax = dqfrommvr
1186 locdqfrommvrmax = n
1187 else
1188 if (abs(drejinf) > abs(drejinfmax)) then
1189 drejinfmax = drejinf
1190 locdrejinfmax = n
1191 end if
1192 if (abs(drch) > abs(drchmax)) then
1193 drchmax = drch
1194 locdrchmax = n
1195 end if
1196 if (abs(dseep) > abs(dseepmax)) then
1197 dseepmax = dseep
1198 locdseepmax = n
1199 end if
1200 if (abs(dqfrommvr) > abs(dqfrommvrmax)) then
1201 dqfrommvrmax = dqfrommvr
1202 locdqfrommvrmax = n
1203 end if
1204 end if
1205 end do final_check
1206 !
1207 ! -- set dpak and cpak
1208 if (abs(drejinfmax) > abs(dpak)) then
1209 ipak = locdrejinfmax
1210 dpak = drejinfmax
1211 write (cloc, "(a,'-',a)") trim(this%packName), 'rejinf'
1212 cpak = trim(cloc)
1213 end if
1214 if (abs(drchmax) > abs(dpak)) then
1215 ipak = locdrchmax
1216 dpak = drchmax
1217 write (cloc, "(a,'-',a)") trim(this%packName), 'rech'
1218 cpak = trim(cloc)
1219 end if
1220 if (this%iseepflag == 1) then
1221 if (abs(dseepmax) > abs(dpak)) then
1222 ipak = locdseepmax
1223 dpak = dseepmax
1224 write (cloc, "(a,'-',a)") trim(this%packName), 'seep'
1225 cpak = trim(cloc)
1226 end if
1227 end if
1228 if (this%imover == 1) then
1229 if (abs(dqfrommvrmax) > abs(dpak)) then
1230 ipak = locdqfrommvrmax
1231 dpak = dqfrommvrmax
1232 write (cloc, "(a,'-',a)") trim(this%packName), 'qfrommvr'
1233 cpak = trim(cloc)
1234 end if
1235 end if
1236 !
1237 ! -- write convergence data to package csv
1238 if (this%ipakcsv /= 0) then
1239 !
1240 ! -- write the data
1241 call this%pakcsvtab%add_term(innertot)
1242 call this%pakcsvtab%add_term(totim)
1243 call this%pakcsvtab%add_term(kper)
1244 call this%pakcsvtab%add_term(kstp)
1245 call this%pakcsvtab%add_term(kiter)
1246 call this%pakcsvtab%add_term(drejinfmax)
1247 call this%pakcsvtab%add_term(locdrejinfmax)
1248 call this%pakcsvtab%add_term(drchmax)
1249 call this%pakcsvtab%add_term(locdrchmax)
1250 if (this%iseepflag == 1) then
1251 call this%pakcsvtab%add_term(dseepmax)
1252 call this%pakcsvtab%add_term(locdseepmax)
1253 end if
1254 if (this%imover == 1) then
1255 call this%pakcsvtab%add_term(dqfrommvrmax)
1256 call this%pakcsvtab%add_term(locdqfrommvrmax)
1257 end if
1258 !
1259 ! -- finalize the package csv
1260 if (iend == 1) then
1261 call this%pakcsvtab%finalize_table()
1262 end if
1263 end if
1264 end if
1265 end subroutine uzf_cc
1266
1267 !> @brief Calculate flows
1268 !<
1269 subroutine uzf_cq(this, x, flowja, iadv)
1270 ! -- modules
1271 use tdismodule, only: delt
1273 use budgetmodule, only: budgettype
1274 ! -- dummy
1275 class(uzftype), intent(inout) :: this
1276 real(DP), dimension(:), intent(in) :: x
1277 real(DP), dimension(:), contiguous, intent(inout) :: flowja
1278 integer(I4B), optional, intent(in) :: iadv
1279 ! -- local
1280 integer(I4B) :: n
1281 integer(I4B) :: node
1282 real(DP) :: qout
1283 real(DP) :: qfact
1284 real(DP) :: qtomvr
1285 real(DP) :: q
1286 ! -- for observations
1287 ! -- formats
1288 character(len=*), parameter :: fmttkk = &
1289 &"(1X,/1X,A,' PERIOD ',I0,' STEP ',I0)"
1290 !
1291 ! -- Make uzf solution for budget calculations, and then reset waves.
1292 ! Final uzf solve will be done as part of ot().
1293 call this%uzf_solve(reset_state=.true.)
1294 !
1295 ! -- call base functionality in bnd_cq. This will calculate uzf-gwf flows
1296 ! and put them into this%simvals and this%simvtomvr
1297 call this%BndType%bnd_cq(x, flowja, iadv=1)
1298 !
1299 ! -- Go through and process each UZF cell
1300 do n = 1, this%nodes
1301 !
1302 ! -- Initialize variables
1303 node = this%nodelist(n)
1304 !
1305 ! -- Skip if cell is not active
1306 if (this%ibound(node) < 1) cycle
1307 !
1308 ! -- infiltration terms
1309 this%appliedinf(n) = this%uzfobj%finf_spec(n) * this%uzfobj%uzfarea(n)
1310 this%infiltration(n) = this%uzfobj%surf_infil(n) * this%uzfobj%uzfarea(n)
1311 !
1312 ! -- qtomvr
1313 qout = this%rejinf(n) + this%uzfobj%surf_seep(n)
1314 qtomvr = dzero
1315 if (this%imover == 1) then
1316 qtomvr = this%pakmvrobj%get_qtomvr(n)
1317 end if
1318 !
1319 ! -- rejected infiltration
1320 qfact = dzero
1321 if (qout > dzero) then
1322 qfact = this%rejinf(n) / qout
1323 end if
1324 q = this%rejinf(n)
1325 this%rejinftomvr(n) = qfact * qtomvr
1326 !
1327 ! -- set rejected infiltration to the remainder
1328 q = q - this%rejinftomvr(n)
1329 !
1330 ! -- values less than zero represent a volumetric error resulting
1331 ! from qtomvr being greater than water available to the mover
1332 if (q < dzero) then
1333 q = dzero
1334 end if
1335 this%rejinf(n) = q
1336 !
1337 ! -- calculate groundwater discharge and what goes to mover
1338 this%gwd(n) = this%uzfobj%surf_seep(n)
1339 qfact = dzero
1340 if (qout > dzero) then
1341 qfact = this%gwd(n) / qout
1342 end if
1343 q = this%gwd(n)
1344 this%gwdtomvr(n) = qfact * qtomvr
1345 !
1346 ! -- set groundwater discharge to the remainder
1347 q = q - this%gwdtomvr(n)
1348 !
1349 ! -- values less than zero represent a volumetric error resulting
1350 ! from qtomvr being greater than water available to the mover
1351 if (q < dzero) then
1352 q = dzero
1353 end if
1354 this%gwd(n) = q
1355 !
1356 ! -- calculate and store remaining budget terms
1357 this%uzet(n) = this%uzfobj%et_uz(n) * this%uzfobj%uzfarea(n) / delt
1358 !
1359 ! -- End of UZF cell loop
1360 !
1361 end do
1362 !
1363 ! -- fill the budget object
1364 call this%uzf_fill_budobj()
1365 end subroutine uzf_cq
1366
1367 !> @brief Calculate the change in mobile water stored in the unsaturated zone
1368 !<
1369 function get_storage_change(top, bot, carea, hold, hnew, wcold, wcnew, &
1370 thtr, delt, iss) result(qsto)
1371 ! -- dummy
1372 real(dp), intent(in) :: top
1373 real(dp), intent(in) :: bot
1374 real(dp), intent(in) :: hold
1375 real(dp), intent(in) :: hnew
1376 real(dp), intent(in) :: wcold
1377 real(dp), intent(in) :: wcnew
1378 real(dp), intent(in) :: thtr
1379 real(dp), intent(in) :: carea
1380 real(dp), intent(in) :: delt
1381 integer(I4B) :: iss
1382 ! -- return
1383 real(dp) :: qsto
1384 ! -- local
1385 real(dp) :: thknew
1386 real(dp) :: thkold
1387 if (iss == 0) then
1388 thknew = top - max(bot, hnew)
1389 thkold = top - max(bot, hold)
1390 qsto = dzero
1391 if (thknew > dzero) then
1392 qsto = qsto + thknew * (wcnew - thtr)
1393 end if
1394 if (thkold > dzero) then
1395 qsto = qsto - thkold * (wcold - thtr)
1396 end if
1397 qsto = qsto * carea / delt
1398 else
1399 qsto = dzero
1400 end if
1401 end function get_storage_change
1402
1403 !> @brief Add package ratin/ratout to model budget
1404 !<
1405 subroutine uzf_bd(this, model_budget)
1406 ! -- add package ratin/ratout to model budget
1407 use tdismodule, only: delt
1409 class(uzftype) :: this
1410 type(budgettype), intent(inout) :: model_budget
1411 real(DP) :: ratin
1412 real(DP) :: ratout
1413 integer(I4B) :: isuppress_output
1414 isuppress_output = 0
1415 !
1416 ! -- Calculate flow from uzf to gwf (UZF-GWRCH)
1417 call rate_accumulator(this%rch, ratin, ratout)
1418 call model_budget%addentry(ratin, ratout, delt, this%bdtxt(2), &
1419 isuppress_output, this%packName)
1420 !
1421 ! -- GW discharge and GW discharge to mover
1422 if (this%iseepflag == 1) then
1423 call rate_accumulator(-this%gwd, ratin, ratout)
1424 call model_budget%addentry(ratin, ratout, delt, this%bdtxt(3), &
1425 isuppress_output, this%packName)
1426 if (this%imover == 1) then
1427 call rate_accumulator(-this%gwdtomvr, ratin, ratout)
1428 call model_budget%addentry(ratin, ratout, delt, this%bdtxt(5), &
1429 isuppress_output, this%packName)
1430 end if
1431 end if
1432 !
1433 ! -- groundwater et (gwet array is positive, so switch ratin/ratout)
1434 if (this%igwetflag /= 0) then
1435 call rate_accumulator(-this%uzfobj%gwet, ratin, ratout)
1436 call model_budget%addentry(ratin, ratout, delt, this%bdtxt(4), &
1437 isuppress_output, this%packName)
1438 end if
1439 end subroutine uzf_bd
1440
1441 !> @brief Write flows to binary file and/or print flows to budget
1442 !<
1443 subroutine uzf_ot_model_flows(this, icbcfl, ibudfl, icbcun, imap)
1444 ! -- modules
1447 ! -- dummy
1448 class(uzftype) :: this
1449 integer(I4B), intent(in) :: icbcfl
1450 integer(I4B), intent(in) :: ibudfl
1451 integer(I4B), intent(in) :: icbcun
1452 integer(I4B), dimension(:), optional, intent(in) :: imap
1453 ! -- local
1454 character(len=LINELENGTH) :: title
1455 integer(I4B) :: itxt
1456 !
1457 ! -- UZF-GWRCH
1458 itxt = 2
1459 title = trim(adjustl(this%bdtxt(itxt)))//' PACKAGE ('// &
1460 trim(this%packName)//') FLOW RATES'
1461 call save_print_model_flows(icbcfl, ibudfl, icbcun, this%iprflow, &
1462 this%outputtab, this%nbound, this%nodelist, &
1463 this%rch, this%ibound, title, this%bdtxt(itxt), &
1464 this%ipakcb, this%dis, this%naux, &
1465 this%name_model, this%name_model, &
1466 this%name_model, this%packName, this%auxname, &
1467 this%auxvar, this%iout, this%inamedbound, &
1468 this%boundname)
1469 !
1470 ! -- UZF-GWD
1471 if (this%iseepflag == 1) then
1472 itxt = 3
1473 title = trim(adjustl(this%bdtxt(itxt)))//' PACKAGE ('// &
1474 trim(this%packName)//') FLOW RATES'
1475 call save_print_model_flows(icbcfl, ibudfl, icbcun, this%iprflow, &
1476 this%outputtab, this%nbound, this%nodelist, &
1477 -this%gwd, this%ibound, title, &
1478 this%bdtxt(itxt), this%ipakcb, this%dis, &
1479 this%naux, this%name_model, this%name_model, &
1480 this%name_model, this%packName, this%auxname, &
1481 this%auxvar, this%iout, this%inamedbound, &
1482 this%boundname)
1483 !
1484 ! -- UZF-GWD TO-MVR
1485 if (this%imover == 1) then
1486 itxt = 5
1487 title = trim(adjustl(this%bdtxt(itxt)))//' PACKAGE ('// &
1488 trim(this%packName)//') FLOW RATES'
1489 call save_print_model_flows(icbcfl, ibudfl, icbcun, this%iprflow, &
1490 this%outputtab, this%nbound, this%nodelist, &
1491 -this%gwdtomvr, this%ibound, title, &
1492 this%bdtxt(itxt), this%ipakcb, this%dis, &
1493 this%naux, this%name_model, this%name_model, &
1494 this%name_model, this%packName, &
1495 this%auxname, this%auxvar, this%iout, &
1496 this%inamedbound, this%boundname)
1497 end if
1498 end if
1499 !
1500 ! -- UZF-GWET
1501 if (this%igwetflag /= 0) then
1502 itxt = 4
1503 title = trim(adjustl(this%bdtxt(itxt)))//' PACKAGE ('// &
1504 trim(this%packName)//') FLOW RATES'
1505 call save_print_model_flows(icbcfl, ibudfl, icbcun, this%iprflow, &
1506 this%outputtab, this%nbound, this%nodelist, &
1507 -this%uzfobj%gwet, this%ibound, title, &
1508 this%bdtxt(itxt), this%ipakcb, this%dis, &
1509 this%naux, this%name_model, this%name_model, &
1510 this%name_model, this%packName, this%auxname, &
1511 this%auxvar, this%iout, this%inamedbound, &
1512 this%boundname)
1513 end if
1514 end subroutine uzf_ot_model_flows
1515
1516 !> @brief Output UZF package flow terms
1517 !<
1518 subroutine uzf_ot_package_flows(this, icbcfl, ibudfl)
1519 ! -- modules
1520 use tdismodule, only: kstp, kper, delt, pertim, totim
1521 ! -- dummy
1522 class(uzftype) :: this
1523 integer(I4B), intent(in) :: icbcfl
1524 integer(I4B), intent(in) :: ibudfl
1525 integer(I4B) :: ibinun
1526 !
1527 ! -- write the flows from the budobj
1528 ibinun = 0
1529 if (this%ibudgetout /= 0) then
1530 ibinun = this%ibudgetout
1531 end if
1532 if (icbcfl == 0) ibinun = 0
1533 if (ibinun > 0) then
1534 call this%budobj%save_flows(this%dis, ibinun, kstp, kper, delt, &
1535 pertim, totim, this%iout)
1536 end if
1537 !
1538 ! -- Print lake flows table
1539 if (ibudfl /= 0 .and. this%iprflow /= 0) then
1540 call this%budobj%write_flowtable(this%dis, kstp, kper)
1541 end if
1542 end subroutine uzf_ot_package_flows
1543
1544 !> @brief Save UZF-calculated values to binary file
1545 !<
1546 subroutine uzf_ot_dv(this, idvsave, idvprint)
1547 ! -- modules
1548 use tdismodule, only: kstp, kper, pertim, totim
1549 ! -- dummy
1550 use inputoutputmodule, only: ulasav
1551 class(uzftype) :: this
1552 integer(I4B), intent(in) :: idvsave
1553 integer(I4B), intent(in) :: idvprint
1554 ! -- local
1555 integer(I4B) :: ibinun
1556 !
1557 ! -- set unit number for binary dependent variable output
1558 ibinun = 0
1559 if (this%iwcontout /= 0) then
1560 ibinun = this%iwcontout
1561 end if
1562 if (idvsave == 0) ibinun = 0
1563 !
1564 ! -- write uzf binary moisture-content output
1565 if (ibinun > 0) then
1566 call ulasav(this%wcnew, ' WATER-CONTENT', kstp, kper, pertim, &
1567 totim, this%nodes, 1, 1, ibinun)
1568 end if
1569 end subroutine uzf_ot_dv
1570
1571 !> @brief Write UZF budget to listing file
1572 !<
1573 subroutine uzf_ot_bdsummary(this, kstp, kper, iout, ibudfl)
1574 ! -- module
1575 use tdismodule, only: totim, delt
1576 ! -- dummy
1577 class(uzftype) :: this !< UzfType object
1578 integer(I4B), intent(in) :: kstp !< time step number
1579 integer(I4B), intent(in) :: kper !< period number
1580 integer(I4B), intent(in) :: iout !< flag and unit number for the model listing file
1581 integer(I4B), intent(in) :: ibudfl !< flag indicating budget should be written
1582 !
1583 call this%budobj%write_budtable(kstp, kper, iout, ibudfl, totim, delt)
1584 end subroutine uzf_ot_bdsummary
1585
1586 !> @brief Formulate the HCOF and RHS terms
1587 !!
1588 !! Called three times per time step with different intent. uzf_fc and uzf_cq
1589 !! pass reset_state true, so each cell's waves are saved before it is solved
1590 !! and restored afterwards and the wave state does not advance. Only uzf_bd_obs
1591 !! passes false, and that call is what commits the waves to their end-of-step
1592 !! position. It runs after a converged solution, so the committed waves are the
1593 !! ones consistent with the final head.
1594 !!
1595 !! The cell loop cascades water downward: a cell with cell_below sets the
1596 !! infiltration of the cell beneath it, which is read when that cell is solved
1597 !! later in the same loop. This is correct only where UZF cells are numbered
1598 !! from the top down within a vertical stack.
1599 !<
1600 subroutine uzf_solve(this, reset_state)
1601 ! -- modules
1602 use tdismodule, only: delt
1603 logical, intent(in) :: reset_state !< flag indicating that waves should be reset after solution
1604 ! -- dummy
1605 class(uzftype) :: this
1606 ! -- locals
1607 integer(I4B) :: n, ivertflag
1608 integer(I4B) :: node, m, ierr
1609 real(DP) :: trhs1, thcof1, trhs2, thcof2
1610 real(DP) :: hgwf, uzderiv, derivgwet
1611 real(DP) :: qfrommvr
1612 real(DP) :: qformvr
1613 real(DP) :: wc
1614 real(DP) :: watabold
1615 !
1616 ! -- Initialize
1617 ierr = 0
1618 do n = 1, this%nodes
1619 this%uzfobj%pet(n) = this%uzfobj%pet_max(n)
1620 end do
1621 !
1622 ! -- Calculate hcof and rhs for each UZF entry
1623 do n = 1, this%nodes
1624 !
1625 ! -- Initialize hcof/rhs terms
1626 this%hcof(n) = dzero
1627 this%rhs(n) = dzero
1628 thcof1 = dzero
1629 thcof2 = dzero
1630 trhs1 = dzero
1631 trhs2 = dzero
1632 uzderiv = dzero
1633 derivgwet = dzero
1634 !
1635 ! -- Initialize variables
1636 node = this%nodelist(n)
1637 ivertflag = this%uzfobj%cell_below(n)
1638 watabold = this%uzfobj%water_table_old(n)
1639 !
1640 if (this%ibound(node) > 0) then
1641 !
1642 ! -- Water mover added to infiltration
1643 qfrommvr = dzero
1644 qformvr = dzero
1645 if (this%imover == 1) then
1646 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
1647 end if
1648 !
1649 hgwf = this%xnew(node)
1650 m = node
1651 !
1652 ! -- solve for current uzf cell
1653 call this%uzfobj%solve(ivertflag, n, &
1654 this%totfluxtot, this%ietflag, &
1655 this%issflag, this%iseepflag, hgwf, &
1656 qfrommvr, ierr, &
1657 reset_state=reset_state, &
1658 trhs=trhs1, thcof=thcof1, deriv=uzderiv, &
1659 watercontent=wc)
1660 !
1661 ! -- terminate if an error condition has occurred
1662 if (ierr > 0) then
1663 if (ierr == 1) &
1664 errmsg = 'UZF variable NWAVESETS needs to be increased.'
1665 call store_error(errmsg, terminate=.true.)
1666 end if
1667 !
1668 ! -- Calculate gwet
1669 if (this%igwetflag > 0) then
1670 call this%uzfobj%setgwpet(n)
1671 call this%uzfobj%simgwet(this%igwetflag, n, hgwf, trhs2, thcof2, &
1672 derivgwet)
1673 end if
1674 !
1675 ! -- distribute PET to deeper cells
1676 if (this%ietflag > 0) then
1677 if (this%uzfobj%cell_below(n) > 0) then
1678 call this%uzfobj%setbelowpet(n, ivertflag)
1679 end if
1680 end if
1681 !
1682 ! -- store derivative for Newton addition to equations in _fn()
1683 this%deriv(n) = uzderiv + derivgwet
1684 !
1685 ! -- save current rejected infiltration, groundwater recharge, and
1686 ! groundwater discharge
1687 this%rejinf(n) = this%uzfobj%finf_rej(n) * this%uzfobj%uzfarea(n)
1688 this%rch(n) = this%uzfobj%flux_to_wt(n) * this%uzfobj%uzfarea(n) / delt
1689 this%gwd(n) = this%uzfobj%surf_seep(n)
1690 !
1691 ! -- add to hcof and rhs
1692 this%hcof(n) = thcof1 + thcof2
1693 this%rhs(n) = -trhs1 + trhs2
1694 !
1695 ! -- add spring discharge and rejected infiltration to mover
1696 if (this%imover == 1) then
1697 qformvr = this%gwd(n) + this%rejinf(n)
1698 call this%pakmvrobj%accumulate_qformvr(n, qformvr)
1699 end if
1700 !
1701 ! -- Store water content
1702 this%wcnew(n) = wc
1703 !
1704 ! -- Calculate change in mobile storage
1705 this%qsto(n) = get_storage_change(this%uzfobj%celtop(n), &
1706 this%uzfobj%celbot(n), &
1707 this%uzfobj%uzfarea(n), &
1708 watabold, &
1709 this%uzfobj%water_table(n), &
1710 this%wcold(n), this%wcnew(n), &
1711 this%uzfobj%theta_res(n), delt, &
1712 this%issflag)
1713 !
1714 end if
1715 end do
1716 end subroutine uzf_solve
1717
1718 !> @brief Define the list heading that is written to iout when PRINT_INPUT
1719 !! option is used
1720 !<
1721 subroutine define_listlabel(this)
1722 ! -- dummy
1723 class(uzftype), intent(inout) :: this
1724 !
1725 ! -- create the header list label
1726 this%listlabel = trim(this%filtyp)//' NO.'
1727 if (this%dis%ndim == 3) then
1728 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
1729 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'ROW'
1730 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'COL'
1731 elseif (this%dis%ndim == 2) then
1732 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
1733 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'CELL2D'
1734 else
1735 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'NODE'
1736 end if
1737 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'STRESS RATE'
1738 if (this%inamedbound == 1) then
1739 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'BOUNDARY NAME'
1740 end if
1741 end subroutine define_listlabel
1742
1743 ! -- Procedures related to observations (type-bound)
1744
1745 ! -- Procedures related to observations (NOT type-bound)
1746
1747 !> @brief Allocate scalar members
1748 !<
1749 subroutine uzf_allocate_scalars(this)
1750 ! -- modules
1752 ! -- dummy
1753 class(uzftype) :: this
1754 !
1755 ! -- call standard BndExtType allocate scalars
1756 call this%BndExtType%allocate_scalars()
1757 !
1758 ! -- allocate uzf specific scalars
1759 call mem_allocate(this%iprwcont, 'IPRWCONT', this%memoryPath)
1760 call mem_allocate(this%iwcontout, 'IWCONTOUT', this%memoryPath)
1761 call mem_allocate(this%ibudgetout, 'IBUDGETOUT', this%memoryPath)
1762 call mem_allocate(this%ibudcsv, 'IBUDCSV', this%memoryPath)
1763 call mem_allocate(this%ipakcsv, 'IPAKCSV', this%memoryPath)
1764 call mem_allocate(this%ntrail_input, 'NTRAIL_INPUT', this%memoryPath)
1765 call mem_allocate(this%nwavesets, 'NWAVESETS', this%memoryPath)
1766 call mem_allocate(this%nodes, 'NODES', this%memoryPath)
1767 call mem_allocate(this%istocb, 'ISTOCB', this%memoryPath)
1768 call mem_allocate(this%totfluxtot, 'TOTFLUXTOT', this%memoryPath)
1769 call mem_allocate(this%bditems, 'BDITEMS', this%memoryPath)
1770 call mem_allocate(this%nbdtxt, 'NBDTXT', this%memoryPath)
1771 call mem_allocate(this%issflag, 'ISSFLAG', this%memoryPath)
1772 call mem_allocate(this%issflagold, 'ISSFLAGOLD', this%memoryPath)
1773 call mem_allocate(this%readflag, 'READFLAG', this%memoryPath)
1774 call mem_allocate(this%iseepflag, 'ISEEPFLAG', this%memoryPath)
1775 call mem_allocate(this%imaxcellcnt, 'IMAXCELLCNT', this%memoryPath)
1776 call mem_allocate(this%ietflag, 'IETFLAG', this%memoryPath)
1777 call mem_allocate(this%igwetflag, 'IGWETFLAG', this%memoryPath)
1778 call mem_allocate(this%iuzf2uzf, 'IUZF2UZF', this%memoryPath)
1779 call mem_allocate(this%cbcauxitems, 'CBCAUXITEMS', this%memoryPath)
1780 !
1781 call mem_allocate(this%iconvchk, 'ICONVCHK', this%memoryPath)
1782 !
1783 ! -- initialize scalars
1784 this%iprwcont = 0
1785 this%iwcontout = 0
1786 this%ibudgetout = 0
1787 this%ibudcsv = 0
1788 this%ipakcsv = 0
1789 this%istocb = 0
1790 this%bditems = 7
1791 this%nbdtxt = 5
1792 this%issflag = 0
1793 this%issflagold = 0
1794 this%ietflag = 0
1795 this%igwetflag = 0
1796 this%iseepflag = 0
1797 this%imaxcellcnt = 0
1798 this%iuzf2uzf = 0
1799 this%cbcauxitems = 1
1800 this%imover = 0
1801 !
1802 ! -- convergence check
1803 this%iconvchk = 1
1804 end subroutine uzf_allocate_scalars
1805
1806 !> @brief Deallocate objects
1807 !<
1808 subroutine uzf_da(this)
1809 ! -- modules
1811 ! -- dummy
1812 class(uzftype) :: this
1813 !
1814 ! -- deallocate uzf objects
1815 call this%uzfobj%dealloc()
1816 deallocate (this%uzfobj)
1817 nullify (this%uzfobj)
1818 !
1819 call this%budobj%budgetobject_da()
1820 deallocate (this%budobj)
1821 nullify (this%budobj)
1822 !
1823 ! -- character arrays
1824 deallocate (this%bdtxt)
1825 deallocate (this%cauxcbc)
1826 deallocate (this%uzfname)
1827 !
1828 ! -- package csv table
1829 if (this%ipakcsv > 0) then
1830 if (associated(this%pakcsvtab)) then
1831 call this%pakcsvtab%table_da()
1832 deallocate (this%pakcsvtab)
1833 nullify (this%pakcsvtab)
1834 end if
1835 end if
1836 !
1837 ! -- deallocate scalars
1838 call mem_deallocate(this%iprwcont)
1839 call mem_deallocate(this%iwcontout)
1840 call mem_deallocate(this%ibudgetout)
1841 call mem_deallocate(this%ibudcsv)
1842 call mem_deallocate(this%ipakcsv)
1843 call mem_deallocate(this%ntrail_input)
1844 call mem_deallocate(this%nwavesets)
1845 call mem_deallocate(this%nodes)
1846 call mem_deallocate(this%istocb)
1847 call mem_deallocate(this%totfluxtot)
1848 call mem_deallocate(this%bditems)
1849 call mem_deallocate(this%nbdtxt)
1850 call mem_deallocate(this%issflag)
1851 call mem_deallocate(this%issflagold)
1852 call mem_deallocate(this%readflag)
1853 call mem_deallocate(this%iseepflag)
1854 call mem_deallocate(this%imaxcellcnt)
1855 call mem_deallocate(this%ietflag)
1856 call mem_deallocate(this%igwetflag)
1857 call mem_deallocate(this%iuzf2uzf)
1858 call mem_deallocate(this%cbcauxitems)
1859 !
1860 ! -- convergence check
1861 call mem_deallocate(this%iconvchk)
1862 !
1863 ! -- deallocate arrays
1864 call mem_deallocate(this%igwfnode)
1865 call mem_deallocate(this%appliedinf)
1866 call mem_deallocate(this%rejinf)
1867 call mem_deallocate(this%rejinf0)
1868 call mem_deallocate(this%rejinftomvr)
1869 call mem_deallocate(this%infiltration)
1870 call mem_deallocate(this%uzet)
1871 call mem_deallocate(this%gwd)
1872 call mem_deallocate(this%gwd0)
1873 call mem_deallocate(this%gwdtomvr)
1874 call mem_deallocate(this%rch)
1875 call mem_deallocate(this%rch0)
1876 call mem_deallocate(this%qsto)
1877 call mem_deallocate(this%deriv)
1878 call mem_deallocate(this%qauxcbc)
1879 call mem_deallocate(this%wcnew)
1880 call mem_deallocate(this%wcold)
1881 !
1882 ! -- deallocate integer arrays
1883 call mem_deallocate(this%ia)
1884 call mem_deallocate(this%ja)
1885 !
1886 ! -- finf_input/pet_input/extdp_input/extwc_input/ha_input/hroot_input/
1887 ! -- rootact_input/uauxvar are input context pointers
1888 !
1889 ! -- Parent object
1890 call this%BndExtType%bnd_da()
1891 end subroutine uzf_da
1892
1893end module uzfmodule
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 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_ot_model_flows(this, icbcfl, ibudfl, icbcun, imap)
Output package flow terms.
subroutine bnd_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
Convergence check for package.
subroutine bnd_bd_obs(this)
Save observations for the package.
subroutine bnd_da(this)
Deallocate package memory.
subroutine bnd_bd(this, model_budget)
Add package flows to model budget.
subroutine bnd_fc(this, rhs, ia, idxglo, matrix_sln)
Copy hcof and rhs terms into solution.
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, public save_print_model_flows(icbcfl, ibudfl, icbcun, iprflow, outputtab, nbound, nodelist, flow, ibound, title, text, ipakcb, dis, naux, textmodel, textpackage, dstmodel, dstpackage, auxname, auxvar, iout, inamedbound, boundname, imap)
Save and/or print flows for a package.
subroutine bnd_rp_obs(this)
Read and prepare observations for a package.
subroutine bnd_cf(this)
Formulate the package hcof and rhs terms.
subroutine bnd_fn(this, rhs, ia, idxglo, matrix_sln)
Add Newton-Raphson terms for package into solution.
subroutine bnd_ad(this)
Advance the boundary package.
subroutine bnd_cq(this, x, flowja, iadv)
Calculate advanced package flows.
This module contains the BudgetModule.
Definition Budget.f90:20
subroutine, public rate_accumulator(flow, rin, rout)
Rate accumulator subroutine.
Definition Budget.f90:634
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 dhundred
real constant 100
Definition Constants.f90:86
integer(i4b), parameter lenpakloc
maximum length of a package location
Definition Constants.f90:50
real(dp), parameter dem1
real constant 1e-1
real(dp), parameter dhalf
real constant 1/2
Definition Constants.f90:68
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
Definition Constants.f90:39
integer(i4b), parameter lenboundname
maximum length of a bound name
Definition Constants.f90:36
real(dp), parameter dem4
real constant 1e-4
real(dp), parameter dem6
real constant 1e-6
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
integer(i4b), parameter maxcharlen
maximum length of char string
Definition Constants.f90:47
real(dp), parameter dem2
real constant 1e-2
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
integer(i4b) function, public getunit()
Get a free unit number.
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.
subroutine, public urword(line, icol, istart, istop, ncode, n, r, iout, in)
Extract a word from a string.
This module defines variable data types.
Definition kind.f90:8
Previous variable names checked in as deprecated aliases.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
This module contains the derived types ObserveType and ObsDataType.
Definition Observe.f90:15
This module contains the derived type ObsType.
Definition Obs.f90:127
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 deprecation_warning(cblock, cvar, cver, endmsg, iunit)
Store deprecation warning message.
Definition Sim.f90:261
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
integer(i4b) ifailedstepretry
current retry for this time step
character(len=maxcharlen) warnmsg
warning message string
integer(i4b) iout
file unit number for simulation output
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
Unsaturated zone flow by the method of characteristics.
subroutine uzf_ar(this)
Allocate and Read.
Definition gwf-uzf.f90:264
subroutine uzf_fc(this, rhs, ia, idxglo, matrix_sln)
Copy rhs and hcof into solution rhs and amat.
Definition gwf-uzf.f90:990
subroutine uzf_ot_dv(this, idvsave, idvprint)
Save UZF-calculated values to binary file.
Definition gwf-uzf.f90:1547
subroutine define_listlabel(this)
Define the list heading that is written to iout when PRINT_INPUT option is used.
Definition gwf-uzf.f90:1722
subroutine uzf_da(this)
Deallocate objects.
Definition gwf-uzf.f90:1809
subroutine uzf_checkin_deprecated_names(this)
Alias deprecated UZF variable names to their current storage.
Definition gwf-uzf.f90:417
subroutine uzf_cq(this, x, flowja, iadv)
Calculate flows.
Definition gwf-uzf.f90:1270
subroutine uzf_allocate_arrays(this)
Allocate arrays used for uzf.
Definition gwf-uzf.f90:311
character(len=lenftype) ftype
Definition gwf-uzf.f90:37
subroutine uzf_ot_bdsummary(this, kstp, kper, iout, ibudfl)
Write UZF budget to listing file.
Definition gwf-uzf.f90:1574
subroutine uzf_source_dimensions(this)
Source DIMENSIONS block from input context.
Definition gwf-uzf.f90:609
subroutine uzf_cf(this)
Formulate the HCOF and RHS terms.
Definition gwf-uzf.f90:969
subroutine uzf_fn(this, rhs, ia, idxglo, matrix_sln)
Fill newton terms.
Definition gwf-uzf.f90:1020
subroutine uzf_ot_model_flows(this, icbcfl, ibudfl, icbcun, imap)
Write flows to binary file and/or print flows to budget.
Definition gwf-uzf.f90:1444
subroutine uzf_bd(this, model_budget)
Add package ratin/ratout to model budget.
Definition gwf-uzf.f90:1406
subroutine uzf_allocate_scalars(this)
Allocate scalar members.
Definition gwf-uzf.f90:1750
subroutine uzf_rp(this)
Read stress data from input context.
Definition gwf-uzf.f90:704
subroutine uzf_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
Final convergence check for package.
Definition gwf-uzf.f90:1042
subroutine, public uzf_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath)
Create a New UZF Package and point packobj to the new package.
Definition gwf-uzf.f90:223
character(len=lenpackagename) text
Definition gwf-uzf.f90:38
subroutine uzf_ot_package_flows(this, icbcfl, ibudfl)
Output UZF package flow terms.
Definition gwf-uzf.f90:1519
subroutine uzf_solve(this, reset_state)
Formulate the HCOF and RHS terms.
Definition gwf-uzf.f90:1601
subroutine uzf_ad(this)
Advance UZF Package.
Definition gwf-uzf.f90:868
subroutine uzf_source_options(this)
Source OPTIONS block from input context.
Definition gwf-uzf.f90:458
Derived type for the Budget object.
Definition Budget.f90:40
This class is used to store a single deferred-length character string. It was designed to work in an ...