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_initial_saturation (this, sat)
 Saturation implied by the heads the simulation starts from.
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 3168 of file gwf-npf.f90.

3169 class(GwfNpfType), intent(inout) :: this !< this NPF instance
3170 class(GwfNpfFormulationType), pointer :: npf_form !< the extended flow calculator
3171 integer(I4B) :: form_id !< the id for the flow formulation
3172
3173 this%flow_formulations(form_id)%form => npf_form
3174

◆ allocate_arrays()

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

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

1473 ! -- dummy
1474 class(GwfNpftype), target :: this
1475 integer(I4B), intent(in) :: ncells
1476 integer(I4B), intent(in) :: njas
1477 ! -- local
1478 integer(I4B) :: n
1479 !
1480 call mem_allocate(this%ithickstartflag, ncells, 'ITHICKSTARTFLAG', &
1481 this%memoryPath)
1482 call mem_allocate(this%icelltype, ncells, 'ICELLTYPE', this%memoryPath)
1483 call mem_allocate(this%k11, ncells, 'K11', this%memoryPath)
1484 call mem_allocate(this%krel, ncells, 'KREL', this%memoryPath)
1485 call mem_allocate(this%sat, ncells, 'SAT', this%memoryPath)
1486 call mem_allocate(this%condsat, njas, 'CONDSAT', this%memoryPath)
1487 !
1488 ! -- Optional arrays dimensioned to full size initially
1489 call mem_allocate(this%k22, ncells, 'K22', this%memoryPath)
1490 call mem_allocate(this%k33, ncells, 'K33', this%memoryPath)
1491 call mem_allocate(this%wetdry, ncells, 'WETDRY', this%memoryPath)
1492 call mem_allocate(this%angle1, ncells, 'ANGLE1', this%memoryPath)
1493 call mem_allocate(this%angle2, ncells, 'ANGLE2', this%memoryPath)
1494 call mem_allocate(this%angle3, ncells, 'ANGLE3', this%memoryPath)
1495 !
1496 ! -- Optional arrays
1497 call mem_allocate(this%ibotnode, 0, 'IBOTNODE', this%memoryPath)
1498 call mem_allocate(this%nodedge, 0, 'NODEDGE', this%memoryPath)
1499 call mem_allocate(this%ihcedge, 0, 'IHCEDGE', this%memoryPath)
1500 call mem_allocate(this%propsedge, 0, 0, 'PROPSEDGE', this%memoryPath)
1501 call mem_allocate(this%iedge_ptr, 0, 'NREDGESNODE', this%memoryPath)
1502 call mem_allocate(this%edge_idxs, 0, 'EDGEIDXS', this%memoryPath)
1503 !
1504 ! -- Optional arrays only needed when vsc package is active
1505 call mem_allocate(this%k11input, 0, 'K11INPUT', this%memoryPath)
1506 call mem_allocate(this%k22input, 0, 'K22INPUT', this%memoryPath)
1507 call mem_allocate(this%k33input, 0, 'K33INPUT', this%memoryPath)
1508 !
1509 ! -- Specific discharge is (re-)allocated when nedges is known
1510 call mem_allocate(this%spdis, 3, 0, 'SPDIS', this%memoryPath)
1511 !
1512 ! -- Time-varying property flag arrays
1513 call mem_allocate(this%nodekchange, ncells, 'NODEKCHANGE', this%memoryPath)
1514 !
1515 call mem_allocate(this%iformulation, this%dis%con%nja, 'IFORM', &
1516 this%memoryPath)
1517 !
1518 ! -- set to standard NPF flow
1519 do n = 1, size(this%iformulation)
1520 this%iformulation(n) = default_flow
1521 end do
1522 !
1523 ! -- create the default conductance formulation and point it at this package
1524 allocate (defaultflowformulationtype :: this%default_form)
1525 select type (form => this%default_form)
1526 type is (defaultflowformulationtype)
1527 form%npf => this
1528 end select
1529 !
1530 ! -- initialize iangle1, iangle2, iangle3, and wetdry
1531 do n = 1, ncells
1532 this%angle1(n) = dzero
1533 this%angle2(n) = dzero
1534 this%angle3(n) = dzero
1535 this%wetdry(n) = dzero
1536 this%nodekchange(n) = dzero
1537 this%krel(n) = done
1538 end do
1539 !
1540 ! -- allocate variable names
1541 allocate (this%aname(this%iname))
1542 this%aname = [' ICELLTYPE', ' K', &
1543 ' K33', ' K22', &
1544 ' WETDRY', ' ANGLE1', &
1545 ' 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 1353 of file gwf-npf.f90.

1354 ! -- modules
1356 ! -- dummy
1357 class(GwfNpftype) :: this
1358 !
1359 ! -- allocate scalars in NumericalPackageType
1360 call this%NumericalPackageType%allocate_scalars()
1361 !
1362 ! -- Allocate scalars
1363 call mem_allocate(this%iname, 'INAME', this%memoryPath)
1364 call mem_allocate(this%ixt3d, 'IXT3D', this%memoryPath)
1365 call mem_allocate(this%ixt3drhs, 'IXT3DRHS', this%memoryPath)
1366 call mem_allocate(this%satomega, 'SATOMEGA', this%memoryPath)
1367 call mem_allocate(this%hnoflo, 'HNOFLO', this%memoryPath)
1368 call mem_allocate(this%hdry, 'HDRY', this%memoryPath)
1369 call mem_allocate(this%icellavg, 'ICELLAVG', this%memoryPath)
1370 call mem_allocate(this%iavgkeff, 'IAVGKEFF', this%memoryPath)
1371 call mem_allocate(this%ik22, 'IK22', this%memoryPath)
1372 call mem_allocate(this%ik33, 'IK33', this%memoryPath)
1373 call mem_allocate(this%ik22overk, 'IK22OVERK', this%memoryPath)
1374 call mem_allocate(this%ik33overk, 'IK33OVERK', this%memoryPath)
1375 call mem_allocate(this%iperched, 'IPERCHED', this%memoryPath)
1376 call mem_allocate(this%ivarcv, 'IVARCV', this%memoryPath)
1377 call mem_allocate(this%idewatcv, 'IDEWATCV', this%memoryPath)
1378 call mem_allocate(this%ithickstrt, 'ITHICKSTRT', this%memoryPath)
1379 call mem_allocate(this%ihighcellsat, 'IHIGHCELLSAT', this%memoryPath)
1380 call mem_allocate(this%icalcspdis, 'ICALCSPDIS', this%memoryPath)
1381 call mem_allocate(this%isavspdis, 'ISAVSPDIS', this%memoryPath)
1382 call mem_allocate(this%isavsat, 'ISAVSAT', this%memoryPath)
1383 call mem_allocate(this%irewet, 'IREWET', this%memoryPath)
1384 call mem_allocate(this%wetfct, 'WETFCT', this%memoryPath)
1385 call mem_allocate(this%iwetit, 'IWETIT', this%memoryPath)
1386 call mem_allocate(this%ihdwet, 'IHDWET', this%memoryPath)
1387 call mem_allocate(this%iangle1, 'IANGLE1', this%memoryPath)
1388 call mem_allocate(this%iangle2, 'IANGLE2', this%memoryPath)
1389 call mem_allocate(this%iangle3, 'IANGLE3', this%memoryPath)
1390 call mem_allocate(this%iwetdry, 'IWETDRY', this%memoryPath)
1391 call mem_allocate(this%nedges, 'NEDGES', this%memoryPath)
1392 call mem_allocate(this%lastedge, 'LASTEDGE', this%memoryPath)
1393 call mem_allocate(this%intvk, 'INTVK', this%memoryPath)
1394 call mem_allocate(this%invsc, 'INVSC', this%memoryPath)
1395 call mem_allocate(this%kchangeper, 'KCHANGEPER', this%memoryPath)
1396 call mem_allocate(this%kchangestp, 'KCHANGESTP', this%memoryPath)
1397 !
1398 ! -- set pointer to inewtonur
1399 call mem_setptr(this%igwfnewtonur, 'INEWTONUR', &
1400 create_mem_path(this%name_model))
1401 !
1402 ! -- Initialize value
1403 this%iname = 8
1404 this%ixt3d = 0
1405 this%ixt3drhs = 0
1406 this%satomega = dzero
1407 this%hnoflo = dhnoflo !1.d30
1408 this%hdry = dhdry !-1.d30
1409 this%icellavg = ccond_hmean
1410 this%iavgkeff = 0
1411 this%ik22 = 0
1412 this%ik33 = 0
1413 this%ik22overk = 0
1414 this%ik33overk = 0
1415 this%iperched = 0
1416 this%ivarcv = 0
1417 this%idewatcv = 0
1418 this%ithickstrt = 0
1419 this%ihighcellsat = 0
1420 this%icalcspdis = 0
1421 this%isavspdis = 0
1422 this%isavsat = 0
1423 this%irewet = 0
1424 this%wetfct = done
1425 this%iwetit = 1
1426 this%ihdwet = 0
1427 this%iangle1 = 0
1428 this%iangle2 = 0
1429 this%iangle3 = 0
1430 this%iwetdry = 0
1431 this%nedges = 0
1432 this%lastedge = 0
1433 this%intvk = 0
1434 this%invsc = 0
1435 this%kchangeper = 0
1436 this%kchangestp = 0
1437 !
1438 ! -- If newton is on, then NPF creates asymmetric matrix
1439 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 2312 of file gwf-npf.f90.

2313 ! -- dummy variables
2314 class(GwfNpfType) :: this
2315 integer(I4B), intent(in) :: node
2316 logical, intent(in) :: upperOnly
2317 ! -- local variables
2318 integer(I4B) :: ii, m, n, ihc, jj
2319 real(DP) :: topm, topn, topnode, botm, botn, botnode, satm, satn, satnode
2320 real(DP) :: hyn, hym, hn, hm, fawidth, csat
2321 !
2322 satnode = this%calc_initial_sat(node)
2323 !
2324 topnode = this%dis%top(node)
2325 botnode = this%dis%bot(node)
2326 !
2327 ! -- Go through the connecting cells
2328 do ii = this%dis%con%ia(node) + 1, this%dis%con%ia(node + 1) - 1
2329 !
2330 ! -- Set the m cell number and cycle if lower triangle connection and
2331 ! -- we're not updating both upper and lower matrix parts for this node
2332 m = this%dis%con%ja(ii)
2333 jj = this%dis%con%jas(ii)
2334 if (m < node) then
2335 if (upperonly) cycle
2336 ! m => node, n => neighbour
2337 n = m
2338 m = node
2339 topm = topnode
2340 botm = botnode
2341 satm = satnode
2342 topn = this%dis%top(n)
2343 botn = this%dis%bot(n)
2344 satn = this%calc_initial_sat(n)
2345 else
2346 ! n => node, m => neighbour
2347 n = node
2348 topn = topnode
2349 botn = botnode
2350 satn = satnode
2351 topm = this%dis%top(m)
2352 botm = this%dis%bot(m)
2353 satm = this%calc_initial_sat(m)
2354 end if
2355 !
2356 ihc = this%dis%con%ihc(jj)
2357 hyn = this%hy_eff(n, m, ihc, ipos=ii)
2358 hym = this%hy_eff(m, n, ihc, ipos=ii)
2359 if (this%ithickstartflag(n) == 0) then
2360 hn = topn
2361 else
2362 hn = this%ic%strt(n)
2363 end if
2364 if (this%ithickstartflag(m) == 0) then
2365 hm = topm
2366 else
2367 hm = this%ic%strt(m)
2368 end if
2369 !
2370 ! -- Calculate conductance depending on whether connection is
2371 ! vertical (0), horizontal (1), or staggered horizontal (2)
2372 if (ihc == c3d_vertical) then
2373 !
2374 ! -- Vertical conductance for fully saturated conditions
2375 csat = vcond(1, 1, 1, 1, 0, 1, 1, done, &
2376 botn, botm, &
2377 hyn, hym, &
2378 satn, satm, &
2379 topn, topm, &
2380 botn, botm, &
2381 this%dis%con%hwva(jj))
2382 else
2383 !
2384 ! -- Horizontal conductance for fully saturated conditions
2385 fawidth = this%dis%con%hwva(jj)
2386 csat = hcond(1, 1, 1, 1, 0, &
2387 ihc, &
2388 this%icellavg, &
2389 done, &
2390 hn, hm, satn, satm, hyn, hym, &
2391 topn, topm, &
2392 botn, botm, &
2393 this%dis%con%cl1(jj), &
2394 this%dis%con%cl2(jj), &
2395 fawidth)
2396 end if
2397 this%condsat(jj) = csat
2398 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 2408 of file gwf-npf.f90.

2409 ! -- dummy variables
2410 class(GwfNpfType) :: this
2411 integer(I4B), intent(in) :: n
2412 ! -- Return
2413 real(DP) :: satn
2414 !
2415 satn = done
2416 if (this%ibound(n) /= 0 .and. this%ithickstartflag(n) /= 0) then
2417 call this%thksat(n, this%ic%strt(n), satn)
2418 end if

◆ calc_max_conns()

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

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

3043 class(GwfNpfType) :: this
3044 integer(I4B) :: max_conns
3045 ! local
3046 integer(I4B) :: n, m, ic
3047
3048 max_conns = 0
3049 do n = 1, this%dis%nodes
3050
3051 ! Count internal model connections
3052 ic = this%dis%con%ia(n + 1) - this%dis%con%ia(n) - 1
3053
3054 ! Add edge connections
3055 do m = 1, this%nedges
3056 if (this%nodedge(m) == n) then
3057 ic = ic + 1
3058 end if
3059 end do
3060
3061 ! Set max number of connections for any cell
3062 if (ic > max_conns) max_conns = ic
3063 end do
3064

◆ calc_spdis()

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

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

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

3144 ! -- dummy
3145 class(GwfNpfType) :: this !< this NPF instance
3146 integer(I4B) :: n !< node n
3147 integer(I4B) :: m !< node m
3148 integer(I4B) :: ihc !< 1 = horizontal connection, 0 for vertical
3149 ! -- return
3150 real(DP) :: satThickness !< saturated thickness
3151 !
3152 satthickness = thksatnm(this%ibound(n), &
3153 this%ibound(m), &
3154 this%icelltype(n), &
3155 this%icelltype(m), &
3156 this%inewton, &
3157 ihc, &
3158 this%hnew(n), &
3159 this%hnew(m), &
3160 this%sat(n), &
3161 this%sat(m), &
3162 this%dis%top(n), &
3163 this%dis%top(m), &
3164 this%dis%bot(n), &
3165 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 542 of file gwf-npf.f90.

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

◆ check_options()

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

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

1734 ! -- modules
1735 use simmodule, only: store_error, store_warning, &
1737 use constantsmodule, only: linelength
1738 ! -- dummy
1739 class(GwfNpftype) :: this
1740 !
1741 ! -- set omega value used for saturation calculations
1742 if (this%inewton > 0) then
1743 this%satomega = dem6
1744 end if
1745 !
1746 if (this%inewton > 0) then
1747 if (this%iperched > 0) then
1748 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. NEWTON OPTION CANNOT '// &
1749 'BE USED WITH PERCHED OPTION.'
1750 call store_error(errmsg)
1751 end if
1752 if (this%ivarcv > 0) then
1753 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. NEWTON OPTION CANNOT '// &
1754 'BE USED WITH VARIABLECV OPTION.'
1755 call store_error(errmsg)
1756 end if
1757 if (this%irewet > 0) then
1758 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. NEWTON OPTION CANNOT '// &
1759 'BE USED WITH REWET OPTION.'
1760 call store_error(errmsg)
1761 end if
1762 else
1763 if (this%ihighcellsat /= 0) then
1764 write (warnmsg, '(a)') 'HIGHEST_CELL_SATURATION '// &
1765 'option cannot be used when NEWTON option in not specified. '// &
1766 'Resetting HIGHEST_CELL_SATURATION option to off.'
1767 this%ihighcellsat = 0
1768 call store_warning(warnmsg)
1769 end if
1770 end if
1771 !
1772 if (this%ixt3d /= 0) then
1773 if (this%icellavg > 0) then
1774 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. '// &
1775 'ALTERNATIVE_CELL_AVERAGING OPTION '// &
1776 'CANNOT BE USED WITH XT3D OPTION.'
1777 call store_error(errmsg)
1778 end if
1779 if (this%ithickstrt > 0) then
1780 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. THICKSTRT OPTION '// &
1781 'CANNOT BE USED WITH XT3D OPTION.'
1782 call store_error(errmsg)
1783 end if
1784 if (this%iperched > 0) then
1785 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. PERCHED OPTION '// &
1786 'CANNOT BE USED WITH XT3D OPTION.'
1787 call store_error(errmsg)
1788 end if
1789 if (this%ivarcv > 0) then
1790 write (errmsg, '(a)') 'ERROR IN NPF OPTIONS. VARIABLECV OPTION '// &
1791 'CANNOT BE USED WITH XT3D OPTION.'
1792 call store_error(errmsg)
1793 end if
1794 end if
1795 !
1796 ! -- Terminate if errors
1797 if (count_errors() > 0) then
1798 call store_error_filename(this%input_fname)
1799 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 1050 of file gwf-npf.f90.

1051 class(GwfNpfType) :: this
1052 integer(I4B), intent(in) :: n
1053 integer(I4B), intent(in) :: m
1054 integer(I4B), intent(in) :: ipos
1055 real(DP), dimension(:), intent(inout) :: flowja
1056 real(DP), dimension(:), intent(in) :: hnew
1057 ! local
1058 real(DP) :: qnm
1059
1060 call this%qcalc(n, m, hnew(n), hnew(m), ipos, qnm)
1061 flowja(ipos) = qnm
1062 flowja(this%dis%con%isym(ipos)) = -qnm
1063

◆ 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 525 of file gwf-npf.f90.

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

◆ 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 1028 of file gwf-npf.f90.

1029 class(DefaultFlowFormulationType), intent(inout) :: this !< default formulation
1030 real(DP), dimension(:), intent(inout) :: hnew !< new head values
1031 real(DP), dimension(:), intent(inout) :: flowja !< flow between cells
1032 ! local
1033 integer(I4B) :: n, m, ipos
1034
1035 do n = 1, this%npf%dis%nodes
1036 do ipos = this%npf%dis%con%ia(n) + 1, this%npf%dis%con%ia(n + 1) - 1
1037 m = this%npf%dis%con%ja(ipos)
1038 if (m < n) cycle
1039 !TODO_MJR: why don't we exclude masked connections here?
1040
1041 ! skip faces claimed by an exclusive formulation
1042 if (this%npf%iformulation(ipos) /= default_flow) cycle
1043
1044 call this%npf%cq_default_flow(n, m, ipos, flowja, hnew)
1045 end do
1046 end do
1047

◆ 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 718 of file gwf-npf.f90.

719 class(DefaultFlowFormulationType), intent(inout) :: this !< default formulation
720 integer(I4B), intent(in) :: kiter !< outer iteration number
721 class(MatrixBaseType), pointer, intent(inout) :: matrix_sln !< system matrix
722 integer(I4B), dimension(:), intent(in) :: idxglo !< local to global connection map
723 real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector
724 real(DP), dimension(:), intent(inout) :: hnew !< new head values
725 ! local
726 integer(I4B) :: n, m, ipos
727
728 do n = 1, this%npf%dis%nodes
729 do ipos = this%npf%dis%con%ia(n) + 1, this%npf%dis%con%ia(n + 1) - 1
730 if (this%npf%dis%con%mask(ipos) == 0) cycle
731
732 m = this%npf%dis%con%ja(ipos)
733
734 ! Calculate upper triangle only, but insert into
735 ! upper and lower parts of matrix
736 if (m < n) cycle
737
738 ! skip faces claimed by an exclusive formulation
739 if (this%npf%iformulation(ipos) /= default_flow) cycle
740
741 call this%npf%fc_default_flow(n, m, ipos, matrix_sln, &
742 rhs, idxglo, hnew)
743 end do
744 end do
745

◆ 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 817 of file gwf-npf.f90.

818 class(DefaultFlowFormulationType), intent(inout) :: this !< default formulation
819 integer(I4B), intent(in) :: kiter !< outer iteration number
820 class(MatrixBaseType), pointer, intent(inout) :: matrix_sln !< system matrix
821 integer(I4B), dimension(:), intent(in) :: idxglo !< local to global connection map
822 real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector
823 real(DP), dimension(:), intent(inout) :: hnew !< new head values
824 ! local
825 integer(I4B) :: n, m, ipos
826
827 do n = 1, this%npf%dis%nodes
828 do ipos = this%npf%dis%con%ia(n) + 1, this%npf%dis%con%ia(n + 1) - 1
829 if (this%npf%dis%con%mask(ipos) == 0) cycle
830
831 m = this%npf%dis%con%ja(ipos)
832
833 ! work on upper triangle
834 if (m < n) cycle
835
836 ! skip faces claimed by an exclusive formulation
837 if (this%npf%iformulation(ipos) /= default_flow) cycle
838
839 call this%npf%fn_default_flow(n, m, ipos, matrix_sln, &
840 rhs, idxglo, hnew)
841 end do
842 end do
843

◆ 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 624 of file gwf-npf.f90.

625 class(GwfNpfType) :: this !< this instance
626 integer(I4B) :: n !< node number n
627 integer(I4B) :: m !< node number m
628 integer(I4B) :: ipos !< connection number
629 class(MatrixBaseType), pointer :: matrix_sln !< system matrix
630 real(DP), intent(inout), dimension(:) :: rhs !< rhs vector
631 integer(I4B), intent(in), dimension(:) :: idxglo !< lookup table from local ipos to global system
632 real(DP), intent(inout), dimension(:) :: hnew !< new head values
633 ! local
634 integer(I4B) :: idiag, ihc
635 integer(I4B) :: isymcon, idiagm
636 real(DP) :: hyn, hym
637 real(DP) :: cond
638 real(DP) :: satn
639 real(DP) :: satm
640
641 ihc = this%dis%con%ihc(this%dis%con%jas(ipos))
642 hyn = this%hy_eff(n, m, ihc, ipos=ipos)
643 hym = this%hy_eff(m, n, ihc, ipos=ipos)
644
645 if (ihc == c3d_vertical) then
646 ! Horizontal conductance
647 cond = vcond(this%ibound(n), this%ibound(m), &
648 this%icelltype(n), this%icelltype(m), this%inewton, &
649 this%ivarcv, this%idewatcv, &
650 this%condsat(this%dis%con%jas(ipos)), hnew(n), hnew(m), &
651 hyn, hym, &
652 this%sat(n), this%sat(m), &
653 this%dis%top(n), this%dis%top(m), &
654 this%dis%bot(n), this%dis%bot(m), &
655 this%dis%con%hwva(this%dis%con%jas(ipos)))
656
657 ! Vertical flow for perched conditions
658 if (this%iperched /= 0) then
659 if (this%icelltype(m) /= 0) then
660 if (hnew(m) < this%dis%top(m)) then
661
662 ! Fill diagonal for n, and add to RHS
663 idiag = this%dis%con%ia(n)
664 rhs(n) = rhs(n) - cond * this%dis%bot(n)
665 call matrix_sln%add_value_pos(idxglo(idiag), -cond)
666
667 ! Fill diagonal for m, and add to RHS
668 isymcon = this%dis%con%isym(ipos)
669 call matrix_sln%add_value_pos(idxglo(isymcon), cond)
670 rhs(m) = rhs(m) + cond * this%dis%bot(n)
671
672 ! go to next connection
673 return
674 end if
675 end if
676 end if
677 else
678 satn = this%sat(n)
679 satm = this%sat(m)
680 if (this%ihighcellsat /= 0) then
681 call this%highest_cell_saturation(n, m, &
682 hnew(n), hnew(m), &
683 satn, satm)
684 end if
685 ! Horizontal conductance
686 cond = hcond(this%ibound(n), this%ibound(m), &
687 this%icelltype(n), this%icelltype(m), &
688 this%inewton, &
689 this%dis%con%ihc(this%dis%con%jas(ipos)), &
690 this%icellavg, &
691 this%condsat(this%dis%con%jas(ipos)), &
692 hnew(n), hnew(m), satn, satm, hyn, hym, &
693 this%dis%top(n), this%dis%top(m), &
694 this%dis%bot(n), this%dis%bot(m), &
695 this%dis%con%cl1(this%dis%con%jas(ipos)), &
696 this%dis%con%cl2(this%dis%con%jas(ipos)), &
697 this%dis%con%hwva(this%dis%con%jas(ipos)))
698 end if
699
700 ! Fill row n
701 idiag = this%dis%con%ia(n)
702 call matrix_sln%add_value_pos(idxglo(ipos), cond)
703 call matrix_sln%add_value_pos(idxglo(idiag), -cond)
704
705 ! Fill row m
706 isymcon = this%dis%con%isym(ipos)
707 idiagm = this%dis%con%ia(m)
708 call matrix_sln%add_value_pos(idxglo(isymcon), cond)
709 call matrix_sln%add_value_pos(idxglo(idiagm), -cond)
710
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 846 of file gwf-npf.f90.

847 class(GwfNpfType) :: this
848 integer(I4B) :: n
849 integer(I4B) :: m
850 integer(I4B) :: ipos
851 class(MatrixBaseType), pointer :: matrix_sln
852 real(DP), intent(inout), dimension(:) :: rhs
853 integer(I4B), intent(in), dimension(:) :: idxglo
854 real(DP), intent(inout), dimension(:) :: hnew
855 ! local
856 integer(I4B) :: isymcon
857 integer(I4B) :: idiag, idiagm
858 integer(I4B) :: iups
859 integer(I4B) :: idn
860 real(DP) :: cond
861 real(DP) :: consterm
862 real(DP) :: filledterm
863 real(DP) :: derv
864 real(DP) :: hds
865 real(DP) :: term
866 real(DP) :: topup
867 real(DP) :: botup
868
869 idiag = this%dis%con%ia(n)
870 isymcon = this%dis%con%isym(ipos)
871
872 if (this%dis%con%ihc(this%dis%con%jas(ipos)) == 0 .and. &
873 this%ivarcv == 0) then
874 return
875 end if
876
877 ! determine upstream node
878 iups = m
879 if (hnew(m) < hnew(n)) iups = n
880 idn = n
881 if (iups == n) idn = m
882 !
883 ! -- no newton terms if upstream cell is confined
884 if (this%icelltype(iups) == 0) return
885 !
886 ! -- Set the upstream top and bot, and then recalculate for a
887 ! vertically staggered horizontal connection
888 topup = this%dis%top(iups)
889 botup = this%dis%bot(iups)
890 if (this%dis%con%ihc(this%dis%con%jas(ipos)) == 2) then
891 topup = min(this%dis%top(n), this%dis%top(m))
892 botup = max(this%dis%bot(n), this%dis%bot(m))
893 end if
894 !
895 ! get saturated conductivity for derivative
896 cond = this%condsat(this%dis%con%jas(ipos))
897 !
898 ! compute additional term
899 consterm = -cond * (hnew(iups) - hnew(idn)) !needs to use hwadi instead of hnew(idn)
900 !filledterm = cond
901 filledterm = matrix_sln%get_value_pos(idxglo(ipos))
902 derv = squadraticsaturationderivative(topup, botup, hnew(iups), &
903 this%satomega)
904 idiagm = this%dis%con%ia(m)
905 ! fill jacobian for n being the upstream node
906 if (iups == n) then
907 hds = hnew(m)
908 !isymcon = this%dis%con%isym(ii)
909 term = consterm * derv
910 rhs(n) = rhs(n) + term * hnew(n) !+ amat(idxglo(isymcon)) * (dwadi * hds - hds) !need to add dwadi
911 rhs(m) = rhs(m) - term * hnew(n) !- amat(idxglo(isymcon)) * (dwadi * hds - hds) !need to add dwadi
912 ! fill in row of n
913 call matrix_sln%add_value_pos(idxglo(idiag), term)
914 ! fill newton term in off diagonal if active cell
915 if (this%ibound(n) > 0) then
916 filledterm = matrix_sln%get_value_pos(idxglo(ipos))
917 call matrix_sln%set_value_pos(idxglo(ipos), filledterm) !* dwadi !need to add dwadi
918 end if
919 !fill row of m
920 filledterm = matrix_sln%get_value_pos(idxglo(idiagm))
921 call matrix_sln%set_value_pos(idxglo(idiagm), filledterm) !- filledterm * (dwadi - DONE) !need to add dwadi
922 ! fill newton term in off diagonal if active cell
923 if (this%ibound(m) > 0) then
924 call matrix_sln%add_value_pos(idxglo(isymcon), -term)
925 end if
926 ! fill jacobian for m being the upstream node
927 else
928 hds = hnew(n)
929 term = -consterm * derv
930 rhs(n) = rhs(n) + term * hnew(m) !+ amat(idxglo(ii)) * (dwadi * hds - hds) !need to add dwadi
931 rhs(m) = rhs(m) - term * hnew(m) !- amat(idxglo(ii)) * (dwadi * hds - hds) !need to add dwadi
932 ! fill in row of n
933 filledterm = matrix_sln%get_value_pos(idxglo(idiag))
934 call matrix_sln%set_value_pos(idxglo(idiag), filledterm) !- filledterm * (dwadi - DONE) !need to add dwadi
935 ! fill newton term in off diagonal if active cell
936 if (this%ibound(n) > 0) then
937 call matrix_sln%add_value_pos(idxglo(ipos), term)
938 end if
939 !fill row of m
940 call matrix_sln%add_value_pos(idxglo(idiagm), -term)
941 ! fill newton term in off diagonal if active cell
942 if (this%ibound(m) > 0) then
943 filledterm = matrix_sln%get_value_pos(idxglo(isymcon))
944 call matrix_sln%set_value_pos(idxglo(isymcon), filledterm) !* dwadi !need to add dwadi
945 end if
946 end if
947
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 753 of file gwf-npf.f90.

754 ! dummy
755 class(GwfNpfType) :: this
756 integer(I4B), intent(in) :: n, m
757 real(DP), intent(in) :: hn, hm
758 real(DP), intent(inout) :: satn, satm
759 ! local
760 integer(I4B) :: ihdbot
761 real(DP) :: botn, botm
762 real(DP) :: top, bot
763
764 botn = this%dis%bot(n)
765 botm = this%dis%bot(m)
766
767 ihdbot = n
768 if (botm > botn) ihdbot = m
769
770 ! recalculate saturation if the difference in elevation between
771 ! two cells exceed a threshold value
772 if (abs(botm - botn) >= dem2) then
773 top = this%dis%top(ihdbot)
774 bot = this%dis%bot(ihdbot)
775 satn = squadraticsaturation(top, bot, hn, this%satomega)
776 satm = squadraticsaturation(top, bot, hm, this%satomega)
777 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 2642 of file gwf-npf.f90.

2643 ! -- return
2644 real(DP) :: hy
2645 ! -- dummy
2646 class(GwfNpfType) :: this
2647 integer(I4B), intent(in) :: n
2648 integer(I4B), intent(in) :: m
2649 integer(I4B), intent(in) :: ihc
2650 integer(I4B), intent(in), optional :: ipos
2651 real(DP), dimension(3), intent(in), optional :: vg
2652 ! -- local
2653 integer(I4B) :: iipos
2654 real(DP) :: hy11, hy22, hy33
2655 real(DP) :: ang1, ang2, ang3
2656 real(DP) :: vg1, vg2, vg3
2657 !
2658 ! -- Initialize
2659 iipos = 0
2660 if (present(ipos)) iipos = ipos
2661 hy11 = this%k11(n)
2662 hy22 = this%k11(n)
2663 hy33 = this%k11(n)
2664 hy22 = this%k22(n)
2665 hy33 = this%k33(n)
2666 !
2667 ! -- Calculate effective K based on whether connection is vertical
2668 ! or horizontal
2669 if (ihc == c3d_vertical) then
2670 !
2671 ! -- Handle rotated anisotropy case that would affect the effective
2672 ! vertical hydraulic conductivity
2673 hy = hy33
2674 if (this%iangle2 > 0) then
2675 if (present(vg)) then
2676 vg1 = vg(1)
2677 vg2 = vg(2)
2678 vg3 = vg(3)
2679 else
2680 call this%dis%connection_normal(n, m, ihc, vg1, vg2, vg3, iipos)
2681 end if
2682 ang1 = this%angle1(n)
2683 ang2 = this%angle2(n)
2684 ang3 = dzero
2685 if (this%iangle3 > 0) ang3 = this%angle3(n)
2686 hy = hyeff(hy11, hy22, hy33, ang1, ang2, ang3, vg1, vg2, vg3, &
2687 this%iavgkeff)
2688 end if
2689 !
2690 else
2691 !
2692 ! -- Handle horizontal case
2693 hy = hy11
2694 if (this%ik22 > 0) then
2695 if (present(vg)) then
2696 vg1 = vg(1)
2697 vg2 = vg(2)
2698 vg3 = vg(3)
2699 else
2700 call this%dis%connection_normal(n, m, ihc, vg1, vg2, vg3, iipos)
2701 end if
2702 ang1 = dzero
2703 ang2 = dzero
2704 ang3 = dzero
2705 if (this%iangle1 > 0) then
2706 ang1 = this%angle1(n)
2707 if (this%iangle2 > 0) then
2708 ang2 = this%angle2(n)
2709 if (this%iangle3 > 0) ang3 = this%angle3(n)
2710 end if
2711 end if
2712 hy = hyeff(hy11, hy22, hy33, ang1, ang2, ang3, vg1, vg2, vg3, &
2713 this%iavgkeff)
2714 end if
2715 !
2716 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 3032 of file gwf-npf.f90.

3033 ! -- dummy
3034 class(GwfNpfType) :: this
3035 integer(I4B), intent(in) :: nedges
3036 !
3037 this%nedges = this%nedges + nedges

◆ log_griddata()

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

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

1805 ! -- modules
1807 ! -- dummy
1808 class(GwfNpfType) :: this
1809 type(GwfNpfParamFoundType), intent(in) :: found
1810 !
1811 write (this%iout, '(1x,a)') 'Setting NPF Griddata'
1812 !
1813 if (found%icelltype) then
1814 write (this%iout, '(4x,a)') 'ICELLTYPE set from input file'
1815 end if
1816 !
1817 if (found%k) then
1818 write (this%iout, '(4x,a)') 'K set from input file'
1819 end if
1820 !
1821 if (found%k33) then
1822 write (this%iout, '(4x,a)') 'K33 set from input file'
1823 else
1824 write (this%iout, '(4x,a)') 'K33 not provided. Setting K33 = K.'
1825 end if
1826 !
1827 if (found%k22) then
1828 write (this%iout, '(4x,a)') 'K22 set from input file'
1829 else
1830 write (this%iout, '(4x,a)') 'K22 not provided. Setting K22 = K.'
1831 end if
1832 !
1833 if (found%wetdry) then
1834 write (this%iout, '(4x,a)') 'WETDRY set from input file'
1835 end if
1836 !
1837 if (found%angle1) then
1838 write (this%iout, '(4x,a)') 'ANGLE1 set from input file'
1839 end if
1840 !
1841 if (found%angle2) then
1842 write (this%iout, '(4x,a)') 'ANGLE2 set from input file'
1843 end if
1844 !
1845 if (found%angle3) then
1846 write (this%iout, '(4x,a)') 'ANGLE3 set from input file'
1847 end if
1848 !
1849 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 1550 of file gwf-npf.f90.

1551 ! -- modules
1552 use kindmodule, only: lgp
1554 ! -- dummy
1555 class(GwfNpftype) :: this
1556 ! -- locals
1557 type(GwfNpfParamFoundType), intent(in) :: found
1558 !
1559 write (this%iout, '(1x,a)') 'Setting NPF Options'
1560 if (found%iprflow) &
1561 write (this%iout, '(4x,a)') 'Cell-by-cell flow information will be printed &
1562 &to listing file whenever ICBCFL is not zero.'
1563 if (found%ipakcb) &
1564 write (this%iout, '(4x,a)') 'Cell-by-cell flow information will be saved &
1565 &to binary file whenever ICBCFL is not zero.'
1566 if (found%cellavg) &
1567 write (this%iout, '(4x,a,i0)') 'Alternative cell averaging [1=logarithmic, &
1568 &2=AMT-LMK, 3=AMT-HMK] set to: ', &
1569 this%icellavg
1570 if (found%ithickstrt) &
1571 write (this%iout, '(4x,a)') 'THICKSTRT option has been activated.'
1572 if (found%ihighcellsat) &
1573 write (this%iout, '(4x,a)') 'HIGHEST_CELL_SATURATION option &
1574 &has been activated.'
1575 if (found%iperched) &
1576 write (this%iout, '(4x,a)') 'Vertical flow will be adjusted for perched &
1577 &conditions.'
1578 if (found%ivarcv) &
1579 write (this%iout, '(4x,a)') 'Vertical conductance varies with water table.'
1580 if (found%idewatcv) &
1581 write (this%iout, '(4x,a)') 'Vertical conductance is calculated using &
1582 &only the saturated thickness and properties &
1583 &of the overlying cell if the head in the &
1584 &underlying cell is below its top.'
1585 if (found%ixt3d) write (this%iout, '(4x,a)') 'XT3D formulation is selected.'
1586 if (found%ixt3drhs) &
1587 write (this%iout, '(4x,a)') 'XT3D RHS formulation is selected.'
1588 if (found%isavspdis) &
1589 write (this%iout, '(4x,a)') 'Specific discharge will be calculated at cell &
1590 &centers and written to DATA-SPDIS in budget &
1591 &file when requested.'
1592 if (found%isavsat) &
1593 write (this%iout, '(4x,a)') 'Saturation will be written to DATA-SAT in &
1594 &budget file when requested.'
1595 if (found%ik22overk) &
1596 write (this%iout, '(4x,a)') 'Values specified for K22 are anisotropy &
1597 &ratios and will be multiplied by K before &
1598 &being used in calculations.'
1599 if (found%ik33overk) &
1600 write (this%iout, '(4x,a)') 'Values specified for K33 are anisotropy &
1601 &ratios and will be multiplied by K before &
1602 &being used in calculations.'
1603 if (found%inewton) &
1604 write (this%iout, '(4x,a)') 'NEWTON-RAPHSON method disabled for unconfined &
1605 &cells'
1606 if (found%satomega) &
1607 write (this%iout, '(4x,a,1pg15.6)') 'Saturation omega: ', this%satomega
1608 if (found%irewet) &
1609 write (this%iout, '(4x,a)') 'Rewetting is active.'
1610 if (found%wetfct) &
1611 write (this%iout, '(4x,a,1pg15.6)') &
1612 'Wetting factor (WETFCT) has been set to: ', this%wetfct
1613 if (found%iwetit) &
1614 write (this%iout, '(4x,a,i5)') &
1615 'Wetting iteration interval (IWETIT) has been set to: ', this%iwetit
1616 if (found%ihdwet) &
1617 write (this%iout, '(4x,a,i5)') &
1618 'Head rewet equation (IHDWET) has been set to: ', this%ihdwet
1619 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 289 of file gwf-npf.f90.

290 ! -- modules
291 use sparsemodule, only: sparsematrix
292 ! -- dummy
293 class(GwfNpftype) :: this
294 integer(I4B), intent(in) :: moffset
295 type(sparsematrix), intent(inout) :: sparse
296 !
297 ! -- Add extended neighbors (neighbors of neighbors)
298 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 432 of file gwf-npf.f90.

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

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

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

◆ 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 999 of file gwf-npf.f90.

1000 ! -- dummy
1001 class(GwfNpfType) :: this
1002 real(DP), intent(inout), dimension(:) :: hnew
1003 real(DP), intent(inout), dimension(:) :: flowja
1004 ! -- local
1005 integer(I4B) :: iform
1006 !
1007 ! -- Calculate the flow across each cell face and store in flowja
1008 !
1009 if (this%ixt3d /= 0) then
1010 call this%xt3d%xt3d_flowja(hnew, flowja)
1011 else
1012 ! Each active formulation runs over all connections and adds its
1013 ! flows; the default conductance formulation is always active.
1014 call this%default_form%cq(hnew, flowja)
1015 do iform = 1, max_ext_flow_forms
1016 if (associated(this%flow_formulations(iform)%form)) then
1017 call this%flow_formulations(iform)%form%cq(hnew, flowja)
1018 end if
1019 end do
1020 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 189 of file gwf-npf.f90.

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

◆ npf_da()

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

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

1246 ! -- modules
1249 ! -- dummy
1250 class(GwfNpftype) :: this
1251
1252 ! free spdis work structure
1253 if (this%icalcspdis == 1 .and. this%spdis_wa%is_created()) &
1254 call this%spdis_wa%destroy()
1255 deallocate (this%spdis_wa)
1256 !
1257 ! -- Deallocate input memory
1258 call memorystore_remove(this%name_model, 'NPF', idm_context)
1259 !
1260 ! -- TVK
1261 if (this%intvk /= 0) then
1262 call this%tvk%da()
1263 deallocate (this%tvk)
1264 end if
1265 !
1266 ! -- VSC
1267 if (this%invsc /= 0) then
1268 nullify (this%vsc)
1269 end if
1270 !
1271 ! -- Scalars
1272 call mem_deallocate(this%iname)
1273 call mem_deallocate(this%ixt3d)
1274 call mem_deallocate(this%ixt3drhs)
1275 call mem_deallocate(this%satomega)
1276 call mem_deallocate(this%hnoflo)
1277 call mem_deallocate(this%hdry)
1278 call mem_deallocate(this%icellavg)
1279 call mem_deallocate(this%iavgkeff)
1280 call mem_deallocate(this%ik22)
1281 call mem_deallocate(this%ik33)
1282 call mem_deallocate(this%iperched)
1283 call mem_deallocate(this%ivarcv)
1284 call mem_deallocate(this%idewatcv)
1285 call mem_deallocate(this%ithickstrt)
1286 call mem_deallocate(this%ihighcellsat)
1287 call mem_deallocate(this%isavspdis)
1288 call mem_deallocate(this%isavsat)
1289 call mem_deallocate(this%icalcspdis)
1290 call mem_deallocate(this%irewet)
1291 call mem_deallocate(this%wetfct)
1292 call mem_deallocate(this%iwetit)
1293 call mem_deallocate(this%ihdwet)
1294 call mem_deallocate(this%ibotnode)
1295 call mem_deallocate(this%iwetdry)
1296 call mem_deallocate(this%iangle1)
1297 call mem_deallocate(this%iangle2)
1298 call mem_deallocate(this%iangle3)
1299 call mem_deallocate(this%nedges)
1300 call mem_deallocate(this%lastedge)
1301 call mem_deallocate(this%ik22overk)
1302 call mem_deallocate(this%ik33overk)
1303 call mem_deallocate(this%intvk)
1304 call mem_deallocate(this%invsc)
1305 call mem_deallocate(this%kchangeper)
1306 call mem_deallocate(this%kchangestp)
1307 !
1308 ! -- Deallocate arrays
1309 deallocate (this%aname)
1310 call mem_deallocate(this%ithickstartflag)
1311 call mem_deallocate(this%icelltype)
1312 call mem_deallocate(this%k11)
1313 call mem_deallocate(this%k22)
1314 call mem_deallocate(this%k33)
1315 call mem_deallocate(this%krel)
1316 call mem_deallocate(this%k11input)
1317 call mem_deallocate(this%k22input)
1318 call mem_deallocate(this%k33input)
1319 call mem_deallocate(this%sat, 'SAT', this%memoryPath)
1320 call mem_deallocate(this%condsat)
1321 call mem_deallocate(this%wetdry)
1322 call mem_deallocate(this%angle1)
1323 call mem_deallocate(this%angle2)
1324 call mem_deallocate(this%angle3)
1325 call mem_deallocate(this%nodedge)
1326 call mem_deallocate(this%ihcedge)
1327 call mem_deallocate(this%propsedge)
1328 call mem_deallocate(this%iedge_ptr)
1329 call mem_deallocate(this%edge_idxs)
1330 call mem_deallocate(this%spdis, 'SPDIS', this%memoryPath)
1331 call mem_deallocate(this%nodekchange)
1332 call mem_deallocate(this%iformulation)
1333 !
1334 ! -- deallocate the default conductance formulation
1335 if (associated(this%default_form)) then
1336 deallocate (this%default_form)
1337 this%default_form => null()
1338 end if
1339 !
1340 ! -- deallocate parent
1341 call this%NumericalPackageType%da()
1342
1343 ! pointers
1344 this%hnew => null()
1345
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 236 of file gwf-npf.f90.

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

597 class(GwfNpfType) :: this !< this instance
598 integer(I4B) :: kiter !< outer iteration number
599 class(MatrixBaseType), pointer :: matrix_sln !< the system to be formulated
600 integer(I4B), intent(in), dimension(:) :: idxglo !< lookup table from local to global connection number
601 real(DP), intent(inout), dimension(:) :: rhs !< the righthandside vector
602 real(DP), intent(inout), dimension(:) :: hnew !< the new head values
603 ! local
604 integer(I4B) :: iform
605
606 if (this%ixt3d /= 0) then
607 call this%xt3d%xt3d_fc(kiter, matrix_sln, idxglo, rhs, hnew)
608 else
609 ! Each active formulation runs over all connections and adds its
610 ! terms; the default conductance formulation is always active.
611 call this%default_form%fc(kiter, matrix_sln, idxglo, rhs, hnew)
612 do iform = 1, max_ext_flow_forms
613 if (associated(this%flow_formulations(iform)%form)) then
614 call this%flow_formulations(iform)%form%fc(kiter, matrix_sln, &
615 idxglo, rhs, hnew)
616 end if
617 end do
618 end if
619

◆ 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 782 of file gwf-npf.f90.

783 ! -- dummy
784 class(GwfNpfType) :: this
785 integer(I4B) :: kiter
786 class(MatrixBaseType), pointer :: matrix_sln
787 integer(I4B), intent(in), dimension(:) :: idxglo
788 real(DP), intent(inout), dimension(:) :: rhs
789 real(DP), intent(inout), dimension(:) :: hnew
790 ! -- local
791 integer(I4B) :: nodes, nja
792 integer(I4B) :: iform
793 !
794 ! -- add newton terms to solution matrix
795 nodes = this%dis%nodes
796 nja = this%dis%con%nja
797 if (this%ixt3d /= 0) then
798 call this%xt3d%xt3d_fn(kiter, nodes, nja, matrix_sln, idxglo, rhs, hnew)
799 else
800 ! Each active formulation runs over all connections and adds its
801 ! newton terms; the default conductance formulation is always active.
802 call this%default_form%fn(kiter, matrix_sln, idxglo, rhs, hnew)
803 do iform = 1, max_ext_flow_forms
804 if (associated(this%flow_formulations(iform)%form)) then
805 call this%flow_formulations(iform)%form%fn(kiter, matrix_sln, &
806 idxglo, rhs, hnew)
807 end if
808 end do
809 end if

◆ npf_initial_saturation()

subroutine gwfnpfmodule::npf_initial_saturation ( class(gwfnpftype) this,
real(dp), dimension(:), intent(inout) sat )
private

Saturation is not evaluated from the initial heads until the first solve.

Parameters
thisGwfNpfType object
[in,out]satsaturation from the initial heads

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

566 ! -- dummy
567 class(GwfNpfType) :: this !< GwfNpfType object
568 real(DP), dimension(:), intent(inout) :: sat !< saturation from the initial heads
569 ! -- local
570 integer(I4B) :: n
571 real(DP) :: satn
572 !
573 do n = 1, this%dis%nodes
574 if (this%icelltype(n) /= 0) then
575 !
576 ! -- a convertible cell that is inactive at the start, such as one
577 ! whose starting head is below its bottom, has no saturated
578 ! thickness
579 if (this%ibound(n) == 0) then
580 satn = dzero
581 else
582 call this%thksat(n, this%ic%strt(n), satn)
583 end if
584 else
585 !
586 ! -- a confined cell is saturated, unless THICKSTRT sets its
587 ! saturated thickness from the starting head
588 satn = this%calc_initial_sat(n)
589 end if
590 sat(n) = satn
591 end do

◆ npf_mc()

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

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

304 ! -- dummy
305 class(GwfNpftype) :: this
306 integer(I4B), intent(in) :: moffset
307 class(MatrixBaseType), pointer :: matrix_sln
308 !
309 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 955 of file gwf-npf.f90.

956 ! -- dummy
957 class(GwfNpfType) :: this
958 integer(I4B), intent(in) :: neqmod
959 real(DP), dimension(neqmod), intent(inout) :: x
960 real(DP), dimension(neqmod), intent(in) :: xtemp
961 real(DP), dimension(neqmod), intent(inout) :: dx
962 integer(I4B), intent(inout) :: inewtonur
963 real(DP), intent(inout) :: dxmax
964 integer(I4B), intent(inout) :: locmax
965 ! -- local
966 integer(I4B) :: n
967 integer(I4B) :: ibot
968 real(DP) :: botm
969 real(DP) :: xx
970 real(DP) :: dxx
971 !
972 ! -- Newton-Raphson under-relaxation
973 do n = 1, this%dis%nodes
974 if (this%ibound(n) < 1) cycle
975 ibot = this%ibotnode(n)
976 ! Newton-Raphson under-relaxation is only applied to convertible cells where
977 ! the bottom cell in a stack is convertible
978 if (this%icelltype(n) > 0 .and. this%icelltype(ibot) > 0) then
979 botm = this%dis%bot(ibot)
980 ! Newton-Raphson under-relaxation applied when solution head is
981 ! below the bottom of the model
982 if (x(n) < botm) then
983 inewtonur = 1
984 xx = xtemp(n) * (done - dp9) + botm * dp9
985 dxx = xx - xtemp(n)
986 if (abs(dxx) > abs(dxmax)) then
987 locmax = n
988 dxmax = dxx
989 end if
990 x(n) = xx
991 dx(n) = xtemp(n) - x(n)
992 end if
993 end if
994 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 1206 of file gwf-npf.f90.

1207 ! -- modules
1208 use tdismodule, only: kper, kstp
1209 use constantsmodule, only: lenbigline
1210 ! -- dummy
1211 class(GwfNpfType) :: this
1212 integer(I4B), intent(in) :: ibudfl
1213 real(DP), intent(inout), dimension(:) :: flowja
1214 ! -- local
1215 character(len=LENBIGLINE) :: line
1216 character(len=30) :: tempstr
1217 integer(I4B) :: n, ipos, m
1218 real(DP) :: qnm
1219 ! -- formats
1220 character(len=*), parameter :: fmtiprflow = &
1221 &"(/,4x,'CALCULATED INTERCELL FLOW FOR PERIOD ', i0, ' STEP ', i0)"
1222 !
1223 ! -- Write flowja to list file if requested
1224 if (ibudfl /= 0 .and. this%iprflow > 0) then
1225 write (this%iout, fmtiprflow) kper, kstp
1226 do n = 1, this%dis%nodes
1227 line = ''
1228 call this%dis%noder_to_string(n, tempstr)
1229 line = trim(tempstr)//':'
1230 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
1231 m = this%dis%con%ja(ipos)
1232 call this%dis%noder_to_string(m, tempstr)
1233 line = trim(line)//' '//trim(tempstr)
1234 qnm = flowja(ipos)
1235 write (tempstr, '(1pg15.6)') qnm
1236 line = trim(line)//' '//trim(adjustl(tempstr))
1237 end do
1238 write (this%iout, '(a)') trim(line)
1239 end do
1240 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 417 of file gwf-npf.f90.

418 implicit none
419 ! -- dummy
420 class(GwfNpfType) :: this
421 !
422 ! -- TVK
423 if (this%intvk /= 0) then
424 call this%tvk%rp()
425 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 1169 of file gwf-npf.f90.

1170 ! -- dummy
1171 class(GwfNpfType) :: this
1172 real(DP), dimension(:), intent(in) :: flowja
1173 integer(I4B), intent(in) :: icbcfl
1174 integer(I4B), intent(in) :: icbcun
1175 ! -- local
1176 integer(I4B) :: ibinun
1177 !
1178 ! -- Set unit number for binary output
1179 if (this%ipakcb < 0) then
1180 ibinun = icbcun
1181 elseif (this%ipakcb == 0) then
1182 ibinun = 0
1183 else
1184 ibinun = this%ipakcb
1185 end if
1186 if (icbcfl == 0) ibinun = 0
1187 !
1188 ! -- Write the face flows if requested
1189 if (ibinun /= 0) then
1190 call this%dis%record_connection_array(flowja, ibinun, this%iout)
1191 end if
1192 !
1193 ! -- Calculate specific discharge at cell centers and write, if requested
1194 if (this%isavspdis /= 0) then
1195 if (ibinun /= 0) call this%sav_spdis(ibinun)
1196 end if
1197 !
1198 ! -- Save saturation, if requested
1199 if (this%isavsat /= 0) then
1200 if (ibinun /= 0) call this%sav_sat(ibinun)
1201 end if

◆ prepare_edge_lookup()

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

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

3099 class(GwfNpfType) :: this
3100 ! local
3101 integer(I4B) :: i, inode, iedge
3102 integer(I4B) :: n, start, end
3103 integer(I4B) :: prev_cnt, strt_idx, ipos
3104
3105 do i = 1, size(this%iedge_ptr)
3106 this%iedge_ptr(i) = 0
3107 end do
3108 do i = 1, size(this%edge_idxs)
3109 this%edge_idxs(i) = 0
3110 end do
3111
3112 ! count
3113 do iedge = 1, this%nedges
3114 n = this%nodedge(iedge)
3115 this%iedge_ptr(n) = this%iedge_ptr(n) + 1
3116 end do
3117
3118 ! determine start indexes
3119 prev_cnt = this%iedge_ptr(1)
3120 this%iedge_ptr(1) = 1
3121 do inode = 2, this%dis%nodes + 1
3122 strt_idx = this%iedge_ptr(inode - 1) + prev_cnt
3123 prev_cnt = this%iedge_ptr(inode)
3124 this%iedge_ptr(inode) = strt_idx
3125 end do
3126
3127 ! loop over edges to fill lookup table
3128 do iedge = 1, this%nedges
3129 n = this%nodedge(iedge)
3130 start = this%iedge_ptr(n)
3131 end = this%iedge_ptr(n + 1) - 1
3132 do ipos = start, end
3133 if (this%edge_idxs(ipos) > 0) cycle ! go to next
3134 this%edge_idxs(ipos) = iedge
3135 exit
3136 end do
3137 end do
3138

◆ prepcheck()

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

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

1950 ! -- modules
1953 ! -- dummy
1954 class(GwfNpfType) :: this
1955 ! -- local
1956 character(len=24), dimension(:), pointer :: aname
1957 character(len=LINELENGTH) :: cellstr, errmsg
1958 integer(I4B) :: nerr, n
1959 ! -- format
1960 character(len=*), parameter :: fmtkerr = &
1961 &"(1x, 'Hydraulic property ',a,' is <= 0 for cell ',a, ' ', 1pg15.6)"
1962 character(len=*), parameter :: fmtkerr2 = &
1963 &"(1x, '... ', i0,' additional errors not shown for ',a)"
1964 !
1965 ! -- initialize
1966 aname => this%aname
1967 !
1968 ! -- check k11
1969 nerr = 0
1970 do n = 1, size(this%k11)
1971 if (this%k11(n) <= dzero) then
1972 nerr = nerr + 1
1973 if (nerr <= 20) then
1974 call this%dis%noder_to_string(n, cellstr)
1975 write (errmsg, fmtkerr) trim(adjustl(aname(2))), trim(cellstr), &
1976 this%k11(n)
1977 call store_error(errmsg)
1978 end if
1979 end if
1980 end do
1981 if (nerr > 20) then
1982 write (errmsg, fmtkerr2) nerr, trim(adjustl(aname(2)))
1983 call store_error(errmsg)
1984 end if
1985 !
1986 ! -- check k33 because it was read
1987 if (this%ik33 /= 0) then
1988 !
1989 ! -- Check to make sure values are greater than or equal to zero
1990 nerr = 0
1991 do n = 1, size(this%k33)
1992 if (this%ik33overk /= 0) this%k33(n) = this%k33(n) * this%k11(n)
1993 if (this%k33(n) <= dzero) then
1994 nerr = nerr + 1
1995 if (nerr <= 20) then
1996 call this%dis%noder_to_string(n, cellstr)
1997 write (errmsg, fmtkerr) trim(adjustl(aname(3))), trim(cellstr), &
1998 this%k33(n)
1999 call store_error(errmsg)
2000 end if
2001 end if
2002 end do
2003 if (nerr > 20) then
2004 write (errmsg, fmtkerr2) nerr, trim(adjustl(aname(3)))
2005 call store_error(errmsg)
2006 end if
2007 end if
2008 !
2009 ! -- check k22 because it was read
2010 if (this%ik22 /= 0) then
2011 !
2012 ! -- Check to make sure that angles are available
2013 if (this%dis%con%ianglex == 0) then
2014 write (errmsg, '(a)') 'Error. ANGLDEGX not provided in '// &
2015 'discretization file, but K22 was specified. '
2016 call store_error(errmsg)
2017 end if
2018 !
2019 ! -- Check to make sure values are greater than or equal to zero
2020 nerr = 0
2021 do n = 1, size(this%k22)
2022 if (this%ik22overk /= 0) this%k22(n) = this%k22(n) * this%k11(n)
2023 if (this%k22(n) <= dzero) then
2024 nerr = nerr + 1
2025 if (nerr <= 20) then
2026 call this%dis%noder_to_string(n, cellstr)
2027 write (errmsg, fmtkerr) trim(adjustl(aname(4))), trim(cellstr), &
2028 this%k22(n)
2029 call store_error(errmsg)
2030 end if
2031 end if
2032 end do
2033 if (nerr > 20) then
2034 write (errmsg, fmtkerr2) nerr, trim(adjustl(aname(4)))
2035 call store_error(errmsg)
2036 end if
2037 end if
2038 !
2039 ! -- check for wetdry conflicts
2040 if (this%irewet == 1) then
2041 if (this%iwetdry == 0) then
2042 write (errmsg, '(a, a, a)') 'Error in GRIDDATA block: ', &
2043 trim(adjustl(aname(5))), ' not found.'
2044 call store_error(errmsg)
2045 end if
2046 end if
2047 !
2048 ! -- Check for angle conflicts
2049 if (this%iangle1 /= 0) then
2050 do n = 1, size(this%angle1)
2051 this%angle1(n) = this%angle1(n) * dpio180
2052 end do
2053 else
2054 if (this%ixt3d /= 0) then
2055 this%iangle1 = 1
2056 write (this%iout, '(a)') 'XT3D IN USE, BUT ANGLE1 NOT SPECIFIED. '// &
2057 'SETTING ANGLE1 TO ZERO.'
2058 do n = 1, size(this%angle1)
2059 this%angle1(n) = dzero
2060 end do
2061 end if
2062 end if
2063 if (this%iangle2 /= 0) then
2064 if (this%iangle1 == 0) then
2065 write (errmsg, '(a)') 'ANGLE2 SPECIFIED BUT NOT ANGLE1. '// &
2066 'ANGLE2 REQUIRES ANGLE1. '
2067 call store_error(errmsg)
2068 end if
2069 if (this%iangle3 == 0) then
2070 write (errmsg, '(a)') 'ANGLE2 SPECIFIED BUT NOT ANGLE3. '// &
2071 'SPECIFY BOTH OR NEITHER ONE. '
2072 call store_error(errmsg)
2073 end if
2074 do n = 1, size(this%angle2)
2075 this%angle2(n) = this%angle2(n) * dpio180
2076 end do
2077 end if
2078 if (this%iangle3 /= 0) then
2079 if (this%iangle1 == 0) then
2080 write (errmsg, '(a)') 'ANGLE3 SPECIFIED BUT NOT ANGLE1. '// &
2081 'ANGLE3 REQUIRES ANGLE1. '
2082 call store_error(errmsg)
2083 end if
2084 if (this%iangle2 == 0) then
2085 write (errmsg, '(a)') 'ANGLE3 SPECIFIED BUT NOT ANGLE2. '// &
2086 'SPECIFY BOTH OR NEITHER ONE. '
2087 call store_error(errmsg)
2088 end if
2089 do n = 1, size(this%angle3)
2090 this%angle3(n) = this%angle3(n) * dpio180
2091 end do
2092 end if
2093 !
2094 ! -- terminate if data errors
2095 if (count_errors() > 0) then
2096 call store_error_filename(this%input_fname)
2097 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 2110 of file gwf-npf.f90.

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

2530 ! -- dummy
2531 class(GwfNpfType) :: this
2532 integer(I4B), intent(in) :: kiter
2533 integer(I4B), intent(in) :: node
2534 real(DP), intent(in) :: hm
2535 integer(I4B), intent(in) :: ibdm
2536 integer(I4B), intent(in) :: ihc
2537 real(DP), intent(inout), dimension(:) :: hnew
2538 integer(I4B), intent(out) :: irewet
2539 ! -- local
2540 integer(I4B) :: itflg
2541 real(DP) :: wd, awd, turnon, bbot
2542 !
2543 irewet = 0
2544 !
2545 ! -- Convert a dry cell to wet if it meets the criteria
2546 if (this%irewet > 0) then
2547 itflg = mod(kiter, this%iwetit)
2548 if (itflg == 0) then
2549 if (this%ibound(node) == 0 .and. this%wetdry(node) /= dzero) then
2550 !
2551 ! -- Calculate wetting elevation
2552 bbot = this%dis%bot(node)
2553 wd = this%wetdry(node)
2554 awd = wd
2555 if (wd < 0) awd = -wd
2556 turnon = bbot + awd
2557 !
2558 ! -- Check head in adjacent cells to see if wetting elevation has
2559 ! been reached
2560 if (ihc == c3d_vertical) then
2561 !
2562 ! -- check cell below
2563 if (ibdm > 0 .and. hm >= turnon) irewet = 1
2564 else
2565 if (wd > dzero) then
2566 !
2567 ! -- check horizontally adjacent cells
2568 if (ibdm > 0 .and. hm >= turnon) irewet = 1
2569 end if
2570 end if
2571 !
2572 if (irewet == 1) then
2573 ! -- rewet cell; use equation 3a if ihdwet=0; use equation 3b if
2574 ! ihdwet is not 0.
2575 if (this%ihdwet == 0) then
2576 hnew(node) = bbot + this%wetfct * (hm - bbot)
2577 else
2578 hnew(node) = bbot + this%wetfct * awd !(hm - bbot)
2579 end if
2580 this%ibound(node) = 30000
2581 end if
2582 end if
2583 end if
2584 end if

◆ sav_sat()

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

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

3001 ! -- dummy
3002 class(GwfNpfType) :: this
3003 integer(I4B), intent(in) :: ibinun
3004 ! -- local
3005 character(len=16) :: text
3006 character(len=16), dimension(1) :: auxtxt
3007 real(DP), dimension(1) :: a
3008 integer(I4B) :: n
3009 integer(I4B) :: naux
3010 !
3011 ! -- Write the header
3012 text = ' DATA-SAT'
3013 naux = 1
3014 auxtxt(:) = [' sat']
3015 call this%dis%record_srcdst_list_header(text, this%name_model, &
3016 this%packName, this%name_model, &
3017 this%packName, naux, auxtxt, ibinun, &
3018 this%dis%nodes, this%iout)
3019 !
3020 ! -- Write a zero for Q, and then write saturation as an aux variables
3021 do n = 1, this%dis%nodes
3022 a(1) = this%sat(n)
3023 call this%dis%record_mf6_list_entry(ibinun, n, n, dzero, naux, a)
3024 end do

◆ sav_spdis()

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

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

2973 ! -- dummy
2974 class(GwfNpfType) :: this
2975 integer(I4B), intent(in) :: ibinun
2976 ! -- local
2977 character(len=16) :: text
2978 character(len=16), dimension(3) :: auxtxt
2979 integer(I4B) :: n
2980 integer(I4B) :: naux
2981 !
2982 ! -- Write the header
2983 text = ' DATA-SPDIS'
2984 naux = 3
2985 auxtxt(:) = [' qx', ' qy', ' qz']
2986 call this%dis%record_srcdst_list_header(text, this%name_model, &
2987 this%packName, this%name_model, &
2988 this%packName, naux, auxtxt, ibinun, &
2989 this%dis%nodes, this%iout)
2990 !
2991 ! -- Write a zero for Q, and then write qx, qy, qz as aux variables
2992 do n = 1, this%dis%nodes
2993 call this%dis%record_mf6_list_entry(ibinun, n, n, dzero, naux, &
2994 this%spdis(:, n))
2995 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 3069 of file gwf-npf.f90.

3071 ! -- dummy
3072 class(GwfNpfType) :: this
3073 integer(I4B), intent(in) :: nodedge
3074 integer(I4B), intent(in) :: ihcedge
3075 real(DP), intent(in) :: q
3076 real(DP), intent(in) :: area
3077 real(DP), intent(in) :: nx
3078 real(DP), intent(in) :: ny
3079 real(DP), intent(in) :: distance
3080 ! -- local
3081 integer(I4B) :: lastedge
3082 !
3083 this%lastedge = this%lastedge + 1
3084 lastedge = this%lastedge
3085 this%nodedge(lastedge) = nodedge
3086 this%ihcedge(lastedge) = ihcedge
3087 this%propsedge(1, lastedge) = q
3088 this%propsedge(2, lastedge) = area
3089 this%propsedge(3, lastedge) = nx
3090 this%propsedge(4, lastedge) = ny
3091 this%propsedge(5, lastedge) = distance
3092 !
3093 ! -- If this is the last edge, then the next call must be starting a new
3094 ! edge properties assignment loop, so need to reset lastedge to 0
3095 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 1715 of file gwf-npf.f90.

1716 ! -- dummy
1717 class(GwfNpftype) :: this
1718 type(GwfNpfOptionsType), intent(in) :: options
1719 !
1720 this%ithickstrt = options%ithickstrt
1721 this%ihighcellsat = options%ihighcellsat
1722 this%iperched = options%iperched
1723 this%ivarcv = options%ivarcv
1724 this%idewatcv = options%idewatcv
1725 this%irewet = options%irewet
1726 this%wetfct = options%wetfct
1727 this%iwetit = options%iwetit
1728 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 1091 of file gwf-npf.f90.

1092 ! -- dummy
1093 class(GwfNpfType) :: this
1094 integer(I4B), intent(in) :: n
1095 integer(I4B), intent(in) :: m
1096 real(DP), intent(in) :: hn
1097 real(DP), intent(in) :: hm
1098 integer(I4B), intent(in) :: icon
1099 real(DP), intent(inout) :: qnm
1100 ! -- local
1101 real(DP) :: hyn, hym
1102 real(DP) :: condnm
1103 real(DP) :: hntemp, hmtemp
1104 real(DP) :: satn, satm
1105 integer(I4B) :: ihc
1106 !
1107 ! -- Initialize
1108 ihc = this%dis%con%ihc(this%dis%con%jas(icon))
1109 hyn = this%hy_eff(n, m, ihc, ipos=icon)
1110 hym = this%hy_eff(m, n, ihc, ipos=icon)
1111 !
1112 ! -- Calculate conductance
1113 if (ihc == c3d_vertical) then
1114 condnm = vcond(this%ibound(n), this%ibound(m), &
1115 this%icelltype(n), this%icelltype(m), this%inewton, &
1116 this%ivarcv, this%idewatcv, &
1117 this%condsat(this%dis%con%jas(icon)), hn, hm, &
1118 hyn, hym, &
1119 this%sat(n), this%sat(m), &
1120 this%dis%top(n), this%dis%top(m), &
1121 this%dis%bot(n), this%dis%bot(m), &
1122 this%dis%con%hwva(this%dis%con%jas(icon)))
1123 else
1124 satn = this%sat(n)
1125 satm = this%sat(m)
1126 if (this%ihighcellsat /= 0) then
1127 call this%highest_cell_saturation(n, m, hn, hm, satn, satm)
1128 end if
1129
1130 condnm = hcond(this%ibound(n), this%ibound(m), &
1131 this%icelltype(n), this%icelltype(m), &
1132 this%inewton, &
1133 this%dis%con%ihc(this%dis%con%jas(icon)), &
1134 this%icellavg, &
1135 this%condsat(this%dis%con%jas(icon)), &
1136 hn, hm, satn, satm, hyn, hym, &
1137 this%dis%top(n), this%dis%top(m), &
1138 this%dis%bot(n), this%dis%bot(m), &
1139 this%dis%con%cl1(this%dis%con%jas(icon)), &
1140 this%dis%con%cl2(this%dis%con%jas(icon)), &
1141 this%dis%con%hwva(this%dis%con%jas(icon)))
1142 end if
1143 !
1144 ! -- Initialize hntemp and hmtemp
1145 hntemp = hn
1146 hmtemp = hm
1147 !
1148 ! -- Check and adjust for dewatered conditions
1149 if (this%iperched /= 0) then
1150 if (this%dis%con%ihc(this%dis%con%jas(icon)) == 0) then
1151 if (n > m) then
1152 if (this%icelltype(n) /= 0) then
1153 if (hn < this%dis%top(n)) hntemp = this%dis%bot(m)
1154 end if
1155 else
1156 if (this%icelltype(m) /= 0) then
1157 if (hm < this%dis%top(m)) hmtemp = this%dis%bot(n)
1158 end if
1159 end if
1160 end if
1161 end if
1162 !
1163 ! -- Calculate flow positive into cell n
1164 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 1068 of file gwf-npf.f90.

1069 ! -- dummy
1070 class(GwfNpfType) :: this
1071 integer(I4B), intent(in) :: n
1072 real(DP), intent(in) :: hn
1073 real(DP), intent(inout) :: thksat
1074 !
1075 ! -- Standard Formulation
1076 if (hn >= this%dis%top(n)) then
1077 thksat = done
1078 else
1079 thksat = (hn - this%dis%bot(n)) / (this%dis%top(n) - this%dis%bot(n))
1080 end if
1081 !
1082 ! -- Newton-Raphson Formulation
1083 if (this%inewton /= 0) then
1084 thksat = squadraticsaturation(this%dis%top(n), this%dis%bot(n), hn, &
1085 this%satomega)
1086 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 2589 of file gwf-npf.f90.

2591 ! -- modules
2592 use tdismodule, only: kstp, kper
2593 ! -- dummy
2594 class(GwfNpfType) :: this
2595 integer(I4B), intent(in) :: icode
2596 integer(I4B), intent(inout) :: ncnvrt
2597 character(len=30), dimension(5), intent(inout) :: nodcnvrt
2598 character(len=3), dimension(5), intent(inout) :: acnvrt
2599 integer(I4B), intent(inout) :: ihdcnv
2600 integer(I4B), intent(in) :: kiter
2601 integer(I4B), intent(in) :: n
2602 ! -- local
2603 integer(I4B) :: l
2604 ! -- formats
2605 character(len=*), parameter :: fmtcnvtn = &
2606 "(1X,/1X,'CELL CONVERSIONS FOR ITER.=',I0, &
2607 &' STEP=',I0,' PERIOD=',I0,' (NODE or LRC)')"
2608 character(len=*), parameter :: fmtnode = "(1X,3X,5(A4, A20))"
2609 !
2610 ! -- Keep track of cell conversions
2611 if (icode > 0) then
2612 ncnvrt = ncnvrt + 1
2613 call this%dis%noder_to_string(n, nodcnvrt(ncnvrt))
2614 if (icode == 1) then
2615 acnvrt(ncnvrt) = 'DRY'
2616 else
2617 acnvrt(ncnvrt) = 'WET'
2618 end if
2619 end if
2620 !
2621 ! -- Print a line if 5 conversions have occurred or if icode indicates that a
2622 ! partial line should be printed
2623 if (ncnvrt == 5 .or. (icode == 0 .and. ncnvrt > 0)) then
2624 if (ihdcnv == 0) write (this%iout, fmtcnvtn) kiter, kstp, kper
2625 ihdcnv = 1
2626 write (this%iout, fmtnode) &
2627 (acnvrt(l), trim(adjustl(nodcnvrt(l))), l=1, ncnvrt)
2628 ncnvrt = 0
2629 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 2423 of file gwf-npf.f90.

