39 character(len=LINELENGTH),
pointer :: filename => null()
40 integer(I4B),
pointer :: ipr_input => null()
41 integer(I4B),
pointer :: ipr_flow => null()
43 integer(I4B),
pointer :: nexg => null()
44 integer(I4B),
dimension(:),
pointer,
contiguous :: nodem1 => null()
45 integer(I4B),
dimension(:),
pointer,
contiguous :: nodem2 => null()
46 real(dp),
dimension(:),
pointer,
contiguous :: cond => null()
47 integer(I4B),
dimension(:),
pointer,
contiguous :: idxglo => null()
48 integer(I4B),
dimension(:),
pointer,
contiguous :: idxsymglo => null()
49 real(dp),
dimension(:),
pointer,
contiguous :: simvals => null()
53 integer(I4B),
pointer :: inobs => null()
96 subroutine swfgwf_cr(filename, name, id, m1_id, m2_id, input_mempath)
99 character(len=*),
intent(in) :: filename
100 character(len=*) :: name
101 integer(I4B),
intent(in) :: id
102 integer(I4B),
intent(in) :: m1_id
103 integer(I4B),
intent(in) :: m2_id
104 character(len=*),
intent(in) :: input_mempath
109 integer(I4B) :: m1_index, m2_index
113 baseexchange => exchange
120 exchange%input_mempath = input_mempath
123 call exchange%allocate_scalars()
124 exchange%filename = filename
125 exchange%typename =
'SWF-GWF'
129 if (m1_index > 0)
then
133 exchange%model1 => mb
134 exchange%swfmodel1 => mb
142 if (m2_index > 0)
then
146 exchange%model2 => mb
147 exchange%gwfmodel2 => mb
153 if (.not.
associated(exchange%swfmodel1) .and. m1_index > 0)
then
154 write (
errmsg,
'(3a)')
'Problem with SWF-GWF exchange ', &
155 trim(exchange%name), &
156 '. Specified SWF Model does not appear to be of the correct type.'
161 if (.not.
associated(exchange%gwfmodel2) .and. m2_index > 0)
then
162 write (
errmsg,
'(3a)')
'Problem with SWF-GWF exchange ', &
163 trim(exchange%name), &
164 '. Specified GWF Model does not appear to be of the correct type.'
169 call obs_cr(exchange%obs, exchange%inobs)
186 write (
iout,
'(/a,a)')
' Creating exchange: ', this%name
189 if (
associated(this%swfmodel1) .and.
associated(this%gwfmodel2))
then
190 if (this%swfmodel1%idsoln /= this%gwfmodel2%idsoln)
then
191 call store_error(
'Two models are connected in a SWF-GWF '// &
192 'exchange but they are in different solutions. '// &
193 'Models must be in same solution: '// &
194 trim(this%swfmodel1%name)//
' '// &
195 trim(this%gwfmodel2%name))
196 call this%parser%StoreErrorUnit()
201 call this%source_options(
iout)
204 call this%source_dimensions(
iout)
207 call this%allocate_arrays()
210 call this%source_data(
iout)
236 integer(I4B) :: n, iglo, jglo
240 iglo = this%nodem1(n) + this%swfmodel1%moffset
241 jglo = this%nodem2(n) + this%gwfmodel2%moffset
242 call sparse%addconnection(iglo, jglo, 1)
243 call sparse%addconnection(jglo, iglo, 1)
261 integer(I4B) :: n, iglo, jglo
265 iglo = this%nodem1(n) + this%swfmodel1%moffset
266 jglo = this%nodem2(n) + this%gwfmodel2%moffset
267 this%idxglo(n) = matrix_sln%get_position(iglo, jglo)
268 this%idxsymglo(n) = matrix_sln%get_position(jglo, iglo)
281 subroutine swf_gwf_fc(this, kiter, matrix_sln, rhs_sln, inwtflag)
285 integer(I4B),
intent(in) :: kiter
287 real(DP),
dimension(:),
intent(inout) :: rhs_sln
288 integer(I4B),
optional,
intent(in) :: inwtflag
290 integer(I4B) :: i, nodem1sln, nodem2sln
294 call matrix_sln%set_value_pos(this%idxglo(i), this%cond(i))
295 call matrix_sln%set_value_pos(this%idxsymglo(i), this%cond(i))
297 nodem1sln = this%nodem1(i) + this%swfmodel1%moffset
298 nodem2sln = this%nodem2(i) + this%gwfmodel2%moffset
299 call matrix_sln%add_diag_value(nodem1sln, -this%cond(i))
300 call matrix_sln%add_diag_value(nodem2sln, -this%cond(i))
312 subroutine swf_gwf_cq(this, icnvg, isuppress_output, isolnid)
315 integer(I4B),
intent(inout) :: icnvg
316 integer(I4B),
intent(in) :: isuppress_output
317 integer(I4B),
intent(in) :: isolnid
320 call this%swf_gwf_calc_simvals()
327 call this%swf_gwf_add_to_flowja()
344 call this%obs%obs_da()
345 deallocate (this%obs)
356 deallocate (this%filename)
375 allocate (this%filename)
378 call mem_allocate(this%ipr_input,
'IPR_INPUT', this%memoryPath)
379 call mem_allocate(this%ipr_flow,
'IPR_FLOW', this%memoryPath)
399 call mem_allocate(this%nodem1, this%nexg,
'NODEM1', this%memoryPath)
400 call mem_allocate(this%nodem2, this%nexg,
'NODEM2', this%memoryPath)
401 call mem_allocate(this%cond, this%nexg,
'COND', this%memoryPath)
402 call mem_allocate(this%idxglo, this%nexg,
'IDXGLO', this%memoryPath)
403 call mem_allocate(this%idxsymglo, this%nexg,
'IDXSYMGLO', this%memoryPath)
404 call mem_allocate(this%simvals, this%nexg,
'SIMVALS', this%memoryPath)
424 integer(I4B),
intent(in) :: iout
430 this%input_mempath, found%ipr_input)
432 this%input_mempath, found%ipr_flow)
434 write (iout,
'(1x,a)')
'PROCESSING SWF-GWF EXCHANGE OPTIONS'
436 if (found%ipr_input)
then
437 write (iout,
'(4x,a)') &
438 'THE LIST OF EXCHANGES WILL BE PRINTED.'
441 if (found%ipr_flow)
then
442 write (iout,
'(4x,a)') &
443 'EXCHANGE FLOWS WILL BE PRINTED TO LIST FILES.'
456 write (iout,
'(1x,a)')
'END OF SWF-GWF EXCHANGE OPTIONS'
470 integer(I4B),
intent(in) :: iout
475 call mem_set_value(this%nexg,
'NEXG', this%input_mempath, found%nexg)
477 write (iout,
'(1x,a)')
'PROCESSING EXCHANGE DIMENSIONS'
480 write (iout,
'(4x,a,i0)')
'NEXG = ', this%nexg
483 write (iout,
'(1x,a)')
'END OF EXCHANGE DIMENSIONS'
491 function noder(this, model, cellid, iout)
497 integer(I4B),
dimension(:),
pointer,
intent(in) :: cellid
498 integer(I4B),
intent(in) ::
iout
499 integer(I4B) ::
noder, node
501 if (model%dis%ndim == 1)
then
503 elseif (model%dis%ndim == 2)
then
504 node =
get_node(cellid(1), 1, cellid(2), &
505 model%dis%mshape(1), 1, &
508 node =
get_node(cellid(1), cellid(2), cellid(3), &
509 model%dis%mshape(1), &
510 model%dis%mshape(2), &
513 noder = model%dis%get_nodenumber(node, 0)
526 integer(I4B),
dimension(:),
pointer,
intent(in) :: cellid
527 integer(I4B),
intent(in) ::
iout
529 character(len=*),
parameter :: fmtndim1 = &
531 character(len=*),
parameter :: fmtndim2 = &
532 "('(',i0,',',i0,')')"
533 character(len=*),
parameter :: fmtndim3 = &
534 "('(',i0,',',i0,',',i0,')')"
538 select case (model%dis%ndim)
540 write (
cellstr, fmtndim1) cellid(1)
542 write (
cellstr, fmtndim2) cellid(1), cellid(2)
544 write (
cellstr, fmtndim3) cellid(1), cellid(2), cellid(3)
559 integer(I4B),
intent(in) :: iout
561 integer(I4B),
dimension(:, :),
contiguous,
pointer :: cellidm1
562 integer(I4B),
dimension(:, :),
contiguous,
pointer :: cellidm2
563 real(DP),
dimension(:),
contiguous,
pointer :: cond
564 character(len=20) :: cellstr1, cellstr2
566 integer(I4B) :: iexg, nodem1, nodem2
568 character(len=*),
parameter :: fmtexglabel =
"(1x, 3a10, 50(a16))"
569 character(len=*),
parameter :: fmtexgdata = &
570 "(5x, a, 1x, a ,50(1pg16.6))"
572 call mem_setptr(cellidm1,
'CELLIDM1', this%input_mempath)
573 call mem_setptr(cellidm2,
'CELLIDM2', this%input_mempath)
574 call mem_setptr(cond,
'COND', this%input_mempath)
576 write (iout,
'(1x,a)')
'PROCESSING EXCHANGEDATA'
578 if (this%ipr_input /= 0)
then
579 write (iout, fmtexglabel)
'NODEM1',
'NODEM2',
'COND'
582 do iexg = 1, this%nexg
584 if (
associated(this%model1))
then
587 nodem1 = this%noder(this%model1, cellidm1(:, iexg), iout)
588 this%nodem1(iexg) = nodem1
591 this%nodem1(iexg) = -1
594 if (
associated(this%model2))
then
597 nodem2 = this%noder(this%model2, cellidm2(:, iexg), iout)
598 this%nodem2(iexg) = nodem2
601 this%nodem2(iexg) = -1
605 this%cond(iexg) = cond(iexg)
608 if (this%ipr_input /= 0)
then
609 cellstr1 = this%cellstr(this%model1, cellidm1(:, iexg), iout)
610 cellstr2 = this%cellstr(this%model2, cellidm2(:, iexg), iout)
611 write (iout, fmtexgdata) trim(cellstr1), trim(cellstr2), &
616 if (
associated(this%model1))
then
617 if (nodem1 <= 0)
then
618 cellstr1 = this%cellstr(this%model1, cellidm1(:, iexg), iout)
620 trim(adjustl(this%model1%name))// &
621 ' Cell is outside active grid domain ('// &
622 trim(adjustl(cellstr1))//
').'
628 if (
associated(this%model2))
then
629 if (nodem2 <= 0)
then
630 cellstr2 = this%cellstr(this%model2, cellidm2(:, iexg), iout)
632 trim(adjustl(this%model2%name))// &
633 ' Cell is outside active grid domain ('// &
634 trim(adjustl(cellstr2))//
').'
640 write (iout,
'(1x,a)')
'END OF EXCHANGEDATA'
645 call store_error(
'Errors encountered in exchange input file.')
663 integer(I4B) :: n1, n2
664 integer(I4B) :: ibdn1, ibdn2
671 ibdn1 = this%swfmodel1%ibound(n1)
672 ibdn2 = this%gwfmodel2%ibound(n2)
673 if (ibdn1 /= 0 .and. ibdn2 /= 0)
then
674 rrate = this%qcalc(i, n1, n2)
676 this%simvals(i) = rrate
692 integer(I4B),
intent(in) :: iexg
693 integer(I4B),
intent(in) :: n1
694 integer(I4B),
intent(in) :: n2
698 qcalc = this%cond(iexg) * (this%gwfmodel2%x(n2) - this%swfmodel1%x(n1))
713 integer(I4B) :: idiag
718 if (
associated(this%swfmodel1))
then
720 if (this%swfmodel1%ibound(n) > 0)
then
721 flow = this%simvals(i)
722 idiag = this%swfmodel1%ia(n)
723 this%swfmodel1%flowja(idiag) = this%swfmodel1%flowja(idiag) + flow
727 if (
associated(this%gwfmodel2))
then
729 if (this%gwfmodel2%ibound(n) > 0)
then
730 flow = -this%simvals(i)
731 idiag = this%gwfmodel2%ia(n)
732 this%gwfmodel2%flowja(idiag) = this%gwfmodel2%flowja(idiag) + flow
746 subroutine swf_gwf_bd(this, icnvg, isuppress_output, isolnid)
752 integer(I4B),
intent(inout) :: icnvg
753 integer(I4B),
intent(in) :: isuppress_output
754 integer(I4B),
intent(in) :: isolnid
756 character(len=LENBUDTXT),
dimension(1) :: budtxt
757 real(DP),
dimension(2, 1) :: budterm
758 real(DP) :: ratin, ratout
761 budtxt(1) =
' FLOW-JA-FACE'
767 if (
associated(this%swfmodel1))
then
768 budterm(1, 1) = ratin
769 budterm(2, 1) = ratout
770 call this%swfmodel1%model_bdentry(budterm, budtxt, this%name)
774 if (
associated(this%gwfmodel2))
then
775 budterm(1, 1) = ratout
776 budterm(2, 1) = ratin
777 call this%gwfmodel2%model_bdentry(budterm, budtxt, this%name)
782 call this%swf_gwf_chd_bd()
798 character(len=LENBUDTXT),
dimension(1) :: budtxt
801 real(DP),
dimension(2, 1) :: budterm
802 real(DP) :: ratin, ratout
806 budtxt(1) =
'FLOW-JA-FACE-CHD'
809 if (
associated(this%swfmodel1))
then
814 if (this%swfmodel1%ibound(n) < 0)
then
823 budterm(1, 1) = ratin
824 budterm(2, 1) = ratout
825 call this%swfmodel1%model_bdentry(budterm, budtxt, this%name)
829 if (
associated(this%gwfmodel2))
then
834 if (this%gwfmodel2%ibound(n) < 0)
then
844 budterm(1, 1) = ratin
845 budterm(2, 1) = ratout
846 call this%gwfmodel2%model_bdentry(budterm, budtxt, this%name)
861 integer(I4B) :: icbcfl, ibudfl
879 if (this%inobs /= 0)
then
880 call this%swf_gwf_save_simvals()
1053 integer(I4B) :: iexg, n1, n2
1055 character(len=LINELENGTH) :: node1str, node2str
1057 character(len=*),
parameter :: fmtheader2 = &
1058 "(/1x, 'SUMMARY OF EXCHANGE RATES FOR EXCHANGE ', a, ' WITH ID ', i0, /, &
1059 &2a16, 4a16, /, 96('-'))"
1060 character(len=*),
parameter :: fmtdata = &
1061 "(2a16, 5(1pg16.6))"
1064 call this%swf_gwf_bdsav()
1067 if (this%ipr_flow /= 0)
then
1068 write (
iout, fmtheader2) trim(adjustl(this%name)), this%id,
'NODEM1', &
1069 'NODEM2',
'COND',
'X_M1',
'X_M2',
'FLOW'
1070 do iexg = 1, this%nexg
1071 n1 = this%nodem1(iexg)
1072 n2 = this%nodem2(iexg)
1073 flow = this%simvals(iexg)
1074 call this%swfmodel1%dis%noder_to_string(n1, node1str)
1075 call this%gwfmodel2%dis%noder_to_string(n2, node2str)
1076 write (
iout, fmtdata) trim(adjustl(node1str)), &
1077 trim(adjustl(node2str)), &
1078 this%cond(iexg), this%swfmodel1%x(n1), &
1079 this%gwfmodel2%x(n2), flow
1084 call this%obs%obs_ot()
1107 integer(I4B) :: iexg
1112 if (this%obs%npakobs > 0)
then
1113 call this%obs%obs_bd_clear()
1114 do i = 1, this%obs%npakobs
1115 obsrv => this%obs%pakobs(i)%obsrv
1116 do j = 1, obsrv%indxbnds_count
1117 iexg = obsrv%indxbnds(j)
1119 select case (obsrv%ObsTypeId)
1120 case (
'FLOW-JA-FACE')
1121 n1 = this%nodem1(iexg)
1122 n2 = this%nodem2(iexg)
1123 v = this%simvals(iexg)
1125 errmsg =
'Unrecognized observation type: '// &
1126 trim(obsrv%ObsTypeId)
1130 call this%obs%SaveOneSimval(obsrv, v)
1147 logical(LGP) :: is_connected
1149 is_connected = .false.
1152 if (
associated(this%gwfmodel2, model))
then
1153 is_connected = .true.
1156 if (
associated(this%swfmodel1, model))
then
1157 is_connected = .true.
subroutine, public addbaseexchangetolist(list, exchange)
Add the exchange object (BaseExchangeType) to a list.
class(basemodeltype) function, pointer, public getbasemodelfromlist(list, idx)
This module contains block parser methods.
This module contains the BudgetModule.
subroutine, public rate_accumulator(flow, rin, rout)
@ brief Rate accumulator subroutine
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenpackagename
maximum length of the package name
integer(i4b), parameter lenvarname
maximum length of a variable name
real(dp), parameter dem6
real constant 1e-6
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
This module defines variable data types.
type(listtype), public basemodellist
type(listtype), public baseexchangelist
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains the derived types ObserveType and ObsDataType.
This module contains the derived type ObsType.
subroutine, public obs_cr(obs, inobs)
@ brief Create a new ObsType object
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
integer(i4b), dimension(:), allocatable model_loc_idx
equals the local index into the basemodel list (-1 when not available)
integer(i4b) iout
file unit number for simulation output
This module contains the SourceCommonModule.
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
This module contains the SwfGwfExchangeModule Module.
integer(i4b) function noder(this, model, cellid, iout)
subroutine swf_gwf_df(this)
@ brief Define SWF GWF exchange
character(len=20) function cellstr(this, model, cellid, iout)
subroutine swf_gwf_mc(this, matrix_sln)
@ brief Map connections
real(dp) function qcalc(this, iexg, n1, n2)
@ brief Calculate flow
subroutine swf_gwf_fc(this, kiter, matrix_sln, rhs_sln, inwtflag)
@ brief Fill coefficients
subroutine swf_gwf_ac(this, sparse)
@ brief Add connections
subroutine swf_gwf_cq(this, icnvg, isuppress_output, isolnid)
@ brief Calculate flow
subroutine source_options(this, iout)
@ brief Source options
subroutine swf_gwf_save_simvals(this)
@ brief Save simulated flow observations
subroutine swf_gwf_add_to_flowja(this)
Add exchange flow to each model flowja diagonal position so that residual is calculated correctly.
subroutine swf_gwf_ot(this)
@ brief Output
subroutine allocate_scalars(this)
@ brief Allocate scalars
subroutine swf_gwf_da(this)
@ brief Deallocate
subroutine swf_gwf_bd(this, icnvg, isuppress_output, isolnid)
@ brief Budget
logical(lgp) function swf_gwf_connects_model(this, model)
Should return true when the exchange should be added to the solution where the model resides.
subroutine swf_gwf_bdsav(this)
@ brief Budget save
subroutine swf_gwf_calc_simvals(this)
Calculate flow rates for the exchanges and store them in a member array.
subroutine, public swfgwf_cr(filename, name, id, m1_id, m2_id, input_mempath)
@ brief Create SWF GWF exchange
subroutine allocate_arrays(this)
Allocate array data, using the number of connected nodes.
subroutine source_dimensions(this, iout)
Source dimension from input context.
subroutine swf_gwf_chd_bd(this)
@ brief swf-gwf-chd-bd
subroutine source_data(this, iout)
Source exchange data from input context.
Stream Network Flow (SWF) Module.
subroutine, public table_cr(this, name, title)
Highest level model type. All models extend this parent type.
This class is used to store a single deferred-length character string. It was designed to work in an ...