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

Data Types

type  gwfnpftype
type  defaultflowformulationtype
 Default conductance flow formulation. More...

Functions/Subroutines

subroutine, public npf_cr (npfobj, name_model, input_mempath, inunit, iout)
 Create a new NPF object. Pass a inunit value of 0 if npf data will initialized from memory.
subroutine npf_df (this, dis, xt3d, ingnc, invsc, npf_options)
 Define the NPF package instance.
subroutine npf_ac (this, moffset, sparse)
 Add connections for extended neighbors to the sparse matrix.
subroutine npf_mc (this, moffset, matrix_sln)
 Map connections and construct iax, jax, and idxglox.
subroutine npf_ar (this, ic, vsc, ibound, hnew)
 Allocate and read this NPF instance.
subroutine npf_rp (this)
 Read and prepare method for package.
subroutine npf_ad (this, nodes, hold, hnew, irestore)
 Advance.
subroutine npf_cf (this, kiter, nodes, hnew)
 Calculate coefficients.
subroutine default_flow_cf (this, kiter)
 Calculate coefficients for the default conductance formulation.
subroutine cf_default_flow (this, kiter, n)
 Calculate coefficients using the.
subroutine npf_fc (this, kiter, matrix_sln, idxglo, rhs, hnew)
 Formulate coefficients.
subroutine fc_default_flow (this, n, m, ipos, matrix_sln, rhs, idxglo, hnew)
 Calculate and add coefficients using the.
subroutine default_flow_fc (this, kiter, matrix_sln, idxglo, rhs, hnew)
 Fill coefficients for the default conductance formulation.
subroutine highest_cell_saturation (this, n, m, hn, hm, satn, satm)
 Calculate dry cell saturation.
subroutine npf_fn (this, kiter, matrix_sln, idxglo, rhs, hnew)
 Fill newton terms.
subroutine default_flow_fn (this, kiter, matrix_sln, idxglo, rhs, hnew)
 Fill newton terms for the default conductance formulation.
subroutine fn_default_flow (this, n, m, ipos, matrix_sln, rhs, idxglo, hnew)
subroutine npf_nur (this, neqmod, x, xtemp, dx, inewtonur, dxmax, locmax)
 Under-relaxation.
subroutine npf_cq (this, hnew, flowja)
 Calculate flowja.
subroutine default_flow_cq (this, hnew, flowja)
 Calculate flows for the default conductance formulation.
subroutine cq_default_flow (this, n, m, ipos, flowja, hnew)
subroutine sgwf_npf_thksat (this, n, hn, thksat)
 Fractional cell saturation.
subroutine sgwf_npf_qcalc (this, n, m, hn, hm, icon, qnm)
 Flow between two cells.
subroutine npf_save_model_flows (this, flowja, icbcfl, icbcun)
 Record flowja and calculate specific discharge if requested.
subroutine npf_print_model_flows (this, ibudfl, flowja)
 Print budget.
subroutine npf_da (this)
 Deallocate variables.
subroutine allocate_scalars (this)
 Allocate scalars.
subroutine store_original_k_arrays (this, ncells, njas)
 Store backup copy of hydraulic conductivity when the VSC package is activate.
subroutine allocate_arrays (this, ncells, njas)
 Allocate npf arrays.
subroutine log_options (this, found)
 Log npf options sourced from the input mempath.
subroutine source_options (this)
 Update simulation options from input mempath.
subroutine set_options (this, options)
 Set options in the NPF object.
subroutine check_options (this)
 Check for conflicting NPF options.
subroutine log_griddata (this, found)
 Write dimensions to list file.
subroutine source_griddata (this)
 Update simulation griddata from input mempath.
subroutine prepcheck (this)
 Initialize and check NPF data.
subroutine preprocess_input (this)
 preprocess the NPF input data
subroutine calc_condsat (this, node, upperonly)
 Calculate CONDSAT array entries for the given node.
real(dp) function calc_initial_sat (this, n)
 Calculate initial saturation for the given node.
subroutine sgwf_npf_wetdry (this, kiter, hnew)
 Perform wetting and drying.
subroutine rewet_check (this, kiter, node, hm, ibdm, ihc, hnew, irewet)
 Determine if a cell should rewet.
subroutine sgwf_npf_wdmsg (this, icode, ncnvrt, nodcnvrt, acnvrt, ihdcnv, kiter, n)
 Print wet/dry message.
real(dp) function hy_eff (this, n, m, ihc, ipos, vg)
 Calculate the effective hydraulic conductivity for the n-m connection.
subroutine calc_spdis (this, flowja)
 Calculate the 3 components of specific discharge at the cell center.
subroutine sav_spdis (this, ibinun)
 Save specific discharge in binary format to ibinun.
subroutine sav_sat (this, ibinun)
 Save saturation in binary format to ibinun.
subroutine increase_edge_count (this, nedges)
 Reserve space for nedges cells that have an edge on them.
integer(i4b) function calc_max_conns (this)
 Calculate the maximum number of connections for any cell.
subroutine set_edge_properties (this, nodedge, ihcedge, q, area, nx, ny, distance)
 Provide the npf package with edge properties.
subroutine prepare_edge_lookup (this)
real(dp) function calcsatthickness (this, n, m, ihc)
 Calculate saturated thickness between cell n and m.
subroutine add_flow_formulation (this, npf_form, form_id)

Function/Subroutine Documentation

◆ add_flow_formulation()

subroutine gwfnpfmodule::add_flow_formulation ( class(gwfnpftype), intent(inout) this,
class(gwfnpfformulationtype), pointer npf_form,
integer(i4b) form_id )
private
Parameters
[in,out]thisthis NPF instance
npf_formthe extended flow calculator
form_idthe id for the flow formulation

Definition at line 3134 of file gwf-npf.f90.

3135 class(GwfNpfType), intent(inout) :: this !< this NPF instance
3136 class(GwfNpfFormulationType), pointer :: npf_form !< the extended flow calculator
3137 integer(I4B) :: form_id !< the id for the flow formulation
3138
3139 this%flow_formulations(form_id)%form => npf_form
3140

◆ allocate_arrays()

subroutine gwfnpfmodule::allocate_arrays ( class(gwfnpftype), target this,
integer(i4b), intent(in) ncells,
integer(i4b), intent(in) njas )
private

Definition at line 1438 of file gwf-npf.f90.

1439 ! -- dummy
1440 class(GwfNpftype), target :: this
1441 integer(I4B), intent(in) :: ncells
1442 integer(I4B), intent(in) :: njas
1443 ! -- local
1444 integer(I4B) :: n
1445 !
1446 call mem_allocate(this%ithickstartflag, ncells, 'ITHICKSTARTFLAG', &
1447 this%memoryPath)
1448 call mem_allocate(this%icelltype, ncells, 'ICELLTYPE', this%memoryPath)
1449 call mem_allocate(this%k11, ncells, 'K11', this%memoryPath)
1450 call mem_allocate(this%krel, ncells, 'KREL', this%memoryPath)
1451 call mem_allocate(this%sat, ncells, 'SAT', this%memoryPath)
1452 call mem_allocate(this%condsat, njas, 'CONDSAT', this%memoryPath)
1453 !
1454 ! -- Optional arrays dimensioned to full size initially
1455 call mem_allocate(this%k22, ncells, 'K22', this%memoryPath)
1456 call mem_allocate(this%k33, ncells, 'K33', this%memoryPath)
1457 call mem_allocate(this%wetdry, ncells, 'WETDRY', this%memoryPath)
1458 call mem_allocate(this%angle1, ncells, 'ANGLE1', this%memoryPath)
1459 call mem_allocate(this%angle2, ncells, 'ANGLE2', this%memoryPath)
1460 call mem_allocate(this%angle3, ncells, 'ANGLE3', this%memoryPath)
1461 !
1462 ! -- Optional arrays
1463 call mem_allocate(this%ibotnode, 0, 'IBOTNODE', this%memoryPath)
1464 call mem_allocate(this%nodedge, 0, 'NODEDGE', this%memoryPath)
1465 call mem_allocate(this%ihcedge, 0, 'IHCEDGE', this%memoryPath)
1466 call mem_allocate(this%propsedge, 0, 0, 'PROPSEDGE', this%memoryPath)
1467 call mem_allocate(this%iedge_ptr, 0, 'NREDGESNODE', this%memoryPath)
1468 call mem_allocate(this%edge_idxs, 0, 'EDGEIDXS', this%memoryPath)
1469 !
1470 ! -- Optional arrays only needed when vsc package is active
1471 call mem_allocate(this%k11input, 0, 'K11INPUT', this%memoryPath)
1472 call mem_allocate(this%k22input, 0, 'K22INPUT', this%memoryPath)
1473 call mem_allocate(this%k33input, 0, 'K33INPUT', this%memoryPath)
1474 !
1475 ! -- Specific discharge is (re-)allocated when nedges is known
1476 call mem_allocate(this%spdis, 3, 0, 'SPDIS', this%memoryPath)
1477 !
1478 ! -- Time-varying property flag arrays
1479 call mem_allocate(this%nodekchange, ncells, 'NODEKCHANGE', this%memoryPath)
1480 !
1481 call mem_allocate(this%iformulation, this%dis%con%nja, 'IFORM', &
1482 this%memoryPath)
1483 !
1484 ! -- set to standard NPF flow
1485 do n = 1, size(this%iformulation)
1486 this%iformulation(n) = default_flow
1487 end do
1488 !
1489 ! -- create the default conductance formulation and point it at this package
1490 allocate (defaultflowformulationtype :: this%default_form)
1491 select type (form => this%default_form)
1492 type is (defaultflowformulationtype)
1493 form%npf => this
1494 end select
1495 !
1496 ! -- initialize iangle1, iangle2, iangle3, and wetdry
1497 do n = 1, ncells
1498 this%angle1(n) = dzero
1499 this%angle2(n) = dzero
1500 this%angle3(n) = dzero
1501 this%wetdry(n) = dzero
1502 this%nodekchange(n) = dzero
1503 this%krel(n) = done
1504 end do
1505 !
1506 ! -- allocate variable names
1507 allocate (this%aname(this%iname))
1508 this%aname = [' ICELLTYPE', ' K', &
1509 ' K33', ' K22', &
1510 ' WETDRY', ' ANGLE1', &
1511 ' ANGLE2', ' ANGLE3']

◆ allocate_scalars()

subroutine gwfnpfmodule::allocate_scalars ( class(gwfnpftype) this)
private

Allocate and initialize scalars for the VSC package. The base model allocate scalars method is also called.

Definition at line 1319 of file gwf-npf.f90.

1320 ! -- modules
1322 ! -- dummy
1323 class(GwfNpftype) :: this
1324 !
1325 ! -- allocate scalars in NumericalPackageType
1326 call this%NumericalPackageType%allocate_scalars()
1327 !
1328 ! -- Allocate scalars
1329 call mem_allocate(this%iname, 'INAME', this%memoryPath)
1330 call mem_allocate(this%ixt3d, 'IXT3D', this%memoryPath)
1331 call mem_allocate(this%ixt3drhs, 'IXT3DRHS', this%memoryPath)
1332 call mem_allocate(this%satomega, 'SATOMEGA', this%memoryPath)
1333 call mem_allocate(this%hnoflo, 'HNOFLO', this%memoryPath)
1334 call mem_allocate(this%hdry, 'HDRY', this%memoryPath)
1335 call mem_allocate(this%icellavg, 'ICELLAVG', this%memoryPath)
1336 call mem_allocate(this%iavgkeff, 'IAVGKEFF', this%memoryPath)
1337 call mem_allocate(this%ik22, 'IK22', this%memoryPath)
1338 call mem_allocate(this%ik33, 'IK33', this%memoryPath)
1339 call mem_allocate(this%ik22overk, 'IK22OVERK', this%memoryPath)
1340 call mem_allocate(this%ik33overk, 'IK33OVERK', this%memoryPath)
1341 call mem_allocate(this%iperched, 'IPERCHED', this%memoryPath)
1342 call mem_allocate(this%ivarcv, 'IVARCV', this%memoryPath)
1343 call mem_allocate(this%idewatcv, 'IDEWATCV', this%memoryPath)
1344 call mem_allocate(this%ithickstrt, 'ITHICKSTRT', this%memoryPath)
1345 call mem_allocate(this%ihighcellsat, 'IHIGHCELLSAT', this%memoryPath)
1346 call mem_allocate(this%icalcspdis, 'ICALCSPDIS', this%memoryPath)
1347 call mem_allocate(this%isavspdis, 'ISAVSPDIS', this%memoryPath)
1348 call mem_allocate(this%isavsat, 'ISAVSAT', this%memoryPath)
1349 call mem_allocate(this%irewet, 'IREWET', this%memoryPath)
1350 call mem_allocate(this%wetfct, 'WETFCT', this%memoryPath)
1351 call mem_allocate(this%iwetit, 'IWETIT', this%memoryPath)
1352 call mem_allocate(this%ihdwet, 'IHDWET', this%memoryPath)
1353 call mem_allocate(this%iangle1, 'IANGLE1', this%memoryPath)
1354 call mem_allocate(this%iangle2, 'IANGLE2', this%memoryPath)
1355 call mem_allocate(this%iangle3, 'IANGLE3', this%memoryPath)
1356 call mem_allocate(this%iwetdry, 'IWETDRY', this%memoryPath)
1357 call mem_allocate(this%nedges, 'NEDGES', this%memoryPath)
1358 call mem_allocate(this%lastedge, 'LASTEDGE', this%memoryPath)
1359 call mem_allocate(this%intvk, 'INTVK', this%memoryPath)
1360 call mem_allocate(this%invsc, 'INVSC', this%memoryPath)
1361 call mem_allocate(this%kchangeper, 'KCHANGEPER', this%memoryPath)
1362 call mem_allocate(this%kchangestp, 'KCHANGESTP', this%memoryPath)
1363 !
1364 ! -- set pointer to inewtonur
1365 call mem_setptr(this%igwfnewtonur, 'INEWTONUR', &
1366 create_mem_path(this%name_model))
1367 !
1368 ! -- Initialize value
1369 this%iname = 8
1370 this%ixt3d = 0
1371 this%ixt3drhs = 0
1372 this%satomega = dzero
1373 this%hnoflo = dhnoflo !1.d30
1374 this%hdry = dhdry !-1.d30
1375 this%icellavg = ccond_hmean
1376 this%iavgkeff = 0
1377 this%ik22 = 0
1378 this%ik33 = 0
1379 this%ik22overk = 0
1380 this%ik33overk = 0
1381 this%iperched = 0
1382 this%ivarcv = 0
1383 this%idewatcv = 0
1384 this%ithickstrt = 0
1385 this%ihighcellsat = 0
1386 this%icalcspdis = 0
1387 this%isavspdis = 0
1388 this%isavsat = 0
1389 this%irewet = 0
1390 this%wetfct = done
1391 this%iwetit = 1
1392 this%ihdwet = 0
1393 this%iangle1 = 0
1394 this%iangle2 = 0
1395 this%iangle3 = 0
1396 this%iwetdry = 0
1397 this%nedges = 0
1398 this%lastedge = 0
1399 this%intvk = 0
1400 this%invsc = 0
1401 this%kchangeper = 0
1402 this%kchangestp = 0
1403 !
1404 ! -- If newton is on, then NPF creates asymmetric matrix
1405 this%iasym = this%inewton
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
Here is the call graph for this function:

◆ calc_condsat()

subroutine gwfnpfmodule::calc_condsat ( class(gwfnpftype) this,
integer(i4b), intent(in) node,
logical, intent(in) upperonly )
private

Calculate saturated conductances for all connections of the given node, or optionally for the upper portion of the matrix only.

Definition at line 2278 of file gwf-npf.f90.

2279 ! -- dummy variables
2280 class(GwfNpfType) :: this
2281 integer(I4B), intent(in) :: node
2282 logical, intent(in) :: upperOnly
2283 ! -- local variables
2284 integer(I4B) :: ii, m, n, ihc, jj
2285 real(DP) :: topm, topn, topnode, botm, botn, botnode, satm, satn, satnode
2286 real(DP) :: hyn, hym, hn, hm, fawidth, csat
2287 !
2288 satnode = this%calc_initial_sat(node)
2289 !
2290 topnode = this%dis%top(node)
2291 botnode = this%dis%bot(node)
2292 !
2293 ! -- Go through the connecting cells
2294 do ii = this%dis%con%ia(node) + 1, this%dis%con%ia(node + 1) - 1
2295 !
2296 ! -- Set the m cell number and cycle if lower triangle connection and
2297 ! -- we're not updating both upper and lower matrix parts for this node
2298 m = this%dis%con%ja(ii)
2299 jj = this%dis%con%jas(ii)
2300 if (m < node) then
2301 if (upperonly) cycle
2302 ! m => node, n => neighbour
2303 n = m
2304 m = node
2305 topm = topnode
2306 botm = botnode
2307 satm = satnode
2308 topn = this%dis%top(n)
2309 botn = this%dis%bot(n)
2310 satn = this%calc_initial_sat(n)
2311 else
2312 ! n => node, m => neighbour
2313 n = node
2314 topn = topnode
2315 botn = botnode
2316 satn = satnode
2317 topm = this%dis%top(m)
2318 botm = this%dis%bot(m)
2319 satm = this%calc_initial_sat(m)
2320 end if
2321 !
2322 ihc = this%dis%con%ihc(jj)
2323 hyn = this%hy_eff(n, m, ihc, ipos=ii)
2324 hym = this%hy_eff(m, n, ihc, ipos=ii)
2325 if (this%ithickstartflag(n) == 0) then
2326 hn = topn
2327 else
2328 hn = this%ic%strt(n)
2329 end if
2330 if (this%ithickstartflag(m) == 0) then
2331 hm = topm
2332 else
2333 hm = this%ic%strt(m)
2334 end if
2335 !
2336 ! -- Calculate conductance depending on whether connection is
2337 ! vertical (0), horizontal (1), or staggered horizontal (2)
2338 if (ihc == c3d_vertical) then
2339 !
2340 ! -- Vertical conductance for fully saturated conditions
2341 csat = vcond(1, 1, 1, 1, 0, 1, 1, done, &
2342 botn, botm, &
2343 hyn, hym, &
2344 satn, satm, &
2345 topn, topm, &
2346 botn, botm, &
2347 this%dis%con%hwva(jj))
2348 else
2349 !
2350 ! -- Horizontal conductance for fully saturated conditions
2351 fawidth = this%dis%con%hwva(jj)
2352 csat = hcond(1, 1, 1, 1, 0, &
2353 ihc, &
2354 this%icellavg, &
2355 done, &
2356 hn, hm, satn, satm, hyn, hym, &
2357 topn, topm, &
2358 botn, botm, &
2359 this%dis%con%cl1(jj), &
2360 this%dis%con%cl2(jj), &
2361 fawidth)
2362 end if
2363 this%condsat(jj) = csat
2364 end do
Here is the call graph for this function:

◆ calc_initial_sat()

real(dp) function gwfnpfmodule::calc_initial_sat ( class(gwfnpftype) this,
integer(i4b), intent(in) n )
private

Calculate saturation as a fraction of thickness for the given node, used for saturated conductance calculations: full thickness by default (1.0) or saturation based on initial conditions if the THICKSTRT option is used.

Definition at line 2374 of file gwf-npf.f90.

2375 ! -- dummy variables
2376 class(GwfNpfType) :: this
2377 integer(I4B), intent(in) :: n
2378 ! -- Return
2379 real(DP) :: satn
2380 !
2381 satn = done
2382 if (this%ibound(n) /= 0 .and. this%ithickstartflag(n) /= 0) then
2383 call this%thksat(n, this%ic%strt(n), satn)
2384 end if

◆ calc_max_conns()

integer(i4b) function gwfnpfmodule::calc_max_conns ( class(gwfnpftype) this)
private

Definition at line 3008 of file gwf-npf.f90.

3009 class(GwfNpfType) :: this
3010 integer(I4B) :: max_conns
3011 ! local
3012 integer(I4B) :: n, m, ic
3013
3014 max_conns = 0
3015 do n = 1, this%dis%nodes
3016
3017 ! Count internal model connections
3018 ic = this%dis%con%ia(n + 1) - this%dis%con%ia(n) - 1
3019
3020 ! Add edge connections
3021 do m = 1, this%nedges
3022 if (this%nodedge(m) == n) then
3023 ic = ic + 1
3024 end if
3025 end do
3026
3027 ! Set max number of connections for any cell
3028 if (ic > max_conns) max_conns = ic
3029 end do
3030

◆ calc_spdis()

subroutine gwfnpfmodule::calc_spdis ( class(gwfnpftype) this,
real(dp), dimension(:), intent(in) flowja )
private

Definition at line 2687 of file gwf-npf.f90.

2688 ! -- modules
2689 use simmodule, only: store_error
2690 ! -- dummy
2691 class(GwfNpfType) :: this
2692 real(DP), intent(in), dimension(:) :: flowja
2693 ! -- local
2694 integer(I4B) :: n
2695 integer(I4B) :: m
2696 integer(I4B) :: ipos
2697 integer(I4B) :: iedge
2698 integer(I4B) :: isympos
2699 integer(I4B) :: ihc
2700 integer(I4B) :: ic
2701 integer(I4B) :: iz
2702 integer(I4B) :: nc
2703 integer(I4B) :: ncz
2704 real(DP) :: qz
2705 real(DP) :: vx
2706 real(DP) :: vy
2707 real(DP) :: vz
2708 real(DP) :: xn
2709 real(DP) :: yn
2710 real(DP) :: zn
2711 real(DP) :: xc
2712 real(DP) :: yc
2713 real(DP) :: zc
2714 real(DP) :: cl1
2715 real(DP) :: cl2
2716 real(DP) :: dltot
2717 real(DP) :: ooclsum
2718 real(DP) :: dsumx
2719 real(DP) :: dsumy
2720 real(DP) :: dsumz
2721 real(DP) :: denom
2722 real(DP) :: area
2723 real(DP) :: dz
2724 real(DP) :: axy
2725 real(DP) :: ayx
2726 logical :: nozee = .true.
2727 type(SpdisWorkArrayType), pointer :: swa => null() !< pointer to spdis work arrays structure
2728 !
2729 ! -- Ensure dis has necessary information
2730 if (this%icalcspdis /= 0 .and. this%dis%con%ianglex == 0) then
2731 call store_error('Error. ANGLDEGX not provided in '// &
2732 'discretization file. ANGLDEGX required for '// &
2733 'calculation of specific discharge.', terminate=.true.)
2734 end if
2735
2736 swa => this%spdis_wa
2737 if (.not. swa%is_created()) then
2738 ! prepare work arrays
2739 call this%spdis_wa%create(this%calc_max_conns())
2740
2741 ! prepare lookup table
2742 if (this%nedges > 0) call this%prepare_edge_lookup()
2743 end if
2744 !
2745 ! -- Go through each cell and calculate specific discharge
2746 do n = 1, this%dis%nodes
2747 !
2748 ! -- first calculate geometric properties for x and y directions and
2749 ! the specific discharge at a face (vi)
2750 ic = 0
2751 iz = 0
2752
2753 ! reset work arrays
2754 call swa%reset()
2755
2756 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
2757 m = this%dis%con%ja(ipos)
2758 isympos = this%dis%con%jas(ipos)
2759 ihc = this%dis%con%ihc(isympos)
2760 area = this%dis%con%hwva(isympos)
2761 if (ihc == c3d_vertical) then
2762 !
2763 ! -- vertical connection
2764 iz = iz + 1
2765 !call this%dis%connection_normal(n, m, ihc, xn, yn, zn, ipos)
2766 call this%dis%connection_vector(n, m, nozee, this%sat(n), this%sat(m), &
2767 ihc, xc, yc, zc, dltot)
2768 cl1 = this%dis%con%cl1(isympos)
2769 cl2 = this%dis%con%cl2(isympos)
2770 if (m < n) then
2771 cl1 = this%dis%con%cl2(isympos)
2772 cl2 = this%dis%con%cl1(isympos)
2773 end if
2774 ooclsum = done / (cl1 + cl2)
2775 swa%diz(iz) = dltot * cl1 * ooclsum
2776 qz = flowja(ipos)
2777 if (n > m) qz = -qz
2778 swa%viz(iz) = qz / area
2779 else
2780 !
2781 ! -- horizontal connection
2782 ic = ic + 1
2783 dz = thksatnm(this%ibound(n), this%ibound(m), &
2784 this%icelltype(n), this%icelltype(m), &
2785 this%inewton, ihc, &
2786 this%hnew(n), this%hnew(m), this%sat(n), this%sat(m), &
2787 this%dis%top(n), this%dis%top(m), this%dis%bot(n), &
2788 this%dis%bot(m))
2789 area = area * dz
2790 call this%dis%connection_normal(n, m, ihc, xn, yn, zn, ipos)
2791 call this%dis%connection_vector(n, m, nozee, this%sat(n), this%sat(m), &
2792 ihc, xc, yc, zc, dltot)
2793 cl1 = this%dis%con%cl1(isympos)
2794 cl2 = this%dis%con%cl2(isympos)
2795 if (m < n) then
2796 cl1 = this%dis%con%cl2(isympos)
2797 cl2 = this%dis%con%cl1(isympos)
2798 end if
2799 ooclsum = done / (cl1 + cl2)
2800 swa%nix(ic) = -xn
2801 swa%niy(ic) = -yn
2802 swa%di(ic) = dltot * cl1 * ooclsum
2803 if (area > dzero) then
2804 swa%vi(ic) = flowja(ipos) / area
2805 else
2806 swa%vi(ic) = dzero
2807 end if
2808 end if
2809 end do
2810
2811 ! add contribution from edge flows (i.e. from exchanges)
2812 if (this%nedges > 0) then
2813 do ipos = this%iedge_ptr(n), this%iedge_ptr(n + 1) - 1
2814 iedge = this%edge_idxs(ipos)
2815
2816 ! propsedge: (Q, area, nx, ny, distance)
2817 ihc = this%ihcedge(iedge)
2818 area = this%propsedge(2, iedge)
2819 if (ihc == c3d_vertical) then
2820 iz = iz + 1
2821 swa%viz(iz) = this%propsedge(1, iedge) / area
2822 swa%diz(iz) = this%propsedge(5, iedge)
2823 else
2824 ic = ic + 1
2825 swa%nix(ic) = -this%propsedge(3, iedge)
2826 swa%niy(ic) = -this%propsedge(4, iedge)
2827 swa%di(ic) = this%propsedge(5, iedge)
2828 if (area > dzero) then
2829 swa%vi(ic) = this%propsedge(1, iedge) / area
2830 else
2831 swa%vi(ic) = dzero
2832 end if
2833 end if
2834 end do
2835 end if
2836 !
2837 ! -- Assign number of vertical and horizontal connections
2838 ncz = iz
2839 nc = ic
2840 !
2841 ! -- calculate z weight (wiz) and z velocity
2842 if (ncz == 1) then
2843 swa%wiz(1) = done
2844 else
2845 dsumz = dzero
2846 do iz = 1, ncz
2847 dsumz = dsumz + swa%diz(iz)
2848 end do
2849 denom = (ncz - done)
2850 if (denom < dzero) denom = dzero
2851 dsumz = dsumz + dem10 * dsumz
2852 do iz = 1, ncz
2853 if (dsumz > dzero) swa%wiz(iz) = done - swa%diz(iz) / dsumz
2854 if (denom > 0) then
2855 swa%wiz(iz) = swa%wiz(iz) / denom
2856 else
2857 swa%wiz(iz) = dzero
2858 end if
2859 end do
2860 end if
2861 vz = dzero
2862 do iz = 1, ncz
2863 vz = vz + swa%wiz(iz) * swa%viz(iz)
2864 end do
2865 !
2866 ! -- distance-based weighting
2867 nc = ic
2868 dsumx = dzero
2869 dsumy = dzero
2870 dsumz = dzero
2871 do ic = 1, nc
2872 swa%wix(ic) = swa%di(ic) * abs(swa%nix(ic))
2873 swa%wiy(ic) = swa%di(ic) * abs(swa%niy(ic))
2874 dsumx = dsumx + swa%wix(ic)
2875 dsumy = dsumy + swa%wiy(ic)
2876 end do
2877 !
2878 ! -- Finish computing omega weights. Add a tiny bit
2879 ! to dsum so that the normalized omega weight later
2880 ! evaluates to (essentially) 1 in the case of a single
2881 ! relevant connection, avoiding 0/0.
2882 dsumx = dsumx + dem10 * dsumx
2883 dsumy = dsumy + dem10 * dsumy
2884 do ic = 1, nc
2885 swa%wix(ic) = (dsumx - swa%wix(ic)) * abs(swa%nix(ic))
2886 swa%wiy(ic) = (dsumy - swa%wiy(ic)) * abs(swa%niy(ic))
2887 end do
2888 !
2889 ! -- compute B weights
2890 dsumx = dzero
2891 dsumy = dzero
2892 do ic = 1, nc
2893 swa%bix(ic) = swa%wix(ic) * sign(done, swa%nix(ic))
2894 swa%biy(ic) = swa%wiy(ic) * sign(done, swa%niy(ic))
2895 dsumx = dsumx + swa%wix(ic) * abs(swa%nix(ic))
2896 dsumy = dsumy + swa%wiy(ic) * abs(swa%niy(ic))
2897 end do
2898 if (dsumx > dzero) dsumx = done / dsumx
2899 if (dsumy > dzero) dsumy = done / dsumy
2900 axy = dzero
2901 ayx = dzero
2902 do ic = 1, nc
2903 swa%bix(ic) = swa%bix(ic) * dsumx
2904 swa%biy(ic) = swa%biy(ic) * dsumy
2905 axy = axy + swa%bix(ic) * swa%niy(ic)
2906 ayx = ayx + swa%biy(ic) * swa%nix(ic)
2907 end do
2908 !
2909 ! -- Calculate specific discharge. The divide by zero checking below
2910 ! is problematic for cells with only one flow, such as can happen
2911 ! with triangular cells in corners. In this case, the resulting
2912 ! cell velocity will be calculated as zero. The method should be
2913 ! improved so that edge flows of zero are included in these
2914 ! calculations. But this needs to be done with consideration for LGR
2915 ! cases in which flows are submitted from an exchange.
2916 vx = dzero
2917 vy = dzero
2918 do ic = 1, nc
2919 vx = vx + (swa%bix(ic) - axy * swa%biy(ic)) * swa%vi(ic)
2920 vy = vy + (swa%biy(ic) - ayx * swa%bix(ic)) * swa%vi(ic)
2921 end do
2922 denom = done - axy * ayx
2923 if (denom /= dzero) then
2924 vx = vx / denom
2925 vy = vy / denom
2926 end if
2927 !
2928 this%spdis(1, n) = vx
2929 this%spdis(2, n) = vy
2930 this%spdis(3, n) = vz
2931 !
2932 end do
2933
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
Here is the call graph for this function:

◆ calcsatthickness()

real(dp) function gwfnpfmodule::calcsatthickness ( class(gwfnpftype) this,
integer(i4b) n,
integer(i4b) m,
integer(i4b) ihc )
private
Parameters
thisthis NPF instance
nnode n
mnode m
ihc1 = horizontal connection, 0 for vertical
Returns
saturated thickness

Definition at line 3109 of file gwf-npf.f90.

3110 ! -- dummy
3111 class(GwfNpfType) :: this !< this NPF instance
3112 integer(I4B) :: n !< node n
3113 integer(I4B) :: m !< node m
3114 integer(I4B) :: ihc !< 1 = horizontal connection, 0 for vertical
3115 ! -- return
3116 real(DP) :: satThickness !< saturated thickness
3117 !
3118 satthickness = thksatnm(this%ibound(n), &
3119 this%ibound(m), &
3120 this%icelltype(n), &
3121 this%icelltype(m), &
3122 this%inewton, &
3123 ihc, &
3124 this%hnew(n), &
3125 this%hnew(m), &
3126 this%sat(n), &
3127 this%sat(m), &
3128 this%dis%top(n), &
3129 this%dis%top(m), &
3130 this%dis%bot(n), &
3131 this%dis%bot(m))

◆ cf_default_flow()

subroutine gwfnpfmodule::cf_default_flow ( class(gwfnpftype) this,
integer(i4b) kiter,
integer(i4b) n )
private

Definition at line 541 of file gwf-npf.f90.

542 class(GwfNpfType) :: this
543 integer(I4B) :: kiter
544 integer(I4B) :: n
545 ! local
546 real(DP) :: satn
547
548 ! Calculate saturated fraction for convertible cells
549 if (this%icelltype(n) /= 0) then
550 if (this%ibound(n) == 0) then
551 satn = dzero
552 else
553 call this%thksat(n, this%hnew(n), satn)
554 end if
555 this%sat(n) = satn
556 end if
557

◆ check_options()

subroutine gwfnpfmodule::check_options ( class(gwfnpftype) this)
private

Definition at line 1699 of file gwf-npf.f90.

1700 ! -- modules
1701 use simmodule, only: store_error, store_warning, &
1703 use constantsmodule, only: linelength
1704 ! -- dummy
1705 class(GwfNpftype) :: this
1706 !
1707 ! -- set omega value used for saturation calculations
1708 if (this%inewton > 0) then
1709 this%satomega = dem6
1710 end if
1711 !
1712 if (this%inewton > 0) then
1713 if (this%iperched > 0) then
1714 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. NEWTON OPTION CANNOT '// &
1715 'BE USED WITH PERCHED OPTION.'
1716 call store_error(errmsg)
1717 end if
1718 if (this%ivarcv > 0) then
1719 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. NEWTON OPTION CANNOT '// &
1720 'BE USED WITH VARIABLECV OPTION.'
1721 call store_error(errmsg)
1722 end if
1723 if (this%irewet > 0) then
1724 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. NEWTON OPTION CANNOT '// &
1725 'BE USED WITH REWET OPTION.'
1726 call store_error(errmsg)
1727 end if
1728 else
1729 if (this%ihighcellsat /= 0) then
1730 write (warnmsg, '(a)') 'HIGHEST_CELL_SATURATION '// &
1731 'option cannot be used when NEWTON option in not specified. '// &
1732 'Resetting HIGHEST_CELL_SATURATION option to off.'
1733 this%ihighcellsat = 0
1734 call store_warning(warnmsg)
1735 end if
1736 end if
1737 !
1738 if (this%ixt3d /= 0) then
1739 if (this%icellavg > 0) then
1740 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. '// &
1741 'ALTERNATIVE_CELL_AVERAGING OPTION '// &
1742 'CANNOT BE USED WITH XT3D OPTION.'
1743 call store_error(errmsg)
1744 end if
1745 if (this%ithickstrt > 0) then
1746 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. THICKSTRT OPTION '// &
1747 'CANNOT BE USED WITH XT3D OPTION.'
1748 call store_error(errmsg)
1749 end if
1750 if (this%iperched > 0) then
1751 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. PERCHED OPTION '// &
1752 'CANNOT BE USED WITH XT3D OPTION.'
1753 call store_error(errmsg)
1754 end if
1755 if (this%ivarcv > 0) then
1756 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. VARIABLECV OPTION '// &
1757 'CANNOT BE USED WITH XT3D OPTION.'
1758 call store_error(errmsg)
1759 end if
1760 end if
1761 !
1762 ! -- Terminate if errors
1763 if (count_errors() > 0) then
1764 call store_error_filename(this%input_fname)
1765 end if
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 dem6
real constant 1e-6
subroutine, public store_warning(msg, substring)
Store warning message.
Definition Sim.f90:241
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
Here is the call graph for this function:

◆ cq_default_flow()

subroutine gwfnpfmodule::cq_default_flow ( class(gwfnpftype) this,
integer(i4b), intent(in) n,
integer(i4b), intent(in) m,
integer(i4b), intent(in) ipos,
real(dp), dimension(:), intent(inout) flowja,
real(dp), dimension(:), intent(in) hnew )
private

Definition at line 1016 of file gwf-npf.f90.

1017 class(GwfNpfType) :: this
1018 integer(I4B), intent(in) :: n
1019 integer(I4B), intent(in) :: m
1020 integer(I4B), intent(in) :: ipos
1021 real(DP), dimension(:), intent(inout) :: flowja
1022 real(DP), dimension(:), intent(in) :: hnew
1023 ! local
1024 real(DP) :: qnm
1025
1026 call this%qcalc(n, m, hnew(n), hnew(m), ipos, qnm)
1027 flowja(ipos) = qnm
1028 flowja(this%dis%con%isym(ipos)) = -qnm
1029

◆ default_flow_cf()

subroutine gwfnpfmodule::default_flow_cf ( class(defaultflowformulationtype), intent(inout) this,
integer(i4b), intent(in) kiter )
private

Runs over all cells and computes the saturated fraction for convertible cells, skipping cells claimed by an exclusive formulation.

Parameters
[in,out]thisdefault formulation
[in]kiterouter iteration number

Definition at line 524 of file gwf-npf.f90.

525 class(DefaultFlowFormulationType), intent(inout) :: this !< default formulation
526 integer(I4B), intent(in) :: kiter !< outer iteration number
527 ! local
528 integer(I4B) :: n, idiag
529
530 do n = 1, this%npf%dis%nodes
531 ! skip cells claimed by an exclusive formulation
532 idiag = this%npf%dis%con%ia(n)
533 if (this%npf%iformulation(idiag) /= default_flow) cycle
534 call this%npf%cf_default_flow(kiter, n)
535 end do
536

◆ default_flow_cq()

subroutine gwfnpfmodule::default_flow_cq ( class(defaultflowformulationtype), intent(inout) this,
real(dp), dimension(:), intent(inout) hnew,
real(dp), dimension(:), intent(inout) flowja )
private

Runs over all connections and stores the standard NPF face flows, skipping faces claimed by an exclusive formulation.

Parameters
[in,out]thisdefault formulation
[in,out]hnewnew head values
[in,out]flowjaflow between cells

Definition at line 994 of file gwf-npf.f90.

995 class(DefaultFlowFormulationType), intent(inout) :: this !< default formulation
996 real(DP), dimension(:), intent(inout) :: hnew !< new head values
997 real(DP), dimension(:), intent(inout) :: flowja !< flow between cells
998 ! local
999 integer(I4B) :: n, m, ipos
1000
1001 do n = 1, this%npf%dis%nodes
1002 do ipos = this%npf%dis%con%ia(n) + 1, this%npf%dis%con%ia(n + 1) - 1
1003 m = this%npf%dis%con%ja(ipos)
1004 if (m < n) cycle
1005 !TODO_MJR: why don't we exclude masked connections here?
1006
1007 ! skip faces claimed by an exclusive formulation
1008 if (this%npf%iformulation(ipos) /= default_flow) cycle
1009
1010 call this%npf%cq_default_flow(n, m, ipos, flowja, hnew)
1011 end do
1012 end do
1013

◆ default_flow_fc()

subroutine gwfnpfmodule::default_flow_fc ( class(defaultflowformulationtype), intent(inout) this,
integer(i4b), intent(in) kiter,
class(matrixbasetype), intent(inout), pointer matrix_sln,
integer(i4b), dimension(:), intent(in) idxglo,
real(dp), dimension(:), intent(inout) rhs,
real(dp), dimension(:), intent(inout) hnew )
private

Runs over all connections and fills the standard NPF conductance terms, skipping faces claimed by an exclusive formulation.

Parameters
[in,out]thisdefault formulation
[in]kiterouter iteration number
[in,out]matrix_slnsystem matrix
[in]idxglolocal to global connection map
[in,out]rhsright-hand side vector
[in,out]hnewnew head values

Definition at line 684 of file gwf-npf.f90.

685 class(DefaultFlowFormulationType), intent(inout) :: this !< default formulation
686 integer(I4B), intent(in) :: kiter !< outer iteration number
687 class(MatrixBaseType), pointer, intent(inout) :: matrix_sln !< system matrix
688 integer(I4B), dimension(:), intent(in) :: idxglo !< local to global connection map
689 real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector
690 real(DP), dimension(:), intent(inout) :: hnew !< new head values
691 ! local
692 integer(I4B) :: n, m, ipos
693
694 do n = 1, this%npf%dis%nodes
695 do ipos = this%npf%dis%con%ia(n) + 1, this%npf%dis%con%ia(n + 1) - 1
696 if (this%npf%dis%con%mask(ipos) == 0) cycle
697
698 m = this%npf%dis%con%ja(ipos)
699
700 ! Calculate upper triangle only, but insert into
701 ! upper and lower parts of matrix
702 if (m < n) cycle
703
704 ! skip faces claimed by an exclusive formulation
705 if (this%npf%iformulation(ipos) /= default_flow) cycle
706
707 call this%npf%fc_default_flow(n, m, ipos, matrix_sln, &
708 rhs, idxglo, hnew)
709 end do
710 end do
711

◆ default_flow_fn()

subroutine gwfnpfmodule::default_flow_fn ( class(defaultflowformulationtype), intent(inout) this,
integer(i4b), intent(in) kiter,
class(matrixbasetype), intent(inout), pointer matrix_sln,
integer(i4b), dimension(:), intent(in) idxglo,
real(dp), dimension(:), intent(inout) rhs,
real(dp), dimension(:), intent(inout) hnew )
private

Runs over all connections and fills the standard NPF newton terms, skipping faces claimed by an exclusive formulation.

Parameters
[in,out]thisdefault formulation
[in]kiterouter iteration number
[in,out]matrix_slnsystem matrix
[in]idxglolocal to global connection map
[in,out]rhsright-hand side vector
[in,out]hnewnew head values

Definition at line 783 of file gwf-npf.f90.

784 class(DefaultFlowFormulationType), intent(inout) :: this !< default formulation
785 integer(I4B), intent(in) :: kiter !< outer iteration number
786 class(MatrixBaseType), pointer, intent(inout) :: matrix_sln !< system matrix
787 integer(I4B), dimension(:), intent(in) :: idxglo !< local to global connection map
788 real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector
789 real(DP), dimension(:), intent(inout) :: hnew !< new head values
790 ! local
791 integer(I4B) :: n, m, ipos
792
793 do n = 1, this%npf%dis%nodes
794 do ipos = this%npf%dis%con%ia(n) + 1, this%npf%dis%con%ia(n + 1) - 1
795 if (this%npf%dis%con%mask(ipos) == 0) cycle
796
797 m = this%npf%dis%con%ja(ipos)
798
799 ! work on upper triangle
800 if (m < n) cycle
801
802 ! skip faces claimed by an exclusive formulation
803 if (this%npf%iformulation(ipos) /= default_flow) cycle
804
805 call this%npf%fn_default_flow(n, m, ipos, matrix_sln, &
806 rhs, idxglo, hnew)
807 end do
808 end do
809

◆ fc_default_flow()

subroutine gwfnpfmodule::fc_default_flow ( class(gwfnpftype) this,
integer(i4b) n,
integer(i4b) m,
integer(i4b) ipos,
class(matrixbasetype), pointer matrix_sln,
real(dp), dimension(:), intent(inout) rhs,
integer(i4b), dimension(:), intent(in) idxglo,
real(dp), dimension(:), intent(inout) hnew )
private
Parameters
thisthis instance
nnode number n
mnode number m
iposconnection number
matrix_slnsystem matrix
[in,out]rhsrhs vector
[in]idxglolookup table from local ipos to global system
[in,out]hnewnew head values

Definition at line 590 of file gwf-npf.f90.

591 class(GwfNpfType) :: this !< this instance
592 integer(I4B) :: n !< node number n
593 integer(I4B) :: m !< node number m
594 integer(I4B) :: ipos !< connection number
595 class(MatrixBaseType), pointer :: matrix_sln !< system matrix
596 real(DP), intent(inout), dimension(:) :: rhs !< rhs vector
597 integer(I4B), intent(in), dimension(:) :: idxglo !< lookup table from local ipos to global system
598 real(DP), intent(inout), dimension(:) :: hnew !< new head values
599 ! local
600 integer(I4B) :: idiag, ihc
601 integer(I4B) :: isymcon, idiagm
602 real(DP) :: hyn, hym
603 real(DP) :: cond
604 real(DP) :: satn
605 real(DP) :: satm
606
607 ihc = this%dis%con%ihc(this%dis%con%jas(ipos))
608 hyn = this%hy_eff(n, m, ihc, ipos=ipos)
609 hym = this%hy_eff(m, n, ihc, ipos=ipos)
610
611 if (ihc == c3d_vertical) then
612 ! Horizontal conductance
613 cond = vcond(this%ibound(n), this%ibound(m), &
614 this%icelltype(n), this%icelltype(m), this%inewton, &
615 this%ivarcv, this%idewatcv, &
616 this%condsat(this%dis%con%jas(ipos)), hnew(n), hnew(m), &
617 hyn, hym, &
618 this%sat(n), this%sat(m), &
619 this%dis%top(n), this%dis%top(m), &
620 this%dis%bot(n), this%dis%bot(m), &
621 this%dis%con%hwva(this%dis%con%jas(ipos)))
622
623 ! Vertical flow for perched conditions
624 if (this%iperched /= 0) then
625 if (this%icelltype(m) /= 0) then
626 if (hnew(m) < this%dis%top(m)) then
627
628 ! Fill diagonal for n, and add to RHS
629 idiag = this%dis%con%ia(n)
630 rhs(n) = rhs(n) - cond * this%dis%bot(n)
631 call matrix_sln%add_value_pos(idxglo(idiag), -cond)
632
633 ! Fill diagonal for m, and add to RHS
634 isymcon = this%dis%con%isym(ipos)
635 call matrix_sln%add_value_pos(idxglo(isymcon), cond)
636 rhs(m) = rhs(m) + cond * this%dis%bot(n)
637
638 ! go to next connection
639 return
640 end if
641 end if
642 end if
643 else
644 satn = this%sat(n)
645 satm = this%sat(m)
646 if (this%ihighcellsat /= 0) then
647 call this%highest_cell_saturation(n, m, &
648 hnew(n), hnew(m), &
649 satn, satm)
650 end if
651 ! Horizontal conductance
652 cond = hcond(this%ibound(n), this%ibound(m), &
653 this%icelltype(n), this%icelltype(m), &
654 this%inewton, &
655 this%dis%con%ihc(this%dis%con%jas(ipos)), &
656 this%icellavg, &
657 this%condsat(this%dis%con%jas(ipos)), &
658 hnew(n), hnew(m), satn, satm, hyn, hym, &
659 this%dis%top(n), this%dis%top(m), &
660 this%dis%bot(n), this%dis%bot(m), &
661 this%dis%con%cl1(this%dis%con%jas(ipos)), &
662 this%dis%con%cl2(this%dis%con%jas(ipos)), &
663 this%dis%con%hwva(this%dis%con%jas(ipos)))
664 end if
665
666 ! Fill row n
667 idiag = this%dis%con%ia(n)
668 call matrix_sln%add_value_pos(idxglo(ipos), cond)
669 call matrix_sln%add_value_pos(idxglo(idiag), -cond)
670
671 ! Fill row m
672 isymcon = this%dis%con%isym(ipos)
673 idiagm = this%dis%con%ia(m)
674 call matrix_sln%add_value_pos(idxglo(isymcon), cond)
675 call matrix_sln%add_value_pos(idxglo(idiagm), -cond)
676
Here is the call graph for this function:

◆ fn_default_flow()

subroutine gwfnpfmodule::fn_default_flow ( class(gwfnpftype) this,
integer(i4b) n,
integer(i4b) m,
integer(i4b) ipos,
class(matrixbasetype), pointer matrix_sln,
real(dp), dimension(:), intent(inout) rhs,
integer(i4b), dimension(:), intent(in) idxglo,
real(dp), dimension(:), intent(inout) hnew )
private

Definition at line 812 of file gwf-npf.f90.

813 class(GwfNpfType) :: this
814 integer(I4B) :: n
815 integer(I4B) :: m
816 integer(I4B) :: ipos
817 class(MatrixBaseType), pointer :: matrix_sln
818 real(DP), intent(inout), dimension(:) :: rhs
819 integer(I4B), intent(in), dimension(:) :: idxglo
820 real(DP), intent(inout), dimension(:) :: hnew
821 ! local
822 integer(I4B) :: isymcon
823 integer(I4B) :: idiag, idiagm
824 integer(I4B) :: iups
825 integer(I4B) :: idn
826 real(DP) :: cond
827 real(DP) :: consterm
828 real(DP) :: filledterm
829 real(DP) :: derv
830 real(DP) :: hds
831 real(DP) :: term
832 real(DP) :: topup
833 real(DP) :: botup
834
835 idiag = this%dis%con%ia(n)
836 isymcon = this%dis%con%isym(ipos)
837
838 if (this%dis%con%ihc(this%dis%con%jas(ipos)) == 0 .and. &
839 this%ivarcv == 0) then
840 return
841 end if
842
843 ! determine upstream node
844 iups = m
845 if (hnew(m) < hnew(n)) iups = n
846 idn = n
847 if (iups == n) idn = m
848 !
849 ! -- no newton terms if upstream cell is confined
850 if (this%icelltype(iups) == 0) return
851 !
852 ! -- Set the upstream top and bot, and then recalculate for a
853 ! vertically staggered horizontal connection
854 topup = this%dis%top(iups)
855 botup = this%dis%bot(iups)
856 if (this%dis%con%ihc(this%dis%con%jas(ipos)) == 2) then
857 topup = min(this%dis%top(n), this%dis%top(m))
858 botup = max(this%dis%bot(n), this%dis%bot(m))
859 end if
860 !
861 ! get saturated conductivity for derivative
862 cond = this%condsat(this%dis%con%jas(ipos))
863 !
864 ! compute additional term
865 consterm = -cond * (hnew(iups) - hnew(idn)) !needs to use hwadi instead of hnew(idn)
866 !filledterm = cond
867 filledterm = matrix_sln%get_value_pos(idxglo(ipos))
868 derv = squadraticsaturationderivative(topup, botup, hnew(iups), &
869 this%satomega)
870 idiagm = this%dis%con%ia(m)
871 ! fill jacobian for n being the upstream node
872 if (iups == n) then
873 hds = hnew(m)
874 !isymcon = this%dis%con%isym(ii)
875 term = consterm * derv
876 rhs(n) = rhs(n) + term * hnew(n) !+ amat(idxglo(isymcon)) * (dwadi * hds - hds) !need to add dwadi
877 rhs(m) = rhs(m) - term * hnew(n) !- amat(idxglo(isymcon)) * (dwadi * hds - hds) !need to add dwadi
878 ! fill in row of n
879 call matrix_sln%add_value_pos(idxglo(idiag), term)
880 ! fill newton term in off diagonal if active cell
881 if (this%ibound(n) > 0) then
882 filledterm = matrix_sln%get_value_pos(idxglo(ipos))
883 call matrix_sln%set_value_pos(idxglo(ipos), filledterm) !* dwadi !need to add dwadi
884 end if
885 !fill row of m
886 filledterm = matrix_sln%get_value_pos(idxglo(idiagm))
887 call matrix_sln%set_value_pos(idxglo(idiagm), filledterm) !- filledterm * (dwadi - DONE) !need to add dwadi
888 ! fill newton term in off diagonal if active cell
889 if (this%ibound(m) > 0) then
890 call matrix_sln%add_value_pos(idxglo(isymcon), -term)
891 end if
892 ! fill jacobian for m being the upstream node
893 else
894 hds = hnew(n)
895 term = -consterm * derv
896 rhs(n) = rhs(n) + term * hnew(m) !+ amat(idxglo(ii)) * (dwadi * hds - hds) !need to add dwadi
897 rhs(m) = rhs(m) - term * hnew(m) !- amat(idxglo(ii)) * (dwadi * hds - hds) !need to add dwadi
898 ! fill in row of n
899 filledterm = matrix_sln%get_value_pos(idxglo(idiag))
900 call matrix_sln%set_value_pos(idxglo(idiag), filledterm) !- filledterm * (dwadi - DONE) !need to add dwadi
901 ! fill newton term in off diagonal if active cell
902 if (this%ibound(n) > 0) then
903 call matrix_sln%add_value_pos(idxglo(ipos), term)
904 end if
905 !fill row of m
906 call matrix_sln%add_value_pos(idxglo(idiagm), -term)
907 ! fill newton term in off diagonal if active cell
908 if (this%ibound(m) > 0) then
909 filledterm = matrix_sln%get_value_pos(idxglo(isymcon))
910 call matrix_sln%set_value_pos(idxglo(isymcon), filledterm) !* dwadi !need to add dwadi
911 end if
912 end if
913
Here is the call graph for this function:

◆ highest_cell_saturation()

subroutine gwfnpfmodule::highest_cell_saturation ( class(gwfnpftype) this,
integer(i4b), intent(in) n,
integer(i4b), intent(in) m,
real(dp), intent(in) hn,
real(dp), intent(in) hm,
real(dp), intent(inout) satn,
real(dp), intent(inout) satm )
private

Calculate the saturation based on the maximum cell bottom for two connected cells

Definition at line 719 of file gwf-npf.f90.

720 ! dummy
721 class(GwfNpfType) :: this
722 integer(I4B), intent(in) :: n, m
723 real(DP), intent(in) :: hn, hm
724 real(DP), intent(inout) :: satn, satm
725 ! local
726 integer(I4B) :: ihdbot
727 real(DP) :: botn, botm
728 real(DP) :: top, bot
729
730 botn = this%dis%bot(n)
731 botm = this%dis%bot(m)
732
733 ihdbot = n
734 if (botm > botn) ihdbot = m
735
736 ! recalculate saturation if the difference in elevation between
737 ! two cells exceed a threshold value
738 if (abs(botm - botn) >= dem2) then
739 top = this%dis%top(ihdbot)
740 bot = this%dis%bot(ihdbot)
741 satn = squadraticsaturation(top, bot, hn, this%satomega)
742 satm = squadraticsaturation(top, bot, hm, this%satomega)
743 end if
Here is the call graph for this function:

◆ hy_eff()

real(dp) function gwfnpfmodule::hy_eff ( class(gwfnpftype) this,
integer(i4b), intent(in) n,
integer(i4b), intent(in) m,
integer(i4b), intent(in) ihc,
integer(i4b), intent(in), optional ipos,
real(dp), dimension(3), intent(in), optional vg )
private

n is primary node node number m is connected node (not used if vg is provided) ihc is horizontal indicator (0 vertical, 1 horizontal, 2 vertically staggered) ipos_opt is position of connection in ja array vg is the global unit vector that expresses the direction from which to calculate an effective hydraulic conductivity.

Definition at line 2608 of file gwf-npf.f90.

2609 ! -- return
2610 real(DP) :: hy
2611 ! -- dummy
2612 class(GwfNpfType) :: this
2613 integer(I4B), intent(in) :: n
2614 integer(I4B), intent(in) :: m
2615 integer(I4B), intent(in) :: ihc
2616 integer(I4B), intent(in), optional :: ipos
2617 real(DP), dimension(3), intent(in), optional :: vg
2618 ! -- local
2619 integer(I4B) :: iipos
2620 real(DP) :: hy11, hy22, hy33
2621 real(DP) :: ang1, ang2, ang3
2622 real(DP) :: vg1, vg2, vg3
2623 !
2624 ! -- Initialize
2625 iipos = 0
2626 if (present(ipos)) iipos = ipos
2627 hy11 = this%k11(n)
2628 hy22 = this%k11(n)
2629 hy33 = this%k11(n)
2630 hy22 = this%k22(n)
2631 hy33 = this%k33(n)
2632 !
2633 ! -- Calculate effective K based on whether connection is vertical
2634 ! or horizontal
2635 if (ihc == c3d_vertical) then
2636 !
2637 ! -- Handle rotated anisotropy case that would affect the effective
2638 ! vertical hydraulic conductivity
2639 hy = hy33
2640 if (this%iangle2 > 0) then
2641 if (present(vg)) then
2642 vg1 = vg(1)
2643 vg2 = vg(2)
2644 vg3 = vg(3)
2645 else
2646 call this%dis%connection_normal(n, m, ihc, vg1, vg2, vg3, iipos)
2647 end if
2648 ang1 = this%angle1(n)
2649 ang2 = this%angle2(n)
2650 ang3 = dzero
2651 if (this%iangle3 > 0) ang3 = this%angle3(n)
2652 hy = hyeff(hy11, hy22, hy33, ang1, ang2, ang3, vg1, vg2, vg3, &
2653 this%iavgkeff)
2654 end if
2655 !
2656 else
2657 !
2658 ! -- Handle horizontal case
2659 hy = hy11
2660 if (this%ik22 > 0) then
2661 if (present(vg)) then
2662 vg1 = vg(1)
2663 vg2 = vg(2)
2664 vg3 = vg(3)
2665 else
2666 call this%dis%connection_normal(n, m, ihc, vg1, vg2, vg3, iipos)
2667 end if
2668 ang1 = dzero
2669 ang2 = dzero
2670 ang3 = dzero
2671 if (this%iangle1 > 0) then
2672 ang1 = this%angle1(n)
2673 if (this%iangle2 > 0) then
2674 ang2 = this%angle2(n)
2675 if (this%iangle3 > 0) ang3 = this%angle3(n)
2676 end if
2677 end if
2678 hy = hyeff(hy11, hy22, hy33, ang1, ang2, ang3, vg1, vg2, vg3, &
2679 this%iavgkeff)
2680 end if
2681 !
2682 end if
Here is the call graph for this function:

◆ increase_edge_count()

subroutine gwfnpfmodule::increase_edge_count ( class(gwfnpftype) this,
integer(i4b), intent(in) nedges )
private

This must be called before the npfallocate_arrays routine, which is called from npfar.

Definition at line 2998 of file gwf-npf.f90.

2999 ! -- dummy
3000 class(GwfNpfType) :: this
3001 integer(I4B), intent(in) :: nedges
3002 !
3003 this%nedges = this%nedges + nedges

◆ log_griddata()

subroutine gwfnpfmodule::log_griddata ( class(gwfnpftype) this,
type(gwfnpfparamfoundtype), intent(in) found )
private

Definition at line 1770 of file gwf-npf.f90.

1771 ! -- modules
1773 ! -- dummy
1774 class(GwfNpfType) :: this
1775 type(GwfNpfParamFoundType), intent(in) :: found
1776 !
1777 write (this%iout, '(1x,a)') 'Setting NPF Griddata'
1778 !
1779 if (found%icelltype) then
1780 write (this%iout, '(4x,a)') 'ICELLTYPE set from input file'
1781 end if
1782 !
1783 if (found%k) then
1784 write (this%iout, '(4x,a)') 'K set from input file'
1785 end if
1786 !
1787 if (found%k33) then
1788 write (this%iout, '(4x,a)') 'K33 set from input file'
1789 else
1790 write (this%iout, '(4x,a)') 'K33 not provided. Setting K33 = K.'
1791 end if
1792 !
1793 if (found%k22) then
1794 write (this%iout, '(4x,a)') 'K22 set from input file'
1795 else
1796 write (this%iout, '(4x,a)') 'K22 not provided. Setting K22 = K.'
1797 end if
1798 !
1799 if (found%wetdry) then
1800 write (this%iout, '(4x,a)') 'WETDRY set from input file'
1801 end if
1802 !
1803 if (found%angle1) then
1804 write (this%iout, '(4x,a)') 'ANGLE1 set from input file'
1805 end if
1806 !
1807 if (found%angle2) then
1808 write (this%iout, '(4x,a)') 'ANGLE2 set from input file'
1809 end if
1810 !
1811 if (found%angle3) then
1812 write (this%iout, '(4x,a)') 'ANGLE3 set from input file'
1813 end if
1814 !
1815 write (this%iout, '(1x,a,/)') 'End Setting NPF Griddata'

◆ log_options()

subroutine gwfnpfmodule::log_options ( class(gwfnpftype) this,
type(gwfnpfparamfoundtype), intent(in) found )
private

Definition at line 1516 of file gwf-npf.f90.

1517 ! -- modules
1518 use kindmodule, only: lgp
1520 ! -- dummy
1521 class(GwfNpftype) :: this
1522 ! -- locals
1523 type(GwfNpfParamFoundType), intent(in) :: found
1524 !
1525 write (this%iout, '(1x,a)') 'Setting NPF Options'
1526 if (found%iprflow) &
1527 write (this%iout, '(4x,a)') 'Cell-by-cell flow information will be printed &
1528 &to listing file whenever ICBCFL is not zero.'
1529 if (found%ipakcb) &
1530 write (this%iout, '(4x,a)') 'Cell-by-cell flow information will be saved &
1531 &to binary file whenever ICBCFL is not zero.'
1532 if (found%cellavg) &
1533 write (this%iout, '(4x,a,i0)') 'Alternative cell averaging [1=logarithmic, &
1534 &2=AMT-LMK, 3=AMT-HMK] set to: ', &
1535 this%icellavg
1536 if (found%ithickstrt) &
1537 write (this%iout, '(4x,a)') 'THICKSTRT option has been activated.'
1538 if (found%ihighcellsat) &
1539 write (this%iout, '(4x,a)') 'HIGHEST_CELL_SATURATION option &
1540 &has been activated.'
1541 if (found%iperched) &
1542 write (this%iout, '(4x,a)') 'Vertical flow will be adjusted for perched &
1543 &conditions.'
1544 if (found%ivarcv) &
1545 write (this%iout, '(4x,a)') 'Vertical conductance varies with water table.'
1546 if (found%idewatcv) &
1547 write (this%iout, '(4x,a)') 'Vertical conductance is calculated using &
1548 &only the saturated thickness and properties &
1549 &of the overlying cell if the head in the &
1550 &underlying cell is below its top.'
1551 if (found%ixt3d) write (this%iout, '(4x,a)') 'XT3D formulation is selected.'
1552 if (found%ixt3drhs) &
1553 write (this%iout, '(4x,a)') 'XT3D RHS formulation is selected.'
1554 if (found%isavspdis) &
1555 write (this%iout, '(4x,a)') 'Specific discharge will be calculated at cell &
1556 &centers and written to DATA-SPDIS in budget &
1557 &file when requested.'
1558 if (found%isavsat) &
1559 write (this%iout, '(4x,a)') 'Saturation will be written to DATA-SAT in &
1560 &budget file when requested.'
1561 if (found%ik22overk) &
1562 write (this%iout, '(4x,a)') 'Values specified for K22 are anisotropy &
1563 &ratios and will be multiplied by K before &
1564 &being used in calculations.'
1565 if (found%ik33overk) &
1566 write (this%iout, '(4x,a)') 'Values specified for K33 are anisotropy &
1567 &ratios and will be multiplied by K before &
1568 &being used in calculations.'
1569 if (found%inewton) &
1570 write (this%iout, '(4x,a)') 'NEWTON-RAPHSON method disabled for unconfined &
1571 &cells'
1572 if (found%satomega) &
1573 write (this%iout, '(4x,a,1pg15.6)') 'Saturation omega: ', this%satomega
1574 if (found%irewet) &
1575 write (this%iout, '(4x,a)') 'Rewetting is active.'
1576 if (found%wetfct) &
1577 write (this%iout, '(4x,a,1pg15.6)') &
1578 'Wetting factor (WETFCT) has been set to: ', this%wetfct
1579 if (found%iwetit) &
1580 write (this%iout, '(4x,a,i5)') &
1581 'Wetting iteration interval (IWETIT) has been set to: ', this%iwetit
1582 if (found%ihdwet) &
1583 write (this%iout, '(4x,a,i5)') &
1584 'Head rewet equation (IHDWET) has been set to: ', this%ihdwet
1585 write (this%iout, '(1x,a,/)') 'End Setting NPF Options'
This module defines variable data types.
Definition kind.f90:8

◆ npf_ac()

subroutine gwfnpfmodule::npf_ac ( class(gwfnpftype) this,
integer(i4b), intent(in) moffset,
type(sparsematrix), intent(inout) sparse )
private

Definition at line 288 of file gwf-npf.f90.

289 ! -- modules
290 use sparsemodule, only: sparsematrix
291 ! -- dummy
292 class(GwfNpftype) :: this
293 integer(I4B), intent(in) :: moffset
294 type(sparsematrix), intent(inout) :: sparse
295 !
296 ! -- Add extended neighbors (neighbors of neighbors)
297 if (this%ixt3d /= 0) call this%xt3d%xt3d_ac(moffset, sparse)

◆ npf_ad()

subroutine gwfnpfmodule::npf_ad ( class(gwfnpftype) this,
integer(i4b), intent(in) nodes,
real(dp), dimension(nodes), intent(inout) hold,
real(dp), dimension(nodes), intent(inout) hnew,
integer(i4b), intent(in) irestore )
private

Sets hold (head old) to bot whenever a wettable cell is dry

Definition at line 431 of file gwf-npf.f90.

432 ! -- modules
433 use tdismodule, only: kper, kstp
434 !
435 implicit none
436 ! -- dummy
437 class(GwfNpfType) :: this
438 integer(I4B), intent(in) :: nodes
439 real(DP), dimension(nodes), intent(inout) :: hold
440 real(DP), dimension(nodes), intent(inout) :: hnew
441 integer(I4B), intent(in) :: irestore
442 ! -- local
443 integer(I4B) :: n
444 !
445 ! -- loop through all cells and set hold=bot if wettable cell is dry
446 if (this%irewet > 0) then
447 do n = 1, this%dis%nodes
448 if (this%wetdry(n) == dzero) cycle
449 if (this%ibound(n) /= 0) cycle
450 hold(n) = this%dis%bot(n)
451 end do
452 !
453 ! -- if restore state, then set hnew to DRY if it is a dry wettable cell
454 do n = 1, this%dis%nodes
455 if (this%wetdry(n) == dzero) cycle
456 if (this%ibound(n) /= 0) cycle
457 hnew(n) = dhdry
458 end do
459 end if
460 !
461 ! -- TVK
462 if (this%intvk /= 0) then
463 call this%tvk%ad()
464 end if
465 !
466 ! -- VSC
467 ! -- Hit the TVK-updated K's with VSC correction before calling/updating condsat
468 if (this%invsc /= 0) then
469 call this%vsc%update_k_with_vsc()
470 end if
471 !
472 ! -- If any K values have changed, we need to update CONDSAT or XT3D arrays
473 if (this%kchangeper == kper .and. this%kchangestp == kstp) then
474 if (this%ixt3d == 0) then
475 !
476 ! -- Update the saturated conductance for all connections
477 ! -- of the affected nodes
478 do n = 1, this%dis%nodes
479 if (this%nodekchange(n) == 1) then
480 call this%calc_condsat(n, .false.)
481 end if
482 end do
483 else
484 !
485 ! -- Recompute XT3D coefficients for permanently confined connections
486 if (this%xt3d%lamatsaved .and. .not. this%xt3d%ldispersion) then
487 call this%xt3d%xt3d_fcpc(this%dis%nodes, .true.)
488 end if
489 end if
490 end if
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

◆ npf_ar()

subroutine gwfnpfmodule::npf_ar ( class(gwfnpftype) this,
type(gwfictype), intent(in), pointer ic,
type(gwfvsctype), intent(in), pointer vsc,
integer(i4b), dimension(:), intent(inout), pointer, contiguous ibound,
real(dp), dimension(:), intent(inout), pointer, contiguous hnew )
private

Allocate remaining package arrays, preprocess the input data and call *_ar on xt3d, when active.

Parameters
thisinstance of the NPF package
[in]icinitial conditions
[in]vscviscosity package
[in,out]iboundmodel ibound array
[in,out]hnewpointer to model head array

Definition at line 316 of file gwf-npf.f90.

