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

Data Types

type  laktabtype
type  lakinputtype
 input context runtime pointers for LAK More...
type  laktype

Functions/Subroutines

subroutine, public lak_create (packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath)
 Create a new LAK Package and point bndobj to the new package.
subroutine lak_allocate_scalars (this)
 Allocate scalar members.
subroutine lak_allocate_arrays (this)
 Allocate scalar members.
subroutine lak_checkin_deprecated_names (this)
 Alias deprecated LAK variable names to their current storage.
subroutine lak_source_packagedata (this)
 Source PACKAGEDATA block from input context.
subroutine lak_source_connectiondata (this)
 Source CONNECTIONDATA block from input context.
subroutine lak_source_tables (this)
 Source TABLES block from input context.
subroutine laktables_to_vectors (this, laketables)
 Copy the laketables structure data into flattened vectors that are stored in the memory manager.
subroutine lak_source_table (this, ilak, mempath, laketable)
 Source one lake's table from its LAKTAB6 subpackage.
subroutine lak_source_outlets (this)
 Source OUTLETS block from input context.
subroutine lak_source_dimensions (this)
 Source DIMENSIONS block from input context and load static data.
subroutine lak_read_initial_attr (this)
 Read the initial parameters for this package.
subroutine lak_linear_interpolation (this, n, x, y, z, v)
 Perform linear interpolation of two vectors.
subroutine lak_calculate_sarea (this, ilak, stage, sarea)
 Calculate the surface area of a lake at a given stage.
subroutine lak_calculate_warea (this, ilak, stage, warea, hin)
 Calculate the wetted area of a lake at a given stage.
subroutine lak_calculate_conn_warea (this, ilak, iconn, stage, head, wa)
 Calculate the wetted area of a lake connection at a given stage.
subroutine lak_calculate_vol (this, ilak, stage, volume)
 Calculate the volume of a lake at a given stage.
subroutine lak_calculate_conductance (this, ilak, stage, conductance)
 Calculate the total conductance for a lake at a provided stage.
subroutine lak_calculate_cond_head (this, iconn, stage, head, vv)
 Calculate the controlling lake stage or groundwater head used to calculate the conductance for a lake connection from a provided stage and groundwater head.
subroutine lak_calculate_conn_conductance (this, ilak, iconn, stage, head, cond)
 Calculate the conductance for a lake connection at a provided stage and groundwater head.
subroutine lak_calculate_exchange (this, ilak, stage, totflow)
 Calculate the total groundwater-lake flow at a provided stage.
subroutine lak_calculate_conn_exchange (this, ilak, iconn, stage, head, flow, gwfhcof, gwfrhs)
 Calculate the groundwater-lake flow at a provided stage and groundwater head.
subroutine lak_calculate_conn_exchange_deriv (this, ilak, iconn, stage, head, flow, dqds, dqdh)
 Lakebed seepage and its derivatives for a connection (IMPLICIT).
subroutine lak_estimate_conn_exchange (this, iflag, ilak, iconn, idry, stage, head, flow, source, gwfhcof, gwfrhs)
 Calculate the groundwater-lake flow at a provided stage and groundwater head.
subroutine lak_calculate_storagechange (this, ilak, stage, stage0, delt, dvr)
 Calculate the storage change in a lake based on provided stages and a passed delt.
subroutine lak_calculate_rainfall (this, ilak, stage, ra)
 Calculate the rainfall for a lake.
subroutine lak_calculate_runoff (this, ilak, ro)
 Calculate runoff to a lake.
subroutine lak_calculate_inflow (this, ilak, qin)
 Calculate specified inflow to a lake.
subroutine lak_calculate_external (this, ilak, ex)
 Calculate the external flow terms to a lake.
subroutine lak_calculate_withdrawal (this, ilak, avail, wr)
 Calculate the withdrawal from a lake subject to an available volume.
subroutine lak_calculate_evaporation (this, ilak, stage, avail, ev)
 Calculate the evaporation from a lake at a provided stage subject to an available volume.
subroutine lak_calculate_outlet_inflow (this, ilak, outinf)
 Calculate the outlet inflow to a lake.
subroutine lak_calculate_outlet_outflow (this, ilak, stage, avail, outoutf)
 Calculate the outlet outflow from a lake.
subroutine lak_outlet_outflow_rate (this, ilak, stage, qout)
 Total uncapped outlet outflow rate from a lake at a provided stage.
subroutine lak_get_internal_inlet (this, ilak, outinf)
 Get the outlet inflow to a lake from another lake.
subroutine lak_get_internal_outlet (this, ilak, outoutf)
 Get the outlet from a lake to another lake.
subroutine lak_get_external_outlet (this, ilak, outoutf)
 Get the outlet outflow from a lake to an external boundary.
subroutine lak_get_external_mover (this, ilak, outoutf)
 Get the mover outflow from a lake to an external boundary.
subroutine lak_get_internal_mover (this, ilak, outoutf)
 Get the mover outflow from a lake to another lake.
subroutine lak_get_outlet_tomover (this, ilak, outoutf)
 Get the outlet to mover from a lake.
subroutine lak_vol2stage (this, ilak, vol, stage)
 Determine the stage from a provided volume.
integer(i4b) function lak_check_valid (this, itemno)
 Determine if a valid lake or outlet number has been specified.
subroutine lak_set_nonneg_value (this, n, itemno, setting, value_array, label)
 Apply a PERIOD lake setting and require its value be non-negative.
subroutine lak_set_attribute_error (this, ilak, keyword, msg)
 Issue a parameter error for lake ilak.
subroutine lak_source_options (this)
 Source OPTIONS block from input context.
subroutine lak_input_init (this, mempath, naux, noutlets)
 Bind LakInputType pointers.
subroutine lak_input_destroy (this)
 Nullify all LakInputType pointers.
subroutine lak_ar (this)
 Allocate and Read.
subroutine lak_rp (this)
 Read and prepare (stress period data).
subroutine lak_ad (this)
 Add package connection to matrix.
subroutine lak_cf (this)
 Formulate the HCOF and RHS terms.
subroutine lak_fc (this, rhs, ia, idxglo, matrix_sln)
 Copy rhs and hcof into solution rhs and amat.
subroutine lak_fn (this, rhs, ia, idxglo, matrix_sln)
 Fill newton terms.
subroutine lak_nur (this, neqpak, x, xtemp, dx, inewtonur, dxmax, locmax)
 Apply Newton under-relaxation to the lake stage.
subroutine lak_cc (this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
 Final convergence check for package.
subroutine lak_cq (this, x, flowja, iadv)
 Calculate flows.
subroutine lak_ot_package_flows (this, icbcfl, ibudfl)
 Output LAK package flow terms.
subroutine lak_ot_model_flows (this, icbcfl, ibudfl, icbcun, imap)
 Write flows to binary file and/or print flows to budget.
subroutine lak_ot_dv (this, idvsave, idvprint)
 Save LAK-calculated values to binary file.
subroutine lak_ot_bdsummary (this, kstp, kper, iout, ibudfl)
 Write LAK budget to listing file.
subroutine lak_da (this)
 Deallocate objects.
subroutine define_listlabel (this)
 Define the list heading that is written to iout when PRINT_INPUT option is used.
subroutine lak_set_pointers (this, neq, ibound, xnew, xold, flowja)
 Set pointers to model arrays and variables so that a package has access to these things.
subroutine lak_ac (this, moffset, sparse)
 Add the lake rows and columns to the sparse matrix.
subroutine lak_mc (this, moffset, matrix_sln)
 Find the matrix position of each lake row and connection.
logical function lak_obs_supported (this)
 Procedures related to observations (type-bound).
subroutine lak_df_obs (this)
 Store observation type supported by LAK package. Overrides BndTypebnd_df_obs.
subroutine lak_bd_obs (this)
 Calculate observations this time step and call ObsTypeSaveOneSimval for each LakType observation.
subroutine lak_rp_obs (this)
 Process each observation.
subroutine lak_process_obsid (obsrv, dis, inunitobs, iout)
 This procedure is pointed to by ObsDataTypeProcesssIdPtr. It processes the ID string of an observation definition for LAK package observations.
subroutine lak_accumulate_chterm (this, ilak, rrate, chratin, chratout)
 Accumulate constant head terms for budget.
subroutine lak_bound_update (this)
 Store the lake head and connection conductance in the bound array.
subroutine lak_solve (this, update, only_legacy)
 Solve for lake stage.
subroutine lak_solve_single (this, n, iter, maxiter, ncnv, lupdate)
 Advance one lake stage by a single substitution iteration.
subroutine lak_estimate_seepage_single (this, n, ncnv)
 Estimate the lakebed seepage for a single lake.
subroutine lak_bisection (this, n, ibflg, hlak, temporary_stage, dh, residual)
 Lake package bisection method.
subroutine lak_calculate_available (this, n, hlak, avail, ra, ro, qinf, ex, headp)
 Calculate the available volumetric rate for a lake given a passed stage.
subroutine lak_calculate_residual (this, n, hlak, resid, headp)
 Calculate the residual for a lake given a passed stage.
subroutine lak_setup_budobj (this)
 Set up the budget object that stores all the lake flows.
subroutine lak_fill_budobj (this)
 Copy flow terms into thisbudobj.
subroutine lak_setup_tableobj (this)
 Set up the table object that is used to write the lak stage data.
subroutine lak_activate_density (this)
 Activate addition of density terms.
subroutine lak_activate_viscosity (this)
 Activate viscosity terms.
subroutine lak_calculate_density_exchange (this, iconn, stage, head, cond, botl, flow, gwfhcof, gwfrhs)
 Calculate the groundwater-lake density exchange terms.

Variables

character(len=lenftype) ftype = 'LAK'
character(len=lenpackagename) text = ' LAK'

Function/Subroutine Documentation

◆ define_listlabel()

subroutine lakmodule::define_listlabel ( class(laktype), intent(inout) this)
private

Definition at line 4652 of file gwf-lak.f90.

4653 ! -- modules
4654 class(LakType), intent(inout) :: this
4655 !
4656 ! -- create the header list label
4657 this%listlabel = trim(this%filtyp)//' NO.'
4658 if (this%dis%ndim == 3) then
4659 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
4660 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'ROW'
4661 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'COL'
4662 elseif (this%dis%ndim == 2) then
4663 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
4664 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'CELL2D'
4665 else
4666 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'NODE'
4667 end if
4668 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'STRESS RATE'
4669 if (this%inamedbound == 1) then
4670 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'BOUNDARY NAME'
4671 end if

◆ lak_ac()

subroutine lakmodule::lak_ac ( class(laktype), intent(inout) this,
integer(i4b), intent(in) moffset,
type(sparsematrix), intent(inout) sparse )
private

Implicit formulation only. Each lake adds one equation (row and column) to the groundwater flow matrix: a diagonal entry, plus a symmetric off-diagonal pair (lake-to-cell and cell-to-lake) for every lake-cell connection.

Definition at line 4719 of file gwf-lak.f90.

4720 use sparsemodule, only: sparsematrix
4721 ! -- dummy
4722 class(LakType), intent(inout) :: this
4723 integer(I4B), intent(in) :: moffset
4724 type(sparsematrix), intent(inout) :: sparse
4725 ! -- local
4726 integer(I4B) :: j, n
4727 integer(I4B) :: jj
4728 integer(I4B) :: jglo
4729 integer(I4B) :: nglo
4730 !
4731 ! -- the default formulation adds no rows to the matrix
4732 if (this%iimplicit == 0) return
4733 !
4734 ! -- add a row for each lake and its connections to the cells
4735 do n = 1, this%nlakes
4736 nglo = moffset + this%dis%nodes + this%ioffset + n
4737 call sparse%addconnection(nglo, nglo, 1)
4738 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
4739 jj = this%gwfconn(j)
4740 jglo = jj + moffset
4741 call sparse%addconnection(nglo, jglo, 1)
4742 call sparse%addconnection(jglo, nglo, 1)
4743 end do
4744 end do

◆ lak_accumulate_chterm()

subroutine lakmodule::lak_accumulate_chterm ( class(laktype) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) rrate,
real(dp), intent(inout) chratin,
real(dp), intent(inout) chratout )
private

Definition at line 5316 of file gwf-lak.f90.

5317 ! -- dummy
5318 class(LakType) :: this
5319 integer(I4B), intent(in) :: ilak
5320 real(DP), intent(in) :: rrate
5321 real(DP), intent(inout) :: chratin
5322 real(DP), intent(inout) :: chratout
5323 ! -- locals
5324 real(DP) :: q
5325 !
5326 ! code
5327 if (this%iboundpak(ilak) < 0) then
5328 q = -rrate
5329 this%chterm(ilak) = this%chterm(ilak) + q
5330 !
5331 ! -- See if flow is into lake or out of lake.
5332 if (q < dzero) then
5333 !
5334 ! -- Flow is out of lake subtract rate from ratout.
5335 chratout = chratout - q
5336 else
5337 !
5338 ! -- Flow is into lake; add rate to ratin.
5339 chratin = chratin + q
5340 end if
5341 end if

◆ lak_activate_density()

subroutine lakmodule::lak_activate_density ( class(laktype), intent(inout) this)
private

Definition at line 6529 of file gwf-lak.f90.

6530 ! -- dummy
6531 class(LakType), intent(inout) :: this
6532 ! -- local
6533 integer(I4B) :: i, j
6534 !
6535 ! -- the IMPLICIT formulation does not include the density terms yet
6536 if (this%iimplicit /= 0) then
6537 write (errmsg, '(a)') &
6538 'The IMPLICIT option cannot be used with the BUY package until the &
6539 &implicit formulation includes density terms. Remove the IMPLICIT &
6540 &option from LAK package '//trim(this%packName)//' to simulate &
6541 &density.'
6542 call store_error(errmsg)
6543 call store_error_filename(this%input_fname)
6544 end if
6545 !
6546 ! -- Set idense and reallocate denseterms to be of size MAXBOUND
6547 this%idense = 1
6548 call mem_reallocate(this%denseterms, 3, this%MAXBOUND, 'DENSETERMS', &
6549 this%memoryPath)
6550 do i = 1, this%maxbound
6551 do j = 1, 3
6552 this%denseterms(j, i) = dzero
6553 end do
6554 end do
6555 write (this%iout, '(/1x,a)') 'DENSITY TERMS HAVE BEEN ACTIVATED FOR LAKE &
6556 &PACKAGE: '//trim(adjustl(this%packName))

◆ lak_activate_viscosity()

subroutine lakmodule::lak_activate_viscosity ( class(laktype), intent(inout) this)
private

Method to activate addition of viscosity terms for a LAK package reach.

Parameters
[in,out]thisLakType object

Definition at line 6563 of file gwf-lak.f90.

6564 ! -- modules
6566 ! -- dummy variables
6567 class(LakType), intent(inout) :: this !< LakType object
6568 ! -- local variables
6569 integer(I4B) :: i
6570 integer(I4B) :: j
6571 !
6572 ! -- Set ivsc and reallocate viscratios to be of size MAXBOUND
6573 this%ivsc = 1
6574 call mem_reallocate(this%viscratios, 2, this%MAXBOUND, 'VISCRATIOS', &
6575 this%memoryPath)
6576 do i = 1, this%maxbound
6577 do j = 1, 2
6578 this%viscratios(j, i) = done
6579 end do
6580 end do
6581 write (this%iout, '(/1x,a)') 'VISCOSITY HAS BEEN ACTIVATED FOR LAK &
6582 &PACKAGE: '//trim(adjustl(this%packName))

◆ lak_ad()

subroutine lakmodule::lak_ad ( class(laktype) this)
private

Definition at line 3565 of file gwf-lak.f90.

3566 ! -- modules
3568 ! -- dummy
3569 class(LakType) :: this
3570 ! -- local
3571 integer(I4B) :: n
3572 integer(I4B) :: j
3573 integer(I4B) :: iaux
3574 integer(I4B) :: itemno
3575 !
3576 ! -- sync PACKAGEDATA AUX TS and advance observations;
3577 ! sync_period_auxvar (inside bnd_ad) handles PERIOD AUXILIARY TS
3578 call this%BndExtType%bnd_ad()
3579 !
3580 ! -- re-sync static OUTLETS values (invert, width, rough, slope) linked
3581 ! to a time series, skipping any field a PERIOD-block setting has
3582 ! already overridden for this outlet -- that override must persist
3583 ! until a later PERIOD block changes it
3584 if (this%ts_active .and. this%noutlets > 0) then
3585 do n = 1, size(this%input%outletno)
3586 itemno = this%input%outletno(n)
3587 if (itemno < 1 .or. itemno > this%noutlets) cycle
3588 if (.not. this%outlet_invert_set(itemno) .and. &
3589 this%input%invert_tslink(n) /= 0) &
3590 this%outinvert(itemno) = this%input%outlets_invert(n)
3591 if (.not. this%outlet_width_set(itemno) .and. &
3592 this%input%width_tslink(n) /= 0) &
3593 this%outwidth(itemno) = this%input%outlets_width(n)
3594 if (.not. this%outlet_rough_set(itemno) .and. &
3595 this%input%rough_tslink(n) /= 0) &
3596 this%outrough(itemno) = this%input%outlets_rough(n)
3597 if (.not. this%outlet_slope_set(itemno) .and. &
3598 this%input%slope_tslink(n) /= 0) &
3599 this%outslope(itemno) = this%input%outlets_slope(n)
3600 end do
3601 end if
3602 !
3603 ! -- update auxiliary variables
3604 if (this%naux > 0) then
3605 do n = 1, this%nlakes
3606 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3607 do iaux = 1, this%naux
3608 if (this%noupdateauxvar(iaux) /= 0) cycle
3609 this%auxvar(iaux, j) = this%featureauxvar(iaux, n)
3610 end do
3611 end do
3612 end do
3613 end if
3614 !
3615 ! -- Update or restore state
3616 if (ifailedstepretry == 0) then
3617 !
3618 ! -- copy xnew into xold and set xnewpak to stage for
3619 ! constant stage lakes
3620 do n = 1, this%nlakes
3621 this%xoldpak(n) = this%xnewpak(n)
3622 this%stageiter(n) = this%xnewpak(n)
3623 if (this%iboundpak(n) < 0) then
3624 this%xnewpak(n) = this%stage(n)
3625 end if
3626 this%seep0(n) = dzero
3627 end do
3628 else
3629 !
3630 ! -- copy xold back into xnew as this is a
3631 ! retry of this time step
3632 do n = 1, this%nlakes
3633 this%xnewpak(n) = this%xoldpak(n)
3634 this%stageiter(n) = this%xnewpak(n)
3635 if (this%iboundpak(n) < 0) then
3636 this%xnewpak(n) = this%stage(n)
3637 end if
3638 this%seep0(n) = dzero
3639 end do
3640 end if
3641 !
3642 ! -- pakmvrobj ad
3643 if (this%imover == 1) then
3644 call this%pakmvrobj%ad()
3645 end if
This module contains simulation variables.
integer(i4b) ifailedstepretry
current retry for this time step

◆ lak_allocate_arrays()

subroutine lakmodule::lak_allocate_arrays ( class(laktype), intent(inout) this)
private

Definition at line 575 of file gwf-lak.f90.

576 ! -- modules
577 ! -- dummy
578 class(LakType), intent(inout) :: this
579 ! -- local
580 integer(I4B) :: i
581 !
582 ! -- call standard BndExtType allocate arrays
583 call this%BndExtType%allocate_arrays()
584 !
585 ! -- allocate featureauxvar and set pkg_ifno/pkg_auxvar input context pointers
586 call this%BndExtType%allocate_featureauxvar()
587 !
588 ! -- allocate character array for budget text
589 allocate (this%clakbudget(this%bditems))
590 !
591 !-- fill clakbudget
592 this%clakbudget(1) = ' GWF'
593 this%clakbudget(2) = ' RAINFALL'
594 this%clakbudget(3) = ' EVAPORATION'
595 this%clakbudget(4) = ' RUNOFF'
596 this%clakbudget(5) = ' EXT-INFLOW'
597 this%clakbudget(6) = ' WITHDRAWAL'
598 this%clakbudget(7) = ' EXT-OUTFLOW'
599 this%clakbudget(8) = ' STORAGE'
600 this%clakbudget(9) = ' CONSTANT'
601 this%clakbudget(10) = ' FROM-MVR'
602 this%clakbudget(11) = ' TO-MVR'
603 !
604 ! -- allocate and initialize dbuff
605 if (this%istageout > 0) then
606 call mem_allocate(this%dbuff, this%nlakes, 'DBUFF', this%memoryPath)
607 do i = 1, this%nlakes
608 this%dbuff(i) = dzero
609 end do
610 else
611 call mem_allocate(this%dbuff, 0, 'DBUFF', this%memoryPath)
612 end if
613 !
614 ! -- allocate character array for budget text
615 allocate (this%cauxcbc(this%cbcauxitems))
616 !
617 ! -- allocate and initialize qauxcbc
618 call mem_allocate(this%qauxcbc, this%cbcauxitems, 'QAUXCBC', this%memoryPath)
619 do i = 1, this%cbcauxitems
620 this%qauxcbc(i) = dzero
621 end do
622 !
623 ! -- allocate qleak and qsto
624 call mem_allocate(this%qleak, this%maxbound, 'QLEAK', this%memoryPath)
625 do i = 1, this%maxbound
626 this%qleak(i) = dzero
627 end do
628 ! -- holdconn is only used by the implicit legacy-switch detector; allocate it at
629 ! size 0 otherwise so legacy LAK runs do not pay the maxbound memory cost
630 if (this%iimplicit /= 0) then
631 call mem_allocate(this%holdconn, this%maxbound, 'HOLDCONN', this%memoryPath)
632 do i = 1, this%maxbound
633 this%holdconn(i) = dzero
634 end do
635 else
636 call mem_allocate(this%holdconn, 0, 'HOLDCONN', this%memoryPath)
637 end if
638 call mem_allocate(this%qsto, this%nlakes, 'QSTO', this%memoryPath)
639 do i = 1, this%nlakes
640 this%qsto(i) = dzero
641 end do
642 !
643 ! -- allocate denseterms to size 0
644 call mem_allocate(this%denseterms, 3, 0, 'DENSETERMS', this%memoryPath)
645 !
646 ! -- allocate viscratios to size 0
647 call mem_allocate(this%viscratios, 2, 0, 'VISCRATIOS', this%memoryPath)

◆ lak_allocate_scalars()

subroutine lakmodule::lak_allocate_scalars ( class(laktype), intent(inout) this)
private

Definition at line 511 of file gwf-lak.f90.

512 ! -- dummy
513 class(LakType), intent(inout) :: this
514 !
515 ! -- call standard BndExtType allocate scalars
516 call this%BndExtType%allocate_scalars()
517 !
518 ! -- allocate the object and assign values to object variables
519 call mem_allocate(this%iprhed, 'IPRHED', this%memoryPath)
520 call mem_allocate(this%istageout, 'ISTAGEOUT', this%memoryPath)
521 call mem_allocate(this%ibudgetout, 'IBUDGETOUT', this%memoryPath)
522 call mem_allocate(this%ibudcsv, 'IBUDCSV', this%memoryPath)
523 call mem_allocate(this%ipakcsv, 'IPAKCSV', this%memoryPath)
524 call mem_allocate(this%nlakes, 'NLAKES', this%memoryPath)
525 call mem_allocate(this%noutlets, 'NOUTLETS', this%memoryPath)
526 call mem_allocate(this%ntables, 'NTABLES', this%memoryPath)
527 call mem_allocate(this%convlength, 'CONVLENGTH', this%memoryPath)
528 call mem_allocate(this%convtime, 'CONVTIME', this%memoryPath)
529 call mem_allocate(this%outdmax, 'OUTDMAX', this%memoryPath)
530 call mem_allocate(this%igwhcopt, 'IGWHCOPT', this%memoryPath)
531 call mem_allocate(this%iconvchk, 'ICONVCHK', this%memoryPath)
532 call mem_allocate(this%maxlakit, 'MAXLAKIT', this%memoryPath)
533 call mem_allocate(this%surfdep, 'SURFDEP', this%memoryPath)
534 call mem_allocate(this%dmaxchg, 'DMAXCHG', this%memoryPath)
535 call mem_allocate(this%delh, 'DELH', this%memoryPath)
536 call mem_allocate(this%check_attr, 'CHECK_ATTR', this%memoryPath)
537 call mem_allocate(this%iimplicit, 'IIMPLICIT', this%memoryPath)
538 call mem_allocate(this%iforceleg, 'IFORCELEG', this%memoryPath)
539 call mem_allocate(this%iforceleglak, 'IFORCELEGLAK', this%memoryPath)
540 call mem_allocate(this%moffset, 'MOFFSET', this%memoryPath)
541 call mem_allocate(this%bditems, 'BDITEMS', this%memoryPath)
542 call mem_allocate(this%cbcauxitems, 'CBCAUXITEMS', this%memoryPath)
543 call mem_allocate(this%idense, 'IDENSE', this%memoryPath)
544 !
545 ! -- Set values
546 this%iprhed = 0
547 this%istageout = 0
548 this%ibudgetout = 0
549 this%ibudcsv = 0
550 this%ipakcsv = 0
551 this%nlakes = 0
552 this%noutlets = 0
553 this%ntables = 0
554 this%convlength = done
555 this%convtime = done
556 this%outdmax = dzero
557 this%igwhcopt = 0
558 this%iconvchk = 1
559 this%maxlakit = maxadpit
560 this%surfdep = dzero
561 this%dmaxchg = dem5
562 this%delh = dp999 * this%dmaxchg
563 this%iimplicit = 0
564 this%iforceleg = 0
565 this%iforceleglak = 0
566 this%moffset = 0
567 this%bditems = 11
568 this%cbcauxitems = 1
569 this%idense = 0
570 this%ivsc = 0

◆ lak_ar()

subroutine lakmodule::lak_ar ( class(laktype), intent(inout) this)
private

Create new LAK package and point bndobj to the new package

Definition at line 3283 of file gwf-lak.f90.

3284 ! -- modules
3285 use constantsmodule, only: mnormal
3287 ! -- dummy
3288 class(LakType), intent(inout) :: this
3289 ! -- formats
3290 character(len=*), parameter :: fmtlakbin = &
3291 "(4x, 'LAK ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', &
3292 &a, /4x, 'OPENED ON UNIT: ', I0)"
3293 !
3294 ! -- open the deferred PACKAGE_CONVERGENCE file now that all options have
3295 ! been read. lak_cc does not write package convergence for the implicit
3296 ! formulation, because the lake stage is part of the solver (IMS)
3297 ! convergence check. With the IMPLICIT option the file is therefore left
3298 ! unopened (ipakcsv stays 0) and a warning is issued instead.
3299 if (allocated(this%pakcsvfile)) then
3300 if (this%iimplicit /= 0) then
3301 write (warnmsg, '(a)') &
3302 'PACKAGE_CONVERGENCE output file "'//trim(this%pakcsvfile)// &
3303 '" is not written when the IMPLICIT option is active; the lake '// &
3304 'stage is part of the solver (IMS) convergence check.'
3305 call store_warning(warnmsg)
3306 else
3307 this%ipakcsv = getunit()
3308 call openfile(this%ipakcsv, this%iout, this%pakcsvfile, 'CSV', &
3309 filstat_opt='REPLACE', mode_opt=mnormal)
3310 write (this%iout, fmtlakbin) 'PACKAGE_CONVERGENCE', &
3311 trim(this%pakcsvfile), this%ipakcsv
3312 end if
3313 deallocate (this%pakcsvfile)
3314 end if
3315 !
3316 call this%obs%obs_ar()
3317 !
3318 ! -- Allocate arrays in LAK and in package superclass
3319 call this%lak_allocate_arrays()
3320 !
3321 ! -- read optional initial package parameters
3322 call this%read_initial_attr()
3323 !
3324 ! -- bind input context persistent pointers
3325 call this%input%init(this%input_mempath, this%naux, this%noutlets)
3326 if (this%noutlets > 0) then
3327 if (.not. (associated(this%input%invert_tslink) .and. &
3328 associated(this%input%width_tslink) .and. &
3329 associated(this%input%rough_tslink) .and. &
3330 associated(this%input%slope_tslink))) then
3331 call store_error('Time series links for OUTLETS not found in input.')
3332 call store_error_filename(this%input_fname)
3333 end if
3334 end if
3335 !
3336 ! -- setup pakmvrobj
3337 if (this%imover /= 0) then
3338 allocate (this%pakmvrobj)
3339 call this%pakmvrobj%ar(this%noutlets, this%nlakes, this%memoryPath)
3340 end if
This module contains simulation constants.
Definition Constants.f90:9
@ mnormal
normal output mode
integer(i4b) function, public getunit()
Get a free unit number.
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
Here is the call graph for this function:

◆ lak_bd_obs()

subroutine lakmodule::lak_bd_obs ( class(laktype) this)
private

Definition at line 4939 of file gwf-lak.f90.

4940 ! -- dummy
4941 class(LakType) :: this
4942 ! -- local
4943 integer(I4B) :: i
4944 integer(I4B) :: igwfnode
4945 integer(I4B) :: j
4946 integer(I4B) :: jj
4947 integer(I4B) :: n
4948 real(DP) :: hgwf
4949 real(DP) :: hlak
4950 real(DP) :: v
4951 real(DP) :: v2
4952 type(ObserveType), pointer :: obsrv => null()
4953 !
4954 ! Write simulated values for all LAK observations
4955 if (this%obs%npakobs > 0) then
4956 call this%obs%obs_bd_clear()
4957 do i = 1, this%obs%npakobs
4958 obsrv => this%obs%pakobs(i)%obsrv
4959 do j = 1, obsrv%indxbnds_count
4960 v = dnodata
4961 jj = obsrv%indxbnds(j)
4962 select case (obsrv%ObsTypeId)
4963 case ('STAGE')
4964 if (this%iboundpak(jj) /= 0) then
4965 v = this%xnewpak(jj)
4966 end if
4967 case ('EXT-INFLOW')
4968 if (this%iboundpak(jj) /= 0) then
4969 call this%lak_calculate_inflow(jj, v)
4970 end if
4971 case ('OUTLET-INFLOW')
4972 if (this%iboundpak(jj) /= 0) then
4973 call this%lak_calculate_outlet_inflow(jj, v)
4974 end if
4975 case ('INFLOW')
4976 if (this%iboundpak(jj) /= 0) then
4977 call this%lak_calculate_inflow(jj, v)
4978 call this%lak_calculate_outlet_inflow(jj, v2)
4979 v = v + v2
4980 end if
4981 case ('FROM-MVR')
4982 if (this%iboundpak(jj) /= 0) then
4983 if (this%imover == 1) then
4984 v = this%pakmvrobj%get_qfrommvr(jj)
4985 end if
4986 end if
4987 case ('RAINFALL')
4988 if (this%iboundpak(jj) /= 0) then
4989 v = this%precip(jj)
4990 end if
4991 case ('RUNOFF')
4992 if (this%iboundpak(jj) /= 0) then
4993 v = this%runoff(jj)
4994 end if
4995 case ('LAK')
4996 n = this%imap(jj)
4997 if (this%iboundpak(n) /= 0) then
4998 igwfnode = this%gwfconn(jj)
4999 hgwf = this%xnew(igwfnode)
5000 if (this%hcof(jj) /= dzero) then
5001 v = -(this%hcof(jj) * (this%xnewpak(n) - hgwf))
5002 else
5003 v = -this%rhs(jj)
5004 end if
5005 end if
5006 case ('EVAPORATION')
5007 if (this%iboundpak(jj) /= 0) then
5008 v = this%evap(jj)
5009 end if
5010 case ('WITHDRAWAL')
5011 if (this%iboundpak(jj) /= 0) then
5012 v = this%withr(jj)
5013 end if
5014 case ('EXT-OUTFLOW')
5015 n = this%lakein(jj)
5016 if (this%iboundpak(n) /= 0) then
5017 if (this%lakeout(jj) == 0) then
5018 v = this%simoutrate(jj)
5019 if (v < dzero) then
5020 if (this%imover == 1) then
5021 v = v + this%pakmvrobj%get_qtomvr(jj)
5022 end if
5023 end if
5024 end if
5025 end if
5026 case ('TO-MVR')
5027 n = this%lakein(jj)
5028 if (this%iboundpak(n) /= 0) then
5029 if (this%imover == 1) then
5030 v = this%pakmvrobj%get_qtomvr(jj)
5031 if (v > dzero) then
5032 v = -v
5033 end if
5034 end if
5035 end if
5036 case ('STORAGE')
5037 if (this%iboundpak(jj) /= 0) then
5038 v = this%qsto(jj)
5039 end if
5040 case ('CONSTANT')
5041 if (this%iboundpak(jj) /= 0) then
5042 v = this%chterm(jj)
5043 end if
5044 case ('OUTLET')
5045 n = this%lakein(jj)
5046 if (this%iboundpak(n) /= 0) then
5047 v = this%simoutrate(jj)
5048 end if
5049 case ('VOLUME')
5050 if (this%iboundpak(jj) /= 0) then
5051 call this%lak_calculate_vol(jj, this%xnewpak(jj), v)
5052 end if
5053 case ('SURFACE-AREA')
5054 if (this%iboundpak(jj) /= 0) then
5055 hlak = this%xnewpak(jj)
5056 call this%lak_calculate_sarea(jj, hlak, v)
5057 end if
5058 case ('WETTED-AREA')
5059 n = this%imap(jj)
5060 if (this%iboundpak(n) /= 0) then
5061 hlak = this%xnewpak(n)
5062 igwfnode = this%gwfconn(jj)
5063 hgwf = this%xnew(igwfnode)
5064 call this%lak_calculate_conn_warea(n, jj, hlak, hgwf, v)
5065 end if
5066 case ('CONDUCTANCE')
5067 n = this%imap(jj)
5068 if (this%iboundpak(n) /= 0) then
5069 hlak = this%xnewpak(n)
5070 igwfnode = this%gwfconn(jj)
5071 hgwf = this%xnew(igwfnode)
5072 call this%lak_calculate_conn_conductance(n, jj, hlak, hgwf, v)
5073 end if
5074 case default
5075 errmsg = 'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
5076 call store_error(errmsg)
5077 end select
5078 call this%obs%SaveOneSimval(obsrv, v)
5079 end do
5080 end do
5081 !
5082 ! -- write summary of error messages
5083 if (count_errors() > 0) then
5084 call store_error_filename(this%input_fname)
5085 end if
5086 end if