2424 ! -- modules
2425 use tdismodule, only: kstp, kper
2427 use constantsmodule, only: linelength
2428 ! -- dummy
2429 class(GwfNpfType) :: this
2430 integer(I4B), intent(in) :: kiter
2431 real(DP), intent(inout), dimension(:) :: hnew
2432 ! -- local
2433 integer(I4B) :: n, m, ii, ihc
2434 real(DP) :: ttop, bbot, thick
2435 integer(I4B) :: ncnvrt, ihdcnv
2436 character(len=30), dimension(5) :: nodcnvrt
2437 character(len=30) :: nodestr
2438 character(len=3), dimension(5) :: acnvrt
2439 character(len=LINELENGTH) :: errmsg
2440 integer(I4B) :: irewet
2441 ! -- formats
2442 character(len=*), parameter :: fmtnct = &
2443 "(1X,/1X,'Negative cell thickness at (layer,row,col)', &
2444 &I4,',',I5,',',I5)"
2445 character(len=*), parameter :: fmttopbot = &
2446 &"(1X,'Top elevation, bottom elevation:',1P,2G13.5)"
2447 character(len=*), parameter :: fmttopbotthk = &
2448 &"(1X,'Top elevation, bottom elevation, thickness:',1P,3G13.5)"
2449 character(len=*), parameter :: fmtdrychd = &
2450 &"(1X,/1X,'CONSTANT-HEAD CELL WENT DRY -- SIMULATION ABORTED')"
2451 character(len=*), parameter :: fmtni = &
2452 &"(1X,'CELLID=',a,' ITERATION=',I0,' TIME STEP=',I0,' STRESS PERIOD=',I0)"
2453 !
2454 ! -- Initialize
2455 ncnvrt = 0
2456 ihdcnv = 0
2457 !
2458 ! -- Convert dry cells to wet
2459 do n = 1, this%dis%nodes
2460 do ii = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
2461 m = this%dis%con%ja(ii)
2462 ihc = this%dis%con%ihc(this%dis%con%jas(ii))
2463 call this%rewet_check(kiter, n, hnew(m), this%ibound(m), ihc, hnew, &
2464 irewet)
2465 if (irewet == 1) then
2466 call this%wdmsg(2, ncnvrt, nodcnvrt, acnvrt, ihdcnv, kiter, n)
2467 end if
2468 end do
2469 end do
2470 !
2471 ! -- Perform drying
2472 do n = 1, this%dis%nodes
2473 !
2474 ! -- cycle if inactive or confined
2475 if (this%ibound(n) == 0) cycle
2476 if (this%icelltype(n) == 0) cycle
2477 !
2478 ! -- check for negative cell thickness
2479 bbot = this%dis%bot(n)
2480 ttop = this%dis%top(n)
2481 if (bbot > ttop) then
2482 write (errmsg, fmtnct) n
2483 call store_error(errmsg)
2484 write (errmsg, fmttopbot) ttop, bbot
2485 call store_error(errmsg)
2486 call store_error_filename(this%input_fname)
2487 end if
2488 !
2489 ! -- Calculate saturated thickness
2490 if (this%icelltype(n) /= 0) then
2491 if (hnew(n) < ttop) ttop = hnew(n)
2492 end if
2493 thick = ttop - bbot
2494 !
2495 ! -- If thick<0 print message, set hnew, and ibound
2496 if (thick <= dzero) then
2497 call this%wdmsg(1, ncnvrt, nodcnvrt, acnvrt, ihdcnv, kiter, n)
2498 hnew(n) = this%hdry
2499 if (this%ibound(n) < 0) then
2500 errmsg = 'CONSTANT-HEAD CELL WENT DRY -- SIMULATION ABORTED'
2501 call store_error(errmsg)
2502 write (errmsg, fmttopbotthk) ttop, bbot, thick
2503 call store_error(errmsg)
2504 call this%dis%noder_to_string(n, nodestr)
2505 write (errmsg, fmtni) trim(adjustl(nodestr)), kiter, kstp, kper
2506 call store_error(errmsg)
2507 call store_error_filename(this%input_fname)
2508 end if
2509 this%ibound(n) = 0
2510 end if
2511 end do
2512 !
2513 ! -- Print remaining cell conversions
2514 call this%wdmsg(0, ncnvrt, nodcnvrt, acnvrt, ihdcnv, kiter, n)
2515 !
2516 ! -- Change ibound from 30000 to 1
2517 do n = 1, this%dis%nodes
2518 if (this%ibound(n) == 30000) this%ibound(n) = 1
2519 end do
Here is the call graph for this function:

◆ source_griddata()

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

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

1855 ! -- modules
1860 ! -- dummy
1861 class(GwfNpftype) :: this
1862 ! -- locals
1863 character(len=LINELENGTH) :: errmsg
1864 type(GwfNpfParamFoundType) :: found
1865 logical, dimension(2) :: afound
1866 integer(I4B), dimension(:), pointer, contiguous :: map
1867 !
1868 ! -- set map to convert user input data into reduced data
1869 map => null()
1870 if (this%dis%nodes < this%dis%nodesuser) map => this%dis%nodeuser
1871 !
1872 ! -- update defaults with idm sourced values
1873 call mem_set_value(this%icelltype, 'ICELLTYPE', this%input_mempath, map, &
1874 found%icelltype)
1875 call mem_set_value(this%k11, 'K', this%input_mempath, map, found%k, &
1876 release=.false.)
1877 call mem_set_value(this%k33, 'K33', this%input_mempath, map, found%k33)
1878 call mem_set_value(this%k22, 'K22', this%input_mempath, map, found%k22)
1879 call mem_set_value(this%wetdry, 'WETDRY', this%input_mempath, map, &
1880 found%wetdry)
1881 call mem_set_value(this%angle1, 'ANGLE1', this%input_mempath, map, &
1882 found%angle1)
1883 call mem_set_value(this%angle2, 'ANGLE2', this%input_mempath, map, &
1884 found%angle2)
1885 call mem_set_value(this%angle3, 'ANGLE3', this%input_mempath, map, &
1886 found%angle3)
1887 !
1888 ! -- ensure ICELLTYPE was found
1889 if (.not. found%icelltype) then
1890 write (errmsg, '(a)') 'Error in GRIDDATA block: ICELLTYPE not found.'
1891 call store_error(errmsg)
1892 end if
1893 !
1894 ! -- ensure K was found
1895 if (.not. found%k) then
1896 write (errmsg, '(a)') 'Error in GRIDDATA block: K not found.'
1897 call store_error(errmsg)
1898 end if
1899 !
1900 ! -- set error if ik33overk set with no k33
1901 if (.not. found%k33 .and. this%ik33overk /= 0) then
1902 write (errmsg, '(a)') 'K33OVERK option specified but K33 not specified.'
1903 call store_error(errmsg)
1904 end if
1905 !
1906 ! -- set error if ik22overk set with no k22
1907 if (.not. found%k22 .and. this%ik22overk /= 0) then
1908 write (errmsg, '(a)') 'K22OVERK option specified but K22 not specified.'
1909 call store_error(errmsg)
1910 end if
1911 !
1912 ! -- handle found side effects
1913 if (found%k33) this%ik33 = 1
1914 if (found%k22) this%ik22 = 1
1915 if (found%wetdry) this%iwetdry = 1
1916 if (found%angle1) this%iangle1 = 1
1917 if (found%angle2) this%iangle2 = 1
1918 if (found%angle3) this%iangle3 = 1
1919 !
1920 ! -- handle not found side effects
1921 if (.not. found%k33) then
1922 call mem_set_value(this%k33, 'K', this%input_mempath, map, afound(1), &
1923 release=.false.)
1924 end if
1925 if (.not. found%k22) then
1926 call mem_set_value(this%k22, 'K', this%input_mempath, map, afound(2), &
1927 release=.false.)
1928 end if
1929 if (.not. found%wetdry) call mem_reallocate(this%wetdry, 1, 'WETDRY', &
1930 trim(this%memoryPath))
1931 if (.not. found%angle1 .and. this%ixt3d == 0) &
1932 call mem_reallocate(this%angle1, 0, 'ANGLE1', trim(this%memoryPath))
1933 if (.not. found%angle2 .and. this%ixt3d == 0) &
1934 call mem_reallocate(this%angle2, 0, 'ANGLE2', trim(this%memoryPath))
1935 if (.not. found%angle3 .and. this%ixt3d == 0) &
1936 call mem_reallocate(this%angle3, 0, 'ANGLE3', trim(this%memoryPath))
1937 !
1938 ! -- cleanup
1939 call memorystore_release('K', this%input_mempath)
1940 !
1941 ! -- log griddata
1942 if (this%iout > 0) then
1943 call this%log_griddata(found)
1944 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 1624 of file gwf-npf.f90.

