MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
gwf-maw.f90
Go to the documentation of this file.
2 !
3 use kindmodule, only: dp, i4b, lgp
9 dnodata, &
17 use bndmodule, only: bndtype
18 use bndextmodule, only: bndexttype
21 use observemodule, only: observetype
22 use obsmodule, only: obstype
23 use geomutilmodule, only: get_node
26 use basedismodule, only: disbasetype
35 use openspecmodule, only: access, form
39 !
40 implicit none
41
42 public :: mawtype
43
44 !
45 character(len=LENFTYPE) :: ftype = 'MAW'
46 character(len=LENPACKAGENAME) :: text = ' MAW'
47
48 private
49 public :: maw_create
50 public :: maw_damp_weight
51 public :: maw_screen_length
52 !
53 !> @brief input context data pointers for MAW.
54 !!
55 !! Holds persistent pointers to input context arrays used at
56 !! runtime.
57 !<
59 ! -- packagedata (TS-linked; set in maw_source_packagedata)
60 real(dp), dimension(:), pointer, contiguous :: strt => null()
61 integer(I4B), dimension(:), pointer :: strt_tslink => null() !< nonzero for STRT rows linked to a time series
62 ! -- period
63 integer(I4B), pointer :: nbound => null()
64 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
65 type(characterstringtype), dimension(:), pointer, &
66 contiguous :: setting => null()
67 type(characterstringtype), dimension(:), pointer, &
68 contiguous :: status => null()
69 integer(I4B), dimension(:), pointer, contiguous :: period_icon => null()
70 type(characterstringtype), dimension(:), pointer, &
71 contiguous :: connstatus => null()
72 real(dp), dimension(:), pointer, contiguous :: period_bottom => null()
73 type(characterstringtype), dimension(:), pointer, &
74 contiguous :: head_limit => null()
75 real(dp), dimension(:), pointer, contiguous :: fwelev => null()
76 real(dp), dimension(:), pointer, contiguous :: fwcond => null()
77 real(dp), dimension(:), pointer, contiguous :: fwrlen => null()
78 real(dp), dimension(:), pointer, contiguous :: minrate => null()
79 real(dp), dimension(:), pointer, contiguous :: maxrate => null()
80 real(dp), dimension(:), pointer, contiguous :: pump_elevation => null()
81 real(dp), dimension(:), pointer, contiguous :: scaling_length => null()
82 type(characterstringtype), dimension(:), pointer, &
83 contiguous :: auxname => null()
84 real(dp), dimension(:), pointer, &
85 contiguous :: auxval => null()
86 contains
87 procedure :: init => maw_input_init
88 procedure :: destroy => maw_input_destroy
89 end type mawinputtype
90 !
91 type, extends(bndexttype) :: mawtype
92 !
93 ! -- scalars
94 ! -- characters
95 !
96 character(len=LENBUDTXT), dimension(:), pointer, &
97 contiguous :: cmawbudget => null()
98 character(len=LENAUXNAME), dimension(:), pointer, &
99 contiguous :: cauxcbc => null()
100 !
101 ! -- logical
102 logical(LGP), pointer :: correct_flow => null()
103 !
104 ! -- integers
105 integer(I4B), pointer :: iprhed => null()
106 integer(I4B), pointer :: iheadout => null()
107 integer(I4B), pointer :: ibudgetout => null()
108 integer(I4B), pointer :: ibudcsv => null()
109 integer(I4B), pointer :: cbcauxitems => null()
110 integer(I4B), pointer :: iflowingwells => null()
111 integer(I4B), pointer :: imawiss => null()
112 integer(I4B), pointer :: imawissopt => null()
113 integer(I4B), pointer :: nmawwells => null()
114 integer(I4B), pointer :: check_attr => null()
115 integer(I4B), pointer :: ishutoffcnt => null()
116 integer(I4B), pointer :: ieffradopt => null()
117 integer(I4B), pointer :: inonvert => null() !< flag indicating that non-vertical (slanted) well connections are simulated
118 integer(I4B), pointer :: ioutredflowcsv => null() !< unit number for CSV output file containing MAWs with reduced extraction/injection rates
119 real(dp), pointer :: satomega => null()
120 !
121 ! -- for underrelaxation of estimated well q if using shutoff
122 real(dp), pointer :: theta => null()
123 real(dp), pointer :: kappa => null()
124 !
125 ! -- vector data for each well
126 character(len=8), dimension(:), pointer, contiguous :: status => null()
127 integer(I4B), dimension(:), pointer, contiguous :: ngwfnodes => null()
128 integer(I4B), dimension(:), pointer, contiguous :: ieqn => null()
129 integer(I4B), dimension(:), pointer, contiguous :: ishutoff => null()
130 integer(I4B), dimension(:), pointer, contiguous :: ifwdischarge => null()
131 real(dp), dimension(:), pointer, contiguous :: strt => null()
132 real(dp), dimension(:), pointer, contiguous :: radius => null()
133 real(dp), dimension(:), pointer, contiguous :: area => null()
134 real(dp), dimension(:), pointer, contiguous :: pumpelev => null()
135 real(dp), dimension(:), pointer, contiguous :: bot => null()
136 real(dp), dimension(:), pointer, contiguous :: ratesim => null()
137 real(dp), dimension(:), pointer, contiguous :: qsim0 => null() !well rate from the previous outer iteration (rate convergence check)
138 real(dp), dimension(:), pointer, contiguous :: reduction_length => null()
139 real(dp), dimension(:), pointer, contiguous :: fwelev => null()
140 real(dp), dimension(:), pointer, contiguous :: fwcond => null()
141 real(dp), dimension(:), pointer, contiguous :: fwrlen => null()
142 real(dp), dimension(:), pointer, contiguous :: fwcondsim => null()
143 real(dp), dimension(:), pointer, contiguous :: xsto => null()
144 real(dp), dimension(:), pointer, contiguous :: xoldsto => null()
145 real(dp), dimension(:), pointer, contiguous :: shutoffmin => null()
146 real(dp), dimension(:), pointer, contiguous :: shutoffmax => null()
147 real(dp), dimension(:), pointer, contiguous :: shutofflevel => null()
148 real(dp), dimension(:), pointer, contiguous :: shutoffweight => null()
149 real(dp), dimension(:), pointer, contiguous :: shutoffdq => null()
150 real(dp), dimension(:), pointer, contiguous :: shutoffqold => null()
151 real(dp), dimension(:), pointer, contiguous :: nurdxold => null() !well head change applied in the previous outer iteration
152 real(dp), dimension(:), pointer, contiguous :: nurweight => null() !how much each well head change is cut back to stop it from oscillating
153 character(len=LENBOUNDNAME), dimension(:), pointer, &
154 contiguous :: cmawname => null()
155 !
156 ! -- time-series aware data
157 real(dp), dimension(:), pointer, contiguous :: rate => null()
158 real(dp), dimension(:), pointer, contiguous :: well_head => null()
159 !
160 ! -- .true. once a PERIOD WELL_HEAD entry has been given for a well;
161 ! WELL_HEAD then takes precedence over the PACKAGEDATA STRT baseline
162 ! for CONSTANT/INACTIVE wells
163 logical(LGP), dimension(:), pointer, contiguous :: well_head_set => null()
164 !
165 ! -- input context data pointers
166 type(mawinputtype) :: input
167 !
168 ! -- ia vector for connections
169 integer(I4B), dimension(:), pointer, contiguous :: iaconn => null()
170 !
171 ! -- vector data for each connections
172 integer(I4B), dimension(:), pointer, contiguous :: gwfnodes => null()
173 integer(I4B), dimension(:), pointer, contiguous :: iboundconn => null() !< connection status, 0 = inactive
174 real(dp), dimension(:), pointer, contiguous :: sradius => null()
175 real(dp), dimension(:), pointer, contiguous :: hk => null()
176 real(dp), dimension(:), pointer, contiguous :: satcond => null()
177 real(dp), dimension(:), pointer, contiguous :: simcond => null()
178 real(dp), dimension(:), pointer, contiguous :: topscrn => null()
179 real(dp), dimension(:), pointer, contiguous :: botscrn => null()
180 real(dp), dimension(:), pointer, contiguous :: angle => null() !< tilt angle of a non-vertical connection, in degrees from vertical (0.0 = vertical)
181 real(dp), dimension(:), pointer, contiguous :: connlen => null() !< user-specified in-cell screen length for a non-vertical connection (<= 0.0 = derive from angle and screen elevations)
182 real(dp), dimension(:), pointer, contiguous :: usrtopscrn => null() !< user-specified screen top, retained so a non-vertical SPECIFIED connection can honor it
183 real(dp), dimension(:), pointer, contiguous :: usrbotscrn => null() !< user-specified screen bottom, retained so a non-vertical SPECIFIED connection can honor it
184 !
185 ! -- imap vector
186 integer(I4B), dimension(:), pointer, contiguous :: imap => null()
187 !
188 ! -- maw output data
189 real(dp), dimension(:), pointer, contiguous :: qauxcbc => null()
190 real(dp), dimension(:), pointer, contiguous :: dbuff => null()
191 real(dp), dimension(:), pointer, contiguous :: qleak => null()
192 real(dp), dimension(:), pointer, contiguous :: qout => null()
193 real(dp), dimension(:), pointer, contiguous :: qfw => null()
194 real(dp), dimension(:), pointer, contiguous :: qsto => null()
195 real(dp), dimension(:), pointer, contiguous :: qconst => null()
196 !
197 ! -- for budgets
198 integer(I4B), pointer :: bditems => null()
199 type(budgetobjecttype), pointer :: budobj => null()
200 !
201 ! -- table objects
202 type(tabletype), pointer :: headtab => null()
203 !
204 ! -- pointer to gwf iss, k11, k22.
205 integer(I4B), pointer :: gwfiss => null()
206 real(dp), dimension(:), pointer, contiguous :: gwfk11 => null()
207 real(dp), dimension(:), pointer, contiguous :: gwfk22 => null()
208 integer(I4B), pointer :: gwfik22 => null()
209 real(dp), dimension(:), pointer, contiguous :: gwfsat => null()
210 !
211 ! -- arrays for handling the rows added to the solution matrix
212 integer(I4B), dimension(:), pointer, contiguous :: idxlocnode => null() !map position in global rhs and x array of pack entry
213 integer(I4B), dimension(:), pointer, contiguous :: idxdglo => null() !map position in global array of package diagonal row entries
214 integer(I4B), dimension(:), pointer, contiguous :: idxoffdglo => null() !map position in global array of package off diagonal row entries
215 integer(I4B), dimension(:), pointer, contiguous :: idxsymdglo => null() !map position in global array of package diagonal entries to model rows
216 integer(I4B), dimension(:), pointer, contiguous :: idxsymoffdglo => null() !map position in global array of package off diagonal entries to model rows
217 integer(I4B), dimension(:), pointer, contiguous :: iboundpak => null() !package ibound
218 real(dp), dimension(:), pointer, contiguous :: xnewpak => null() !package x vector
219 real(dp), dimension(:), pointer, contiguous :: xoldpak => null() !package xold vector
220 !
221 ! -- density variables
222 integer(I4B), pointer :: idense
223 real(dp), dimension(:, :), pointer, contiguous :: denseterms => null()
224 !
225 ! -- viscosity variables
226 real(dp), dimension(:, :), pointer, contiguous :: viscratios => null() !< viscosity ratios (1: maw vsc ratio; 2: gwf vsc ratio)
227 !
228 ! -- type bound procedures
229
230 contains
231
238 procedure :: read_initial_attr => maw_read_initial_attr
240 procedure :: bnd_ac => maw_ac
241 procedure :: bnd_mc => maw_mc
242 procedure :: bnd_ar => maw_ar
243 procedure :: bnd_rp => maw_rp
244 procedure :: bnd_ad => maw_ad
245 procedure :: bnd_cf => maw_cf
246 procedure :: bnd_fc => maw_fc
247 procedure :: bnd_fn => maw_fn
248 procedure :: bnd_nur => maw_nur
249 procedure :: bnd_cc => maw_cc
250 procedure :: bnd_cq => maw_cq
253 procedure :: bnd_ot_dv => maw_ot_dv
255 procedure :: bnd_da => maw_da
256 procedure :: define_listlabel
257 ! -- methods for observations
258 procedure, public :: bnd_obs_supported => maw_obs_supported
259 procedure, public :: bnd_df_obs => maw_df_obs
260 procedure, public :: bnd_rp_obs => maw_rp_obs
261 procedure, public :: bnd_bd_obs => maw_bd_obs
262 ! -- private procedures
263 procedure, private :: maw_source_packagedata
264 procedure, private :: maw_source_connectiondata
265 procedure, private :: maw_source_angledata
266 procedure, private :: maw_cell_extent
267 procedure, private :: maw_calc_lcorr
268 procedure, private :: maw_check_attributes
269 procedure, private :: maw_set_attribute_error
270 procedure, private :: maw_set_period_value
271 procedure, private :: maw_calculate_saturation
272 procedure, private :: maw_calculate_satcond
273 procedure, private :: maw_calculate_conn_terms
274 procedure, private :: maw_calculate_wellq
275 procedure, private :: maw_calculate_qpot
276 procedure, private :: maw_cfupdate
277 procedure, private :: get_jpos
278 procedure, private :: get_gwfnode
279 ! -- budget
280 procedure, private :: maw_setup_budobj
281 procedure, private :: maw_fill_budobj
282 ! -- table
283 procedure, private :: maw_setup_tableobj
284 ! -- density
286 procedure, private :: maw_calculate_density_exchange
287 ! -- MAW reduced flow outputs
288 procedure, private :: maw_redflow_csv_init
289 procedure, private :: maw_redflow_csv_write
290 ! -- viscosity
292 end type mawtype
293
294contains
295
296!> @brief Create a New Multi-Aquifer Well (MAW) Package
297!!
298!! After creating the package object point bndobj to the new package
299!<
300 subroutine maw_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, &
301 mempath)
302 ! -- dummy
303 class(bndtype), pointer :: packobj
304 integer(I4B), intent(in) :: id
305 integer(I4B), intent(in) :: ibcnum
306 integer(I4B), intent(in) :: inunit
307 integer(I4B), intent(in) :: iout
308 character(len=*), intent(in) :: namemodel
309 character(len=*), intent(in) :: pakname
310 character(len=*), intent(in) :: mempath
311 type(mawtype), pointer :: mawobj
312 !
313 ! -- allocate the object and assign values to object variables
314 allocate (mawobj)
315 packobj => mawobj
316 !
317 ! -- create name and memory path
318 call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
319 packobj%text = text
320 !
321 ! -- allocate scalars
322 call mawobj%maw_allocate_scalars()
323 !
324 ! -- initialize package
325 call packobj%pack_initialize()
326 !
327 packobj%inunit = inunit
328 packobj%iout = iout
329 packobj%id = id
330 packobj%ibcnum = ibcnum
331 packobj%ncolbnd = 4
332 packobj%iscloc = 0 ! not supported
333 packobj%isadvpak = 1
334 packobj%ictMemPath = create_mem_path(namemodel, 'NPF')
335 end subroutine maw_create
336
337 !> @brief Allocate scalar members
338 !<
339 subroutine maw_allocate_scalars(this)
340 ! -- modules
342 ! -- dummy
343 class(mawtype), intent(inout) :: this
344 !
345 ! -- call standard BndExtType allocate scalars
346 call this%BndExtType%allocate_scalars()
347 !
348 ! -- allocate the object and assign values to object variables
349 call mem_allocate(this%correct_flow, 'CORRECT_FLOW', this%memoryPath)
350 call mem_allocate(this%iprhed, 'IPRHED', this%memoryPath)
351 call mem_allocate(this%iheadout, 'IHEADOUT', this%memoryPath)
352 call mem_allocate(this%ibudgetout, 'IBUDGETOUT', this%memoryPath)
353 call mem_allocate(this%ibudcsv, 'IBUDCSV', this%memoryPath)
354 call mem_allocate(this%iflowingwells, 'IFLOWINGWELLS', this%memoryPath)
355 call mem_allocate(this%imawiss, 'IMAWISS', this%memoryPath)
356 call mem_allocate(this%imawissopt, 'IMAWISSOPT', this%memoryPath)
357 call mem_allocate(this%nmawwells, 'NMAWWELLS', this%memoryPath)
358 call mem_allocate(this%check_attr, 'CHECK_ATTR', this%memoryPath)
359 call mem_allocate(this%ishutoffcnt, 'ISHUTOFFCNT', this%memoryPath)
360 call mem_allocate(this%ieffradopt, 'IEFFRADOPT', this%memoryPath)
361 call mem_allocate(this%inonvert, 'INONVERT', this%memoryPath)
362 call mem_allocate(this%ioutredflowcsv, 'IOUTREDFLOWCSV', this%memoryPath) !for writing reduced MAW flows to csv file
363 call mem_allocate(this%satomega, 'SATOMEGA', this%memoryPath)
364 call mem_allocate(this%bditems, 'BDITEMS', this%memoryPath)
365 call mem_allocate(this%theta, 'THETA', this%memoryPath)
366 call mem_allocate(this%kappa, 'KAPPA', this%memoryPath)
367 call mem_allocate(this%cbcauxitems, 'CBCAUXITEMS', this%memoryPath)
368 call mem_allocate(this%idense, 'IDENSE', this%memoryPath)
369 !
370 ! -- Set values
371 this%correct_flow = .false.
372 this%nmawwells = 0
373 this%iprhed = 0
374 this%iheadout = 0
375 this%ibudgetout = 0
376 this%ibudcsv = 0
377 this%iflowingwells = 0
378 this%imawiss = 0
379 this%imawissopt = 0
380 this%ieffradopt = 0
381 this%inonvert = 0
382 this%ioutredflowcsv = 0
383 this%satomega = dzero
384 this%bditems = 8
385 this%theta = dp7
386 this%kappa = dem4
387 this%cbcauxitems = 1
388 this%idense = 0
389 this%ivsc = 0
390 end subroutine maw_allocate_scalars
391
392 !> @brief Allocate well arrays
393 !<
395 ! -- modules
397 ! -- dummy
398 class(mawtype), intent(inout) :: this
399 ! -- local
400 integer(I4B) :: j
401 integer(I4B) :: n
402 !
403 ! -- allocate character array for budget text
404 call mem_allocate(this%cmawbudget, lenbudtxt, this%bditems, 'CMAWBUDGET', &
405 this%memoryPath)
406 !
407 !-- fill cmawbudget
408 this%cmawbudget(1) = ' GWF'
409 this%cmawbudget(2) = ' RATE'
410 this%cmawbudget(3) = ' STORAGE'
411 this%cmawbudget(4) = ' CONSTANT'
412 this%cmawbudget(5) = ' FW-RATE'
413 this%cmawbudget(6) = ' FROM-MVR'
414 this%cmawbudget(7) = ' RATE-TO-MVR'
415 this%cmawbudget(8) = ' FW-RATE-TO-MVR'
416 !
417 ! -- allocate character arrays
418 call mem_allocate(this%cmawname, lenboundname, this%nmawwells, 'CMAWNAME', &
419 this%memoryPath)
420 call mem_allocate(this%status, 8, this%nmawwells, 'STATUS', this%memoryPath)
421 !
422 ! -- allocate well data pointers in memory manager
423 call mem_allocate(this%ngwfnodes, this%nmawwells, 'NGWFNODES', &
424 this%memoryPath)
425 call mem_allocate(this%ieqn, this%nmawwells, 'IEQN', this%memoryPath)
426 call mem_allocate(this%ishutoff, this%nmawwells, 'ISHUTOFF', this%memoryPath)
427 call mem_allocate(this%ifwdischarge, this%nmawwells, 'IFWDISCHARGE', &
428 this%memoryPath)
429 call mem_allocate(this%strt, this%nmawwells, 'STRT', this%memoryPath)
430 call mem_allocate(this%radius, this%nmawwells, 'RADIUS', this%memoryPath)
431 call mem_allocate(this%area, this%nmawwells, 'AREA', this%memoryPath)
432 call mem_allocate(this%pumpelev, this%nmawwells, 'PUMPELEV', this%memoryPath)
433 call mem_allocate(this%bot, this%nmawwells, 'BOT', this%memoryPath)
434 call mem_allocate(this%ratesim, this%nmawwells, 'RATESIM', this%memoryPath)
435 call mem_allocate(this%qsim0, this%nmawwells, 'QSIM0', this%memoryPath)
436 call mem_allocate(this%reduction_length, this%nmawwells, 'REDUCTION_LENGTH', &
437 this%memoryPath)
438 call mem_allocate(this%fwelev, this%nmawwells, 'FWELEV', this%memoryPath)
439 call mem_allocate(this%fwcond, this%nmawwells, 'FWCONDS', this%memoryPath)
440 call mem_allocate(this%fwrlen, this%nmawwells, 'FWRLEN', this%memoryPath)
441 call mem_allocate(this%fwcondsim, this%nmawwells, 'FWCONDSIM', &
442 this%memoryPath)
443 call mem_allocate(this%xsto, this%nmawwells, 'XSTO', this%memoryPath)
444 call mem_allocate(this%xoldsto, this%nmawwells, 'XOLDSTO', this%memoryPath)
445 call mem_allocate(this%shutoffmin, this%nmawwells, 'SHUTOFFMIN', &
446 this%memoryPath)
447 call mem_allocate(this%shutoffmax, this%nmawwells, 'SHUTOFFMAX', &
448 this%memoryPath)
449 call mem_allocate(this%shutofflevel, this%nmawwells, 'SHUTOFFLEVEL', &
450 this%memoryPath)
451 call mem_allocate(this%shutoffweight, this%nmawwells, 'SHUTOFFWEIGHT', &
452 this%memoryPath)
453 call mem_allocate(this%shutoffdq, this%nmawwells, 'SHUTOFFDQ', &
454 this%memoryPath)
455 call mem_allocate(this%shutoffqold, this%nmawwells, 'SHUTOFFQOLD', &
456 this%memoryPath)
457 call mem_allocate(this%nurdxold, this%nmawwells, 'NURDXOLD', &
458 this%memoryPath)
459 call mem_allocate(this%nurweight, this%nmawwells, 'NURWEIGHT', &
460 this%memoryPath)
461 !
462 ! -- alias into the input context's permanent, feature-indexed arrays
463 ! (allocated and DZERO-initialized by the loader)
464 call mem_setptr(this%rate, 'RATE', this%input_mempath)
465 call mem_setptr(this%well_head, 'WELL_HEAD', this%input_mempath)
466 call mem_allocate(this%well_head_set, this%nmawwells, 'WELL_HEAD_SET', &
467 this%memoryPath)
468 this%well_head_set = .false.
469 !
470 ! -- allocate and initialize dbuff
471 if (this%iheadout > 0) then
472 call mem_allocate(this%dbuff, this%nmawwells, 'DBUFF', this%memoryPath)
473 else
474 call mem_allocate(this%dbuff, 0, 'DBUFF', this%memoryPath)
475 end if
476 !
477 ! -- allocate iaconn
478 call mem_allocate(this%iaconn, this%nmawwells + 1, 'IACONN', this%memoryPath)
479 !
480 ! -- allocate imap
481 call mem_allocate(this%imap, this%MAXBOUND, 'IMAP', this%memoryPath)
482 !
483 ! -- allocate connection data
484 call mem_allocate(this%gwfnodes, this%maxbound, 'GWFNODES', this%memoryPath)
485 call mem_allocate(this%iboundconn, this%maxbound, 'IBOUNDCONN', &
486 this%memoryPath)
487 call mem_allocate(this%sradius, this%maxbound, 'SRADIUS', this%memoryPath)
488 call mem_allocate(this%hk, this%maxbound, 'HK', this%memoryPath)
489 call mem_allocate(this%satcond, this%maxbound, 'SATCOND', this%memoryPath)
490 call mem_allocate(this%simcond, this%maxbound, 'SIMCOND', this%memoryPath)
491 call mem_allocate(this%topscrn, this%maxbound, 'TOPSCRN', this%memoryPath)
492 call mem_allocate(this%botscrn, this%maxbound, 'BOTSCRN', this%memoryPath)
493 call mem_allocate(this%angle, this%maxbound, 'ANGLE', this%memoryPath)
494 call mem_allocate(this%connlen, this%maxbound, 'CONNLEN', this%memoryPath)
495 call mem_allocate(this%usrtopscrn, this%maxbound, 'USRTOPSCRN', &
496 this%memoryPath)
497 call mem_allocate(this%usrbotscrn, this%maxbound, 'USRBOTSCRN', &
498 this%memoryPath)
499 !
500 ! -- allocate qleak
501 call mem_allocate(this%qleak, this%maxbound, 'QLEAK', this%memoryPath)
502 !
503 ! -- initialize well data
504 do n = 1, this%nmawwells
505 this%status(n) = 'ACTIVE'
506 this%ngwfnodes(n) = 0
507 this%ieqn(n) = 0
508 this%ishutoff(n) = 0
509 this%ifwdischarge(n) = 0
510 this%strt(n) = dep20
511 this%radius(n) = dep20
512 this%area(n) = dzero
513 this%pumpelev(n) = dep20
514 this%bot(n) = dep20
515 this%ratesim(n) = dzero
516 this%qsim0(n) = dzero
517 this%reduction_length(n) = dep20
518 this%fwelev(n) = dzero
519 this%fwcond(n) = dzero
520 this%fwrlen(n) = dzero
521 this%fwcondsim(n) = dzero
522 this%xsto(n) = dzero
523 this%xoldsto(n) = dzero
524 this%shutoffmin(n) = dzero
525 this%shutoffmax(n) = dzero
526 this%shutofflevel(n) = dep20
527 this%shutoffweight(n) = done
528 this%shutoffdq(n) = done
529 this%shutoffqold(n) = done
530 this%nurdxold(n) = dzero
531 this%nurweight(n) = done
532 !
533 ! -- timeseries aware variables
534 this%rate(n) = dzero
535 this%well_head(n) = dzero
536 !
537 ! -- dbuff
538 if (this%iheadout > 0) then
539 this%dbuff(n) = dzero
540 end if
541 end do
542 !
543 ! -- initialize iaconn
544 do n = 1, this%nmawwells + 1
545 this%iaconn(n) = 0
546 end do
547 !
548 ! -- allocate character array for budget text
549 call mem_allocate(this%cauxcbc, lenauxname, this%cbcauxitems, 'CAUXCBC', &
550 this%memoryPath)
551 !
552 ! -- allocate and initialize qauxcbc
553 call mem_allocate(this%qauxcbc, this%cbcauxitems, 'QAUXCBC', this%memoryPath)
554 do j = 1, this%cbcauxitems
555 this%qauxcbc(j) = dzero
556 end do
557 !
558 ! -- allocate flowing well data
559 if (this%iflowingwells /= 0) then
560 call mem_allocate(this%qfw, this%nmawwells, 'QFW', this%memoryPath)
561 else
562 call mem_allocate(this%qfw, 1, 'QFW', this%memoryPath)
563 end if
564 call mem_allocate(this%qout, this%nmawwells, 'QOUT', this%memoryPath)
565 call mem_allocate(this%qsto, this%nmawwells, 'QSTO', this%memoryPath)
566 call mem_allocate(this%qconst, this%nmawwells, 'QCONST', this%memoryPath)
567 !
568 ! -- initialize flowing well, storage, and constant flow terms
569 do n = 1, this%nmawwells
570 if (this%iflowingwells > 0) then
571 this%qfw(n) = dzero
572 end if
573 this%qsto(n) = dzero
574 this%qconst(n) = dzero
575 end do
576 !
577 ! -- initialize connection data
578 do j = 1, this%maxbound
579 this%imap(j) = 0
580 this%gwfnodes(j) = 0
581 this%iboundconn(j) = 1
582 this%sradius(j) = dzero
583 this%hk(j) = dzero
584 this%satcond(j) = dzero
585 this%simcond(j) = dzero
586 this%topscrn(j) = dzero
587 this%botscrn(j) = dzero
588 this%angle(j) = dzero
589 this%connlen(j) = dzero
590 this%usrtopscrn(j) = dzero
591 this%usrbotscrn(j) = dzero
592 this%qleak(j) = dzero
593 end do
594 !
595 ! -- allocate denseterms to size 0
596 call mem_allocate(this%denseterms, 3, 0, 'DENSETERMS', this%memoryPath)
597 !
598 ! -- allocate viscratios to size 0
599 call mem_allocate(this%viscratios, 2, 0, 'VISCRATIOS', this%memoryPath)
600 end subroutine maw_allocate_well_conn_arrays
601
602 !> @brief Allocate arrays
603 !<
604 subroutine maw_allocate_arrays(this)
605 ! -- modules
607 ! -- dummy
608 class(mawtype), intent(inout) :: this
609 ! -- local
610 !
611 ! -- allocate BndType connection-level arrays
612 call this%BndExtType%allocate_arrays()
613 !
614 ! -- allocate featureauxvar PACKAGEDATA variables
615 call this%BndExtType%allocate_featureauxvar()
616 end subroutine maw_allocate_arrays
617
618 !> @brief Alias deprecated MAW variable names to their current storage
619 !!
620 !! IDM integration moved several well variables into the input context,
621 !! renaming some. These aliases share memory with the relocated variables so
622 !! that programs addressing them through the API by their old package-path
623 !! names continue to resolve; each use is reported as deprecated.
624 !<
626 ! -- modules
629 ! -- dummy
630 class(mawtype), intent(inout) :: this
631 ! -- local
632 real(DP), dimension(:, :), pointer, contiguous :: aux => null()
633 integer(I4B) :: isize
634 ! -- code
635 !
636 call mem_alias_deprecated(this%rate, 'RATE', this%memoryPath, &
637 'RATE', this%input_mempath, '6.8.2')
638 call mem_alias_deprecated(this%well_head, 'WELL_HEAD', this%memoryPath, &
639 'WELL_HEAD', this%input_mempath, '6.8.2')
640 !
641 ! -- well auxiliary values, present (possibly empty) in the input context;
642 ! without auxiliary variables MAUXVAR is empty, where 6.8.1 allocated
643 ! one row of zeros
644 call get_isize('AUX', this%input_mempath, isize)
645 if (isize >= 0) then
646 call mem_setptr(aux, 'AUX', this%input_mempath)
647 call mem_alias_deprecated(aux, 'MAUXVAR', this%memoryPath, &
648 'AUX', this%input_mempath, '6.8.2')
649 end if
650 end subroutine maw_checkin_deprecated_names
651
652 !> @brief Source OPTIONS block from input context
653 !<
654 subroutine maw_source_options(this)
655 ! -- dummy
656 class(mawtype), intent(inout) :: this
657 ! -- local
658 type(gwfmawparamfoundtype) :: found
659 integer(I4B) :: isize
660 character(len=LINELENGTH) :: fname
661 ! -- formats
662 character(len=*), parameter :: fmtflowingwells = &
663 &"(4x, 'FLOWING WELLS WILL BE SIMULATED.')"
664 character(len=*), parameter :: fmtshutdown = &
665 &"(4x, 'SHUTDOWN ', a, ' VALUE (',g15.7,') SPECIFIED.')"
666 character(len=*), parameter :: fmtnostoragewells = &
667 &"(4x, 'WELL STORAGE WILL NOT BE SIMULATED.')"
668 character(len=*), parameter :: fmtmawbin = &
669 "(4x, 'MAW ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, /4x, &
670 &'OPENED ON UNIT: ', I0)"
671 !
672 ! -- call base class to handle AUXILIARY/NAUX, BOUNDNAMES, PRINT_INPUT,
673 ! PRINT_FLOWS, SAVE_FLOWS, OBS6_FILENAME, AUXMULTNAME
674 call this%BndExtType%source_options()
675 !
676 write (this%iout, '(1x,a)') &
677 'PROCESSING '//trim(adjustl(this%text))//' OPTIONS'
678 !
679 ! -- PRINT_HEAD
680 call get_isize('PRINT_HEAD', this%input_mempath, isize)
681 if (isize > 0) then
682 this%iprhed = 1
683 write (this%iout, '(4x,a)') &
684 trim(adjustl(this%text))//' heads will be printed to listing file.'
685 end if
686 !
687 ! -- HEAD FILEOUT
688 call mem_set_value(fname, 'HEADFILE', this%input_mempath, found%headfile)
689 if (found%headfile) then
690 call assign_iounit(this%iheadout, this%inunit, "HEAD fileout")
691 call openfile(this%iheadout, this%iout, fname, 'DATA(BINARY)', &
692 form, access, 'REPLACE', mode_opt=mnormal)
693 write (this%iout, fmtmawbin) 'HEAD', trim(adjustl(fname)), this%iheadout
694 end if
695 !
696 ! -- BUDGET FILEOUT
697 call mem_set_value(fname, 'BUDGETFILE', this%input_mempath, found%budgetfile)
698 if (found%budgetfile) then
699 call assign_iounit(this%ibudgetout, this%inunit, "BUDGET fileout")
700 call openfile(this%ibudgetout, this%iout, fname, 'DATA(BINARY)', &
701 form, access, 'REPLACE', mode_opt=mnormal)
702 write (this%iout, fmtmawbin) 'BUDGET', trim(adjustl(fname)), this%ibudgetout
703 end if
704 !
705 ! -- BUDGETCSV FILEOUT
706 call mem_set_value(fname, 'BUDGETCSVFILE', this%input_mempath, &
707 found%budgetcsvfile)
708 if (found%budgetcsvfile) then
709 call assign_iounit(this%ibudcsv, this%inunit, "BUDGETCSV fileout")
710 call openfile(this%ibudcsv, this%iout, fname, 'CSV', filstat_opt='REPLACE')
711 write (this%iout, fmtmawbin) &
712 'BUDGET CSV', trim(adjustl(fname)), this%ibudcsv
713 end if
714 !
715 ! -- NO_WELL_STORAGE
716 call get_isize('NO_WELL_STORAGE', this%input_mempath, isize)
717 if (isize > 0) then
718 this%imawissopt = 1
719 write (this%iout, fmtnostoragewells)
720 end if
721 !
722 ! -- FLOW_CORRECTION
723 call get_isize('FLOW_CORRECTION', this%input_mempath, isize)
724 if (isize > 0) then
725 this%correct_flow = .true.
726 write (this%iout, '(4x,a,/,4x,a)') &
727 'MAW-GWF FLOW CORRECTIONS WILL BE APPLIED WHEN MAW HEADS ARE BELOW', &
728 'OR GWF HEADS IN CONNECTED CELLS ARE BELOW THE CELL BOTTOM.'
729 end if
730 !
731 ! -- FLOWING_WELLS
732 call get_isize('FLOWING_WELLS', this%input_mempath, isize)
733 if (isize > 0) then
734 this%iflowingwells = 1
735 write (this%iout, fmtflowingwells)
736 end if
737 !
738 ! -- SHUTDOWN_THETA
739 call mem_set_value(this%theta, 'SHUTDOWN_THETA', this%input_mempath, &
740 found%shutdown_theta)
741 if (found%shutdown_theta) then
742 write (this%iout, fmtshutdown) 'THETA', this%theta
743 end if
744 !
745 ! -- SHUTDOWN_KAPPA
746 call mem_set_value(this%kappa, 'SHUTDOWN_KAPPA', this%input_mempath, &
747 found%shutdown_kappa)
748 if (found%shutdown_kappa) then
749 write (this%iout, fmtshutdown) 'KAPPA', this%kappa
750 end if
751 !
752 ! -- MAW_FLOW_REDUCE_CSV FILEOUT
753 call mem_set_value(fname, 'MFRCSVFILE', this%input_mempath, found%mfrcsvfile)
754 if (found%mfrcsvfile) then
755 call this%maw_redflow_csv_init(fname)
756 end if
757 !
758 ! -- MOVER
759 call get_isize('MOVER', this%input_mempath, isize)
760 if (isize > 0) then
761 this%imover = 1
762 write (this%iout, '(4x,A)') 'MOVER OPTION ENABLED'
763 end if
764 !
765 ! -- DEV_PEACEMAN_EFFECTIVE_RADIUS
766 call get_isize('IEFFRADOPT', this%input_mempath, isize)
767 if (isize > 0) then
768 this%ieffradopt = 1
769 write (this%iout, '(4x,a)') &
770 'EFFECTIVE RADIUS FOR STRUCTURED GRIDS WILL BE CALCULATED &
771 &USING PEACEMAN 1983'
772 end if
773 !
774 ! -- NON_VERTICAL_WELLS
775 call get_isize('INONVERT', this%input_mempath, isize)
776 if (isize > 0) then
777 this%inonvert = 1
778 write (this%iout, '(4x,a)') &
779 'NON-VERTICAL (SLANTED) WELL CONNECTIONS ENABLED'
780 end if
781 !
782 write (this%iout, '(1x,a)') 'END OF '//trim(adjustl(this%text))//' OPTIONS'
783 end subroutine maw_source_options
784
785 !> @brief Source DIMENSIONS block from input context
786 !<
787 subroutine maw_source_dimensions(this)
788 ! -- dummy
789 class(mawtype), intent(inout) :: this
790 ! -- local
791 type(gwfmawparamfoundtype) :: found
792 !
793 ! -- initialize dimensions
794 this%nmawwells = -1
795 this%maxbound = -1
796 !
797 write (this%iout, '(/1x,a)') &
798 'PROCESSING '//trim(adjustl(this%text))//' DIMENSIONS'
799 !
800 ! -- read NMAWWELLS
801 call mem_set_value(this%nmawwells, 'MAXBOUND', this%input_mempath, &
802 found%maxbound, release=.false.)
803 if (found%maxbound) then
804 write (this%iout, '(4x,a,i0)') 'NMAWWELLS = ', this%nmawwells
805 end if
806 !
807 write (this%iout, '(1x,a)') &
808 'END OF '//trim(adjustl(this%text))//' DIMENSIONS'
809 !
810 if (this%nmawwells < 0) then
811 write (errmsg, '(a)') &
812 'NMAWWELLS was not specified or was specified incorrectly.'
813 call store_error(errmsg)
814 call store_error_filename(this%input_fname)
815 end if
816 !
817 ! -- set npakeq to nmawwells
818 this%npakeq = this%nmawwells
819 !
820 ! -- read PACKAGEDATA
821 call this%maw_source_packagedata()
822 !
823 ! -- read CONNECTIONDATA
824 call this%maw_source_connectiondata()
825 !
826 ! -- read optional ANGLEDATA (non-vertical well connections)
827 call this%maw_source_angledata()
828 !
829 ! -- alias deprecated variable names
830 call this%maw_checkin_deprecated_names()
831 !
832 ! -- Call define_listlabel
833 call this%define_listlabel()
834 !
835 ! -- setup the budget object
836 call this%maw_setup_budobj()
837 !
838 ! -- setup the head table object
839 call this%maw_setup_tableobj()
840 end subroutine maw_source_dimensions
841
842 !> @brief Bind MawInputType pointers to input context arrays.
843 !!
844 !! Values are updated from the input context each stress period
845 !! including integrated timeseries for supported arrays.
846 !<
847 subroutine maw_input_init(this, mempath, naux)
848 class(mawinputtype), intent(inout) :: this
849 character(len=*), intent(in) :: mempath
850 integer(I4B), intent(in) :: naux
851 call mem_setptr(this%nbound, 'NBOUND', mempath)
852 call mem_setptr(this%ifno, 'IFNO', mempath)
853 call mem_setptr(this%setting, 'SETTING', mempath)
854 call mem_setptr(this%status, 'STATUS', mempath)
855 call mem_setptr(this%period_icon, 'PERIOD_ICON', mempath)
856 call mem_setptr(this%connstatus, 'CONNSTATUS', mempath)
857 call mem_setptr(this%period_bottom, 'PERIOD_BOTTOM', mempath)
858 call mem_setptr(this%head_limit, 'HEAD_LIMIT', mempath)
859 call mem_setptr(this%fwelev, 'FWELEV', mempath)
860 call mem_setptr(this%fwcond, 'FWCOND', mempath)
861 call mem_setptr(this%fwrlen, 'FWRLEN', mempath)
862 call mem_setptr(this%minrate, 'MINRATE', mempath)
863 call mem_setptr(this%maxrate, 'MAXRATE', mempath)
864 call mem_setptr(this%pump_elevation, 'PUMP_ELEVATION', mempath)
865 call mem_setptr(this%scaling_length, 'SCALING_LENGTH', mempath)
866 if (naux > 0) then
867 call mem_setptr(this%auxname, 'AUXNAME', mempath)
868 call mem_setptr(this%auxval, 'AUXVAL', mempath)
869 end if
870 end subroutine maw_input_init
871
872 !> @brief Nullify all MawInputType pointers.
873 !<
874 subroutine maw_input_destroy(this)
875 class(mawinputtype), intent(inout) :: this
876 nullify (this%strt)
877 nullify (this%strt_tslink)
878 nullify (this%nbound)
879 nullify (this%ifno)
880 nullify (this%setting)
881 nullify (this%status)
882 nullify (this%period_icon)
883 nullify (this%connstatus)
884 nullify (this%period_bottom)
885 nullify (this%head_limit)
886 nullify (this%fwelev)
887 nullify (this%fwcond)
888 nullify (this%fwrlen)
889 nullify (this%minrate)
890 nullify (this%maxrate)
891 nullify (this%pump_elevation)
892 nullify (this%scaling_length)
893 nullify (this%auxname)
894 nullify (this%auxval)
895 end subroutine maw_input_destroy
896
897 !> @brief Source PACKAGEDATA block from input context
898 !<
899 subroutine maw_source_packagedata(this)
900 ! -- dummy
901 class(mawtype), intent(inout) :: this
902 ! -- local
903 integer(I4B) :: n, jj, idx, imaw
904 character(len=9) :: cno9
905 character(len=LINELENGTH) :: keyword
906 real(DP) :: rval
907 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
908 real(DP), dimension(:), pointer, contiguous :: radius => null()
909 real(DP), dimension(:), pointer, contiguous :: bottom => null()
910 type(characterstringtype), dimension(:), pointer, &
911 contiguous :: condeqn => null()
912 integer(I4B), dimension(:), pointer, contiguous :: ngwfnodes => null()
913 type(characterstringtype), dimension(:), pointer, &
914 contiguous :: boundname => null()
915 integer(I4B), dimension(:, :), pointer, contiguous :: tslink => null()
916 type(characterstringtype), dimension(:), pointer, &
917 contiguous :: tslinkvars => null()
918 integer(I4B), allocatable :: nboundchk(:)
919 ! -- formats
920 character(len=*), parameter :: fmthdbot = &
921 "('well head (', G0, ') must be greater than or equal to the &
922 &BOTTOM_ELEVATION (', G0, ').')"
923 !
924 write (this%iout, '(/1x,a)') &
925 'PROCESSING '//trim(adjustl(this%text))//' PACKAGEDATA'
926 !
927 ! -- get input context PACKAGEDATA column arrays
928 call mem_setptr(ifno, 'PACKAGEDATA_IFNO', this%input_mempath)
929 call mem_setptr(radius, 'RADIUS', this%input_mempath)
930 call mem_setptr(bottom, 'BOTTOM', this%input_mempath)
931 call mem_setptr(this%input%strt, 'STRT', this%input_mempath)
932 call mem_setptr(tslink, 'TSLINK_PD', this%input_mempath)
933 call mem_setptr(tslinkvars, 'TSLINKVARS_PD', this%input_mempath)
934 do n = 1, size(tslinkvars)
935 if (tslinkvars(n) == 'STRT') this%input%strt_tslink => tslink(n, :)
936 end do
937 if (.not. associated(this%input%strt_tslink)) then
938 call store_error('Time series links for STRT not found in input.')
939 call store_error_filename(this%input_fname)
940 end if
941 call mem_setptr(condeqn, 'CONDEQN', this%input_mempath)
942 call mem_setptr(ngwfnodes, 'NGWFNODES', this%input_mempath)
943 if (this%inamedbound /= 0) then
944 call mem_setptr(boundname, 'BOUNDNAME', this%input_mempath)
945 end if
946 !
947 ! -- total GWF connections is the sum of per-well node counts;
948 ! -- allocate well and connection arrays before filling them
949 this%maxbound = sum(ngwfnodes)
950 write (this%iout, '(//4x,a,i7)') 'MAXBOUND = ', this%maxbound
951 call this%maw_allocate_well_conn_arrays()
952 !
953 ! -- validate and fill allocated arrays in feature-number order
954 allocate (nboundchk(this%nmawwells))
955 nboundchk = 0
956 do n = 1, this%nmawwells
957 imaw = this%validate_ifno(ifno(n), this%nmawwells, nboundchk, &
958 'IMAW', 'PACKAGEDATA')
959 if (imaw == 0) cycle
960 !
961 ! -- radius
962 rval = radius(n)
963 if (rval <= dzero) then
964 write (errmsg, '(a,1x,i0,1x,a)') &
965 'Radius for well', imaw, 'must be greater than zero.'
966 call store_error(errmsg)
967 end if
968 this%radius(imaw) = rval
969 this%area(imaw) = dpi * rval**dtwo
970 !
971 ! -- well bottom
972 this%bot(imaw) = bottom(n)
973 !
974 ! -- conductance equation
975 keyword = condeqn(n)
976 select case (trim(keyword))
977 case ('SPECIFIED')
978 this%ieqn(imaw) = 0
979 case ('THIEM')
980 this%ieqn(imaw) = 1
981 case ('THEIM') ! # codespell:ignore
982 this%ieqn(imaw) = 1
983 write (warnmsg, '(a,a,a,a,a,a)') &
984 "CONDEQN in '", trim(this%packName), "' should be ", &
985 "corrected from '", trim(keyword), "' to 'THIEM'."
987 case ('SKIN')
988 this%ieqn(imaw) = 2
989 case ('CUMULATIVE')
990 this%ieqn(imaw) = 3
991 case ('MEAN')
992 this%ieqn(imaw) = 4
993 case default
994 write (errmsg, '(a,1x,i0,1x,a)') &
995 'CONDEQN for well', imaw, &
996 "must be 'CUMULATIVE', 'THIEM', 'MEAN', or 'SKIN'."
997 call store_error(errmsg)
998 this%ieqn(imaw) = 0
999 end select
1000 !
1001 ! -- ngwfnodes
1002 if (ngwfnodes(n) < 1) then
1003 write (errmsg, '(a,1x,i0,1x,a)') &
1004 'NGWFNODES for well', imaw, 'must be greater than zero.'
1005 call store_error(errmsg)
1006 end if
1007 this%ngwfnodes(imaw) = ngwfnodes(n)
1008 !
1009 ! -- read the TS integrated numeric value directly
1010 this%well_head(imaw) = this%input%strt(n)
1011 this%strt(imaw) = this%input%strt(n)
1012 if (this%strt(imaw) < this%bot(imaw)) then
1013 write (keyword, fmthdbot) this%strt(imaw), this%bot(imaw)
1014 call this%maw_set_attribute_error(imaw, 'STRT', trim(keyword))
1015 end if
1016 !
1017 ! -- well name / boundname
1018 write (cno9, '(i9.9)') imaw
1019 this%cmawname(imaw) = 'MAWWELL'//cno9
1020 if (this%inamedbound /= 0) then
1021 text = boundname(n)
1022 if (trim(text) /= '') then
1023 this%cmawname(imaw) = trim(text)
1024 end if
1025 end if
1026 end do
1027 !
1028 ! -- check for duplicate or missing wells
1029 call this%report_ifno_coverage(nboundchk, this%nmawwells, 'well', &
1030 'PACKAGEDATA')
1031 deallocate (nboundchk)
1032 !
1033 write (this%iout, '(1x,a)') &
1034 'END OF '//trim(adjustl(this%text))//' PACKAGEDATA'
1035 !
1036 if (count_errors() > 0) then
1037 call store_error_filename(this%input_fname)
1038 end if
1039 !
1040 ! -- set iaconn and imap for each connection
1041 idx = 0
1042 this%iaconn(1) = 1
1043 do n = 1, this%nmawwells
1044 do jj = 1, this%ngwfnodes(n)
1045 idx = idx + 1
1046 this%imap(idx) = n
1047 end do
1048 this%iaconn(n + 1) = idx + 1
1049 end do
1050 !
1051 ! -- release input context packagedata memory;
1052 ! exclude STRT and PACKAGEDATA_IFNO
1053 call memorystore_release('RADIUS', this%input_mempath)
1054 call memorystore_release('BOTTOM', this%input_mempath)
1055 call memorystore_release('CONDEQN', this%input_mempath)
1056 call memorystore_release('NGWFNODES', this%input_mempath)
1057 call memorystore_release('BOUNDNAME', this%input_mempath)
1058 end subroutine maw_source_packagedata
1059
1060 !> @brief Source CONNECTIONDATA block from input context
1061 !<
1063 ! -- dummy
1064 class(mawtype), intent(inout) :: this
1065 ! -- local
1066 integer(I4B) :: n, nconn, imaw, iconn, ipos, jpos, j, jj
1067 integer(I4B) :: nn, nn2
1068 integer(I4B) :: ireset_scrntop, ireset_scrnbot, ireset_wellbot
1069 real(DP) :: rval, topnn, botnn, botw
1070 character(len=LINELENGTH) :: cellid_str
1071 character(len=30) :: nodestr
1072 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
1073 integer(I4B), dimension(:), pointer, contiguous :: icon => null()
1074 integer(I4B), dimension(:, :), pointer, contiguous :: cellid => null()
1075 real(DP), dimension(:), pointer, contiguous :: scrn_top => null()
1076 real(DP), dimension(:), pointer, contiguous :: scrn_bot => null()
1077 real(DP), dimension(:), pointer, contiguous :: hk_skin => null()
1078 real(DP), dimension(:), pointer, contiguous :: radius_skin => null()
1079 integer(I4B), allocatable :: iachk(:)
1080 integer(I4B), allocatable :: nboundchk(:)
1081 !
1082 ireset_scrntop = 0
1083 ireset_scrnbot = 0
1084 ireset_wellbot = 0
1085 !
1086 write (this%iout, '(/1x,a)') &
1087 'PROCESSING '//trim(adjustl(this%text))//' CONNECTIONDATA'
1088 !
1089 ! -- get input context CONNECTIONDATA columns
1090 call mem_setptr(ifno, 'CONNDATA_IFNO', this%input_mempath)
1091 call mem_setptr(icon, 'ICON', this%input_mempath)
1092 call mem_setptr(cellid, 'CELLID', this%input_mempath)
1093 call mem_setptr(scrn_top, 'SCRN_TOP', this%input_mempath)
1094 call mem_setptr(scrn_bot, 'SCRN_BOT', this%input_mempath)
1095 call mem_setptr(hk_skin, 'HK_SKIN', this%input_mempath)
1096 call mem_setptr(radius_skin, 'RADIUS_SKIN', this%input_mempath)
1097 !
1098 nconn = size(ifno)
1099 !
1100 ! -- allocate check arrays
1101 allocate (iachk(this%nmawwells + 1))
1102 iachk(1) = 1
1103 do n = 1, this%nmawwells
1104 iachk(n + 1) = iachk(n) + this%ngwfnodes(n)
1105 end do
1106 allocate (nboundchk(this%maxbound))
1107 nboundchk = 0
1108 !
1109 do n = 1, nconn
1110 imaw = ifno(n)
1111 iconn = icon(n)
1112 !
1113 ! -- check for error condition
1114 if (imaw < 1 .or. imaw > this%nmawwells) then
1115 write (errmsg, '(a,1x,i0,a)') &
1116 'IMAW must be greater than 0 and less than or equal to ', &
1117 this%nmawwells, '.'
1118 call store_error(errmsg)
1119 cycle
1120 end if
1121 if (iconn < 1 .or. iconn > this%ngwfnodes(imaw)) then
1122 write (errmsg, '(a,1x,i0,1x,a,1x,i0,a)') &
1123 'JCONN for well ', imaw, &
1124 'must be greater than 1 and less than or equal to ', &
1125 this%ngwfnodes(imaw), '.'
1126 call store_error(errmsg)
1127 cycle
1128 end if
1129 !
1130 ipos = iachk(imaw) + iconn - 1
1131 nboundchk(ipos) = nboundchk(ipos) + 1
1132 j = iconn
1133 jpos = this%get_jpos(imaw, iconn)
1134 !
1135 ! -- convert cellid integer array to string and get node number
1136 write (cellid_str, '(10(i0,1x))') cellid(1:this%dis%ndim, n)
1137 nn = this%dis%noder_from_cellid(cellid_str, this%inunit, this%iout)
1138 topnn = this%dis%top(nn)
1139 botnn = this%dis%bot(nn)
1140 botw = this%bot(imaw)
1141 !
1142 ! -- set gwf node number for connection
1143 this%gwfnodes(jpos) = nn
1144 !
1145 ! -- top of screen; retain user value before clipping for non-vertical SPECIFIED connections
1146 this%usrtopscrn(jpos) = scrn_top(n)
1147 rval = scrn_top(n)
1148 if (this%ieqn(imaw) /= 4) then
1149 rval = topnn
1150 else
1151 if (rval > topnn) then
1152 ireset_scrntop = ireset_scrntop + 1
1153 rval = topnn
1154 end if
1155 end if
1156 this%topscrn(jpos) = rval
1157 !
1158 ! -- bottom of screen; retain user value before clipping for non-vertical SPECIFIED connections
1159 this%usrbotscrn(jpos) = scrn_bot(n)
1160 rval = scrn_bot(n)
1161 if (this%ieqn(imaw) /= 4) then
1162 rval = botnn
1163 else
1164 if (rval < botnn) then
1165 ireset_scrnbot = ireset_scrnbot + 1
1166 rval = botnn
1167 end if
1168 end if
1169 this%botscrn(jpos) = rval
1170 !
1171 ! -- adjust the bottom of the well for all conductance approaches
1172 ! except for "mean"
1173 if (rval < botw) then
1174 if (this%ieqn(imaw) /= 4) then
1175 ireset_wellbot = ireset_wellbot + 1
1176 botw = rval
1177 this%bot(imaw) = rval
1178 else
1179 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,g0,a,g0,a)') &
1180 'Screen bottom for maw well', imaw, 'connection', j, '(', &
1181 this%botscrn(jpos), ') is less than the well bottom (', &
1182 this%bot(imaw), ').'
1183 call store_error(errmsg)
1184 end if
1185 end if
1186 !
1187 ! -- hydraulic conductivity or conductance
1188 rval = hk_skin(n)
1189 if (this%ieqn(imaw) == 0) then
1190 this%satcond(jpos) = rval
1191 else if (this%ieqn(imaw) == 2 .OR. this%ieqn(imaw) == 3 .OR. &
1192 this%ieqn(imaw) == 4) then
1193 this%hk(jpos) = rval
1194 end if
1195 !
1196 ! -- skin radius
1197 rval = radius_skin(n)
1198 if (this%ieqn(imaw) == 2 .OR. this%ieqn(imaw) == 3 .OR. &
1199 this%ieqn(imaw) == 4) then
1200 this%sradius(jpos) = rval
1201 if (this%sradius(jpos) <= this%radius(imaw)) then
1202 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,g0,a,g0,a)') &
1203 'Screen radius for maw well', imaw, 'connection', j, '(', &
1204 this%sradius(jpos), &
1205 ') is less than or equal to the well radius (', &
1206 this%radius(imaw), ').'
1207 call store_error(errmsg)
1208 end if
1209 end if
1210 end do
1211 !
1212 write (this%iout, '(1x,a)') &
1213 'END OF '//trim(adjustl(this%text))//' CONNECTIONDATA'
1214 !
1215 ! -- check for missing or duplicate connections
1216 ipos = 0
1217 do n = 1, this%nmawwells
1218 do j = 1, this%ngwfnodes(n)
1219 ipos = ipos + 1
1220 if (nboundchk(ipos) == 0) then
1221 write (errmsg, '(a,1x,i0,1x,a,1x,i0,a)') &
1222 'No data specified for maw well', n, 'connection', j, '.'
1223 call store_error(errmsg)
1224 else if (nboundchk(ipos) > 1) then
1225 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1226 'Data for maw well', n, 'connection', j, &
1227 'specified', nboundchk(ipos), 'times.'
1228 call store_error(errmsg)
1229 end if
1230 end do
1231 end do
1232 !
1233 ! -- make sure that more than one connection per cell is only specified
1234 ! for wells using the mean conductance type
1235 do n = 1, this%nmawwells
1236 if (this%ieqn(n) /= 4) then
1237 do j = 1, this%ngwfnodes(n)
1238 nn = this%get_gwfnode(n, j)
1239 do jj = 1, this%ngwfnodes(n)
1240 if (jj == j) cycle
1241 nn2 = this%get_gwfnode(n, jj)
1242 if (nn2 == nn) then
1243 call this%dis%noder_to_string(nn, nodestr)
1244 write (errmsg, '(a,1x,i0,1x,a,1x,i0,3(1x,a))') &
1245 'Only one connection can be specified for maw well', &
1246 n, 'connection', j, 'to gwf cell', trim(adjustl(nodestr)), &
1247 'unless the mean condeqn is specified.'
1248 call store_error(errmsg)
1249 end if
1250 end do
1251 end do
1252 end if
1253 end do
1254 !
1255 ! -- deallocate local storage
1256 deallocate (iachk)
1257 deallocate (nboundchk)
1258 !
1259 ! -- add warning messages
1260 if (ireset_scrntop > 0) then
1261 write (warnmsg, '(a,1x,a,1x,a,1x,i0,1x,a)') &
1262 'The screen tops in multi-aquifer well package', trim(this%packName), &
1263 'were reset to the top of the connected cell', ireset_scrntop, 'times.'
1265 end if
1266 if (ireset_scrnbot > 0) then
1267 write (warnmsg, '(a,1x,a,1x,a,1x,i0,1x,a)') &
1268 'The screen bottoms in multi-aquifer well package', trim(this%packName), &
1269 'were reset to the bottom of the connected cell', ireset_scrnbot, &
1270 'times.'
1272 end if
1273 if (ireset_wellbot > 0) then
1274 write (warnmsg, '(a,1x,a,1x,a,1x,i0,1x,a)') &
1275 'The well bottoms in multi-aquifer well package', trim(this%packName), &
1276 'were reset to the bottom of the connected cell', ireset_wellbot, &
1277 'times.'
1279 end if
1280 !
1281 if (count_errors() > 0) then
1282 call store_error_filename(this%input_fname)
1283 end if
1284 !
1285 ! -- release input context connectiondata memory
1286 call memorystore_release('CONNDATA_IFNO', this%input_mempath)
1287 call memorystore_release('ICON', this%input_mempath)
1288 call memorystore_release('CELLID', this%input_mempath)
1289 call memorystore_release('SCRN_TOP', this%input_mempath)
1290 call memorystore_release('SCRN_BOT', this%input_mempath)
1291 call memorystore_release('HK_SKIN', this%input_mempath)
1292 call memorystore_release('RADIUS_SKIN', this%input_mempath)
1293 end subroutine maw_source_connectiondata
1294
1295 !> @brief Source ANGLEDATA block from input context for non-vertical MAW connections
1296 !<
1297 subroutine maw_source_angledata(this)
1299 use mathutilmodule, only: is_close
1301 ! -- dummy
1302 class(mawtype), intent(inout) :: this
1303 ! -- local
1304 integer(I4B) :: n, imaw, iconn, jpos, ichk, nangle, node
1305 real(DP) :: angle, dz, omega, lw, topexp
1306 real(DP) :: hlen
1307 real(DP) :: extent
1308 character(len=LINELENGTH) :: cndmsg
1309 character(len=LINELENGTH) :: extmsg
1310 logical(LGP) :: estimated
1311 integer(I4B), dimension(:), pointer, contiguous :: angledata_ifno => null()
1312 integer(I4B), dimension(:), pointer, contiguous :: angledata_icon => null()
1313 real(DP), dimension(:), pointer, contiguous :: angle_arr => null()
1314 real(DP), dimension(:), pointer, contiguous :: connlen_arr => null()
1315 integer(I4B), allocatable :: iachk(:)
1316 integer(I4B), allocatable :: nboundchk(:)
1317 real(DP), parameter :: coszero = dem6
1318 real(DP), parameter :: dninety = 9.0d1
1319 !
1320 call get_isize('ANGLEDATA_IFNO', this%input_mempath, nangle)
1321 !
1322 if (nangle > 0) then
1323 !
1324 if (this%inonvert == 0) then
1325 call store_error('An ANGLEDATA block was specified but the '// &
1326 'NON_VERTICAL_WELLS option was not specified in the '// &
1327 'OPTIONS block.')
1328 call store_error_filename(this%input_fname)
1329 end if
1330 !
1331 call mem_setptr(angledata_ifno, 'ANGLEDATA_IFNO', this%input_mempath)
1332 call mem_setptr(angledata_icon, 'ANGLEDATA_ICON', this%input_mempath)
1333 call mem_setptr(angle_arr, 'ANGLE', this%input_mempath)
1334 call mem_setptr(connlen_arr, 'CONNLEN', this%input_mempath)
1335 !
1336 allocate (iachk(this%nmawwells + 1))
1337 iachk(1) = 1
1338 do n = 1, this%nmawwells
1339 iachk(n + 1) = iachk(n) + this%ngwfnodes(n)
1340 end do
1341 allocate (nboundchk(this%maxbound))
1342 nboundchk = 0
1343 !
1344 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text))// &
1345 ' ANGLEDATA'
1346 !
1347 do n = 1, nangle
1348 imaw = angledata_ifno(n)
1349 if (imaw < 1 .or. imaw > this%nmawwells) then
1350 write (errmsg, '(a,1x,i0,a)') &
1351 'IFNO must be greater than 0 and less than or equal to ', &
1352 this%nmawwells, '.'
1353 call store_error(errmsg)
1354 cycle
1355 end if
1356 !
1357 iconn = angledata_icon(n)
1358 if (iconn < 1 .or. iconn > this%ngwfnodes(imaw)) then
1359 write (errmsg, '(a,1x,i0,1x,a,1x,i0,a)') &
1360 'ICON for well ', imaw, &
1361 'must be greater than 0 and less than or equal to ', &
1362 this%ngwfnodes(imaw), '.'
1363 call store_error(errmsg)
1364 cycle
1365 end if
1366 jpos = this%get_jpos(imaw, iconn)
1367 !
1368 ichk = iachk(imaw) + iconn - 1
1369 nboundchk(ichk) = nboundchk(ichk) + 1
1370 if (nboundchk(ichk) > 1) then
1371 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1372 'ANGLEDATA for maw well', imaw, 'connection', iconn, &
1373 'is specified more than once.'
1374 call store_error(errmsg)
1375 end if
1376 !
1377 angle = angle_arr(n)
1378 this%angle(jpos) = angle
1379 if (connlen_arr(n) /= dnodata) then
1380 this%connlen(jpos) = max(connlen_arr(n), dzero)
1381 end if
1382 !
1383 if (angle < dzero .or. angle > dninety) then
1384 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,g0,a)') &
1385 'ANGLE for maw well', imaw, 'connection', iconn, '(', angle, &
1386 ') must be greater than or equal to 0.0 and less than or '// &
1387 'equal to 90.0 degrees.'
1388 call store_error(errmsg)
1389 cycle
1390 end if
1391 !
1392 node = this%get_gwfnode(imaw, iconn)
1393 !
1394 ! -- a SPECIFIED connection provides the saturated conductance directly,
1395 ! so the length correction is not applied; the user-specified screen
1396 ! elevations (which are otherwise reset to the cell top and bottom)
1397 ! are restored here, clamped to the cell, so the connection
1398 ! saturation is calculated over the correct interval. It is the
1399 ! user's responsibility to calculate the correct conductance.
1400 if (this%ieqn(imaw) == 0) then
1401 this%topscrn(jpos) = min(this%usrtopscrn(jpos), this%dis%top(node))
1402 this%botscrn(jpos) = max(this%usrbotscrn(jpos), this%dis%bot(node))
1403 end if
1404 !
1405 dz = this%topscrn(jpos) - this%botscrn(jpos)
1406 if (dz <= dzero) then
1407 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1408 'The screen top must be greater than the screen bottom for maw '// &
1409 'well', imaw, 'connection', iconn, 'listed in the ANGLEDATA block.'
1410 call store_error(errmsg)
1411 cycle
1412 end if
1413 !
1414 omega = angle * dpio180
1415 !
1416 ! -- the in-cell screen length is specified directly or derived from
1417 ! the screen elevations, well radius, and tilt angle; it cannot be
1418 ! derived for a (near) horizontal connection
1419 if (this%connlen(jpos) > dzero) then
1420 lw = this%connlen(jpos)
1421 else if (cos(omega) > coszero) then
1422 lw = maw_screen_length(dz, this%radius(imaw), omega)
1423 else
1424 lw = dzero
1425 end if
1426 !
1427 ! -- the in-cell screen length is used only by the conductance
1428 ! equations calculated by the program (it is not used by the
1429 ! SPECIFIED equation). For those equations a (near) horizontal
1430 ! connection requires a connection length, because the length cannot
1431 ! be derived from the screen elevations, and the calculated length
1432 ! must be positive.
1433 if (this%ieqn(imaw) /= 0) then
1434 if (cos(omega) <= coszero .and. this%connlen(jpos) <= dzero) then
1435 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1436 'A connection length must be specified for the (near) '// &
1437 'horizontal maw well', imaw, 'connection', iconn, &
1438 'listed in the ANGLEDATA block.'
1439 call store_error(errmsg)
1440 cycle
1441 end if
1442 if (lw <= dzero) then
1443 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,g0,a)') &
1444 'The calculated in-cell screen length for maw well', imaw, &
1445 'connection', iconn, '(', lw, &
1446 ') is not greater than zero. Specify a connection length in '// &
1447 'the ANGLEDATA block.'
1448 call store_error(errmsg)
1449 cycle
1450 end if
1451 end if
1452 !
1453 ! -- a connection spans a horizontal distance of lw * sin(omega), which
1454 ! cannot exceed the horizontal extent of the connected cell
1455 if (lw > dzero) then
1456 hlen = lw * sin(omega)
1457 extent = this%maw_cell_extent(node, estimated)
1458 if (hlen > extent) then
1459 !
1460 ! -- the extent is estimated from the cell area where the cell
1461 ! vertices are not defined
1462 if (estimated) then
1463 extmsg = 'estimated maximum horizontal extent'
1464 else
1465 extmsg = 'maximum horizontal extent'
1466 end if
1467 !
1468 ! -- the length correction is not applied to a SPECIFIED
1469 ! connection, so the conductance of one is not the program's
1470 ! to describe as too large
1471 if (this%ieqn(imaw) == 0) then
1472 cndmsg = 'The specified saturated conductance is applied to a '// &
1473 'screen that is longer than the cell.'
1474 else
1475 cndmsg = 'The calculated saturated conductance is '// &
1476 'correspondingly too large.'
1477 end if
1478 write (warnmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,g0,a,g0,a)') &
1479 'The horizontal distance spanned by maw well', imaw, &
1480 'connection', iconn, '(', hlen, &
1481 ') is greater than the '//trim(extmsg)//' of the '// &
1482 'connected cell (', extent, &
1483 '), so the screen extends beyond the cell it is connected '// &
1484 'to. '//trim(cndmsg)//' Reduce ANGLE or CONN_LENGTH, or '// &
1485 'specify a separate connection to each cell the connection '// &
1486 'passes through.'
1488 end if
1489 end if
1490 !
1491 ! -- the radial (THIEM, SKIN, and CUMULATIVE) conductance equations use
1492 ! the horizontal-plane flow geometry, so a (near) horizontal
1493 ! connection is an approximation; recommend the MEAN equation
1494 if (cos(omega) <= coszero .and. &
1495 this%ieqn(imaw) /= 4 .and. this%ieqn(imaw) /= 0) then
1496 write (warnmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1497 'The (near) horizontal maw well', imaw, 'connection', iconn, &
1498 'uses a radial conductance equation (THIEM, SKIN, or '// &
1499 'CUMULATIVE). The calculated conductance is an approximation '// &
1500 'for horizontal connections; the MEAN conductance equation is '// &
1501 'recommended for horizontal connections.'
1503 end if
1504 !
1505 if (cos(omega) <= coszero .and. &
1506 (this%ieqn(imaw) == 4 .or. this%ieqn(imaw) == 0)) then
1507 topexp = this%botscrn(jpos) + dtwo * this%radius(imaw)
1508 if (is_close(this%topscrn(jpos), topexp)) then
1509 this%topscrn(jpos) = topexp
1510 else
1511 write (warnmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,g0,a)') &
1512 'The vertical screen extent (SCRN_TOP - SCRN_BOT) for the '// &
1513 '(near) horizontal maw well', imaw, 'connection', iconn, &
1514 'is not equal to the well diameter (2 * RADIUS = ', &
1515 dtwo * this%radius(imaw), &
1516 '). The vertical screen extent is used to determine the '// &
1517 'saturation of a connection and should equal the well '// &
1518 'diameter for a horizontal connection.'
1520 end if
1521 end if
1522 end do
1523 !
1524 write (this%iout, '(1x,a)') &
1525 'END OF '//trim(adjustl(this%text))//' ANGLEDATA'
1526 !
1527 deallocate (iachk)
1528 deallocate (nboundchk)
1529 !
1530 call memorystore_release('ANGLEDATA_IFNO', this%input_mempath)
1531 call memorystore_release('ANGLEDATA_ICON', this%input_mempath)
1532 call memorystore_release('ANGLE', this%input_mempath)
1533 call memorystore_release('CONNLEN', this%input_mempath)
1534 else
1535 if (this%inonvert /= 0) then
1536 write (warnmsg, '(a)') &
1537 'The NON_VERTICAL_WELLS option was specified but an ANGLEDATA '// &
1538 'block was not found. All multi-aquifer well connections will be '// &
1539 'treated as vertical.'
1541 end if
1542 end if
1543 !
1544 if (count_errors() > 0) call store_error_filename(this%input_fname)
1545 end subroutine maw_source_angledata
1546
1547 !> @brief In-cell screen length of a non-vertical well connection
1548 !!
1549 !! The length is derived from the vertical screen extent, the well radius,
1550 !! and the tilt angle, and grows without bound as the connection approaches
1551 !! horizontal.
1552 !<
1553 pure function maw_screen_length(dz, radius, omega) result(lw)
1554 ! -- dummy
1555 real(dp), intent(in) :: dz !< vertical screen extent
1556 real(dp), intent(in) :: radius !< well radius
1557 real(dp), intent(in) :: omega !< tilt angle from vertical, in radians
1558 ! -- return
1559 real(dp) :: lw
1560 !
1561 lw = (dz - dtwo * radius * sin(omega)) / cos(omega)
1562 end function maw_screen_length
1563
1564 !> @brief Maximum horizontal extent of a cell
1565 !!
1566 !! The extent is the largest distance between two cell vertices where they
1567 !! are defined, and is estimated as the diagonal of a square with the same
1568 !! area where they are not.
1569 !<
1570 function maw_cell_extent(this, node, estimated) result(extent)
1571 use constantsmodule, only: dis, disv, disu, dtwo
1573 ! -- dummy
1574 class(mawtype), intent(inout) :: this
1575 integer(I4B), intent(in) :: node !< reduced node number of the connected cell
1576 logical(LGP), intent(out) :: estimated !< extent is estimated from the cell area
1577 ! -- return
1578 real(dp) :: extent
1579 ! -- local
1580 real(dp), allocatable, dimension(:, :) :: polyverts
1581 integer(I4B) :: nverts
1582 !
1583 ! -- the vertices are optional for a disu grid and are not defined for
1584 ! grids that have no cell polygons
1585 nverts = 0
1586 select case (this%dis%get_dis_enum())
1587 case (dis, disv, disu)
1588 nverts = this%dis%get_npolyverts(node)
1589 end select
1590 !
1591 estimated = nverts == 0
1592 if (estimated) then
1593 extent = sqrt(dtwo * this%dis%area(node))
1594 else
1595 call this%dis%get_polyverts(node, polyverts)
1596 extent = polygon_extent(polyverts(1, :), polyverts(2, :))
1597 deallocate (polyverts)
1598 end if
1599 end function maw_cell_extent
1600
1601 !> @brief Calculate the length correction factor for a multi-aquifer well
1602 !! connection
1603 !!
1604 !! The saturated conductance of a non-vertical (slanted) connection is scaled
1605 !! by the ratio of the in-cell screen length to the vertical screen thickness.
1606 !! The factor is 1.0 for vertical connections (angle = 0 and no connection
1607 !! length specified). The in-cell screen length is either specified directly
1608 !! (CONNLEN > 0) or derived from the screen elevations and the tilt angle,
1609 !! accounting for the vertical band occupied by the finite-radius borehole.
1610 !<
1611 function maw_calc_lcorr(this, i, jpos) result(lcorr)
1612 use constantsmodule, only: dzero, done, dtwo, dpio180
1613 ! -- dummy
1614 class(mawtype), intent(inout) :: this
1615 integer(I4B), intent(in) :: i !< well number
1616 integer(I4B), intent(in) :: jpos !< connection position
1617 ! -- return
1618 real(dp) :: lcorr
1619 ! -- local
1620 real(dp) :: dz
1621 real(dp) :: omega
1622 real(dp) :: lw
1623 !
1624 ! -- default to no correction (vertical connection)
1625 lcorr = done
1626 if (this%angle(jpos) == dzero .and. this%connlen(jpos) <= dzero) then
1627 return
1628 end if
1629 !
1630 ! -- vertical screen thickness
1631 dz = this%topscrn(jpos) - this%botscrn(jpos)
1632 if (dz <= dzero) then
1633 return
1634 end if
1635 !
1636 ! -- in-cell screen length: specified directly or derived from the screen
1637 ! elevations and the tilt angle
1638 if (this%connlen(jpos) > dzero) then
1639 lw = this%connlen(jpos)
1640 else
1641 omega = this%angle(jpos) * dpio180
1642 lw = maw_screen_length(dz, this%radius(i), omega)
1643 end if
1644 !
1645 lcorr = lw / dz
1646 end function maw_calc_lcorr
1647
1648 !> @brief Read the initial parameters for this package
1649 !<
1650 subroutine maw_read_initial_attr(this)
1651 ! -- modules
1652 use constantsmodule, only: linelength
1654 ! -- dummy
1655 class(mawtype), intent(inout) :: this
1656 ! -- local
1657 character(len=LINELENGTH) :: title
1658 character(len=LINELENGTH) :: text
1659 integer(I4B) :: ntabcols
1660 integer(I4B) :: j
1661 integer(I4B) :: n
1662 integer(I4B) :: nn
1663 integer(I4B) :: jpos
1664 integer(I4B) :: inode
1665 integer(I4B) :: idx
1666 real(DP) :: k11
1667 real(DP) :: k22
1668 character(len=10), dimension(0:4) :: ccond
1669 character(len=30) :: nodestr
1670 ! -- data
1671 data ccond(0)/'SPECIFIED '/
1672 data ccond(1)/'THIEM '/
1673 data ccond(2)/'SKIN '/
1674 data ccond(3)/'CUMULATIVE'/
1675 data ccond(4)/'MEAN '/
1676 ! -- format
1677 character(len=*), parameter :: fmtwelln = &
1678 "(1X,//43X,'MULTI-AQUIFER WELL DATA'&
1679 &/1X,109('-'),&
1680 &/1X,7(A10,1X),A16)"
1681 character(len=*), parameter :: fmtwelld = &
1682 &"(1X,I10,1X,4(G10.3,1X),I10,1X,A10,1X,A16)"
1683 character(len=*), parameter :: fmtline = &
1684 &"(1X,119('-'),//)"
1685 character(len=*), parameter :: fmtwellcn = &
1686 "(1X,//37X,'MULTI-AQUIFER WELL CONNECTION DATA'&
1687 &/1X,119('-'),&
1688 &/1X,2(A10,1X),A20,7(A10,1X))"
1689 character(len=*), parameter :: fmtwellcd = &
1690 &"(1X,2(I10,1X),A20,1X,2(G10.3,1X),2(A10,1X),3(G10.3,1X))"
1691 !
1692 ! -- initialize xnewpak
1693 do n = 1, this%nmawwells
1694 this%xnewpak(n) = this%strt(n)
1695 this%xsto(n) = this%strt(n)
1696 end do
1697 !
1698 ! -- initialize status (iboundpak) of maw wells to active
1699 do n = 1, this%nmawwells
1700 select case (this%status(n))
1701 case ('CONSTANT')
1702 this%iboundpak(n) = -1
1703 case ('INACTIVE')
1704 this%iboundpak(n) = 0
1705 case ('ACTIVE')
1706 this%iboundpak(n) = 1
1707 end select
1708 end do
1709 !
1710 ! -- set imap and boundname for each connection
1711 if (this%inamedbound /= 0) then
1712 idx = 0
1713 do n = 1, this%nmawwells
1714 do j = 1, this%ngwfnodes(n)
1715 idx = idx + 1
1716 this%boundname(idx) = this%cmawname(n)
1717 this%imap(idx) = n
1718 end do
1719 end do
1720 else
1721 do n = 1, this%nmawwells
1722 this%cmawname(n) = ''
1723 end do
1724 end if
1725 !
1726 ! -- copy boundname into boundname_cst
1727 call this%copy_boundname()
1728 !
1729 ! -- set pointer to gwf iss and gwf hk
1730 call mem_setptr(this%gwfiss, 'ISS', create_mem_path(this%name_model))
1731 call mem_setptr(this%gwfk11, 'K11', create_mem_path(this%name_model, 'NPF'))
1732 call mem_setptr(this%gwfk22, 'K22', create_mem_path(this%name_model, 'NPF'))
1733 call mem_setptr(this%gwfik22, 'IK22', create_mem_path(this%name_model, 'NPF'))
1734 call mem_setptr(this%gwfsat, 'SAT', create_mem_path(this%name_model, 'NPF'))
1735 !
1736 ! -- qa data
1737 call this%maw_check_attributes()
1738 !
1739 ! -- Calculate the saturated conductance
1740 do n = 1, this%nmawwells
1741 !
1742 ! -- calculate saturated conductance only if CONDUCTANCE was not
1743 ! specified for each maw-gwf connection (CONDUCTANCE keyword).
1744 do j = 1, this%ngwfnodes(n)
1745 if (this%ieqn(n) /= 0) then
1746 inode = this%get_gwfnode(n, j)
1747 call this%maw_calculate_satcond(n, j, inode)
1748 end if
1749 end do
1750 end do
1751 !
1752 ! -- write summary of static well data
1753 ! -- write well data
1754 if (this%iprpak /= 0) then
1755 ntabcols = 7
1756 if (this%inamedbound /= 0) then
1757 ntabcols = ntabcols + 1
1758 end if
1759 title = trim(adjustl(this%text))//' PACKAGE ('// &
1760 trim(adjustl(this%packName))//') STATIC WELL DATA'
1761 call table_cr(this%inputtab, this%packName, title)
1762 call this%inputtab%table_df(this%nmawwells, ntabcols, this%iout)
1763 text = 'NUMBER'
1764 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1765 text = 'RADIUS'
1766 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1767 text = 'AREA'
1768 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1769 text = 'WELL BOTTOM'
1770 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1771 text = 'STARTING HEAD'
1772 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1773 text = 'NUMBER OF GWF NODES'
1774 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1775 text = 'CONDUCT. EQUATION'
1776 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1777 if (this%inamedbound /= 0) then
1778 text = 'NAME'
1779 call this%inputtab%initialize_column(text, 20, alignment=tableft)
1780 end if
1781 do n = 1, this%nmawwells
1782 call this%inputtab%add_term(n)
1783 call this%inputtab%add_term(this%radius(n))
1784 call this%inputtab%add_term(this%area(n))
1785 call this%inputtab%add_term(this%bot(n))
1786 call this%inputtab%add_term(this%strt(n))
1787 call this%inputtab%add_term(this%ngwfnodes(n))
1788 call this%inputtab%add_term(ccond(this%ieqn(n)))
1789 if (this%inamedbound /= 0) then
1790 call this%inputtab%add_term(this%cmawname(n))
1791 end if
1792 end do
1793 end if
1794 !
1795 ! -- write well connection data
1796 if (this%iprpak /= 0) then
1797 ntabcols = 10
1798 if (this%inonvert /= 0) then
1799 ntabcols = ntabcols + 1
1800 end if
1801 title = trim(adjustl(this%text))//' PACKAGE ('// &
1802 trim(adjustl(this%packName))//') STATIC WELL CONNECTION DATA'
1803 call table_cr(this%inputtab, this%packName, title)
1804 call this%inputtab%table_df(this%maxbound, ntabcols, this%iout)
1805 text = 'NUMBER'
1806 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1807 text = 'WELL CONNECTION'
1808 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1809 text = 'CELLID'
1810 call this%inputtab%initialize_column(text, 20, alignment=tableft)
1811 text = 'TOP OF SCREEN'
1812 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1813 text = 'BOTTOM OF SCREEN'
1814 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1815 text = 'SKIN RADIUS'
1816 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1817 text = 'SKIN K'
1818 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1819 text = 'K11'
1820 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1821 text = 'K22'
1822 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1823 text = 'SATURATED WELL CONDUCT.'
1824 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1825 if (this%inonvert /= 0) then
1826 text = 'ANGLE (DEG)'
1827 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1828 end if
1829 !
1830 ! -- write the data to the table
1831 do n = 1, this%nmawwells
1832 do j = 1, this%ngwfnodes(n)
1833 call this%inputtab%add_term(n)
1834 call this%inputtab%add_term(j)
1835 jpos = this%get_jpos(n, j)
1836 nn = this%get_gwfnode(n, j)
1837 call this%dis%noder_to_string(nn, nodestr)
1838 call this%inputtab%add_term(nodestr)
1839 call this%inputtab%add_term(this%topscrn(jpos))
1840 call this%inputtab%add_term(this%botscrn(jpos))
1841 if (this%ieqn(n) == 2 .or. &
1842 this%ieqn(n) == 3 .or. &
1843 this%ieqn(n) == 4) then
1844 call this%inputtab%add_term(this%sradius(jpos))
1845 call this%inputtab%add_term(this%hk(jpos))
1846 else
1847 call this%inputtab%add_term(' ')
1848 call this%inputtab%add_term(' ')
1849 end if
1850 if (this%ieqn(n) == 1 .or. &
1851 this%ieqn(n) == 2 .or. &
1852 this%ieqn(n) == 3) then
1853 k11 = this%gwfk11(nn)
1854 if (this%gwfik22 == 0) then
1855 k22 = this%gwfk11(nn)
1856 else
1857 k22 = this%gwfk22(nn)
1858 end if
1859 call this%inputtab%add_term(k11)
1860 call this%inputtab%add_term(k22)
1861 else
1862 call this%inputtab%add_term(' ')
1863 call this%inputtab%add_term(' ')
1864 end if
1865 call this%inputtab%add_term(this%satcond(jpos))
1866 if (this%inonvert /= 0) then
1867 call this%inputtab%add_term(this%angle(jpos))
1868 end if
1869 end do
1870 end do
1871 end if
1872 !
1873 ! -- finished with pointer to gwf hydraulic conductivity
1874 this%gwfk11 => null()
1875 this%gwfk22 => null()
1876 this%gwfik22 => null()
1877 this%gwfsat => null()
1878 !
1879 ! -- check for any error conditions
1880 if (count_errors() > 0) then
1881 call store_error_filename(this%input_fname)
1882 end if
1883 end subroutine maw_read_initial_attr
1884
1885 !> @brief Issue a parameter error for mawweslls(imaw)
1886 !<
1887 subroutine maw_set_attribute_error(this, imaw, keyword, msg)
1888 use simmodule, only: store_error
1889 ! -- dummy
1890 class(mawtype), intent(inout) :: this
1891 integer(I4B), intent(in) :: imaw
1892 character(len=*), intent(in) :: keyword
1893 character(len=*), intent(in) :: msg
1894 ! -- local
1895 ! -- formats
1896 !
1897 if (len(msg) == 0) then
1898 write (errmsg, '(a,1x,a,1x,i0,1x,a)') &
1899 keyword, ' for MAW well', imaw, 'has already been set.'
1900 else
1901 write (errmsg, '(a,1x,a,1x,i0,1x,a)') &
1902 keyword, ' for MAW well', imaw, msg
1903 end if
1904 call store_error(errmsg)
1905 end subroutine maw_set_attribute_error
1906
1907 !> @brief Apply a PERIOD setting value to well imaw
1908 !!
1909 !! Shared by maw_rp (once per period) and maw_ad (per-timestep resync of
1910 !! TS-linked settings); validation stays with the caller.
1911 !<
1912 subroutine maw_set_period_value(this, n, imaw, setting)
1913 ! -- dummy
1914 class(mawtype), intent(inout) :: this
1915 integer(I4B), intent(in) :: n !< row index into input context arrays
1916 integer(I4B), intent(in) :: imaw !< well number
1917 character(len=*), intent(in) :: setting !< uppercase tagname dispatch key
1918 !
1919 select case (trim(setting))
1920 case ('WELL_HEAD')
1921 this%well_head_set(imaw) = .true.
1922 this%xnewpak(imaw) = this%well_head(imaw)
1923 end select
1924 end subroutine maw_set_period_value
1925
1926 !> @brief Issue parameter errors for mawwells(imaw)
1927 !<
1928 subroutine maw_check_attributes(this)
1929 use simmodule, only: store_error
1930 ! -- dummy
1931 class(mawtype), intent(inout) :: this
1932 ! -- local
1933 character(len=LINELENGTH) :: cgwfnode
1934 integer(I4B) :: idx
1935 integer(I4B) :: n
1936 integer(I4B) :: j
1937 integer(I4B) :: jpos
1938 ! -- formats
1939 !
1940 idx = 1
1941 do n = 1, this%nmawwells
1942 if (this%ngwfnodes(n) < 1) then
1943 call this%maw_set_attribute_error(n, 'NGWFNODES', 'must be greater '// &
1944 'than 0.')
1945 end if
1946 if (this%radius(n) == dep20) then
1947 call this%maw_set_attribute_error(n, 'RADIUS', 'has not been specified.')
1948 end if
1949 if (this%shutoffmin(n) > dzero) then
1950 if (this%shutoffmin(n) >= this%shutoffmax(n)) then
1951 call this%maw_set_attribute_error(n, 'SHUT_OFF', 'shutoffmax must '// &
1952 'be greater than shutoffmin.')
1953 end if
1954 end if
1955 do j = 1, this%ngwfnodes(n)
1956 !
1957 ! -- calculate jpos
1958 jpos = this%get_jpos(n, j)
1959 !
1960 ! -- write gwfnode number
1961 write (cgwfnode, '(a,i0,a)') 'gwfnode(', j, ')'
1962 !
1963 ! -- connection screen data
1964 if (this%botscrn(jpos) >= this%topscrn(jpos)) then
1965 call this%maw_set_attribute_error(n, 'SCREEN_TOP', 'screen bottom '// &
1966 'must be less than screen top. '// &
1967 trim(cgwfnode))
1968 end if
1969 !
1970 ! -- connection skin hydraulic conductivity
1971 if (this%ieqn(n) == 2 .OR. this%ieqn(n) == 3 .OR. &
1972 this%ieqn(n) == 4) then
1973 if (this%hk(jpos) <= dzero) then
1974 call this%maw_set_attribute_error(n, 'HK_SKIN', 'skin hyraulic '// &
1975 'conductivity must be greater '// &
1976 'than zero. '//trim(cgwfnode))
1977 end if
1978 else if (this%ieqn(n) == 0) then
1979 !
1980 ! -- saturated conductance
1981 if (this%satcond(jpos) < dzero) then
1982 call this%maw_set_attribute_error(n, 'HK_SKIN', &
1983 'skin hyraulic conductivity '// &
1984 'must be greater than or '// &
1985 'equal to zero when using '// &
1986 'SPECIFIED condeqn. '// &
1987 trim(cgwfnode))
1988 end if
1989 end if
1990 idx = idx + 1
1991 end do
1992 end do
1993 ! -- reset check_attr
1994 this%check_attr = 0
1995 end subroutine maw_check_attributes
1996
1997 !> @brief Add package connection to matrix
1998 !<
1999 subroutine maw_ac(this, moffset, sparse)
2000 use sparsemodule, only: sparsematrix
2001 ! -- dummy
2002 class(mawtype), intent(inout) :: this
2003 integer(I4B), intent(in) :: moffset
2004 type(sparsematrix), intent(inout) :: sparse
2005 ! -- local
2006 integer(I4B) :: j
2007 integer(I4B) :: n
2008 integer(I4B) :: jj
2009 integer(I4B) :: jglo
2010 integer(I4B) :: nglo
2011 ! -- format
2012 !
2013 ! -- Add package rows to sparse
2014 do n = 1, this%nmawwells
2015 nglo = moffset + this%dis%nodes + this%ioffset + n
2016 call sparse%addconnection(nglo, nglo, 1)
2017 do j = 1, this%ngwfnodes(n)
2018 jj = this%get_gwfnode(n, j)
2019 jglo = jj + moffset
2020 call sparse%addconnection(nglo, jglo, 1)
2021 call sparse%addconnection(jglo, nglo, 1)
2022 end do
2023
2024 end do
2025 end subroutine maw_ac
2026
2027 !> @brief Map package connection to matrix
2028 !<
2029 subroutine maw_mc(this, moffset, matrix_sln)
2030 use sparsemodule, only: sparsematrix
2032 ! -- dummy
2033 class(mawtype), intent(inout) :: this
2034 integer(I4B), intent(in) :: moffset
2035 class(matrixbasetype), pointer :: matrix_sln
2036 ! -- local
2037 integer(I4B) :: n
2038 integer(I4B) :: j
2039 integer(I4B) :: ii
2040 integer(I4B) :: iglo
2041 integer(I4B) :: jglo
2042 integer(I4B) :: ipos
2043 ! -- format
2044 !
2045 ! -- allocate connection mapping vectors
2046 call mem_allocate(this%idxlocnode, this%nmawwells, 'IDXLOCNODE', &
2047 this%memoryPath)
2048 call mem_allocate(this%idxdglo, this%maxbound, 'IDXDGLO', this%memoryPath)
2049 call mem_allocate(this%idxoffdglo, this%maxbound, 'IDXOFFDGLO', &
2050 this%memoryPath)
2051 call mem_allocate(this%idxsymdglo, this%maxbound, 'IDXSYMDGLO', &
2052 this%memoryPath)
2053 call mem_allocate(this%idxsymoffdglo, this%maxbound, 'IDXSYMOFFDGLO', &
2054 this%memoryPath)
2055 !
2056 ! -- Find the position of each connection in the global ia, ja structure
2057 ! and store them in idxglo. idxglo allows this model to insert or
2058 ! retrieve values into or from the global A matrix
2059 ! -- maw rows
2060 ipos = 1
2061 do n = 1, this%nmawwells
2062 iglo = moffset + this%dis%nodes + this%ioffset + n
2063 this%idxlocnode(n) = this%dis%nodes + this%ioffset + n
2064 do ii = 1, this%ngwfnodes(n)
2065 j = this%get_gwfnode(n, ii)
2066 jglo = j + moffset
2067 this%idxdglo(ipos) = matrix_sln%get_position_diag(iglo)
2068 this%idxoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
2069 ipos = ipos + 1
2070 end do
2071 end do
2072 ! -- maw contributions gwf portion of global matrix
2073 ipos = 1
2074 do n = 1, this%nmawwells
2075 do ii = 1, this%ngwfnodes(n)
2076 iglo = this%get_gwfnode(n, ii) + moffset
2077 jglo = moffset + this%dis%nodes + this%ioffset + n
2078 this%idxsymdglo(ipos) = matrix_sln%get_position_diag(iglo)
2079 this%idxsymoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
2080 ipos = ipos + 1
2081 end do
2082 end do
2083 end subroutine maw_mc
2084
2085 !> @brief Allocate and Read
2086 !!
2087 !! Create new MAW package and point bndobj to the new package
2088 !<
2089 subroutine maw_ar(this)
2090 ! -- dummy
2091 class(mawtype), intent(inout) :: this
2092 ! -- local
2093 ! -- format
2094 !
2095 call this%obs%obs_ar()
2096 !
2097 ! -- set omega value used for saturation calculations
2098 if (this%inewton > 0) then
2099 this%satomega = dem6
2100 end if
2101 !
2102 ! -- Allocate connection arrays in MAW and in package superclass
2103 call this%maw_allocate_arrays()
2104 !
2105 ! -- read optional initial package parameters
2106 call this%read_initial_attr()
2107 !
2108 ! -- bind persistent pointers to input context data
2109 call this%input%init(this%input_mempath, this%naux)
2110 !
2111 ! -- setup pakmvrobj
2112 if (this%imover /= 0) then
2113 allocate (this%pakmvrobj)
2114 call this%pakmvrobj%ar(this%nmawwells, this%nmawwells, this%memoryPath)
2115 end if
2116 end subroutine maw_ar
2117
2118 !> @brief Read and Prepare
2119 !!
2120 !! Read itmp and new boundaries if itmp > 0
2121 !<
2122 subroutine maw_rp(this)
2123 use constantsmodule, only: lenvarname
2124 use tdismodule, only: kper
2128 ! -- dummy
2129 class(mawtype), intent(inout) :: this
2130 ! -- local
2131 character(len=LINELENGTH) :: title
2132 character(len=LINELENGTH) :: text
2133 character(len=LINELENGTH) :: csteady
2134 character(len=LINELENGTH) :: str
2135 real(DP) :: auxvaldbl
2136 character(len=LENVARNAME) :: setting
2137 character(len=LINELENGTH) :: cstr
2138 character(len=LINELENGTH) :: errmsgr
2139 integer(I4B) :: node
2140 integer(I4B) :: n
2141 integer(I4B) :: ntabcols
2142 integer(I4B) :: ntabrows
2143 integer(I4B) :: imaw
2144 integer(I4B) :: ibnd
2145 integer(I4B) :: j
2146 integer(I4B) :: jpos
2147 integer(I4B) :: jj
2148 integer(I4B) :: nactive
2149 integer(I4B) :: icon
2150 integer(I4B), dimension(:), allocatable :: ibotset
2151 integer(I4B), dimension(:), allocatable :: iheadset
2152 integer(I4B), dimension(:), allocatable :: ilimset
2153 integer(I4B) :: istat
2154 integer(I4B) :: iheadlimit_warning
2155 ! -- formats
2156 character(len=*), parameter :: fmtlsp = &
2157 &"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
2158 character(len=*), parameter :: fmthdbot = &
2159 &"('well head (',G0,') must be >= BOTTOM_ELEVATION (',G0, ').')"
2160 !
2161 ! -- initialize counters
2162 iheadlimit_warning = 0
2163 !
2164 ! -- set steady-state flag based on gwfiss
2165 this%imawiss = this%gwfiss
2166 !
2167 ! -- reset maw steady flag if 'STEADY-STATE' specified in the OPTIONS block
2168 if (this%imawissopt == 1) then
2169 this%imawiss = 1
2170 end if
2171 !
2172 ! -- set nbound to maxbound
2173 this%nbound = this%maxbound
2174 !
2175 ! -- check if input context has been updated for this stress period
2176 if (this%iper == kper) then
2177 !
2178 ! -- setup table to echo period data
2179 if (this%iprpak /= 0) then
2180 title = trim(adjustl(this%text))//' PACKAGE ('// &
2181 trim(adjustl(this%packName))//') DATA FOR PERIOD'
2182 write (title, '(a,1x,i6)') trim(adjustl(title)), kper
2183 call table_cr(this%inputtab, this%packName, title)
2184 call this%inputtab%table_df(1, 5, this%iout, finalize=.false.)
2185 text = 'NUMBER'
2186 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
2187 text = 'KEYWORD'
2188 call this%inputtab%initialize_column(text, 20, alignment=tableft)
2189 do jj = 1, 3
2190 write (text, '(a,1x,i6)') 'VALUE', jj
2191 call this%inputtab%initialize_column(text, 15, alignment=tabcenter)
2192 end do
2193 end if
2194 !
2195 ! -- set flag to check attributes
2196 this%check_attr = 1
2197 ! -- wells with BOTTOM, WELL_HEAD, or HEAD_LIMIT set this period, which
2198 ! are checked after all of the period's settings are applied
2199 allocate (ibotset(this%nmawwells))
2200 allocate (iheadset(this%nmawwells))
2201 allocate (ilimset(this%nmawwells))
2202 do imaw = 1, this%nmawwells
2203 ibotset(imaw) = 0
2204 iheadset(imaw) = 0
2205 ilimset(imaw) = 0
2206 end do
2207 !
2208 do n = 1, this%input%nbound
2209 imaw = this%input%ifno(n)
2210 if (imaw < 1 .or. imaw > this%nmawwells) then
2211 write (errmsg, '(2(a,1x),i0,a)') &
2212 'IMAW must be greater than 0 and', &
2213 'less than or equal to ', this%nmawwells, '.'
2214 call store_error(errmsg)
2215 cycle
2216 end if
2217 !
2218 ! -- dispatch key for this row
2219 setting = this%input%setting(n)
2220 !
2221 ! -- STATUS
2222 if (trim(setting) == 'STATUS') then
2223 str = this%input%status(n)
2224 this%status(imaw) = str(1:8)
2225 select case (trim(str))
2226 case ('CONSTANT')
2227 this%iboundpak(imaw) = -1
2228 case ('INACTIVE')
2229 this%iboundpak(imaw) = 0
2230 case ('ACTIVE')
2231 this%iboundpak(imaw) = 1
2232 case default
2233 write (errmsg, '(2a)') &
2234 'Unknown '//trim(this%text)//" maw status keyword: '", &
2235 trim(str)//"'."
2236 call store_error(errmsg)
2237 end select
2238 end if
2239 !
2240 ! -- CONNECTION_STATUS (compound group)
2241 if (trim(setting) == 'CONN_STATUS') then
2242 icon = this%input%period_icon(n)
2243 str = this%input%connstatus(n)
2244 if (icon < 1 .or. icon > this%ngwfnodes(imaw)) then
2245 write (errmsg, '(2(a,1x),i0,1x,a,1x,i0,a)') &
2246 'ICON must be greater than 0 and', &
2247 'less than or equal to ', this%ngwfnodes(imaw), &
2248 'for maw well', imaw, '.'
2249 call store_error(errmsg)
2250 else
2251 jpos = this%get_jpos(imaw, icon)
2252 select case (trim(str))
2253 case ('INACTIVE')
2254 this%iboundconn(jpos) = 0
2255 case ('ACTIVE')
2256 this%iboundconn(jpos) = 1
2257 case default
2258 write (errmsg, '(2a)') &
2259 'Unknown '//trim(this%text)//" maw connection status "// &
2260 "keyword: '", trim(str)//"'."
2261 call store_error(errmsg)
2262 end select
2263 end if
2264 end if
2265 !
2266 ! -- BOTTOM
2267 if (trim(setting) == 'PERIOD_BOTTOM') then
2268 this%bot(imaw) = this%input%period_bottom(n)
2269 ibotset(imaw) = 1
2270 end if
2271 !
2272 ! -- RATE / WELL_HEAD
2273 call this%maw_set_period_value(n, imaw, setting)
2274 !
2275 ! -- WELL_HEAD
2276 if (trim(setting) == 'WELL_HEAD') then
2277 iheadset(imaw) = 1
2278 end if
2279 !
2280 ! -- HEAD_LIMIT
2281 if (trim(setting) == 'HEAD_LIMIT') then
2282 str = this%input%head_limit(n)
2283 if (trim(str) == 'OFF') then
2284 this%shutofflevel(imaw) = dep20
2285 else
2286 read (str, *, iostat=istat, iomsg=errmsgr) &
2287 this%shutofflevel(imaw)
2288 if (istat /= 0) then
2289 errmsg = 'Could not read HEAD_LIMIT value. '//trim(errmsgr)
2290 call store_error(errmsg)
2291 end if
2292 end if
2293 ilimset(imaw) = 1
2294 end if
2295 !
2296 ! -- FLOWING_WELL (compound group)
2297 if (trim(setting) == 'FLOWING_WELL') then
2298 this%fwelev(imaw) = this%input%fwelev(n)
2299 this%fwcond(imaw) = this%input%fwcond(n)
2300 this%fwrlen(imaw) = this%input%fwrlen(n)
2301 if (this%iflowingwells == 0) then
2302 this%iflowingwells = -1
2303 text = 'Flowing well data is specified in the '// &
2304 trim(this%packName)//' package but FLOWING_WELL was'// &
2305 ' not specified in the OPTIONS block.'
2306 call store_warning(text)
2307 end if
2308 end if
2309 !
2310 ! -- SHUT_OFF (compound group)
2311 if (trim(setting) == 'SHUT_OFF') then
2312 this%shutoffmin(imaw) = this%input%minrate(n)
2313 this%shutoffmax(imaw) = this%input%maxrate(n)
2314 end if
2315 !
2316 ! -- RATE_SCALING (compound group)
2317 if (trim(setting) == 'RATE_SCALING') then
2318 this%pumpelev(imaw) = this%input%pump_elevation(n)
2319 this%reduction_length(imaw) = this%input%scaling_length(n)
2320 if (this%reduction_length(imaw) < dzero) then
2321 call this%maw_set_attribute_error(imaw, 'RATE_SCALING', &
2322 &'must be greater than or equal to 0.')
2323 end if
2324 end if
2325 !
2326 ! -- AUXILIARY (compound group); the current value is already set --
2327 ! -- only extract auxname here for echoing this period's row below
2328 if (this%naux > 0) then
2329 if (trim(setting) == 'PERIOD_AUXILIARY') then
2330 str = this%input%auxname(n)
2331 auxvaldbl = this%input%auxval(n)
2332 end if
2333 end if
2334 !
2335 ! -- echo row to period data table
2336 if (this%iprpak /= 0) then
2337 call this%inputtab%add_term(imaw)
2338 if (trim(setting) == 'PERIOD_AUXILIARY') then
2339 call this%inputtab%add_term('AUXILIARY')
2340 else
2341 call this%inputtab%add_term(trim(setting))
2342 end if
2343 select case (trim(setting))
2344 case ('STATUS')
2345 call this%inputtab%add_term(trim(str))
2346 call this%inputtab%add_term(' ')
2347 call this%inputtab%add_term(' ')
2348 case ('CONN_STATUS')
2349 call this%inputtab%add_term(icon)
2350 call this%inputtab%add_term(trim(str))
2351 call this%inputtab%add_term(' ')
2352 case ('PERIOD_BOTTOM')
2353 call this%inputtab%add_term(this%bot(imaw))
2354 call this%inputtab%add_term(' ')
2355 call this%inputtab%add_term(' ')
2356 case ('RATE')
2357 call this%inputtab%add_term(this%rate(imaw))
2358 call this%inputtab%add_term(' ')
2359 call this%inputtab%add_term(' ')
2360 case ('WELL_HEAD')
2361 call this%inputtab%add_term(this%well_head(imaw))
2362 call this%inputtab%add_term(' ')
2363 call this%inputtab%add_term(' ')
2364 case ('HEAD_LIMIT')
2365 call this%inputtab%add_term(trim(str))
2366 call this%inputtab%add_term(' ')
2367 call this%inputtab%add_term(' ')
2368 case ('FLOWING_WELL')
2369 call this%inputtab%add_term(this%fwelev(imaw))
2370 call this%inputtab%add_term(this%fwcond(imaw))
2371 call this%inputtab%add_term(this%fwrlen(imaw))
2372 case ('SHUT_OFF')
2373 call this%inputtab%add_term(this%shutoffmin(imaw))
2374 call this%inputtab%add_term(this%shutoffmax(imaw))
2375 call this%inputtab%add_term(' ')
2376 case ('RATE_SCALING')
2377 call this%inputtab%add_term(this%pumpelev(imaw))
2378 call this%inputtab%add_term(this%reduction_length(imaw))
2379 call this%inputtab%add_term(' ')
2380 case ('PERIOD_AUXILIARY')
2381 call this%inputtab%add_term(trim(str))
2382 call this%inputtab%add_term(auxvaldbl)
2383 call this%inputtab%add_term(' ')
2384 case default
2385 call this%inputtab%add_term(' ')
2386 call this%inputtab%add_term(' ')
2387 call this%inputtab%add_term(' ')
2388 end select
2389 end if
2390 end do
2391 if (this%iprpak /= 0) then
2392 call this%inputtab%finalize_table()
2393 end if
2394 !
2395 ! -- the well bottom, the datum for well storage, may not be above the
2396 ! head of an ACTIVE well or the screen bottom of an active connection;
2397 ! a CONSTANT well is checked against its well head, and the head of an
2398 ! INACTIVE well is not current
2399 do imaw = 1, this%nmawwells
2400 if (ibotset(imaw) /= 0 .and. this%iboundpak(imaw) > 0) then
2401 if (this%bot(imaw) > this%xnewpak(imaw)) then
2402 write (cstr, fmthdbot) this%xnewpak(imaw), this%bot(imaw)
2403 call this%maw_set_attribute_error(imaw, 'BOTTOM', trim(cstr))
2404 end if
2405 end if
2406 do jj = 1, this%ngwfnodes(imaw)
2407 jpos = this%get_jpos(imaw, jj)
2408 if (this%iboundconn(jpos) == 0) cycle
2409 if (this%bot(imaw) > this%botscrn(jpos)) then
2410 write (errmsg, '(a,g0,a,1x,i0,1x,a,1x,i0,1x,a,g0,a)') &
2411 'BOTTOM (', this%bot(imaw), ') for maw well', imaw, &
2412 'is above the screen bottom of active connection', jj, '(', &
2413 this%botscrn(jpos), ').'
2414 call store_error(errmsg)
2415 exit
2416 end if
2417 end do
2418 if (iheadset(imaw) /= 0 .or. this%iboundpak(imaw) < 0) then
2419 if (this%well_head(imaw) < this%bot(imaw)) then
2420 write (cstr, fmthdbot) this%well_head(imaw), this%bot(imaw)
2421 call this%maw_set_attribute_error(imaw, 'WELL HEAD', trim(cstr))
2422 end if
2423 end if
2424 if (ibotset(imaw) /= 0 .or. ilimset(imaw) /= 0) then
2425 if (this%shutofflevel(imaw) <= this%bot(imaw)) then
2426 iheadlimit_warning = iheadlimit_warning + 1
2427 end if
2428 end if
2429 end do
2430 deallocate (ibotset)
2431 deallocate (iheadset)
2432 deallocate (ilimset)
2433 !
2434 ! -- a well must keep at least one active connection; STATUS INACTIVE,
2435 ! not CONNECTION_STATUS, is used to deactivate every connection
2436 do imaw = 1, this%nmawwells
2437 nactive = 0
2438 do jj = 1, this%ngwfnodes(imaw)
2439 jpos = this%get_jpos(imaw, jj)
2440 if (this%iboundconn(jpos) /= 0) nactive = nactive + 1
2441 end do
2442 if (nactive == 0) then
2443 write (errmsg, '(a,1x,i0,1x,a)') &
2444 'Every connection of maw well', imaw, 'is inactive. Use '// &
2445 'STATUS INACTIVE to deactivate all connections of a well.'
2446 call store_error(errmsg)
2447 end if
2448 end do
2449 !
2450 ! -- using data from the last stress period
2451 else
2452 write (this%iout, fmtlsp) trim(this%filtyp)
2453 end if
2454 !
2455 ! -- issue warning messages
2456 if (iheadlimit_warning > 0) then
2457 write (warnmsg, '(a,a,a,1x,a,1x,a)') &
2458 "HEAD_LIMIT in '", trim(this%packName), "' was below the well bottom", &
2459 "for one or more multi-aquifer well(s). This may result in", &
2460 "convergence failures for some models."
2461 call store_warning(warnmsg, substring=warnmsg(:50))
2462 end if
2463 !
2464 ! -- write summary of maw well stress period error messages
2465 if (count_errors() > 0) then
2466 call store_error_filename(this%input_fname)
2467 end if
2468 !
2469 ! -- qa data if necessary
2470 if (this%check_attr /= 0) then
2471 call this%maw_check_attributes()
2472
2473 ! -- write summary of stress period data for MAW
2474 if (this%iprpak == 1) then
2475 if (this%imawiss /= 0) then
2476 csteady = 'STEADY-STATE '
2477 else
2478 csteady = 'TRANSIENT '
2479 end if
2480 !
2481 ! -- reset the input table object for rate data
2482 title = trim(adjustl(this%text))//' PACKAGE ('// &
2483 trim(adjustl(this%packName))//') '//trim(adjustl(csteady))// &
2484 ' RATE DATA FOR PERIOD'
2485 write (title, '(a,1x,i6)') trim(adjustl(title)), kper
2486 ntabcols = 6
2487 call table_cr(this%inputtab, this%packName, title)
2488 call this%inputtab%table_df(this%nmawwells, ntabcols, this%iout)
2489 text = 'NUMBER'
2490 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
2491 text = 'STATUS'
2492 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2493 text = 'RATE'
2494 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2495 text = 'SPECIFIED HEAD'
2496 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2497 text = 'PUMP ELEVATION'
2498 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2499 text = 'REDUCTION LENGTH'
2500 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2501 do n = 1, this%nmawwells
2502 call this%inputtab%add_term(n)
2503 call this%inputtab%add_term(this%status(n))
2504 call this%inputtab%add_term(this%rate(n))
2505 if (this%iboundpak(n) < 0) then
2506 call this%inputtab%add_term(this%well_head(n))
2507 else
2508 call this%inputtab%add_term(' ')
2509 end if
2510 call this%inputtab%add_term(this%pumpelev(n))
2511 if (this%reduction_length(n) /= dep20) then
2512 call this%inputtab%add_term(this%reduction_length(n))
2513 else
2514 call this%inputtab%add_term(' ')
2515 end if
2516 end do
2517 !
2518 ! -- flowing wells
2519 if (this%iflowingwells > 0) then
2520 !
2521 ! -- reset the input table object for flowing well data
2522 title = trim(adjustl(this%text))//' PACKAGE ('// &
2523 trim(adjustl(this%packName))//') '//trim(adjustl(csteady))// &
2524 ' FLOWING WELL DATA FOR PERIOD'
2525 write (title, '(a,1x,i6)') trim(adjustl(title)), kper
2526 ntabcols = 4
2527 ntabrows = 0
2528 do n = 1, this%nmawwells
2529 if (this%fwcond(n) > dzero) then
2530 ntabrows = ntabrows + 1
2531 end if
2532 end do
2533 if (ntabrows > 0) then
2534 call table_cr(this%inputtab, this%packName, title)
2535 call this%inputtab%table_df(ntabrows, ntabcols, this%iout)
2536 text = 'NUMBER'
2537 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
2538 text = 'ELEVATION'
2539 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2540 text = 'CONDUCT.'
2541 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2542 text = 'REDUCTION LENGTH'
2543 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2544 do n = 1, this%nmawwells
2545 if (this%fwcond(n) > dzero) then
2546 call this%inputtab%add_term(n)
2547 call this%inputtab%add_term(this%fwelev(n))
2548 call this%inputtab%add_term(this%fwcond(n))
2549 call this%inputtab%add_term(this%fwrlen(n))
2550 end if
2551 end do
2552 end if
2553 end if
2554 !
2555 ! -- reset the input table object for shutoff data
2556 title = trim(adjustl(this%text))//' PACKAGE ('// &
2557 trim(adjustl(this%packName))//') '//trim(adjustl(csteady))// &
2558 ' WELL SHUTOFF DATA FOR PERIOD'
2559 write (title, '(a,1x,i6)') trim(adjustl(title)), kper
2560 ntabcols = 4
2561 ntabrows = 0
2562 do n = 1, this%nmawwells
2563 if (this%shutofflevel(n) /= dep20) then
2564 ntabrows = ntabrows + 1
2565 end if
2566 end do
2567 if (ntabrows > 0) then
2568 call table_cr(this%inputtab, this%packName, title)
2569 call this%inputtab%table_df(ntabrows, ntabcols, this%iout)
2570 text = 'NUMBER'
2571 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
2572 text = 'ELEVATION'
2573 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2574 text = 'MINIMUM. Q'
2575 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2576 text = 'MAXIMUM Q'
2577 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
2578 do n = 1, this%nmawwells
2579 if (this%shutofflevel(n) /= dep20) then
2580 call this%inputtab%add_term(n)
2581 call this%inputtab%add_term(this%shutofflevel(n))
2582 call this%inputtab%add_term(this%shutoffmin(n))
2583 call this%inputtab%add_term(this%shutoffmax(n))
2584 end if
2585 end do
2586 end if
2587 end if
2588 end if
2589 !
2590 ! -- fill arrays
2591 ibnd = 1
2592 do n = 1, this%nmawwells
2593 do j = 1, this%ngwfnodes(n)
2594 jpos = this%get_jpos(n, j)
2595 node = this%get_gwfnode(n, j)
2596 this%nodelist(ibnd) = node
2597 this%bound(1, ibnd) = this%xnewpak(n)
2598 this%bound(2, ibnd) = this%satcond(jpos)
2599 this%bound(3, ibnd) = this%botscrn(jpos)
2600 if (this%iboundpak(n) > 0) then
2601 this%bound(4, ibnd) = this%rate(n)
2602 else
2603 this%bound(4, ibnd) = dzero
2604 end if
2605 ibnd = ibnd + 1
2606 end do
2607 end do
2608 end subroutine maw_rp
2609
2610 !> @brief Add package connection to matrix
2611 !<
2612 subroutine maw_ad(this)
2613 use constantsmodule, only: lenvarname
2614 use tdismodule, only: kper, kstp
2615 ! -- dummy
2616 class(mawtype) :: this
2617 ! -- local
2618 integer(I4B) :: i
2619 integer(I4B) :: n
2620 integer(I4B) :: j
2621 integer(I4B) :: jj
2622 integer(I4B) :: ibnd
2623 integer(I4B) :: imaw
2624 character(len=LENVARNAME) :: setting
2625 !
2626 ! -- sync PACKAGEDATA AUX TS and advance observations;
2627 ! -- step auxvar period block overrides
2628 call this%BndExtType%bnd_ad()
2629 !
2630 ! -- sync PERIOD TS from input context
2631 if (this%ts_active .and. this%input%nbound > 0) then
2632 do n = 1, this%input%nbound
2633 imaw = this%input%ifno(n)
2634 if (imaw < 1 .or. imaw > this%nmawwells) cycle
2635 setting = this%input%setting(n)
2636 call this%maw_set_period_value(n, imaw, setting)
2637 end do
2638 end if
2639 !
2640 ! -- update auxiliary variables
2641 if (this%naux > 0) then
2642 ibnd = 1
2643 do n = 1, this%nmawwells
2644 do j = 1, this%ngwfnodes(n)
2645 do jj = 1, this%naux
2646 if (this%noupdateauxvar(jj) /= 0) cycle
2647 this%auxvar(jj, ibnd) = this%featureauxvar(jj, n)
2648 end do
2649 ibnd = ibnd + 1
2650 end do
2651 end do
2652 end if
2653 !
2654 ! -- copy xnew into xold; CONSTANT well heads track a PACKAGEDATA STRT
2655 ! time series until a PERIOD WELL_HEAD entry overrides it
2656 do i = 1, this%nmawwells
2657 n = this%pkg_ifno(i)
2658 this%xoldpak(n) = this%xnewpak(n)
2659 this%xoldsto(n) = this%xsto(n)
2660 if (this%iboundpak(n) < 0) then
2661 if (.not. this%well_head_set(n) .and. &
2662 this%input%strt_tslink(i) /= 0) then
2663 this%well_head(n) = this%input%strt(i)
2664 end if
2665 this%xnewpak(n) = this%well_head(n)
2666 end if
2667 !
2668 ! -- start each time step with damping turned off. Clearing the weight
2669 ! and the previous head change stops a leftover value from the last
2670 ! time step from triggering damping on the first iteration.
2671 this%nurdxold(n) = dzero
2672 this%nurweight(n) = done
2673 end do
2674 !
2675 !--use the appropriate xoldsto if initial heads are above the
2676 ! specified flowing well discharge elevation
2677 if (kper == 1 .and. kstp == 1) then
2678 do n = 1, this%nmawwells
2679 if (this%fwcond(n) > dzero) then
2680 if (this%xoldsto(n) > this%fwelev(n)) then
2681 this%xoldsto(n) = this%fwelev(n)
2682 end if
2683 end if
2684 end do
2685 end if
2686 !
2687 ! -- reset ishutoffcnt (equivalent to kiter) to zero
2688 this%ishutoffcnt = 0
2689 !
2690 ! -- pakmvrobj ad
2691 if (this%imover == 1) then
2692 call this%pakmvrobj%ad()
2693 end if
2694 end subroutine maw_ad
2695
2696 !> @brief Formulate the HCOF and RHS terms
2697 !!
2698 !! Skip if no multi-aquifer wells, otherwise, calculate hcof and rhs
2699 !<
2700 subroutine maw_cf(this)
2701 ! -- dummy
2702 class(mawtype) :: this
2703 ! -- local
2704 !
2705 ! -- Calculate maw conductance and update package RHS and HCOF
2706 call this%maw_cfupdate()
2707 end subroutine maw_cf
2708
2709 !> @brief Copy rhs and hcof into solution rhs and amat
2710 !<
2711 subroutine maw_fc(this, rhs, ia, idxglo, matrix_sln)
2712 ! -- modules
2713 use tdismodule, only: delt
2714 ! -- dummy
2715 class(mawtype) :: this
2716 real(DP), dimension(:), intent(inout) :: rhs
2717 integer(I4B), dimension(:), intent(in) :: ia
2718 integer(I4B), dimension(:), intent(in) :: idxglo
2719 class(matrixbasetype), pointer :: matrix_sln
2720 ! -- local
2721 integer(I4B) :: j
2722 integer(I4B) :: n
2723 integer(I4B) :: idx
2724 integer(I4B) :: iloc
2725 integer(I4B) :: isymloc
2726 integer(I4B) :: igwfnode
2727 integer(I4B) :: iposd
2728 integer(I4B) :: iposoffd
2729 integer(I4B) :: isymnode
2730 integer(I4B) :: ipossymd
2731 integer(I4B) :: ipossymoffd
2732 integer(I4B) :: jpos
2733 integer(I4B) :: icflow
2734 real(DP) :: hmaw
2735 real(DP) :: hgwf
2736 real(DP) :: cfw
2737 real(DP) :: cmaw
2738 real(DP) :: cterm
2739 real(DP) :: term
2740 real(DP) :: scale
2741 real(DP) :: tp
2742 real(DP) :: bt
2743 real(DP) :: rate
2744 real(DP) :: ratefw
2745 real(DP) :: flow
2746 real(DP) :: tled
2747 real(DP) :: sd
2748 real(DP) :: ss
2749 real(DP) :: ssold
2750 !
2751 ! -- pakmvrobj fc
2752 if (this%imover == 1) then
2753 call this%pakmvrobj%fc()
2754 end if
2755 !
2756 ! -- Copy package rhs and hcof into solution rhs and amat
2757 idx = 1
2758 do n = 1, this%nmawwells
2759 iloc = this%idxlocnode(n)
2760 !
2761 ! -- save the well rate from the previous outer iteration before it is
2762 ! recalculated below, for the rate convergence check in maw_cc
2763 this%qsim0(n) = this%ratesim(n)
2764 !
2765 ! -- update head value for constant head maw wells
2766 if (this%iboundpak(n) < 0) then
2767 this%xnewpak(n) = this%well_head(n)
2768 end if
2769 hmaw = this%xnewpak(n)
2770 !
2771 ! -- add pumping rate to active or constant maw well
2772 if (this%iboundpak(n) == 0) then
2773 this%ratesim(n) = dzero
2774 else
2775 call this%maw_calculate_wellq(n, hmaw, rate)
2776 this%ratesim(n) = rate
2777 rhs(iloc) = rhs(iloc) - rate
2778 !
2779 ! -- location of diagonal for maw row
2780 iposd = this%idxdglo(idx)
2781 !
2782 ! -- add flowing well
2783 this%xsto(n) = hmaw
2784 ratefw = dzero
2785 if (this%iflowingwells > 0) then
2786 if (this%fwcond(n) > dzero) then
2787 bt = this%fwelev(n)
2788 tp = bt + this%fwrlen(n)
2789 scale = sqsaturation(tp, bt, hmaw)
2790 cfw = scale * this%fwcond(n)
2791 this%ifwdischarge(n) = 0
2792 if (cfw > dzero) then
2793 this%ifwdischarge(n) = 1
2794 this%xsto(n) = bt
2795 end if
2796 this%fwcondsim(n) = cfw
2797 call matrix_sln%add_value_pos(iposd, -cfw)
2798 rhs(iloc) = rhs(iloc) - cfw * bt
2799 ratefw = cfw * (bt - hmaw)
2800 end if
2801 end if
2802 !
2803 ! -- add maw storage changes
2804 if (this%imawiss /= 1) then
2805 if (this%ifwdischarge(n) /= 1) then
2806 ! -- well storage. The storage water level is not allowed to drop
2807 ! below the bottom of the well: ss is a smooth version of
2808 ! max(hmaw, well bottom). The storage release then fades out as
2809 ! the well empties instead of drawing water from below the well
2810 ! bottom. While the head is above the bottom this is the original
2811 ! term (sd = 1, ss = hmaw, giving -area/delt).
2812 tled = this%area(n) / delt
2813 sd = squadratic0spderivative(hmaw, this%bot(n), this%satomega)
2814 ss = squadratic0sp(hmaw, this%bot(n), this%satomega)
2815 ssold = squadratic0sp(this%xoldsto(n), this%bot(n), this%satomega)
2816 call matrix_sln%add_value_pos(iposd, -tled * sd)
2817 rhs(iloc) = rhs(iloc) - tled * (sd * hmaw - ss + ssold)
2818 else
2819 cterm = this%xoldsto(n) - this%fwelev(n)
2820 rhs(iloc) = rhs(iloc) - (this%area(n) * cterm / delt)
2821 end if
2822 end if
2823 !
2824 ! -- If mover is active, add receiver water to rhs and
2825 ! store available water (as positive value)
2826 if (this%imover == 1) then
2827 rhs(iloc) = rhs(iloc) - this%pakmvrobj%get_qfrommvr(n)
2828 !
2829 ! -- add pumping rate to mover if not injection
2830 if (rate < 0) then
2831 call this%pakmvrobj%accumulate_qformvr(n, -rate) !pumped water
2832 end if
2833 !
2834 ! -- add flowing well flow to mover
2835 call this%pakmvrobj%accumulate_qformvr(n, -ratefw) !flowing water
2836 end if
2837 !
2838 end if
2839 !
2840 ! -- process each maw/gwf connection
2841 do j = 1, this%ngwfnodes(n)
2842 jpos = this%get_jpos(n, j)
2843 if (this%iboundpak(n) /= 0 .and. this%iboundconn(jpos) /= 0) then
2844 igwfnode = this%get_gwfnode(n, j)
2845 hgwf = this%xnew(igwfnode)
2846 !
2847 ! -- calculate connection terms
2848 call this%maw_calculate_conn_terms(n, j, icflow, cmaw, cterm, term, &
2849 flow)
2850 this%simcond(jpos) = cmaw
2851 !
2852 ! -- add to maw row
2853 iposd = this%idxdglo(idx)
2854 iposoffd = this%idxoffdglo(idx)
2855 call matrix_sln%add_value_pos(iposd, -term)
2856 call matrix_sln%set_value_pos(iposoffd, term)
2857 !
2858 ! -- add correction term
2859 rhs(iloc) = rhs(iloc) - cterm
2860 !
2861 ! -- add to gwf row for maw connection
2862 isymnode = this%get_gwfnode(n, j)
2863 isymloc = ia(isymnode)
2864 ipossymd = this%idxsymdglo(idx)
2865 ipossymoffd = this%idxsymoffdglo(idx)
2866 call matrix_sln%add_value_pos(ipossymd, -term)
2867 call matrix_sln%set_value_pos(ipossymoffd, term)
2868 !
2869 ! -- add correction term to gwf row
2870 rhs(isymnode) = rhs(isymnode) + cterm
2871 end if
2872 !
2873 ! -- increment maw connection counter
2874 idx = idx + 1
2875 end do
2876 end do
2877 end subroutine maw_fc
2878
2879 !> @brief Fill newton terms
2880 !<
2881 subroutine maw_fn(this, rhs, ia, idxglo, matrix_sln)
2882 ! -- dummy
2883 class(mawtype) :: this
2884 real(DP), dimension(:), intent(inout) :: rhs
2885 integer(I4B), dimension(:), intent(in) :: ia
2886 integer(I4B), dimension(:), intent(in) :: idxglo
2887 class(matrixbasetype), pointer :: matrix_sln
2888 ! -- local
2889 integer(I4B) :: j
2890 integer(I4B) :: n
2891 integer(I4B) :: idx
2892 integer(I4B) :: iloc
2893 integer(I4B) :: isymloc
2894 integer(I4B) :: igwfnode
2895 integer(I4B) :: iposd
2896 integer(I4B) :: iposoffd
2897 integer(I4B) :: isymnode
2898 integer(I4B) :: ipossymd
2899 integer(I4B) :: ipossymoffd
2900 integer(I4B) :: jpos
2901 integer(I4B) :: icflow
2902 real(DP) :: hmaw
2903 real(DP) :: hgwf
2904 real(DP) :: scale
2905 real(DP) :: tp
2906 real(DP) :: bt
2907 real(DP) :: cfw
2908 real(DP) :: rate
2909 real(DP) :: rate2
2910 real(DP) :: rterm
2911 real(DP) :: derv
2912 real(DP) :: drterm
2913 real(DP) :: cmaw
2914 real(DP) :: cterm
2915 real(DP) :: term
2916 real(DP) :: flow
2917 real(DP) :: term2
2918 real(DP) :: rhsterm
2919 !
2920 ! -- Calculate Newton-Raphson corrections
2921 idx = 1
2922 do n = 1, this%nmawwells
2923 iloc = this%idxlocnode(n)
2924 hmaw = this%xnewpak(n)
2925 !
2926 ! -- add pumping rate to active or constant maw well
2927 if (this%iboundpak(n) /= 0) then
2928 iposd = this%idxdglo(idx)
2929 scale = done
2930 drterm = dzero
2931 rate = this%ratesim(n)
2932 !
2933 !-- calculate final derivative for pumping rate
2934 call this%maw_calculate_wellq(n, hmaw + dem4, rate2)
2935 drterm = (rate2 - rate) / dem4
2936 !
2937 !-- fill amat and rhs with newton-raphson terms
2938 call matrix_sln%add_value_pos(iposd, drterm)
2939 rhs(iloc) = rhs(iloc) + drterm * hmaw
2940 !
2941 ! -- add flowing well
2942 if (this%iflowingwells > 0) then
2943 if (this%fwcond(n) > dzero) then
2944 bt = this%fwelev(n)
2945 tp = bt + this%fwrlen(n)
2946 scale = sqsaturation(tp, bt, hmaw)
2947 cfw = scale * this%fwcond(n)
2948 this%ifwdischarge(n) = 0
2949 if (cfw > dzero) then
2950 this%ifwdischarge(n) = 1
2951 end if
2952 this%fwcondsim(n) = cfw
2953 rate = cfw * (bt - hmaw)
2954 rterm = -cfw * hmaw
2955 !
2956 ! --calculate derivative for flowing well
2957 if (hmaw < tp) then
2958 derv = sqsaturationderivative(tp, bt, hmaw)
2959 drterm = -(cfw + this%fwcond(n) * derv * (hmaw - bt))
2960 !
2961 ! -- fill amat and rhs with newton-raphson terms
2962 call matrix_sln%add_value_pos(iposd, &
2963 -this%fwcond(n) * derv * (hmaw - bt))
2964 rhs(iloc) = rhs(iloc) - rterm + drterm * hmaw
2965 end if
2966 end if
2967 end if
2968 end if
2969 !
2970 ! -- process each maw/gwf connection
2971 do j = 1, this%ngwfnodes(n)
2972 jpos = this%get_jpos(n, j)
2973 if (this%iboundpak(n) /= 0 .and. this%iboundconn(jpos) /= 0) then
2974 igwfnode = this%get_gwfnode(n, j)
2975 hgwf = this%xnew(igwfnode)
2976 !
2977 ! -- add to maw row
2978 iposd = this%idxdglo(idx)
2979 iposoffd = this%idxoffdglo(idx)
2980 !
2981 ! -- add to gwf row for maw connection
2982 isymnode = this%get_gwfnode(n, j)
2983 isymloc = ia(isymnode)
2984 ipossymd = this%idxsymdglo(idx)
2985 ipossymoffd = this%idxsymoffdglo(idx)
2986 !
2987 ! -- calculate newton terms
2988 call this%maw_calculate_conn_terms(n, j, icflow, cmaw, cterm, term, &
2989 flow, term2)
2990 !
2991 ! -- maw is upstream
2992 if (hmaw > hgwf) then
2993 if (icflow /= 0) then
2994 rhsterm = term2 * hgwf + term * hmaw
2995 rhs(iloc) = rhs(iloc) + rhsterm
2996 rhs(isymnode) = rhs(isymnode) - rhsterm
2997 if (this%iboundpak(n) > 0) then
2998 call matrix_sln%add_value_pos(iposd, term)
2999 call matrix_sln%add_value_pos(iposoffd, term2)
3000 end if
3001 call matrix_sln%add_value_pos(ipossymd, -term2)
3002 call matrix_sln%add_value_pos(ipossymoffd, -term)
3003 else
3004 rhs(iloc) = rhs(iloc) + term * hmaw
3005 rhs(isymnode) = rhs(isymnode) - term * hmaw
3006 call matrix_sln%add_value_pos(iposd, term)
3007 if (this%ibound(igwfnode) > 0) then
3008 call matrix_sln%add_value_pos(ipossymoffd, -term)
3009 end if
3010 end if
3011 !
3012 ! -- gwf is upstream
3013 else
3014 if (icflow /= 0) then
3015 rhsterm = term2 * hmaw + term * hgwf
3016 rhs(iloc) = rhs(iloc) + rhsterm
3017 rhs(isymnode) = rhs(isymnode) - rhsterm
3018 if (this%iboundpak(n) > 0) then
3019 call matrix_sln%add_value_pos(iposd, term2)
3020 call matrix_sln%add_value_pos(iposoffd, term)
3021 end if
3022 call matrix_sln%add_value_pos(ipossymd, -term)
3023 call matrix_sln%add_value_pos(ipossymoffd, -term2)
3024 else
3025 rhs(iloc) = rhs(iloc) + term * hgwf
3026 rhs(isymnode) = rhs(isymnode) - term * hgwf
3027 if (this%iboundpak(n) > 0) then
3028 call matrix_sln%add_value_pos(iposoffd, term)
3029 end if
3030 call matrix_sln%add_value_pos(ipossymd, -term)
3031 end if
3032 end if
3033 end if
3034 !
3035 ! -- increment maw connection counter
3036 idx = idx + 1
3037 end do
3038 end do
3039 end subroutine maw_fn
3040
3041 !> @brief Apply Newton under-relaxation to the MAW Package well heads.
3042 !!
3043 !! Two corrections are applied to each well head, in order:
3044 !! 1. Oscillation damping. If the well head change reverses direction and is
3045 !! not getting smaller, it is cut back by a per-well weight. The weight
3046 !! shrinks while the head oscillates and grows back when the head moves
3047 !! steadily in one direction. This settles poorly connected wells (for
3048 !! example a low-K cell or a single connection) whose full Newton step is
3049 !! too large.
3050 !! 2. Bottom limit. If the head is still below the well bottom, it is moved
3051 !! back up toward the well bottom (the original behavior).
3052 !<
3053 subroutine maw_nur(this, neqpak, x, xtemp, dx, inewtonur, dxmax, locmax)
3054 ! -- dummy
3055 class(mawtype), intent(inout) :: this
3056 integer(I4B), intent(in) :: neqpak
3057 real(DP), dimension(neqpak), intent(inout) :: x
3058 real(DP), dimension(neqpak), intent(in) :: xtemp
3059 real(DP), dimension(neqpak), intent(inout) :: dx
3060 integer(I4B), intent(inout) :: inewtonur
3061 real(DP), intent(inout) :: dxmax
3062 integer(I4B), intent(inout) :: locmax
3063 ! -- local
3064 integer(I4B) :: n
3065 real(DP) :: botw
3066 real(DP) :: xx
3067 real(DP) :: dxx
3068 real(DP) :: dxprop
3069 real(DP) :: weight
3070 ! -- parameters
3071 real(DP), parameter :: damptheta = dp7 !factor the weight is cut by when the head oscillates
3072 real(DP), parameter :: damptol = dhalf !only damp if the change is at least this fraction of the last one
3073 real(DP), parameter :: weightmin = dem2 !smallest allowed weight
3074 real(DP), parameter :: recover = 0.2_dp !amount the weight grows back each iteration
3075 !
3076 ! -- Newton-Raphson under-relaxation
3077 do n = 1, this%nmawwells
3078 if (this%iboundpak(n) < 1) cycle
3079 botw = this%bot(n)
3080 !
3081 ! -- full Newton head change proposed for this outer iteration
3082 dxprop = x(n) - xtemp(n)
3083 !
3084 ! -- oscillation damping. Cut the weight only when the head change flips
3085 ! direction and is not already shrinking on its own (it is still at
3086 ! least damptol times the previous change). Otherwise let the weight
3087 ! grow back toward one, so a normal, converging well is not slowed
3088 ! down. This catches oscillations above the well bottom, which the
3089 ! bottom limit below cannot.
3090 weight = maw_damp_weight(dxprop, this%nurdxold(n), this%nurweight(n), &
3091 damptheta, damptol, weightmin, recover)
3092 this%nurweight(n) = weight
3093 !
3094 ! -- apply the reduced step when damping is turned on
3095 if (weight < done) then
3096 inewtonur = 1
3097 xx = xtemp(n) + weight * dxprop
3098 dxx = x(n) - xx
3099 if (abs(dxx) > abs(dxmax)) then
3100 locmax = n
3101 dxmax = dxx
3102 end if
3103 x(n) = xx
3104 dx(n) = weight * dxprop
3105 end if
3106 !
3107 ! -- bottom limit: if the (reduced) head is still below the bottom of the
3108 ! well, move it back up toward the well bottom
3109 if (x(n) < botw) then
3110 inewtonur = 1
3111 xx = xtemp(n) * (done - dp9) + botw * dp9
3112 dxx = x(n) - xx
3113 if (abs(dxx) > abs(dxmax)) then
3114 locmax = n
3115 dxmax = dxx
3116 end if
3117 x(n) = xx
3118 dx(n) = dzero
3119 end if
3120 !
3121 ! -- save the head change actually applied this iteration (after damping
3122 ! and the bottom limit). Saving it after the bottom limit lets the
3123 ! next iteration see the downward push from the limit, so the upward
3124 ! swing that follows can be damped.
3125 this%nurdxold(n) = x(n) - xtemp(n)
3126 end do
3127 end subroutine maw_nur
3128
3129 !> @brief Update the oscillation-damping weight for a single MAW well head.
3130 !!
3131 !! This is the decision used by maw_nur. The weight is cut back (multiplied by
3132 !! damptheta, but never below weightmin) only when the proposed head change
3133 !! reversed direction and is not already getting smaller (its size is at least
3134 !! damptol times the previous change). Otherwise the weight grows back toward
3135 !! one by recover. It is a pure function so the logic can be unit tested.
3136 !<
3137 pure function maw_damp_weight(dxprop, dxold, weight, damptheta, damptol, &
3138 weightmin, recover) result(new_weight)
3139 ! -- dummy
3140 real(dp), intent(in) :: dxprop !proposed well head change this outer iteration
3141 real(dp), intent(in) :: dxold !well head change applied last outer iteration
3142 real(dp), intent(in) :: weight !current damping weight
3143 real(dp), intent(in) :: damptheta !factor the weight is cut by when oscillating
3144 real(dp), intent(in) :: damptol !smallest |dxprop|/|dxold| ratio that is damped
3145 real(dp), intent(in) :: weightmin !smallest allowed weight
3146 real(dp), intent(in) :: recover !amount the weight grows back each iteration
3147 ! -- return
3148 real(dp) :: new_weight
3149 !
3150 if (dxprop * dxold < dzero .and. abs(dxprop) > damptol * abs(dxold)) then
3151 new_weight = max(damptheta * weight, weightmin)
3152 else
3153 new_weight = min(weight + recover, done)
3154 end if
3155 end function maw_damp_weight
3156
3157 !> @brief Extra convergence check for the MAW package.
3158 !!
3159 !! This does two things:
3160 !! 1. While a well is being damped by Newton under-relaxation, it keeps the
3161 !! model from converging until the well rate has also stopped changing
3162 !! (reported through dpak). Wells that are not being damped, and models
3163 !! that do not use Newton under-relaxation, are not affected.
3164 !! 2. When the model fails to converge, it warns about any pumping well that
3165 !! is asking for more water than the aquifer can supply, a likely reason
3166 !! for the failure.
3167 !<
3168 subroutine maw_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
3169 ! -- modules
3170 use tdismodule, only: delt
3171 ! -- dummy
3172 class(mawtype), intent(inout) :: this
3173 integer(I4B), intent(in) :: innertot
3174 integer(I4B), intent(in) :: kiter
3175 integer(I4B), intent(in) :: iend
3176 integer(I4B), intent(in) :: icnvgmod
3177 character(len=LENPAKLOC), intent(inout) :: cpak
3178 integer(I4B), intent(inout) :: ipak
3179 real(DP), intent(inout) :: dpak
3180 ! -- local
3181 integer(I4B) :: n
3182 integer(I4B) :: j
3183 integer(I4B) :: jpos
3184 integer(I4B) :: igwfnode
3185 integer(I4B) :: locdpak
3186 real(DP) :: botw
3187 real(DP) :: bmaw
3188 real(DP) :: hgwf
3189 real(DP) :: hv
3190 real(DP) :: sat
3191 real(DP) :: cmaw
3192 real(DP) :: qmax
3193 real(DP) :: qreq
3194 real(DP) :: qtolfact
3195 real(DP) :: dq
3196 real(DP) :: dpakmax
3197 character(len=LENPAKLOC) :: cloc
3198 ! -- parameters
3199 real(DP), parameter :: qtol = 1.001_dp !the request must exceed supply by this factor to warn
3200 ! -- formats
3201 character(len=*), parameter :: fmtwarn = &
3202 "('MAW well ', a, ' requests an extraction rate (', g0.5, &
3203 &') larger than the maximum rate (', g0.5, ') the aquifer can supply &
3204 &with the well head at its bottom. This may be preventing convergence. &
3205 &Consider reducing the requested rate, applying or widening RATE_SCALING, &
3206 &or reviewing the connection conductance (e.g. aquifer K).')"
3207 !
3208 ! -- rate convergence check. While a well is being damped (nurweight < 1)
3209 ! its head barely moves, so also require the well rate to stop changing
3210 ! before the model is allowed to converge. The rate change is turned
3211 ! into an equivalent head change (using the well area and time step) so
3212 ! it can be compared with the solver tolerance, and is passed back in
3213 ! dpak. Wells that are not being damped are left unchanged.
3214 dpakmax = dzero
3215 locdpak = 0
3216 do n = 1, this%nmawwells
3217 if (this%iboundpak(n) < 1) cycle
3218 if (this%nurweight(n) >= done) cycle
3219 if (this%area(n) > dzero) then
3220 qtolfact = delt / this%area(n)
3221 else
3222 qtolfact = dzero
3223 end if
3224 ! -- qsim0 and ratesim both come from maw_fc (before the solve), so dq is
3225 ! the rate change from the previous outer iteration -- one step behind
3226 ! the newest heads. That is fine here: a lagged rate can only delay
3227 ! convergence, never accept a bad answer, because the solver already
3228 ! checks the heads and steady heads mean a steady rate. The up-to-date
3229 ! rate is not used because recomputing it would change the well's
3230 ! shutoff and RATE_SCALING state.
3231 dq = (this%qsim0(n) - this%ratesim(n)) * qtolfact
3232 if (abs(dq) > abs(dpakmax)) then
3233 dpakmax = dq
3234 locdpak = n
3235 end if
3236 end do
3237 if (locdpak > 0 .and. abs(dpakmax) > abs(dpak)) then
3238 ipak = locdpak
3239 dpak = dpakmax
3240 write (cloc, "(a,'-',a)") trim(this%packName), 'rate'
3241 cpak = trim(cloc)
3242 end if
3243 !
3244 ! -- the over-demand warning is only written on the last outer iteration of
3245 ! a model that did not converge
3246 if (iend == 0) return
3247 if (icnvgmod /= 0) return
3248 !
3249 ! -- look at each active pumping (extraction) well
3250 do n = 1, this%nmawwells
3251 if (this%iboundpak(n) < 1) cycle
3252 if (this%rate(n) >= dzero) cycle
3253 botw = this%bot(n)
3254 !
3255 ! -- largest rate the aquifer could supply if the well head dropped all
3256 ! the way to the bottom of the well
3257 qmax = dzero
3258 do j = 1, this%ngwfnodes(n)
3259 jpos = this%get_jpos(n, j)
3260 if (this%iboundconn(jpos) == 0) cycle
3261 igwfnode = this%get_gwfnode(n, j)
3262 hgwf = this%xnew(igwfnode)
3263 bmaw = this%botscrn(jpos)
3264 hv = max(botw, bmaw)
3265 !
3266 ! -- connection saturation evaluated with the well head at the bottom of
3267 ! the well (hv), consistent with this maximum-supply estimate, rather
3268 ! than at the current well head
3269 call this%maw_calculate_saturation(n, j, igwfnode, sat, hv)
3270 cmaw = this%satcond(jpos) * sat
3271 !
3272 ! -- only count connections that can supply water. A connection whose
3273 ! aquifer head is below the well bottom would take water in, so skip
3274 ! it instead of letting it lower the maximum supply.
3275 qmax = qmax + cmaw * max(hgwf - hv, dzero)
3276 end do
3277 !
3278 ! -- warn if the well is asking for more than the aquifer can supply
3279 qreq = -this%rate(n)
3280 if (qmax >= dzero .and. qreq > qtol * qmax) then
3281 write (cloc, '(a, a, a, a, i0, a, i0, a)') trim(this%name_model), '-(', &
3282 trim(this%filtyp), '_', this%ibcnum, '-', n, ')'
3283 write (warnmsg, fmtwarn) trim(cloc), qreq, qmax
3284 call store_warning(warnmsg)
3285 end if
3286 end do
3287 end subroutine maw_cc
3288
3289 !> @brief Calculate flows
3290 !<
3291 subroutine maw_cq(this, x, flowja, iadv)
3292 ! -- modules
3293 use tdismodule, only: delt
3294 use constantsmodule, only: lenboundname
3295 use budgetmodule, only: budgettype
3296 ! -- dummy
3297 class(mawtype), intent(inout) :: this
3298 real(DP), dimension(:), intent(in) :: x
3299 real(DP), dimension(:), contiguous, intent(inout) :: flowja
3300 integer(I4B), optional, intent(in) :: iadv
3301 ! -- local
3302 real(DP) :: rrate
3303 real(DP) :: ss
3304 real(DP) :: ssold
3305 ! -- for budget
3306 integer(I4B) :: j
3307 integer(I4B) :: n
3308 integer(I4B) :: ibnd
3309 real(DP) :: hmaw
3310 real(DP) :: cfw
3311 ! -- for observations
3312 ! -- formats
3313 !
3314 ! -- recalculate package HCOF and RHS terms with latest groundwater and
3315 ! maw heads prior to calling base budget functionality
3316 call this%maw_cfupdate()
3317 !
3318 ! -- call base functionality in bnd_cq. This will calculate maw-gwf flows
3319 ! and put them into this%simvals
3320 call this%BndType%bnd_cq(x, flowja, iadv=1)
3321 !
3322 ! -- calculate maw budget flow and storage terms
3323 do n = 1, this%nmawwells
3324 this%qout(n) = dzero
3325 this%qsto(n) = dzero
3326 if (this%iflowingwells > 0) then
3327 this%qfw(n) = dzero
3328 end if
3329 if (this%iboundpak(n) == 0) then
3330 cycle
3331 end if
3332 !
3333 ! -- set hmaw and xsto
3334 hmaw = this%xnewpak(n)
3335 this%xsto(n) = hmaw
3336 !
3337 ! -- add pumping rate to active maw well
3338 rrate = this%ratesim(n)
3339 !
3340 ! -- If flow is out of maw set qout to rrate.
3341 if (rrate < dzero) then
3342 this%qout(n) = rrate
3343 end if
3344 !
3345 ! -- add flowing well
3346 if (this%iflowingwells > 0) then
3347 if (this%fwcond(n) > dzero) then
3348 cfw = this%fwcondsim(n)
3349 ! -- only raise the storage level to the flowing-well elevation when
3350 ! the well is actually discharging (ifwdischarge == 1), matching
3351 ! the storage term assembled in maw_fc
3352 if (this%ifwdischarge(n) == 1) then
3353 this%xsto(n) = this%fwelev(n)
3354 end if
3355 rrate = cfw * (this%fwelev(n) - hmaw)
3356 this%qfw(n) = rrate
3357 !
3358 ! -- Subtract flowing well rrate from qout.
3359 this%qout(n) = this%qout(n) + rrate
3360 end if
3361 end if
3362 !
3363 ! -- Calculate qsto so it matches the storage term built in maw_fc. A
3364 ! flowing well that is actively discharging (ifwdischarge == 1) uses
3365 ! the flowing-well elevation (xsto = fwelev). Otherwise the storage
3366 ! water level is not allowed to drop below the bottom of the well.
3367 ! Testing ifwdischarge (not fwcond) keeps the budget in step with the
3368 ! matrix when a flowing well is at or below its discharge elevation.
3369 if (this%imawiss /= 1) then
3370 if (this%iflowingwells > 0 .and. this%ifwdischarge(n) == 1) then
3371 rrate = -this%area(n) * (this%xsto(n) - this%xoldsto(n)) / delt
3372 else
3373 ss = squadratic0sp(hmaw, this%bot(n), this%satomega)
3374 ssold = squadratic0sp(this%xoldsto(n), this%bot(n), this%satomega)
3375 rrate = -this%area(n) * (ss - ssold) / delt
3376 end if
3377 this%qsto(n) = rrate
3378 end if
3379 end do
3380 !
3381 ! -- gwf and constant flow
3382 ibnd = 1
3383 do n = 1, this%nmawwells
3384 hmaw = this%xnewpak(n)
3385 this%qconst(n) = dzero
3386 do j = 1, this%ngwfnodes(n)
3387 rrate = -this%simvals(ibnd)
3388 this%qleak(ibnd) = rrate
3389 if (this%iboundpak(n) < 0) then
3390 this%qconst(n) = this%qconst(n) - rrate
3391 !
3392 ! -- If flow is out increment qout by -rrate.
3393 if (-rrate < dzero) then
3394 this%qout(n) = this%qout(n) - rrate
3395 end if
3396 end if
3397 !
3398 ! -- increment ibnd counter
3399 ibnd = ibnd + 1
3400 end do
3401 !
3402 ! -- add additional flow terms to constant head term
3403 if (this%iboundpak(n) < 0) then
3404 !
3405 ! -- add well pumping rate
3406 this%qconst(n) = this%qconst(n) - this%ratesim(n)
3407 !
3408 ! -- add flowing well rate
3409 if (this%iflowingwells > 0) then
3410 this%qconst(n) = this%qconst(n) - this%qfw(n)
3411 end if
3412 !
3413 ! -- add storage term
3414 if (this%imawiss /= 1) then
3415 this%qconst(n) = this%qconst(n) - this%qsto(n)
3416 end if
3417 end if
3418 end do
3419 !
3420 ! -- fill the budget object
3421 call this%maw_fill_budobj()
3422 end subroutine maw_cq
3423
3424 !> @brief Write flows to binary file and/or print flows to budget
3425 !<
3426 subroutine maw_ot_model_flows(this, icbcfl, ibudfl, icbcun, imap)
3427 ! -- dummy
3428 class(mawtype) :: this
3429 integer(I4B), intent(in) :: icbcfl
3430 integer(I4B), intent(in) :: ibudfl
3431 integer(I4B), intent(in) :: icbcun
3432 integer(I4B), dimension(:), optional, intent(in) :: imap
3433 !
3434 ! -- write the flows from the budobj
3435 call this%BndType%bnd_ot_model_flows(icbcfl, ibudfl, icbcun, this%imap)
3436 end subroutine maw_ot_model_flows
3437
3438 !> @brief Output MAW package flow terms.
3439 !<
3440 subroutine maw_ot_package_flows(this, icbcfl, ibudfl)
3441 use tdismodule, only: kstp, kper, delt, pertim, totim
3442 class(mawtype) :: this
3443 integer(I4B), intent(in) :: icbcfl
3444 integer(I4B), intent(in) :: ibudfl
3445 integer(I4B) :: ibinun
3446 !
3447 ! -- write the flows from the budobj
3448 ibinun = 0
3449 if (this%ibudgetout /= 0) then
3450 ibinun = this%ibudgetout
3451 end if
3452 if (icbcfl == 0) ibinun = 0
3453 if (ibinun > 0) then
3454 call this%budobj%save_flows(this%dis, ibinun, kstp, kper, delt, &
3455 pertim, totim, this%iout)
3456 end if
3457 !
3458 ! -- Print maw flows table
3459 if (ibudfl /= 0 .and. this%iprflow /= 0) then
3460 call this%budobj%write_flowtable(this%dis, kstp, kper)
3461 end if
3462 end subroutine maw_ot_package_flows
3463
3464 !> @brief Save maw-calculated values to binary file
3465 !<
3466 subroutine maw_ot_dv(this, idvsave, idvprint)
3467 use tdismodule, only: kstp, kper, pertim, totim
3468 use constantsmodule, only: dhnoflo, dhdry
3469 use inputoutputmodule, only: ulasav
3470 class(mawtype) :: this
3471 integer(I4B), intent(in) :: idvsave
3472 integer(I4B), intent(in) :: idvprint
3473 integer(I4B) :: ibinun
3474 integer(I4B) :: n
3475 real(DP) :: v
3476 real(DP) :: d
3477 !
3478 ! -- set unit number for binary dependent variable output
3479 ibinun = 0
3480 if (this%iheadout /= 0) then
3481 ibinun = this%iheadout
3482 end if
3483 if (idvsave == 0) ibinun = 0
3484 !
3485 ! -- write maw binary output
3486 if (ibinun > 0) then
3487 do n = 1, this%nmawwells
3488 v = this%xnewpak(n)
3489 d = v - this%bot(n)
3490 if (this%iboundpak(n) == 0) then
3491 v = dhnoflo
3492 else if (d <= dzero) then
3493 v = dhdry
3494 end if
3495 this%dbuff(n) = v
3496 end do
3497 call ulasav(this%dbuff, ' HEAD', &
3498 kstp, kper, pertim, totim, &
3499 this%nmawwells, 1, 1, ibinun)
3500 end if
3501 !
3502 ! -- write maw head table
3503 if (idvprint /= 0 .and. this%iprhed /= 0) then
3504 !
3505 ! -- set table kstp and kper
3506 call this%headtab%set_kstpkper(kstp, kper)
3507 !
3508 ! -- fill stage data
3509 do n = 1, this%nmawwells
3510 if (this%inamedbound == 1) then
3511 call this%headtab%add_term(this%cmawname(n))
3512 end if
3513 call this%headtab%add_term(n)
3514 call this%headtab%add_term(this%xnewpak(n))
3515 end do
3516 end if
3517 end subroutine maw_ot_dv
3518
3519 !> @brief Write MAW budget to listing file
3520 !<
3521 subroutine maw_ot_bdsummary(this, kstp, kper, iout, ibudfl)
3522 ! -- module
3523 use tdismodule, only: totim, delt
3524 ! -- dummy
3525 class(mawtype) :: this !< MawType object
3526 integer(I4B), intent(in) :: kstp !< time step number
3527 integer(I4B), intent(in) :: kper !< period number
3528 integer(I4B), intent(in) :: iout !< flag and unit number for the model listing file
3529 integer(I4B), intent(in) :: ibudfl !< flag indicating budget should be written
3530 !
3531 call this%budobj%write_budtable(kstp, kper, iout, ibudfl, totim, delt)
3532 end subroutine maw_ot_bdsummary
3533
3534 !> @brief Deallocate memory
3535 !<
3536 subroutine maw_da(this)
3537 ! -- modules
3539 ! -- dummy
3540 class(mawtype) :: this
3541 ! -- local
3542 !
3543 ! -- budobj
3544 call this%budobj%budgetobject_da()
3545 deallocate (this%budobj)
3546 nullify (this%budobj)
3547 !
3548 ! -- head table
3549 if (this%iprhed > 0) then
3550 call this%headtab%table_da()
3551 deallocate (this%headtab)
3552 nullify (this%headtab)
3553 end if
3554 !
3555 ! -- character arrays
3556 call mem_deallocate(this%cmawbudget, 'CMAWBUDGET', this%memoryPath)
3557 call mem_deallocate(this%cmawname, 'CMAWNAME', this%memoryPath)
3558 call mem_deallocate(this%status, 'STATUS', this%memoryPath)
3559 !
3560 ! -- deallocate well data pointers in memory manager
3561 call mem_deallocate(this%ngwfnodes)
3562 call mem_deallocate(this%ieqn)
3563 call mem_deallocate(this%ishutoff)
3564 call mem_deallocate(this%ifwdischarge)
3565 call mem_deallocate(this%strt)
3566 call mem_deallocate(this%radius)
3567 call mem_deallocate(this%area)
3568 call mem_deallocate(this%pumpelev)
3569 call mem_deallocate(this%bot)
3570 call mem_deallocate(this%ratesim)
3571 call mem_deallocate(this%qsim0)
3572 call mem_deallocate(this%reduction_length)
3573 call mem_deallocate(this%fwelev)
3574 call mem_deallocate(this%fwcond)
3575 call mem_deallocate(this%fwrlen)
3576 call mem_deallocate(this%fwcondsim)
3577 call mem_deallocate(this%xsto)
3578 call mem_deallocate(this%xoldsto)
3579 call mem_deallocate(this%shutoffmin)
3580 call mem_deallocate(this%shutoffmax)
3581 call mem_deallocate(this%shutofflevel)
3582 call mem_deallocate(this%shutoffweight)
3583 call mem_deallocate(this%shutoffdq)
3584 call mem_deallocate(this%shutoffqold)
3585 call mem_deallocate(this%nurdxold)
3586 call mem_deallocate(this%nurweight)
3587 !
3588 ! -- input-context-owned aliases, not package-allocated
3589 nullify (this%rate)
3590 nullify (this%well_head)
3591 call mem_deallocate(this%well_head_set)
3592 !
3593 ! -- connection data
3594 call mem_deallocate(this%iaconn)
3595 call mem_deallocate(this%gwfnodes)
3596 call mem_deallocate(this%sradius)
3597 call mem_deallocate(this%hk)
3598 call mem_deallocate(this%iboundconn)
3599 call mem_deallocate(this%satcond)
3600 call mem_deallocate(this%simcond)
3601 call mem_deallocate(this%topscrn)
3602 call mem_deallocate(this%botscrn)
3603 call mem_deallocate(this%angle)
3604 call mem_deallocate(this%connlen)
3605 call mem_deallocate(this%usrtopscrn)
3606 call mem_deallocate(this%usrbotscrn)
3607 !
3608 ! -- imap vector
3609 call mem_deallocate(this%imap)
3610 call mem_deallocate(this%dbuff)
3611 call mem_deallocate(this%cauxcbc, 'CAUXCBC', this%memoryPath)
3612 call mem_deallocate(this%qauxcbc)
3613 call mem_deallocate(this%qleak)
3614 call mem_deallocate(this%qfw)
3615 call mem_deallocate(this%qout)
3616 call mem_deallocate(this%qsto)
3617 call mem_deallocate(this%qconst)
3618 call mem_deallocate(this%denseterms)
3619 call mem_deallocate(this%viscratios)
3620 call mem_deallocate(this%idxlocnode)
3621 call mem_deallocate(this%idxdglo)
3622 call mem_deallocate(this%idxoffdglo)
3623 call mem_deallocate(this%idxsymdglo)
3624 call mem_deallocate(this%idxsymoffdglo)
3625 call mem_deallocate(this%xoldpak)
3626 !
3627 ! -- nullify pointers
3628 call mem_deallocate(this%xnewpak, 'HEAD', this%memoryPath)
3629 !
3630 ! -- scalars
3631 call mem_deallocate(this%correct_flow)
3632 call mem_deallocate(this%iprhed)
3633 call mem_deallocate(this%iheadout)
3634 call mem_deallocate(this%ibudgetout)
3635 call mem_deallocate(this%ibudcsv)
3636 call mem_deallocate(this%iflowingwells)
3637 call mem_deallocate(this%imawiss)
3638 call mem_deallocate(this%imawissopt)
3639 call mem_deallocate(this%nmawwells)
3640 call mem_deallocate(this%check_attr)
3641 call mem_deallocate(this%ishutoffcnt)
3642 call mem_deallocate(this%ieffradopt)
3643 call mem_deallocate(this%inonvert)
3644 call mem_deallocate(this%ioutredflowcsv)
3645 call mem_deallocate(this%satomega)
3646 call mem_deallocate(this%bditems)
3647 call mem_deallocate(this%theta)
3648 call mem_deallocate(this%kappa)
3649 call mem_deallocate(this%cbcauxitems)
3650 call mem_deallocate(this%idense)
3651 !
3652 ! -- pointers to gwf variables
3653 nullify (this%gwfiss)
3654 !
3655 ! -- nullify MAW input context pointers
3656 call this%input%destroy()
3657 !
3658 ! -- deallocate base
3659 call this%BndExtType%bnd_da()
3660 end subroutine maw_da
3661
3662 !> @brief Define the list heading that is written to iout when PRINT_INPUT
3663 !! option is used.
3664 !<
3665 subroutine define_listlabel(this)
3666 class(mawtype), intent(inout) :: this
3667 !
3668 ! -- create the header list label
3669 this%listlabel = trim(this%filtyp)//' NO.'
3670 if (this%dis%ndim == 3) then
3671 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
3672 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'ROW'
3673 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'COL'
3674 elseif (this%dis%ndim == 2) then
3675 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
3676 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'CELL2D'
3677 else
3678 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'NODE'
3679 end if
3680 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'STRESS RATE'
3681 if (this%inamedbound == 1) then
3682 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'BOUNDARY NAME'
3683 end if
3684 end subroutine define_listlabel
3685
3686 !> @brief Set pointers to model arrays and variables so that a package has
3687 !! has access to these things.
3688 !<
3689 subroutine maw_set_pointers(this, neq, ibound, xnew, xold, flowja)
3690 ! -- modules
3692 ! -- dummy
3693 class(mawtype) :: this
3694 integer(I4B), pointer :: neq
3695 integer(I4B), dimension(:), pointer, contiguous :: ibound
3696 real(DP), dimension(:), pointer, contiguous :: xnew
3697 real(DP), dimension(:), pointer, contiguous :: xold
3698 real(DP), dimension(:), pointer, contiguous :: flowja
3699 ! -- local
3700 integer(I4B) :: n
3701 integer(I4B) :: istart, iend
3702 !
3703 ! -- call base BndType set_pointers
3704 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
3705 !
3706 ! -- Set the MAW pointers
3707 !
3708 ! -- set package pointers
3709 istart = this%dis%nodes + this%ioffset + 1
3710 iend = istart + this%nmawwells - 1
3711 this%iboundpak => this%ibound(istart:iend)
3712 this%xnewpak => this%xnew(istart:iend)
3713 call mem_checkin(this%xnewpak, 'HEAD', this%memoryPath, 'X', &
3714 this%memoryPathModel)
3715 call mem_allocate(this%xoldpak, this%nmawwells, 'XOLDPAK', this%memoryPath)
3716 !
3717 ! -- initialize xnewpak
3718 do n = 1, this%nmawwells
3719 this%xnewpak(n) = dep20
3720 end do
3721 end subroutine maw_set_pointers
3722
3723 ! -- Procedures related to observations (type-bound)
3724
3725 !> @brief Return true because MAW package supports observations
3726 !!
3727 !! Overrides BndType%bnd_obs_supported()
3728 !<
3729 logical function maw_obs_supported(this)
3730 class(mawtype) :: this
3731 !
3732 maw_obs_supported = .true.
3733 end function maw_obs_supported
3734
3735 !> @brief Store observation type supported by MAW package
3736 !!
3737 !! Overrides BndType%bnd_df_obs
3738 !<
3739 subroutine maw_df_obs(this)
3740 ! -- dummy
3741 class(mawtype) :: this
3742 ! -- local
3743 integer(I4B) :: indx
3744 !
3745 ! -- Store obs type and assign procedure pointer
3746 ! for head observation type.
3747 call this%obs%StoreObsType('head', .false., indx)
3748 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3749 !
3750 ! -- Store obs type and assign procedure pointer
3751 ! for frommvr observation type.
3752 call this%obs%StoreObsType('from-mvr', .false., indx)
3753 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3754 !
3755 ! -- Store obs type and assign procedure pointer
3756 ! for conn-rate observation type.
3757 call this%obs%StoreObsType('maw', .true., indx)
3758 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3759 !
3760 ! -- Store obs type and assign procedure pointer
3761 ! for rate observation type.
3762 call this%obs%StoreObsType('rate', .true., indx)
3763 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3764 !
3765 ! -- Store obs type and assign procedure pointer
3766 ! for rate-to-mvr observation type.
3767 call this%obs%StoreObsType('rate-to-mvr', .true., indx)
3768 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3769 !
3770 ! -- Store obs type and assign procedure pointer
3771 ! for fw-rate observation type.
3772 call this%obs%StoreObsType('fw-rate', .true., indx)
3773 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3774 !
3775 ! -- Store obs type and assign procedure pointer
3776 ! for rate-to-mvr observation type.
3777 call this%obs%StoreObsType('fw-to-mvr', .true., indx)
3778 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3779 !
3780 ! -- Store obs type and assign procedure pointer
3781 ! for storage observation type.
3782 call this%obs%StoreObsType('storage', .true., indx)
3783 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3784 !
3785 ! -- Store obs type and assign procedure pointer
3786 ! for constant observation type.
3787 call this%obs%StoreObsType('constant', .true., indx)
3788 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3789 !
3790 ! -- Store obs type and assign procedure pointer
3791 ! for cond observation type.
3792 call this%obs%StoreObsType('conductance', .true., indx)
3793 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3794 !
3795 ! -- Store obs type and assign procedure pointer
3796 ! for fw-conductance observation type.
3797 call this%obs%StoreObsType('fw-conductance', .true., indx)
3798 this%obs%obsData(indx)%ProcessIdPtr => maw_process_obsid
3799 end subroutine maw_df_obs
3800
3801 !> @brief Calculate observations this time step and call
3802 !! ObsType%SaveOneSimval for each MawType observation.
3803 !<
3804 subroutine maw_bd_obs(this)
3805 ! -- dummy
3806 class(mawtype) :: this
3807 ! -- local
3808 integer(I4B) :: i
3809 integer(I4B) :: j
3810 integer(I4B) :: jj
3811 integer(I4B) :: n
3812 integer(I4B) :: nn
3813 integer(I4B) :: jpos
3814 real(DP) :: cmaw
3815 real(DP) :: hmaw
3816 real(DP) :: v
3817 real(DP) :: qfact
3818 type(observetype), pointer :: obsrv => null()
3819 !
3820 ! Calculate, save, and write simulated values for all MAW observations
3821 if (this%obs%npakobs > 0) then
3822 call this%obs%obs_bd_clear()
3823 do i = 1, this%obs%npakobs
3824 obsrv => this%obs%pakobs(i)%obsrv
3825 do j = 1, obsrv%indxbnds_count
3826 v = dnodata
3827 jj = obsrv%indxbnds(j)
3828 select case (obsrv%ObsTypeId)
3829 case ('HEAD')
3830 if (this%iboundpak(jj) /= 0) then
3831 v = this%xnewpak(jj)
3832 end if
3833 case ('FROM-MVR')
3834 if (this%iboundpak(jj) /= 0) then
3835 if (this%imover == 1) then
3836 v = this%pakmvrobj%get_qfrommvr(jj)
3837 end if
3838 end if
3839 case ('MAW')
3840 ! -- an inactive connection reports DNODATA, as an inactive well
3841 n = this%imap(jj)
3842 nn = jj - this%iaconn(n) + 1
3843 jpos = this%get_jpos(n, nn)
3844 if (this%iboundpak(n) /= 0 .and. this%iboundconn(jpos) /= 0) then
3845 v = this%qleak(jj)
3846 end if
3847 case ('RATE')
3848 if (this%iboundpak(jj) /= 0) then
3849 v = this%ratesim(jj)
3850 if (v < dzero .and. this%qout(jj) < dzero) then
3851 qfact = v / this%qout(jj)
3852 if (this%imover == 1) then
3853 v = v + this%pakmvrobj%get_qtomvr(jj) * qfact
3854 end if
3855 end if
3856 end if
3857 case ('RATE-TO-MVR')
3858 if (this%iboundpak(jj) /= 0) then
3859 if (this%imover == 1) then
3860 v = this%ratesim(jj)
3861 qfact = dzero
3862 if (v < dzero .and. this%qout(jj) < dzero) then
3863 qfact = v / this%qout(jj)
3864 end if
3865 v = this%pakmvrobj%get_qtomvr(jj) * qfact
3866 if (v > dzero) then
3867 v = -v
3868 end if
3869 end if
3870 end if
3871 case ('FW-RATE')
3872 if (this%iboundpak(jj) /= 0 .and. this%iflowingwells > 0) then
3873 hmaw = this%xnewpak(jj)
3874 cmaw = this%fwcondsim(jj)
3875 v = cmaw * (this%fwelev(jj) - hmaw)
3876 if (v < dzero .and. this%qout(jj) < dzero) then
3877 qfact = v / this%qout(jj)
3878 if (this%imover == 1) then
3879 v = v + this%pakmvrobj%get_qtomvr(jj) * qfact
3880 end if
3881 end if
3882 end if
3883 case ('FW-TO-MVR')
3884 if (this%iboundpak(jj) /= 0 .and. this%iflowingwells > 0) then
3885 if (this%imover == 1) then
3886 hmaw = this%xnewpak(jj)
3887 cmaw = this%fwcondsim(jj)
3888 v = cmaw * (this%fwelev(jj) - hmaw)
3889 qfact = dzero
3890 if (v < dzero .and. this%qout(jj) < dzero) then
3891 qfact = v / this%qout(jj)
3892 end if
3893 v = this%pakmvrobj%get_qtomvr(jj) * qfact
3894 if (v > dzero) then
3895 v = -v
3896 end if
3897 end if
3898 end if
3899 case ('STORAGE')
3900 if (this%iboundpak(jj) /= 0 .and. this%imawissopt /= 1) then
3901 v = this%qsto(jj)
3902 end if
3903 case ('CONSTANT')
3904 if (this%iboundpak(jj) /= 0) then
3905 v = this%qconst(jj)
3906 end if
3907 case ('CONDUCTANCE')
3908 n = this%imap(jj)
3909 nn = jj - this%iaconn(n) + 1
3910 jpos = this%get_jpos(n, nn)
3911 if (this%iboundpak(n) /= 0 .and. this%iboundconn(jpos) /= 0) then
3912 v = this%simcond(jpos)
3913 end if
3914 case ('FW-CONDUCTANCE')
3915 if (this%iboundpak(jj) /= 0) then
3916 v = this%fwcondsim(jj)
3917 end if
3918 case default
3919 errmsg = 'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
3920 call store_error(errmsg)
3921 end select
3922 call this%obs%SaveOneSimval(obsrv, v)
3923 end do
3924 end do
3925 !
3926 ! -- write summary of error messages
3927 if (count_errors() > 0) then
3928 call store_error_filename(this%input_fname)
3929 end if
3930 end if
3931 !
3932 ! -- Write the MAW reduced flows to csv file entries for this step
3933 if (this%ioutredflowcsv > 0) then
3934 call this%maw_redflow_csv_write()
3935 end if
3936 end subroutine maw_bd_obs
3937
3938 !> @brief Process each observation
3939 !!
3940 !! Only done the first stress period since boundaries are fixed for the
3941 !! simulation
3942 !<
3943 subroutine maw_rp_obs(this)
3944 use tdismodule, only: kper
3945 ! -- dummy
3946 class(mawtype), intent(inout) :: this
3947 ! -- local
3948 integer(I4B) :: i
3949 integer(I4B) :: j
3950 integer(I4B) :: nn1
3951 integer(I4B) :: nn2
3952 integer(I4B) :: jj
3953 character(len=LENBOUNDNAME) :: bname
3954 logical :: jfound
3955 class(observetype), pointer :: obsrv => null()
3956 ! -- formats
395710 format('Boundary "', a, '" for observation "', a, &
3958 '" is invalid in package "', a, '"')
3959 !
3960 if (kper == 1) then
3961 do i = 1, this%obs%npakobs
3962 obsrv => this%obs%pakobs(i)%obsrv
3963 !
3964 ! -- get node number 1
3965 nn1 = obsrv%NodeNumber
3966 if (nn1 == namedboundflag) then
3967 bname = obsrv%FeatureName
3968 if (bname /= '') then
3969 ! -- Observation maw is based on a boundary name.
3970 ! Iterate through all multi-aquifer wells to identify and store
3971 ! corresponding index in bound array.
3972 jfound = .false.
3973 if (obsrv%ObsTypeId == 'MAW' .or. &
3974 obsrv%ObsTypeId == 'CONDUCTANCE') then
3975 if (this%inamedbound /= 0) then
3976 do j = 1, this%nmawwells
3977 do jj = this%iaconn(j), this%iaconn(j + 1) - 1
3978 if (this%boundname(jj) == bname) then
3979 jfound = .true.
3980 call obsrv%AddObsIndex(jj)
3981 end if
3982 end do
3983 end do
3984 end if
3985 else
3986 do j = 1, this%nmawwells
3987 if (this%cmawname(j) == bname) then
3988 jfound = .true.
3989 call obsrv%AddObsIndex(j)
3990 end if
3991 end do
3992 end if
3993 if (.not. jfound) then
3994 write (errmsg, 10) &
3995 trim(bname), trim(obsrv%Name), trim(this%packName)
3996 call store_error(errmsg)
3997 end if
3998 end if
3999 else
4000 if (obsrv%indxbnds_count == 0) then
4001 if (obsrv%ObsTypeId == 'MAW' .or. &
4002 obsrv%ObsTypeId == 'CONDUCTANCE') then
4003 nn2 = obsrv%NodeNumber2
4004 if (nn1 < 1 .or. nn1 > this%nmawwells) then
4005 write (errmsg, '(5a,i0,a,i0,a)') &
4006 'Observation ', trim(obsrv%Name), ' of type ', &
4007 trim(adjustl(obsrv%ObsTypeId)), &
4008 ' was assigned multi-aquifer well ', nn1, &
4009 '. Multi-aquifer well must be >= 1 and <= ', &
4010 this%nmawwells, '.'
4011 call store_error(errmsg)
4012 else if (nn2 < 1 .or. nn2 > this%ngwfnodes(nn1)) then
4013 write (errmsg, '(5a,i0,a,i0,a,i0,a)') &
4014 'Observation ', trim(obsrv%Name), ' of type ', &
4015 trim(adjustl(obsrv%ObsTypeId)), &
4016 ' was assigned connection ', nn2, &
4017 ' of multi-aquifer well ', nn1, &
4018 '. Connection must be >= 1 and <= ', &
4019 this%ngwfnodes(nn1), '.'
4020 call store_error(errmsg)
4021 else
4022 j = this%iaconn(nn1) + nn2 - 1
4023 call obsrv%AddObsIndex(j)
4024 end if
4025 else
4026 call obsrv%AddObsIndex(nn1)
4027 end if
4028 else
4029 errmsg = 'Programming error in maw_rp_obs'
4030 call store_error(errmsg)
4031 end if
4032 end if
4033 !
4034 ! -- catch non-cumulative observation assigned to observation defined
4035 ! by a boundname that is assigned to more than one element
4036 if (obsrv%ObsTypeId == 'HEAD') then
4037 if (obsrv%indxbnds_count > 1) then
4038 write (errmsg, '(a,3(1x,a))') &
4039 trim(adjustl(obsrv%ObsTypeId)), &
4040 'for observation', trim(adjustl(obsrv%Name)), &
4041 'must be assigned to a multi-aquifer well with a unique boundname.'
4042 call store_error(errmsg)
4043 end if
4044 end if
4045 !
4046 ! -- check that index values are valid
4047 if (obsrv%ObsTypeId == 'MAW' .or. &
4048 obsrv%ObsTypeId == 'CONDUCTANCE') then
4049 do j = 1, obsrv%indxbnds_count
4050 nn1 = obsrv%indxbnds(j)
4051 if (nn1 < 1 .or. nn1 > this%maxbound) then
4052 write (errmsg, '(3(a,1x),i0,1x,a,i0,a)') &
4053 trim(adjustl(obsrv%ObsTypeId)), &
4054 'multi-aquifer well connection number must be greater than 0', &
4055 'and less than or equal to', this%maxbound, &
4056 '(specified value is ', nn1, ').'
4057 call store_error(errmsg)
4058 end if
4059 end do
4060 else
4061 do j = 1, obsrv%indxbnds_count
4062 nn1 = obsrv%indxbnds(j)
4063 if (nn1 < 1 .or. nn1 > this%nmawwells) then
4064 write (errmsg, '(3(a,1x),i0,1x,a,i0,a)') &
4065 trim(adjustl(obsrv%ObsTypeId)), &
4066 'multi-aquifer well must be greater than 0 ', &
4067 'and less than or equal to', this%nmawwells, &
4068 '(specified value is ', nn1, ').'
4069 call store_error(errmsg)
4070 end if
4071 end do
4072 end if
4073 end do
4074 !
4075 ! -- evaluate if there are any observation errors
4076 if (count_errors() > 0) then
4077 call store_error_filename(this%input_fname)
4078 end if
4079 end if
4080 end subroutine maw_rp_obs
4081
4082 !
4083 ! -- Procedures related to observations (NOT type-bound)
4084
4085 !> @brief This procedure is pointed to by ObsDataType%ProcesssIdPtr. It
4086 !! processes the ID string of an observation definition for MAW package
4087 !! observations.
4088 !<
4089 subroutine maw_process_obsid(obsrv, dis, inunitobs, iout)
4090 ! -- dummy
4091 type(observetype), intent(inout) :: obsrv
4092 class(disbasetype), intent(in) :: dis
4093 integer(I4B), intent(in) :: inunitobs
4094 integer(I4B), intent(in) :: iout
4095 ! -- local
4096 integer(I4B) :: nn1, nn2
4097 integer(I4B) :: icol, istart, istop
4098 character(len=LINELENGTH) :: string
4099 character(len=LENBOUNDNAME) :: bndname
4100 ! formats
4101 !
4102 string = obsrv%IDstring
4103 ! -- Extract multi-aquifer well number from string and store it.
4104 ! If 1st item is not an integer(I4B), it should be a
4105 ! maw name--deal with it.
4106 icol = 1
4107 ! -- get multi-aquifer well number or boundary name
4108 call extract_idnum_or_bndname(string, icol, istart, istop, nn1, bndname)
4109 if (nn1 == namedboundflag) then
4110 obsrv%FeatureName = bndname
4111 else
4112 if (obsrv%ObsTypeId == 'MAW' .or. &
4113 obsrv%ObsTypeId == 'CONDUCTANCE') then
4114 call extract_idnum_or_bndname(string, icol, istart, istop, nn2, bndname)
4115 if (len_trim(bndname) < 1 .and. nn2 < 0) then
4116 write (errmsg, '(a,1x,a,a,1x,a,1x,a)') &
4117 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
4118 ', ID given as an integer and not as boundname,', &
4119 'but ID2 (icon) is missing. Either change ID to valid', &
4120 'boundname or supply valid entry for ID2.'
4121 call store_error(errmsg)
4122 end if
4123 if (nn2 == namedboundflag) then
4124 obsrv%FeatureName = bndname
4125 ! -- reset nn1
4126 nn1 = nn2
4127 else
4128 obsrv%NodeNumber2 = nn2
4129 end if
4130 end if
4131 end if
4132 ! -- store multi-aquifer well number (NodeNumber)
4133 obsrv%NodeNumber = nn1
4134 end subroutine maw_process_obsid
4135
4136 !
4137 ! -- private MAW methods
4138
4139 !> @brief Initialize the auto flow reduce csv output file
4140 !<
4141 subroutine maw_redflow_csv_init(this, fname)
4142 ! -- dummy variables
4143 class(mawtype), intent(inout) :: this !< MawType object
4144 character(len=*), intent(in) :: fname
4145 ! -- format
4146 character(len=*), parameter :: fmtredflowcsv = &
4147 "(4x, 'MAW REDUCED FLOW INFORMATION WILL BE SAVED TO FILE: ', a, /4x, &
4148 &'OPENED ON UNIT: ', I0)"
4149
4150 this%ioutredflowcsv = getunit()
4151 call openfile(this%ioutredflowcsv, this%iout, fname, 'CSV', &
4152 filstat_opt='REPLACE')
4153 write (this%iout, fmtredflowcsv) trim(adjustl(fname)), &
4154 this%ioutredflowcsv
4155 write (this%ioutredflowcsv, '(a)') &
4156 'time,period,step,MAWnumber,rate-requested,rate-actual,maw-reduction'
4157 end subroutine maw_redflow_csv_init
4158
4159 !> @brief MAW reduced flows only when & where they occur
4160 !<
4161 subroutine maw_redflow_csv_write(this)
4162 ! -- modules
4163 use tdismodule, only: totim, kstp, kper
4164 ! -- dummy variables
4165 class(mawtype), intent(inout) :: this !< MawType object
4166 ! -- local
4167 integer(I4B) :: n
4168 !integer(I4B) :: nodereduced
4169 !integer(I4B) :: nodeuser
4170 real(DP) :: v
4171 ! -- format
4172 do n = 1, this%nmawwells
4173 !
4174 ! -- test if node is constant or inactive
4175 if (this%status(n) .ne. 'ACTIVE') then
4176 cycle
4177 end if
4178 v = this%rate(n) - this%ratesim(n) !reductions in extraction will be negative and reductions in injection will be positive; follows convention of WEL AUTO_FLOW_REDUCE_CSV
4179 if (abs(v) > dem9) then !need to check absolute value of difference for both extraction and injection; using 1e-9 as epsilon value but could be tweaked
4180 write (this%ioutredflowcsv, '(*(G0,:,","))') &
4181 totim, kper, kstp, n, this%rate(n), this%ratesim(n), v
4182 end if
4183 end do
4184 end subroutine maw_redflow_csv_write
4185
4186 !> @brief Calculate the appropriate saturated conductance to use based on
4187 !! aquifer and multi-aquifer well characteristics
4188 !<
4189 subroutine maw_calculate_satcond(this, i, j, node)
4190 ! -- dummy
4191 class(mawtype), intent(inout) :: this
4192 integer(I4B), intent(in) :: i
4193 integer(I4B), intent(in) :: j
4194 integer(I4B), intent(in) :: node
4195 ! -- local
4196 integer(I4B) :: iTcontrastErr
4197 integer(I4B) :: jpos
4198 real(DP) :: c
4199 real(DP) :: k11
4200 real(DP) :: k22
4201 real(DP) :: sqrtk11k22
4202 real(DP) :: hks
4203 real(DP) :: area
4204 real(DP) :: eradius
4205 real(DP) :: topw
4206 real(DP) :: botw
4207 real(DP) :: tthkw
4208 real(DP) :: tthka
4209 real(DP) :: Tcontrast
4210 real(DP) :: skin
4211 real(DP) :: ravg
4212 real(DP) :: slen
4213 real(DP) :: pavg
4214 real(DP) :: gwfsat
4215 real(DP) :: gwftop
4216 real(DP) :: gwfbot
4217 real(DP) :: lc1
4218 real(DP) :: lc2
4219 real(DP) :: dx
4220 real(DP) :: dy
4221 real(DP) :: Txx
4222 real(DP) :: Tyy
4223 real(DP) :: T2pi
4224 real(DP) :: yx4
4225 real(DP) :: xy4
4226 ! -- formats
4227 !
4228 ! -- initialize conductance variables
4229 itcontrasterr = 0
4230 lc1 = dzero
4231 lc2 = dzero
4232 !
4233 ! -- calculate connection position
4234 jpos = this%get_jpos(i, j)
4235 !
4236 ! -- set K11 and K22
4237 k11 = this%gwfk11(node)
4238 if (this%gwfik22 == 0) then
4239 k22 = this%gwfk11(node)
4240 else
4241 k22 = this%gwfk22(node)
4242 end if
4243 sqrtk11k22 = sqrt(k11 * k22)
4244 !
4245 ! -- set gwftop, gwfbot, and gwfsat
4246 gwftop = this%dis%top(node)
4247 gwfbot = this%dis%bot(node)
4248 tthka = gwftop - gwfbot
4249 gwfsat = this%gwfsat(node)
4250 !
4251 ! -- set top and bottom of well screen
4252 c = dzero
4253 topw = this%topscrn(jpos)
4254 botw = this%botscrn(jpos)
4255 tthkw = topw - botw
4256 !
4257 ! -- scale screen thickness using gwfsat (for NPF Package THICKSTRT)
4258 if (gwftop == topw .and. gwfbot == botw) then
4259 if (this%icelltype(node) == 0) then
4260 tthkw = tthkw * gwfsat
4261 tthka = tthka * gwfsat
4262 end if
4263 end if
4264 !
4265 ! -- calculate the aquifer transmissivity (T2pi)
4266 t2pi = dtwopi * tthka * sqrtk11k22
4267 !
4268 ! -- calculate effective radius
4269 if (this%dis%ndim == 3 .and. this%ieffradopt /= 0) then
4270 txx = k11 * tthka
4271 tyy = k22 * tthka
4272 dx = sqrt(this%dis%area(node))
4273 dy = dx
4274 yx4 = (tyy / txx)**dquarter
4275 xy4 = (txx / tyy)**dquarter
4276 eradius = 0.28_dp * ((yx4 * dx)**dtwo + &
4277 (xy4 * dy)**dtwo)**dhalf / (yx4 + xy4)
4278 else
4279 area = this%dis%area(node)
4280 eradius = sqrt(area / (deight * dpi))
4281 end if
4282 !
4283 ! -- conductance calculations
4284 ! -- Thiem equation (1) and cumulative Thiem and skin equations (3)
4285 if (this%ieqn(i) == 1 .or. this%ieqn(i) == 3) then
4286 lc1 = log(eradius / this%radius(i)) / t2pi
4287 end if
4288 !
4289 ! -- skin equation (2) and cumulative Thiem and skin equations (3)
4290 if (this%ieqn(i) == 2 .or. this%ieqn(i) == 3) then
4291 hks = this%hk(jpos)
4292 if (tthkw * hks > dzero) then
4293 tcontrast = (sqrtk11k22 * tthka) / (hks * tthkw)
4294 skin = (tcontrast - done) * log(this%sradius(jpos) / this%radius(i))
4295 !
4296 ! -- trap invalid transmissvity contrast if using skin equation (2).
4297 ! Not trapped for cumulative Thiem and skin equations (3)
4298 ! because the MNW2 package allowed this condition (for
4299 ! backward compatibility with the MNW2 package for
4300 ! MODFLOW-2005, MODFLOW-NWT, and MODFLOW-USG).
4301 if (tcontrast <= 1 .and. this%ieqn(i) == 2) then
4302 itcontrasterr = 1
4303 write (errmsg, '(a,g0,a,1x,i0,1x,a,1x,i0,a,4(1x,a))') &
4304 'Invalid calculated transmissivity contrast (', tcontrast, &
4305 ') for maw well', i, 'connection', j, '.', 'This happens when the', &
4306 'skin transmissivity equals or exceeds the aquifer transmissivity.', &
4307 'Consider decreasing HK_SKIN for the connection or using the', &
4308 'CUMULATIVE or MEAN conductance equations.'
4309 call store_error(errmsg)
4310 else
4311 lc2 = skin / t2pi
4312 end if
4313 end if
4314 end if
4315 ! -- conductance using screen elevations, hk, well radius,
4316 ! and screen radius
4317 if (this%ieqn(i) == 4) then
4318 hks = this%hk(jpos)
4319 ravg = dhalf * (this%radius(i) + this%sradius(jpos))
4320 slen = this%sradius(jpos) - this%radius(i)
4321 pavg = dtwopi * ravg
4322 c = hks * pavg * tthkw / slen
4323 end if
4324 !
4325 ! -- calculate final conductance for Thiem (1), Skin (2), and
4326 ! and cumulative Thiem and skin equations (3)
4327 if (this%ieqn(i) < 4) then
4328 if (lc1 + lc2 /= dzero) then
4329 c = done / (lc1 + lc2)
4330 else
4331 c = -dnodata
4332 end if
4333 end if
4334 !
4335 ! -- ensure that the conductance is not negative. Only write error message
4336 ! if error condition has not occurred for skin calculations (LC2)
4337 if (c < dzero .and. itcontrasterr == 0) then
4338 write (errmsg, '(a,g0,a,1x,i0,1x,a,1x,i0,a,4(1x,a))') &
4339 'Invalid calculated negative conductance (', c, &
4340 ') for maw well', i, 'connection', j, '.', 'this happens when the', &
4341 'skin transmissivity equals or exceeds the aquifer transmissivity.', &
4342 'consider decreasing hk_skin for the connection or using the', &
4343 'mean conductance equation.'
4344 call store_error(errmsg)
4345 end if
4346 !
4347 ! -- scale the saturated conductance by the length correction factor for
4348 ! non-vertical (slanted) connections. The factor is 1.0 for vertical
4349 ! connections, so this has no effect unless an ANGLEDATA block was read.
4350 if (this%inonvert /= 0) then
4351 c = c * this%maw_calc_lcorr(i, jpos)
4352 end if
4353 !
4354 ! -- set saturated conductance
4355 this%satcond(jpos) = c
4356 end subroutine maw_calculate_satcond
4357
4358 !> @brief Calculate the saturation between the aquifer maw well_head
4359 !<
4360 subroutine maw_calculate_saturation(this, n, j, node, sat, hwell_in)
4361 ! -- dummy
4362 class(mawtype), intent(inout) :: this
4363 integer(I4B), intent(in) :: n
4364 integer(I4B), intent(in) :: j
4365 integer(I4B), intent(in) :: node
4366 real(DP), intent(inout) :: sat
4367 real(DP), intent(in), optional :: hwell_in !well head to use instead of the current well head
4368 ! -- local
4369 integer(I4B) :: jpos
4370 real(DP) :: h_temp
4371 real(DP) :: hwell
4372 real(DP) :: topw
4373 real(DP) :: botw
4374 ! -- formats
4375 !
4376 ! -- initialize saturation
4377 sat = dzero
4378 !
4379 ! -- calculate current saturation for convertible cells
4380 if (this%icelltype(node) /= 0) then
4381 !
4382 ! -- set hwell (use the caller-supplied head if provided)
4383 hwell = this%xnewpak(n)
4384 if (present(hwell_in)) then
4385 hwell = hwell_in
4386 end if
4387 !
4388 ! -- set connection position
4389 jpos = this%get_jpos(n, j)
4390 !
4391 ! -- set top and bottom of the well connection
4392 topw = this%topscrn(jpos)
4393 botw = this%botscrn(jpos)
4394 !
4395 ! -- calculate appropriate saturation
4396 if (this%inewton /= 1) then
4397 h_temp = this%xnew(node)
4398 if (h_temp < botw) then
4399 h_temp = botw
4400 end if
4401 if (hwell < botw) then
4402 hwell = botw
4403 end if
4404 h_temp = dhalf * (h_temp + hwell)
4405 else
4406 h_temp = this%xnew(node)
4407 if (hwell > h_temp) then
4408 h_temp = hwell
4409 end if
4410 if (h_temp < botw) then
4411 h_temp = botw
4412 end if
4413 end if
4414 ! -- calculate saturation
4415 sat = squadraticsaturation(topw, botw, h_temp, this%satomega)
4416 else
4417 sat = done
4418 end if
4419 end subroutine maw_calculate_saturation
4420
4421 !> @brief Calculate matrix terms for a multi-aquifer well connection. Terms
4422 !! for fc and fn methods are calculated based on whether term2 is passed
4423 !! Arguments are as follows:
4424 !! n : maw well number
4425 !! j : connection number for well n
4426 !! icflow : flag indicating that flow should be corrected
4427 !! cmaw : maw-gwf conducance
4428 !! cterm : correction term for flow to dry cell
4429 !! term : xxx
4430 !! flow : calculated flow for this connection, positive into well
4431 !! term2 : xxx
4432 !<
4433 subroutine maw_calculate_conn_terms(this, n, j, icflow, cmaw, cterm, term, &
4434 flow, term2)
4435 ! -- dummy
4436 class(mawtype) :: this
4437 integer(I4B), intent(in) :: n
4438 integer(I4B), intent(in) :: j
4439 integer(I4B), intent(inout) :: icflow
4440 real(DP), intent(inout) :: cmaw
4441 real(DP), intent(inout) :: cterm
4442 real(DP), intent(inout) :: term
4443 real(DP), intent(inout) :: flow
4444 real(DP), intent(inout), optional :: term2
4445 ! -- local
4446 logical(LGP) :: correct_flow
4447 integer(I4B) :: inewton
4448 integer(I4B) :: jpos
4449 integer(I4B) :: igwfnode
4450 real(DP) :: hmaw
4451 real(DP) :: hgwf
4452 real(DP) :: hups
4453 real(DP) :: hdowns
4454 real(DP) :: sat
4455 real(DP) :: tmaw
4456 real(DP) :: bmaw
4457 real(DP) :: en
4458 real(DP) :: hbar
4459 real(DP) :: drterm
4460 real(DP) :: dhbarterm
4461 real(DP) :: vscratio
4462 !
4463 ! -- initialize terms
4464 cterm = dzero
4465 vscratio = done
4466 icflow = 0
4467 if (present(term2)) then
4468 inewton = 1
4469 else
4470 inewton = 0
4471 end if
4472 !
4473 ! -- set common terms
4474 jpos = this%get_jpos(n, j)
4475 igwfnode = this%get_gwfnode(n, j)
4476 hgwf = this%xnew(igwfnode)
4477 hmaw = this%xnewpak(n)
4478 tmaw = this%topscrn(jpos)
4479 bmaw = this%botscrn(jpos)
4480 !
4481 ! -- if vsc active, select appropriate viscosity ratio
4482 if (this%ivsc == 1) then
4483 ! flow out of well (flow is negative)
4484 if (flow < 0) then
4485 vscratio = this%viscratios(1, n)
4486 else
4487 vscratio = this%viscratios(2, n)
4488 end if
4489 end if
4490 !
4491 ! -- calculate saturation
4492 call this%maw_calculate_saturation(n, j, igwfnode, sat)
4493 cmaw = this%satcond(jpos) * vscratio * sat
4494 !
4495 ! -- set upstream head, term, and term2 if returning newton terms
4496 if (inewton == 1) then
4497 term = dzero
4498 term2 = dzero
4499 hups = hmaw
4500 if (hgwf > hups) then
4501 hups = hgwf
4502 end if
4503 !
4504 ! -- slope of the saturation with head. In a confined (non-convertible)
4505 ! cell the saturation is always one and does not change with head, so
4506 ! this slope must be zero. Otherwise the matrix terms would not match
4507 ! the flow that is actually calculated for the well.
4508 if (this%icelltype(igwfnode) /= 0) then
4509 drterm = squadraticsaturationderivative(tmaw, bmaw, hups, this%satomega)
4510 else
4511 drterm = dzero
4512 end if
4513 else
4514 term = cmaw
4515 end if
4516 !
4517 ! -- calculate correction term if flow_correction option specified
4518 if (this%correct_flow) then
4519 !
4520 ! -- set bmaw, determine en, and set correct_flow flag
4521 en = max(bmaw, this%dis%bot(igwfnode))
4522 correct_flow = .false.
4523 if (hmaw < en) then
4524 correct_flow = .true.
4525 end if
4526 if (hgwf < en .and. this%icelltype(igwfnode) /= 0) then
4527 correct_flow = .true.
4528 end if
4529 !
4530 ! -- if flow should be corrected because hgwf or hmaw is below bottom
4531 ! then calculate correction term (cterm)
4532 if (correct_flow) then
4533 icflow = 1
4534 hdowns = min(hmaw, hgwf)
4535 hbar = squadratic0sp(hdowns, en, this%satomega)
4536 if (hgwf > hmaw) then
4537 cterm = cmaw * (hmaw - hbar)
4538 else
4539 cterm = cmaw * (hbar - hgwf)
4540 end if
4541 end if
4542 !
4543 ! -- if newton formulation then calculate newton terms
4544 if (inewton /= 0) then
4545 !
4546 ! -- maw is upstream
4547 if (hmaw > hgwf) then
4548 hbar = squadratic0sp(hgwf, en, this%satomega)
4549 term = drterm * this%satcond(jpos) * vscratio * (hbar - hmaw)
4550 dhbarterm = squadratic0spderivative(hgwf, en, this%satomega)
4551 term2 = cmaw * (dhbarterm - done)
4552 !
4553 ! -- gwf is upstream
4554 else
4555 hbar = squadratic0sp(hmaw, en, this%satomega)
4556 term = -drterm * this%satcond(jpos) * vscratio * (hgwf - hbar)
4557 dhbarterm = squadratic0spderivative(hmaw, en, this%satomega)
4558 term2 = cmaw * (done - dhbarterm)
4559 end if
4560 end if
4561 else
4562 !
4563 ! -- flow is not corrected, so calculate term for newton formulation
4564 if (inewton /= 0) then
4565 term = drterm * this%satcond(jpos) * vscratio * (hgwf - hmaw)
4566 end if
4567 end if
4568 !
4569 ! -- calculate flow relative to maw for fc and bd
4570 flow = dzero
4571 if (inewton == 0) then
4572 flow = term * (hgwf - hmaw) + cterm
4573 end if
4574 !
4575 ! -- add density part here
4576 if (this%idense /= 0 .and. inewton == 0) then
4577 call this%maw_calculate_density_exchange(jpos, hmaw, hgwf, cmaw, &
4578 bmaw, flow, term, cterm)
4579 end if
4580 end subroutine maw_calculate_conn_terms
4581
4582 !> @brief Calculate well pumping rate based on constraints
4583 !<
4584 subroutine maw_calculate_wellq(this, n, hmaw, q)
4585 ! -- dummy
4586 class(mawtype) :: this
4587 integer(I4B), intent(in) :: n
4588 real(DP), intent(in) :: hmaw
4589 real(DP), intent(inout) :: q
4590 ! -- local
4591 real(DP) :: scale
4592 real(DP) :: tp
4593 real(DP) :: bt
4594 real(DP) :: rate
4595 real(DP) :: weight
4596 real(DP) :: dq
4597 !
4598 ! -- Initialize q
4599 q = dzero
4600 !
4601 ! -- Assign rate as the user-provided base pumping rate
4602 rate = this%rate(n)
4603 !
4604 ! -- Assign q differently depending on whether this is an extraction well
4605 ! (rate < 0) or an injection well (rate > 0).
4606 if (rate < dzero) then
4607 !
4608 ! -- If well shut off is activated, then turn off well if necessary,
4609 ! or if shut off is not activated then check to see if rate scaling
4610 ! is on.
4611 if (this%shutofflevel(n) /= dep20) then
4612 call this%maw_calculate_qpot(n, q)
4613 if (q < dzero) q = dzero
4614 if (q > -rate) q = -rate
4615
4616 if (this%ishutoffcnt == 1) then
4617 this%shutoffweight(n) = done
4618 this%shutoffdq(n) = dzero
4619 this%shutoffqold(n) = q
4620 end if
4621
4622 dq = q - this%shutoffqold(n)
4623 weight = this%shutoffweight(n)
4624 !
4625 ! -- for oscillating condition, decrease factor
4626 if (this%shutoffdq(n) * dq < dzero) then
4627 weight = this%theta * this%shutoffweight(n)
4628 !
4629 ! -- when change is of same sign, increase factor
4630 else
4631 weight = this%shutoffweight(n) + this%kappa
4632 end if
4633 if (weight > done) weight = done
4634
4635 q = this%shutoffqold(n) + weight * dq
4636
4637 this%shutoffqold(n) = q
4638 this%shutoffdq(n) = dq
4639 this%shutoffweight(n) = weight
4640 !
4641 ! -- If shutoffmin and shutoffmax are specified then apply
4642 ! additional checks for when to shut off the well.
4643 if (this%shutoffmin(n) > dzero) then
4644 if (hmaw < this%shutofflevel(n)) then
4645 !
4646 ! -- calculate adjusted well rate subject to constraints
4647 ! -- well is shutoff
4648 if (this%ishutoff(n) /= 0) then
4649 q = dzero
4650 !
4651 ! --- well is not shut off
4652 else
4653 ! -- turn off well if q is less than the minimum rate and
4654 ! reset the ishutoff flag if at least on iteration 3
4655 if (q < this%shutoffmin(n)) then
4656 if (this%ishutoffcnt > 2) then
4657 this%ishutoff(n) = 1
4658 end if
4659 q = dzero
4660 !
4661 ! -- leave well on and use the specified rate
4662 ! or the potential rate
4663 end if
4664 end if
4665 !
4666 ! -- try to use the specified rate or the potential rate
4667 else
4668 if (q > this%shutoffmax(n)) then
4669 if (this%ishutoffcnt <= 2) then
4670 this%ishutoff(n) = 0
4671 end if
4672 end if
4673 if (this%ishutoff(n) /= 0) then
4674 q = dzero
4675 end if
4676 end if
4677 end if
4678
4679 if (q /= dzero) q = -q
4680
4681 else
4682 scale = done
4683 !
4684 ! -- Apply rate scaling by reducing pumpage when hmaw is less than the
4685 ! sum of maw pump elevation (pumpelev) and the specified reduction
4686 ! length. The rate will go to zero as hmaw drops to the pump
4687 ! elevation.
4688 if (this%reduction_length(n) /= dep20) then
4689 bt = this%pumpelev(n)
4690 tp = bt + this%reduction_length(n)
4691 scale = sqsaturation(tp, bt, hmaw)
4692 end if
4693 q = scale * rate
4694 end if
4695 !
4696 else
4697 !
4698 ! -- Handle the injection case (rate > 0) differently than extraction.
4699 q = rate
4700 if (this%shutofflevel(n) /= dep20) then
4701 call this%maw_calculate_qpot(n, q)
4702 q = -q
4703 if (q < dzero) q = dzero
4704 if (q > rate) q = rate
4705
4706 if (this%ishutoffcnt == 1) then
4707 this%shutoffweight(n) = done
4708 this%shutoffdq(n) = dzero
4709 this%shutoffqold(n) = q
4710 end if
4711
4712 dq = q - this%shutoffqold(n)
4713 weight = this%shutoffweight(n)
4714 !
4715 ! -- for oscillating condition, decrease factor
4716 if (this%shutoffdq(n) * dq < dzero) then
4717 weight = this%theta * this%shutoffweight(n)
4718 !
4719 ! -- when change is of same sign, increase factor
4720 else
4721 weight = this%shutoffweight(n) + this%kappa
4722 end if
4723 if (weight > done) weight = done
4724
4725 q = this%shutoffqold(n) + weight * dq
4726
4727 this%shutoffqold(n) = q
4728 this%shutoffdq(n) = dq
4729 this%shutoffweight(n) = weight
4730
4731 else
4732 scale = done
4733 !
4734 ! -- Apply rate scaling for an injection well by reducing the
4735 ! injection rate as hmaw rises above the pump elevation. The rate
4736 ! will approach zero as hmaw approaches pumpelev + reduction_length.
4737 if (this%reduction_length(n) /= dep20) then
4738 bt = this%pumpelev(n)
4739 tp = bt + this%reduction_length(n)
4740 scale = done - sqsaturation(tp, bt, hmaw)
4741 end if
4742 q = scale * rate
4743 end if
4744 end if
4745 end subroutine maw_calculate_wellq
4746
4747 !> @brief Calculate groundwater inflow to a maw well
4748 !<
4749 subroutine maw_calculate_qpot(this, n, qnet)
4750 use tdismodule, only: delt
4751 ! -- dummy
4752 class(mawtype), intent(inout) :: this
4753 integer(I4B), intent(in) :: n
4754 real(DP), intent(inout) :: qnet
4755 ! -- local
4756 integer(I4B) :: j
4757 integer(I4B) :: jpos
4758 integer(I4B) :: igwfnode
4759 real(DP) :: bt
4760 real(DP) :: tp
4761 real(DP) :: scale
4762 real(DP) :: cfw
4763 real(DP) :: hdterm
4764 real(DP) :: sat
4765 real(DP) :: cmaw
4766 real(DP) :: hgwf
4767 real(DP) :: bmaw
4768 real(DP) :: h_temp
4769 real(DP) :: hv
4770 real(DP) :: vscratio
4771 ! -- format
4772 !
4773 ! -- initialize qnet and h_temp
4774 qnet = dzero
4775 vscratio = done
4776 h_temp = this%shutofflevel(n)
4777 !
4778 ! -- if vsc active, select appropriate viscosity ratio
4779 if (this%ivsc == 1) then
4780 ! flow out of well (flow is negative)
4781 if (qnet < 0) then
4782 vscratio = this%viscratios(1, n)
4783 else
4784 vscratio = this%viscratios(2, n)
4785 end if
4786 end if
4787 !
4788 ! -- calculate discharge to flowing wells
4789 if (this%iflowingwells > 0) then
4790 if (this%fwcond(n) > dzero) then
4791 bt = this%fwelev(n)
4792 tp = bt + this%fwrlen(n)
4793 scale = sqsaturation(tp, bt, h_temp)
4794 cfw = scale * this%fwcond(n) * this%viscratios(2, n)
4795 this%ifwdischarge(n) = 0
4796 if (cfw > dzero) then
4797 this%ifwdischarge(n) = 1
4798 this%xsto(n) = bt
4799 end if
4800 qnet = qnet + cfw * (bt - h_temp)
4801 end if
4802 end if
4803 !
4804 ! -- calculate maw storage changes
4805 if (this%imawiss /= 1) then
4806 if (this%ifwdischarge(n) /= 1) then
4807 hdterm = this%xoldsto(n) - h_temp
4808 else
4809 hdterm = this%xoldsto(n) - this%fwelev(n)
4810 end if
4811 qnet = qnet - (this%area(n) * hdterm / delt)
4812 end if
4813 !
4814 ! -- calculate inflow from aquifer
4815 do j = 1, this%ngwfnodes(n)
4816 jpos = this%get_jpos(n, j)
4817 if (this%iboundconn(jpos) == 0) cycle
4818 igwfnode = this%get_gwfnode(n, j)
4819 call this%maw_calculate_saturation(n, j, igwfnode, sat)
4820 cmaw = this%satcond(jpos) * vscratio * sat
4821 hgwf = this%xnew(igwfnode)
4822 bmaw = this%botscrn(jpos)
4823 hv = h_temp
4824 if (hv < bmaw) then
4825 hv = bmaw
4826 end if
4827 if (hgwf < bmaw) then
4828 hgwf = bmaw
4829 end if
4830 qnet = qnet + cmaw * (hgwf - hv)
4831 end do
4832 end subroutine maw_calculate_qpot
4833
4834 !> @brief Update MAW satcond and package rhs and hcof
4835 !<
4836 subroutine maw_cfupdate(this)
4837 class(mawtype) :: this
4838 ! -- dummy
4839 ! -- local
4840 integer(I4B) :: j
4841 integer(I4B) :: n
4842 integer(I4B) :: jpos
4843 integer(I4B) :: icflow
4844 integer(I4B) :: ibnd
4845 real(DP) :: flow
4846 real(DP) :: cmaw
4847 real(DP) :: hmaw
4848 real(DP) :: cterm
4849 real(DP) :: term
4850 !
4851 ! -- Return if no maw wells
4852 if (this%nbound .eq. 0) return
4853 !
4854 ! -- Update shutoff count
4855 this%ishutoffcnt = this%ishutoffcnt + 1
4856 !
4857 ! -- Calculate hcof and rhs for each maw entry
4858 ibnd = 1
4859 do n = 1, this%nmawwells
4860 hmaw = this%xnewpak(n)
4861 do j = 1, this%ngwfnodes(n)
4862 jpos = this%get_jpos(n, j)
4863 this%hcof(ibnd) = dzero
4864 this%rhs(ibnd) = dzero
4865 !
4866 ! -- set bound, hcof, and rhs components
4867 !
4868 ! -- use connection method so the gwf-maw budget flows
4869 ! are consistent with the maw-gwf budget flows
4870 if (this%iboundpak(n) == 0 .or. this%iboundconn(jpos) == 0) then
4871 cmaw = dzero
4872 term = dzero
4873 cterm = dzero
4874 else
4875 call this%maw_calculate_conn_terms(n, j, icflow, cmaw, cterm, &
4876 term, flow)
4877 end if
4878 this%simcond(jpos) = cmaw
4879 this%bound(2, ibnd) = cmaw
4880 this%hcof(ibnd) = -term
4881 this%rhs(ibnd) = -term * hmaw + cterm
4882 !
4883 ! -- increment boundary number
4884 ibnd = ibnd + 1
4885 end do
4886 end do
4887 end subroutine maw_cfupdate
4888
4889 !> @brief Set up the budget object that stores all the maw flows
4890 !! The terms listed here must correspond in number and order to the ones
4891 !! listed in the maw_fill_budobj routine.
4892 !<
4893 subroutine maw_setup_budobj(this)
4894 ! -- modules
4895 use constantsmodule, only: lenbudtxt
4896 ! -- dummy
4897 class(mawtype) :: this
4898 ! -- local
4899 integer(I4B) :: nbudterm
4900 integer(I4B) :: n, j, n2
4901 real(DP) :: q
4902 integer(I4B) :: maxlist, naux
4903 integer(I4B) :: idx
4904 character(len=LENBUDTXT) :: text
4905 character(len=LENBUDTXT), dimension(1) :: auxtxt
4906 !
4907 ! -- Determine the number of maw budget terms. These are fixed for
4908 ! the simulation and cannot change.
4909 ! gwf rate [flowing_well] storage constant_flow [frommvr tomvr tomvrcf [tomvrfw]] [aux]
4910 nbudterm = 4
4911 if (this%iflowingwells > 0) then
4912 nbudterm = nbudterm + 1
4913 end if
4914 if (this%imover == 1) then
4915 nbudterm = nbudterm + 3
4916 if (this%iflowingwells > 0) then
4917 nbudterm = nbudterm + 1
4918 end if
4919 end if
4920 if (this%naux > 0) nbudterm = nbudterm + 1
4921 !
4922 ! -- set up budobj
4923 call budgetobject_cr(this%budobj, this%packName)
4924 call this%budobj%budgetobject_df(this%nmawwells, nbudterm, 0, 0, &
4925 ibudcsv=this%ibudcsv)
4926 idx = 0
4927 !
4928 ! -- Go through and set up each budget term
4929 !
4930 ! --
4931 text = ' GWF'
4932 idx = idx + 1
4933 maxlist = this%maxbound
4934 naux = 1
4935 auxtxt(1) = ' FLOW-AREA'
4936 call this%budobj%budterm(idx)%initialize(text, &
4937 this%name_model, &
4938 this%packName, &
4939 this%name_model, &
4940 this%name_model, &
4941 maxlist, .false., .true., &
4942 naux, auxtxt)
4943 call this%budobj%budterm(idx)%reset(this%maxbound)
4944 q = dzero
4945 do n = 1, this%nmawwells
4946 do j = 1, this%ngwfnodes(n)
4947 n2 = this%get_gwfnode(n, j)
4948 call this%budobj%budterm(idx)%update_term(n, n2, q)
4949 end do
4950 end do
4951 !
4952 ! --
4953 text = ' RATE'
4954 idx = idx + 1
4955 maxlist = this%nmawwells
4956 naux = 0
4957 call this%budobj%budterm(idx)%initialize(text, &
4958 this%name_model, &
4959 this%packName, &
4960 this%name_model, &
4961 this%packName, &
4962 maxlist, .false., .false., &
4963 naux)
4964 !
4965 ! --
4966 if (this%iflowingwells > 0) then
4967 text = ' FW-RATE'
4968 idx = idx + 1
4969 maxlist = this%nmawwells
4970 naux = 0
4971 call this%budobj%budterm(idx)%initialize(text, &
4972 this%name_model, &
4973 this%packName, &
4974 this%name_model, &
4975 this%packName, &
4976 maxlist, .false., .false., &
4977 naux)
4978 end if
4979 !
4980 ! --
4981 text = ' STORAGE'
4982 idx = idx + 1
4983 maxlist = this%nmawwells
4984 naux = 1
4985 auxtxt(1) = ' VOLUME'
4986 call this%budobj%budterm(idx)%initialize(text, &
4987 this%name_model, &
4988 this%packName, &
4989 this%name_model, &
4990 this%name_model, &
4991 maxlist, .false., .true., &
4992 naux, auxtxt)
4993 !
4994 ! --
4995 text = ' CONSTANT'
4996 idx = idx + 1
4997 maxlist = this%nmawwells
4998 naux = 0
4999 call this%budobj%budterm(idx)%initialize(text, &
5000 this%name_model, &
5001 this%packName, &
5002 this%name_model, &
5003 this%packName, &
5004 maxlist, .false., .false., &
5005 naux)
5006 !
5007 ! --
5008 if (this%imover == 1) then
5009 !
5010 ! --
5011 text = ' FROM-MVR'
5012 idx = idx + 1
5013 maxlist = this%nmawwells
5014 naux = 0
5015 call this%budobj%budterm(idx)%initialize(text, &
5016 this%name_model, &
5017 this%packName, &
5018 this%name_model, &
5019 this%packName, &
5020 maxlist, .false., .false., &
5021 naux)
5022 !
5023 ! --
5024 text = ' RATE-TO-MVR'
5025 idx = idx + 1
5026 maxlist = this%nmawwells
5027 naux = 0
5028 call this%budobj%budterm(idx)%initialize(text, &
5029 this%name_model, &
5030 this%packName, &
5031 this%name_model, &
5032 this%packName, &
5033 maxlist, .false., .false., &
5034 naux)
5035 !
5036 ! -- constant-head flow to mover
5037 text = ' CONSTANT-TO-MVR'
5038 idx = idx + 1
5039 maxlist = this%nmawwells
5040 naux = 0
5041 call this%budobj%budterm(idx)%initialize(text, &
5042 this%name_model, &
5043 this%packName, &
5044 this%name_model, &
5045 this%packName, &
5046 maxlist, .false., .false., &
5047 naux)
5048 !
5049 ! -- flowing-well flow to mover
5050 if (this%iflowingwells > 0) then
5051 !
5052 ! --
5053 text = ' FW-RATE-TO-MVR'
5054 idx = idx + 1
5055 maxlist = this%nmawwells
5056 naux = 0
5057 call this%budobj%budterm(idx)%initialize(text, &
5058 this%name_model, &
5059 this%packName, &
5060 this%name_model, &
5061 this%packName, &
5062 maxlist, .false., .false., &
5063 naux)
5064 end if
5065 end if
5066 !
5067 ! -- auxiliary variable
5068 naux = this%naux
5069 if (naux > 0) then
5070 !
5071 ! --
5072 text = ' AUXILIARY'
5073 idx = idx + 1
5074 maxlist = this%maxbound
5075 call this%budobj%budterm(idx)%initialize(text, &
5076 this%name_model, &
5077 this%packName, &
5078 this%name_model, &
5079 this%packName, &
5080 maxlist, .false., .false., &
5081 naux, this%auxname)
5082 end if
5083 !
5084 ! -- if maw flow for each reach are written to the listing file
5085 if (this%iprflow /= 0) then
5086 call this%budobj%flowtable_df(this%iout)
5087 end if
5088 end subroutine maw_setup_budobj
5089
5090 !> @brief Copy flow terms into this%budobj
5091 !!
5092 !! terms include a combination of the following:
5093 !! gwf rate [flowing_well] [storage] constant_flow [frommvr tomvr tomvrcf [tomvrfw]] [aux]
5094 !<
5095 subroutine maw_fill_budobj(this)
5096 ! -- modules
5097 ! -- dummy
5098 class(mawtype) :: this
5099 ! -- local
5100 integer(I4B) :: naux
5101 integer(I4B) :: j
5102 integer(I4B) :: n
5103 integer(I4B) :: n2
5104 integer(I4B) :: jpos
5105 integer(I4B) :: idx
5106 integer(I4B) :: ibnd
5107 real(DP) :: q
5108 real(DP) :: tmaw
5109 real(DP) :: bmaw
5110 real(DP) :: sat
5111 real(DP) :: qfact
5112 real(DP) :: q2
5113 real(DP) :: b
5114 real(DP) :: v
5115 ! -- formats
5116 !
5117 ! -- initialize counter
5118 idx = 0
5119 !
5120 ! -- GWF (LEAKAGE) and connection surface area (aux)
5121 idx = idx + 1
5122 call this%budobj%budterm(idx)%reset(this%maxbound)
5123 ibnd = 1
5124 do n = 1, this%nmawwells
5125 do j = 1, this%ngwfnodes(n)
5126 jpos = this%get_jpos(n, j)
5127 n2 = this%get_gwfnode(n, j)
5128 !
5129 ! -- a connection that is not simulated has no wetted area, so it
5130 ! exchanges no heat by conduction with the aquifer (MWE)
5131 if (this%iboundpak(n) == 0 .or. this%iboundconn(jpos) == 0) then
5132 this%qauxcbc(1) = dzero
5133 else
5134 tmaw = this%topscrn(jpos)
5135 bmaw = this%botscrn(jpos)
5136 call this%maw_calculate_saturation(n, j, n2, sat)
5137 this%qauxcbc(1) = dtwo * dpi * this%radius(n) * sat * (tmaw - bmaw)
5138 end if
5139 q = this%qleak(ibnd)
5140 call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc)
5141 ibnd = ibnd + 1
5142 end do
5143 end do
5144 !
5145 ! -- RATE (WITHDRAWAL RATE)
5146 idx = idx + 1
5147 call this%budobj%budterm(idx)%reset(this%nmawwells)
5148 do n = 1, this%nmawwells
5149 q = this%ratesim(n)
5150 !
5151 ! -- adjust if well rate is an outflow
5152 if (this%imover == 1 .and. q < dzero) then
5153 qfact = done
5154 if (this%qout(n) < dzero) then
5155 qfact = q / this%qout(n)
5156 end if
5157 q = q + qfact * this%pakmvrobj%get_qtomvr(n)
5158 end if
5159 call this%budobj%budterm(idx)%update_term(n, n, q)
5160 end do
5161 !
5162 ! -- FLOWING WELL
5163 if (this%iflowingwells > 0) then
5164 idx = idx + 1
5165 call this%budobj%budterm(idx)%reset(this%nmawwells)
5166 do n = 1, this%nmawwells
5167 q = this%qfw(n)
5168 if (this%imover == 1) then
5169 qfact = done
5170 !
5171 ! -- adjust if well rate is an outflow
5172 if (this%qout(n) < dzero) then
5173 qfact = q / this%qout(n)
5174 end if
5175 q = q + qfact * this%pakmvrobj%get_qtomvr(n)
5176 end if
5177 call this%budobj%budterm(idx)%update_term(n, n, q)
5178 end do
5179 end if
5180 !
5181 ! -- STORAGE (AND VOLUME AS AUX)
5182 idx = idx + 1
5183 call this%budobj%budterm(idx)%reset(this%nmawwells)
5184 do n = 1, this%nmawwells
5185 b = this%xsto(n) - this%bot(n)
5186 if (b < dzero) then
5187 b = dzero
5188 end if
5189 v = this%area(n) * b
5190 if (this%imawissopt /= 1) then
5191 q = this%qsto(n)
5192 else
5193 q = dzero
5194 end if
5195 this%qauxcbc(1) = v
5196 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
5197 end do
5198 !
5199 ! -- CONSTANT FLOW
5200 idx = idx + 1
5201 call this%budobj%budterm(idx)%reset(this%nmawwells)
5202 do n = 1, this%nmawwells
5203 q = this%qconst(n)
5204 !
5205 ! -- adjust if constant-flow rate is an outflow
5206 if (this%imover == 1 .and. q < dzero) then
5207 qfact = done
5208 if (this%qout(n) < dzero) then
5209 qfact = q / this%qout(n)
5210 end if
5211 q = q + qfact * this%pakmvrobj%get_qtomvr(n)
5212 end if
5213 call this%budobj%budterm(idx)%update_term(n, n, q)
5214 end do
5215 !
5216 ! -- MOVER
5217 if (this%imover == 1) then
5218 !
5219 ! -- FROM MOVER
5220 idx = idx + 1
5221 call this%budobj%budterm(idx)%reset(this%nmawwells)
5222 do n = 1, this%nmawwells
5223 if (this%iboundpak(n) == 0) then
5224 q = dzero
5225 else
5226 q = this%pakmvrobj%get_qfrommvr(n)
5227 end if
5228 call this%budobj%budterm(idx)%update_term(n, n, q)
5229 end do
5230 !
5231 ! -- RATE TO MOVER
5232 idx = idx + 1
5233 call this%budobj%budterm(idx)%reset(this%nmawwells)
5234 do n = 1, this%nmawwells
5235 q = this%pakmvrobj%get_qtomvr(n)
5236 if (q > dzero) then
5237 q = -q
5238 q2 = this%ratesim(n)
5239 !
5240 ! -- adjust TO MOVER if well rate is outflow
5241 if (q2 < dzero) then
5242 qfact = q2 / this%qout(n)
5243 q = q * qfact
5244 else
5245 q = dzero
5246 end if
5247 end if
5248 call this%budobj%budterm(idx)%update_term(n, n, q)
5249 end do
5250 !
5251 ! -- CONSTANT TO MOVER
5252 idx = idx + 1
5253 call this%budobj%budterm(idx)%reset(this%nmawwells)
5254 do n = 1, this%nmawwells
5255 q = this%pakmvrobj%get_qtomvr(n)
5256 if (q > dzero) then
5257 q = -q
5258 q2 = this%qconst(n)
5259 ! -- adjust TO MOVER if well rate is outflow
5260 if (q2 < dzero) then
5261 qfact = q2 / this%qout(n)
5262 q = q * qfact
5263 else
5264 q = dzero
5265 end if
5266 end if
5267 call this%budobj%budterm(idx)%update_term(n, n, q)
5268 end do
5269 !
5270 ! -- FLOWING WELL TO MOVER
5271 if (this%iflowingwells > 0) then
5272 idx = idx + 1
5273 call this%budobj%budterm(idx)%reset(this%nmawwells)
5274 do n = 1, this%nmawwells
5275 q = this%pakmvrobj%get_qtomvr(n)
5276 if (q > dzero) then
5277 q = -q
5278 q2 = this%ratesim(n)
5279 !
5280 ! -- adjust TO MOVER if well rate is outflow
5281 qfact = done
5282 if (this%qout(n) < dzero) then
5283 qfact = this%qfw(n) / this%qout(n)
5284 end if
5285 q = q * qfact
5286 end if
5287 call this%budobj%budterm(idx)%update_term(n, n, q)
5288 end do
5289 end if
5290
5291 end if
5292 !
5293 ! -- AUXILIARY VARIABLES
5294 naux = this%naux
5295 if (naux > 0) then
5296 idx = idx + 1
5297 call this%budobj%budterm(idx)%reset(this%nmawwells)
5298 do n = 1, this%nmawwells
5299 q = dzero
5300 call this%budobj%budterm(idx)%update_term(n, n, q, this%auxvar(:, n))
5301 end do
5302 end if
5303 !
5304 ! --Terms are filled, now accumulate them for this time step
5305 call this%budobj%accumulate_terms()
5306 end subroutine maw_fill_budobj
5307
5308 !> @brief Set up the table object that is used to write the maw head data
5309 !!
5310 !! The terms listed here must correspond in number and order to the ones
5311 !! written to the head table in the maw_ot method.
5312 !<
5313 subroutine maw_setup_tableobj(this)
5314 ! -- modules
5316 ! -- dummy
5317 class(mawtype) :: this
5318 ! -- local
5319 integer(I4B) :: nterms
5320 character(len=LINELENGTH) :: title
5321 character(len=LINELENGTH) :: text
5322 !
5323 ! -- setup well head table
5324 if (this%iprhed > 0) then
5325 !
5326 ! -- Determine the number of head table columns
5327 nterms = 2
5328 if (this%inamedbound == 1) nterms = nterms + 1
5329 !
5330 ! -- set up table title
5331 title = trim(adjustl(this%text))//' PACKAGE ('// &
5332 trim(adjustl(this%packName))//') HEADS FOR EACH CONTROL VOLUME'
5333 !
5334 ! -- set up head tableobj
5335 call table_cr(this%headtab, this%packName, title)
5336 call this%headtab%table_df(this%nmawwells, nterms, this%iout, &
5337 transient=.true.)
5338 !
5339 ! -- Go through and set up table budget term
5340 if (this%inamedbound == 1) then
5341 text = 'NAME'
5342 call this%headtab%initialize_column(text, 20, alignment=tableft)
5343 end if
5344 !
5345 ! -- reach number
5346 text = 'NUMBER'
5347 call this%headtab%initialize_column(text, 10, alignment=tabcenter)
5348 !
5349 ! -- reach stage
5350 text = 'HEAD'
5351 call this%headtab%initialize_column(text, 12, alignment=tabcenter)
5352 end if
5353 end subroutine maw_setup_tableobj
5354
5355 !> @brief Get position of value in connection data
5356 !<
5357 function get_jpos(this, n, j) result(jpos)
5358 ! -- return variable
5359 integer(I4B) :: jpos
5360 ! -- dummy
5361 class(mawtype) :: this
5362 integer(I4B), intent(in) :: n
5363 integer(I4B), intent(in) :: j
5364 ! -- local
5365 !
5366 ! -- set jpos
5367 jpos = this%iaconn(n) + j - 1
5368 end function get_jpos
5369
5370 !> @brief Get the gwfnode for connection
5371 !<
5372 function get_gwfnode(this, n, j) result(igwfnode)
5373 ! -- return variable
5374 integer(I4B) :: igwfnode
5375 ! -- dummy
5376 class(mawtype) :: this
5377 integer(I4B), intent(in) :: n
5378 integer(I4B), intent(in) :: j
5379 ! -- local
5380 integer(I4B) :: jpos
5381 !
5382 ! -- set jpos
5383 jpos = this%get_jpos(n, j)
5384 igwfnode = this%gwfnodes(jpos)
5385 end function get_gwfnode
5386
5387 !> @brief Activate density terms
5388 !<
5389 subroutine maw_activate_density(this)
5390 ! -- dummy
5391 class(mawtype), intent(inout) :: this
5392 ! -- local
5393 integer(I4B) :: i, j
5394 ! -- formats
5395 !
5396 ! -- Set idense and reallocate denseterms to be of size MAXBOUND
5397 this%idense = 1
5398 call mem_reallocate(this%denseterms, 3, this%MAXBOUND, 'DENSETERMS', &
5399 this%memoryPath)
5400 do i = 1, this%maxbound
5401 do j = 1, 3
5402 this%denseterms(j, i) = dzero
5403 end do
5404 end do
5405 write (this%iout, '(/1x,a)') 'DENSITY TERMS HAVE BEEN ACTIVATED FOR MAW &
5406 &PACKAGE: '//trim(adjustl(this%packName))
5407 end subroutine maw_activate_density
5408
5409 !> @brief Activate viscosity terms
5410 !!
5411 !! Method to activate addition of viscosity terms for a MAW package reach.
5412 !<
5413 subroutine maw_activate_viscosity(this)
5414 ! -- modules
5416 ! -- dummy variables
5417 class(mawtype), intent(inout) :: this !< MawType object
5418 ! -- local variables
5419 integer(I4B) :: i
5420 integer(I4B) :: j
5421 !
5422 ! -- Set ivsc and reallocate viscratios to be of size MAXBOUND
5423 this%ivsc = 1
5424 call mem_reallocate(this%viscratios, 2, this%MAXBOUND, 'VISCRATIOS', &
5425 this%memoryPath)
5426 do i = 1, this%maxbound
5427 do j = 1, 2
5428 this%viscratios(j, i) = done
5429 end do
5430 end do
5431 write (this%iout, '(/1x,a)') 'VISCOSITY HAS BEEN ACTIVATED FOR MAW &
5432 &PACKAGE: '//trim(adjustl(this%packName))
5433 end subroutine maw_activate_viscosity
5434
5435 !> @brief Calculate the groundwater-maw density exchange terms
5436 !!
5437 !! Arguments are as follows:
5438 !! iconn : maw-gwf connection number
5439 !! hmaw : maw head
5440 !! hgwf : gwf head
5441 !! cond : conductance
5442 !! bmaw : bottom elevation of this connection
5443 !! flow : calculated flow, updated here with density terms, + into maw
5444 !! hcofterm : head coefficient term
5445 !! rhsterm : right-hand-side value, updated here with density terms
5446 !!
5447 !! Member variable used here
5448 !! denseterms : shape (3, MAXBOUND), filled by buoyancy package
5449 !! col 1 is relative density of maw (densemaw / denseref)
5450 !! col 2 is relative density of gwf cell (densegwf / denseref)
5451 !! col 3 is elevation of gwf cell
5452 !!
5453 !! Upon return, amat and rhs for maw row should be updated as:
5454 !! amat(idiag) = amat(idiag) - hcofterm
5455 !! rhs(n) = rhs(n) + rhsterm
5456 !<
5457 subroutine maw_calculate_density_exchange(this, iconn, hmaw, hgwf, cond, &
5458 bmaw, flow, hcofterm, rhsterm)
5459 ! -- dummy
5460 class(mawtype), intent(inout) :: this
5461 integer(I4B), intent(in) :: iconn
5462 real(DP), intent(in) :: hmaw
5463 real(DP), intent(in) :: hgwf
5464 real(DP), intent(in) :: cond
5465 real(DP), intent(in) :: bmaw
5466 real(DP), intent(inout) :: flow
5467 real(DP), intent(inout) :: hcofterm
5468 real(DP), intent(inout) :: rhsterm
5469 ! -- local
5470 real(DP) :: t
5471 real(DP) :: havg
5472 real(DP) :: rdensemaw
5473 real(DP) :: rdensegwf
5474 real(DP) :: rdenseavg
5475 real(DP) :: elevavg
5476 ! -- formats
5477 !
5478 ! -- assign relative density terms, return if zero which means not avail yet
5479 rdensemaw = this%denseterms(1, iconn)
5480 rdensegwf = this%denseterms(2, iconn)
5481 if (rdensegwf == dzero) return
5482 !
5483 ! -- update rhsterm with density contribution
5484 if (hmaw > bmaw .and. hgwf > bmaw) then
5485 !
5486 ! -- hmaw and hgwf both above bmaw
5487 rdenseavg = dhalf * (rdensemaw + rdensegwf)
5488 !
5489 ! -- update rhsterm with first density term
5490 t = cond * (rdenseavg - done) * (hgwf - hmaw)
5491 rhsterm = rhsterm + t
5492 flow = flow + t
5493 !
5494 ! -- update rhterm with second density term
5495 havg = dhalf * (hgwf + hmaw)
5496 elevavg = this%denseterms(3, iconn)
5497 t = cond * (havg - elevavg) * (rdensegwf - rdensemaw)
5498 rhsterm = rhsterm + t
5499 flow = flow + t
5500 else if (hmaw > bmaw) then
5501 !
5502 ! -- if only hmaw is above bmaw, then increase correction term by density
5503 t = (rdensemaw - done) * rhsterm
5504 rhsterm = rhsterm + t
5505 !
5506 else if (hgwf > bmaw) then
5507 !
5508 ! -- if only hgwf is above bmaw, then increase correction term by density
5509 t = (rdensegwf - done) * rhsterm
5510 rhsterm = rhsterm + t
5511 !
5512 else
5513 !
5514 ! -- Flow should be zero so do nothing
5515 end if
5516 end subroutine maw_calculate_density_exchange
5517
5518end module mawmodule
subroutine init()
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_nur(this, neqpak, x, xtemp, dx, inewtonur, dxmax, locmax)
Apply Newton-Raphson under-relaxation for package.
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_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 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_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 budgetobject_cr(this, name)
Create a new budget object.
subroutine destroy(this)
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
real(dp), parameter dp9
real constant 9/10
Definition Constants.f90:72
real(dp), parameter deight
real constant 8
Definition Constants.f90:83
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
@ disu
DISV6 discretization.
@ dis
DIS6 discretization.
@ disv
DISU6 discretization.
real(dp), parameter dtwopi
real constant
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
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 lenauxname
maximum length of a aux variable
Definition Constants.f90:35
real(dp), parameter dpi
real constant
integer(i4b), parameter lenboundname
maximum length of a bound name
Definition Constants.f90:36
real(dp), parameter dpio180
real constant
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 dp7
real constant 7/10
Definition Constants.f90:71
real(dp), parameter dem9
real constant 1e-9
real(dp), parameter dem2
real constant 1e-2
real(dp), parameter dtwo
real constant 2
Definition Constants.f90:79
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition Constants.f90:37
real(dp), parameter dquarter
real constant 1/3
Definition Constants.f90:66
real(dp), parameter done
real constant 1
Definition Constants.f90:76
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
Definition GeomUtil.f90:92
real(dp) function, public area(xv, yv, cw)
Calculate polygon area, with vertices given in CW or CCW order.
Definition GeomUtil.f90:364
pure real(dp) function, public polygon_extent(xv, yv)
Calculate the maximum distance between two polygon vertices.
Definition GeomUtil.f90:388
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).
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
pure logical function, public is_close(a, b, rtol, atol, symmetric)
Check if a real value is approximately equal to another.
Definition MathUtil.f90:46
subroutine maw_fill_budobj(this)
Copy flow terms into thisbudobj.
Definition gwf-maw.f90:5096
subroutine maw_source_dimensions(this)
Source DIMENSIONS block from input context.
Definition gwf-maw.f90:788
subroutine maw_rp(this)
Read and Prepare.
Definition gwf-maw.f90:2123
subroutine maw_set_period_value(this, n, imaw, setting)
Apply a PERIOD setting value to well imaw.
Definition gwf-maw.f90:1913
subroutine maw_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
Extra convergence check for the MAW package.
Definition gwf-maw.f90:3169
integer(i4b) function get_gwfnode(this, n, j)
Get the gwfnode for connection.
Definition gwf-maw.f90:5373
subroutine maw_cf(this)
Formulate the HCOF and RHS terms.
Definition gwf-maw.f90:2701
subroutine maw_ot_bdsummary(this, kstp, kper, iout, ibudfl)
Write MAW budget to listing file.
Definition gwf-maw.f90:3522
subroutine maw_activate_viscosity(this)
Activate viscosity terms.
Definition gwf-maw.f90:5414
subroutine maw_read_initial_attr(this)
Read the initial parameters for this package.
Definition gwf-maw.f90:1651
subroutine maw_bd_obs(this)
Calculate observations this time step and call ObsTypeSaveOneSimval for each MawType observation.
Definition gwf-maw.f90:3805
subroutine maw_ar(this)
Allocate and Read.
Definition gwf-maw.f90:2090
subroutine maw_set_attribute_error(this, imaw, keyword, msg)
Issue a parameter error for mawweslls(imaw).
Definition gwf-maw.f90:1888
subroutine maw_ad(this)
Add package connection to matrix.
Definition gwf-maw.f90:2613
subroutine maw_calculate_conn_terms(this, n, j, icflow, cmaw, cterm, term, flow, term2)
Calculate matrix terms for a multi-aquifer well connection. Terms for fc and fn methods are calculate...
Definition gwf-maw.f90:4435
pure real(dp) function, public maw_screen_length(dz, radius, omega)
In-cell screen length of a non-vertical well connection.
Definition gwf-maw.f90:1554
subroutine maw_calculate_density_exchange(this, iconn, hmaw, hgwf, cond, bmaw, flow, hcofterm, rhsterm)
Calculate the groundwater-maw density exchange terms.
Definition gwf-maw.f90:5459
subroutine maw_calculate_wellq(this, n, hmaw, q)
Calculate well pumping rate based on constraints.
Definition gwf-maw.f90:4585
subroutine maw_source_connectiondata(this)
Source CONNECTIONDATA block from input context.
Definition gwf-maw.f90:1063
subroutine maw_rp_obs(this)
Process each observation.
Definition gwf-maw.f90:3944
character(len=lenpackagename) text
Definition gwf-maw.f90:46
subroutine maw_allocate_scalars(this)
Allocate scalar members.
Definition gwf-maw.f90:340
subroutine maw_source_angledata(this)
Source ANGLEDATA block from input context for non-vertical MAW connections.
Definition gwf-maw.f90:1298
subroutine maw_calculate_saturation(this, n, j, node, sat, hwell_in)
Calculate the saturation between the aquifer maw well_head.
Definition gwf-maw.f90:4361
subroutine maw_calculate_qpot(this, n, qnet)
Calculate groundwater inflow to a maw well.
Definition gwf-maw.f90:4750
subroutine maw_ot_model_flows(this, icbcfl, ibudfl, icbcun, imap)
Write flows to binary file and/or print flows to budget.
Definition gwf-maw.f90:3427
subroutine maw_set_pointers(this, neq, ibound, xnew, xold, flowja)
Set pointers to model arrays and variables so that a package has has access to these things.
Definition gwf-maw.f90:3690
subroutine maw_activate_density(this)
Activate density terms.
Definition gwf-maw.f90:5390
integer(i4b) function get_jpos(this, n, j)
Get position of value in connection data.
Definition gwf-maw.f90:5358
subroutine maw_fn(this, rhs, ia, idxglo, matrix_sln)
Fill newton terms.
Definition gwf-maw.f90:2882
subroutine maw_ot_package_flows(this, icbcfl, ibudfl)
Output MAW package flow terms.
Definition gwf-maw.f90:3441
subroutine maw_allocate_well_conn_arrays(this)
Allocate well arrays.
Definition gwf-maw.f90:395
subroutine maw_source_options(this)
Source OPTIONS block from input context.
Definition gwf-maw.f90:655
logical function maw_obs_supported(this)
Return true because MAW package supports observations.
Definition gwf-maw.f90:3730
pure real(dp) function, public maw_damp_weight(dxprop, dxold, weight, damptheta, damptol, weightmin, recover)
Update the oscillation-damping weight for a single MAW well head.
Definition gwf-maw.f90:3139
subroutine maw_allocate_arrays(this)
Allocate arrays.
Definition gwf-maw.f90:605
subroutine maw_input_destroy(this)
Nullify all MawInputType pointers.
Definition gwf-maw.f90:875
subroutine, public maw_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath)
Create a New Multi-Aquifer Well (MAW) Package.
Definition gwf-maw.f90:302
subroutine maw_cfupdate(this)
Update MAW satcond and package rhs and hcof.
Definition gwf-maw.f90:4837
subroutine maw_redflow_csv_write(this)
MAW reduced flows only when & where they occur.
Definition gwf-maw.f90:4162
subroutine maw_redflow_csv_init(this, fname)
Initialize the auto flow reduce csv output file.
Definition gwf-maw.f90:4142
subroutine maw_input_init(this, mempath, naux)
Bind MawInputType pointers to input context arrays.
Definition gwf-maw.f90:848
real(dp) function maw_calc_lcorr(this, i, jpos)
Calculate the length correction factor for a multi-aquifer well connection.
Definition gwf-maw.f90:1612
subroutine maw_source_packagedata(this)
Source PACKAGEDATA block from input context.
Definition gwf-maw.f90:900
subroutine maw_mc(this, moffset, matrix_sln)
Map package connection to matrix.
Definition gwf-maw.f90:2030
subroutine maw_nur(this, neqpak, x, xtemp, dx, inewtonur, dxmax, locmax)
Apply Newton under-relaxation to the MAW Package well heads.
Definition gwf-maw.f90:3054
subroutine maw_check_attributes(this)
Issue parameter errors for mawwells(imaw).
Definition gwf-maw.f90:1929
subroutine maw_ac(this, moffset, sparse)
Add package connection to matrix.
Definition gwf-maw.f90:2000
subroutine maw_ot_dv(this, idvsave, idvprint)
Save maw-calculated values to binary file.
Definition gwf-maw.f90:3467
subroutine maw_fc(this, rhs, ia, idxglo, matrix_sln)
Copy rhs and hcof into solution rhs and amat.
Definition gwf-maw.f90:2712
real(dp) function maw_cell_extent(this, node, estimated)
Maximum horizontal extent of a cell.
Definition gwf-maw.f90:1571
character(len=lenftype) ftype
Definition gwf-maw.f90:45
subroutine maw_checkin_deprecated_names(this)
Alias deprecated MAW variable names to their current storage.
Definition gwf-maw.f90:626
subroutine define_listlabel(this)
Define the list heading that is written to iout when PRINT_INPUT option is used.
Definition gwf-maw.f90:3666
subroutine maw_setup_budobj(this)
Set up the budget object that stores all the maw flows The terms listed here must correspond in numbe...
Definition gwf-maw.f90:4894
subroutine maw_cq(this, x, flowja, iadv)
Calculate flows.
Definition gwf-maw.f90:3292
subroutine maw_df_obs(this)
Store observation type supported by MAW package.
Definition gwf-maw.f90:3740
subroutine maw_calculate_satcond(this, i, j, node)
Calculate the appropriate saturated conductance to use based on aquifer and multi-aquifer well charac...
Definition gwf-maw.f90:4190
subroutine maw_da(this)
Deallocate memory.
Definition gwf-maw.f90:3537
subroutine maw_process_obsid(obsrv, dis, inunitobs, iout)
This procedure is pointed to by ObsDataTypeProcesssIdPtr. It processes the ID string of an observatio...
Definition gwf-maw.f90:4090
subroutine maw_setup_tableobj(this)
Set up the table object that is used to write the maw head data.
Definition gwf-maw.f90:5314
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.
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
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_warning(msg, substring)
Store warning message.
Definition Sim.f90:241
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
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=maxcharlen) warnmsg
warning message string
integer(i4b) iout
file unit number for simulation output
real(dp) function squadraticsaturation(top, bot, x, eps)
sQuadraticSaturation
real(dp) function squadraticsaturationderivative(top, bot, x, eps)
Derivative of the quadratic saturation function.
real(dp) function sqsaturationderivative(top, bot, x, c1, c2)
sQSaturationDerivative
real(dp) function squadratic0spderivative(x, xi, tomega)
sQuadratic0spDerivative
real(dp) function sqsaturation(top, bot, x, c1, c2)
sQSaturation
real(dp) function squadratic0sp(x, xi, tomega)
sQuadratic0sp
This module contains the SourceCommonModule.
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
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
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 ...
input context data pointers for MAW.
Definition gwf-maw.f90:58