◆ lak_bisection()

subroutine lakmodule::lak_bisection ( class(laktype), intent(inout) this,
integer(i4b), intent(in) n,
integer(i4b), intent(inout) ibflg,
real(dp), intent(in) hlak,
real(dp), intent(inout) temporary_stage,
real(dp), intent(inout) dh,
real(dp), intent(inout) residual )
private

Use bisection method to find lake stage that reduces the residual

Parameters
[in]nlake number
[in,out]ibflgbisection flag
[in]hlaklake stage
[in,out]temporary_stagetemporary lake stage
[in,out]dhlake stage change
[in,out]residuallake residual

Definition at line 5833 of file gwf-lak.f90.

5834 ! -- dummy
5835 class(LakType), intent(inout) :: this
5836 integer(I4B), intent(in) :: n !< lake number
5837 integer(I4B), intent(inout) :: ibflg !< bisection flag
5838 real(DP), intent(in) :: hlak !< lake stage
5839 real(DP), intent(inout) :: temporary_stage !< temporary lake stage
5840 real(DP), intent(inout) :: dh !< lake stage change
5841 real(DP), intent(inout) :: residual !< lake residual
5842 ! -- local
5843 integer(I4B) :: i
5844 real(DP) :: temporary_stage0
5845 real(DP) :: residuala
5846 real(DP) :: endpoint1
5847 real(DP) :: endpoint2
5848 ! -- code
5849 ibflg = 1
5850 temporary_stage0 = hlak
5851 endpoint1 = this%en1(n)
5852 endpoint2 = this%en2(n)
5853 call this%lak_calculate_residual(n, temporary_stage, residuala)
5854 if (hlak > endpoint1 .and. hlak < endpoint2) then
5855 endpoint2 = hlak
5856 end if
5857 do i = 1, this%maxlakit
5858 temporary_stage = dhalf * (endpoint1 + endpoint2)
5859 call this%lak_calculate_residual(n, temporary_stage, residual)
5860 if (abs(residual) == dzero .or. &
5861 abs(temporary_stage0 - temporary_stage) < this%dmaxchg) then
5862 exit
5863 end if
5864 call this%lak_calculate_residual(n, endpoint1, residuala)
5865 ! -- change end points
5866 ! -- root is between temporary_stage and endpoint2
5867 if (sign(done, residuala) == sign(done, residual)) then
5868 endpoint1 = temporary_stage
5869 ! -- root is between endpoint1 and temporary_stage
5870 else
5871 endpoint2 = temporary_stage
5872 end if
5873 temporary_stage0 = temporary_stage
5874 end do
5875 dh = hlak - temporary_stage

◆ lak_bound_update()

subroutine lakmodule::lak_bound_update ( class(laktype), intent(inout) this)
private

Definition at line 5346 of file gwf-lak.f90.

5347 ! -- dummy
5348 class(LakType), intent(inout) :: this
5349 ! -- local
5350 integer(I4B) :: j, n, node
5351 real(DP) :: hlak, head, clak
5352 !
5353 ! -- Return if no lak lakes
5354 if (this%nbound == 0) return
5355 !
5356 ! -- Calculate hcof and rhs for each lak entry
5357 do n = 1, this%nlakes
5358 hlak = this%xnewpak(n)
5359 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5360 node = this%gwfconn(j)
5361 head = this%xnew(node)
5362 call this%lak_calculate_conn_conductance(n, j, hlak, head, clak)
5363 this%bound(1, j) = hlak
5364 this%bound(2, j) = clak
5365 end do
5366 end do

◆ lak_calculate_available()

subroutine lakmodule::lak_calculate_available ( class(laktype), intent(inout) this,
integer(i4b), intent(in) n,
real(dp), intent(in) hlak,
real(dp), intent(inout) avail,
real(dp), intent(inout) ra,
real(dp), intent(inout) ro,
real(dp), intent(inout) qinf,
real(dp), intent(inout) ex,
real(dp), intent(in), optional headp )
private

Definition at line 5881 of file gwf-lak.f90.

5883 ! -- modules
5884 use tdismodule, only: delt
5885 ! -- dummy
5886 class(LakType), intent(inout) :: this
5887 integer(I4B), intent(in) :: n
5888 real(DP), intent(in) :: hlak
5889 real(DP), intent(inout) :: avail
5890 real(DP), intent(inout) :: ra
5891 real(DP), intent(inout) :: ro
5892 real(DP), intent(inout) :: qinf
5893 real(DP), intent(inout) :: ex
5894 real(DP), intent(in), optional :: headp
5895 ! -- local
5896 integer(I4B) :: j
5897 integer(I4B) :: idry
5898 integer(I4B) :: igwfnode
5899 real(DP) :: hp
5900 real(DP) :: head
5901 real(DP) :: qlakgw
5902 real(DP) :: v0
5903 !
5904 ! -- set hp
5905 if (present(headp)) then
5906 hp = headp
5907 else
5908 hp = dzero
5909 end if
5910 !
5911 ! -- initialize
5912 avail = dzero
5913 !
5914 ! -- calculate the aquifer sources to the lake
5915 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5916 igwfnode = this%gwfconn(j)
5917 if (this%ibound(igwfnode) == 0) cycle
5918 head = this%xnew(igwfnode) + hp
5919 call this%lak_estimate_conn_exchange(1, n, j, idry, hlak, head, qlakgw, &
5920 avail)
5921 end do
5922 !
5923 ! -- add rainfall
5924 call this%lak_calculate_rainfall(n, hlak, ra)
5925 avail = avail + ra
5926 !
5927 ! -- calculate runoff
5928 call this%lak_calculate_runoff(n, ro)
5929 avail = avail + ro
5930 !
5931 ! -- calculate inflow
5932 call this%lak_calculate_inflow(n, qinf)
5933 avail = avail + qinf
5934 !
5935 ! -- calculate external flow terms
5936 call this%lak_calculate_external(n, ex)
5937 avail = avail + ex
5938 !
5939 ! -- calculate volume available in storage
5940 call this%lak_calculate_vol(n, this%xoldpak(n), v0)
5941 avail = avail + v0 / delt
real(dp), pointer, public delt
length of the current time step
Definition tdis.f90:32

◆ lak_calculate_cond_head()

subroutine lakmodule::lak_calculate_cond_head ( class(laktype), intent(inout) this,
integer(i4b), intent(in) iconn,
real(dp), intent(in) stage,
real(dp), intent(in) head,
real(dp), intent(inout) vv )
private

Definition at line 2230 of file gwf-lak.f90.

2231 ! -- dummy
2232 class(LakType), intent(inout) :: this
2233 integer(I4B), intent(in) :: iconn
2234 real(DP), intent(in) :: stage
2235 real(DP), intent(in) :: head
2236 real(DP), intent(inout) :: vv
2237 ! -- local
2238 real(DP) :: ss
2239 real(DP) :: hh
2240 real(DP) :: topl
2241 real(DP) :: botl
2242 !
2243 topl = this%telev(iconn)
2244 botl = this%belev(iconn)
2245 ss = min(stage, topl)
2246 hh = min(head, topl)
2247 if (this%igwhcopt > 0) then
2248 vv = hh
2249 else if (this%inewton > 0) then
2250 vv = max(ss, hh)
2251 else
2252 vv = dhalf * (ss + hh)
2253 end if

◆ lak_calculate_conductance()

subroutine lakmodule::lak_calculate_conductance ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) conductance )
private

Definition at line 2209 of file gwf-lak.f90.

2210 ! -- dummy
2211 class(LakType), intent(inout) :: this
2212 integer(I4B), intent(in) :: ilak
2213 real(DP), intent(in) :: stage
2214 real(DP), intent(inout) :: conductance
2215 ! -- local
2216 integer(I4B) :: i
2217 real(DP) :: c
2218 !
2219 conductance = dzero
2220 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2221 call this%lak_calculate_conn_conductance(ilak, i, stage, stage, c)
2222 conductance = conductance + c
2223 end do

◆ lak_calculate_conn_conductance()

subroutine lakmodule::lak_calculate_conn_conductance ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
integer(i4b), intent(in) iconn,
real(dp), intent(in) stage,
real(dp), intent(in) head,
real(dp), intent(inout) cond )
private

Definition at line 2259 of file gwf-lak.f90.

2260 ! -- dummy
2261 class(LakType), intent(inout) :: this
2262 integer(I4B), intent(in) :: ilak
2263 integer(I4B), intent(in) :: iconn
2264 real(DP), intent(in) :: stage
2265 real(DP), intent(in) :: head
2266 real(DP), intent(inout) :: cond
2267 ! -- local
2268 integer(I4B) :: node
2269 !real(DP) :: ss
2270 !real(DP) :: hh
2271 real(DP) :: vv
2272 real(DP) :: topl
2273 real(DP) :: botl
2274 real(DP) :: sat
2275 real(DP) :: wa
2276 real(DP) :: vscratio
2277 !
2278 cond = dzero
2279 vscratio = done
2280 topl = this%telev(iconn)
2281 botl = this%belev(iconn)
2282 call this%lak_calculate_cond_head(iconn, stage, head, vv)
2283 sat = squadraticsaturation(topl, botl, vv)
2284 ! vertical connection
2285 ! use full saturated conductance if top and bottom of the lake connection
2286 ! are equal
2287 if (this%ictype(iconn) == 0) then
2288 if (abs(topl - botl) < dprec) then
2289 sat = done
2290 end if
2291 ! horizontal connection
2292 ! use full saturated conductance if the connected cell is not convertible
2293 else if (this%ictype(iconn) == 1) then
2294 node = this%gwfconn(iconn)
2295 if (this%icelltype(node) == 0) then
2296 sat = done
2297 end if
2298 ! embedded connection
2299 else if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
2300 node = this%gwfconn(iconn)
2301 if (this%icelltype(node) == 0) then
2302 vv = this%telev(iconn)
2303 call this%lak_calculate_conn_warea(ilak, iconn, vv, vv, wa)
2304 else
2305 call this%lak_calculate_conn_warea(ilak, iconn, stage, head, wa)
2306 end if
2307 sat = wa
2308 end if
2309 !
2310 ! -- account for viscosity effects (if vsc active)
2311 if (this%ivsc == 1) then
2312 ! flow from lake to aquifer
2313 if (stage > head) then
2314 vscratio = this%viscratios(1, iconn)
2315 ! flow from aquifer to lake
2316 else
2317 vscratio = this%viscratios(2, iconn)
2318 end if
2319 end if
2320 cond = sat * this%satcond(iconn) * vscratio
Here is the call graph for this function:

◆ lak_calculate_conn_exchange()

subroutine lakmodule::lak_calculate_conn_exchange ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
integer(i4b), intent(in) iconn,
real(dp), intent(in) stage,
real(dp), intent(in) head,
real(dp), intent(inout) flow,
real(dp), intent(inout), optional gwfhcof,
real(dp), intent(inout), optional gwfrhs )
private

Definition at line 2349 of file gwf-lak.f90.

2351 ! -- dummy
2352 class(LakType), intent(inout) :: this
2353 integer(I4B), intent(in) :: ilak
2354 integer(I4B), intent(in) :: iconn
2355 real(DP), intent(in) :: stage
2356 real(DP), intent(in) :: head
2357 real(DP), intent(inout) :: flow
2358 real(DP), intent(inout), optional :: gwfhcof
2359 real(DP), intent(inout), optional :: gwfrhs
2360 ! -- local
2361 real(DP) :: botl
2362 real(DP) :: cond
2363 real(DP) :: ss
2364 real(DP) :: hh
2365 real(DP) :: gwfhcof0
2366 real(DP) :: gwfrhs0
2367 !
2368 flow = dzero
2369 call this%lak_calculate_conn_conductance(ilak, iconn, stage, head, cond)
2370 botl = this%belev(iconn)
2371 !
2372 ! -- Set ss to stage or botl
2373 if (stage >= botl) then
2374 ss = stage
2375 else
2376 ss = botl
2377 end if
2378 !
2379 ! -- set hh to head or botl
2380 if (head >= botl) then
2381 hh = head
2382 else
2383 hh = botl
2384 end if
2385 !
2386 ! -- calculate flow, positive into lake
2387 flow = cond * (hh - ss)
2388 !
2389 ! -- Calculate gwfhcof and gwfrhs
2390 if (head >= botl) then
2391 gwfhcof0 = -cond
2392 gwfrhs0 = -cond * ss
2393 else
2394 gwfhcof0 = dzero
2395 gwfrhs0 = flow
2396 end if
2397 !
2398 ! Add density contributions, if active
2399 if (this%idense /= 0) then
2400 call this%lak_calculate_density_exchange(iconn, stage, head, cond, botl, &
2401 flow, gwfhcof0, gwfrhs0)
2402 end if
2403 !
2404 ! -- If present update gwfhcof and gwfrhs
2405 if (present(gwfhcof)) gwfhcof = gwfhcof0
2406 if (present(gwfrhs)) gwfrhs = gwfrhs0

◆ lak_calculate_conn_exchange_deriv()

subroutine lakmodule::lak_calculate_conn_exchange_deriv ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
integer(i4b), intent(in) iconn,
real(dp), intent(in) stage,
real(dp), intent(in) head,
real(dp), intent(inout) flow,
real(dp), intent(inout), optional dqds,
real(dp), intent(inout), optional dqdh )
private

Returns the lakebed seepage for one connection, positive into the lake, and optionally its stage and head derivatives. The stage and the connected- cell head are each held at or above the lake bottom, the same wet/dry cutoff used by the default formulation, so the implicit seepage matches the default formulation exactly. lak_fc_implicit uses this to assemble the matrix and lak_cq uses it to report the budget, so the two are consistent.

Definition at line 2418 of file gwf-lak.f90.

2420 ! -- dummy
2421 class(LakType), intent(inout) :: this
2422 integer(I4B), intent(in) :: ilak
2423 integer(I4B), intent(in) :: iconn
2424 real(DP), intent(in) :: stage
2425 real(DP), intent(in) :: head
2426 real(DP), intent(inout) :: flow
2427 real(DP), intent(inout), optional :: dqds
2428 real(DP), intent(inout), optional :: dqdh
2429 ! -- local
2430 real(DP) :: cond, botl, dps, dph, ss, hh
2431 !
2432 call this%lak_calculate_conn_conductance(ilak, iconn, stage, head, cond)
2433 botl = this%belev(iconn)
2434 if (stage >= botl) then
2435 ss = stage
2436 dps = done
2437 else
2438 ss = botl
2439 dps = dzero
2440 end if
2441 if (head >= botl) then
2442 hh = head
2443 dph = done
2444 else
2445 hh = botl
2446 dph = dzero
2447 end if
2448 flow = cond * (hh - ss)
2449 if (present(dqds)) dqds = -cond * dps
2450 if (present(dqdh)) dqdh = cond * dph

◆ lak_calculate_conn_warea()

subroutine lakmodule::lak_calculate_conn_warea ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
integer(i4b), intent(in) iconn,
real(dp), intent(in) stage,
real(dp), intent(in) head,
real(dp), intent(inout) wa )
private

Definition at line 2105 of file gwf-lak.f90.

2106 ! -- dummy
2107 class(LakType), intent(inout) :: this
2108 integer(I4B), intent(in) :: ilak
2109 integer(I4B), intent(in) :: iconn
2110 real(DP), intent(in) :: stage
2111 real(DP), intent(in) :: head
2112 real(DP), intent(inout) :: wa
2113 ! -- local
2114 integer(I4B) :: i
2115 integer(I4B) :: ifirst
2116 integer(I4B) :: ilast
2117 integer(I4B) :: node
2118 real(DP) :: topl
2119 real(DP) :: botl
2120 real(DP) :: vv
2121 real(DP) :: sat
2122 !
2123 wa = dzero
2124 topl = this%telev(iconn)
2125 botl = this%belev(iconn)
2126 call this%lak_calculate_cond_head(iconn, stage, head, vv)
2127 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
2128 if (vv > topl) vv = topl
2129 i = this%ntabrow(ilak)
2130 ifirst = this%ialaktab(ilak)
2131 ilast = this%ialaktab(ilak + 1) - 1
2132 if (vv <= this%tabstage(ifirst)) then
2133 wa = this%tabwarea(ifirst)
2134 else if (vv >= this%tabstage(ilast)) then
2135 wa = this%tabwarea(ilast)
2136 else
2137 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2138 this%tabwarea(ifirst:ilast), &
2139 vv, wa)
2140 end if
2141 else
2142 node = this%gwfconn(iconn)
2143 ! -- confined cell
2144 if (this%icelltype(node) == 0) then
2145 sat = done
2146 ! -- convertible cell
2147 else
2148 sat = squadraticsaturation(topl, botl, vv)
2149 end if
2150 wa = sat * this%warea(iconn)
2151 end if
Here is the call graph for this function:

◆ lak_calculate_density_exchange()

subroutine lakmodule::lak_calculate_density_exchange ( class(laktype), intent(inout) this,
integer(i4b), intent(in) iconn,
real(dp), intent(in) stage,
real(dp), intent(in) head,
real(dp), intent(in) cond,
real(dp), intent(in) botl,
real(dp), intent(inout) flow,
real(dp), intent(inout) gwfhcof,
real(dp), intent(inout) gwfrhs )
private

Arguments are as follows: iconn : lak-gwf connection number stage : lake stage head : gwf head cond : conductance botl : bottom elevation of this connection flow : calculated flow, updated here with density terms gwfhcof : gwf head coefficient, updated here with density terms gwfrhs : gwf right-hand-side value, updated here with density terms

Member variable used here denseterms : shape (3, MAXBOUND), filled by buoyancy package col 1 is relative density of lake (denselak / denseref) col 2 is relative density of gwf cell (densegwf / denseref) col 3 is elevation of gwf cell

Definition at line 6603 of file gwf-lak.f90.

6605 ! -- dummy
6606 class(LakType), intent(inout) :: this
6607 integer(I4B), intent(in) :: iconn
6608 real(DP), intent(in) :: stage
6609 real(DP), intent(in) :: head
6610 real(DP), intent(in) :: cond
6611 real(DP), intent(in) :: botl
6612 real(DP), intent(inout) :: flow
6613 real(DP), intent(inout) :: gwfhcof
6614 real(DP), intent(inout) :: gwfrhs
6615 ! -- local
6616 real(DP) :: ss
6617 real(DP) :: hh
6618 real(DP) :: havg
6619 real(DP) :: rdenselak
6620 real(DP) :: rdensegwf
6621 real(DP) :: rdenseavg
6622 real(DP) :: elevlak
6623 real(DP) :: elevgwf
6624 real(DP) :: elevavg
6625 real(DP) :: d1
6626 real(DP) :: d2
6627 logical(LGP) :: stage_below_bot
6628 logical(LGP) :: head_below_bot
6629 !
6630 ! -- Set lak density to lak density or gwf density
6631 if (stage >= botl) then
6632 ss = stage
6633 stage_below_bot = .false.
6634 rdenselak = this%denseterms(1, iconn) ! lak rel density
6635 else
6636 ss = botl
6637 stage_below_bot = .true.
6638 rdenselak = this%denseterms(2, iconn) ! gwf rel density
6639 end if
6640 !
6641 ! -- set hh to head or botl
6642 if (head >= botl) then
6643 hh = head
6644 head_below_bot = .false.
6645 rdensegwf = this%denseterms(2, iconn) ! gwf rel density
6646 else
6647 hh = botl
6648 head_below_bot = .true.
6649 rdensegwf = this%denseterms(1, iconn) ! lak rel density
6650 end if
6651 !
6652 ! -- todo: hack because denseterms not updated in a cf calculation
6653 if (rdensegwf == dzero) return
6654 !
6655 ! -- Update flow
6656 if (stage_below_bot .and. head_below_bot) then
6657 !
6658 ! -- flow is zero, so no terms are updated
6659 !
6660 else
6661 !
6662 ! -- calculate average relative density
6663 rdenseavg = dhalf * (rdenselak + rdensegwf)
6664 !
6665 ! -- Add contribution of first density term:
6666 ! cond * (denseavg/denseref - 1) * (hgwf - hlak)
6667 d1 = cond * (rdenseavg - done)
6668 gwfhcof = gwfhcof - d1
6669 gwfrhs = gwfrhs - d1 * ss
6670 d1 = d1 * (hh - ss)
6671 flow = flow + d1
6672 !
6673 ! -- Add second density term if stage and head not below bottom
6674 if (.not. stage_below_bot .and. .not. head_below_bot) then
6675 !
6676 ! -- Add contribution of second density term:
6677 ! cond * (havg - elevavg) * (densegwf - denselak) / denseref
6678 elevgwf = this%denseterms(3, iconn)
6679 if (this%ictype(iconn) == 0 .or. this%ictype(iconn) == 3) then
6680 ! -- vertical or embedded vertical connection
6681 elevlak = botl
6682 else
6683 ! -- horizontal or embedded horizontal connection
6684 elevlak = elevgwf
6685 end if
6686 elevavg = dhalf * (elevlak + elevgwf)
6687 havg = dhalf * (hh + ss)
6688 d2 = cond * (havg - elevavg) * (rdensegwf - rdenselak)
6689 gwfrhs = gwfrhs + d2
6690 flow = flow + d2
6691 end if
6692 end if

◆ lak_calculate_evaporation()

subroutine lakmodule::lak_calculate_evaporation ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) avail,
real(dp), intent(inout) ev )
private

Definition at line 2605 of file gwf-lak.f90.

2606 ! -- dummy
2607 class(LakType), intent(inout) :: this
2608 integer(I4B), intent(in) :: ilak
2609 real(DP), intent(in) :: stage
2610 real(DP), intent(inout) :: avail
2611 real(DP), intent(inout) :: ev
2612 ! -- local
2613 real(DP) :: sa
2614 !
2615 ! -- evaporation - limit to sum of inflows and available volume
2616 call this%lak_calculate_sarea(ilak, stage, sa)
2617 ev = sa * this%evaporation(ilak)
2618 if (ev > avail) then
2619 if (is_close(avail, dprec)) then
2620 ev = dzero
2621 else
2622 ev = -avail
2623 end if
2624 else
2625 ev = -ev
2626 end if
2627 avail = avail + ev
Here is the call graph for this function:

◆ lak_calculate_exchange()

subroutine lakmodule::lak_calculate_exchange ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) totflow )
private

Definition at line 2325 of file gwf-lak.f90.

2326 ! -- dummy
2327 class(LakType), intent(inout) :: this
2328 integer(I4B), intent(in) :: ilak
2329 real(DP), intent(in) :: stage
2330 real(DP), intent(inout) :: totflow
2331 ! -- local
2332 integer(I4B) :: j
2333 integer(I4B) :: igwfnode
2334 real(DP) :: flow
2335 real(DP) :: hgwf
2336 !
2337 totflow = dzero
2338 do j = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2339 igwfnode = this%gwfconn(j)
2340 hgwf = this%xnew(igwfnode)
2341 call this%lak_calculate_conn_exchange(ilak, j, stage, hgwf, flow)
2342 totflow = totflow + flow
2343 end do

◆ lak_calculate_external()

subroutine lakmodule::lak_calculate_external ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) ex )
private

Definition at line 2567 of file gwf-lak.f90.

2568 ! -- dummy
2569 class(LakType), intent(inout) :: this
2570 integer(I4B), intent(in) :: ilak
2571 real(DP), intent(inout) :: ex
2572 !
2573 ! -- If mover is active, add receiver water to rhs and
2574 ! store available water (as positive value)
2575 ex = dzero
2576 if (this%imover == 1) then
2577 ex = this%pakmvrobj%get_qfrommvr(ilak)
2578 end if

◆ lak_calculate_inflow()

subroutine lakmodule::lak_calculate_inflow ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) qin )
private

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

2556 ! -- dummy
2557 class(LakType), intent(inout) :: this
2558 integer(I4B), intent(in) :: ilak
2559 real(DP), intent(inout) :: qin
2560 !
2561 ! -- inflow to lake
2562 qin = this%inflow(ilak)

◆ lak_calculate_outlet_inflow()

subroutine lakmodule::lak_calculate_outlet_inflow ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) outinf )
private

Definition at line 2632 of file gwf-lak.f90.

2633 ! -- dummy
2634 class(LakType), intent(inout) :: this
2635 integer(I4B), intent(in) :: ilak
2636 real(DP), intent(inout) :: outinf
2637 ! -- local
2638 integer(I4B) :: n
2639 !
2640 outinf = dzero
2641 do n = 1, this%noutlets
2642 if (this%lakeout(n) == ilak) then
2643 outinf = outinf - this%simoutrate(n)
2644 if (this%imover == 1) then
2645 outinf = outinf - this%pakmvrobj%get_qtomvr(n)
2646 end if
2647 end if
2648 end do

◆ lak_calculate_outlet_outflow()

subroutine lakmodule::lak_calculate_outlet_outflow ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) avail,
real(dp), intent(inout) outoutf )
private

Definition at line 2653 of file gwf-lak.f90.

2654 ! -- dummy
2655 class(LakType), intent(inout) :: this
2656 integer(I4B), intent(in) :: ilak
2657 real(DP), intent(in) :: stage
2658 real(DP), intent(inout) :: avail
2659 real(DP), intent(inout) :: outoutf
2660 ! -- local
2661 integer(I4B) :: n
2662 real(DP) :: g
2663 real(DP) :: d
2664 real(DP) :: c
2665 real(DP) :: gsm
2666 real(DP) :: rate
2667 !
2668 outoutf = dzero
2669 do n = 1, this%noutlets
2670 if (this%lakein(n) == ilak) then
2671 rate = dzero
2672 d = stage - this%outinvert(n)
2673 if (this%outdmax > dzero) then
2674 if (d > this%outdmax) d = this%outdmax
2675 end if
2676 g = dgravity * this%convlength * this%convtime * this%convtime
2677 select case (this%iouttype(n))
2678 ! specified rate
2679 case (0)
2680 rate = this%outrate(n)
2681 if (-rate > avail) then
2682 rate = -avail
2683 end if
2684 ! manning
2685 case (1)
2686 if (d > dzero) then
2687 c = (this%convlength**donethird) * this%convtime
2688 gsm = dzero
2689 if (this%outrough(n) > dzero) then
2690 gsm = done / this%outrough(n)
2691 end if
2692 rate = -c * gsm * this%outwidth(n) * (d**dfivethirds) * &
2693 sqrt(this%outslope(n))
2694 end if
2695 ! weir
2696 case (2)
2697 if (d > dzero) then
2698 rate = -dtwothirds * dcd * this%outwidth(n) * d * &
2699 sqrt(dtwo * g * d)
2700 end if
2701 end select
2702 this%simoutrate(n) = rate
2703 avail = avail + rate
2704 outoutf = outoutf + rate
2705 end if
2706 end do

◆ lak_calculate_rainfall()

subroutine lakmodule::lak_calculate_rainfall ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) ra )
private

Definition at line 2521 of file gwf-lak.f90.

2522 ! -- dummy
2523 class(LakType), intent(inout) :: this
2524 integer(I4B), intent(in) :: ilak
2525 real(DP), intent(in) :: stage
2526 real(DP), intent(inout) :: ra
2527 ! -- local
2528 integer(I4B) :: iconn
2529 real(DP) :: sa
2530 !
2531 ! -- rainfall
2532 iconn = this%idxlakeconn(ilak)
2533 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
2534 sa = this%sareamax(ilak)
2535 else
2536 call this%lak_calculate_sarea(ilak, stage, sa)
2537 end if
2538 ra = this%rainfall(ilak) * sa

◆ lak_calculate_residual()

subroutine lakmodule::lak_calculate_residual ( class(laktype), intent(inout) this,
integer(i4b), intent(in) n,
real(dp), intent(in) hlak,
real(dp), intent(inout) resid,
real(dp), intent(in), optional headp )
private

Definition at line 5946 of file gwf-lak.f90.

5947 ! -- modules
5948 use tdismodule, only: delt
5949 ! -- dummy
5950 class(LakType), intent(inout) :: this
5951 integer(I4B), intent(in) :: n
5952 real(DP), intent(in) :: hlak
5953 real(DP), intent(inout) :: resid
5954 real(DP), intent(in), optional :: headp
5955 ! -- local
5956 integer(I4B) :: j
5957 integer(I4B) :: idry
5958 integer(I4B) :: igwfnode
5959 real(DP) :: hp
5960 real(DP) :: avail
5961 real(DP) :: head
5962 real(DP) :: ra
5963 real(DP) :: ro
5964 real(DP) :: qinf
5965 real(DP) :: ex
5966 real(DP) :: ev
5967 real(DP) :: wr
5968 real(DP) :: sout
5969 real(DP) :: sin
5970 real(DP) :: qlakgw
5971 real(DP) :: seep
5972 real(DP) :: hlak0
5973 real(DP) :: v0
5974 real(DP) :: v1
5975 !
5976 ! -- set hp
5977 if (present(headp)) then
5978 hp = headp
5979 else
5980 hp = dzero
5981 end if
5982 !
5983 ! -- initialize
5984 resid = dzero
5985 avail = dzero
5986 seep = dzero
5987 !
5988 ! -- calculate the available water
5989 call this%lak_calculate_available(n, hlak, avail, &
5990 ra, ro, qinf, ex, hp)
5991 !
5992 ! -- calculate groundwater seepage
5993 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5994 igwfnode = this%gwfconn(j)
5995 if (this%ibound(igwfnode) == 0) cycle
5996 head = this%xnew(igwfnode) + hp
5997 call this%lak_estimate_conn_exchange(2, n, j, idry, hlak, head, qlakgw, &
5998 avail)
5999 seep = seep + qlakgw
6000 end do
6001 !
6002 ! -- limit withdrawals to lake inflows and lake storage
6003 call this%lak_calculate_withdrawal(n, avail, wr)
6004 !
6005 ! -- limit evaporation to lake inflows and lake storage
6006 call this%lak_calculate_evaporation(n, hlak, avail, ev)
6007 !
6008 ! -- no outlet flow if evaporation consumes all water
6009 call this%lak_calculate_outlet_outflow(n, hlak, avail, sout)
6010 !
6011 ! -- update the surface inflow values
6012 call this%lak_calculate_outlet_inflow(n, sin)
6013 !
6014 ! -- calculate residual
6015 resid = ra + ev + wr + ro + qinf + ex + sin + sout + seep
6016 !
6017 ! -- include storage
6018 if (this%gwfiss /= 1) then
6019 hlak0 = this%xoldpak(n)
6020 call this%lak_calculate_vol(n, hlak0, v0)
6021 call this%lak_calculate_vol(n, hlak, v1)
6022 resid = resid + (v0 - v1) / delt
6023 end if

◆ lak_calculate_runoff()

subroutine lakmodule::lak_calculate_runoff ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) ro )
private

Definition at line 2543 of file gwf-lak.f90.

2544 ! -- dummy
2545 class(LakType), intent(inout) :: this
2546 integer(I4B), intent(in) :: ilak
2547 real(DP), intent(inout) :: ro
2548 !
2549 ! -- runoff
2550 ro = this%runoff(ilak)

◆ lak_calculate_sarea()

subroutine lakmodule::lak_calculate_sarea ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) sarea )
private

Definition at line 2035 of file gwf-lak.f90.

2036 ! -- dummy
2037 class(LakType), intent(inout) :: this
2038 integer(I4B), intent(in) :: ilak
2039 real(DP), intent(in) :: stage
2040 real(DP), intent(inout) :: sarea
2041 ! -- local
2042 integer(I4B) :: i
2043 integer(I4B) :: ifirst
2044 integer(I4B) :: ilast
2045 real(DP) :: topl
2046 real(DP) :: botl
2047 real(DP) :: sat
2048 real(DP) :: sa
2049 !
2050 sarea = dzero
2051 i = this%ntabrow(ilak)
2052 if (i > 0) then
2053 ifirst = this%ialaktab(ilak)
2054 ilast = this%ialaktab(ilak + 1) - 1
2055 if (stage <= this%tabstage(ifirst)) then
2056 sarea = this%tabsarea(ifirst)
2057 else if (stage >= this%tabstage(ilast)) then
2058 sarea = this%tabsarea(ilast)
2059 else
2060 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2061 this%tabsarea(ifirst:ilast), &
2062 stage, sarea)
2063 end if
2064 else
2065 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2066 topl = this%telev(i)
2067 botl = this%belev(i)
2068 sat = squadraticsaturation(topl, botl, stage)
2069 sa = sat * this%sarea(i)
2070 sarea = sarea + sa
2071 end do
2072 end if
Here is the call graph for this function:

◆ lak_calculate_storagechange()

subroutine lakmodule::lak_calculate_storagechange ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(in) stage0,
real(dp), intent(in) delt,
real(dp), intent(inout) dvr )
private

Definition at line 2499 of file gwf-lak.f90.

2500 ! -- dummy
2501 class(LakType), intent(inout) :: this
2502 integer(I4B), intent(in) :: ilak
2503 real(DP), intent(in) :: stage
2504 real(DP), intent(in) :: stage0
2505 real(DP), intent(in) :: delt
2506 real(DP), intent(inout) :: dvr
2507 ! -- local
2508 real(DP) :: v
2509 real(DP) :: v0
2510 !
2511 dvr = dzero
2512 if (this%gwfiss /= 1) then
2513 call this%lak_calculate_vol(ilak, stage, v)
2514 call this%lak_calculate_vol(ilak, stage0, v0)
2515 dvr = (v0 - v) / delt
2516 end if

◆ lak_calculate_vol()

subroutine lakmodule::lak_calculate_vol ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) volume )
private

Definition at line 2156 of file gwf-lak.f90.