1625 ! -- modules
1632 ! -- dummy
1633 class(GwfNpftype) :: this
1634 ! -- locals
1635 character(len=LENVARNAME), dimension(3) :: cellavg_method = &
1636 &[character(len=LENVARNAME) :: 'LOGARITHMIC', 'AMT-LMK', 'AMT-HMK']
1637 type(gwfnpfparamfoundtype) :: found
1638 type(CharacterStringType), dimension(:), pointer, contiguous :: tvk6_mempaths
1639 character(len=LINELENGTH) :: tvk6_filename
1640 character(len=LENMEMPATH) :: tvk6_mempath
1641 !
1642 ! -- update defaults with idm sourced values
1643 call mem_set_value(this%iprflow, 'IPRFLOW', this%input_mempath, found%iprflow)
1644 call mem_set_value(this%ipakcb, 'IPAKCB', this%input_mempath, found%ipakcb)
1645 call mem_set_value(this%icellavg, 'CELLAVG', this%input_mempath, &
1646 cellavg_method, found%cellavg)
1647 call mem_set_value(this%ithickstrt, 'ITHICKSTRT', this%input_mempath, &
1648 found%ithickstrt)
1649 call mem_set_value(this%ihighcellsat, 'IHIGHCELLSAT', this%input_mempath, &
1650 found%ihighcellsat)
1651 call mem_set_value(this%iperched, 'IPERCHED', this%input_mempath, &
1652 found%iperched)
1653 call mem_set_value(this%ivarcv, 'IVARCV', this%input_mempath, found%ivarcv)
1654 call mem_set_value(this%idewatcv, 'IDEWATCV', this%input_mempath, &
1655 found%idewatcv)
1656 call mem_set_value(this%ixt3d, 'IXT3D', this%input_mempath, found%ixt3d)
1657 call mem_set_value(this%ixt3drhs, 'IXT3DRHS', this%input_mempath, &
1658 found%ixt3drhs)
1659 call mem_set_value(this%isavspdis, 'ISAVSPDIS', this%input_mempath, &
1660 found%isavspdis)
1661 call mem_set_value(this%isavsat, 'ISAVSAT', this%input_mempath, found%isavsat)
1662 call mem_set_value(this%ik22overk, 'IK22OVERK', this%input_mempath, &
1663 found%ik22overk)
1664 call mem_set_value(this%ik33overk, 'IK33OVERK', this%input_mempath, &
1665 found%ik33overk)
1666 call mem_set_value(this%inewton, 'INEWTON', this%input_mempath, found%inewton)
1667 call mem_set_value(this%satomega, 'SATOMEGA', this%input_mempath, &
1668 found%satomega)
1669 call mem_set_value(this%irewet, 'IREWET', this%input_mempath, found%irewet)
1670 call mem_set_value(this%wetfct, 'WETFCT', this%input_mempath, found%wetfct)
1671 call mem_set_value(this%iwetit, 'IWETIT', this%input_mempath, found%iwetit)
1672 call mem_set_value(this%ihdwet, 'IHDWET', this%input_mempath, found%ihdwet)
1673 !
1674 ! -- save flows option active
1675 if (found%ipakcb) this%ipakcb = -1
1676 !
1677 ! -- xt3d active with rhs
1678 if (found%ixt3d .and. found%ixt3drhs) this%ixt3d = 2
1679 !
1680 ! -- save specific discharge active
1681 if (found%isavspdis) this%icalcspdis = this%isavspdis
1682 !
1683 ! -- no newton specified
1684 if (found%inewton) then
1685 this%inewton = 0
1686 this%iasym = 0
1687 end if
1688 !
1689 ! -- TVK6 subpackage
1690 if (filein_fname(tvk6_filename, 'TVK6_FILENAME', &
1691 this%input_mempath, this%input_fname)) then
1692 call mem_setptr(tvk6_mempaths, 'TVK6_MEMPATH', this%input_mempath)
1693 tvk6_mempath = tvk6_mempaths(1)
1694 this%intvk = 1 ! tvk active
1695 call tvk_cr(this%tvk, this%name_model, tvk6_mempath, this%intvk, this%iout)
1696 end if
1697 !
1698 ! -- verify ALTERNATIVE_CELL_AVERAGING input value is supported
1699 if (found%cellavg) then
1700 if (this%icellavg == 0) then
1701 errmsg = 'Unrecognized input value for ALTERNATIVE_CELL_AVERAGING option.'
1702 call store_error(errmsg)
1703 call store_error_filename(this%input_fname)
1704 end if
1705 end if
1706 !
1707 ! -- log options
1708 if (this%iout > 0) then
1709 call this%log_options(found)
1710 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 1452 of file gwf-npf.f90.

1453 ! -- modules
1455 ! -- dummy
1456 class(GwfNpftype) :: this
1457 integer(I4B), intent(in) :: ncells
1458 integer(I4B), intent(in) :: njas
1459 ! -- local
1460 integer(I4B) :: n
1461 !
1462 ! -- Retain copy of user-specified K arrays
1463 do n = 1, ncells
1464 this%k11input(n) = this%k11(n)
1465 this%k22input(n) = this%k22(n)
1466 this%k33input(n) = this%k33(n)
1467 end do