317 ! -- modules
320 ! -- dummy
321 class(GwfNpftype) :: this !< instance of the NPF package
322 type(GwfIcType), pointer, intent(in) :: ic !< initial conditions
323 type(GwfVscType), pointer, intent(in) :: vsc !< viscosity package
324 integer(I4B), dimension(:), pointer, contiguous, intent(inout) :: ibound !< model ibound array
325 real(DP), dimension(:), pointer, contiguous, intent(inout) :: hnew !< pointer to model head array
326 ! -- local
327 integer(I4B) :: n
328 !
329 ! -- Store pointers to arguments that were passed in
330 this%ic => ic
331 this%ibound => ibound
332 this%hnew => hnew
333 !
334 if (this%icalcspdis == 1) then
335 call mem_reallocate(this%spdis, 3, this%dis%nodes, 'SPDIS', this%memoryPath)
336 call mem_reallocate(this%nodedge, this%nedges, 'NODEDGE', this%memoryPath)
337 call mem_reallocate(this%ihcedge, this%nedges, 'IHCEDGE', this%memoryPath)
338 call mem_reallocate(this%propsedge, 5, this%nedges, 'PROPSEDGE', &
339 this%memoryPath)
340 call mem_reallocate(this%iedge_ptr, this%dis%nodes + 1, &
341 'NREDGESNODE', this%memoryPath)
342 call mem_reallocate(this%edge_idxs, this%nedges, &
343 'EDGEIDXS', this%memoryPath)
344
345 do n = 1, this%nedges
346 this%edge_idxs(n) = 0
347 end do
348 do n = 1, this%dis%nodes
349 this%iedge_ptr(n) = 0
350 this%spdis(:, n) = dzero
351 end do
352 end if
353 !
354 ! -- Store pointer to VSC if active
355 if (this%invsc /= 0) then
356 this%vsc => vsc
357 end if
358 !
359 ! -- allocate arrays to store K before VSC adjustment
360 if (this%invsc > 0) then
361 !
362 ! -- Reallocate arrays that store K before VSC adjustment.
363 call mem_reallocate(this%k11input, this%dis%nodes, 'K11INPUT', &
364 this%memoryPath)
365 call mem_reallocate(this%k22input, this%dis%nodes, 'K22INPUT', &
366 this%memoryPath)
367 call mem_reallocate(this%k33input, this%dis%nodes, 'K33INPUT', &
368 this%memoryPath)
369 ! Store K before VSC adjustment; TVK changes are made to these arrays.
370 ! When VSC active, the current Kxx arrays carry the viscosity-adjusted
371 ! K values.
372 ! This approach leverages existing functionality that makes use of K.
373 call this%store_original_k_arrays(this%dis%nodes, this%dis%njas)
374 end if
375 !
376 ! -- preprocess data
377 call this%preprocess_input()
378 !
379 ! -- xt3d
380 ! -- Terminate if the DISU ANGLDEGX values are inconsistent and this
381 ! package requires ANGLDEGX (it has no effect otherwise)
382 if (this%ixt3d /= 0 .or. this%ik22 /= 0 .or. this%icalcspdis /= 0) then
383 select type (dis => this%dis)
384 type is (disutype)
385 if (dis%nangldegxerr > 0) then
386 write (errmsg, '(a,1x,i0,1x,a)') &
387 'ANGLDEGX values in the DISU Package are inconsistent for', &
388 dis%nangldegxerr, 'cell faces (see the warnings written after &
389 &the DISU Package input in the model listing file). ANGLDEGX &
390 &must be correct because it is required input for the NPF &
391 &Package when XT3D, K22, or SAVE_SPECIFIC_DISCHARGE is specified.'
392 call store_error(errmsg)
393 call store_error_filename(dis%input_fname)
394 end if
395 end select
396 end if
397 !
398 if (this%ixt3d /= 0) then
399 call this%xt3d%xt3d_ar(ibound, this%k11, this%ik33, this%k33, &
400 this%sat, this%ik22, this%k22, &
401 this%iangle1, this%iangle2, this%iangle3, &
402 this%angle1, this%angle2, this%angle3, &
403 this%inewton, this%icelltype)
404 end if
405 !
406 ! -- TVK
407 if (this%intvk /= 0) then
408 call this%tvk%ar(this%dis)
409 end if
Here is the call graph for this function:

◆ npf_cf()

subroutine gwfnpfmodule::npf_cf ( class(gwfnpftype) this,
integer(i4b) kiter,
integer(i4b), intent(in) nodes,
real(dp), dimension(nodes), intent(inout) hnew )
private

Definition at line 495 of file gwf-npf.f90.

496 class(GwfNpfType) :: this
497 integer(I4B) :: kiter
498 integer(I4B), intent(in) :: nodes
499 real(DP), intent(inout), dimension(nodes) :: hnew
500 ! local
501 integer(I4B) :: iform
502
503 ! Perform wetting and drying
504 if (this%inewton /= 1) then
505 call this%wd(kiter, hnew)
506 end if
507
508 ! Each active formulation runs over all cells and adds its
509 ! terms; the default conductance formulation is always active.
510 call this%default_form%cf(kiter)
511 do iform = 1, max_ext_flow_forms
512 if (associated(this%flow_formulations(iform)%form)) then
513 call this%flow_formulations(iform)%form%cf(kiter)
514 end if
515 end do
516

◆ npf_cq()

subroutine gwfnpfmodule::npf_cq ( class(gwfnpftype) this,
real(dp), dimension(:), intent(inout) hnew,
real(dp), dimension(:), intent(inout) flowja )
private

Definition at line 965 of file gwf-npf.f90.

966 ! -- dummy
967 class(GwfNpfType) :: this
968 real(DP), intent(inout), dimension(:) :: hnew
969 real(DP), intent(inout), dimension(:) :: flowja
970 ! -- local
971 integer(I4B) :: iform
972 !
973 ! -- Calculate the flow across each cell face and store in flowja
974 !
975 if (this%ixt3d /= 0) then
976 call this%xt3d%xt3d_flowja(hnew, flowja)
977 else
978 ! Each active formulation runs over all connections and adds its
979 ! flows; the default conductance formulation is always active.
980 call this%default_form%cq(hnew, flowja)
981 do iform = 1, max_ext_flow_forms
982 if (associated(this%flow_formulations(iform)%form)) then
983 call this%flow_formulations(iform)%form%cq(hnew, flowja)
984 end if
985 end do
986 end if

◆ npf_cr()

subroutine, public gwfnpfmodule::npf_cr ( type(gwfnpftype), pointer npfobj,
character(len=*), intent(in) name_model,
character(len=*), intent(in) input_mempath,
integer(i4b), intent(in) inunit,
integer(i4b), intent(in) iout )

Definition at line 188 of file gwf-npf.f90.

189 ! -- modules
190 use kindmodule, only: lgp
192 ! -- dummy
193 type(GwfNpfType), pointer :: npfobj
194 character(len=*), intent(in) :: name_model
195 character(len=*), intent(in) :: input_mempath
196 integer(I4B), intent(in) :: inunit
197 integer(I4B), intent(in) :: iout
198 ! -- formats
199 character(len=*), parameter :: fmtheader = &
200 "(1x, /1x, 'NPF -- NODE PROPERTY FLOW PACKAGE, VERSION 1, 3/30/2015', &
201 &' INPUT READ FROM MEMPATH: ', A, /)"
202 !
203 ! -- Create the object
204 allocate (npfobj)
205 !
206 ! -- create name and memory path
207 call npfobj%set_names(1, name_model, 'NPF', 'NPF', input_mempath)
208 !
209 ! -- Allocate scalars
210 call npfobj%allocate_scalars()
211 !
212 ! -- Set variables
213 npfobj%inunit = inunit
214 npfobj%iout = iout
215 !
216 ! -- check if npf is enabled
217 if (inunit > 0) then
218 !
219 ! -- Print a message identifying the node property flow package.
220 write (iout, fmtheader) input_mempath
221 end if
222
223 ! allocate spdis structure
224 allocate (npfobj%spdis_wa)
225
Here is the caller graph for this function:

◆ npf_da()

subroutine gwfnpfmodule::npf_da ( class(gwfnpftype) this)
private

Definition at line 1211 of file gwf-npf.f90.

1212 ! -- modules
1215 ! -- dummy
1216 class(GwfNpftype) :: this
1217
1218 ! free spdis work structure
1219 if (this%icalcspdis == 1 .and. this%spdis_wa%is_created()) &
1220 call this%spdis_wa%destroy()
1221 deallocate (this%spdis_wa)
1222 !
1223 ! -- Deallocate input memory
1224 call memorystore_remove(this%name_model, 'NPF', idm_context)
1225 !
1226 ! -- TVK
1227 if (this%intvk /= 0) then
1228 call this%tvk%da()
1229 deallocate (this%tvk)
1230 end if
1231 !
1232 ! -- VSC
1233 if (this%invsc /= 0) then
1234 nullify (this%vsc)
1235 end if
1236 !
1237 ! -- Scalars
1238 call mem_deallocate(this%iname)
1239 call mem_deallocate(this%ixt3d)
1240 call mem_deallocate(this%ixt3drhs)
1241 call mem_deallocate(this%satomega)
1242 call mem_deallocate(this%hnoflo)
1243 call mem_deallocate(this%hdry)
1244 call mem_deallocate(this%icellavg)
1245 call mem_deallocate(this%iavgkeff)
1246 call mem_deallocate(this%ik22)
1247 call mem_deallocate(this%ik33)
1248 call mem_deallocate(this%iperched)
1249 call mem_deallocate(this%ivarcv)
1250 call mem_deallocate(this%idewatcv)
1251 call mem_deallocate(this%ithickstrt)
1252 call mem_deallocate(this%ihighcellsat)
1253 call mem_deallocate(this%isavspdis)
1254 call mem_deallocate(this%isavsat)
1255 call mem_deallocate(this%icalcspdis)
1256 call mem_deallocate(this%irewet)
1257 call mem_deallocate(this%wetfct)
1258 call mem_deallocate(this%iwetit)
1259 call mem_deallocate(this%ihdwet)
1260 call mem_deallocate(this%ibotnode)
1261 call mem_deallocate(this%iwetdry)
1262 call mem_deallocate(this%iangle1)
1263 call mem_deallocate(this%iangle2)
1264 call mem_deallocate(this%iangle3)
1265 call mem_deallocate(this%nedges)
1266 call mem_deallocate(this%lastedge)
1267 call mem_deallocate(this%ik22overk)
1268 call mem_deallocate(this%ik33overk)
1269 call mem_deallocate(this%intvk)
1270 call mem_deallocate(this%invsc)
1271 call mem_deallocate(this%kchangeper)
1272 call mem_deallocate(this%kchangestp)
1273 !
1274 ! -- Deallocate arrays
1275 deallocate (this%aname)
1276 call mem_deallocate(this%ithickstartflag)
1277 call mem_deallocate(this%icelltype)
1278 call mem_deallocate(this%k11)
1279 call mem_deallocate(this%k22)
1280 call mem_deallocate(this%k33)
1281 call mem_deallocate(this%krel)
1282 call mem_deallocate(this%k11input)
1283 call mem_deallocate(this%k22input)
1284 call mem_deallocate(this%k33input)
1285 call mem_deallocate(this%sat, 'SAT', this%memoryPath)
1286 call mem_deallocate(this%condsat)
1287 call mem_deallocate(this%wetdry)
1288 call mem_deallocate(this%angle1)
1289 call mem_deallocate(this%angle2)
1290 call mem_deallocate(this%angle3)
1291 call mem_deallocate(this%nodedge)
1292 call mem_deallocate(this%ihcedge)
1293 call mem_deallocate(this%propsedge)
1294 call mem_deallocate(this%iedge_ptr)
1295 call mem_deallocate(this%edge_idxs)
1296 call mem_deallocate(this%spdis, 'SPDIS', this%memoryPath)
1297 call mem_deallocate(this%nodekchange)
1298 call mem_deallocate(this%iformulation)
1299 !
1300 ! -- deallocate the default conductance formulation
1301 if (associated(this%default_form)) then
1302 deallocate (this%default_form)
1303 this%default_form => null()
1304 end if
1305 !
1306 ! -- deallocate parent
1307 call this%NumericalPackageType%da()
1308
1309 ! pointers
1310 this%hnew => null()
1311
subroutine, public memorystore_remove(component, subcomponent, context)
This module contains simulation variables.
character(len=linelength) idm_context
Here is the call graph for this function:

◆ npf_df()

subroutine gwfnpfmodule::npf_df ( class(gwfnpftype) this,
class(disbasetype), intent(inout), pointer dis,
type(xt3dtype), pointer xt3d,
integer(i4b), intent(in) ingnc,
integer(i4b), intent(in) invsc,
type(gwfnpfoptionstype), intent(in), optional npf_options )
private

This is a hybrid routine: it either reads the options for this package from the input file, or the optional argument npf_options should be passed. A consistency check is performed, and finally xt3d_df is called, when enabled.

Parameters
thisinstance of the NPF package
[in,out]disthe pointer to the discretization
xt3dthe pointer to the XT3D 'package'
[in]ingncghostnodes enabled? (>0 means yes)
[in]invscviscosity enabled? (>0 means yes)
[in]npf_optionsthe optional options, for when not constructing from file

Definition at line 235 of file gwf-npf.f90.