2157 ! -- dummy
2158 class(LakType), intent(inout) :: this
2159 integer(I4B), intent(in) :: ilak
2160 real(DP), intent(in) :: stage
2161 real(DP), intent(inout) :: volume
2162 ! -- local
2163 integer(I4B) :: i
2164 integer(I4B) :: ifirst
2165 integer(I4B) :: ilast
2166 real(DP) :: topl
2167 real(DP) :: botl
2168 real(DP) :: ds
2169 real(DP) :: sa
2170 real(DP) :: v
2171 real(DP) :: sat
2172 !
2173 volume = dzero
2174 i = this%ntabrow(ilak)
2175 if (i > 0) then
2176 ifirst = this%ialaktab(ilak)
2177 ilast = this%ialaktab(ilak + 1) - 1
2178 if (stage <= this%tabstage(ifirst)) then
2179 volume = this%tabvolume(ifirst)
2180 else if (stage >= this%tabstage(ilast)) then
2181 ds = stage - this%tabstage(ilast)
2182 sa = this%tabsarea(ilast)
2183 volume = this%tabvolume(ilast) + ds * sa
2184 else
2185 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2186 this%tabvolume(ifirst:ilast), &
2187 stage, volume)
2188 end if
2189 else
2190 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2191 topl = this%telev(i)
2192 botl = this%belev(i)
2193 sat = squadraticsaturation(topl, botl, stage)
2194 sa = sat * this%sarea(i)
2195 if (stage < botl) then
2196 v = dzero
2197 else if (stage > botl .and. stage < topl) then
2198 v = sa * (stage - botl)
2199 else
2200 v = sa * (topl - botl) + sa * (stage - topl)
2201 end if
2202 volume = volume + v
2203 end do
2204 end if
Here is the call graph for this function:

◆ lak_calculate_warea()

subroutine lakmodule::lak_calculate_warea ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) warea,
real(dp), intent(inout), optional hin )
private

Definition at line 2077 of file gwf-lak.f90.

2078 ! -- dummy
2079 class(LakType), intent(inout) :: this
2080 integer(I4B), intent(in) :: ilak
2081 real(DP), intent(in) :: stage
2082 real(DP), intent(inout) :: warea
2083 real(DP), optional, intent(inout) :: hin
2084 ! -- local
2085 integer(I4B) :: i
2086 integer(I4B) :: igwfnode
2087 real(DP) :: head
2088 real(DP) :: wa
2089 !
2090 warea = dzero
2091 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2092 if (present(hin)) then
2093 head = hin
2094 else
2095 igwfnode = this%gwfconn(i)
2096 head = this%xnew(igwfnode)
2097 end if
2098 call this%lak_calculate_conn_warea(ilak, i, stage, head, wa)
2099 warea = warea + wa
2100 end do

◆ lak_calculate_withdrawal()

subroutine lakmodule::lak_calculate_withdrawal ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) avail,
real(dp), intent(inout) wr )
private

Definition at line 2583 of file gwf-lak.f90.

2584 ! -- dummy
2585 class(LakType), intent(inout) :: this
2586 integer(I4B), intent(in) :: ilak
2587 real(DP), intent(inout) :: avail
2588 real(DP), intent(inout) :: wr
2589 !
2590 ! -- withdrawals - limit to sum of inflows and available volume
2591 wr = this%withdrawal(ilak)
2592 if (wr > avail) then
2593 wr = -avail
2594 else
2595 if (wr > dzero) then
2596 wr = -wr
2597 end if
2598 end if
2599 avail = avail + wr

◆ lak_cc()

subroutine lakmodule::lak_cc ( class(laktype), intent(inout) this,
integer(i4b), intent(in) innertot,
integer(i4b), intent(in) kiter,
integer(i4b), intent(in) iend,
integer(i4b), intent(in) icnvgmod,
character(len=lenpakloc), intent(inout) cpak,
integer(i4b), intent(inout) ipak,
real(dp), intent(inout) dpak )
private

Definition at line 3889 of file gwf-lak.f90.

3890 ! -- modules
3891 use tdismodule, only: totim, kstp, kper, delt
3892 ! -- dummy
3893 class(LakType), intent(inout) :: this
3894 integer(I4B), intent(in) :: innertot
3895 integer(I4B), intent(in) :: kiter
3896 integer(I4B), intent(in) :: iend
3897 integer(I4B), intent(in) :: icnvgmod
3898 character(len=LENPAKLOC), intent(inout) :: cpak
3899 integer(I4B), intent(inout) :: ipak
3900 real(DP), intent(inout) :: dpak
3901 ! -- local
3902 character(len=LENPAKLOC) :: cloc
3903 character(len=LINELENGTH) :: tag
3904 integer(I4B) :: icheck
3905 integer(I4B) :: ipakfail
3906 integer(I4B) :: locdhmax
3907 integer(I4B) :: locresidmax
3908 integer(I4B) :: locdgwfmax
3909 integer(I4B) :: locdqoutmax
3910 integer(I4B) :: locdqfrommvrmax
3911 integer(I4B) :: ntabrows
3912 integer(I4B) :: ntabcols
3913 integer(I4B) :: n
3914 real(DP) :: q
3915 real(DP) :: q0
3916 real(DP) :: qtolfact
3917 real(DP) :: area
3918 real(DP) :: gwf0
3919 real(DP) :: gwf
3920 real(DP) :: dh
3921 real(DP) :: resid
3922 real(DP) :: dgwf
3923 real(DP) :: hlak0
3924 real(DP) :: hlak
3925 real(DP) :: qout0
3926 real(DP) :: qout
3927 real(DP) :: dqout
3928 real(DP) :: inf
3929 real(DP) :: ra
3930 real(DP) :: ro
3931 real(DP) :: qinf
3932 real(DP) :: ex
3933 real(DP) :: dhmax
3934 real(DP) :: residmax
3935 real(DP) :: dgwfmax
3936 real(DP) :: dqoutmax
3937 real(DP) :: dqfrommvr
3938 real(DP) :: dqfrommvrmax
3939 ! -- switch any stalled IMPLICIT lake back to the legacy solver
3940 call this%lak_set_legacy(kiter, icnvgmod)
3941 !
3942 ! -- on the last outer iteration of a solution that has not converged, warn
3943 ! about a perched (disconnected) lake that has no practical steady state.
3944 ! Done for both formulations (the implicit path returns just below).
3945 if (iend /= 0 .and. icnvgmod == 0) then
3946 call this%lak_check_disconnected()
3947 end if
3948 !
3949 ! -- implicit formulation: lake stage is solved in the global matrix,
3950 ! so its convergence is governed by the solution's dvclose check on the
3951 ! stage unknown; no separate package convergence check is performed here.
3952 if (this%iimplicit /= 0) then
3953 return
3954 end if
3955 !
3956 ! -- initialize local variables
3957 icheck = this%iconvchk
3958 ipakfail = 0
3959 locdhmax = 0
3960 locresidmax = 0
3961 locdgwfmax = 0
3962 locdqoutmax = 0
3963 locdqfrommvrmax = 0
3964 dhmax = dzero
3965 residmax = dzero
3966 dgwfmax = dzero
3967 dqoutmax = dzero
3968 dqfrommvrmax = dzero
3969 !
3970 ! -- if not saving package convergence data on check convergence if
3971 ! the model is considered converged
3972 if (this%ipakcsv == 0) then
3973 if (icnvgmod == 0) then
3974 icheck = 0
3975 end if
3976 !
3977 ! -- saving package convergence data
3978 else
3979 !
3980 ! -- header for package csv
3981 if (.not. associated(this%pakcsvtab)) then
3982 !
3983 ! -- determine the number of columns and rows
3984 ntabrows = 1
3985 ntabcols = 11
3986 if (this%noutlets > 0) then
3987 ntabcols = ntabcols + 2
3988 end if
3989 if (this%imover == 1) then
3990 ntabcols = ntabcols + 2
3991 end if
3992 !
3993 ! -- setup table
3994 call table_cr(this%pakcsvtab, this%packName, '')
3995 call this%pakcsvtab%table_df(ntabrows, ntabcols, this%ipakcsv, &
3996 lineseparator=.false., separator=',', &
3997 finalize=.false.)
3998 !
3999 ! -- add columns to package csv
4000 tag = 'total_inner_iterations'
4001 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
4002 tag = 'totim'
4003 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
4004 tag = 'kper'
4005 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
4006 tag = 'kstp'
4007 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
4008 tag = 'nouter'
4009 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
4010 tag = 'dvmax'
4011 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4012 tag = 'dvmax_loc'
4013 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4014 tag = 'residmax'
4015 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4016 tag = 'residmax_loc'
4017 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4018 tag = 'dgwfmax'
4019 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4020 tag = 'dgwfmax_loc'
4021 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4022 if (this%noutlets > 0) then
4023 tag = 'dqoutmax'
4024 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4025 tag = 'dqoutmax_loc'
4026 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4027 end if
4028 if (this%imover == 1) then
4029 tag = 'dqfrommvrmax'
4030 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
4031 tag = 'dqfrommvrmax_loc'
4032 call this%pakcsvtab%initialize_column(tag, 16, alignment=tableft)
4033 end if
4034 end if
4035 end if
4036 !
4037 ! -- perform package convergence check
4038 if (icheck /= 0) then
4039 final_check: do n = 1, this%nlakes
4040 if (this%iboundpak(n) < 1) cycle
4041 !
4042 ! -- set previous and current lake stage
4043 hlak0 = this%s0(n)
4044 hlak = this%xnewpak(n)
4045 !
4046 ! -- stage difference
4047 dh = hlak0 - hlak
4048 !
4049 ! -- calculate surface area
4050 call this%lak_calculate_sarea(n, hlak, area)
4051 !
4052 ! -- set the Q to length factor
4053 if (area > dzero) then
4054 qtolfact = delt / area
4055 else
4056 qtolfact = dzero
4057 end if
4058 !
4059 ! -- difference in the residual
4060 call this%lak_calculate_residual(n, hlak, resid)
4061 resid = resid * qtolfact
4062 !
4063 ! -- change in gwf exchange
4064 dgwf = dzero
4065 if (area > dzero) then
4066 gwf0 = this%qgwf0(n)
4067 call this%lak_calculate_exchange(n, hlak, gwf)
4068 dgwf = (gwf0 - gwf) * qtolfact
4069 end if
4070 !
4071 ! -- change in outflows
4072 dqout = dzero
4073 if (this%noutlets > 0) then
4074 if (area > dzero) then
4075 call this%lak_calculate_available(n, hlak0, inf, ra, ro, qinf, ex)
4076 call this%lak_calculate_outlet_outflow(n, hlak0, inf, qout0)
4077 call this%lak_calculate_available(n, hlak, inf, ra, ro, qinf, ex)
4078 call this%lak_calculate_outlet_outflow(n, hlak, inf, qout)
4079 dqout = (qout0 - qout) * qtolfact
4080 end if
4081 end if
4082 !
4083 ! -- q from mvr
4084 dqfrommvr = dzero
4085 if (this%imover == 1) then
4086 q = this%pakmvrobj%get_qfrommvr(n)
4087 q0 = this%pakmvrobj%get_qfrommvr0(n)
4088 dqfrommvr = qtolfact * (q0 - q)
4089 end if
4090 !
4091 ! -- evaluate magnitude of differences
4092 if (n == 1) then
4093 locdhmax = n
4094 dhmax = dh
4095 locdgwfmax = n
4096 residmax = resid
4097 locresidmax = n
4098 dgwfmax = dgwf
4099 locdqoutmax = n
4100 dqoutmax = dqout
4101 dqfrommvrmax = dqfrommvr
4102 locdqfrommvrmax = n
4103 else
4104 if (abs(dh) > abs(dhmax)) then
4105 locdhmax = n
4106 dhmax = dh
4107 end if
4108 if (abs(resid) > abs(residmax)) then
4109 locresidmax = n
4110 residmax = resid
4111 end if
4112 if (abs(dgwf) > abs(dgwfmax)) then
4113 locdgwfmax = n
4114 dgwfmax = dgwf
4115 end if
4116 if (abs(dqout) > abs(dqoutmax)) then
4117 locdqoutmax = n
4118 dqoutmax = dqout
4119 end if
4120 if (abs(dqfrommvr) > abs(dqfrommvrmax)) then
4121 dqfrommvrmax = dqfrommvr
4122 locdqfrommvrmax = n
4123 end if
4124 end if
4125 end do final_check
4126 !
4127 ! -- set dpak and cpak
4128 if (abs(dhmax) > abs(dpak)) then
4129 ipak = locdhmax
4130 dpak = dhmax
4131 write (cloc, "(a,'-',a)") &
4132 trim(this%packName), 'stage'
4133 cpak = trim(cloc)
4134 end if
4135 if (abs(residmax) > abs(dpak)) then
4136 ipak = locresidmax
4137 dpak = residmax
4138 write (cloc, "(a,'-',a)") &
4139 trim(this%packName), 'residual'
4140 cpak = trim(cloc)
4141 end if
4142 if (abs(dgwfmax) > abs(dpak)) then
4143 ipak = locdgwfmax
4144 dpak = dgwfmax
4145 write (cloc, "(a,'-',a)") &
4146 trim(this%packName), 'gwf'
4147 cpak = trim(cloc)
4148 end if
4149 if (this%noutlets > 0) then
4150 if (abs(dqoutmax) > abs(dpak)) then
4151 ipak = locdqoutmax
4152 dpak = dqoutmax
4153 write (cloc, "(a,'-',a)") &
4154 trim(this%packName), 'outlet'
4155 cpak = trim(cloc)
4156 end if
4157 end if
4158 if (this%imover == 1) then
4159 if (abs(dqfrommvrmax) > abs(dpak)) then
4160 ipak = locdqfrommvrmax
4161 dpak = dqfrommvrmax
4162 write (cloc, "(a,'-',a)") trim(this%packName), 'qfrommvr'
4163 cpak = trim(cloc)
4164 end if
4165 end if
4166 !
4167 ! -- write convergence data to package csv
4168 if (this%ipakcsv /= 0) then
4169 !
4170 ! -- write the data
4171 call this%pakcsvtab%add_term(innertot)
4172 call this%pakcsvtab%add_term(totim)
4173 call this%pakcsvtab%add_term(kper)
4174 call this%pakcsvtab%add_term(kstp)
4175 call this%pakcsvtab%add_term(kiter)
4176 call this%pakcsvtab%add_term(dhmax)
4177 call this%pakcsvtab%add_term(locdhmax)
4178 call this%pakcsvtab%add_term(residmax)
4179 call this%pakcsvtab%add_term(locresidmax)
4180 call this%pakcsvtab%add_term(dgwfmax)
4181 call this%pakcsvtab%add_term(locdgwfmax)
4182 if (this%noutlets > 0) then
4183 call this%pakcsvtab%add_term(dqoutmax)
4184 call this%pakcsvtab%add_term(locdqoutmax)
4185 end if
4186 if (this%imover == 1) then
4187 call this%pakcsvtab%add_term(dqfrommvrmax)
4188 call this%pakcsvtab%add_term(locdqfrommvrmax)
4189 end if
4190 !
4191 ! -- finalize the package csv
4192 if (iend == 1) then
4193 call this%pakcsvtab%finalize_table()
4194 end if
4195 end if
4196 end if
real(dp), pointer, public totim
time relative to start of simulation
Definition tdis.f90:35
integer(i4b), pointer, public kstp
current time step number
Definition tdis.f90:27
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
Here is the call graph for this function:

◆ lak_cf()

subroutine lakmodule::lak_cf ( class(laktype) this)
private

Skip if no lakes, otherwise calculate hcof and rhs

Definition at line 3652 of file gwf-lak.f90.

3653 ! -- dummy
3654 class(LakType) :: this
3655 ! -- local
3656 integer(I4B) :: j, n
3657 integer(I4B) :: igwfnode
3658 real(DP) :: hlak, bottom_lake
3659 !
3660 ! -- save groundwater seepage for lake solution
3661 do n = 1, this%nlakes
3662 this%seep0(n) = this%seep(n)
3663 end do
3664 !
3665 ! -- save variables for convergence check
3666 do n = 1, this%nlakes
3667 this%s0(n) = this%xnewpak(n)
3668 call this%lak_calculate_exchange(n, this%s0(n), this%qgwf0(n))
3669 end do
3670 !
3671 ! -- find highest active cell
3672 do n = 1, this%nlakes
3673 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3674 ! -- skip horizontal connections
3675 if (this%ictype(j) /= 0) then
3676 cycle
3677 end if
3678 igwfnode = this%nodesontop(j)
3679 if (this%ibound(igwfnode) == 0) then
3680 call this%dis%highest_active(igwfnode, this%ibound)
3681 end if
3682 this%nodelist(j) = igwfnode
3683 this%gwfconn(j) = igwfnode
3684 end do
3685 end do
3686 !
3687 ! -- reset ibound for cells where lake stage is above the bottom
3688 ! of the lake in the cell or the lake is inactive - only applied to
3689 ! vertical connections
3690 do n = 1, this%nlakes
3691 !
3692 hlak = this%xnewpak(n)
3693 !
3694 ! -- Go through lake connections
3695 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3696 !
3697 ! -- assign gwf node number
3698 igwfnode = this%gwfconn(j)
3699 !
3700 ! -- skip inactive or constant head GWF cells
3701 if (this%ibound(igwfnode) < 1) then
3702 cycle
3703 end if
3704 !
3705 ! -- skip horizontal connections
3706 if (this%ictype(j) /= 0) then
3707 cycle
3708 end if
3709 !
3710 ! -- skip embedded lakes
3711 if (this%ictype(j) == 2 .or. this%ictype(j) == 3) then
3712 cycle
3713 end if
3714 !
3715 ! -- Mark ibound for wet lakes or inactive lakes; reset to 1 otherwise
3716 bottom_lake = this%belev(j)
3717 if (hlak > bottom_lake .or. this%iboundpak(n) == 0) then
3718 this%ibound(igwfnode) = iwetlake
3719 else
3720 this%ibound(igwfnode) = 1
3721 end if
3722 end do
3723 !
3724 end do
3725 !
3726 ! -- Store the lake stage and cond in bound array for other
3727 ! packages, such as the BUY package
3728 call this%lak_bound_update()

◆ lak_check_valid()

integer(i4b) function lakmodule::lak_check_valid ( class(laktype), intent(inout) this,
integer(i4b), intent(in) itemno )
private

Definition at line 2958 of file gwf-lak.f90.

2959 ! -- modules
2960 use simmodule, only: store_error
2961 ! -- return
2962 integer(I4B) :: ierr
2963 ! -- dummy
2964 class(LakType), intent(inout) :: this
2965 integer(I4B), intent(in) :: itemno
2966 ! -- local
2967 integer(I4B) :: ival
2968 !
2969 ierr = 0
2970 ival = abs(itemno)
2971 if (itemno > 0) then
2972 if (ival < 1 .or. ival > this%nlakes) then
2973 write (errmsg, '(a,1x,i0,1x,a,1x,i0,a)') &
2974 'LAKENO', itemno, 'must be greater than 0 and less than or equal to', &
2975 this%nlakes, '.'
2976 call store_error(errmsg)
2977 ierr = 1
2978 end if
2979 else
2980 if (ival < 1 .or. ival > this%noutlets) then
2981 write (errmsg, '(a,1x,i0,1x,a,1x,i0,a)') &
2982 'IOUTLET', itemno, 'must be greater than 0 and less than or equal to', &
2983 this%noutlets, '.'
2984 call store_error(errmsg)
2985 ierr = 1
2986 end if
2987 end if
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:

◆ lak_checkin_deprecated_names()

subroutine lakmodule::lak_checkin_deprecated_names ( class(laktype), intent(inout) this)
private

IDM integration (#3021) moved several lake and outlet variables into the input context, renaming some, and renamed the lake connection cell array. The legacy solver refactor (#2976) renamed the fallback variables. These aliases share memory with the current variables so that programs addressing them through the API by their old package-path names continue to resolve; each use is reported as deprecated. Outlet names are only aliased when outlets are present.

Definition at line 660 of file gwf-lak.f90.

661 ! -- modules
664 ! -- dummy
665 class(LakType), intent(inout) :: this
666 ! -- local
667 real(DP), dimension(:, :), pointer, contiguous :: aux => null()
668 integer(I4B) :: isize
669 ! -- code
670 !
671 ! -- lake period data
672 call mem_alias_deprecated(this%stage, 'STAGE', this%memoryPath, &
673 'STAGE', this%input_mempath, '6.8.2')
674 call mem_alias_deprecated(this%rainfall, 'RAINFALL', this%memoryPath, &
675 'RAINFALL', this%input_mempath, '6.8.2')
676 call mem_alias_deprecated(this%evaporation, 'EVAPORATION', &
677 this%memoryPath, 'EVAPORATION', &
678 this%input_mempath, '6.8.2')
679 call mem_alias_deprecated(this%runoff, 'RUNOFF', this%memoryPath, &
680 'RUNOFF', this%input_mempath, '6.8.2')
681 call mem_alias_deprecated(this%inflow, 'INFLOW', this%memoryPath, &
682 'INFLOW', this%input_mempath, '6.8.2')
683 call mem_alias_deprecated(this%withdrawal, 'WITHDRAWAL', this%memoryPath, &
684 'WITHDRAWAL', this%input_mempath, '6.8.2')
685 !
686 ! -- outlet period data
687 call mem_alias_deprecated(this%outrate, 'OUTRATE', this%memoryPath, &
688 'RATE', this%input_mempath, '6.8.2')
689 call mem_alias_deprecated(this%outinvert, 'OUTINVERT', this%memoryPath, &
690 'INVERT', this%input_mempath, '6.8.2')
691 call mem_alias_deprecated(this%outwidth, 'OUTWIDTH', this%memoryPath, &
692 'WIDTH', this%input_mempath, '6.8.2')
693 call mem_alias_deprecated(this%outslope, 'OUTSLOPE', this%memoryPath, &
694 'SLOPE', this%input_mempath, '6.8.2')
695 call mem_alias_deprecated(this%outrough, 'OUTROUGH', this%memoryPath, &
696 'ROUGH', this%input_mempath, '6.8.2')
697 !
698 ! -- lake auxiliary values, present (possibly empty) in the input context
699 call get_isize('AUX', this%input_mempath, isize)
700 if (isize >= 0) then
701 call mem_setptr(aux, 'AUX', this%input_mempath)
702 call mem_alias_deprecated(aux, 'LAUXVAR', this%memoryPath, &
703 'AUX', this%input_mempath, '6.8.2')
704 end if
705 !
706 ! -- renamed at the package path: CELLID by IDM integration (#3021),
707 ! IFALLBACK and IFORCEFB by the legacy solver refactor (#2976)
708 call mem_alias_deprecated(this%gwfconn, 'CELLID', this%memoryPath, &
709 'GWFCONN', this%memoryPath, '6.8.2')
710 call mem_alias_deprecated(this%ilegacy, 'IFALLBACK', this%memoryPath, &
711 'ILEGACY', this%memoryPath, '6.8.2')
712 call mem_alias_deprecated(this%iforceleg, 'IFORCEFB', this%memoryPath, &
713 'IFORCELEG', this%memoryPath, '6.8.2')
Previous variable names checked in as deprecated aliases.
subroutine, public get_isize(name, mem_path, isize)
Get the number of elements for this variable.
Here is the call graph for this function:

◆ lak_cq()

subroutine lakmodule::lak_cq ( class(laktype), intent(inout) this,
real(dp), dimension(:), intent(in) x,
real(dp), dimension(:), intent(inout), contiguous flowja,
integer(i4b), intent(in), optional iadv )
private

Definition at line 4201 of file gwf-lak.f90.

4202 ! -- modules
4203 use tdismodule, only: delt
4204 ! -- dummy
4205 class(LakType), intent(inout) :: this
4206 real(DP), dimension(:), intent(in) :: x
4207 real(DP), dimension(:), contiguous, intent(inout) :: flowja
4208 integer(I4B), optional, intent(in) :: iadv
4209 ! -- local
4210 real(DP) :: rrate
4211 real(DP) :: chratin, chratout
4212 ! -- for budget
4213 integer(I4B) :: j, n, igwfnode
4214 real(DP) :: hlak, head, flow, dqdh
4215 real(DP) :: v0, v1, sa, sf
4216 !
4217 call this%lak_solve(update=.false.)
4218 !
4219 ! -- for the IMPLICIT formulation, report the lake terms with the same
4220 ! treatment that lak_fc_implicit assembled into the matrix, so the lake
4221 ! and gwf-cell budgets match the solved flows. lak_solve above set these
4222 ! from the substitution path (hard-cutoff seepage; availability-limited
4223 ! losses), which is correct for a lake on the legacy solver but
4224 ! not for an implicit lake, so overwrite them for the implicit
4225 ! (non-legacy) lakes only.
4226 if (this%iimplicit /= 0) then
4227 do n = 1, this%nlakes
4228 if (this%iboundpak(n) < 1 .or. this%ilegacy(n) /= 0) cycle
4229 hlak = this%xnewpak(n)
4230 !
4231 ! -- lakebed seepage: use the same exchange the matrix assembled
4232 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
4233 igwfnode = this%gwfconn(j)
4234 if (this%ibound(igwfnode) < 1) cycle
4235 head = this%xnew(igwfnode)
4236 call this%lak_calculate_conn_exchange_deriv(n, j, hlak, head, &
4237 flow, dqdh=dqdh)
4238 this%hcof(j) = -dqdh
4239 this%rhs(j) = -dqdh * head + flow
4240 end do
4241 !
4242 ! -- stage-driven losses: the matrix (lak_budget_nogwf) ramps
4243 ! evaporation and withdrawal toward zero as the lake approaches its
4244 ! bottom with the surfdep factor (sf) rather than the substitution
4245 ! solver's availability limiting, so report them the same way. This
4246 ! keeps the lake budget closed for a drying lake. (The outlet
4247 ! outflow is already near zero at the bottom, as its invert is above
4248 ! the lake bottom, and the storage term reflects the solved stage.)
4249 call this%lak_calculate_sarea(n, hlak, sa)
4250 sf = done
4251 if (this%surfdep > dzero) then
4252 sf = squadraticsaturation(this%lakebot(n) + this%surfdep, &
4253 this%lakebot(n), hlak)
4254 end if
4255 this%evap(n) = -this%evaporation(n) * sa * sf
4256 this%withr(n) = -this%withdrawal(n) * sf
4257 end do
4258 end if
4259 !
4260 ! -- call base functionality in bnd_cq. This will calculate lake-gwf flows
4261 ! and put them into this%simvals
4262 call this%BndType%bnd_cq(x, flowja, iadv=1)
4263 !
4264 ! -- calculate several budget terms
4265 chratin = dzero
4266 chratout = dzero
4267 do n = 1, this%nlakes
4268 this%chterm(n) = dzero
4269 if (this%iboundpak(n) == 0) cycle
4270 hlak = this%xnewpak(n)
4271 call this%lak_calculate_vol(n, hlak, v1)
4272 !
4273 ! -- add budget terms for active lakes
4274 if (this%iboundpak(n) /= 0) then
4275 !
4276 ! -- rainfall
4277 rrate = this%precip(n)
4278 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4279 !
4280 ! -- evaporation
4281 rrate = this%evap(n)
4282 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4283 !
4284 ! -- runoff
4285 rrate = this%runoff(n)
4286 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4287 !
4288 ! -- inflow
4289 rrate = this%inflow(n)
4290 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4291 !
4292 ! -- withdrawals
4293 rrate = this%withr(n)
4294 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4295 !
4296 ! -- add lake storage changes
4297 rrate = dzero
4298 if (this%iboundpak(n) > 0) then
4299 if (this%gwfiss /= 1) then
4300 call this%lak_calculate_vol(n, this%xoldpak(n), v0)
4301 rrate = -(v1 - v0) / delt
4302 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4303 end if
4304 end if
4305 this%qsto(n) = rrate
4306 !
4307 ! -- add external outlets
4308 call this%lak_get_external_outlet(n, rrate)
4309 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4310 !
4311 ! -- add mover terms
4312 if (this%imover == 1) then
4313 if (this%iboundpak(n) /= 0) then
4314 rrate = this%pakmvrobj%get_qfrommvr(n)
4315 else
4316 rrate = dzero
4317 end if
4318 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4319 end if
4320 end if
4321 end do
4322 !
4323 ! -- gwf flow and constant flow to lake
4324 do n = 1, this%nlakes
4325 rrate = dzero
4326 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
4327 ! simvals is from aquifer perspective, and so it is positive
4328 ! for flow into the aquifer. Need to switch sign for lake
4329 ! perspective.
4330 rrate = -this%simvals(j)
4331 this%qleak(j) = rrate
4332 if (this%iboundpak(n) /= 0) then
4333 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4334 end if
4335 end do
4336 end do
4337 !
4338 ! -- fill the budget object
4339 call this%lak_fill_budobj()
Here is the call graph for this function:

◆ lak_create()

subroutine, public lakmodule::lak_create ( class(bndtype), pointer packobj,
integer(i4b), intent(in) id,
integer(i4b), intent(in) ibcnum,
integer(i4b), intent(in) inunit,
integer(i4b), intent(in) iout,
character(len=*), intent(in) namemodel,
character(len=*), intent(in) pakname,
character(len=*), intent(in) mempath )

Definition at line 469 of file gwf-lak.f90.

471 ! -- modules
473 ! -- dummy
474 class(BndType), pointer :: packobj
475 integer(I4B), intent(in) :: id
476 integer(I4B), intent(in) :: ibcnum
477 integer(I4B), intent(in) :: inunit
478 integer(I4B), intent(in) :: iout
479 character(len=*), intent(in) :: namemodel
480 character(len=*), intent(in) :: pakname
481 character(len=*), intent(in) :: mempath
482 ! -- local
483 type(LakType), pointer :: lakobj
484 !
485 ! -- allocate the object and assign values to object variables
486 allocate (lakobj)
487 packobj => lakobj
488 !
489 ! -- create name and memory path
490 call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
491 packobj%text = text
492 !
493 ! -- allocate scalars
494 call lakobj%lak_allocate_scalars()
495 !
496 ! -- initialize package
497 call packobj%pack_initialize()
498 !
499 packobj%inunit = inunit
500 packobj%iout = iout
501 packobj%id = id
502 packobj%ibcnum = ibcnum
503 packobj%ncolbnd = 3
504 packobj%iscloc = 0 ! not supported
505 packobj%isadvpak = 1
506 packobj%ictMemPath = create_mem_path(namemodel, 'NPF')
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:
Here is the caller graph for this function:

◆ lak_da()

subroutine lakmodule::lak_da ( class(laktype) this)
private

Definition at line 4469 of file gwf-lak.f90.

4470 ! -- modules
4472 ! -- dummy
4473 class(LakType) :: this
4474 !
4475 ! -- nullify input context runtime pointers
4476 call this%input%destroy()
4477 !
4478 ! -- arrays
4479 deallocate (this%lakename)
4480 deallocate (this%status)
4481 deallocate (this%clakbudget)
4482 call mem_deallocate(this%dbuff)
4483 deallocate (this%cauxcbc)
4484 call mem_deallocate(this%qauxcbc)
4485 call mem_deallocate(this%qleak)
4486 call mem_deallocate(this%holdconn)
4487 call mem_deallocate(this%qsto)
4488 call mem_deallocate(this%denseterms)
4489 call mem_deallocate(this%viscratios)
4490 !
4491 ! -- tables
4492 if (this%ntables > 0) then
4493 call mem_deallocate(this%ialaktab)
4494 call mem_deallocate(this%tabstage)
4495 call mem_deallocate(this%tabvolume)
4496 call mem_deallocate(this%tabsarea)
4497 call mem_deallocate(this%tabwarea)
4498 end if
4499 !
4500 ! -- budobj
4501 call this%budobj%budgetobject_da()
4502 deallocate (this%budobj)
4503 nullify (this%budobj)
4504 !
4505 ! -- outlets
4506 if (this%noutlets > 0) then
4507 call mem_deallocate(this%lakein)
4508 call mem_deallocate(this%lakeout)
4509 call mem_deallocate(this%iouttype)
4510 ! -- outrate/outinvert/outwidth/outrough/outslope are live aliases
4511 ! into the input context's permanent arrays, not owned here
4512 call mem_deallocate(this%simoutrate)
4513 call mem_deallocate(this%outlet_invert_set)
4514 call mem_deallocate(this%outlet_width_set)
4515 call mem_deallocate(this%outlet_rough_set)
4516 call mem_deallocate(this%outlet_slope_set)
4517 end if
4518 !
4519 ! -- stage table
4520 if (this%iprhed > 0) then
4521 call this%stagetab%table_da()
4522 deallocate (this%stagetab)
4523 nullify (this%stagetab)
4524 end if
4525 !
4526 ! -- package csv table
4527 if (this%ipakcsv > 0) then
4528 if (associated(this%pakcsvtab)) then
4529 call this%pakcsvtab%table_da()
4530 deallocate (this%pakcsvtab)
4531 nullify (this%pakcsvtab)
4532 end if
4533 end if
4534 !
4535 ! -- scalars
4536 call mem_deallocate(this%iprhed)
4537 call mem_deallocate(this%istageout)
4538 call mem_deallocate(this%ibudgetout)
4539 call mem_deallocate(this%ibudcsv)
4540 call mem_deallocate(this%ipakcsv)
4541 if (allocated(this%pakcsvfile)) deallocate (this%pakcsvfile)
4542 call mem_deallocate(this%nlakes)
4543 call mem_deallocate(this%noutlets)
4544 call mem_deallocate(this%ntables)
4545 call mem_deallocate(this%convlength)
4546 call mem_deallocate(this%convtime)
4547 call mem_deallocate(this%outdmax)
4548 call mem_deallocate(this%igwhcopt)
4549 call mem_deallocate(this%iconvchk)
4550 call mem_deallocate(this%maxlakit)
4551 call mem_deallocate(this%surfdep)
4552 call mem_deallocate(this%dmaxchg)
4553 call mem_deallocate(this%delh)
4554 call mem_deallocate(this%check_attr)
4555 call mem_deallocate(this%iimplicit)
4556 call mem_deallocate(this%iforceleg)
4557 call mem_deallocate(this%iforceleglak)
4558 call mem_deallocate(this%moffset)
4559 call mem_deallocate(this%bditems)
4560 call mem_deallocate(this%cbcauxitems)
4561 call mem_deallocate(this%idense)
4562 !
4563 call mem_deallocate(this%nlakeconn)
4564 call mem_deallocate(this%idxlakeconn)
4565 call mem_deallocate(this%ntabrow)
4566 call mem_deallocate(this%strt)
4567 call mem_deallocate(this%laketop)
4568 call mem_deallocate(this%lakebot)
4569 call mem_deallocate(this%sareamax)
4570 ! -- stage/rainfall/evaporation/runoff/inflow/withdrawal are live aliases
4571 ! into the input context's permanent arrays, not owned here
4572 call mem_deallocate(this%avail)
4573 call mem_deallocate(this%lkgwsink)
4574 call mem_deallocate(this%ncncvr)
4575 call mem_deallocate(this%ilegacy)
4576 call mem_deallocate(this%nstuck)
4577 call mem_deallocate(this%surfin)
4578 call mem_deallocate(this%surfout)
4579 call mem_deallocate(this%surfout1)
4580 call mem_deallocate(this%precip)
4581 call mem_deallocate(this%precip1)
4582 call mem_deallocate(this%evap)
4583 call mem_deallocate(this%evap1)
4584 call mem_deallocate(this%evapo)
4585 call mem_deallocate(this%withr)
4586 call mem_deallocate(this%withr1)
4587 call mem_deallocate(this%flwin)
4588 call mem_deallocate(this%flwiter)
4589 call mem_deallocate(this%flwiter1)
4590 call mem_deallocate(this%seep)
4591 call mem_deallocate(this%seep1)
4592 call mem_deallocate(this%seep0)
4593 call mem_deallocate(this%stageiter)
4594 call mem_deallocate(this%chterm)
4595 !
4596 ! -- lake boundary and stages
4597 if (this%iimplicit == 0) then
4598 call mem_deallocate(this%iboundpak)
4599 call mem_deallocate(this%xnewpak)
4600 else
4601 ! -- iboundpak aliases the global ibound (not deallocated here); xnewpak
4602 ! was checked in to the global x vector
4603 call mem_deallocate(this%xnewpak, 'XNEWPAK', this%memoryPath)
4604 end if
4605 call mem_deallocate(this%xoldpak)
4606 !
4607 ! -- implicit-formulation matrix-mapping arrays
4608 call mem_deallocate(this%idxlocnode)
4609 call mem_deallocate(this%idxdiag)
4610 call mem_deallocate(this%idxoffdglo)
4611 call mem_deallocate(this%idxsymdglo)
4612 call mem_deallocate(this%idxsymoffdglo)
4613 call mem_deallocate(this%idxcellid)
4614 !
4615 ! -- lake iteration variables
4616 call mem_deallocate(this%iseepc)
4617 call mem_deallocate(this%idhc)
4618 call mem_deallocate(this%en1)
4619 call mem_deallocate(this%en2)
4620 call mem_deallocate(this%r1)
4621 call mem_deallocate(this%r2)
4622 call mem_deallocate(this%dh0)
4623 call mem_deallocate(this%s0)
4624 call mem_deallocate(this%qgwf0)
4625 !
4626 ! -- lake connection variables
4627 call mem_deallocate(this%imap)
4628 call mem_deallocate(this%gwfconn)
4629 call mem_deallocate(this%nodesontop)
4630 call mem_deallocate(this%ictype)
4631 call mem_deallocate(this%bedleak)
4632 call mem_deallocate(this%belev)
4633 call mem_deallocate(this%telev)
4634 call mem_deallocate(this%connlength)
4635 call mem_deallocate(this%connwidth)
4636 call mem_deallocate(this%sarea)
4637 call mem_deallocate(this%warea)
4638 call mem_deallocate(this%satcond)
4639 call mem_deallocate(this%simcond)
4640 call mem_deallocate(this%simlakgw)
4641 !
4642 ! -- pointers to gwf variables
4643 nullify (this%gwfiss)
4644 !
4645 ! -- Parent object
4646 call this%BndExtType%bnd_da()

◆ lak_df_obs()

subroutine lakmodule::lak_df_obs ( class(laktype) this)
private

Definition at line 4834 of file gwf-lak.f90.

4835 ! -- dummy
4836 class(LakType) :: this
4837 ! -- local
4838 integer(I4B) :: indx
4839 !
4840 ! -- Store obs type and assign procedure pointer
4841 ! for stage observation type.
4842 call this%obs%StoreObsType('stage', .false., indx)
4843 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4844 !
4845 ! -- Store obs type and assign procedure pointer
4846 ! for ext-inflow observation type.
4847 call this%obs%StoreObsType('ext-inflow', .true., indx)
4848 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4849 !
4850 ! -- Store obs type and assign procedure pointer
4851 ! for outlet-inflow observation type.
4852 call this%obs%StoreObsType('outlet-inflow', .true., indx)
4853 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4854 !
4855 ! -- Store obs type and assign procedure pointer
4856 ! for inflow observation type.
4857 call this%obs%StoreObsType('inflow', .true., indx)
4858 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4859 !
4860 ! -- Store obs type and assign procedure pointer
4861 ! for from-mvr observation type.
4862 call this%obs%StoreObsType('from-mvr', .true., indx)
4863 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4864 !
4865 ! -- Store obs type and assign procedure pointer
4866 ! for rainfall observation type.
4867 call this%obs%StoreObsType('rainfall', .true., indx)
4868 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4869 !
4870 ! -- Store obs type and assign procedure pointer
4871 ! for runoff observation type.
4872 call this%obs%StoreObsType('runoff', .true., indx)
4873 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4874 !
4875 ! -- Store obs type and assign procedure pointer
4876 ! for lak observation type.
4877 call this%obs%StoreObsType('lak', .true., indx)
4878 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4879 !
4880 ! -- Store obs type and assign procedure pointer
4881 ! for evaporation observation type.
4882 call this%obs%StoreObsType('evaporation', .true., indx)
4883 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4884 !
4885 ! -- Store obs type and assign procedure pointer
4886 ! for withdrawal observation type.
4887 call this%obs%StoreObsType('withdrawal', .true., indx)
4888 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4889 !
4890 ! -- Store obs type and assign procedure pointer
4891 ! for ext-outflow observation type.
4892 call this%obs%StoreObsType('ext-outflow', .true., indx)
4893 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4894 !
4895 ! -- Store obs type and assign procedure pointer
4896 ! for to-mvr observation type.
4897 call this%obs%StoreObsType('to-mvr', .true., indx)
4898 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4899 !
4900 ! -- Store obs type and assign procedure pointer
4901 ! for storage observation type.
4902 call this%obs%StoreObsType('storage', .true., indx)
4903 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4904 !
4905 ! -- Store obs type and assign procedure pointer
4906 ! for constant observation type.
4907 call this%obs%StoreObsType('constant', .true., indx)
4908 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4909 !
4910 ! -- Store obs type and assign procedure pointer
4911 ! for outlet observation type.
4912 call this%obs%StoreObsType('outlet', .true., indx)
4913 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4914 !
4915 ! -- Store obs type and assign procedure pointer
4916 ! for volume observation type.
4917 call this%obs%StoreObsType('volume', .true., indx)
4918 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4919 !
4920 ! -- Store obs type and assign procedure pointer
4921 ! for surface-area observation type.
4922 call this%obs%StoreObsType('surface-area', .true., indx)
4923 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4924 !
4925 ! -- Store obs type and assign procedure pointer
4926 ! for wetted-area observation type.
4927 call this%obs%StoreObsType('wetted-area', .true., indx)
4928 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid
4929 !
4930 ! -- Store obs type and assign procedure pointer
4931 ! for conductance observation type.
4932 call this%obs%StoreObsType('conductance', .true., indx)
4933 this%obs%obsData(indx)%ProcessIdPtr => lak_process_obsid

◆ lak_estimate_conn_exchange()

subroutine lakmodule::lak_estimate_conn_exchange ( class(laktype), intent(inout) this,
integer(i4b), intent(in) iflag,
integer(i4b), intent(in) ilak,
integer(i4b), intent(in) iconn,
integer(i4b), intent(inout) idry,
real(dp), intent(in) stage,
real(dp), intent(in) head,
real(dp), intent(inout) flow,
real(dp), intent(inout) source,
real(dp), intent(inout), optional gwfhcof,
real(dp), intent(inout), optional gwfrhs )
private

Definition at line 2456 of file gwf-lak.f90.

2458 ! -- dummy
2459 class(LakType), intent(inout) :: this
2460 integer(I4B), intent(in) :: iflag
2461 integer(I4B), intent(in) :: ilak
2462 integer(I4B), intent(in) :: iconn
2463 integer(I4B), intent(inout) :: idry
2464 real(DP), intent(in) :: stage
2465 real(DP), intent(in) :: head
2466 real(DP), intent(inout) :: flow
2467 real(DP), intent(inout) :: source
2468 real(DP), intent(inout), optional :: gwfhcof
2469 real(DP), intent(inout), optional :: gwfrhs
2470 ! -- local
2471 real(DP) :: gwfhcof0, gwfrhs0
2472 !
2473 flow = dzero
2474 idry = 0
2475 call this%lak_calculate_conn_exchange(ilak, iconn, stage, head, flow, &
2476 gwfhcof0, gwfrhs0)
2477 if (iflag == 1) then
2478 if (flow > dzero) then
2479 source = source + flow
2480 end if
2481 else if (iflag == 2) then
2482 if (-flow > source) then
2483 flow = -source
2484 source = dzero
2485 idry = 1
2486 else if (flow < dzero) then
2487 source = source + flow
2488 end if
2489 end if
2490 !
2491 ! -- Set gwfhcof and gwfrhs if present
2492 if (present(gwfhcof)) gwfhcof = gwfhcof0
2493 if (present(gwfrhs)) gwfrhs = gwfrhs0

◆ lak_estimate_seepage_single()

subroutine lakmodule::lak_estimate_seepage_single ( class(laktype), intent(inout) this,
integer(i4b), intent(in) n,
integer(i4b), intent(in) ncnv )
private

Runs the two-pass connection-seepage estimate for lake n at its current stage and the perturbed stage, accumulating thisseep(n)/thisseep1(n) and, on the final pass when ncnv == 0, the gwf-cell hcof/rhs contributions. Lakes do not couple within this estimate (each connection touches only its own lake's flwiter), so evaluating both passes per lake is equivalent to the all-lakes-per-pass ordering in lak_solve. Extracted from lak_solve so the same estimate can drive the single-lake legacy solve for the IMPLICIT formulation.

Definition at line 5763 of file gwf-lak.f90.

5764 ! -- dummy
5765 class(LakType), intent(inout) :: this
5766 integer(I4B), intent(in) :: n
5767 integer(I4B), intent(in) :: ncnv
5768 ! -- local
5769 integer(I4B) :: i
5770 integer(I4B) :: j
5771 integer(I4B) :: igwfnode
5772 integer(I4B) :: idry
5773 integer(I4B) :: idry1
5774 real(DP) :: hlak
5775 real(DP) :: head
5776 real(DP) :: qlakgw
5777 real(DP) :: qlakgw1
5778 real(DP) :: gwfhcof
5779 real(DP) :: gwfrhs
5780 real(DP) :: delh
5781 !
5782 delh = this%delh
5783 !
5784 ! -- skip inactive lakes
5785 if (this%iboundpak(n) == 0) return
5786 !
5787 estseep: do i = 1, 2
5788 ! - set xoldpak to xnewpak if steady-state
5789 if (this%gwfiss /= 0) then
5790 this%xoldpak(n) = this%xnewpak(n)
5791 end if
5792 hlak = this%xnewpak(n)
5793 calcconnseep: do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5794 igwfnode = this%gwfconn(j)
5795 head = this%xnew(igwfnode)
5796 if (this%ncncvr(n) /= 2) then
5797 if (this%ibound(igwfnode) > 0) then
5798 call this%lak_estimate_conn_exchange(i, n, j, idry, hlak, &
5799 head, qlakgw, &
5800 this%flwiter(n), &
5801 gwfhcof, gwfrhs)
5802 call this%lak_estimate_conn_exchange(i, n, j, idry1, &
5803 hlak + delh, head, qlakgw1, &
5804 this%flwiter1(n))
5805 !
5806 ! -- add to gwf matrix
5807 if (ncnv == 0 .and. i == 2) then
5808 if (j == this%maxbound) then
5809 this%ncncvr(n) = 2
5810 end if
5811 if (idry /= 1) then
5812 this%hcof(j) = gwfhcof
5813 this%rhs(j) = gwfrhs
5814 else
5815 this%hcof(j) = dzero
5816 this%rhs(j) = qlakgw
5817 end if
5818 end if
5819 if (i == 2) then
5820 this%seep(n) = this%seep(n) + qlakgw
5821 this%seep1(n) = this%seep1(n) + qlakgw1
5822 end if
5823 end if
5824 end if
5825 end do calcconnseep
5826 end do estseep

◆ lak_fc()

subroutine lakmodule::lak_fc ( class(laktype) this,
real(dp), dimension(:), intent(inout) rhs,
integer(i4b), dimension(:), intent(in) ia,
integer(i4b), dimension(:), intent(in) idxglo,
class(matrixbasetype), pointer matrix_sln )
private

Definition at line 3733 of file gwf-lak.f90.

3734 ! -- dummy
3735 class(LakType) :: this
3736 real(DP), dimension(:), intent(inout) :: rhs
3737 integer(I4B), dimension(:), intent(in) :: ia
3738 integer(I4B), dimension(:), intent(in) :: idxglo
3739 class(MatrixBaseType), pointer :: matrix_sln
3740 ! -- local
3741 integer(I4B) :: j, n
3742 integer(I4B) :: igwfnode
3743 integer(I4B) :: ipossymd
3744 !
3745 ! -- pakmvrobj fc
3746 if (this%imover == 1) then
3747 call this%pakmvrobj%fc()
3748 end if
3749 !
3750 ! -- implicit formulation: assemble the lake equations directly into the
3751 ! groundwater flow matrix instead of solving the stage by substitution
3752 if (this%iimplicit /= 0) then
3753 call this%lak_fc_implicit(rhs, matrix_sln)
3754 return
3755 end if
3756 !
3757 ! -- legacy formulation: solve the lake stage by substitution, then add the
3758 ! resulting lake-aquifer exchange terms to the groundwater flow matrix
3759 call this%lak_solve()
3760 do n = 1, this%nlakes
3761 if (this%iboundpak(n) == 0) cycle
3762 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3763 igwfnode = this%gwfconn(j)
3764 if (this%ibound(igwfnode) < 1) cycle
3765 ipossymd = idxglo(ia(igwfnode))
3766 call matrix_sln%add_value_pos(ipossymd, this%hcof(j))
3767 rhs(igwfnode) = rhs(igwfnode) + this%rhs(j)
3768 end do
3769 end do

◆ lak_fill_budobj()

subroutine lakmodule::lak_fill_budobj ( class(laktype) this)
private

Definition at line 6280 of file gwf-lak.f90.

6281 ! -- dummy
6282 class(LakType) :: this
6283 ! -- local
6284 integer(I4B) :: naux
6285 real(DP), dimension(:), allocatable :: auxvartmp
6286 !integer(I4B) :: i
6287 integer(I4B) :: j
6288 integer(I4B) :: n
6289 integer(I4B) :: n1
6290 integer(I4B) :: n2
6291 integer(I4B) :: ii
6292 integer(I4B) :: jj
6293 integer(I4B) :: idx
6294 integer(I4B) :: nlen
6295 real(DP) :: v, v1
6296 real(DP) :: q
6297 real(DP) :: lkstg, gwhead, wa
6298 !
6299 ! -- initialize counter
6300 idx = 0
6301
6302 ! -- FLOW JA FACE
6303 nlen = 0
6304 do n = 1, this%noutlets
6305 if (this%lakein(n) > 0 .and. this%lakeout(n) > 0) then
6306 nlen = nlen + 1
6307 end if
6308 end do
6309 if (nlen > 0) then
6310 idx = idx + 1
6311 call this%budobj%budterm(idx)%reset(2 * nlen)
6312 do n = 1, this%noutlets
6313 n1 = this%lakein(n)
6314 n2 = this%lakeout(n)
6315 if (n1 > 0 .and. n2 > 0) then
6316 q = this%simoutrate(n)
6317 if (this%imover == 1) then
6318 q = q + this%pakmvrobj%get_qtomvr(n)
6319 end if
6320 call this%budobj%budterm(idx)%update_term(n1, n2, q)
6321 call this%budobj%budterm(idx)%update_term(n2, n1, -q)
6322 end if
6323 end do
6324 end if
6325 !
6326 ! -- GWF (LEAKAGE)
6327 idx = idx + 1
6328 call this%budobj%budterm(idx)%reset(this%maxbound)
6329 do n = 1, this%nlakes
6330 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
6331 n2 = this%gwfconn(j)
6332 q = this%qleak(j)
6333 lkstg = this%xnewpak(n)
6334 ! -- For the case when the lak stage is exactly equal
6335 ! to the lake bottom, the wetted area is not returned
6336 ! equal to 0.0
6337 gwhead = this%xnew(n2)
6338 call this%lak_calculate_conn_warea(n, j, lkstg, gwhead, wa)
6339 ! -- For thermal conduction between a lake and a gw cell,
6340 ! the shared wetted area should be reset to zero when the lake
6341 ! stage is below the cell bottom
6342 if (this%belev(j) > lkstg) wa = dzero
6343 this%qauxcbc(1) = wa
6344 call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc)
6345 end do
6346 end do
6347 !
6348 ! -- RAIN
6349 idx = idx + 1
6350 call this%budobj%budterm(idx)%reset(this%nlakes)
6351 do n = 1, this%nlakes
6352 q = this%precip(n)
6353 call this%budobj%budterm(idx)%update_term(n, n, q)
6354 end do
6355 !
6356 ! -- EVAPORATION
6357 idx = idx + 1
6358 call this%budobj%budterm(idx)%reset(this%nlakes)
6359 do n = 1, this%nlakes
6360 q = this%evap(n)
6361 call this%budobj%budterm(idx)%update_term(n, n, q)
6362 end do
6363 !
6364 ! -- RUNOFF
6365 idx = idx + 1
6366 call this%budobj%budterm(idx)%reset(this%nlakes)
6367 do n = 1, this%nlakes
6368 q = this%runoff(n)
6369 call this%budobj%budterm(idx)%update_term(n, n, q)
6370 end do
6371 !
6372 ! -- INFLOW
6373 idx = idx + 1
6374 call this%budobj%budterm(idx)%reset(this%nlakes)
6375 do n = 1, this%nlakes
6376 q = this%inflow(n)
6377 call this%budobj%budterm(idx)%update_term(n, n, q)
6378 end do
6379 !
6380 ! -- WITHDRAWAL
6381 idx = idx + 1
6382 call this%budobj%budterm(idx)%reset(this%nlakes)
6383 do n = 1, this%nlakes
6384 q = this%withr(n)
6385 call this%budobj%budterm(idx)%update_term(n, n, q)
6386 end do
6387 !
6388 ! -- EXTERNAL OUTFLOW
6389 idx = idx + 1
6390 call this%budobj%budterm(idx)%reset(this%nlakes)
6391 do n = 1, this%nlakes
6392 call this%lak_get_external_outlet(n, q)
6393 ! subtract tomover from external outflow
6394 call this%lak_get_external_mover(n, v)
6395 q = q + v
6396 call this%budobj%budterm(idx)%update_term(n, n, q)
6397 end do
6398 !
6399 ! -- STORAGE
6400 idx = idx + 1
6401 call this%budobj%budterm(idx)%reset(this%nlakes)
6402 do n = 1, this%nlakes
6403 call this%lak_calculate_vol(n, this%xnewpak(n), v1)
6404 q = this%qsto(n)
6405 this%qauxcbc(1) = v1
6406 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
6407 end do
6408 !
6409 ! -- CONSTANT FLOW
6410 idx = idx + 1
6411 call this%budobj%budterm(idx)%reset(this%nlakes)
6412 do n = 1, this%nlakes
6413 q = this%chterm(n)
6414 call this%budobj%budterm(idx)%update_term(n, n, q)
6415 end do
6416 !
6417 ! -- MOVER
6418 if (this%imover == 1) then
6419 !
6420 ! -- FROM MOVER
6421 idx = idx + 1
6422 call this%budobj%budterm(idx)%reset(this%nlakes)
6423 do n = 1, this%nlakes
6424 q = this%pakmvrobj%get_qfrommvr(n)
6425 call this%budobj%budterm(idx)%update_term(n, n, q)
6426 end do
6427 !
6428 ! -- TO MOVER
6429 idx = idx + 1
6430 call this%budobj%budterm(idx)%reset(this%noutlets)
6431 do n = 1, this%noutlets
6432 n1 = this%lakein(n)
6433 q = this%pakmvrobj%get_qtomvr(n)
6434 if (q > dzero) then
6435 q = -q
6436 end if
6437 call this%budobj%budterm(idx)%update_term(n1, n1, q)
6438 end do
6439 !
6440 end if
6441 !
6442 ! -- AUXILIARY VARIABLES
6443 naux = this%naux
6444 if (naux > 0) then
6445 idx = idx + 1
6446 allocate (auxvartmp(naux))
6447 call this%budobj%budterm(idx)%reset(this%nlakes)
6448 do n = 1, this%nlakes
6449 q = dzero
6450 do jj = 1, naux
6451 ii = n
6452 auxvartmp(jj) = this%featureauxvar(jj, ii)
6453 end do
6454 call this%budobj%budterm(idx)%update_term(n, n, q, auxvartmp)
6455 end do
6456 deallocate (auxvartmp)
6457 end if
6458 !
6459 ! --Terms are filled, now accumulate them for this time step
6460 call this%budobj%accumulate_terms()

◆ lak_fn()

subroutine lakmodule::lak_fn ( class(laktype) this,
real(dp), dimension(:), intent(inout) rhs,
integer(i4b), dimension(:), intent(in) ia,
integer(i4b), dimension(:), intent(in) idxglo,
class(matrixbasetype), pointer matrix_sln )
private

Definition at line 3774 of file gwf-lak.f90.

3775 ! -- dummy
3776 class(LakType) :: this
3777 real(DP), dimension(:), intent(inout) :: rhs
3778 integer(I4B), dimension(:), intent(in) :: ia
3779 integer(I4B), dimension(:), intent(in) :: idxglo
3780 class(MatrixBaseType), pointer :: matrix_sln
3781 ! -- local
3782 integer(I4B) :: j, n
3783 integer(I4B) :: ipos
3784 integer(I4B) :: igwfnode
3785 integer(I4B) :: idry
3786 real(DP) :: hlak
3787 real(DP) :: avail
3788 real(DP) :: ra
3789 real(DP) :: ro
3790 real(DP) :: qinf
3791 real(DP) :: ex
3792 real(DP) :: head
3793 real(DP) :: q
3794 real(DP) :: q1
3795 real(DP) :: rterm
3796 real(DP) :: drterm
3797 !
3798 ! -- implicit formulation: the lakebed seepage Jacobian is already
3799 ! assembled exactly in lak_fc_implicit for constant-conductance
3800 ! (confined / saturated) connections. Nonlinear conductance Newton terms
3801 ! are Phase 2.
3802 if (this%iimplicit /= 0) then
3803 return
3804 end if
3805 !
3806 do n = 1, this%nlakes
3807 if (this%iboundpak(n) == 0) cycle
3808 hlak = this%xnewpak(n)
3809 call this%lak_calculate_available(n, hlak, avail, &
3810 ra, ro, qinf, ex, this%delh)
3811 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3812 igwfnode = this%gwfconn(j)
3813 ipos = ia(igwfnode)
3814 head = this%xnew(igwfnode)
3815 if (-this%hcof(j) > dzero) then
3816 if (this%ibound(igwfnode) > 0) then
3817 ! -- estimate lake-aquifer exchange with perturbed groundwater head
3818 ! exchange is relative to the lake
3819 !avail = DEP20
3820 call this%lak_estimate_conn_exchange(2, n, j, idry, hlak, &
3821 head + this%delh, q1, avail)
3822 q1 = -q1
3823 ! -- calculate unperturbed lake-aquifer exchange
3824 q = this%hcof(j) * head - this%rhs(j)
3825 ! -- calculate rterm
3826 rterm = this%hcof(j) * head
3827 ! -- calculate derivative
3828 drterm = (q1 - q) / this%delh
3829 ! -- add terms to convert conductance formulation into
3830 ! newton-raphson formulation
3831 call matrix_sln%add_value_pos(idxglo(ipos), drterm - this%hcof(j))
3832 rhs(igwfnode) = rhs(igwfnode) - rterm + drterm * head
3833 end if
3834 end if
3835 end do
3836 end do

◆ lak_get_external_mover()

subroutine lakmodule::lak_get_external_mover ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) outoutf )
private

Definition at line 2815 of file gwf-lak.f90.

2816 ! -- dummy
2817 class(LakType), intent(inout) :: this
2818 integer(I4B), intent(in) :: ilak
2819 real(DP), intent(inout) :: outoutf
2820 ! -- local
2821 integer(I4B) :: n
2822 !
2823 outoutf = dzero
2824 if (this%imover == 1) then
2825 do n = 1, this%noutlets
2826 if (this%lakein(n) == ilak) then
2827 if (this%lakeout(n) > 0) cycle
2828 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2829 end if
2830 end do
2831 end if

◆ lak_get_external_outlet()

subroutine lakmodule::lak_get_external_outlet ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) outoutf )
private

Definition at line 2796 of file gwf-lak.f90.

2797 ! -- dummy
2798 class(LakType), intent(inout) :: this
2799 integer(I4B), intent(in) :: ilak
2800 real(DP), intent(inout) :: outoutf
2801 ! -- local
2802 integer(I4B) :: n
2803 !
2804 outoutf = dzero
2805 do n = 1, this%noutlets
2806 if (this%lakein(n) == ilak) then
2807 if (this%lakeout(n) > 0) cycle
2808 outoutf = outoutf + this%simoutrate(n)
2809 end if
2810 end do

◆ lak_get_internal_inlet()

subroutine lakmodule::lak_get_internal_inlet ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) outinf )
private

Definition at line 2756 of file gwf-lak.f90.

2757 ! -- dummy
2758 class(LakType), intent(inout) :: this
2759 integer(I4B), intent(in) :: ilak
2760 real(DP), intent(inout) :: outinf
2761 ! -- local
2762 integer(I4B) :: n
2763 !
2764 outinf = dzero
2765 do n = 1, this%noutlets
2766 if (this%lakeout(n) == ilak) then
2767 outinf = outinf - this%simoutrate(n)
2768 if (this%imover == 1) then
2769 outinf = outinf - this%pakmvrobj%get_qtomvr(n)
2770 end if
2771 end if
2772 end do

◆ lak_get_internal_mover()

subroutine lakmodule::lak_get_internal_mover ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) outoutf )
private

Definition at line 2836 of file gwf-lak.f90.

2837 ! -- dummy
2838 class(LakType), intent(inout) :: this
2839 integer(I4B), intent(in) :: ilak
2840 real(DP), intent(inout) :: outoutf
2841 ! -- local
2842 integer(I4B) :: n
2843 !
2844 outoutf = dzero
2845 if (this%imover == 1) then
2846 do n = 1, this%noutlets
2847 if (this%lakein(n) == ilak) then
2848 if (this%lakeout(n) < 1) cycle
2849 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2850 end if
2851 end do
2852 end if

◆ lak_get_internal_outlet()

subroutine lakmodule::lak_get_internal_outlet ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) outoutf )
private

Definition at line 2777 of file gwf-lak.f90.

2778 ! -- dummy
2779 class(LakType), intent(inout) :: this
2780 integer(I4B), intent(in) :: ilak
2781 real(DP), intent(inout) :: outoutf
2782 ! -- local
2783 integer(I4B) :: n
2784 !
2785 outoutf = dzero
2786 do n = 1, this%noutlets
2787 if (this%lakein(n) == ilak) then
2788 if (this%lakeout(n) < 1) cycle
2789 outoutf = outoutf + this%simoutrate(n)
2790 end if
2791 end do

◆ lak_get_outlet_tomover()

subroutine lakmodule::lak_get_outlet_tomover ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(inout) outoutf )
private

Definition at line 2857 of file gwf-lak.f90.

2858 ! -- dummy
2859 class(LakType), intent(inout) :: this
2860 integer(I4B), intent(in) :: ilak
2861 real(DP), intent(inout) :: outoutf
2862 ! -- local
2863 integer(I4B) :: n
2864 !
2865 outoutf = dzero
2866 if (this%imover == 1) then
2867 do n = 1, this%noutlets
2868 if (this%lakein(n) == ilak) then
2869 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2870 end if
2871 end do
2872 end if

◆ lak_input_destroy()

subroutine lakmodule::lak_input_destroy ( class(lakinputtype), intent(inout) this)
private

Definition at line 3258 of file gwf-lak.f90.

3259 ! -- dummy
3260 class(LakInputType), intent(inout) :: this
3261 !
3262 nullify (this%nbound)
3263 nullify (this%ifno)
3264 nullify (this%setting)
3265 nullify (this%status)
3266 nullify (this%auxname)
3267 nullify (this%auxval)
3268 nullify (this%outletno)
3269 nullify (this%outlets_invert)
3270 nullify (this%outlets_width)
3271 nullify (this%outlets_rough)
3272 nullify (this%outlets_slope)
3273 nullify (this%invert_tslink)
3274 nullify (this%width_tslink)
3275 nullify (this%rough_tslink)
3276 nullify (this%slope_tslink)

◆ lak_input_init()

subroutine lakmodule::lak_input_init ( class(lakinputtype), intent(inout) this,
character(len=*), intent(in) mempath,
integer(i4b), intent(in) naux,
integer(i4b), intent(in) noutlets )
private

Called once from lak_ar; pointers remain valid for the simulation lifetime. Input tsmanager advances TS-linked values transparently each timestep.

Definition at line 3215 of file gwf-lak.f90.

3217 ! -- dummy
3218 class(LakInputType), intent(inout) :: this
3219 character(len=*), intent(in) :: mempath
3220 integer(I4B), intent(in) :: naux
3221 integer(I4B), intent(in) :: noutlets
3222 ! -- local
3223 integer(I4B), dimension(:, :), pointer, contiguous :: tslink => null()
3224 type(CharacterStringType), dimension(:), pointer, contiguous :: &
3225 tslinkvars => null()
3226 integer(I4B) :: n
3227 !
3228 ! -- period
3229 call mem_setptr(this%nbound, 'NBOUND', mempath)
3230 call mem_setptr(this%ifno, 'IFNO', mempath)
3231 call mem_setptr(this%setting, 'SETTING', mempath)
3232 call mem_setptr(this%status, 'STATUS', mempath)
3233 if (naux > 0) then
3234 call mem_setptr(this%auxname, 'AUXNAME', mempath)
3235 call mem_setptr(this%auxval, 'AUXVAL', mempath)
3236 end if
3237 ! -- outlets
3238 if (noutlets > 0) then
3239 call mem_setptr(this%outletno, 'OUTLETS_OUTLETNO', mempath)
3240 call mem_setptr(this%outlets_invert, 'OUTLETS_INVERT', mempath)
3241 call mem_setptr(this%outlets_width, 'OUTLETS_WIDTH', mempath)
3242 call mem_setptr(this%outlets_rough, 'OUTLETS_ROUGH', mempath)
3243 call mem_setptr(this%outlets_slope, 'OUTLETS_SLOPE', mempath)
3244 call mem_setptr(tslink, 'TSLINK_OL', mempath)
3245 call mem_setptr(tslinkvars, 'TSLINKVARS_OL', mempath)
3246 do n = 1, size(tslinkvars)
3247 if (tslinkvars(n) == 'OUTLETS_INVERT') &
3248 this%invert_tslink => tslink(n, :)
3249 if (tslinkvars(n) == 'OUTLETS_WIDTH') this%width_tslink => tslink(n, :)
3250 if (tslinkvars(n) == 'OUTLETS_ROUGH') this%rough_tslink => tslink(n, :)
3251 if (tslinkvars(n) == 'OUTLETS_SLOPE') this%slope_tslink => tslink(n, :)
3252 end do
3253 end if

◆ lak_linear_interpolation()

subroutine lakmodule::lak_linear_interpolation ( class(laktype), intent(inout) this,
integer(i4b), intent(in) n,
real(dp), dimension(n), intent(in) x,
real(dp), dimension(n), intent(in) y,
real(dp), intent(in) z,
real(dp), intent(inout) v )
private

Function assumes x data is sorted in ascending order

Definition at line 1990 of file gwf-lak.f90.

1991 ! -- dummy
1992 class(LakType), intent(inout) :: this
1993 integer(I4B), intent(in) :: n
1994 real(DP), dimension(n), intent(in) :: x
1995 real(DP), dimension(n), intent(in) :: y
1996 real(DP), intent(in) :: z
1997 real(DP), intent(inout) :: v
1998 ! -- local
1999 integer(I4B) :: i
2000 real(DP) :: dx, dydx
2001 ! code
2002 v = dzero
2003 ! below bottom of range - set to lowest value
2004 if (z <= x(1)) then
2005 v = y(1)
2006 ! above highest value
2007 ! slope calculated from interval between n and n-1
2008 else if (z > x(n)) then
2009 dx = x(n) - x(n - 1)
2010 dydx = dzero
2011 if (abs(dx) > dzero) then
2012 dydx = (y(n) - y(n - 1)) / dx
2013 end if
2014 dx = (z - x(n))
2015 v = y(n) + dydx * dx
2016 ! between lowest and highest value in current interval
2017 else
2018 do i = 2, n
2019 dx = x(i) - x(i - 1)
2020 dydx = dzero
2021 if (z >= x(i - 1) .and. z <= x(i)) then
2022 if (abs(dx) > dzero) then
2023 dydx = (y(i) - y(i - 1)) / dx
2024 end if
2025 dx = (z - x(i - 1))
2026 v = y(i - 1) + dydx * dx
2027 exit
2028 end if
2029 end do
2030 end if

◆ lak_mc()

subroutine lakmodule::lak_mc ( class(laktype), intent(inout) this,
integer(i4b), intent(in) moffset,
class(matrixbasetype), pointer matrix_sln )
private