236 ! -- modules
237 use simmodule, only: store_error
238 use xt3dmodule, only: xt3d_cr
239 ! -- dummy
240 class(GwfNpftype) :: this !< instance of the NPF package
241 class(DisBaseType), pointer, intent(inout) :: dis !< the pointer to the discretization
242 type(Xt3dType), pointer :: xt3d !< the pointer to the XT3D 'package'
243 integer(I4B), intent(in) :: ingnc !< ghostnodes enabled? (>0 means yes)
244 integer(I4B), intent(in) :: invsc !< viscosity enabled? (>0 means yes)
245 type(GwfNpfOptionsType), optional, intent(in) :: npf_options !< the optional options, for when not constructing from file
246 !
247 ! -- Set a pointer to dis
248 this%dis => dis
249 !
250 ! -- Set flag signifying whether vsc is active
251 if (invsc > 0) this%invsc = invsc
252 !
253 if (.not. present(npf_options)) then
254 !
255 ! -- source options
256 call this%source_options()
257 !
258 ! -- allocate arrays
259 call this%allocate_arrays(this%dis%nodes, this%dis%njas)
260 !
261 ! -- source griddata, set, and convert/check the input
262 call this%source_griddata()
263 call this%prepcheck()
264 else
265 call this%set_options(npf_options)
266 !
267 ! -- allocate arrays
268 call this%allocate_arrays(this%dis%nodes, this%dis%njas)
269 end if
270 !
271 call this%check_options()
272 !
273 ! -- Save pointer to xt3d object
274 this%xt3d => xt3d
275 if (this%ixt3d /= 0) xt3d%ixt3d = this%ixt3d
276 call this%xt3d%xt3d_df(dis)
277 !
278 ! -- Ensure GNC and XT3D are not both on at the same time
279 if (this%ixt3d /= 0 .and. ingnc > 0) then
280 call store_error('Error in model '//trim(this%name_model)// &
281 '. The XT3D option cannot be used with the GNC &
282 &Package.', terminate=.true.)
283 end if
subroutine, public xt3d_cr(xt3dobj, name_model, inunit, iout, ldispopt)
Create a new xt3d object.
Here is the call graph for this function:

◆ npf_fc()

subroutine gwfnpfmodule::npf_fc ( class(gwfnpftype) this,
integer(i4b) kiter,
class(matrixbasetype), pointer matrix_sln,
integer(i4b), dimension(:), intent(in) idxglo,
real(dp), dimension(:), intent(inout) rhs,
real(dp), dimension(:), intent(inout) hnew )
private
Parameters
thisthis instance
kiterouter iteration number
matrix_slnthe system to be formulated
[in]idxglolookup table from local to global connection number
[in,out]rhsthe righthandside vector
[in,out]hnewthe new head values

Definition at line 562 of file gwf-npf.f90.

563 class(GwfNpfType) :: this !< this instance
564 integer(I4B) :: kiter !< outer iteration number
565 class(MatrixBaseType), pointer :: matrix_sln !< the system to be formulated
566 integer(I4B), intent(in), dimension(:) :: idxglo !< lookup table from local to global connection number
567 real(DP), intent(inout), dimension(:) :: rhs !< the righthandside vector
568 real(DP), intent(inout), dimension(:) :: hnew !< the new head values
569 ! local
570 integer(I4B) :: iform
571
572 if (this%ixt3d /= 0) then
573 call this%xt3d%xt3d_fc(kiter, matrix_sln, idxglo, rhs, hnew)
574 else
575 ! Each active formulation runs over all connections and adds its
576 ! terms; the default conductance formulation is always active.
577 call this%default_form%fc(kiter, matrix_sln, idxglo, rhs, hnew)
578 do iform = 1, max_ext_flow_forms
579 if (associated(this%flow_formulations(iform)%form)) then
580 call this%flow_formulations(iform)%form%fc(kiter, matrix_sln, &
581 idxglo, rhs, hnew)
582 end if
583 end do
584 end if
585

◆ npf_fn()

subroutine gwfnpfmodule::npf_fn ( class(gwfnpftype) this,
integer(i4b) kiter,
class(matrixbasetype), pointer matrix_sln,
integer(i4b), dimension(:), intent(in) idxglo,
real(dp), dimension(:), intent(inout) rhs,
real(dp), dimension(:), intent(inout) hnew )
private

Definition at line 748 of file gwf-npf.f90.

749 ! -- dummy
750 class(GwfNpfType) :: this
751 integer(I4B) :: kiter
752 class(MatrixBaseType), pointer :: matrix_sln
753 integer(I4B), intent(in), dimension(:) :: idxglo
754 real(DP), intent(inout), dimension(:) :: rhs
755 real(DP), intent(inout), dimension(:) :: hnew
756 ! -- local
757 integer(I4B) :: nodes, nja
758 integer(I4B) :: iform
759 !
760 ! -- add newton terms to solution matrix
761 nodes = this%dis%nodes
762 nja = this%dis%con%nja
763 if (this%ixt3d /= 0) then
764 call this%xt3d%xt3d_fn(kiter, nodes, nja, matrix_sln, idxglo, rhs, hnew)
765 else
766 ! Each active formulation runs over all connections and adds its
767 ! newton terms; the default conductance formulation is always active.
768 call this%default_form%fn(kiter, matrix_sln, idxglo, rhs, hnew)
769 do iform = 1, max_ext_flow_forms
770 if (associated(this%flow_formulations(iform)%form)) then
771 call this%flow_formulations(iform)%form%fn(kiter, matrix_sln, &
772 idxglo, rhs, hnew)
773 end if
774 end do
775 end if

◆ npf_mc()

subroutine gwfnpfmodule::npf_mc ( class(gwfnpftype) this,
integer(i4b), intent(in) moffset,
class(matrixbasetype), pointer matrix_sln )
private

Definition at line 302 of file gwf-npf.f90.

303 ! -- dummy
304 class(GwfNpftype) :: this
305 integer(I4B), intent(in) :: moffset
306 class(MatrixBaseType), pointer :: matrix_sln
307 !
308 if (this%ixt3d /= 0) call this%xt3d%xt3d_mc(moffset, matrix_sln)

◆ npf_nur()

subroutine gwfnpfmodule::npf_nur ( class(gwfnpftype) this,
integer(i4b), intent(in) neqmod,
real(dp), dimension(neqmod), intent(inout) x,
real(dp), dimension(neqmod), intent(in) xtemp,
real(dp), dimension(neqmod), intent(inout) dx,
integer(i4b), intent(inout) inewtonur,
real(dp), intent(inout) dxmax,
integer(i4b), intent(inout) locmax )
private

Under-relaxation of Groundwater Flow Model Heads for current outer iteration using the cell bottoms at the bottom of the model

Definition at line 921 of file gwf-npf.f90.

922 ! -- dummy
923 class(GwfNpfType) :: this
924 integer(I4B), intent(in) :: neqmod
925 real(DP), dimension(neqmod), intent(inout) :: x
926 real(DP), dimension(neqmod), intent(in) :: xtemp
927 real(DP), dimension(neqmod), intent(inout) :: dx
928 integer(I4B), intent(inout) :: inewtonur
929 real(DP), intent(inout) :: dxmax
930 integer(I4B), intent(inout) :: locmax
931 ! -- local
932 integer(I4B) :: n
933 integer(I4B) :: ibot
934 real(DP) :: botm
935 real(DP) :: xx
936 real(DP) :: dxx
937 !
938 ! -- Newton-Raphson under-relaxation
939 do n = 1, this%dis%nodes
940 if (this%ibound(n) < 1) cycle
941 ibot = this%ibotnode(n)
942 ! Newton-Raphson under-relaxation is only applied to convertible cells where
943 ! the bottom cell in a stack is convertible
944 if (this%icelltype(n) > 0 .and. this%icelltype(ibot) > 0) then
945 botm = this%dis%bot(ibot)
946 ! Newton-Raphson under-relaxation applied when solution head is
947 ! below the bottom of the model
948 if (x(n) < botm) then
949 inewtonur = 1
950 xx = xtemp(n) * (done - dp9) + botm * dp9
951 dxx = xx - xtemp(n)
952 if (abs(dxx) > abs(dxmax)) then
953 locmax = n
954 dxmax = dxx
955 end if
956 x(n) = xx
957 dx(n) = xtemp(n) - x(n)
958 end if
959 end if
960 end do

◆ npf_print_model_flows()

subroutine gwfnpfmodule::npf_print_model_flows ( class(gwfnpftype) this,
integer(i4b), intent(in) ibudfl,
real(dp), dimension(:), intent(inout) flowja )
private

Definition at line 1172 of file gwf-npf.f90.

1173 ! -- modules
1174 use tdismodule, only: kper, kstp
1175 use constantsmodule, only: lenbigline
1176 ! -- dummy
1177 class(GwfNpfType) :: this
1178 integer(I4B), intent(in) :: ibudfl
1179 real(DP), intent(inout), dimension(:) :: flowja
1180 ! -- local
1181 character(len=LENBIGLINE) :: line
1182 character(len=30) :: tempstr
1183 integer(I4B) :: n, ipos, m
1184 real(DP) :: qnm
1185 ! -- formats
1186 character(len=*), parameter :: fmtiprflow = &
1187 &"(/,4x,'CALCULATED INTERCELL FLOW FOR PERIOD ', i0, ' STEP ', i0)"
1188 !
1189 ! -- Write flowja to list file if requested
1190 if (ibudfl /= 0 .and. this%iprflow > 0) then
1191 write (this%iout, fmtiprflow) kper, kstp
1192 do n = 1, this%dis%nodes
1193 line = ''
1194 call this%dis%noder_to_string(n, tempstr)
1195 line = trim(tempstr)//':'
1196 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
1197 m = this%dis%con%ja(ipos)
1198 call this%dis%noder_to_string(m, tempstr)
1199 line = trim(line)//' '//trim(tempstr)
1200 qnm = flowja(ipos)
1201 write (tempstr, '(1pg15.6)') qnm
1202 line = trim(line)//' '//trim(adjustl(tempstr))
1203 end do
1204 write (this%iout, '(a)') trim(line)
1205 end do
1206 end if
integer(i4b), parameter lenbigline
maximum length of a big line
Definition Constants.f90:15

◆ npf_rp()

subroutine gwfnpfmodule::npf_rp ( class(gwfnpftype) this)
private

Read and prepare NPF stress period data.

Definition at line 416 of file gwf-npf.f90.

417 implicit none
418 ! -- dummy
419 class(GwfNpfType) :: this
420 !
421 ! -- TVK
422 if (this%intvk /= 0) then
423 call this%tvk%rp()
424 end if

◆ npf_save_model_flows()

subroutine gwfnpfmodule::npf_save_model_flows ( class(gwfnpftype) this,
real(dp), dimension(:), intent(in) flowja,
integer(i4b), intent(in) icbcfl,
integer(i4b), intent(in) icbcun )
private

Definition at line 1135 of file gwf-npf.f90.

1136 ! -- dummy
1137 class(GwfNpfType) :: this
1138 real(DP), dimension(:), intent(in) :: flowja
1139 integer(I4B), intent(in) :: icbcfl
1140 integer(I4B), intent(in) :: icbcun
1141 ! -- local
1142 integer(I4B) :: ibinun
1143 !
1144 ! -- Set unit number for binary output
1145 if (this%ipakcb < 0) then
1146 ibinun = icbcun
1147 elseif (this%ipakcb == 0) then
1148 ibinun = 0
1149 else
1150 ibinun = this%ipakcb
1151 end if
1152 if (icbcfl == 0) ibinun = 0
1153 !
1154 ! -- Write the face flows if requested
1155 if (ibinun /= 0) then
1156 call this%dis%record_connection_array(flowja, ibinun, this%iout)
1157 end if
1158 !
1159 ! -- Calculate specific discharge at cell centers and write, if requested
1160 if (this%isavspdis /= 0) then
1161 if (ibinun /= 0) call this%sav_spdis(ibinun)
1162 end if
1163 !
1164 ! -- Save saturation, if requested
1165 if (this%isavsat /= 0) then
1166 if (ibinun /= 0) call this%sav_sat(ibinun)
1167 end if

◆ prepare_edge_lookup()

subroutine gwfnpfmodule::prepare_edge_lookup ( class(gwfnpftype) this)
private

Definition at line 3064 of file gwf-npf.f90.

3065 class(GwfNpfType) :: this
3066 ! local
3067 integer(I4B) :: i, inode, iedge
3068 integer(I4B) :: n, start, end
3069 integer(I4B) :: prev_cnt, strt_idx, ipos
3070
3071 do i = 1, size(this%iedge_ptr)
3072 this%iedge_ptr(i) = 0
3073 end do
3074 do i = 1, size(this%edge_idxs)
3075 this%edge_idxs(i) = 0
3076 end do
3077
3078 ! count
3079 do iedge = 1, this%nedges
3080 n = this%nodedge(iedge)
3081 this%iedge_ptr(n) = this%iedge_ptr(n) + 1
3082 end do
3083
3084 ! determine start indexes
3085 prev_cnt = this%iedge_ptr(1)
3086 this%iedge_ptr(1) = 1
3087 do inode = 2, this%dis%nodes + 1
3088 strt_idx = this%iedge_ptr(inode - 1) + prev_cnt
3089 prev_cnt = this%iedge_ptr(inode)
3090 this%iedge_ptr(inode) = strt_idx
3091 end do
3092
3093 ! loop over edges to fill lookup table
3094 do iedge = 1, this%nedges
3095 n = this%nodedge(iedge)
3096 start = this%iedge_ptr(n)
3097 end = this%iedge_ptr(n + 1) - 1
3098 do ipos = start, end
3099 if (this%edge_idxs(ipos) > 0) cycle ! go to next
3100 this%edge_idxs(ipos) = iedge
3101 exit
3102 end do
3103 end do
3104

◆ prepcheck()

subroutine gwfnpfmodule::prepcheck ( class(gwfnpftype) this)
private

Definition at line 1915 of file gwf-npf.f90.

1916 ! -- modules
1919 ! -- dummy
1920 class(GwfNpfType) :: this
1921 ! -- local
1922 character(len=24), dimension(:), pointer :: aname
1923 character(len=LINELENGTH) :: cellstr, errmsg
1924 integer(I4B) :: nerr, n
1925 ! -- format
1926 character(len=*), parameter :: fmtkerr = &
1927 &"(1x, 'Hydraulic property ',a,' is <= 0 for cell ',a, ' ', 1pg15.6)"
1928 character(len=*), parameter :: fmtkerr2 = &
1929 &"(1x, '... ', i0,' additional errors not shown for ',a)"
1930 !
1931 ! -- initialize
1932 aname => this%aname
1933 !
1934 ! -- check k11
1935 nerr = 0
1936 do n = 1, size(this%k11)
1937 if (this%k11(n) <= dzero) then
1938 nerr = nerr + 1
1939 if (nerr <= 20) then
1940 call this%dis%noder_to_string(n, cellstr)
1941 write (errmsg, fmtkerr) trim(adjustl(aname(2))), trim(cellstr), &
1942 this%k11(n)
1943 call store_error(errmsg)
1944 end if
1945 end if
1946 end do
1947 if (nerr > 20) then
1948 write (errmsg, fmtkerr2) nerr, trim(adjustl(aname(2)))
1949 call store_error(errmsg)
1950 end if
1951 !
1952 ! -- check k33 because it was read
1953 if (this%ik33 /= 0) then
1954 !
1955 ! -- Check to make sure values are greater than or equal to zero
1956 nerr = 0
1957 do n = 1, size(this%k33)
1958 if (this%ik33overk /= 0) this%k33(n) = this%k33(n) * this%k11(n)
1959 if (this%k33(n) <= dzero) then
1960 nerr = nerr + 1
1961 if (nerr <= 20) then
1962 call this%dis%noder_to_string(n, cellstr)
1963 write (errmsg, fmtkerr) trim(adjustl(aname(3))), trim(cellstr), &
1964 this%k33(n)
1965 call store_error(errmsg)
1966 end if
1967 end if
1968 end do
1969 if (nerr > 20) then
1970 write (errmsg, fmtkerr2) nerr, trim(adjustl(aname(3)))
1971 call store_error(errmsg)
1972 end if
1973 end if
1974 !
1975 ! -- check k22 because it was read
1976 if (this%ik22 /= 0) then
1977 !
1978 ! -- Check to make sure that angles are available
1979 if (this%dis%con%ianglex == 0) then
1980 write (errmsg, '(a)') 'Error. ANGLDEGX not provided in '// &
1981 'discretization file, but K22 was specified. '
1982 call store_error(errmsg)
1983 end if
1984 !
1985 ! -- Check to make sure values are greater than or equal to zero
1986 nerr = 0
1987 do n = 1, size(this%k22)
1988 if (this%ik22overk /= 0) this%k22(n) = this%k22(n) * this%k11(n)
1989 if (this%k22(n) <= dzero) then
1990 nerr = nerr + 1
1991 if (nerr <= 20) then
1992 call this%dis%noder_to_string(n, cellstr)
1993 write (errmsg, fmtkerr) trim(adjustl(aname(4))), trim(cellstr), &
1994 this%k22(n)
1995 call store_error(errmsg)
1996 end if
1997 end if
1998 end do
1999 if (nerr > 20) then
2000 write (errmsg, fmtkerr2) nerr, trim(adjustl(aname(4)))
2001 call store_error(errmsg)
2002 end if
2003 end if
2004 !
2005 ! -- check for wetdry conflicts
2006 if (this%irewet == 1) then
2007 if (this%iwetdry == 0) then
2008 write (errmsg, '(a, a, a)') 'Error in GRIDDATA block: ', &
2009 trim(adjustl(aname(5))), ' not found.'
2010 call store_error(errmsg)
2011 end if
2012 end if
2013 !
2014 ! -- Check for angle conflicts
2015 if (this%iangle1 /= 0) then
2016 do n = 1, size(this%angle1)
2017 this%angle1(n) = this%angle1(n) * dpio180
2018 end do
2019 else
2020 if (this%ixt3d /= 0) then
2021 this%iangle1 = 1
2022 write (this%iout, '(a)') 'XT3D IN USE, BUT ANGLE1 NOT SPECIFIED. '// &
2023 'SETTING ANGLE1 TO ZERO.'
2024 do n = 1, size(this%angle1)
2025 this%angle1(n) = dzero
2026 end do
2027 end if
2028 end if
2029 if (this%iangle2 /= 0) then
2030 if (this%iangle1 == 0) then
2031 write (errmsg, '(a)') 'ANGLE2 SPECIFIED BUT NOT ANGLE1. '// &
2032 'ANGLE2 REQUIRES ANGLE1. '
2033 call store_error(errmsg)
2034 end if
2035 if (this%iangle3 == 0) then
2036 write (errmsg, '(a)') 'ANGLE2 SPECIFIED BUT NOT ANGLE3. '// &
2037 'SPECIFY BOTH OR NEITHER ONE. '
2038 call store_error(errmsg)
2039 end if
2040 do n = 1, size(this%angle2)
2041 this%angle2(n) = this%angle2(n) * dpio180
2042 end do
2043 end if
2044 if (this%iangle3 /= 0) then
2045 if (this%iangle1 == 0) then
2046 write (errmsg, '(a)') 'ANGLE3 SPECIFIED BUT NOT ANGLE1. '// &
2047 'ANGLE3 REQUIRES ANGLE1. '
2048 call store_error(errmsg)
2049 end if
2050 if (this%iangle2 == 0) then
2051 write (errmsg, '(a)') 'ANGLE3 SPECIFIED BUT NOT ANGLE2. '// &
2052 'SPECIFY BOTH OR NEITHER ONE. '
2053 call store_error(errmsg)
2054 end if
2055 do n = 1, size(this%angle3)
2056 this%angle3(n) = this%angle3(n) * dpio180
2057 end do
2058 end if
2059 !
2060 ! -- terminate if data errors
2061 if (count_errors() > 0) then
2062 call store_error_filename(this%input_fname)
2063 end if
real(dp), parameter dpio180
real constant
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
Here is the call graph for this function:

◆ preprocess_input()

subroutine gwfnpfmodule::preprocess_input ( class(gwfnpftype) this)
private

This routine consists of the following steps:

  1. convert cells to noflow when all transmissive parameters equal zero
  2. perform initial wetting and drying
  3. initialize cell saturation
  4. calculate saturated conductance (when not xt3d)
  5. If NEWTON under-relaxation, determine lower most node
    Parameters
    thisthe instance of the NPF package

Definition at line 2076 of file gwf-npf.f90.

2077 ! -- modules
2078 use constantsmodule, only: linelength
2080 ! -- dummy
2081 class(GwfNpfType) :: this !< the instance of the NPF package
2082 ! -- local
2083 integer(I4B) :: n, m, ii, nn
2084 real(DP) :: hyn, hym
2085 real(DP) :: satn, topn, botn
2086 integer(I4B) :: nextn
2087 real(DP) :: minbot, botm
2088 logical :: finished
2089 character(len=LINELENGTH) :: cellstr, errmsg
2090 ! -- format
2091 character(len=*), parameter :: fmtcnv = &
2092 "(1X,'CELL ', A, &
2093 &' ELIMINATED BECAUSE ALL HYDRAULIC CONDUCTIVITIES TO NODE ARE 0.')"
2094 character(len=*), parameter :: fmtnct = &
2095 &"(1X,'Negative cell thickness at cell ', A)"
2096 character(len=*), parameter :: fmtihbe = &
2097 &"(1X,'Initial head, bottom elevation:',1P,2G13.5)"
2098 character(len=*), parameter :: fmttebe = &
2099 &"(1X,'Top elevation, bottom elevation:',1P,2G13.5)"
2100 !
2101 do n = 1, this%dis%nodes
2102 this%ithickstartflag(n) = 0
2103 end do
2104 !
2105 ! -- Insure that each cell has at least one non-zero transmissive parameter
2106 ! Note that a cell can be deactivated even if it has a valid connection
2107 ! to another model.
2108 nodeloop: do n = 1, this%dis%nodes
2109 !
2110 ! -- Skip if already inactive
2111 if (this%ibound(n) == 0) then
2112 if (this%irewet /= 0) then
2113 if (this%wetdry(n) == dzero) cycle nodeloop
2114 else
2115 cycle nodeloop
2116 end if
2117 end if
2118 !
2119 ! -- Cycle if k11 is not zero
2120 if (this%k11(n) /= dzero) cycle nodeloop
2121 !
2122 ! -- Cycle if at least one vertical connection has non-zero k33
2123 ! for n and m
2124 do ii = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
2125 m = this%dis%con%ja(ii)
2126 if (this%dis%con%ihc(this%dis%con%jas(ii)) == 0) then
2127 hyn = this%k11(n)
2128 if (this%ik33 /= 0) hyn = this%k33(n)
2129 if (hyn /= dzero) then
2130 hym = this%k11(m)
2131 if (this%ik33 /= 0) hym = this%k33(m)
2132 if (hym /= dzero) cycle
2133 end if
2134 end if
2135 end do
2136 !
2137 ! -- If this part of the loop is reached, then all connections have
2138 ! zero transmissivity, so convert to noflow.
2139 this%ibound(n) = 0
2140 this%hnew(n) = this%hnoflo
2141 if (this%irewet /= 0) this%wetdry(n) = dzero
2142 call this%dis%noder_to_string(n, cellstr)
2143 write (this%iout, fmtcnv) trim(adjustl(cellstr))
2144 !
2145 end do nodeloop
2146 !
2147 ! -- Preprocess cell status and heads based on initial conditions
2148 if (this%inewton == 0) then
2149 !
2150 ! -- For standard formulation (non-Newton) call wetdry routine
2151 call this%wd(0, this%hnew)
2152 else
2153 !
2154 ! -- Newton formulation, so adjust heads to be above bottom
2155 ! (Not used in present formulation because variable cv
2156 ! cannot be used with Newton)
2157 if (this%ivarcv == 1) then
2158 do n = 1, this%dis%nodes
2159 if (this%hnew(n) < this%dis%bot(n)) then
2160 this%hnew(n) = this%dis%bot(n) + dem6
2161 end if
2162 end do
2163 end if
2164 end if
2165 !
2166 ! -- If THCKSTRT is not active, then loop through icelltype and replace
2167 ! any negative values with 1.
2168 if (this%ithickstrt == 0) then
2169 do n = 1, this%dis%nodes
2170 if (this%icelltype(n) < 0) then
2171 this%icelltype(n) = 1
2172 end if
2173 end do
2174 end if
2175 !
2176 ! -- Initialize sat to zero for ibound=0 cells, unless the cell can
2177 ! rewet. Initialize sat to the saturated fraction based on strt
2178 ! if icelltype is negative and the THCKSTRT option is in effect.
2179 ! Initialize sat to 1.0 for all other cells in order to calculate
2180 ! condsat in next section.
2181 do n = 1, this%dis%nodes
2182 if (this%ibound(n) == 0) then
2183 this%sat(n) = done
2184 if (this%icelltype(n) < 0 .and. this%ithickstrt /= 0) then
2185 this%ithickstartflag(n) = 1
2186 this%icelltype(n) = 0
2187 end if
2188 else
2189 topn = this%dis%top(n)
2190 botn = this%dis%bot(n)
2191 if (this%icelltype(n) < 0 .and. this%ithickstrt /= 0) then
2192 call this%thksat(n, this%ic%strt(n), satn)
2193 if (botn > this%ic%strt(n)) then
2194 call this%dis%noder_to_string(n, cellstr)
2195 write (errmsg, fmtnct) trim(adjustl(cellstr))
2196 call store_error(errmsg)
2197 write (errmsg, fmtihbe) this%ic%strt(n), botn
2198 call store_error(errmsg)
2199 end if
2200 this%ithickstartflag(n) = 1
2201 this%icelltype(n) = 0
2202 else
2203 satn = done
2204 if (botn > topn) then
2205 call this%dis%noder_to_string(n, cellstr)
2206 write (errmsg, fmtnct) trim(adjustl(cellstr))
2207 call store_error(errmsg)
2208 write (errmsg, fmttebe) topn, botn
2209 call store_error(errmsg)
2210 end if
2211 end if
2212 this%sat(n) = satn
2213 end if
2214 end do
2215 if (count_errors() > 0) then
2216 call store_error_filename(this%input_fname)
2217 end if
2218 !
2219 ! -- Calculate condsat, but only if xt3d is not active. If xt3d is
2220 ! active, then condsat is allocated to size of zero.
2221 if (this%ixt3d == 0) then
2222 !
2223 ! -- Calculate the saturated conductance for all connections assuming
2224 ! that saturation is 1 (except for case where icelltype was entered
2225 ! as a negative value and THCKSTRT option in effect)
2226 do n = 1, this%dis%nodes
2227 call this%calc_condsat(n, .true.)
2228 end do
2229 !
2230 end if
2231 !
2232 ! -- Determine the lower most node
2233 if (this%igwfnewtonur /= 0) then
2234 call mem_reallocate(this%ibotnode, this%dis%nodes, 'IBOTNODE', &
2235 trim(this%memoryPath))
2236 do n = 1, this%dis%nodes
2237 !
2238 minbot = this%dis%bot(n)
2239 nn = n
2240 finished = .false.
2241 do while (.not. finished)
2242 nextn = 0
2243 !
2244 ! -- Go through the connecting cells
2245 do ii = this%dis%con%ia(nn) + 1, this%dis%con%ia(nn + 1) - 1
2246 !
2247 ! -- Set the m cell number
2248 m = this%dis%con%ja(ii)
2249 botm = this%dis%bot(m)
2250 !
2251 ! -- select vertical connections: ihc == 0
2252 if (this%dis%con%ihc(this%dis%con%jas(ii)) == 0) then
2253 if (m > nn .and. botm < minbot) then
2254 nextn = m
2255 minbot = botm
2256 end if
2257 end if
2258 end do
2259 if (nextn > 0) then
2260 nn = nextn
2261 else
2262 finished = .true.
2263 end if
2264 end do
2265 this%ibotnode(n) = nn
2266 end do
2267 end if
2268 !
2269 ! -- nullify unneeded gwf pointers
2270 this%igwfnewtonur => null()
real(dp), parameter done
real constant 1
Definition Constants.f90:76
Here is the call graph for this function:

◆ rewet_check()

subroutine gwfnpfmodule::rewet_check ( class(gwfnpftype) this,
integer(i4b), intent(in) kiter,
integer(i4b), intent(in) node,
real(dp), intent(in) hm,
integer(i4b), intent(in) ibdm,
integer(i4b), intent(in) ihc,
real(dp), dimension(:), intent(inout) hnew,
integer(i4b), intent(out) irewet )
private

This method can be called from any external object that has a head that can be used to rewet the GWF cell node. The ihc value is used to determine if it is a vertical or horizontal connection, which can operate differently depending on user settings.

Definition at line 2495 of file gwf-npf.f90.

2496 ! -- dummy
2497 class(GwfNpfType) :: this
2498 integer(I4B), intent(in) :: kiter
2499 integer(I4B), intent(in) :: node
2500 real(DP), intent(in) :: hm
2501 integer(I4B), intent(in) :: ibdm
2502 integer(I4B), intent(in) :: ihc
2503 real(DP), intent(inout), dimension(:) :: hnew
2504 integer(I4B), intent(out) :: irewet
2505 ! -- local
2506 integer(I4B) :: itflg
2507 real(DP) :: wd, awd, turnon, bbot
2508 !
2509 irewet = 0
2510 !
2511 ! -- Convert a dry cell to wet if it meets the criteria
2512 if (this%irewet > 0) then
2513 itflg = mod(kiter, this%iwetit)
2514 if (itflg == 0) then
2515 if (this%ibound(node) == 0 .and. this%wetdry(node) /= dzero) then
2516 !
2517 ! -- Calculate wetting elevation
2518 bbot = this%dis%bot(node)
2519 wd = this%wetdry(node)
2520 awd = wd
2521 if (wd < 0) awd = -wd
2522 turnon = bbot + awd
2523 !
2524 ! -- Check head in adjacent cells to see if wetting elevation has
2525 ! been reached
2526 if (ihc == c3d_vertical) then
2527 !
2528 ! -- check cell below
2529 if (ibdm > 0 .and. hm >= turnon) irewet = 1
2530 else
2531 if (wd > dzero) then
2532 !
2533 ! -- check horizontally adjacent cells
2534 if (ibdm > 0 .and. hm >= turnon) irewet = 1
2535 end if
2536 end if
2537 !
2538 if (irewet == 1) then
2539 ! -- rewet cell; use equation 3a if ihdwet=0; use equation 3b if
2540 ! ihdwet is not 0.
2541 if (this%ihdwet == 0) then
2542 hnew(node) = bbot + this%wetfct * (hm - bbot)
2543 else
2544 hnew(node) = bbot + this%wetfct * awd !(hm - bbot)
2545 end if
2546 this%ibound(node) = 30000
2547 end if
2548 end if
2549 end if
2550 end if

◆ sav_sat()

subroutine gwfnpfmodule::sav_sat ( class(gwfnpftype) this,
integer(i4b), intent(in) ibinun )
private

Definition at line 2966 of file gwf-npf.f90.

2967 ! -- dummy
2968 class(GwfNpfType) :: this
2969 integer(I4B), intent(in) :: ibinun
2970 ! -- local
2971 character(len=16) :: text
2972 character(len=16), dimension(1) :: auxtxt
2973 real(DP), dimension(1) :: a
2974 integer(I4B) :: n
2975 integer(I4B) :: naux
2976 !
2977 ! -- Write the header
2978 text = ' DATA-SAT'
2979 naux = 1
2980 auxtxt(:) = [' sat']
2981 call this%dis%record_srcdst_list_header(text, this%name_model, &
2982 this%packName, this%name_model, &
2983 this%packName, naux, auxtxt, ibinun, &
2984 this%dis%nodes, this%iout)
2985 !
2986 ! -- Write a zero for Q, and then write saturation as an aux variables
2987 do n = 1, this%dis%nodes
2988 a(1) = this%sat(n)
2989 call this%dis%record_mf6_list_entry(ibinun, n, n, dzero, naux, a)
2990 end do

◆ sav_spdis()

subroutine gwfnpfmodule::sav_spdis ( class(gwfnpftype) this,
integer(i4b), intent(in) ibinun )
private

Definition at line 2938 of file gwf-npf.f90.

2939 ! -- dummy
2940 class(GwfNpfType) :: this
2941 integer(I4B), intent(in) :: ibinun
2942 ! -- local
2943 character(len=16) :: text
2944 character(len=16), dimension(3) :: auxtxt
2945 integer(I4B) :: n
2946 integer(I4B) :: naux
2947 !
2948 ! -- Write the header
2949 text = ' DATA-SPDIS'
2950 naux = 3
2951 auxtxt(:) = [' qx', ' qy', ' qz']
2952 call this%dis%record_srcdst_list_header(text, this%name_model, &
2953 this%packName, this%name_model, &
2954 this%packName, naux, auxtxt, ibinun, &
2955 this%dis%nodes, this%iout)
2956 !
2957 ! -- Write a zero for Q, and then write qx, qy, qz as aux variables
2958 do n = 1, this%dis%nodes
2959 call this%dis%record_mf6_list_entry(ibinun, n, n, dzero, naux, &
2960 this%spdis(:, n))
2961 end do

◆ set_edge_properties()

subroutine gwfnpfmodule::set_edge_properties ( class(gwfnpftype) this,
integer(i4b), intent(in) nodedge,
integer(i4b), intent(in) ihcedge,
real(dp), intent(in) q,
real(dp), intent(in) area,
real(dp), intent(in) nx,
real(dp), intent(in) ny,
real(dp), intent(in) distance )
private

Definition at line 3035 of file gwf-npf.f90.

3037 ! -- dummy
3038 class(GwfNpfType) :: this
3039 integer(I4B), intent(in) :: nodedge
3040 integer(I4B), intent(in) :: ihcedge
3041 real(DP), intent(in) :: q
3042 real(DP), intent(in) :: area
3043 real(DP), intent(in) :: nx
3044 real(DP), intent(in) :: ny
3045 real(DP), intent(in) :: distance
3046 ! -- local
3047 integer(I4B) :: lastedge
3048 !
3049 this%lastedge = this%lastedge + 1
3050 lastedge = this%lastedge
3051 this%nodedge(lastedge) = nodedge
3052 this%ihcedge(lastedge) = ihcedge
3053 this%propsedge(1, lastedge) = q
3054 this%propsedge(2, lastedge) = area
3055 this%propsedge(3, lastedge) = nx
3056 this%propsedge(4, lastedge) = ny
3057 this%propsedge(5, lastedge) = distance
3058 !
3059 ! -- If this is the last edge, then the next call must be starting a new
3060 ! edge properties assignment loop, so need to reset lastedge to 0
3061 if (this%lastedge == this%nedges) this%lastedge = 0

◆ set_options()

subroutine gwfnpfmodule::set_options ( class(gwfnpftype) this,
type(gwfnpfoptionstype), intent(in) options )
private

Definition at line 1681 of file gwf-npf.f90.

1682 ! -- dummy
1683 class(GwfNpftype) :: this
1684 type(GwfNpfOptionsType), intent(in) :: options
1685 !
1686 this%ithickstrt = options%ithickstrt
1687 this%ihighcellsat = options%ihighcellsat
1688 this%iperched = options%iperched
1689 this%ivarcv = options%ivarcv
1690 this%idewatcv = options%idewatcv
1691 this%irewet = options%irewet
1692 this%wetfct = options%wetfct
1693 this%iwetit = options%iwetit
1694 this%ihdwet = options%ihdwet

◆ sgwf_npf_qcalc()

subroutine gwfnpfmodule::sgwf_npf_qcalc ( class(gwfnpftype) this,
integer(i4b), intent(in) n,
integer(i4b), intent(in) m,
real(dp), intent(in) hn,
real(dp), intent(in) hm,
integer(i4b), intent(in) icon,
real(dp), intent(inout) qnm )
private

Definition at line 1057 of file gwf-npf.f90.

1058 ! -- dummy
1059 class(GwfNpfType) :: this
1060 integer(I4B), intent(in) :: n
1061 integer(I4B), intent(in) :: m
1062 real(DP), intent(in) :: hn
1063 real(DP), intent(in) :: hm
1064 integer(I4B), intent(in) :: icon
1065 real(DP), intent(inout) :: qnm
1066 ! -- local
1067 real(DP) :: hyn, hym
1068 real(DP) :: condnm
1069 real(DP) :: hntemp, hmtemp
1070 real(DP) :: satn, satm
1071 integer(I4B) :: ihc
1072 !
1073 ! -- Initialize
1074 ihc = this%dis%con%ihc(this%dis%con%jas(icon))
1075 hyn = this%hy_eff(n, m, ihc, ipos=icon)
1076 hym = this%hy_eff(m, n, ihc, ipos=icon)
1077 !
1078 ! -- Calculate conductance
1079 if (ihc == c3d_vertical) then
1080 condnm = vcond(this%ibound(n), this%ibound(m), &
1081 this%icelltype(n), this%icelltype(m), this%inewton, &
1082 this%ivarcv, this%idewatcv, &
1083 this%condsat(this%dis%con%jas(icon)), hn, hm, &
1084 hyn, hym, &
1085 this%sat(n), this%sat(m), &
1086 this%dis%top(n), this%dis%top(m), &
1087 this%dis%bot(n), this%dis%bot(m), &
1088 this%dis%con%hwva(this%dis%con%jas(icon)))
1089 else
1090 satn = this%sat(n)
1091 satm = this%sat(m)
1092 if (this%ihighcellsat /= 0) then
1093 call this%highest_cell_saturation(n, m, hn, hm, satn, satm)
1094 end if
1095
1096 condnm = hcond(this%ibound(n), this%ibound(m), &
1097 this%icelltype(n), this%icelltype(m), &
1098 this%inewton, &
1099 this%dis%con%ihc(this%dis%con%jas(icon)), &
1100 this%icellavg, &
1101 this%condsat(this%dis%con%jas(icon)), &
1102 hn, hm, satn, satm, hyn, hym, &
1103 this%dis%top(n), this%dis%top(m), &
1104 this%dis%bot(n), this%dis%bot(m), &
1105 this%dis%con%cl1(this%dis%con%jas(icon)), &
1106 this%dis%con%cl2(this%dis%con%jas(icon)), &
1107 this%dis%con%hwva(this%dis%con%jas(icon)))
1108 end if
1109 !
1110 ! -- Initialize hntemp and hmtemp
1111 hntemp = hn
1112 hmtemp = hm
1113 !
1114 ! -- Check and adjust for dewatered conditions
1115 if (this%iperched /= 0) then
1116 if (this%dis%con%ihc(this%dis%con%jas(icon)) == 0) then
1117 if (n > m) then
1118 if (this%icelltype(n) /= 0) then
1119 if (hn < this%dis%top(n)) hntemp = this%dis%bot(m)
1120 end if
1121 else
1122 if (this%icelltype(m) /= 0) then
1123 if (hm < this%dis%top(m)) hmtemp = this%dis%bot(n)
1124 end if
1125 end if
1126 end if
1127 end if
1128 !
1129 ! -- Calculate flow positive into cell n
1130 qnm = condnm * (hmtemp - hntemp)
Here is the call graph for this function:

◆ sgwf_npf_thksat()

subroutine gwfnpfmodule::sgwf_npf_thksat ( class(gwfnpftype) this,
integer(i4b), intent(in) n,
real(dp), intent(in) hn,
real(dp), intent(inout) thksat )
private

Definition at line 1034 of file gwf-npf.f90.

1035 ! -- dummy
1036 class(GwfNpfType) :: this
1037 integer(I4B), intent(in) :: n
1038 real(DP), intent(in) :: hn
1039 real(DP), intent(inout) :: thksat
1040 !
1041 ! -- Standard Formulation
1042 if (hn >= this%dis%top(n)) then
1043 thksat = done
1044 else
1045 thksat = (hn - this%dis%bot(n)) / (this%dis%top(n) - this%dis%bot(n))
1046 end if
1047 !
1048 ! -- Newton-Raphson Formulation
1049 if (this%inewton /= 0) then
1050 thksat = squadraticsaturation(this%dis%top(n), this%dis%bot(n), hn, &
1051 this%satomega)
1052 end if
Here is the call graph for this function:

◆ sgwf_npf_wdmsg()

subroutine gwfnpfmodule::sgwf_npf_wdmsg ( class(gwfnpftype) this,
integer(i4b), intent(in) icode,
integer(i4b), intent(inout) ncnvrt,
character(len=30), dimension(5), intent(inout) nodcnvrt,
character(len=3), dimension(5), intent(inout) acnvrt,
integer(i4b), intent(inout) ihdcnv,
integer(i4b), intent(in) kiter,
integer(i4b), intent(in) n )
private

Definition at line 2555 of file gwf-npf.f90.

2557 ! -- modules
2558 use tdismodule, only: kstp, kper
2559 ! -- dummy
2560 class(GwfNpfType) :: this
2561 integer(I4B), intent(in) :: icode
2562 integer(I4B), intent(inout) :: ncnvrt
2563 character(len=30), dimension(5), intent(inout) :: nodcnvrt
2564 character(len=3), dimension(5), intent(inout) :: acnvrt
2565 integer(I4B), intent(inout) :: ihdcnv
2566 integer(I4B), intent(in) :: kiter
2567 integer(I4B), intent(in) :: n
2568 ! -- local
2569 integer(I4B) :: l
2570 ! -- formats
2571 character(len=*), parameter :: fmtcnvtn = &
2572 "(1X,/1X,'CELL CONVERSIONS FOR ITER.=',I0, &
2573 &' STEP=',I0,' PERIOD=',I0,' (NODE or LRC)')"
2574 character(len=*), parameter :: fmtnode = "(1X,3X,5(A4, A20))"
2575 !
2576 ! -- Keep track of cell conversions
2577 if (icode > 0) then
2578 ncnvrt = ncnvrt + 1
2579 call this%dis%noder_to_string(n, nodcnvrt(ncnvrt))
2580 if (icode == 1) then
2581 acnvrt(ncnvrt) = 'DRY'
2582 else
2583 acnvrt(ncnvrt) = 'WET'
2584 end if
2585 end if
2586 !
2587 ! -- Print a line if 5 conversions have occurred or if icode indicates that a
2588 ! partial line should be printed
2589 if (ncnvrt == 5 .or. (icode == 0 .and. ncnvrt > 0)) then
2590 if (ihdcnv == 0) write (this%iout, fmtcnvtn) kiter, kstp, kper
2591 ihdcnv = 1
2592 write (this%iout, fmtnode) &
2593 (acnvrt(l), trim(adjustl(nodcnvrt(l))), l=1, ncnvrt)
2594 ncnvrt = 0
2595 end if

◆ sgwf_npf_wetdry()

subroutine gwfnpfmodule::sgwf_npf_wetdry ( class(gwfnpftype) this,
integer(i4b), intent(in) kiter,
real(dp), dimension(:), intent(inout) hnew )
private

Definition at line 2389 of file gwf-npf.f90.

2390 ! -- modules
2391 use tdismodule, only: kstp, kper
2393 use constantsmodule, only: linelength
2394 ! -- dummy
2395 class(GwfNpfType) :: this
2396 integer(I4B), intent(in) :: kiter
2397 real(DP), intent(inout), dimension(:) :: hnew
2398 ! -- local
2399 integer(I4B) :: n, m, ii, ihc
2400 real(DP) :: ttop, bbot, thick
2401 integer(I4B) :: ncnvrt, ihdcnv
2402 character(len=30), dimension(5) :: nodcnvrt
2403 character(len=30) :: nodestr
2404 character(len=3), dimension(5) :: acnvrt
2405 character(len=LINELENGTH) :: errmsg
2406 integer(I4B) :: irewet
2407 ! -- formats
2408 character(len=*), parameter :: fmtnct = &
2409 "(1X,/1X,'Negative cell thickness at (layer,row,col)', &
2410 &I4,',',I5,',',I5)"
2411 character(len=*), parameter :: fmttopbot = &
2412 &"(1X,'Top elevation, bottom elevation:',1P,2G13.5)"
2413 character(len=*), parameter :: fmttopbotthk = &
2414 &"(1X,'Top elevation, bottom elevation, thickness:',1P,3G13.5)"
2415 character(len=*), parameter :: fmtdrychd = &
2416 &"(1X,/1X,'CONSTANT-HEAD CELL WENT DRY -- SIMULATION ABORTED')"
2417 character(len=*), parameter :: fmtni = &
2418 &"(1X,'CELLID=',a,' ITERATION=',I0,' TIME STEP=',I0,' STRESS PERIOD=',I0)"
2419 !
2420 ! -- Initialize
2421 ncnvrt = 0
2422 ihdcnv = 0
2423 !
2424 ! -- Convert dry cells to wet
2425 do n = 1, this%dis%nodes
2426 do ii = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
2427 m = this%dis%con%ja(ii)
2428 ihc = this%dis%con%ihc(this%dis%con%jas(ii))
2429 call this%rewet_check(kiter, n, hnew(m), this%ibound(m), ihc, hnew, &
2430 irewet)
2431 if (irewet == 1) then
2432 call this%wdmsg(2, ncnvrt, nodcnvrt, acnvrt, ihdcnv, kiter, n)
2433 end if
2434 end do
2435 end do
2436 !
2437 ! -- Perform drying
2438 do n = 1, this%dis%nodes
2439 !
2440 ! -- cycle if inactive or confined
2441 if (this%ibound(n) == 0) cycle
2442 if (this%icelltype(n) == 0) cycle
2443 !
2444 ! -- check for negative cell thickness
2445 bbot = this%dis%bot(n)
2446 ttop = this%dis%top(n)
2447 if (bbot > ttop) then
2448 write (errmsg, fmtnct) n
2449 call store_error(errmsg)
2450 write (errmsg, fmttopbot) ttop, bbot
2451 call store_error(errmsg)
2452 call store_error_filename(this%input_fname)
2453 end if
2454 !
2455 ! -- Calculate saturated thickness
2456 if (this%icelltype(n) /= 0) then
2457 if (hnew(n) < ttop) ttop = hnew(n)
2458 end if
2459 thick = ttop - bbot
2460 !
2461 ! -- If thick<0 print message, set hnew, and ibound
2462 if (thick <= dzero) then
2463 call this%wdmsg(1, ncnvrt, nodcnvrt, acnvrt, ihdcnv, kiter, n)
2464 hnew(n) = this%hdry
2465 if (this%ibound(n) < 0) then
2466 errmsg = 'CONSTANT-HEAD CELL WENT DRY -- SIMULATION ABORTED'
2467 call store_error(errmsg)
2468 write (errmsg, fmttopbotthk) ttop, bbot, thick
2469 call store_error(errmsg)
2470 call this%dis%noder_to_string(n, nodestr)
2471 write (errmsg, fmtni) trim(adjustl(nodestr)), kiter, kstp, kper
2472 call store_error(errmsg)
2473 call store_error_filename(this%input_fname)
2474 end if
2475 this%ibound(n) = 0
2476 end if
2477 end do
2478 !
2479 ! -- Print remaining cell conversions
2480 call this%wdmsg(0, ncnvrt, nodcnvrt, acnvrt, ihdcnv, kiter, n)
2481 !
2482 ! -- Change ibound from 30000 to 1
2483 do n = 1, this%dis%nodes
2484 if (this%ibound(n) == 30000) this%ibound(n) = 1
2485 end do
Here is the call graph for this function:

◆ source_griddata()

subroutine gwfnpfmodule::source_griddata ( class(gwfnpftype) this)
private

Definition at line 1820 of file gwf-npf.f90.

1821 ! -- modules
1826 ! -- dummy
1827 class(GwfNpftype) :: this
1828 ! -- locals
1829 character(len=LINELENGTH) :: errmsg
1830 type(GwfNpfParamFoundType) :: found
1831 logical, dimension(2) :: afound
1832 integer(I4B), dimension(:), pointer, contiguous :: map
1833 !
1834 ! -- set map to convert user input data into reduced data
1835 map => null()
1836 if (this%dis%nodes < this%dis%nodesuser) map => this%dis%nodeuser
1837 !
1838 ! -- update defaults with idm sourced values
1839 call mem_set_value(this%icelltype, 'ICELLTYPE', this%input_mempath, map, &
1840 found%icelltype)
1841 call mem_set_value(this%k11, 'K', this%input_mempath, map, found%k, &
1842 release=.false.)
1843 call mem_set_value(this%k33, 'K33', this%input_mempath, map, found%k33)
1844 call mem_set_value(this%k22, 'K22', this%input_mempath, map, found%k22)
1845 call mem_set_value(this%wetdry, 'WETDRY', this%input_mempath, map, &
1846 found%wetdry)
1847 call mem_set_value(this%angle1, 'ANGLE1', this%input_mempath, map, &
1848 found%angle1)
1849 call mem_set_value(this%angle2, 'ANGLE2', this%input_mempath, map, &
1850 found%angle2)
1851 call mem_set_value(this%angle3, 'ANGLE3', this%input_mempath, map, &
1852 found%angle3)
1853 !
1854 ! -- ensure ICELLTYPE was found
1855 if (.not. found%icelltype) then
1856 write (errmsg, '(a)') 'Error in GRIDDATA block: ICELLTYPE not found.'
1857 call store_error(errmsg)
1858 end if
1859 !
1860 ! -- ensure K was found
1861 if (.not. found%k) then
1862 write (errmsg, '(a)') 'Error in GRIDDATA block: K not found.'
1863 call store_error(errmsg)
1864 end if
1865 !
1866 ! -- set error if ik33overk set with no k33
1867 if (.not. found%k33 .and. this%ik33overk /= 0) then
1868 write (errmsg, '(a)') 'K33OVERK option specified but K33 not specified.'
1869 call store_error(errmsg)
1870 end if
1871 !
1872 ! -- set error if ik22overk set with no k22
1873 if (.not. found%k22 .and. this%ik22overk /= 0) then
1874 write (errmsg, '(a)') 'K22OVERK option specified but K22 not specified.'
1875 call store_error(errmsg)
1876 end if
1877 !
1878 ! -- handle found side effects
1879 if (found%k33) this%ik33 = 1
1880 if (found%k22) this%ik22 = 1
1881 if (found%wetdry) this%iwetdry = 1
1882 if (found%angle1) this%iangle1 = 1
1883 if (found%angle2) this%iangle2 = 1
1884 if (found%angle3) this%iangle3 = 1
1885 !
1886 ! -- handle not found side effects
1887 if (.not. found%k33) then
1888 call mem_set_value(this%k33, 'K', this%input_mempath, map, afound(1), &
1889 release=.false.)
1890 end if
1891 if (.not. found%k22) then
1892 call mem_set_value(this%k22, 'K', this%input_mempath, map, afound(2), &
1893 release=.false.)
1894 end if
1895 if (.not. found%wetdry) call mem_reallocate(this%wetdry, 1, 'WETDRY', &
1896 trim(this%memoryPath))
1897 if (.not. found%angle1 .and. this%ixt3d == 0) &
1898 call mem_reallocate(this%angle1, 0, 'ANGLE1', trim(this%memoryPath))
1899 if (.not. found%angle2 .and. this%ixt3d == 0) &
1900 call mem_reallocate(this%angle2, 0, 'ANGLE2', trim(this%memoryPath))
1901 if (.not. found%angle3 .and. this%ixt3d == 0) &
1902 call mem_reallocate(this%angle3, 0, 'ANGLE3', trim(this%memoryPath))
1903 !
1904 ! -- cleanup
1905 call memorystore_release('K', this%input_mempath)
1906 !
1907 ! -- log griddata
1908 if (this%iout > 0) then
1909 call this%log_griddata(found)
1910 end if
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
Here is the call graph for this function:

◆ source_options()

subroutine gwfnpfmodule::source_options ( class(gwfnpftype) this)
private

Definition at line 1590 of file gwf-npf.f90.

1591 ! -- modules
1598 ! -- dummy
1599 class(GwfNpftype) :: this
1600 ! -- locals
1601 character(len=LENVARNAME), dimension(3) :: cellavg_method = &
1602 &[character(len=LENVARNAME) :: 'LOGARITHMIC', 'AMT-LMK', 'AMT-HMK']
1603 type(gwfnpfparamfoundtype) :: found
1604 type(CharacterStringType), dimension(:), pointer, contiguous :: tvk6_mempaths
1605 character(len=LINELENGTH) :: tvk6_filename
1606 character(len=LENMEMPATH) :: tvk6_mempath
1607 !
1608 ! -- update defaults with idm sourced values
1609 call mem_set_value(this%iprflow, 'IPRFLOW', this%input_mempath, found%iprflow)
1610 call mem_set_value(this%ipakcb, 'IPAKCB', this%input_mempath, found%ipakcb)
1611 call mem_set_value(this%icellavg, 'CELLAVG', this%input_mempath, &
1612 cellavg_method, found%cellavg)
1613 call mem_set_value(this%ithickstrt, 'ITHICKSTRT', this%input_mempath, &
1614 found%ithickstrt)
1615 call mem_set_value(this%ihighcellsat, 'IHIGHCELLSAT', this%input_mempath, &
1616 found%ihighcellsat)
1617 call mem_set_value(this%iperched, 'IPERCHED', this%input_mempath, &
1618 found%iperched)
1619 call mem_set_value(this%ivarcv, 'IVARCV', this%input_mempath, found%ivarcv)
1620 call mem_set_value(this%idewatcv, 'IDEWATCV', this%input_mempath, &
1621 found%idewatcv)
1622 call mem_set_value(this%ixt3d, 'IXT3D', this%input_mempath, found%ixt3d)
1623 call mem_set_value(this%ixt3drhs, 'IXT3DRHS', this%input_mempath, &
1624 found%ixt3drhs)
1625 call mem_set_value(this%isavspdis, 'ISAVSPDIS', this%input_mempath, &
1626 found%isavspdis)
1627 call mem_set_value(this%isavsat, 'ISAVSAT', this%input_mempath, found%isavsat)
1628 call mem_set_value(this%ik22overk, 'IK22OVERK', this%input_mempath, &
1629 found%ik22overk)
1630 call mem_set_value(this%ik33overk, 'IK33OVERK', this%input_mempath, &
1631 found%ik33overk)
1632 call mem_set_value(this%inewton, 'INEWTON', this%input_mempath, found%inewton)
1633 call mem_set_value(this%satomega, 'SATOMEGA', this%input_mempath, &
1634 found%satomega)
1635 call mem_set_value(this%irewet, 'IREWET', this%input_mempath, found%irewet)
1636 call mem_set_value(this%wetfct, 'WETFCT', this%input_mempath, found%wetfct)
1637 call mem_set_value(this%iwetit, 'IWETIT', this%input_mempath, found%iwetit)
1638 call mem_set_value(this%ihdwet, 'IHDWET', this%input_mempath, found%ihdwet)
1639 !
1640 ! -- save flows option active
1641 if (found%ipakcb) this%ipakcb = -1
1642 !
1643 ! -- xt3d active with rhs
1644 if (found%ixt3d .and. found%ixt3drhs) this%ixt3d = 2
1645 !
1646 ! -- save specific discharge active
1647 if (found%isavspdis) this%icalcspdis = this%isavspdis
1648 !
1649 ! -- no newton specified
1650 if (found%inewton) then
1651 this%inewton = 0
1652 this%iasym = 0
1653 end if
1654 !
1655 ! -- TVK6 subpackage
1656 if (filein_fname(tvk6_filename, 'TVK6_FILENAME', &
1657 this%input_mempath, this%input_fname)) then
1658 call mem_setptr(tvk6_mempaths, 'TVK6_MEMPATH', this%input_mempath)
1659 tvk6_mempath = tvk6_mempaths(1)
1660 this%intvk = 1 ! tvk active
1661 call tvk_cr(this%tvk, this%name_model, tvk6_mempath, this%intvk, this%iout)
1662 end if
1663 !
1664 ! -- verify ALTERNATIVE_CELL_AVERAGING input value is supported
1665 if (found%cellavg) then
1666 if (this%icellavg == 0) then
1667 errmsg = 'Unrecognized input value for ALTERNATIVE_CELL_AVERAGING option.'
1668 call store_error(errmsg)
1669 call store_error_filename(this%input_fname)
1670 end if
1671 end if
1672 !
1673 ! -- log options
1674 if (this%iout > 0) then
1675 call this%log_options(found)
1676 end if
subroutine, public get_isize(name, mem_path, isize)
Get the number of elements for this variable.
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
This class is used to store a single deferred-length character string. It was designed to work in an ...
Here is the call graph for this function:

◆ store_original_k_arrays()

subroutine gwfnpfmodule::store_original_k_arrays ( class(gwfnpftype) this,
integer(i4b), intent(in) ncells,
integer(i4b), intent(in) njas )
private

The K arrays (K11, etc.) get multiplied by the viscosity ratio so that subsequent uses of K already take into account the effect of viscosity. Thus K before VSC adjustment, including TVK changes, is kept in k11input, for example. In a new stress period/time step, the values in k11input are multiplied by the viscosity ratio, not k11 since it contains viscosity-adjusted hydraulic conductivity values.

Definition at line 1418 of file gwf-npf.f90.

1419 ! -- modules
1421 ! -- dummy
1422 class(GwfNpftype) :: this
1423 integer(I4B), intent(in) :: ncells
1424 integer(I4B), intent(in) :: njas
1425 ! -- local
1426 integer(I4B) :: n
1427 !
1428 ! -- Retain copy of user-specified K arrays
1429 do n = 1, ncells
1430 this%k11input(n) = this%k11(n)
1431 this%k22input(n) = this%k22(n)
1432 this%k33input(n) = this%k33(n)
1433 end do