Implicit formulation only. Finds the position in the assembled matrix of each lake-row diagonal, lake-to-cell, cell diagonal, and cell-to-lake entry and stores them in the idx* arrays so they can be filled during assembly.

Definition at line 4753 of file gwf-lak.f90.

4755 ! -- dummy
4756 class(LakType), intent(inout) :: this
4757 integer(I4B), intent(in) :: moffset
4758 class(MatrixBaseType), pointer :: matrix_sln
4759 ! -- local
4760 integer(I4B) :: n
4761 integer(I4B) :: j
4762 integer(I4B) :: iglo
4763 integer(I4B) :: jglo
4764 integer(I4B) :: ipos
4765 !
4766 ! -- the connection-mapping vectors are only used by the implicit
4767 ! formulation; allocate them at size 0 otherwise so legacy LAK runs do not
4768 ! pay the maxbound memory cost (lak_da stays symmetric either way)
4769 if (this%iimplicit == 0) then
4770 call mem_allocate(this%idxlocnode, 0, 'IDXLOCNODE', this%memoryPath)
4771 call mem_allocate(this%idxdiag, 0, 'IDXDIAG', this%memoryPath)
4772 call mem_allocate(this%idxoffdglo, 0, 'IDXOFFDGLO', this%memoryPath)
4773 call mem_allocate(this%idxsymdglo, 0, 'IDXSYMDGLO', this%memoryPath)
4774 call mem_allocate(this%idxsymoffdglo, 0, 'IDXSYMOFFDGLO', this%memoryPath)
4775 call mem_allocate(this%idxcellid, 0, 'IDXCELLID', this%memoryPath)
4776 return
4777 end if
4778 call mem_allocate(this%idxlocnode, this%nlakes, 'IDXLOCNODE', &
4779 this%memoryPath)
4780 call mem_allocate(this%idxdiag, this%nlakes, 'IDXDIAG', this%memoryPath)
4781 call mem_allocate(this%idxoffdglo, this%maxbound, 'IDXOFFDGLO', &
4782 this%memoryPath)
4783 call mem_allocate(this%idxsymdglo, this%maxbound, 'IDXSYMDGLO', &
4784 this%memoryPath)
4785 call mem_allocate(this%idxsymoffdglo, this%maxbound, 'IDXSYMOFFDGLO', &
4786 this%memoryPath)
4787 call mem_allocate(this%idxcellid, this%maxbound, 'IDXCELLID', &
4788 this%memoryPath)
4789 this%moffset = moffset
4790 !
4791 ! -- lake rows: a per-lake diagonal position and the per-connection
4792 ! lake->cell off-diagonals.
4793 ipos = 1
4794 do n = 1, this%nlakes
4795 iglo = moffset + this%dis%nodes + this%ioffset + n
4796 this%idxlocnode(n) = this%dis%nodes + this%ioffset + n
4797 this%idxdiag(n) = matrix_sln%get_position_diag(iglo)
4798 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
4799 jglo = this%gwfconn(j) + moffset
4800 this%idxcellid(ipos) = this%gwfconn(j)
4801 this%idxoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
4802 ipos = ipos + 1
4803 end do
4804 end do
4805 !
4806 ! -- lake contributions to the gwf portion of the global matrix
4807 ipos = 1
4808 do n = 1, this%nlakes
4809 jglo = moffset + this%dis%nodes + this%ioffset + n
4810 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
4811 iglo = this%gwfconn(j) + moffset
4812 this%idxsymdglo(ipos) = matrix_sln%get_position_diag(iglo)
4813 this%idxsymoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
4814 ipos = ipos + 1
4815 end do
4816 end do

◆ lak_nur()

subroutine lakmodule::lak_nur ( class(laktype), intent(inout) this,
integer(i4b), intent(in) neqpak,
real(dp), dimension(neqpak), intent(inout) x,
real(dp), dimension(neqpak), intent(in) xtemp,
real(dp), dimension(neqpak), intent(inout) dx,
integer(i4b), intent(inout) inewtonur,
real(dp), intent(inout) dxmax,
integer(i4b), intent(inout) locmax )
private

Implicit formulation only. The model Newton under-relaxation step (gwf_nur) calls this routine with the lake-stage part of the solution. If an updated stage falls below the lake bottom, it is relaxed back toward the bottom (90 percent of the way) and its change is zeroed. Active only when the model uses NEWTON UNDER_RELAXATION.

Definition at line 3847 of file gwf-lak.f90.

3848 ! -- dummy
3849 class(LakType), intent(inout) :: this
3850 integer(I4B), intent(in) :: neqpak
3851 real(DP), dimension(neqpak), intent(inout) :: x
3852 real(DP), dimension(neqpak), intent(in) :: xtemp
3853 real(DP), dimension(neqpak), intent(inout) :: dx
3854 integer(I4B), intent(inout) :: inewtonur
3855 real(DP), intent(inout) :: dxmax
3856 integer(I4B), intent(inout) :: locmax
3857 ! -- local
3858 integer(I4B) :: n
3859 real(DP) :: botl
3860 real(DP) :: xx
3861 real(DP) :: dxx
3862 !
3863 ! -- only the implicit formulation has the lake stage in the global solution
3864 if (this%iimplicit == 0) return
3865 !
3866 ! -- Newton-Raphson under-relaxation: hold the stage at the lake bottom
3867 do n = 1, this%nlakes
3868 if (this%iboundpak(n) < 1) cycle
3869 botl = this%lakebot(n)
3870 !
3871 ! -- only apply under-relaxation if the updated stage is below the bottom
3872 ! of the lake
3873 if (x(n) < botl) then
3874 inewtonur = 1
3875 xx = xtemp(n) * (done - dp9) + botl * dp9
3876 dxx = x(n) - xx
3877 if (abs(dxx) > abs(dxmax)) then
3878 locmax = n
3879 dxmax = dxx
3880 end if
3881 x(n) = xx
3882 dx(n) = dzero
3883 end if
3884 end do

◆ lak_obs_supported()

logical function lakmodule::lak_obs_supported ( class(laktype) this)
private

Return true because LAK package supports observations. Overrides BndTypebnd_obs_supported()

Definition at line 4824 of file gwf-lak.f90.

4825 ! -- dummy
4826 class(LakType) :: this
4827 !
4828 lak_obs_supported = .true.

◆ lak_ot_bdsummary()

subroutine lakmodule::lak_ot_bdsummary ( class(laktype) this,
integer(i4b), intent(in) kstp,
integer(i4b), intent(in) kper,
integer(i4b), intent(in) iout,
integer(i4b), intent(in) ibudfl )
private
Parameters
thisLakType object
[in]kstptime step number
[in]kperperiod number
[in]ioutflag and unit number for the model listing file
[in]ibudflflag indicating budget should be written

Definition at line 4454 of file gwf-lak.f90.

4455 ! -- module
4456 use tdismodule, only: totim, delt
4457 ! -- dummy
4458 class(LakType) :: this !< LakType object
4459 integer(I4B), intent(in) :: kstp !< time step number
4460 integer(I4B), intent(in) :: kper !< period number
4461 integer(I4B), intent(in) :: iout !< flag and unit number for the model listing file
4462 integer(I4B), intent(in) :: ibudfl !< flag indicating budget should be written
4463 !
4464 call this%budobj%write_budtable(kstp, kper, iout, ibudfl, totim, delt)

◆ lak_ot_dv()

subroutine lakmodule::lak_ot_dv ( class(laktype) this,
integer(i4b), intent(in) idvsave,
integer(i4b), intent(in) idvprint )
private

Definition at line 4383 of file gwf-lak.f90.

4384 use tdismodule, only: kstp, kper, pertim, totim
4385 use constantsmodule, only: dhnoflo, dhdry
4386 use inputoutputmodule, only: ulasav
4387 class(LakType) :: this
4388 integer(I4B), intent(in) :: idvsave
4389 integer(I4B), intent(in) :: idvprint
4390 integer(I4B) :: ibinun
4391 integer(I4B) :: n
4392 real(DP) :: v
4393 real(DP) :: d
4394 real(DP) :: stage
4395 real(DP) :: sa
4396 real(DP) :: wa
4397 !
4398 ! -- set unit number for binary dependent variable output
4399 ibinun = 0
4400 if (this%istageout /= 0) then
4401 ibinun = this%istageout
4402 end if
4403 if (idvsave == 0) ibinun = 0
4404 !
4405 ! -- write lake binary output
4406 if (ibinun > 0) then
4407 do n = 1, this%nlakes
4408 v = this%xnewpak(n)
4409 d = v - this%lakebot(n)
4410 if (this%iboundpak(n) == 0) then
4411 v = dhnoflo
4412 else if (d <= dzero) then
4413 v = dhdry
4414 end if
4415 this%dbuff(n) = v
4416 end do
4417 call ulasav(this%dbuff, ' STAGE', kstp, kper, pertim, totim, &
4418 this%nlakes, 1, 1, ibinun)
4419 end if
4420 !
4421 ! -- Print lake stage table
4422 if (idvprint /= 0 .and. this%iprhed /= 0) then
4423 !
4424 ! -- set table kstp and kper
4425 call this%stagetab%set_kstpkper(kstp, kper)
4426 !
4427 ! -- write data
4428 do n = 1, this%nlakes
4429 if (this%iboundpak(n) == 0) then
4430 stage = dhnoflo
4431 sa = dhnoflo
4432 wa = dhnoflo
4433 v = dhnoflo
4434 else
4435 stage = this%xnewpak(n)
4436 call this%lak_calculate_sarea(n, stage, sa)
4437 call this%lak_calculate_warea(n, stage, wa)
4438 call this%lak_calculate_vol(n, stage, v)
4439 end if
4440 if (this%inamedbound == 1) then
4441 call this%stagetab%add_term(this%lakename(n))
4442 end if
4443 call this%stagetab%add_term(n)
4444 call this%stagetab%add_term(stage)
4445 call this%stagetab%add_term(sa)
4446 call this%stagetab%add_term(wa)
4447 call this%stagetab%add_term(v)
4448 end do
4449 end if
real(dp), parameter dhdry
real dry cell constant
Definition Constants.f90:94
real(dp), parameter dhnoflo
real no flow constant
Definition Constants.f90:93
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
subroutine, public ulasav(buf, text, kstp, kper, pertim, totim, ncol, nrow, ilay, ichn)
Save 1 layer array on disk.
real(dp), pointer, public pertim
time relative to start of stress period
Definition tdis.f90:33
Here is the call graph for this function:

◆ lak_ot_model_flows()

subroutine lakmodule::lak_ot_model_flows ( class(laktype) this,
integer(i4b), intent(in) icbcfl,
integer(i4b), intent(in) ibudfl,
integer(i4b), intent(in) icbcun,
integer(i4b), dimension(:), intent(in), optional imap )
private

Definition at line 4370 of file gwf-lak.f90.

4371 class(LakType) :: this
4372 integer(I4B), intent(in) :: icbcfl
4373 integer(I4B), intent(in) :: ibudfl
4374 integer(I4B), intent(in) :: icbcun
4375 integer(I4B), dimension(:), optional, intent(in) :: imap
4376 !
4377 ! -- write the flows from the budobj
4378 call this%BndType%bnd_ot_model_flows(icbcfl, ibudfl, icbcun, this%imap)

◆ lak_ot_package_flows()

subroutine lakmodule::lak_ot_package_flows ( class(laktype) this,
integer(i4b), intent(in) icbcfl,
integer(i4b), intent(in) ibudfl )
private

Definition at line 4344 of file gwf-lak.f90.

4345 use tdismodule, only: kstp, kper, delt, pertim, totim
4346 class(LakType) :: this
4347 integer(I4B), intent(in) :: icbcfl
4348 integer(I4B), intent(in) :: ibudfl
4349 integer(I4B) :: ibinun
4350 !
4351 ! -- write the flows from the budobj
4352 ibinun = 0
4353 if (this%ibudgetout /= 0) then
4354 ibinun = this%ibudgetout
4355 end if
4356 if (icbcfl == 0) ibinun = 0
4357 if (ibinun > 0) then
4358 call this%budobj%save_flows(this%dis, ibinun, kstp, kper, delt, &
4359 pertim, totim, this%iout)
4360 end if
4361 !
4362 ! -- Print lake flows table
4363 if (ibudfl /= 0 .and. this%iprflow /= 0) then
4364 call this%budobj%write_flowtable(this%dis, kstp, kper)
4365 end if

◆ lak_outlet_outflow_rate()

subroutine lakmodule::lak_outlet_outflow_rate ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) stage,
real(dp), intent(inout) qout )
private

Side-effect-free companion to lak_calculate_outlet_outflow used by the implicit formulation: returns the summed (negative) rating-curve outflow for all outlets whose source is ilak, without applying the available-water cap or updating simoutrate. Used to linearize the outlet-outflow sink on the lake row in stage.

Definition at line 2717 of file gwf-lak.f90.

2718 ! -- dummy
2719 class(LakType), intent(inout) :: this
2720 integer(I4B), intent(in) :: ilak
2721 real(DP), intent(in) :: stage
2722 real(DP), intent(inout) :: qout
2723 ! -- local
2724 integer(I4B) :: n
2725 real(DP) :: g, d, c, gsm, rate
2726 !
2727 qout = dzero
2728 do n = 1, this%noutlets
2729 if (this%lakein(n) /= ilak) cycle
2730 rate = dzero
2731 d = stage - this%outinvert(n)
2732 if (this%outdmax > dzero .and. d > this%outdmax) d = this%outdmax
2733 g = dgravity * this%convlength * this%convtime * this%convtime
2734 select case (this%iouttype(n))
2735 case (0) ! specified rate
2736 rate = this%outrate(n)
2737 case (1) ! manning
2738 if (d > dzero) then
2739 c = (this%convlength**donethird) * this%convtime
2740 gsm = dzero
2741 if (this%outrough(n) > dzero) gsm = done / this%outrough(n)
2742 rate = -c * gsm * this%outwidth(n) * (d**dfivethirds) * &
2743 sqrt(this%outslope(n))
2744 end if
2745 case (2) ! weir
2746 if (d > dzero) then
2747 rate = -dtwothirds * dcd * this%outwidth(n) * d * sqrt(dtwo * g * d)
2748 end if
2749 end select
2750 qout = qout + rate
2751 end do

◆ lak_process_obsid()

subroutine lakmodule::lak_process_obsid ( type(observetype), intent(inout) obsrv,
class(disbasetype), intent(in) dis,
integer(i4b), intent(in) inunitobs,
integer(i4b), intent(in) iout )
private

Definition at line 5264 of file gwf-lak.f90.

5265 ! -- dummy
5266 type(ObserveType), intent(inout) :: obsrv
5267 class(DisBaseType), intent(in) :: dis
5268 integer(I4B), intent(in) :: inunitobs
5269 integer(I4B), intent(in) :: iout
5270 ! -- local
5271 integer(I4B) :: nn1, nn2
5272 integer(I4B) :: icol, istart, istop
5273 character(len=LINELENGTH) :: string
5274 character(len=LENBOUNDNAME) :: bndname
5275 !
5276 string = obsrv%IDstring
5277 ! -- Extract lake number from string and store it.
5278 ! If 1st item is not an integer(I4B), it should be a
5279 ! lake name--deal with it.
5280 icol = 1
5281 ! -- get lake number or boundary name
5282 call extract_idnum_or_bndname(string, icol, istart, istop, nn1, bndname)
5283 if (nn1 == namedboundflag) then
5284 obsrv%FeatureName = bndname
5285 else
5286 if (obsrv%ObsTypeId == 'LAK' .or. obsrv%ObsTypeId == 'CONDUCTANCE' .or. &
5287 obsrv%ObsTypeId == 'WETTED-AREA') then
5288 call extract_idnum_or_bndname(string, icol, istart, istop, nn2, bndname)
5289 if (len_trim(bndname) < 1 .and. nn2 < 0) then
5290 write (errmsg, '(a,1x,a,a,1x,a,1x,a)') &
5291 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
5292 ', ID given as an integer and not as boundname,', &
5293 'but ID2 (iconn) is missing. Either change ID to valid', &
5294 'boundname or supply valid entry for ID2.'
5295 call store_error(errmsg)
5296 end if
5297 if (nn2 == namedboundflag) then
5298 obsrv%FeatureName = bndname
5299 ! -- reset nn1
5300 nn1 = nn2
5301 else
5302 obsrv%NodeNumber2 = nn2
5303 end if
5304 end if
5305 end if
5306 ! -- store lake number (NodeNumber)
5307 obsrv%NodeNumber = nn1

◆ lak_read_initial_attr()

subroutine lakmodule::lak_read_initial_attr ( class(laktype), intent(inout) this)
private

Definition at line 1728 of file gwf-lak.f90.

1729 use constantsmodule, only: linelength
1732 ! -- dummy
1733 class(LakType), intent(inout) :: this
1734 ! -- local
1735 integer(I4B) :: j, n
1736 integer(I4B) :: nn
1737 integer(I4B) :: idx
1738 real(DP) :: top
1739 real(DP) :: bot
1740 real(DP) :: k
1741 real(DP) :: area
1742 real(DP) :: length
1743 real(DP) :: s
1744 real(DP) :: dx
1745 real(DP) :: c
1746 real(DP) :: sa
1747 real(DP) :: wa
1748 real(DP) :: v
1749 real(DP) :: fact
1750 real(DP) :: c1
1751 real(DP) :: c2
1752 real(DP), allocatable, dimension(:) :: clb, caq
1753 character(len=14) :: cbedleak
1754 character(len=14) :: cbedcond
1755 character(len=10), dimension(0:3) :: ctype
1756 character(len=15) :: nodestr
1757 ! -- data
1758 data ctype(0)/'VERTICAL '/
1759 data ctype(1)/'HORIZONTAL'/
1760 data ctype(2)/'EMBEDDEDH '/
1761 data ctype(3)/'EMBEDDEDV '/
1762 !
1763 ! -- initialize xnewpak and set stage
1764 do n = 1, this%nlakes
1765 this%xnewpak(n) = this%strt(n)
1766 this%stage(n) = this%strt(n)
1767 end do
1768 !
1769 ! -- initialize status (iboundpak) of lakes to active
1770 do n = 1, this%nlakes
1771 if (this%status(n) == 'CONSTANT') then
1772 this%iboundpak(n) = -1
1773 else if (this%status(n) == 'INACTIVE') then
1774 this%iboundpak(n) = 0
1775 else if (this%status(n) == 'ACTIVE ') then
1776 this%iboundpak(n) = 1
1777 end if
1778 end do
1779 !
1780 ! -- set boundname for each connection
1781 if (this%inamedbound /= 0) then
1782 do n = 1, this%nlakes
1783 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1784 this%boundname(j) = this%lakename(n)
1785 end do
1786 end do
1787 end if
1788 !
1789 ! -- copy boundname into boundname_cst
1790 call this%copy_boundname()
1791 !
1792 ! -- set pointer to gwf iss and gwf hk
1793 call mem_setptr(this%gwfiss, 'ISS', create_mem_path(this%name_model))
1794 call mem_setptr(this%gwfk11, 'K11', create_mem_path(this%name_model, 'NPF'))
1795 call mem_setptr(this%gwfk33, 'K33', create_mem_path(this%name_model, 'NPF'))
1796 call mem_setptr(this%gwfik33, 'IK33', create_mem_path(this%name_model, 'NPF'))
1797 call mem_setptr(this%gwfsat, 'SAT', create_mem_path(this%name_model, 'NPF'))
1798 !
1799 ! -- allocate temporary storage
1800 allocate (clb(this%MAXBOUND))
1801 allocate (caq(this%MAXBOUND))
1802 !
1803 ! -- calculate saturated conductance for each connection
1804 do n = 1, this%nlakes
1805 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1806 nn = this%gwfconn(j)
1807 top = this%dis%top(nn)
1808 bot = this%dis%bot(nn)
1809 ! vertical connection
1810 if (this%ictype(j) == 0) then
1811 area = this%dis%area(nn)
1812 this%sarea(j) = area
1813 this%warea(j) = area
1814 this%sareamax(n) = this%sareamax(n) + area
1815 if (this%gwfik33 == 0) then
1816 k = this%gwfk11(nn)
1817 else
1818 k = this%gwfk33(nn)
1819 end if
1820 length = dhalf * (top - bot)
1821 ! horizontal connection
1822 else if (this%ictype(j) == 1) then
1823 area = (this%telev(j) - this%belev(j)) * this%connwidth(j)
1824 ! -- recalculate area if connected cell is confined and lake
1825 ! connection top and bot are equal to the cell top and bot
1826 if (top == this%telev(j) .and. bot == this%belev(j)) then
1827 if (this%icelltype(nn) == 0) then
1828 area = this%gwfsat(nn) * (top - bot) * this%connwidth(j)
1829 end if
1830 end if
1831 this%sarea(j) = dzero
1832 this%warea(j) = area
1833 this%sareamax(n) = this%sareamax(n) + dzero
1834 k = this%gwfk11(nn)
1835 length = this%connlength(j)
1836 ! embedded horizontal connection
1837 else if (this%ictype(j) == 2) then
1838 area = done
1839 this%sarea(j) = dzero
1840 this%warea(j) = area
1841 this%sareamax(n) = this%sareamax(n) + dzero
1842 k = this%gwfk11(nn)
1843 length = this%connlength(j)
1844 ! embedded vertical connection
1845 else if (this%ictype(j) == 3) then
1846 area = done
1847 this%sarea(j) = dzero
1848 this%warea(j) = area
1849 this%sareamax(n) = this%sareamax(n) + dzero
1850 if (this%gwfik33 == 0) then
1851 k = this%gwfk11(nn)
1852 else
1853 k = this%gwfk33(nn)
1854 end if
1855 length = this%connlength(j)
1856 end if
1857 if (is_close(this%bedleak(j), dnodata)) then
1858 clb(j) = dnodata
1859 else if (this%bedleak(j) > dzero) then
1860 clb(j) = done / this%bedleak(j)
1861 else
1862 clb(j) = dzero
1863 end if
1864 if (k > dzero) then
1865 caq(j) = length / k
1866 else
1867 caq(j) = dzero
1868 end if
1869 if (is_close(this%bedleak(j), dnodata)) then
1870 this%satcond(j) = area / caq(j)
1871 else if (clb(j) * caq(j) > dzero) then
1872 this%satcond(j) = area / (clb(j) + caq(j))
1873 else
1874 this%satcond(j) = dzero
1875 end if
1876 end do
1877 end do
1878 !
1879 ! -- write a summary of the conductance
1880 if (this%iprpak > 0) then
1881 write (this%iout, '(//,29x,a,/)') &
1882 'INTERFACE CONDUCTANCE BETWEEN LAKE AND AQUIFER CELLS'
1883 write (this%iout, '(1x,a)') &
1884 & ' LAKE CONNECTION CONNECTION LAKEBED'// &
1885 & ' C O N D U C T A N C E S '
1886 write (this%iout, '(1x,a)') &
1887 & ' NUMBER NUMBER CELLID DIRECTION LEAKANCE'// &
1888 & ' LAKEBED AQUIFER COMBINED'
1889 write (this%iout, "(1x,108('-'))")
1890 do n = 1, this%nlakes
1891 idx = 0
1892 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1893 idx = idx + 1
1894 fact = done
1895 if (this%ictype(j) == 1) then
1896 fact = this%telev(j) - this%belev(j)
1897 if (abs(fact) > dzero) then
1898 fact = done / fact
1899 end if
1900 end if
1901 nn = this%gwfconn(j)
1902 area = this%warea(j)
1903 c1 = dzero
1904 if (is_close(clb(j), dnodata)) then
1905 cbedleak = ' NONE '
1906 cbedcond = ' NONE '
1907 else if (clb(j) > dzero) then
1908 c1 = area * fact / clb(j)
1909 write (cbedleak, '(g14.5)') this%bedleak(j)
1910 write (cbedcond, '(g14.5)') c1
1911 else
1912 write (cbedleak, '(g14.5)') c1
1913 write (cbedcond, '(g14.5)') c1
1914 end if
1915 c2 = dzero
1916 if (caq(j) > dzero) then
1917 c2 = area * fact / caq(j)
1918 end if
1919 call this%dis%noder_to_string(nn, nodestr)
1920 write (this%iout, &
1921 '(1x,i10,1x,i10,1x,a15,1x,a10,2(1x,a14),2(1x,g14.5))') &
1922 n, idx, nodestr, ctype(this%ictype(j)), cbedleak, &
1923 cbedcond, c2, this%satcond(j) * fact
1924 end do
1925 end do
1926 write (this%iout, "(1x,108('-'))")
1927 write (this%iout, '(1x,a)') &
1928 'IF VERTICAL CONNECTION, CONDUCTANCE (L^2/T) IS &
1929 &BETWEEN AQUIFER CELL AND OVERLYING LAKE CELL.'
1930 write (this%iout, '(1x,a)') &
1931 'IF HORIZONTAL CONNECTION, CONDUCTANCES ARE PER &
1932 &UNIT SATURATED THICKNESS (L/T).'
1933 write (this%iout, '(1x,a)') &
1934 'IF EMBEDDED CONNECTION, CONDUCTANCES ARE PER &
1935 &UNIT EXCHANGE AREA (1/T).'
1936 !
1937 ! write(this%iout,*) n, idx, nodestr, this%sarea(j), this%warea(j)
1938 !
1939 ! -- calculate stage, surface area, wetted area, volume relation
1940 do n = 1, this%nlakes
1941 write (this%iout, '(//1x,a,1x,i10)') 'STAGE/VOLUME RELATION FOR LAKE ', n
1942 write (this%iout, '(/1x,5(a14))') ' STAGE', ' SURFACE AREA', &
1943 & ' WETTED AREA', ' CONDUCTANCE', &
1944 & ' VOLUME'
1945 write (this%iout, "(1x,70('-'))")
1946 dx = (this%laketop(n) - this%lakebot(n)) / 150.
1947 s = this%lakebot(n)
1948 do j = 1, 151
1949 call this%lak_calculate_conductance(n, s, c)
1950 call this%lak_calculate_sarea(n, s, sa)
1951 call this%lak_calculate_warea(n, s, wa, s)
1952 call this%lak_calculate_vol(n, s, v)
1953 write (this%iout, '(1x,5(E14.5))') s, sa, wa, c, v
1954 s = s + dx
1955 end do
1956 write (this%iout, "(1x,70('-'))")
1957 !
1958 write (this%iout, '(//1x,a,1x,i10)') 'STAGE/VOLUME RELATION FOR LAKE ', n
1959 write (this%iout, '(/1x,4(a14))') ' ', ' ', &
1960 & ' CALCULATED', ' STAGE'
1961 write (this%iout, '(1x,4(a14))') ' STAGE', ' VOLUME', &
1962 & ' STAGE', ' DIFFERENCE'
1963 write (this%iout, "(1x,56('-'))")
1964 s = this%lakebot(n) - dx
1965 do j = 1, 156
1966 call this%lak_calculate_vol(n, s, v)
1967 call this%lak_vol2stage(n, v, c)
1968 write (this%iout, '(1x,4(E14.5))') s, v, c, s - c
1969 s = s + dx
1970 end do
1971 write (this%iout, "(1x,56('-'))")
1972 end do
1973 end if
1974 !
1975 ! -- finished with pointer to gwf hydraulic conductivity
1976 this%gwfk11 => null()
1977 this%gwfk33 => null()
1978 this%gwfsat => null()
1979 this%gwfik33 => null()
1980 !
1981 ! -- deallocate temporary storage
1982 deallocate (clb)
1983 deallocate (caq)
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
real(dp), parameter dnodata
real no data constant
Definition Constants.f90:95
real(dp), parameter dhalf
real constant 1/2
Definition Constants.f90:68
real(dp), parameter done
real constant 1
Definition Constants.f90:76
integer(i4b) function, public count_errors()
Return number of errors.
Definition Sim.f90:60
Here is the call graph for this function:

◆ lak_rp()

subroutine lakmodule::lak_rp ( class(laktype), intent(inout) this)
private

Definition at line 3345 of file gwf-lak.f90.

3346 ! -- modules
3347 use constantsmodule, only: lenvarname
3348 use tdismodule, only: kper
3349 ! -- dummy
3350 class(LakType), intent(inout) :: this
3351 ! -- local
3352 character(len=LINELENGTH) :: str = ' '
3353 real(DP) :: auxvaldbl = dzero
3354 character(len=LINELENGTH) :: title
3355 character(len=LINELENGTH) :: text
3356 character(len=LENVARNAME) :: setting
3357 integer(I4B) :: node, n, j, itemno
3358 integer(I4B) :: istat
3359 ! -- formats
3360 character(len=*), parameter :: fmtlsp = &
3361 &"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
3362 !
3363 ! -- set nbound to maxbound
3364 this%nbound = this%maxbound
3365 !
3366 ! -- check if data has been loaded for this stress period
3367 if (this%iper == kper) then
3368 !
3369 this%check_attr = 1
3370 !
3371 ! -- setup table to echo period data
3372 if (this%iprpak /= 0) then
3373 title = trim(adjustl(this%text))//' PACKAGE ('// &
3374 trim(adjustl(this%packName))//') DATA FOR PERIOD'
3375 write (title, '(a,1x,i6)') trim(adjustl(title)), kper
3376 call table_cr(this%inputtab, this%packName, title)
3377 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
3378 text = 'NUMBER'
3379 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
3380 text = 'KEYWORD'
3381 call this%inputtab%initialize_column(text, 20, alignment=tableft)
3382 do n = 1, 2
3383 write (text, '(a,1x,i6)') 'VALUE', n
3384 call this%inputtab%initialize_column(text, 15, alignment=tabcenter)
3385 end do
3386 end if
3387 !
3388 ! -- process each period data entry
3389 do n = 1, this%input%nbound
3390 itemno = this%input%ifno(n)
3391 !
3392 ! -- dispatch key for this row
3393 setting = this%input%setting(n)
3394 str = ' '
3395 !
3396 ! -- STATUS (lake only; not TS-enabled)
3397 if (trim(setting) == 'STATUS') then
3398 str = this%input%status(n)
3399 istat = this%lak_check_valid(itemno)
3400 if (istat == 0 .and. itemno >= 1 .and. itemno <= this%nlakes) then
3401 if (trim(str) == 'CONSTANT') then
3402 this%iboundpak(itemno) = -1
3403 else if (trim(str) == 'INACTIVE') then
3404 this%iboundpak(itemno) = 0
3405 else if (trim(str) == 'ACTIVE') then
3406 this%iboundpak(itemno) = 1
3407 else
3408 write (errmsg, '(a,a)') &
3409 'Unknown '//trim(this%text)//' STATUS keyword: ', &
3410 trim(str)//'.'
3411 call store_error(errmsg)
3412 end if
3413 this%status(itemno) = trim(str)
3414 end if
3415 end if
3416 !
3417 ! -- STAGE (validate itemno; assignment via helper)
3418 if (trim(setting) == 'STAGE') then
3419 istat = this%lak_check_valid(itemno)
3420 end if
3421 !
3422 ! -- RAINFALL, EVAPORATION, RUNOFF, INFLOW, WITHDRAWAL (require
3423 ! non-negative)
3424 if (trim(setting) == 'RAINFALL') &
3425 call this%lak_set_nonneg_value(n, itemno, setting, this%rainfall, &
3426 'rainfall')
3427 if (trim(setting) == 'EVAPORATION') &
3428 call this%lak_set_nonneg_value(n, itemno, setting, &
3429 this%evaporation, 'evaporation')
3430 if (trim(setting) == 'RUNOFF') &
3431 call this%lak_set_nonneg_value(n, itemno, setting, this%runoff, &
3432 'runoff')
3433 if (trim(setting) == 'INFLOW') &
3434 call this%lak_set_nonneg_value(n, itemno, setting, this%inflow, &
3435 'inflow')
3436 if (trim(setting) == 'WITHDRAWAL') &
3437 call this%lak_set_nonneg_value(n, itemno, setting, &
3438 this%withdrawal, 'withdrawal')
3439 !
3440 ! -- RATE, INVERT, WIDTH, ROUGH, SLOPE (outlet; validate with
3441 ! negative sign convention)
3442 if (trim(setting) == 'RATE' .or. trim(setting) == 'INVERT' .or. &
3443 trim(setting) == 'WIDTH' .or. trim(setting) == 'ROUGH' .or. &
3444 trim(setting) == 'SLOPE') then
3445 istat = this%lak_check_valid(-itemno)
3446 end if
3447 !
3448 ! -- INVERT, WIDTH, ROUGH, SLOPE latch here so the OUTLETS block's
3449 ! own (separately time-series-linked) baseline resync in lak_ad
3450 ! stops overwriting this outlet's PERIOD-block override
3451 if (istat == 0 .and. itemno >= 1 .and. itemno <= this%noutlets) then
3452 if (trim(setting) == 'INVERT') this%outlet_invert_set(itemno) = .true.
3453 if (trim(setting) == 'WIDTH') this%outlet_width_set(itemno) = .true.
3454 if (trim(setting) == 'ROUGH') this%outlet_rough_set(itemno) = .true.
3455 if (trim(setting) == 'SLOPE') this%outlet_slope_set(itemno) = .true.
3456 end if
3457 !
3458 ! -- AUXILIARY; featureauxvar set via sync_auxvar()
3459 if (this%naux > 0) then
3460 if (trim(setting) == 'PERIOD_AUXILIARY') then
3461 if (itemno >= 1 .and. itemno <= this%nlakes) then
3462 str = this%input%auxname(n)
3463 auxvaldbl = this%input%auxval(n)
3464 end if
3465 end if
3466 end if
3467 !
3468 ! -- echo row to period data table
3469 if (this%iprpak /= 0) then
3470 call this%inputtab%add_term(itemno)
3471 if (trim(setting) == 'PERIOD_AUXILIARY') then
3472 call this%inputtab%add_term('AUXILIARY')
3473 else
3474 call this%inputtab%add_term(trim(setting))
3475 end if
3476 select case (trim(setting))
3477 case ('STATUS')
3478 call this%inputtab%add_term(trim(str))
3479 call this%inputtab%add_term(' ')
3480 case ('STAGE')
3481 call this%inputtab%add_term(this%stage(itemno))
3482 call this%inputtab%add_term(' ')
3483 case ('RAINFALL')
3484 call this%inputtab%add_term(this%rainfall(itemno))
3485 call this%inputtab%add_term(' ')
3486 case ('EVAPORATION')
3487 call this%inputtab%add_term(this%evaporation(itemno))
3488 call this%inputtab%add_term(' ')
3489 case ('RUNOFF')
3490 call this%inputtab%add_term(this%runoff(itemno))
3491 call this%inputtab%add_term(' ')
3492 case ('INFLOW')
3493 call this%inputtab%add_term(this%inflow(itemno))
3494 call this%inputtab%add_term(' ')
3495 case ('WITHDRAWAL')
3496 call this%inputtab%add_term(this%withdrawal(itemno))
3497 call this%inputtab%add_term(' ')
3498 case ('RATE')
3499 call this%inputtab%add_term(this%outrate(itemno))
3500 call this%inputtab%add_term(' ')
3501 case ('INVERT')
3502 call this%inputtab%add_term(this%outinvert(itemno))
3503 call this%inputtab%add_term(' ')
3504 case ('WIDTH')
3505 call this%inputtab%add_term(this%outwidth(itemno))
3506 call this%inputtab%add_term(' ')
3507 case ('ROUGH')
3508 call this%inputtab%add_term(this%outrough(itemno))
3509 call this%inputtab%add_term(' ')
3510 case ('SLOPE')
3511 call this%inputtab%add_term(this%outslope(itemno))
3512 call this%inputtab%add_term(' ')
3513 case ('PERIOD_AUXILIARY')
3514 call this%inputtab%add_term(trim(str))
3515 call this%inputtab%add_term(auxvaldbl)
3516 case default
3517 call this%inputtab%add_term(' ')
3518 call this%inputtab%add_term(' ')
3519 end select
3520 end if
3521 end do
3522 if (this%iprpak /= 0) then
3523 call this%inputtab%finalize_table()
3524 end if
3525 !
3526 ! -- write summary of lake stress period error messages
3527 if (count_errors() > 0) then
3528 call store_error_filename(this%input_fname)
3529 end if
3530 !
3531 ! -- fill bound array with lake stage, conductance, and bottom elevation
3532 do n = 1, this%nlakes
3533 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3534 node = this%gwfconn(j)
3535 this%nodelist(j) = node
3536 this%bound(1, j) = this%xnewpak(n)
3537 this%bound(2, j) = this%satcond(j)
3538 this%bound(3, j) = this%belev(j)
3539 end do
3540 end do
3541 !
3542 ! -- copy lakein into iprmap so mvr budget contains lake instead of outlet
3543 if (this%imover == 1) then
3544 do n = 1, this%noutlets
3545 this%pakmvrobj%iprmap(n) = this%lakein(n)
3546 end do
3547 end if
3548 else
3549 write (this%iout, fmtlsp) trim(this%filtyp)
3550 end if
3551 !
3552 ! -- fill nodelist and bound(3) every period; nodelist for non-vertical
3553 ! connections is not updated by lak_cf so must be set here.
3554 ! bound(3) (bed elevation) is static and only needs to be set once.
3555 do n = 1, this%nlakes
3556 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3557 this%nodelist(j) = this%gwfconn(j)
3558 this%bound(3, j) = this%belev(j)
3559 end do
3560 end do
@ tabcenter
centered table column
@ tableft
left justified table column
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition Constants.f90:17
Here is the call graph for this function:

◆ lak_rp_obs()

subroutine lakmodule::lak_rp_obs ( class(laktype), intent(inout) this)
private

Only done the first stress period since boundaries are fixed for the simulation

Definition at line 5094 of file gwf-lak.f90.

5095 use tdismodule, only: kper
5096 ! -- dummy
5097 class(LakType), intent(inout) :: this
5098 ! -- local
5099 integer(I4B) :: i
5100 integer(I4B) :: j
5101 integer(I4B) :: nn1
5102 integer(I4B) :: nn2
5103 integer(I4B) :: jj
5104 character(len=LENBOUNDNAME) :: bname
5105 logical(LGP) :: jfound
5106 class(ObserveType), pointer :: obsrv => null()
5107 ! -- formats
510810 format('Boundary "', a, '" for observation "', a, &
5109 '" is invalid in package "', a, '"')
5110 !
5111 ! -- process each package observation
5112 ! only done the first stress period since boundaries are fixed
5113 ! for the simulation
5114 if (kper == 1) then
5115 do i = 1, this%obs%npakobs
5116 obsrv => this%obs%pakobs(i)%obsrv
5117 !
5118 ! -- get node number 1
5119 nn1 = obsrv%NodeNumber
5120 if (nn1 == namedboundflag) then
5121 bname = obsrv%FeatureName
5122 if (bname /= '') then
5123 ! -- Observation lake is based on a boundary name.
5124 ! Iterate through all lakes to identify and store
5125 ! corresponding index in bound array.
5126 jfound = .false.
5127 if (obsrv%ObsTypeId == 'LAK' .or. &
5128 obsrv%ObsTypeId == 'CONDUCTANCE' .or. &
5129 obsrv%ObsTypeId == 'WETTED-AREA') then
5130 if (this%inamedbound /= 0) then
5131 do j = 1, this%nlakes
5132 do jj = this%idxlakeconn(j), this%idxlakeconn(j + 1) - 1
5133 if (this%boundname(jj) == bname) then
5134 jfound = .true.
5135 call obsrv%AddObsIndex(jj)
5136 end if
5137 end do
5138 end do
5139 end if
5140 else if (obsrv%ObsTypeId == 'EXT-OUTFLOW' .or. &
5141 obsrv%ObsTypeId == 'TO-MVR' .or. &
5142 obsrv%ObsTypeId == 'OUTLET') then
5143 do j = 1, this%noutlets
5144 jj = this%lakein(j)
5145 if (this%lakename(jj) == bname) then
5146 jfound = .true.
5147 call obsrv%AddObsIndex(j)
5148 end if
5149 end do
5150 else
5151 do j = 1, this%nlakes
5152 if (this%lakename(j) == bname) then
5153 jfound = .true.
5154 call obsrv%AddObsIndex(j)
5155 end if
5156 end do
5157 end if
5158 if (.not. jfound) then
5159 write (errmsg, 10) &
5160 trim(bname), trim(obsrv%Name), trim(this%packName)
5161 call store_error(errmsg)
5162 end if
5163 end if
5164 else
5165 if (obsrv%indxbnds_count == 0) then
5166 if (obsrv%ObsTypeId == 'LAK' .or. &
5167 obsrv%ObsTypeId == 'CONDUCTANCE' .or. &
5168 obsrv%ObsTypeId == 'WETTED-AREA') then
5169 nn2 = obsrv%NodeNumber2
5170 if (nn1 < 1 .or. nn1 > this%nlakes) then
5171 write (errmsg, '(5a,i0,a,i0,a)') &
5172 'Observation ', trim(obsrv%Name), ' of type ', &
5173 trim(adjustl(obsrv%ObsTypeId)), ' was assigned lake ', &
5174 nn1, '. Lake must be >= 1 and <= ', this%nlakes, '.'
5175 call store_error(errmsg)
5176 else if (nn2 < 1 .or. nn2 > this%nlakeconn(nn1)) then
5177 write (errmsg, '(5a,i0,a,i0,a,i0,a)') &
5178 'Observation ', trim(obsrv%Name), ' of type ', &
5179 trim(adjustl(obsrv%ObsTypeId)), &
5180 ' was assigned connection ', nn2, ' of lake ', nn1, &
5181 '. Connection must be >= 1 and <= ', &
5182 this%nlakeconn(nn1), '.'
5183 call store_error(errmsg)
5184 else
5185 j = this%idxlakeconn(nn1) + nn2 - 1
5186 call obsrv%AddObsIndex(j)
5187 end if
5188 else
5189 call obsrv%AddObsIndex(nn1)
5190 end if
5191 else
5192 errmsg = 'Programming error in lak_rp_obs'
5193 call store_error(errmsg)
5194 end if
5195 end if
5196 !
5197 ! -- catch non-cumulative observation assigned to observation defined
5198 ! by a boundname that is assigned to more than one element
5199 if (obsrv%ObsTypeId == 'STAGE') then
5200 if (obsrv%indxbnds_count > 1) then
5201 write (errmsg, '(a,3(1x,a))') &
5202 trim(adjustl(obsrv%ObsTypeId)), &
5203 'for observation', trim(adjustl(obsrv%Name)), &
5204 ' must be assigned to a lake with a unique boundname.'
5205 call store_error(errmsg)
5206 end if
5207 end if
5208 !
5209 ! -- check that index values are valid
5210 if (obsrv%ObsTypeId == 'TO-MVR' .or. &
5211 obsrv%ObsTypeId == 'EXT-OUTFLOW' .or. &
5212 obsrv%ObsTypeId == 'OUTLET') then
5213 do j = 1, obsrv%indxbnds_count
5214 nn1 = obsrv%indxbnds(j)
5215 if (nn1 < 1 .or. nn1 > this%noutlets) then
5216 write (errmsg, '(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
5217 trim(adjustl(obsrv%ObsTypeId)), &
5218 ' outlet must be > 0 and <=', this%noutlets, &
5219 '(specified value is ', nn1, ')'
5220 call store_error(errmsg)
5221 end if
5222 end do
5223 else if (obsrv%ObsTypeId == 'LAK' .or. &
5224 obsrv%ObsTypeId == 'CONDUCTANCE' .or. &
5225 obsrv%ObsTypeId == 'WETTED-AREA') then
5226 do j = 1, obsrv%indxbnds_count
5227 nn1 = obsrv%indxbnds(j)
5228 if (nn1 < 1 .or. nn1 > this%maxbound) then
5229 write (errmsg, '(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
5230 trim(adjustl(obsrv%ObsTypeId)), &
5231 'lake connection number must be > 0 and <=', this%maxbound, &
5232 '(specified value is ', nn1, ')'
5233 call store_error(errmsg)
5234 end if
5235 end do
5236 else
5237 do j = 1, obsrv%indxbnds_count
5238 nn1 = obsrv%indxbnds(j)
5239 if (nn1 < 1 .or. nn1 > this%nlakes) then
5240 write (errmsg, '(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
5241 trim(adjustl(obsrv%ObsTypeId)), &
5242 ' lake must be > 0 and <=', this%nlakes, &
5243 '(specified value is ', nn1, ')'
5244 call store_error(errmsg)
5245 end if
5246 end do
5247 end if
5248 end do
5249 !
5250 ! -- evaluate if there are any observation errors
5251 if (count_errors() > 0) then
5252 call store_error_filename(this%input_fname)
5253 end if
5254 end if

◆ lak_set_attribute_error()

subroutine lakmodule::lak_set_attribute_error ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
character(len=*), intent(in) keyword,
character(len=*), intent(in) msg )
private

Definition at line 3015 of file gwf-lak.f90.

3016 ! -- modules
3017 use simmodule, only: store_error
3018 ! -- dummy
3019 class(LakType), intent(inout) :: this
3020 integer(I4B), intent(in) :: ilak
3021 character(len=*), intent(in) :: keyword
3022 character(len=*), intent(in) :: msg
3023 !
3024 if (len(msg) == 0) then
3025 write (errmsg, '(a,1x,a,1x,i0,1x,a)') &
3026 keyword, ' for LAKE', ilak, 'has already been set.'
3027 else
3028 write (errmsg, '(a,1x,a,1x,i0,1x,a)') keyword, ' for LAKE', ilak, msg
3029 end if
3030 call store_error(errmsg)
Here is the call graph for this function:

◆ lak_set_nonneg_value()

subroutine lakmodule::lak_set_nonneg_value ( class(laktype), intent(inout) this,
integer(i4b), intent(in) n,
integer(i4b), intent(in) itemno,
character(len=*), intent(in) setting,
real(dp), dimension(:), intent(inout) value_array,
character(len=*), intent(in) label )
private

Definition at line 2991 of file gwf-lak.f90.

2992 ! -- dummy
2993 class(LakType), intent(inout) :: this
2994 integer(I4B), intent(in) :: n
2995 integer(I4B), intent(in) :: itemno
2996 character(len=*), intent(in) :: setting
2997 real(DP), dimension(:), intent(inout) :: value_array
2998 character(len=*), intent(in) :: label
2999 ! -- local
3000 integer(I4B) :: istat
3001 !
3002 istat = this%lak_check_valid(itemno)
3003 if (istat /= 0) return
3004 if (itemno < 1 .or. itemno > this%nlakes) return
3005 if (value_array(itemno) < dzero) then
3006 write (errmsg, '(a,i0,a,g0,a)') &
3007 'Lake ', itemno, ' was assigned a '//trim(label)//' value of ', &
3008 value_array(itemno), '. Value must be positive.'
3009 call store_error(errmsg)
3010 end if

◆ lak_set_pointers()

subroutine lakmodule::lak_set_pointers ( class(laktype) this,
integer(i4b), pointer neq,
integer(i4b), dimension(:), pointer, contiguous ibound,
real(dp), dimension(:), pointer, contiguous xnew,
real(dp), dimension(:), pointer, contiguous xold,
real(dp), dimension(:), pointer, contiguous flowja )
private

Definition at line 4677 of file gwf-lak.f90.

4678 ! -- modules
4680 ! -- dummy
4681 class(LakType) :: this
4682 integer(I4B), pointer :: neq
4683 integer(I4B), dimension(:), pointer, contiguous :: ibound
4684 real(DP), dimension(:), pointer, contiguous :: xnew
4685 real(DP), dimension(:), pointer, contiguous :: xold
4686 real(DP), dimension(:), pointer, contiguous :: flowja
4687 ! -- local
4688 integer(I4B) :: n
4689 integer(I4B) :: istart, iend
4690 !
4691 ! -- call base BndType set_pointers
4692 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
4693 !
4694 ! -- for the implicit formulation, point the lake stage and ibound at the
4695 ! matching slice of the model solution (xnew) and ibound vectors so the
4696 ! stage is solved directly in the matrix. (The default formulation keeps
4697 ! these as its own arrays, allocated in lak_allocate_arrays.)
4698 if (this%iimplicit /= 0) then
4699 istart = this%dis%nodes + this%ioffset + 1
4700 iend = istart + this%nlakes - 1
4701 this%iboundpak => this%ibound(istart:iend)
4702 this%xnewpak => this%xnew(istart:iend)
4703 call mem_checkin(this%xnewpak, 'XNEWPAK', this%memoryPath, 'X', &
4704 this%memoryPathModel)
4705 !
4706 ! -- initialize xnewpak
4707 do n = 1, this%nlakes
4708 this%xnewpak(n) = dep20
4709 end do
4710 end if

◆ lak_setup_budobj()

subroutine lakmodule::lak_setup_budobj ( class(laktype) this)
private

Definition at line 6028 of file gwf-lak.f90.

6029 ! -- modules
6030 use constantsmodule, only: lenbudtxt
6031 ! -- dummy
6032 class(LakType) :: this
6033 ! -- local
6034 integer(I4B) :: nbudterm
6035 integer(I4B) :: nlen
6036 integer(I4B) :: j, n, n1, n2
6037 integer(I4B) :: maxlist, naux
6038 integer(I4B) :: idx
6039 real(DP) :: q
6040 character(len=LENBUDTXT) :: text
6041 character(len=LENBUDTXT), dimension(1) :: auxtxt
6042 !
6043 ! -- Determine the number of lake budget terms. These are fixed for
6044 ! the simulation and cannot change
6045 nbudterm = 9
6046 nlen = 0
6047 do n = 1, this%noutlets
6048 if (this%lakein(n) > 0 .and. this%lakeout(n) > 0) then
6049 nlen = nlen + 1
6050 end if
6051 end do
6052 if (nlen > 0) nbudterm = nbudterm + 1
6053 if (this%imover == 1) nbudterm = nbudterm + 2
6054 if (this%naux > 0) nbudterm = nbudterm + 1
6055 !
6056 ! -- set up budobj
6057 call budgetobject_cr(this%budobj, this%packName)
6058 call this%budobj%budgetobject_df(this%nlakes, nbudterm, 0, 0, &
6059 ibudcsv=this%ibudcsv)
6060 idx = 0
6061 !
6062 ! -- Go through and set up each budget term. nlen is the number
6063 ! of outlets that discharge into another lake
6064 if (nlen > 0) then
6065 text = ' FLOW-JA-FACE'
6066 idx = idx + 1
6067 maxlist = 2 * nlen
6068 naux = 0
6069 call this%budobj%budterm(idx)%initialize(text, &
6070 this%name_model, &
6071 this%packName, &
6072 this%name_model, &
6073 this%packName, &
6074 maxlist, .false., .false., &
6075 naux, ordered_id1=.false.)
6076 !
6077 ! -- store connectivity
6078 call this%budobj%budterm(idx)%reset(2 * nlen)
6079 q = dzero
6080 do n = 1, this%noutlets
6081 n1 = this%lakein(n)
6082 n2 = this%lakeout(n)
6083 if (n1 > 0 .and. n2 > 0) then
6084 call this%budobj%budterm(idx)%update_term(n1, n2, q)
6085 call this%budobj%budterm(idx)%update_term(n2, n1, -q)
6086 end if
6087 end do
6088 end if
6089 !
6090 ! --
6091 text = ' GWF'
6092 idx = idx + 1
6093 maxlist = this%maxbound
6094 naux = 1
6095 auxtxt(1) = ' FLOW-AREA'
6096 call this%budobj%budterm(idx)%initialize(text, &
6097 this%name_model, &
6098 this%packName, &
6099 this%name_model, &
6100 this%name_model, &
6101 maxlist, .false., .true., &
6102 naux, auxtxt)
6103 call this%budobj%budterm(idx)%reset(this%maxbound)
6104 q = dzero
6105 do n = 1, this%nlakes
6106 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
6107 n2 = this%gwfconn(j)
6108 call this%budobj%budterm(idx)%update_term(n, n2, q)
6109 end do
6110 end do
6111 !
6112 ! --
6113 text = ' RAINFALL'
6114 idx = idx + 1
6115 maxlist = this%nlakes
6116 naux = 0
6117 call this%budobj%budterm(idx)%initialize(text, &
6118 this%name_model, &
6119 this%packName, &
6120 this%name_model, &
6121 this%packName, &
6122 maxlist, .false., .false., &
6123 naux)
6124 !
6125 ! --
6126 text = ' EVAPORATION'
6127 idx = idx + 1
6128 maxlist = this%nlakes
6129 naux = 0
6130 call this%budobj%budterm(idx)%initialize(text, &
6131 this%name_model, &
6132 this%packName, &
6133 this%name_model, &
6134 this%packName, &
6135 maxlist, .false., .false., &
6136 naux)
6137 !
6138 ! --
6139 text = ' RUNOFF'
6140 idx = idx + 1
6141 maxlist = this%nlakes
6142 naux = 0
6143 call this%budobj%budterm(idx)%initialize(text, &
6144 this%name_model, &
6145 this%packName, &
6146 this%name_model, &
6147 this%packName, &
6148 maxlist, .false., .false., &
6149 naux)
6150 !
6151 ! --
6152 text = ' EXT-INFLOW'
6153 idx = idx + 1
6154 maxlist = this%nlakes
6155 naux = 0
6156 call this%budobj%budterm(idx)%initialize(text, &
6157 this%name_model, &
6158 this%packName, &
6159 this%name_model, &
6160 this%packName, &
6161 maxlist, .false., .false., &
6162 naux)
6163 !
6164 ! --
6165 text = ' WITHDRAWAL'
6166 idx = idx + 1
6167 maxlist = this%nlakes
6168 naux = 0
6169 call this%budobj%budterm(idx)%initialize(text, &
6170 this%name_model, &
6171 this%packName, &
6172 this%name_model, &
6173 this%packName, &
6174 maxlist, .false., .false., &
6175 naux)
6176 !
6177 ! --
6178 text = ' EXT-OUTFLOW'
6179 idx = idx + 1
6180 maxlist = this%nlakes
6181 naux = 0
6182 call this%budobj%budterm(idx)%initialize(text, &
6183 this%name_model, &
6184 this%packName, &
6185 this%name_model, &
6186 this%packName, &
6187 maxlist, .false., .false., &
6188 naux)
6189 !
6190 ! --
6191 text = ' STORAGE'
6192 idx = idx + 1
6193 maxlist = this%nlakes
6194 naux = 1
6195 auxtxt(1) = ' VOLUME'
6196 call this%budobj%budterm(idx)%initialize(text, &
6197 this%name_model, &
6198 this%packName, &
6199 this%name_model, &
6200 this%packName, &
6201 maxlist, .false., .false., &
6202 naux, auxtxt)
6203 !
6204 ! --
6205 text = ' CONSTANT'
6206 idx = idx + 1
6207 maxlist = this%nlakes
6208 naux = 0
6209 call this%budobj%budterm(idx)%initialize(text, &
6210 this%name_model, &
6211 this%packName, &
6212 this%name_model, &
6213 this%packName, &
6214 maxlist, .false., .false., &
6215 naux)
6216 !
6217 ! --
6218 if (this%imover == 1) then
6219 !
6220 ! --
6221 text = ' FROM-MVR'
6222 idx = idx + 1
6223 maxlist = this%nlakes
6224 naux = 0
6225 call this%budobj%budterm(idx)%initialize(text, &
6226 this%name_model, &
6227 this%packName, &
6228 this%name_model, &
6229 this%packName, &
6230 maxlist, .false., .false., &
6231 naux)
6232 !
6233 ! --
6234 text = ' TO-MVR'
6235 idx = idx + 1
6236 maxlist = this%noutlets
6237 naux = 0
6238 call this%budobj%budterm(idx)%initialize(text, &
6239 this%name_model, &
6240 this%packName, &
6241 this%name_model, &
6242 this%packName, &
6243 maxlist, .false., .false., &
6244 naux, ordered_id1=.false.)
6245 !
6246 ! -- store to-mvr connection information
6247 call this%budobj%budterm(idx)%reset(this%noutlets)
6248 q = dzero
6249 do n = 1, this%noutlets
6250 n1 = this%lakein(n)
6251 call this%budobj%budterm(idx)%update_term(n1, n1, q)
6252 end do
6253 end if
6254 !
6255 ! --
6256 naux = this%naux
6257 if (naux > 0) then
6258 !
6259 ! --
6260 text = ' AUXILIARY'
6261 idx = idx + 1
6262 maxlist = this%nlakes
6263 call this%budobj%budterm(idx)%initialize(text, &
6264 this%name_model, &
6265 this%packName, &
6266 this%name_model, &
6267 this%packName, &
6268 maxlist, .false., .false., &
6269 naux, this%auxname)
6270 end if
6271 !
6272 ! -- if lake flow for each reach are written to the listing file
6273 if (this%iprflow /= 0) then
6274 call this%budobj%flowtable_df(this%iout)
6275 end if
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition Constants.f90:37
Here is the call graph for this function:

◆ lak_setup_tableobj()

subroutine lakmodule::lak_setup_tableobj ( class(laktype) this)
private

The terms listed here must correspond in number and order to the ones written to the stage table in the lak_ot method

Definition at line 6468 of file gwf-lak.f90.

6469 ! -- modules
6471 ! -- dummy
6472 class(LakType) :: this
6473 ! -- local
6474 integer(I4B) :: nterms
6475 character(len=LINELENGTH) :: title
6476 character(len=LINELENGTH) :: text
6477 !
6478 ! -- setup stage table
6479 if (this%iprhed > 0) then
6480 !
6481 ! -- Determine the number of lake stage terms. These are fixed for
6482 ! the simulation and cannot change. This includes FLOW-JA-FACE
6483 ! so they can be written to the binary budget files, but these internal
6484 ! flows are not included as part of the budget table.
6485 nterms = 5
6486 if (this%inamedbound == 1) then
6487 nterms = nterms + 1
6488 end if
6489 !
6490 ! -- set up table title
6491 title = trim(adjustl(this%text))//' PACKAGE ('// &
6492 trim(adjustl(this%packName))//') STAGES FOR EACH CONTROL VOLUME'
6493 !
6494 ! -- set up stage tableobj
6495 call table_cr(this%stagetab, this%packName, title)
6496 call this%stagetab%table_df(this%nlakes, nterms, this%iout, &
6497 transient=.true.)
6498 !
6499 ! -- Go through and set up table budget term
6500 if (this%inamedbound == 1) then
6501 text = 'NAME'
6502 call this%stagetab%initialize_column(text, 20, alignment=tableft)
6503 end if
6504 !
6505 ! -- lake number
6506 text = 'NUMBER'
6507 call this%stagetab%initialize_column(text, 10, alignment=tabcenter)
6508 !
6509 ! -- lake stage
6510 text = 'STAGE'
6511 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
6512 !
6513 ! -- lake surface area
6514 text = 'SURFACE AREA'
6515 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
6516 !
6517 ! -- lake wetted area
6518 text = 'WETTED AREA'
6519 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
6520 !
6521 ! -- lake volume
6522 text = 'VOLUME'
6523 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
6524 end if
Here is the call graph for this function:

◆ lak_solve()

subroutine lakmodule::lak_solve ( class(laktype), intent(inout) this,
logical(lgp), intent(in), optional update,
logical(lgp), intent(in), optional only_legacy )
private

Solve the lake stage by substitution. With only_legacy set, solve only the lakes flagged for the legacy solver (thisilegacy /= 0) and leave the remaining lakes – whose stage is solved in the global matrix by the IMPLICIT formulation – untouched. Without it (the default), every active lake is solved.

Definition at line 5377 of file gwf-lak.f90.

5378 ! -- modules
5379 use tdismodule, only: delt
5380 ! -- dummy
5381 class(LakType), intent(inout) :: this
5382 logical(LGP), intent(in), optional :: update
5383 logical(LGP), intent(in), optional :: only_legacy
5384 ! -- local
5385 logical(LGP) :: lupdate
5386 logical(LGP) :: legonly
5387 integer(I4B) :: j
5388 integer(I4B) :: n
5389 integer(I4B) :: iicnvg
5390 integer(I4B) :: iter
5391 integer(I4B) :: maxiter
5392 integer(I4B) :: ncnv
5393 real(DP) :: hlak
5394 real(DP) :: hlak0
5395 real(DP) :: v0
5396 real(DP) :: v1
5397 real(DP) :: ro
5398 real(DP) :: qinf
5399 real(DP) :: ex
5400 real(DP) :: outinf
5401 real(DP) :: avail
5402 !
5403 ! -- set lupdate
5404 if (present(update)) then
5405 lupdate = update
5406 else
5407 lupdate = .true.
5408 end if
5409 !
5410 ! -- set legonly (solve only the lakes flagged for the legacy solver)
5411 if (present(only_legacy)) then
5412 legonly = only_legacy
5413 else
5414 legonly = .false.
5415 end if
5416 !
5417 ! -- initialize
5418 avail = dzero
5419 !
5420 ! -- initialize
5421 do n = 1, this%nlakes
5422 ! -- a lake not being solved on this call (an IMPLICIT lake when only the
5423 ! flagged lakes are solved) is treated as already converged and left
5424 ! untouched
5425 if (legonly .and. this%ilegacy(n) == 0) then
5426 this%ncncvr(n) = 1
5427 cycle
5428 end if
5429 this%ncncvr(n) = 0
5430 this%surfin(n) = dzero
5431 this%surfout(n) = dzero
5432 this%surfout1(n) = dzero
5433 if (this%xnewpak(n) < this%lakebot(n)) then
5434 this%xnewpak(n) = this%lakebot(n)
5435 end if
5436 if (this%gwfiss /= 0) then
5437 this%xoldpak(n) = this%xnewpak(n)
5438 end if
5439 ! -- lake iteration items
5440 this%iseepc(n) = 0
5441 this%idhc(n) = 0
5442 this%en1(n) = this%lakebot(n)
5443 call this%lak_calculate_residual(n, this%en1(n), this%r1(n))
5444 this%en2(n) = this%laketop(n)
5445 call this%lak_calculate_residual(n, this%en2(n), this%r2(n))
5446 end do
5447 ! -- a legacy-only solve keeps the outlet rates of the implicit lakes,
5448 ! which are final and still needed for the mover and downstream lakes
5449 do n = 1, this%noutlets
5450 if (legonly .and. this%ilegacy(this%lakein(n)) == 0) cycle
5451 this%simoutrate(n) = dzero
5452 end do
5453 !
5454 ! -- sum up inflows from mover inflows
5455 do n = 1, this%nlakes
5456 call this%lak_calculate_outlet_inflow(n, this%surfin(n))
5457 end do
5458 !
5459 ! -- sum up overland runoff, inflows, and external flows into lake
5460 ! (includes maximum lake volume)
5461 do n = 1, this%nlakes
5462 hlak0 = this%xoldpak(n)
5463 hlak = this%xnewpak(n)
5464 call this%lak_calculate_runoff(n, ro)
5465 call this%lak_calculate_inflow(n, qinf)
5466 call this%lak_calculate_external(n, ex)
5467 call this%lak_calculate_vol(n, hlak0, v0)
5468 call this%lak_calculate_vol(n, hlak, v1)
5469 this%flwin(n) = this%surfin(n) + ro + qinf + ex + &
5470 max(v0, v1) / delt
5471 end do
5472 !
5473 ! -- sum up inflows from upstream outlets
5474 do n = 1, this%nlakes
5475 call this%lak_calculate_outlet_inflow(n, outinf)
5476 this%flwin(n) = this%flwin(n) + outinf
5477 end do
5478 !
5479 iicnvg = 0
5480 maxiter = this%maxlakit
5481 !
5482 ! -- outer loop
5483 converge: do iter = 1, maxiter
5484 ncnv = 0
5485 do n = 1, this%nlakes
5486 if (this%ncncvr(n) == 0) ncnv = 1
5487 end do
5488 if (iter == maxiter) ncnv = 0
5489 if (ncnv == 0) iicnvg = 1
5490 !
5491 ! -- initialize variables
5492 do n = 1, this%nlakes
5493 this%evap(n) = dzero
5494 this%precip(n) = dzero
5495 this%precip1(n) = dzero
5496 this%seep(n) = dzero
5497 this%seep1(n) = dzero
5498 this%evap(n) = dzero
5499 this%evap1(n) = dzero
5500 this%evapo(n) = dzero
5501 this%withr(n) = dzero
5502 this%withr1(n) = dzero
5503 this%flwiter(n) = this%flwin(n)
5504 this%flwiter1(n) = this%flwin(n)
5505 if (this%gwfiss /= 0) then
5506 this%flwiter(n) = dep20
5507 this%flwiter1(n) = dep20
5508 end if
5509 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5510 this%hcof(j) = dzero
5511 this%rhs(j) = dzero
5512 end do
5513 end do
5514 !
5515 do n = 1, this%nlakes
5516 if (legonly .and. this%ilegacy(n) == 0) cycle
5517 call this%lak_estimate_seepage_single(n, ncnv)
5518 end do
5519 !
5520 laklevel: do n = 1, this%nlakes
5521 if (legonly .and. this%ilegacy(n) == 0) cycle laklevel
5522 call this%lak_solve_single(n, iter, maxiter, ncnv, lupdate)
5523 end do laklevel
5524 !
5525 if (iicnvg == 1) exit converge
5526 !
5527 end do converge
5528 !
5529 ! -- Mover terms: store outflow after diversion loss
5530 ! as qformvr and reduce outflow (qd)
5531 ! by how much was actually sent to the mover. A legacy-only solve
5532 ! skips this because the implicit formulation accumulates the mover
5533 ! terms for every outlet once the legacy-solved stages are known.
5534 if (this%imover == 1 .and. .not. legonly) then
5535 do n = 1, this%noutlets
5536 call this%pakmvrobj%accumulate_qformvr(n, -this%simoutrate(n))
5537 end do
5538 end if

◆ lak_solve_single()

subroutine lakmodule::lak_solve_single ( class(laktype), intent(inout) this,
integer(i4b), intent(in) n,
integer(i4b), intent(in) iter,
integer(i4b), intent(in) maxiter,
integer(i4b), intent(in) ncnv,
logical(lgp), intent(in) lupdate )
private

Performs one Newton update (with a bisection backup) of lake n's stage in the default substitution solver, using the per-iteration seepage estimate (thisseep / thisseep1) already computed for the lake. Extracted from lak_solve so the same per-lake update can be reused to solve a single lake stage on its own – the per-lake legacy solve for the IMPLICIT formulation.

Definition at line 5549 of file gwf-lak.f90.

5550 ! -- modules
5551 use tdismodule, only: delt
5552 ! -- dummy
5553 class(LakType), intent(inout) :: this
5554 integer(I4B), intent(in) :: n
5555 integer(I4B), intent(in) :: iter
5556 integer(I4B), intent(in) :: maxiter
5557 integer(I4B), intent(in) :: ncnv
5558 logical(LGP), intent(in) :: lupdate
5559 ! -- local
5560 integer(I4B) :: ibflg
5561 integer(I4B) :: idhp
5562 real(DP) :: hlak
5563 real(DP) :: hlak0
5564 real(DP) :: ra
5565 real(DP) :: ro
5566 real(DP) :: qinf
5567 real(DP) :: ex
5568 real(DP) :: ev
5569 real(DP) :: wr
5570 real(DP) :: resid
5571 real(DP) :: resid1
5572 real(DP) :: residb
5573 real(DP) :: derv
5574 real(DP) :: dh
5575 real(DP) :: ts
5576 real(DP) :: adh
5577 real(DP) :: adh0
5578 real(DP) :: v0
5579 real(DP) :: v1
5580 real(DP) :: area
5581 real(DP) :: qtolfact
5582 real(DP) :: delh
5583 !
5584 delh = this%delh
5585 !
5586 ! -- skip inactive lakes
5587 if (this%iboundpak(n) == 0) then
5588 this%ncncvr(n) = 1
5589 return
5590 end if
5591 ibflg = 0
5592 hlak = this%xnewpak(n)
5593 if (iter < maxiter) then
5594 this%stageiter(n) = this%xnewpak(n)
5595 end if
5596 call this%lak_calculate_rainfall(n, hlak, ra)
5597 this%precip(n) = ra
5598 this%flwiter(n) = this%flwiter(n) + ra
5599 call this%lak_calculate_rainfall(n, hlak + delh, ra)
5600 this%precip1(n) = ra
5601 this%flwiter1(n) = this%flwiter1(n) + ra
5602 !
5603 ! -- limit withdrawals to lake inflows and lake storage
5604 call this%lak_calculate_withdrawal(n, this%flwiter(n), wr)
5605 this%withr(n) = wr
5606 call this%lak_calculate_withdrawal(n, this%flwiter1(n), wr)
5607 this%withr1(n) = wr
5608 !
5609 ! -- limit evaporation to lake inflows and lake storage
5610 call this%lak_calculate_evaporation(n, hlak, this%flwiter(n), ev)
5611 this%evap(n) = ev
5612 call this%lak_calculate_evaporation(n, hlak + delh, this%flwiter1(n), ev)
5613 this%evap1(n) = ev
5614 !
5615 ! -- no outlet flow if evaporation consumes all water
5616 call this%lak_calculate_outlet_outflow(n, hlak + delh, &
5617 this%flwiter1(n), &
5618 this%surfout1(n))
5619 call this%lak_calculate_outlet_outflow(n, hlak, this%flwiter(n), &
5620 this%surfout(n))
5621 !
5622 ! -- update the surface inflow values
5623 call this%lak_calculate_outlet_inflow(n, this%surfin(n))
5624 !
5625 !
5626 if (ncnv == 1) then
5627 if (this%iboundpak(n) > 0 .and. lupdate .eqv. .true.) then
5628 !
5629 ! -- recalculate flwin
5630 hlak0 = this%xoldpak(n)
5631 hlak = this%xnewpak(n)
5632 call this%lak_calculate_vol(n, hlak0, v0)
5633 call this%lak_calculate_vol(n, hlak, v1)
5634 call this%lak_calculate_runoff(n, ro)
5635 call this%lak_calculate_inflow(n, qinf)
5636 call this%lak_calculate_external(n, ex)
5637 this%flwin(n) = this%surfin(n) + ro + qinf + ex + &
5638 max(v0, v1) / delt
5639 !
5640 ! -- compute new lake stage using Newton's method
5641 resid = this%precip(n) + this%evap(n) + this%withr(n) + ro + &
5642 qinf + ex + this%surfin(n) + &
5643 this%surfout(n) + this%seep(n)
5644 resid1 = this%precip1(n) + this%evap1(n) + this%withr1(n) + ro + &
5645 qinf + ex + this%surfin(n) + &
5646 this%surfout1(n) + this%seep1(n)
5647 !
5648 ! -- add storage changes for transient stress periods
5649 hlak = this%xnewpak(n)
5650 if (this%gwfiss /= 1) then
5651 call this%lak_calculate_vol(n, hlak, v1)
5652 resid = resid + (v0 - v1) / delt
5653 call this%lak_calculate_vol(n, hlak + delh, v1)
5654 resid1 = resid1 + (v0 - v1) / delt
5655 end if
5656 !
5657 ! -- determine the derivative and the stage change
5658 if (abs(resid1 - resid) > dzero) then
5659 derv = (resid1 - resid) / delh
5660 dh = dzero
5661 if (abs(derv) > dprec) then
5662 dh = resid / derv
5663 end if
5664 else
5665 if (resid < dzero) then
5666 resid = dzero
5667 end if
5668 call this%lak_vol2stage(n, resid, dh)
5669 dh = hlak - dh
5670 this%ncncvr(n) = 1
5671 end if
5672 !
5673 ! -- determine if the updated stage is outside the endpoints
5674 ts = hlak - dh
5675 if (iter == 1) this%dh0(n) = dh
5676 adh = abs(dh)
5677 adh0 = abs(this%dh0(n))
5678 if ((ts >= this%en2(n)) .or. (ts < this%en1(n))) then
5679 ! -- use bisection if dh is increasing or updated stage is below the
5680 ! bottom of the lake
5681 if ((adh > adh0) .or. (ts - this%lakebot(n)) < dprec) then
5682 residb = resid
5683 call this%lak_bisection(n, ibflg, hlak, ts, dh, residb)
5684 end if
5685 end if
5686 !
5687 ! -- set seep0 on the first lake iteration
5688 if (iter == 1) then
5689 this%seep0(n) = this%seep(n)
5690 end if
5691 !
5692 ! -- check for slow convergence
5693 if (this%seep(n) * this%seep0(n) < dprec) then
5694 this%iseepc(n) = this%iseepc(n) + 1
5695 else
5696 this%iseepc(n) = 0
5697 end if
5698 ! -- determine of convergence is slow and oscillating
5699 idhp = 0
5700 if (dh * this%dh0(n) < dprec) idhp = 1
5701 ! -- determine if stage change is increasing
5702 adh = abs(dh)
5703 if (adh > adh0) idhp = 1
5704 ! -- increment idhc convergence flag
5705 if (idhp == 1) then
5706 this%idhc(n) = this%idhc(n) + 1
5707 end if
5708 !
5709 ! -- switch to bisection when the Newton-Raphson method oscillates
5710 ! or when convergence is slow
5711 if (ibflg == 1) then
5712 if (this%iseepc(n) > 7 .or. this%idhc(n) > 12) then
5713 call this%lak_bisection(n, ibflg, hlak, ts, dh, residb)
5714 end if
5715 end if
5716 else
5717 dh = dzero
5718 end if
5719 !
5720 ! -- update lake stage
5721 hlak = hlak - dh
5722 if (hlak < this%lakebot(n)) then
5723 hlak = this%lakebot(n)
5724 end if
5725 !
5726 ! -- calculate surface area
5727 call this%lak_calculate_sarea(n, hlak, area)
5728 !
5729 ! -- set the Q to length factor
5730 if (area > dzero) then
5731 qtolfact = delt / area
5732 else
5733 qtolfact = dzero
5734 end if
5735 !
5736 ! -- recalculate the residual
5737 call this%lak_calculate_residual(n, hlak, resid)
5738 !
5739 ! -- evaluate convergence
5740 !if (ABS(dh) < delh) then
5741 if (abs(dh) < delh .and. abs(resid) * qtolfact < this%dmaxchg) then
5742 this%ncncvr(n) = 1
5743 end if
5744 this%xnewpak(n) = hlak
5745 !
5746 ! -- save iterates for lake
5747 this%seep0(n) = this%seep(n)
5748 this%dh0(n) = dh
5749 end if

◆ lak_source_connectiondata()

subroutine lakmodule::lak_source_connectiondata ( class(laktype), intent(inout) this)
private

Definition at line 910 of file gwf-lak.f90.

911 ! -- dummy
912 class(LakType), intent(inout) :: this
913 ! -- local
914 integer(I4B) :: n, j, ipos, nn
915 integer(I4B) :: ilak, iconn
916 integer(I4B) :: ipos0, icellid0, icellid, nn2
917 logical(LGP) :: is_lake_bed
918 character(len=LINELENGTH) :: cellid_str
919 character(len=LINELENGTH) :: ctypenm
920 character(len=LINELENGTH) :: cbleak
921 real(DP) :: top, bot, rval
922 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
923 integer(I4B), dimension(:), pointer, contiguous :: iconns => null()
924 integer(I4B), dimension(:, :), pointer, contiguous :: cellid => null()
925 type(CharacterStringType), dimension(:), pointer, contiguous :: &
926 claktype => null()
927 type(CharacterStringType), dimension(:), pointer, contiguous :: &
928 bedleak => null()
929 real(DP), dimension(:), pointer, contiguous :: belev => null()
930 real(DP), dimension(:), pointer, contiguous :: telev => null()
931 real(DP), dimension(:), pointer, contiguous :: connlen => null()
932 real(DP), dimension(:), pointer, contiguous :: connwidth => null()
933 integer(I4B), allocatable :: nboundchk(:)
934 !
935 ! -- allocate connection data arrays
936 call mem_allocate(this%imap, this%MAXBOUND, 'IMAP', this%memoryPath)
937 call mem_allocate(this%gwfconn, this%MAXBOUND, 'GWFCONN', this%memoryPath)
938 call mem_allocate(this%nodesontop, this%MAXBOUND, 'NODESONTOP', &
939 this%memoryPath)
940 call mem_allocate(this%ictype, this%MAXBOUND, 'ICTYPE', this%memoryPath)
941 call mem_allocate(this%bedleak, this%MAXBOUND, 'BEDLEAK', this%memoryPath)
942 call mem_allocate(this%belev, this%MAXBOUND, 'BELEV', this%memoryPath)
943 call mem_allocate(this%telev, this%MAXBOUND, 'TELEV', this%memoryPath)
944 call mem_allocate(this%connlength, this%MAXBOUND, 'CONNLENGTH', &
945 this%memoryPath)
946 call mem_allocate(this%connwidth, this%MAXBOUND, 'CONNWIDTH', &
947 this%memoryPath)
948 call mem_allocate(this%sarea, this%MAXBOUND, 'SAREA', this%memoryPath)
949 call mem_allocate(this%warea, this%MAXBOUND, 'WAREA', this%memoryPath)
950 call mem_allocate(this%satcond, this%MAXBOUND, 'SATCOND', this%memoryPath)
951 call mem_allocate(this%simcond, this%MAXBOUND, 'SIMCOND', this%memoryPath)
952 call mem_allocate(this%simlakgw, this%MAXBOUND, 'SIMLAKGW', this%memoryPath)
953 !
954 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text))// &
955 ' CONNECTIONDATA'
956 !
957 ! -- get input context CONNECTIONDATA column arrays
958 call mem_setptr(ifno, 'CONNDATA_IFNO', this%input_mempath)
959 call mem_setptr(iconns, 'ICONN', this%input_mempath)
960 call mem_setptr(cellid, 'CELLID', this%input_mempath)
961 call mem_setptr(claktype, 'CLAKTYPE', this%input_mempath)
962 call mem_setptr(bedleak, 'BEDLEAK', this%input_mempath)
963 call mem_setptr(belev, 'BELEV', this%input_mempath)
964 call mem_setptr(telev, 'TELEV', this%input_mempath)
965 call mem_setptr(connlen, 'CONNLEN', this%input_mempath)
966 call mem_setptr(connwidth, 'CONNWIDTH', this%input_mempath)
967 !
968 ! -- allocate check array
969 allocate (nboundchk(this%MAXBOUND))
970 nboundchk = 0
971 !
972 do n = 1, this%MAXBOUND
973 !
974 ilak = ifno(n)
975 iconn = iconns(n)
976 !
977 if (ilak < 1 .or. ilak > this%nlakes) then
978 write (errmsg, '(a,1x,i0)') 'lakeno MUST BE > 0 and <= ', this%nlakes
979 call store_error(errmsg)
980 cycle
981 end if
982 if (iconn < 1 .or. iconn > this%nlakeconn(ilak)) then
983 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
984 'iconn FOR LAKE ', ilak, 'MUST BE > 0 and <= ', this%nlakeconn(ilak)
985 call store_error(errmsg)
986 cycle
987 end if
988 !
989 ipos = this%idxlakeconn(ilak) + iconn - 1
990 this%imap(ipos) = ilak
991 nboundchk(ipos) = nboundchk(ipos) + 1
992 !
993 ! -- convert cellid integer array to string and resolve to a node number.
994 write (cellid_str, '(10(i0,1x))') cellid(1:this%dis%ndim, n)
995 nn = this%dis%noder_from_cellid(cellid_str, this%inunit, this%iout)
996 if (nn < 1) then
997 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
998 'INVALID cellid FOR LAKE ', ilak, 'connection', iconn
999 call store_error(errmsg)
1000 end if
1001 this%gwfconn(ipos) = nn
1002 this%nodesontop(ipos) = nn
1003 !
1004 ! -- connection type
1005 ctypenm = claktype(n)
1006 select case (trim(ctypenm))
1007 case ('VERTICAL')
1008 this%ictype(ipos) = 0
1009 case ('HORIZONTAL')
1010 this%ictype(ipos) = 1
1011 case ('EMBEDDEDH')
1012 this%ictype(ipos) = 2
1013 case ('EMBEDDEDV')
1014 this%ictype(ipos) = 3
1015 case default
1016 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,a,a)') &
1017 'UNKNOWN ctype FOR LAKE ', ilak, 'connection', iconn, &
1018 '(', trim(ctypenm), ')'
1019 call store_error(errmsg)
1020 end select
1021 !
1022 ! -- bed leakance
1023 cbleak = bedleak(n)
1024 select case (trim(cbleak))
1025 case ('NONE')
1026 is_lake_bed = .false.
1027 rval = dnodata
1028 write (warnmsg, '(2(a,1x,i0,1x),a,1pe8.1,a)') &
1029 'BEDLEAK for connection', iconn, 'in lake', ilak, &
1030 'is specified to be NONE. Lake connections where the lake-GWF '// &
1031 'connection conductance is solely a function of aquifer '// &
1032 'properties in the connected GWF cell should be specified '// &
1033 'with a DNODATA (', dnodata, ') value.'
1034 call deprecation_warning('CONNECTIONDATA', 'bedleak=NONE', '6.4.3', &
1035 warnmsg, this%inunit)
1036 case default
1037 read (cbleak, *) rval
1038 if (is_close(rval, dnodata)) then
1039 is_lake_bed = .false.
1040 else
1041 is_lake_bed = .true.
1042 end if
1043 end select
1044 this%bedleak(ipos) = rval
1045 if (is_lake_bed .and. this%bedleak(ipos) < dzero) then
1046 write (errmsg, '(a,1x,i0,1x,a)') 'bedleak FOR LAKE ', ilak, &
1047 'MUST BE >= 0'
1048 call store_error(errmsg)
1049 end if
1050 !
1051 ! -- belev
1052 this%belev(ipos) = belev(n)
1053 !
1054 ! -- telev
1055 this%telev(ipos) = telev(n)
1056 !
1057 ! -- connection length
1058 rval = connlen(n)
1059 if (rval <= dzero) then
1060 if (this%ictype(ipos) == 1 .or. this%ictype(ipos) == 2 .or. &
1061 this%ictype(ipos) == 3) then
1062 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,a,1x,a)') &
1063 'connection length (connlen) FOR LAKE ', ilak, &
1064 ', CONNECTION NO.', iconn, ', MUST BE > 0 FOR SPECIFIED ', &
1065 'connection type (ctype)', trim(ctypenm)
1066 call store_error(errmsg)
1067 else
1068 rval = dzero
1069 end if
1070 end if
1071 this%connlength(ipos) = rval
1072 !
1073 ! -- connection width
1074 rval = connwidth(n)
1075 if (rval < dzero) then
1076 if (this%ictype(ipos) == 1) then
1077 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1078 'cell width (connwidth) FOR LAKE ', ilak, &
1079 ' HORIZONTAL CONNECTION ', iconn, 'MUST BE >= 0'
1080 call store_error(errmsg)
1081 else
1082 rval = dzero
1083 end if
1084 end if
1085 this%connwidth(ipos) = rval
1086 end do
1087 !
1088 write (this%iout, '(1x,a)') &
1089 'END OF '//trim(adjustl(this%text))//' CONNECTIONDATA'
1090 !
1091 ! -- terminate if any errors were detected
1092 if (count_errors() > 0) then
1093 call store_error_filename(this%input_fname)
1094 end if
1095 !
1096 ! -- check that embedded lakes have only one connection
1097 do n = 1, this%nlakes
1098 j = 0
1099 do ipos = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1100 if (this%ictype(ipos) /= 2 .and. this%ictype(ipos) /= 3) cycle
1101 j = j + 1
1102 if (j > 1) then
1103 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1104 'nlakeconn FOR LAKE', n, 'EMBEDDED CONNECTION', j, ' EXCEEDS 1.'
1105 call store_error(errmsg)
1106 end if
1107 end do
1108 end do
1109 ! -- check that an embedded lake is not in the same cell as a lake
1110 ! with a vertical connection
1111 do n = 1, this%nlakes
1112 ipos0 = this%idxlakeconn(n)
1113 icellid0 = this%gwfconn(ipos0)
1114 if (this%ictype(ipos0) /= 2 .and. this%ictype(ipos0) /= 3) cycle
1115 do nn2 = 1, this%nlakes
1116 if (nn2 == n) cycle
1117 j = 0
1118 do ipos = this%idxlakeconn(nn2), this%idxlakeconn(nn2 + 1) - 1
1119 j = j + 1
1120 icellid = this%gwfconn(ipos)
1121 if (icellid == icellid0) then
1122 if (this%ictype(ipos) == 0) then
1123 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1124 'EMBEDDED LAKE', n, &
1125 'CANNOT COINCIDE WITH VERTICAL CONNECTION', j, &
1126 'IN LAKE', nn2, '.'
1127 call store_error(errmsg)
1128 end if
1129 end if
1130 end do
1131 end do
1132 end do
1133 !
1134 ! -- process the data (post-processing: telev/belev/laketop/lakebot)
1135 do n = 1, this%nlakes
1136 j = 0
1137 do ipos = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1138 j = j + 1
1139 nn = this%gwfconn(ipos)
1140 top = this%dis%top(nn)
1141 bot = this%dis%bot(nn)
1142 if (this%ictype(ipos) == 0) then
1143 this%telev(ipos) = top + this%surfdep
1144 this%belev(ipos) = top
1145 this%lakebot(n) = min(this%belev(ipos), this%lakebot(n))
1146 else if (this%ictype(ipos) == 1) then
1147 if (this%belev(ipos) == this%telev(ipos)) then
1148 this%telev(ipos) = top
1149 this%belev(ipos) = bot
1150 else
1151 if (this%belev(ipos) >= this%telev(ipos)) then
1152 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1153 'telev FOR LAKE ', n, ' HORIZONTAL CONNECTION ', j, &
1154 'MUST BE >= belev'
1155 call store_error(errmsg)
1156 else if (this%belev(ipos) < bot) then
1157 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.7,1x,a)') &
1158 'belev FOR LAKE ', n, ' HORIZONTAL CONNECTION ', j, &
1159 'MUST BE >= cell bottom (', bot, ')'
1160 call store_error(errmsg)
1161 else if (this%telev(ipos) > top) then
1162 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.7,1x,a)') &
1163 'telev FOR LAKE ', n, ' HORIZONTAL CONNECTION ', j, &
1164 'MUST BE <= cell top (', top, ')'
1165 call store_error(errmsg)
1166 end if
1167 end if
1168 this%laketop(n) = max(this%telev(ipos), this%laketop(n))
1169 this%lakebot(n) = min(this%belev(ipos), this%lakebot(n))
1170 else if (this%ictype(ipos) == 2 .or. this%ictype(ipos) == 3) then
1171 this%telev(ipos) = top
1172 this%belev(ipos) = bot
1173 this%lakebot(n) = bot
1174 end if
1175 !
1176 ! -- check for missing or duplicate connections
1177 if (nboundchk(ipos) == 0) then
1178 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
1179 'NO DATA SPECIFIED FOR LAKE', n, 'CONNECTION', j
1180 call store_error(errmsg)
1181 else if (nboundchk(ipos) > 1) then
1182 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1183 'DATA FOR LAKE', n, 'CONNECTION', j, &
1184 'SPECIFIED', nboundchk(ipos), 'TIMES'
1185 call store_error(errmsg)
1186 end if
1187 end do
1188 if (this%laketop(n) == -dep20) then
1189 this%laketop(n) = this%lakebot(n) + 100.
1190 end if
1191 end do
1192 !
1193 deallocate (nboundchk)
1194 !
1195 if (count_errors() > 0) then
1196 call store_error_filename(this%input_fname)
1197 end if
1198 !
1199 ! -- release input context connectiondata memory
1200 call memorystore_release('CONNDATA_IFNO', this%input_mempath)
1201 call memorystore_release('ICONN', this%input_mempath)
1202 call memorystore_release('CELLID', this%input_mempath)
1203 call memorystore_release('CLAKTYPE', this%input_mempath)
1204 call memorystore_release('BEDLEAK', this%input_mempath)
1205 call memorystore_release('BELEV', this%input_mempath)
1206 call memorystore_release('TELEV', this%input_mempath)
1207 call memorystore_release('CONNLEN', this%input_mempath)
1208 call memorystore_release('CONNWIDTH', this%input_mempath)
Here is the call graph for this function:

◆ lak_source_dimensions()

subroutine lakmodule::lak_source_dimensions ( class(laktype), intent(inout) this)
private

Definition at line 1638 of file gwf-lak.f90.

1639 ! -- dummy
1640 class(LakType), intent(inout) :: this
1641 ! -- local
1642 type(GwfLakParamFoundType) :: found
1643 !
1644 ! -- initialize dimensions to -1
1645 this%nlakes = -1
1646 this%maxbound = -1
1647 !
1648 write (this%iout, '(/1x,a)') &
1649 'PROCESSING '//trim(adjustl(this%text))//' DIMENSIONS'
1650 !
1651 ! -- NLAKES (mf6internal: nlakes); kept in the input context (not
1652 ! released) since PERIOD settings resolve it by name via SHAPE
1653 call mem_set_value(this%nlakes, 'NLAKES', this%input_mempath, &
1654 found%nlakes, release=.false.)
1655 if (found%nlakes) write (this%iout, '(4x,a,i7)') 'NLAKES = ', this%nlakes
1656 !
1657 ! -- NOUTLETS (mf6internal: noutlets); kept in the input context (not
1658 ! released) since PERIOD settings resolve it by name via SHAPE
1659 call mem_set_value(this%noutlets, 'NOUTLETS', this%input_mempath, &
1660 found%noutlets, release=.false.)
1661 if (found%noutlets) write (this%iout, '(4x,a,i7)') &
1662 'NOUTLETS = ', this%noutlets
1663 !
1664 ! -- NTABLES (mf6internal: ntables)
1665 call mem_set_value(this%ntables, 'NTABLES', this%input_mempath, found%ntables)
1666 if (found%ntables) write (this%iout, '(4x,a,i7)') 'NTABLES = ', this%ntables
1667 !
1668 write (this%iout, '(1x,a)') &
1669 'END OF '//trim(adjustl(this%text))//' DIMENSIONS'
1670 !
1671 if (this%nlakes < 0) then
1672 write (errmsg, '(a)') &
1673 'NLAKES WAS NOT SPECIFIED OR WAS SPECIFIED INCORRECTLY.'
1674 call store_error(errmsg)
1675 call store_error_filename(this%input_fname)
1676 return
1677 end if
1678 !
1679 if (this%iforceleglak /= 0) then
1680 if (this%iforceleglak < 1 .or. this%iforceleglak > this%nlakes) then
1681 write (errmsg, '(a,i0,a,i0,a)') &
1682 'DEV_FORCE_LEGACY_LAKE (', this%iforceleglak, &
1683 ') MUST BE BETWEEN 1 AND NLAKES (', this%nlakes, ').'
1684 call store_error(errmsg)
1685 call store_error_filename(this%input_fname)
1686 return
1687 end if
1688 end if
1689 !
1690 ! -- read PACKAGEDATA
1691 call this%lak_source_packagedata()
1692 !
1693 ! -- for the implicit formulation each lake adds one equation (one row and
1694 ! column) to the groundwater flow matrix
1695 if (this%iimplicit /= 0) then
1696 this%npakeq = this%nlakes
1697 ! -- the implicit lake-aquifer coupling is asymmetric for perched
1698 ! connections, so flag the coefficient matrix as asymmetric (which
1699 ! requires the BICGSTAB linear acceleration). Only raise the flag; never
1700 ! clear an asymmetry already indicated elsewhere.
1701 this%iasym = 1
1702 end if
1703 !
1704 ! -- read CONNECTIONDATA
1705 call this%lak_source_connectiondata()
1706 !
1707 ! -- read TABLES
1708 call this%lak_source_tables()
1709 !
1710 ! -- read OUTLETS
1711 call this%lak_source_outlets()
1712 !
1713 ! -- alias deprecated variable names
1714 call this%lak_checkin_deprecated_names()
1715 !
1716 ! -- Call define_listlabel
1717 call this%define_listlabel()
1718 !
1719 ! -- setup the budget object
1720 call this%lak_setup_budobj()
1721 !
1722 ! -- setup the stage table object
1723 call this%lak_setup_tableobj()
Here is the call graph for this function:

◆ lak_source_options()

subroutine lakmodule::lak_source_options ( class(laktype), intent(inout) this)
private

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

3036 ! -- dummy
3037 class(LakType), intent(inout) :: this
3038 ! -- local
3039 type(GwfLakParamFoundType) :: found
3040 integer(I4B) :: isize
3041 character(len=LINELENGTH) :: fname
3042 ! -- formats
3043 character(len=*), parameter :: fmtlengthconv = &
3044 &"(4x, 'LENGTH CONVERSION VALUE (',g15.7,') SPECIFIED.')"
3045 character(len=*), parameter :: fmttimeconv = &
3046 &"(4x, 'TIME CONVERSION VALUE (',g15.7,') SPECIFIED.')"
3047 character(len=*), parameter :: fmtlakeopt = &
3048 &"(4x, 'LAKE ', a, ' VALUE (',g15.7,') SPECIFIED.')"
3049 character(len=*), parameter :: fmtoutdmax = &
3050 &"(4x, 'MAXIMUM OUTLET WATER DEPTH (',g15.7,') SPECIFIED.')"
3051 character(len=*), parameter :: fmtlakbin = &
3052 "(4x, 'LAK ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', &
3053 &a, /4x, 'OPENED ON UNIT: ', I0)"
3054 character(len=*), parameter :: fmtiter = &
3055 &"(4x, 'MAXIMUM LAK ITERATION VALUE (',i0,') SPECIFIED.')"
3056 character(len=*), parameter :: fmtdmaxchg = &
3057 &"(4x, 'MAXIMUM STAGE CHANGE VALUE (',g0,') SPECIFIED.')"
3058 !
3059 ! -- call base class to handle AUXILIARY/NAUX, BOUNDNAMES, PRINT_INPUT,
3060 ! PRINT_FLOWS, SAVE_FLOWS, OBS6_FILENAME
3061 call this%BndExtType%source_options()
3062 !
3063 write (this%iout, '(1x,a)') &
3064 'PROCESSING '//trim(adjustl(this%text))//' OPTIONS'
3065 !
3066 ! -- PRINT_STAGE
3067 call mem_set_value(this%iprhed, 'PRINT_STAGE', this%input_mempath, &
3068 found%print_stage)
3069 if (found%print_stage) then
3070 write (this%iout, '(4x,a)') trim(adjustl(this%text))// &
3071 ' STAGES WILL BE PRINTED TO LISTING FILE.'
3072 end if
3073 !
3074 ! -- STAGE FILEOUT
3075 call mem_set_value(fname, 'STAGEFILE', this%input_mempath, found%stagefile)
3076 if (found%stagefile) then
3077 this%istageout = getunit()
3078 call openfile(this%istageout, this%iout, fname, 'DATA(BINARY)', &
3079 form, access, 'REPLACE', mode_opt=mnormal)
3080 write (this%iout, fmtlakbin) 'STAGE', trim(adjustl(fname)), this%istageout
3081 end if
3082 !
3083 ! -- BUDGET FILEOUT
3084 call mem_set_value(fname, 'BUDGETFILE', this%input_mempath, found%budgetfile)
3085 if (found%budgetfile) then
3086 call assign_iounit(this%ibudgetout, this%inunit, 'BUDGET fileout')
3087 call openfile(this%ibudgetout, this%iout, fname, 'DATA(BINARY)', &
3088 form, access, 'REPLACE', mode_opt=mnormal)
3089 write (this%iout, fmtlakbin) 'BUDGET', trim(adjustl(fname)), this%ibudgetout
3090 end if
3091 !
3092 ! -- BUDGETCSV FILEOUT
3093 call mem_set_value(fname, 'BUDGETCSVFILE', this%input_mempath, &
3094 found%budgetcsvfile)
3095 if (found%budgetcsvfile) then
3096 call assign_iounit(this%ibudcsv, this%inunit, 'BUDGETCSV fileout')
3097 call openfile(this%ibudcsv, this%iout, fname, 'CSV', filstat_opt='REPLACE')
3098 write (this%iout, fmtlakbin) 'BUDGET CSV', trim(adjustl(fname)), &
3099 this%ibudcsv
3100 end if
3101 !
3102 ! -- PACKAGE_CONVERGENCE FILEOUT (mf6internal: pkgconvfname)
3103 ! -- defer opening until lak_ar, where the IMPLICIT option is known. The
3104 ! file is not opened for the implicit formulation (lak_cc does not
3105 ! write package convergence in that case).
3106 call mem_set_value(fname, 'PKGCONVFNAME', this%input_mempath, &
3107 found%pkgconvfname)
3108 if (found%pkgconvfname) then
3109 this%pakcsvfile = trim(adjustl(fname))
3110 end if
3111 !
3112 ! -- MOVER
3113 call mem_set_value(this%imover, 'MOVER', this%input_mempath, found%mover)
3114 if (found%mover) then
3115 write (this%iout, '(4x,A)') 'MOVER OPTION ENABLED'
3116 end if
3117 !
3118 ! -- LENGTH_CONVERSION (mf6internal: convlength)
3119 call mem_set_value(this%convlength, 'CONVLENGTH', this%input_mempath, &
3120 found%convlength)
3121 if (found%convlength) write (this%iout, fmtlengthconv) this%convlength
3122 !
3123 ! -- TIME_CONVERSION (mf6internal: convtime)
3124 call mem_set_value(this%convtime, 'CONVTIME', this%input_mempath, &
3125 found%convtime)
3126 if (found%convtime) write (this%iout, fmttimeconv) this%convtime
3127 !
3128 ! -- SURFDEP (mf6internal: surfdep)
3129 call mem_set_value(this%surfdep, 'SURFDEP', this%input_mempath, found%surfdep)
3130 if (found%surfdep) then
3131 if (this%surfdep < dzero) this%surfdep = dzero
3132 write (this%iout, fmtlakeopt) 'SURFDEP', this%surfdep
3133 end if
3134 !
3135 ! -- MAXIMUM_ITERATIONS (mf6internal: maxlakit)
3136 call mem_set_value(this%maxlakit, 'MAXLAKIT', this%input_mempath, &
3137 found%maxlakit)
3138 if (found%maxlakit) write (this%iout, fmtiter) this%maxlakit
3139 !
3140 ! -- MAXIMUM_STAGE_CHANGE (mf6internal: dmaxchg)
3141 call mem_set_value(this%dmaxchg, 'DMAXCHG', this%input_mempath, found%dmaxchg)
3142 if (found%dmaxchg) then
3143 this%delh = dp999 * this%dmaxchg
3144 write (this%iout, fmtdmaxchg) this%dmaxchg
3145 end if
3146 !
3147 ! -- DEV_GROUNDWATER_HEAD_CONDUCTANCE (mf6internal: igwhcopt)
3148 call mem_set_value(this%igwhcopt, 'IGWHCOPT', this%input_mempath, &
3149 found%igwhcopt)
3150 if (found%igwhcopt) then
3151 write (this%iout, '(4x,a)') &
3152 'CONDUCTANCE FOR HORIZONTAL CONNECTIONS WILL BE CALCULATED &
3153 &USING THE GROUNDWATER HEAD'
3154 end if
3155 !
3156 ! -- IMPLICIT (mf6internal: iimplicit)
3157 call mem_set_value(this%iimplicit, 'IIMPLICIT', this%input_mempath, &
3158 found%iimplicit)
3159 if (found%iimplicit) then
3160 write (this%iout, '(4x,a)') &
3161 'LAKE STAGE WILL BE SOLVED AS AN UNKNOWN IN THE GROUNDWATER FLOW '// &
3162 'MATRIX (IMPLICIT FORMULATION)'
3163 end if
3164 !
3165 ! -- DEV_FORCE_LEGACY (mf6internal: iforceleg)
3166 call mem_set_value(this%iforceleg, 'IFORCELEG', this%input_mempath, &
3167 found%iforceleg)
3168 !
3169 ! -- DEV_FORCE_LEGACY_LAKE (mf6internal: iforceleglak); loaded before
3170 ! either block below so both mutual-exclusion checks see a final value
3171 call mem_set_value(this%iforceleglak, 'IFORCELEGLAK', this%input_mempath, &
3172 found%iforceleglak)
3173 !
3174 if (found%iforceleg) then
3175 write (this%iout, '(4x,a)') &
3176 'EVERY ACTIVE LAKE WILL BE SOLVED WITH THE LEGACY SUBSTITUTION '// &
3177 'SOLVER UNDER THE IMPLICIT FORMULATION'
3178 if (this%iforceleglak /= 0) then
3179 call store_error('DEV_FORCE_LEGACY and DEV_FORCE_LEGACY_LAKE '// &
3180 'cannot both be specified.')
3181 end if
3182 end if
3183 !
3184 if (found%iforceleglak) then
3185 write (this%iout, '(4x,a,i0,a)') 'LAKE ', this%iforceleglak, &
3186 ' WILL BE SOLVED WITH THE LEGACY SUBSTITUTION SOLVER UNDER THE '// &
3187 'IMPLICIT FORMULATION'
3188 if (this%iforceleg /= 0) then
3189 call store_error('DEV_FORCE_LEGACY and DEV_FORCE_LEGACY_LAKE '// &
3190 'cannot both be specified.')
3191 end if
3192 end if
3193 !
3194 ! -- DEV_NO_FINAL_CHECK (mf6internal: iconvchk)
3195 call get_isize('ICONVCHK', this%input_mempath, isize)
3196 if (isize > 0) then
3197 this%iconvchk = 0
3198 write (this%iout, '(4x,a)') &
3199 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN LAKE STAGES &
3200 &WILL NOT BE MADE'
3201 end if
3202 !
3203 ! -- DEV_MAXIMUM_OUTLET_DEPTH (mf6internal: outdmax)
3204 call mem_set_value(this%outdmax, 'OUTDMAX', this%input_mempath, found%outdmax)
3205 if (found%outdmax) write (this%iout, fmtoutdmax) this%outdmax
3206 !
3207 write (this%iout, '(1x,a)') 'END OF '//trim(adjustl(this%text))//' OPTIONS'
Here is the call graph for this function:

◆ lak_source_outlets()

subroutine lakmodule::lak_source_outlets ( class(laktype), intent(inout) this)
private

Definition at line 1504 of file gwf-lak.f90.

1505 ! -- dummy
1506 class(LakType), intent(inout) :: this
1507 ! -- local
1508 integer(I4B) :: n, isize, ioutlet
1509 character(len=LINELENGTH) :: keyword
1510 integer(I4B), dimension(:), pointer, contiguous :: outletno => null()
1511 integer(I4B), dimension(:), pointer, contiguous :: lakein => null()
1512 integer(I4B), dimension(:), pointer, contiguous :: lakeout => null()
1513 type(CharacterStringType), dimension(:), pointer, contiguous :: &
1514 couttype => null()
1515 real(DP), dimension(:), pointer, contiguous :: outlets_invert => null()
1516 real(DP), dimension(:), pointer, contiguous :: outlets_width => null()
1517 real(DP), dimension(:), pointer, contiguous :: outlets_rough => null()
1518 real(DP), dimension(:), pointer, contiguous :: outlets_slope => null()
1519 integer(I4B), allocatable :: nboundchk(:)
1520 !
1521 ! -- skip if no outlets
1522 if (this%noutlets < 1) return
1523 !
1524 ! -- guard: OUTLETS block required when noutlets > 0
1525 call get_isize('OUTLETS_OUTLETNO', this%input_mempath, isize)
1526 if (isize < 1) then
1527 write (errmsg, '(a)') &
1528 'NOUTLETS > 0 BUT AN OUTLETS BLOCK WAS NOT FOUND IN THE LAK INPUT.'
1529 call store_error(errmsg, .true.)
1530 end if
1531 !
1532 ! -- allocate outlet arrays
1533 call mem_allocate(this%lakein, this%noutlets, 'LAKEIN', this%memoryPath)
1534 call mem_allocate(this%lakeout, this%noutlets, 'LAKEOUT', this%memoryPath)
1535 call mem_allocate(this%iouttype, this%noutlets, 'IOUTTYPE', this%memoryPath)
1536 ! -- alias into the input context's permanent, feature-indexed arrays
1537 ! (allocated and DZERO-initialized by the loader)
1538 call mem_setptr(this%outrate, 'RATE', this%input_mempath)
1539 call mem_setptr(this%outinvert, 'INVERT', this%input_mempath)
1540 call mem_setptr(this%outwidth, 'WIDTH', this%input_mempath)
1541 call mem_setptr(this%outrough, 'ROUGH', this%input_mempath)
1542 call mem_setptr(this%outslope, 'SLOPE', this%input_mempath)
1543 call mem_allocate(this%simoutrate, this%noutlets, 'SIMOUTRATE', &
1544 this%memoryPath)
1545 call mem_allocate(this%outlet_invert_set, this%noutlets, &
1546 'INVERT_SET', this%memoryPath)
1547 call mem_allocate(this%outlet_width_set, this%noutlets, &
1548 'WIDTH_SET', this%memoryPath)
1549 call mem_allocate(this%outlet_rough_set, this%noutlets, &
1550 'ROUGH_SET', this%memoryPath)
1551 call mem_allocate(this%outlet_slope_set, this%noutlets, &
1552 'SLOPE_SET', this%memoryPath)
1553 this%outlet_invert_set = .false.
1554 this%outlet_width_set = .false.
1555 this%outlet_rough_set = .false.
1556 this%outlet_slope_set = .false.
1557 !
1558 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text))// &
1559 ' OUTLETS'
1560 !
1561 ! -- set input context pointers
1562 call mem_setptr(outletno, 'OUTLETS_OUTLETNO', this%input_mempath)
1563 call mem_setptr(lakein, 'LAKEIN', this%input_mempath)
1564 call mem_setptr(lakeout, 'LAKEOUT', this%input_mempath)
1565 call mem_setptr(couttype, 'COUTTYPE', this%input_mempath)
1566 call mem_setptr(outlets_invert, 'OUTLETS_INVERT', this%input_mempath)
1567 call mem_setptr(outlets_width, 'OUTLETS_WIDTH', this%input_mempath)
1568 call mem_setptr(outlets_rough, 'OUTLETS_ROUGH', this%input_mempath)
1569 call mem_setptr(outlets_slope, 'OUTLETS_SLOPE', this%input_mempath)
1570 !
1571 allocate (nboundchk(this%noutlets))
1572 nboundchk = 0
1573 !
1574 do n = 1, size(outletno)
1575 ioutlet = this%validate_ifno(outletno(n), this%noutlets, &
1576 nboundchk, 'outletno', 'OUTLETS')
1577 if (ioutlet == 0) cycle
1578 !
1579 ! -- lakein
1580 if (lakein(n) < 1 .or. lakein(n) > this%nlakes) then
1581 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
1582 'lakein FOR OUTLET ', ioutlet, 'MUST BE > 0 and <= ', this%nlakes
1583 call store_error(errmsg)
1584 end if
1585 this%lakein(ioutlet) = lakein(n)
1586 !
1587 ! -- lakeout
1588 if (lakeout(n) < 0 .or. lakeout(n) > this%nlakes) then
1589 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
1590 'lakeout FOR OUTLET ', ioutlet, 'MUST BE >= 0 and <= ', this%nlakes
1591 call store_error(errmsg)
1592 end if
1593 this%lakeout(ioutlet) = lakeout(n)
1594 !
1595 ! -- outlet type
1596 keyword = couttype(n)
1597 select case (trim(keyword))
1598 case ('SPECIFIED')
1599 this%iouttype(ioutlet) = 0
1600 case ('MANNING')
1601 this%iouttype(ioutlet) = 1
1602 case ('WEIR')
1603 this%iouttype(ioutlet) = 2
1604 case default
1605 write (errmsg, '(a,1x,i0,1x,a,a,a)') &
1606 'UNKNOWN couttype FOR OUTLET ', ioutlet, '(', trim(keyword), ')'
1607 call store_error(errmsg)
1608 end select
1609 !
1610 ! -- outlet invert, width, roughness, slope
1611 this%outinvert(ioutlet) = outlets_invert(n)
1612 this%outwidth(ioutlet) = outlets_width(n)
1613 this%outrough(ioutlet) = outlets_rough(n)
1614 this%outslope(ioutlet) = outlets_slope(n)
1615 end do
1616 !
1617 write (this%iout, '(1x,a)') 'END OF '//trim(adjustl(this%text))//' OUTLETS'
1618 !
1619 ! -- check for duplicate or missing outlets
1620 call this%report_ifno_coverage(nboundchk, this%noutlets, 'outlet', &
1621 'OUTLETS')
1622 !
1623 deallocate (nboundchk)
1624 !
1625 if (count_errors() > 0) then
1626 call store_error_filename(this%input_fname)
1627 end if
1628 !
1629 ! -- release input context outlets memory; OUTLETS_OUTLETNO/INVERT/
1630 ! WIDTH/ROUGH/SLOPE excluded (bound by lak_input_init for PERIOD use)
1631 call memorystore_release('LAKEIN', this%input_mempath)
1632 call memorystore_release('LAKEOUT', this%input_mempath)
1633 call memorystore_release('COUTTYPE', this%input_mempath)
Here is the call graph for this function:

◆ lak_source_packagedata()

subroutine lakmodule::lak_source_packagedata ( class(laktype), intent(inout) this)
private

Definition at line 718 of file gwf-lak.f90.

719 ! -- dummy
720 class(LakType), intent(inout) :: this
721 ! -- local
722 integer(I4B) :: n
723 integer(I4B) :: ilak, nconn
724 character(len=9) :: cno
725 character(len=LENBOUNDNAME) :: bndName
726 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
727 real(DP), dimension(:), pointer, contiguous :: strt => null()
728 integer(I4B), dimension(:), pointer, contiguous :: nlakeconn => null()
729 type(CharacterStringType), dimension(:), pointer, contiguous :: &
730 boundname_cst => null()
731 integer(I4B), allocatable :: nboundchk(:)
732 !
733 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text))// &
734 ' PACKAGEDATA'
735 !
736 ! -- allocate lake arrays
737 call mem_allocate(this%nlakeconn, this%nlakes, 'NLAKECONN', this%memoryPath)
738 call mem_allocate(this%idxlakeconn, this%nlakes + 1, 'IDXLAKECONN', &
739 this%memoryPath)
740 call mem_allocate(this%ntabrow, this%nlakes, 'NTABROW', this%memoryPath)
741 call mem_allocate(this%strt, this%nlakes, 'STRT', this%memoryPath)
742 call mem_allocate(this%laketop, this%nlakes, 'LAKETOP', this%memoryPath)
743 call mem_allocate(this%lakebot, this%nlakes, 'LAKEBOT', this%memoryPath)
744 call mem_allocate(this%sareamax, this%nlakes, 'SAREAMAX', this%memoryPath)
745 ! -- alias into the input context's permanent, feature-indexed arrays
746 ! (allocated and DZERO-initialized by the loader)
747 call mem_setptr(this%stage, 'STAGE', this%input_mempath)
748 call mem_setptr(this%rainfall, 'RAINFALL', this%input_mempath)
749 call mem_setptr(this%evaporation, 'EVAPORATION', this%input_mempath)
750 call mem_setptr(this%runoff, 'RUNOFF', this%input_mempath)
751 call mem_setptr(this%inflow, 'INFLOW', this%input_mempath)
752 call mem_setptr(this%withdrawal, 'WITHDRAWAL', this%input_mempath)
753 call mem_allocate(this%avail, this%nlakes, 'AVAIL', this%memoryPath)
754 call mem_allocate(this%lkgwsink, this%nlakes, 'LKGWSINK', this%memoryPath)
755 call mem_allocate(this%ncncvr, this%nlakes, 'NCNCVR', this%memoryPath)
756 call mem_allocate(this%ilegacy, this%nlakes, 'ILEGACY', this%memoryPath)
757 call mem_allocate(this%nstuck, this%nlakes, 'NSTUCK', this%memoryPath)
758 call mem_allocate(this%surfin, this%nlakes, 'SURFIN', this%memoryPath)
759 call mem_allocate(this%surfout, this%nlakes, 'SURFOUT', this%memoryPath)
760 call mem_allocate(this%surfout1, this%nlakes, 'SURFOUT1', this%memoryPath)
761 call mem_allocate(this%precip, this%nlakes, 'PRECIP', this%memoryPath)
762 call mem_allocate(this%precip1, this%nlakes, 'PRECIP1', this%memoryPath)
763 call mem_allocate(this%evap, this%nlakes, 'EVAP', this%memoryPath)
764 call mem_allocate(this%evap1, this%nlakes, 'EVAP1', this%memoryPath)
765 call mem_allocate(this%evapo, this%nlakes, 'EVAPO', this%memoryPath)
766 call mem_allocate(this%withr, this%nlakes, 'WITHR', this%memoryPath)
767 call mem_allocate(this%withr1, this%nlakes, 'WITHR1', this%memoryPath)
768 call mem_allocate(this%flwin, this%nlakes, 'FLWIN', this%memoryPath)
769 call mem_allocate(this%flwiter, this%nlakes, 'FLWITER', this%memoryPath)
770 call mem_allocate(this%flwiter1, this%nlakes, 'FLWITER1', this%memoryPath)
771 call mem_allocate(this%seep, this%nlakes, 'SEEP', this%memoryPath)
772 call mem_allocate(this%seep1, this%nlakes, 'SEEP1', this%memoryPath)
773 call mem_allocate(this%seep0, this%nlakes, 'SEEP0', this%memoryPath)
774 call mem_allocate(this%stageiter, this%nlakes, 'STAGEITER', this%memoryPath)
775 call mem_allocate(this%chterm, this%nlakes, 'CHTERM', this%memoryPath)
776 !
777 ! -- lake boundary and stages. In the implicit formulation iboundpak
778 ! and xnewpak are aliased to slices of the global ibound/x vectors in
779 ! lak_set_pointers (called before this routine), so they are not
780 ! allocated here.
781 if (this%iimplicit == 0) then
782 call mem_allocate(this%iboundpak, this%nlakes, 'IBOUND', this%memoryPath)
783 call mem_allocate(this%xnewpak, this%nlakes, 'XNEWPAK', this%memoryPath)
784 end if
785 call mem_allocate(this%xoldpak, this%nlakes, 'XOLDPAK', this%memoryPath)
786 !
787 ! -- lake iteration variables
788 call mem_allocate(this%iseepc, this%nlakes, 'ISEEPC', this%memoryPath)
789 call mem_allocate(this%idhc, this%nlakes, 'IDHC', this%memoryPath)
790 call mem_allocate(this%en1, this%nlakes, 'EN1', this%memoryPath)
791 call mem_allocate(this%en2, this%nlakes, 'EN2', this%memoryPath)
792 call mem_allocate(this%r1, this%nlakes, 'R1', this%memoryPath)
793 call mem_allocate(this%r2, this%nlakes, 'R2', this%memoryPath)
794 call mem_allocate(this%dh0, this%nlakes, 'DH0', this%memoryPath)
795 call mem_allocate(this%s0, this%nlakes, 'S0', this%memoryPath)
796 call mem_allocate(this%qgwf0, this%nlakes, 'QGWF0', this%memoryPath)
797 !
798 ! -- allocate character storage
799 allocate (this%lakename(this%nlakes))
800 allocate (this%status(this%nlakes))
801 !
802 ! -- initialize arrays
803 do n = 1, this%nlakes
804 this%ntabrow(n) = 0
805 this%status(n) = 'ACTIVE'
806 this%laketop(n) = -dep20
807 this%lakebot(n) = dep20
808 this%sareamax(n) = dzero
809 ! -- in the implicit formulation iboundpak/xnewpak are not yet associated
810 ! (they are aliased to the global arrays later in lak_set_pointers and
811 ! initialized in lak_read_initial_attr); only touch them here for the
812 ! legacy formulation
813 if (this%iimplicit == 0) then
814 this%iboundpak(n) = 1
815 this%xnewpak(n) = dep20
816 end if
817 this%xoldpak(n) = dep20
818 this%rainfall(n) = dzero
819 this%evaporation(n) = dzero
820 this%runoff(n) = dzero
821 this%inflow(n) = dzero
822 this%withdrawal(n) = dzero
823 this%ilegacy(n) = 0
824 this%nstuck(n) = 0
825 end do
826 !
827 ! -- get input context PACKAGEDATA column arrays
828 call mem_setptr(ifno, 'PACKAGEDATA_IFNO', this%input_mempath)
829 call mem_setptr(strt, 'STRT', this%input_mempath)
830 call mem_setptr(nlakeconn, 'NLAKECONN', this%input_mempath)
831 if (this%inamedbound /= 0) then
832 call mem_setptr(boundname_cst, 'BOUNDNAME', this%input_mempath)
833 end if
834 !
835 ! -- allocate check array
836 allocate (nboundchk(this%nlakes))
837 nboundchk = 0
838 ilak = 0
839 nconn = 0
840 !
841 do n = 1, this%nlakes
842 !
843 ! -- lake number from input
844 ilak = this%validate_ifno(ifno(n), this%nlakes, nboundchk, &
845 'lakeno', 'PACKAGEDATA')
846 if (ilak == 0) cycle
847 !
848 ! -- strt
849 this%strt(ilak) = strt(n)
850 !
851 ! -- nlakeconn
852 if (nlakeconn(n) < 1) then
853 write (errmsg, '(a,1x,i0,1x,a)') &
854 'NLAKECONN for lake', ilak, 'must be greater than zero.'
855 call store_error(errmsg)
856 end if
857 !
858 nconn = nconn + nlakeconn(n)
859 this%nlakeconn(ilak) = nlakeconn(n)
860 !
861 ! -- set default bndName
862 write (cno, '(i9.9)') ilak
863 bndname = 'Lake'//cno
864 !
865 ! -- lakename from boundname if provided
866 if (this%inamedbound /= 0) then
867 bndname = boundname_cst(n)
868 if (trim(bndname) == '') then
869 write (cno, '(i9.9)') ilak
870 bndname = 'Lake'//cno
871 end if
872 end if
873 this%lakename(ilak) = bndname
874 end do
875 !
876 ! -- check for duplicate or missing lakes
877 call this%report_ifno_coverage(nboundchk, this%nlakes, 'lake', &
878 'PACKAGEDATA')
879 !
880 write (this%iout, '(1x,a)') 'END OF '//trim(adjustl(this%text))// &
881 ' PACKAGEDATA'
882 !
883 ! -- terminate if any errors were detected
884 if (count_errors() > 0) then
885 call store_error_filename(this%input_fname)
886 end if
887 !
888 ! -- set MAXBOUND
889 this%MAXBOUND = nconn
890 write (this%iout, '(//4x,a,i7)') 'MAXBOUND = ', this%maxbound
891 !
892 ! -- set idxlakeconn
893 this%idxlakeconn(1) = 1
894 do n = 1, this%nlakes
895 this%idxlakeconn(n + 1) = this%idxlakeconn(n) + this%nlakeconn(n)
896 end do
897 !
898 ! -- deallocate check array
899 deallocate (nboundchk)
900 !
901 ! -- release input context packagedata memory; PACKAGEDATA_IFNO excluded
902 ! because allocate_featureauxvar retains a pointer to it
903 call memorystore_release('STRT', this%input_mempath)
904 call memorystore_release('NLAKECONN', this%input_mempath)
905 call memorystore_release('BOUNDNAME', this%input_mempath)
Here is the call graph for this function:

◆ lak_source_table()

subroutine lakmodule::lak_source_table ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
character(len=*), intent(in) mempath,
type(laktabtype), intent(inout) laketable )
private

Definition at line 1353 of file gwf-lak.f90.

1354 ! -- dummy
1355 class(LakType), intent(inout) :: this
1356 integer(I4B), intent(in) :: ilak
1357 character(len=*), intent(in) :: mempath
1358 type(LakTabType), intent(inout) :: laketable
1359 ! -- local
1360 integer(I4B), pointer :: nrow => null()
1361 integer(I4B), pointer :: ncol => null()
1362 real(DP), dimension(:), pointer, contiguous :: stage => null()
1363 real(DP), dimension(:), pointer, contiguous :: volume => null()
1364 real(DP), dimension(:), pointer, contiguous :: sarea => null()
1365 real(DP), dimension(:), pointer, contiguous :: barea => null()
1366 character(len=:), pointer :: tabfname => null()
1367 integer(I4B) :: jmin, iconn, n, nerr0
1368 real(DP) :: vol, sa, wa, v, v0
1369 ! -- formats
1370 character(len=*), parameter :: fmttaberr = &
1371 &'(a,1x,i0,1x,a,1x,g15.6,1x,a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.6,1x,a)'
1372 !
1373 ! -- this table's own input file, for error attribution below
1374 call mem_setptr(tabfname, 'INPUT_FNAME', mempath)
1375 call mem_setptr(nrow, 'NROW', mempath)
1376 call mem_setptr(ncol, 'NCOL', mempath)
1377 !
1378 ! -- errors added below this point belong to this lake's own table
1379 nerr0 = count_errors()
1380 !
1381 if (nrow < 1) then
1382 write (errmsg, '(a,1x,i0)') &
1383 'LAKE TABLE NROW MUST BE > 0 FOR LAKE', ilak
1384 call store_error(errmsg)
1385 end if
1386 !
1387 iconn = this%idxlakeconn(ilak)
1388 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
1389 jmin = 4
1390 else
1391 jmin = 3
1392 end if
1393 if (ncol < jmin) then
1394 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
1395 'LAKE TABLE NCOL MUST BE >=', jmin, 'FOR LAKE', ilak
1396 call store_error(errmsg)
1397 end if
1398 !
1399 if (count_errors() > nerr0) then
1400 call store_error_filename(tabfname, terminate=.false.)
1401 call memorystore_release('NROW', mempath)
1402 call memorystore_release('NCOL', mempath)
1403 call memorystore_release('INPUT_FNAME', mempath)
1404 return
1405 end if
1406 !
1407 this%ntabrow(ilak) = nrow
1408 allocate (laketable%tabstage(nrow))
1409 allocate (laketable%tabvolume(nrow))
1410 allocate (laketable%tabsarea(nrow))
1411 call mem_setptr(stage, 'STAGE', mempath)
1412 call mem_setptr(volume, 'VOLUME', mempath)
1413 call mem_setptr(sarea, 'SAREA', mempath)
1414 laketable%tabstage = stage
1415 laketable%tabvolume = volume
1416 laketable%tabsarea = sarea
1417 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
1418 allocate (laketable%tabwarea(nrow))
1419 call mem_setptr(barea, 'BAREA', mempath)
1420 laketable%tabwarea = barea
1421 end if
1422 !
1423 ! -- set lake bottom based on table if it is an embedded lake
1424 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
1425 do n = 1, this%ntabrow(ilak)
1426 vol = laketable%tabvolume(n)
1427 sa = laketable%tabsarea(n)
1428 wa = laketable%tabwarea(n)
1429 vol = vol * sa * wa
1430 ! -- check if all entries are zero
1431 if (vol > dzero) exit
1432 ! -- set lake bottom
1433 this%lakebot(ilak) = laketable%tabstage(n)
1434 this%belev(iconn) = laketable%tabstage(n)
1435 end do
1436 ! -- set maximum surface area for rainfall
1437 n = this%ntabrow(ilak)
1438 this%sareamax(ilak) = laketable%tabsarea(n)
1439 end if
1440 !
1441 ! -- verify the table data
1442 do n = 2, this%ntabrow(ilak)
1443 v = laketable%tabstage(n)
1444 v0 = laketable%tabstage(n - 1)
1445 if (v <= v0) then
1446 write (errmsg, fmttaberr) &
1447 'TABLE STAGE ENTRY', n, '(', laketable%tabstage(n), ') FOR LAKE ', &
1448 ilak, 'MUST BE GREATER THAN THE PREVIOUS STAGE ENTRY', &
1449 n - 1, '(', laketable%tabstage(n - 1), ')'
1450 call store_error(errmsg)
1451 end if
1452 v = laketable%tabvolume(n)
1453 v0 = laketable%tabvolume(n - 1)
1454 if (v <= v0) then
1455 write (errmsg, fmttaberr) &
1456 'TABLE VOLUME ENTRY', n, '(', laketable%tabvolume(n), &
1457 ') FOR LAKE ', &
1458 ilak, 'MUST BE GREATER THAN THE PREVIOUS VOLUME ENTRY', &
1459 n - 1, '(', laketable%tabvolume(n - 1), ')'
1460 call store_error(errmsg)
1461 end if
1462 v = laketable%tabsarea(n)
1463 v0 = laketable%tabsarea(n - 1)
1464 if (v < v0) then
1465 write (errmsg, fmttaberr) &
1466 'TABLE SURFACE AREA ENTRY', n, '(', &
1467 laketable%tabsarea(n), ') FOR LAKE ', ilak, &
1468 'MUST BE GREATER THAN OR EQUAL TO THE PREVIOUS SURFACE AREA ENTRY', &
1469 n - 1, '(', laketable%tabsarea(n - 1), ')'
1470 call store_error(errmsg)
1471 end if
1472 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
1473 v = laketable%tabwarea(n)
1474 v0 = laketable%tabwarea(n - 1)
1475 if (v < v0) then
1476 write (errmsg, fmttaberr) &
1477 'TABLE EXCHANGE AREA ENTRY', n, '(', &
1478 laketable%tabwarea(n), ') FOR LAKE ', ilak, &
1479 'MUST BE GREATER THAN OR EQUAL TO THE PREVIOUS EXCHANGE AREA '// &
1480 'ENTRY', n - 1, '(', laketable%tabwarea(n - 1), ')'
1481 call store_error(errmsg)
1482 end if
1483 end if
1484 end do
1485 !
1486 if (count_errors() > nerr0) then
1487 call store_error_filename(tabfname, terminate=.false.)
1488 end if
1489 !
1490 ! -- release this table's own input context memory
1491 call memorystore_release('NROW', mempath)
1492 call memorystore_release('NCOL', mempath)
1493 call memorystore_release('STAGE', mempath)
1494 call memorystore_release('VOLUME', mempath)
1495 call memorystore_release('SAREA', mempath)
1496 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
1497 call memorystore_release('BAREA', mempath)
1498 end if
1499 call memorystore_release('INPUT_FNAME', mempath)
Here is the call graph for this function:

◆ lak_source_tables()

subroutine lakmodule::lak_source_tables ( class(laktype), intent(inout) this)
private

Definition at line 1213 of file gwf-lak.f90.

1214 ! -- dummy
1215 class(LakType), intent(inout) :: this
1216 ! -- local
1217 integer(I4B) :: n, ntabs
1218 integer(I4B) :: ilak, iconn
1219 character(len=LENMEMPATH) :: mempath
1220 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
1221 type(CharacterStringType), dimension(:), pointer, contiguous :: &
1222 laktab6_mempaths => null()
1223 type(LakTabType), dimension(:), allocatable :: laketables
1224 integer(I4B), allocatable :: nboundchk(:)
1225 !
1226 ! -- skip if no tables
1227 if (this%ntables < 1) return
1228 !
1229 ! -- guard: TABLES block required when ntables > 0
1230 call get_isize('TABLES_IFNO', this%input_mempath, ntabs)
1231 if (ntabs < 1) then
1232 write (errmsg, '(a)') &
1233 'NTABLES > 0 BUT A TABLES BLOCK WAS NOT FOUND IN THE LAK INPUT.'
1234 call store_error(errmsg, .true.)
1235 end if
1236 !
1237 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text))// &
1238 ' TABLES'
1239 !
1240 ! -- set input context pointers
1241 call mem_setptr(ifno, 'TABLES_IFNO', this%input_mempath)
1242 call mem_setptr(laktab6_mempaths, 'LAKTAB6_MEMPATH', this%input_mempath)
1243 !
1244 ntabs = size(ifno)
1245 !
1246 ! -- allocate
1247 allocate (laketables(this%nlakes))
1248 allocate (nboundchk(this%nlakes))
1249 nboundchk = 0
1250 !
1251 do n = 1, ntabs
1252 ilak = this%validate_ifno(ifno(n), this%nlakes, nboundchk, &
1253 'lakeno', 'TABLES')
1254 if (ilak == 0) cycle
1255 mempath = laktab6_mempaths(n)
1256 call this%lak_source_table(ilak, mempath, laketables(ilak))
1257 end do
1258 !
1259 write (this%iout, '(1x,a)') 'END OF '//trim(adjustl(this%text))//' TABLES'
1260 !
1261 ! -- check for missing or duplicate table data
1262 if (ntabs < this%ntables) then
1263 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
1264 'TABLE DATA ARE SPECIFIED', ntabs, &
1265 'TIMES BUT NTABLES IS SET TO', this%ntables
1266 call store_error(errmsg)
1267 end if
1268 ! -- a table that never loaded any rows is not reported as a duplicate
1269 do n = 1, this%nlakes
1270 if (this%ntabrow(n) == 0) nboundchk(n) = 0
1271 end do
1272 call this%report_ifno_coverage(nboundchk, this%nlakes, 'lakeno', &
1273 'TABLES', check_missing=.false.)
1274 !
1275 deallocate (nboundchk)
1276 !
1277 if (count_errors() > 0) then
1278 call store_error_filename(this%input_fname)
1279 end if
1280 !
1281 ! -- release input context tables memory
1282 call memorystore_release('TABLES_IFNO', this%input_mempath)
1283 !
1284 ! -- convert laketables to vectors
1285 call this%laktables_to_vectors(laketables)
1286 !
1287 ! -- destroy laketables
1288 do n = 1, this%nlakes
1289 if (this%ntabrow(n) > 0) then
1290 deallocate (laketables(n)%tabstage)
1291 deallocate (laketables(n)%tabvolume)
1292 deallocate (laketables(n)%tabsarea)
1293 iconn = this%idxlakeconn(n)
1294 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
1295 deallocate (laketables(n)%tabwarea)
1296 end if
1297 end if
1298 end do
1299 deallocate (laketables)
Here is the call graph for this function:

◆ lak_vol2stage()

subroutine lakmodule::lak_vol2stage ( class(laktype), intent(inout) this,
integer(i4b), intent(in) ilak,
real(dp), intent(in) vol,
real(dp), intent(inout) stage )
private

Definition at line 2877 of file gwf-lak.f90.

2878 ! -- dummy
2879 class(LakType), intent(inout) :: this
2880 integer(I4B), intent(in) :: ilak
2881 real(DP), intent(in) :: vol
2882 real(DP), intent(inout) :: stage
2883 ! -- local
2884 integer(I4B) :: i
2885 integer(I4B) :: ibs
2886 real(DP) :: s0, s1, sm
2887 real(DP) :: v0, v1, vm
2888 real(DP) :: f0, f1, fm
2889 real(DP) :: sa
2890 real(DP) :: en0, en1
2891 real(DP) :: ds, ds0
2892 real(DP) :: denom
2893 !
2894 s0 = this%lakebot(ilak)
2895 call this%lak_calculate_vol(ilak, s0, v0)
2896 s1 = this%laketop(ilak)
2897 call this%lak_calculate_vol(ilak, s1, v1)
2898 ! -- zero volume
2899 if (vol <= v0) then
2900 stage = s0
2901 ! -- linear relation between stage and volume above top of lake
2902 else if (vol >= v1) then
2903 call this%lak_calculate_sarea(ilak, s1, sa)
2904 stage = s1 + (vol - v1) / sa
2905 ! -- use combination of secant and bisection
2906 else
2907 en0 = s0
2908 en1 = s1
2909 ! sm = s1 ! causes divide by zero in 1st line in secantbisection loop
2910 ! sm = s0 ! causes divide by zero in 1st line in secantbisection loop
2911 sm = dzero
2912 f0 = vol - v0
2913 f1 = vol - v1
2914 ibs = 0
2915 secantbisection: do i = 1, 150
2916 denom = f1 - f0
2917 if (denom /= dzero) then
2918 ds = f1 * (s1 - s0) / denom
2919 else
2920 ibs = 13
2921 end if
2922 if (i == 1) then
2923 ds0 = ds
2924 end if
2925 ! -- use bisection if end points are exceeded
2926 if (sm < en0 .or. sm > en1) ibs = 13
2927 ! -- use bisection if secant method stagnates or if
2928 ! ds exceeds previous ds - bisection would occur
2929 ! after conditions exceeded in 13 iterations
2930 if (ds * ds0 < dprec .or. abs(ds) > abs(ds0)) ibs = ibs + 1
2931 if (ibs > 12) then
2932 ds = dhalf * (s1 - s0)
2933 ibs = 0
2934 end if
2935 sm = s1 - ds
2936 if (abs(ds) < dem6) then
2937 exit secantbisection
2938 end if
2939 call this%lak_calculate_vol(ilak, sm, vm)
2940 fm = vol - vm
2941 s0 = s1
2942 f0 = f1
2943 s1 = sm
2944 f1 = fm
2945 ds0 = ds
2946 end do secantbisection
2947 stage = sm
2948 if (abs(ds) >= dem6) then
2949 write (this%iout, '(1x,a,1x,i0,4(1x,a,1x,g15.6))') &
2950 & 'LAK_VOL2STAGE failed for lake', ilak, 'volume error =', fm, &
2951 & 'finding stage (', stage, ') for volume =', vol, &
2952 & 'final change in stage =', ds
2953 end if
2954 end if

◆ laktables_to_vectors()

subroutine lakmodule::laktables_to_vectors ( class(laktype), intent(inout) this,
type(laktabtype), dimension(:), intent(in), contiguous laketables )
private

Definition at line 1305 of file gwf-lak.f90.

1306 class(LakType), intent(inout) :: this
1307 type(LakTabType), intent(in), dimension(:), contiguous :: laketables
1308 integer(I4B) :: n
1309 integer(I4B) :: ntabrows
1310 integer(I4B) :: j
1311 integer(I4B) :: ipos
1312 integer(I4B) :: iconn
1313 !
1314 ! -- allocate index array for lak tables
1315 call mem_allocate(this%ialaktab, this%nlakes + 1, 'IALAKTAB', this%memoryPath)
1316 !
1317 ! -- Move the laktables structure information into flattened arrays
1318 this%ialaktab(1) = 1
1319 do n = 1, this%nlakes
1320 ! -- ialaktab contains a pointer into the flattened lak table data
1321 this%ialaktab(n + 1) = this%ialaktab(n) + this%ntabrow(n)
1322 end do
1323 !
1324 ! -- Allocate vectors for storing all lake table data
1325 ntabrows = this%ialaktab(this%nlakes + 1) - 1
1326 call mem_allocate(this%tabstage, ntabrows, 'TABSTAGE', this%memoryPath)
1327 call mem_allocate(this%tabvolume, ntabrows, 'TABVOLUME', this%memoryPath)
1328 call mem_allocate(this%tabsarea, ntabrows, 'TABSAREA', this%memoryPath)
1329 call mem_allocate(this%tabwarea, ntabrows, 'TABWAREA', this%memoryPath)
1330 !
1331 ! -- Copy data from laketables into vectors
1332 do n = 1, this%nlakes
1333 j = 1
1334 do ipos = this%ialaktab(n), this%ialaktab(n + 1) - 1
1335 this%tabstage(ipos) = laketables(n)%tabstage(j)
1336 this%tabvolume(ipos) = laketables(n)%tabvolume(j)
1337 this%tabsarea(ipos) = laketables(n)%tabsarea(j)
1338 iconn = this%idxlakeconn(n)
1339 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3) then
1340 !
1341 ! -- tabwarea only filled for ictype 2 and 3
1342 this%tabwarea(ipos) = laketables(n)%tabwarea(j)
1343 else
1344 this%tabwarea(ipos) = dzero
1345 end if
1346 j = j + 1
1347 end do
1348 end do

Variable Documentation

◆ ftype

character(len=lenftype) lakmodule::ftype = 'LAK'
private

Definition at line 46 of file gwf-lak.f90.

◆ text

character(len=lenpackagename) lakmodule::text = ' LAK'
private

Definition at line 47 of file gwf-lak.f90.