52 character(len=*),
parameter ::
ftype =
'SFT'
53 character(len=*),
parameter ::
flowtype =
'SFR'
54 character(len=16) ::
text =
' SFT'
58 integer(I4B),
pointer :: idxbudrain => null()
59 integer(I4B),
pointer :: idxbudevap => null()
60 integer(I4B),
pointer :: idxbudroff => null()
61 integer(I4B),
pointer :: idxbudiflw => null()
62 integer(I4B),
pointer :: idxbudoutf => null()
64 real(dp),
dimension(:),
pointer,
contiguous :: concrain => null()
65 real(dp),
dimension(:),
pointer,
contiguous :: concevap => null()
66 real(dp),
dimension(:),
pointer,
contiguous :: concroff => null()
67 real(dp),
dimension(:),
pointer,
contiguous :: conciflw => null()
69 real(dp),
dimension(:),
pointer,
contiguous :: vnew => null()
70 real(dp),
dimension(:),
pointer,
contiguous :: vold => null()
101 subroutine sft_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, &
102 mempath, fmi, eqnsclfac, dvt, dvu, dvua)
104 class(
bndtype),
pointer :: packobj
105 integer(I4B),
intent(in) :: id
106 integer(I4B),
intent(in) :: ibcnum
107 integer(I4B),
intent(in) :: inunit
108 integer(I4B),
intent(in) :: iout
109 character(len=*),
intent(in) :: namemodel
110 character(len=*),
intent(in) :: pakname
111 character(len=*),
intent(in) :: mempath
113 real(dp),
intent(in),
pointer :: eqnsclfac
114 character(len=*),
intent(in) :: dvt
115 character(len=*),
intent(in) :: dvu
116 character(len=*),
intent(in) :: dvua
125 call packobj%set_names(ibcnum, namemodel, pakname,
ftype, mempath)
129 call sftobj%allocate_scalars()
132 call packobj%pack_initialize()
134 packobj%inunit = inunit
137 packobj%ibcnum = ibcnum
148 sftobj%eqnsclfac => eqnsclfac
151 sftobj%depvartype = dvt
152 sftobj%depvarunit = dvu
153 sftobj%depvarunitabbrev = dvua
164 character(len=LINELENGTH) :: errmsg
165 class(
bndtype),
pointer :: packobj
166 integer(I4B) :: ip, icount
167 integer(I4B) :: nbudterm
177 if (this%fmi%flows_from_file)
then
178 call this%fmi%set_aptbudobj_pointer(this%flowpackagename, this%flowbudptr)
179 if (
associated(this%flowbudptr)) found = .true.
182 if (
associated(this%fmi%gwfbndlist))
then
185 do ip = 1, this%fmi%gwfbndlist%Count()
187 if (packobj%packName == this%flowpackagename)
then
192 this%flowpackagebnd => packobj
193 select type (packobj)
195 this%flowbudptr => packobj%budobj
204 if (.not. found)
then
205 write (errmsg,
'(a)')
'Could not find flow package with name '&
206 &//trim(adjustl(this%flowpackagename))//
'.'
213 nbudterm = this%flowbudptr%nbudterm
214 call mem_allocate(this%idxbudssm, nbudterm,
'IDXBUDSSM', this%memoryPath)
217 write (this%iout,
'(/, a, a)') &
218 'PROCESSING '//
ftype//
' INFORMATION FOR ', this%packName
219 write (this%iout,
'(a)')
' IDENTIFYING FLOW TERMS IN '//
flowtype//
' PACKAGE'
220 write (this%iout,
'(a, i0)') &
221 ' NUMBER OF '//
flowtype//
' = ', this%flowbudptr%ncv
223 do ip = 1, this%flowbudptr%nbudterm
224 select case (trim(adjustl(this%flowbudptr%budterm(ip)%flowtype)))
225 case (
'FLOW-JA-FACE')
227 this%idxbudssm(ip) = 0
230 this%idxbudssm(ip) = 0
233 this%idxbudssm(ip) = 0
236 this%idxbudssm(ip) = 0
239 this%idxbudssm(ip) = 0
242 this%idxbudssm(ip) = 0
245 this%idxbudssm(ip) = 0
248 this%idxbudssm(ip) = 0
251 this%idxbudssm(ip) = 0
254 this%idxbudssm(ip) = 0
257 this%idxbudssm(ip) = 0
262 this%idxbudssm(ip) = icount
265 write (this%iout,
'(a, i0, " = ", a,/, a, i0)') &
266 ' TERM ', ip, trim(adjustl(this%flowbudptr%budterm(ip)%flowtype)), &
267 ' MAX NO. OF ENTRIES = ', this%flowbudptr%budterm(ip)%maxlist
269 write (this%iout,
'(a, //)')
'DONE PROCESSING '//
ftype//
' INFORMATION'
280 integer(I4B),
intent(in) :: itemno
281 character(len=*),
intent(in) :: key
285 select case (trim(key))
287 val = this%concrain(itemno)
289 val = this%concevap(itemno)
291 val = this%concroff(itemno)
293 val = this%conciflw(itemno)
306 real(DP),
dimension(:),
intent(inout) :: rhs
307 integer(I4B),
dimension(:),
intent(in) :: ia
308 integer(I4B),
dimension(:),
intent(in) :: idxglo
311 integer(I4B) :: j, n1, n2
313 integer(I4B) :: iposd
319 if (this%idxbudrain /= 0)
then
320 do j = 1, this%flowbudptr%budterm(this%idxbudrain)%nlist
321 call this%sft_rain_term(j, n1, n2, rrate, rhsval, hcofval)
322 iloc = this%idxlocnode(n1)
323 iposd = this%idxpakdiag(n1)
324 call matrix_sln%add_value_pos(iposd, hcofval)
325 rhs(iloc) = rhs(iloc) + rhsval
330 if (this%idxbudevap /= 0)
then
331 do j = 1, this%flowbudptr%budterm(this%idxbudevap)%nlist
332 call this%sft_evap_term(j, n1, n2, rrate, rhsval, hcofval)
333 iloc = this%idxlocnode(n1)
334 iposd = this%idxpakdiag(n1)
335 call matrix_sln%add_value_pos(iposd, hcofval)
336 rhs(iloc) = rhs(iloc) + rhsval
341 if (this%idxbudroff /= 0)
then
342 do j = 1, this%flowbudptr%budterm(this%idxbudroff)%nlist
343 call this%sft_roff_term(j, n1, n2, rrate, rhsval, hcofval)
344 iloc = this%idxlocnode(n1)
345 iposd = this%idxpakdiag(n1)
346 call matrix_sln%add_value_pos(iposd, hcofval)
347 rhs(iloc) = rhs(iloc) + rhsval
352 if (this%idxbudiflw /= 0)
then
353 do j = 1, this%flowbudptr%budterm(this%idxbudiflw)%nlist
354 call this%sft_iflw_term(j, n1, n2, rrate, rhsval, hcofval)
355 iloc = this%idxlocnode(n1)
356 iposd = this%idxpakdiag(n1)
357 call matrix_sln%add_value_pos(iposd, hcofval)
358 rhs(iloc) = rhs(iloc) + rhsval
363 if (this%idxbudoutf /= 0)
then
364 do j = 1, this%flowbudptr%budterm(this%idxbudoutf)%nlist
365 call this%sft_outf_term(j, n1, n2, rrate, rhsval, hcofval)
366 iloc = this%idxlocnode(n1)
367 iposd = this%idxpakdiag(n1)
368 call matrix_sln%add_value_pos(iposd, hcofval)
369 rhs(iloc) = rhs(iloc) + rhsval
381 integer(I4B) :: n1, n2
385 if (this%idxbudrain /= 0)
then
386 do j = 1, this%flowbudptr%budterm(this%idxbudrain)%nlist
387 call this%sft_rain_term(j, n1, n2, rrate)
388 this%dbuff(n1) = this%dbuff(n1) + rrate
393 if (this%idxbudevap /= 0)
then
394 do j = 1, this%flowbudptr%budterm(this%idxbudevap)%nlist
395 call this%sft_evap_term(j, n1, n2, rrate)
396 this%dbuff(n1) = this%dbuff(n1) + rrate
401 if (this%idxbudroff /= 0)
then
402 do j = 1, this%flowbudptr%budterm(this%idxbudroff)%nlist
403 call this%sft_roff_term(j, n1, n2, rrate)
404 this%dbuff(n1) = this%dbuff(n1) + rrate
409 if (this%idxbudiflw /= 0)
then
410 do j = 1, this%flowbudptr%budterm(this%idxbudiflw)%nlist
411 call this%sft_iflw_term(j, n1, n2, rrate)
412 this%dbuff(n1) = this%dbuff(n1) + rrate
417 if (this%idxbudoutf /= 0)
then
418 do j = 1, this%flowbudptr%budterm(this%idxbudoutf)%nlist
419 call this%sft_outf_term(j, n1, n2, rrate)
420 this%dbuff(n1) = this%dbuff(n1) + rrate
434 integer(I4B) :: nbudterms
448 integer(I4B),
intent(inout) :: idx
450 integer(I4B) :: maxlist, naux
451 character(len=LENBUDTXT) :: text
456 maxlist = this%flowbudptr%budterm(this%idxbudrain)%maxlist
458 call this%budobj%budterm(idx)%initialize(text, &
463 maxlist, .false., .false., &
467 text =
' EVAPORATION'
469 maxlist = this%flowbudptr%budterm(this%idxbudevap)%maxlist
471 call this%budobj%budterm(idx)%initialize(text, &
476 maxlist, .false., .false., &
482 maxlist = this%flowbudptr%budterm(this%idxbudroff)%maxlist
484 call this%budobj%budterm(idx)%initialize(text, &
489 maxlist, .false., .false., &
495 maxlist = this%flowbudptr%budterm(this%idxbudiflw)%maxlist
497 call this%budobj%budterm(idx)%initialize(text, &
502 maxlist, .false., .false., &
506 text =
' EXT-OUTFLOW'
508 maxlist = this%flowbudptr%budterm(this%idxbudoutf)%maxlist
510 call this%budobj%budterm(idx)%initialize(text, &
515 maxlist, .false., .false., &
525 integer(I4B),
intent(inout) :: idx
526 real(DP),
dimension(:),
intent(in) :: x
527 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
528 real(DP),
intent(inout) :: ccratin
529 real(DP),
intent(inout) :: ccratout
531 integer(I4B) :: j, n1, n2
532 integer(I4B) :: nlist
538 nlist = this%flowbudptr%budterm(this%idxbudrain)%nlist
539 call this%budobj%budterm(idx)%reset(nlist)
541 call this%sft_rain_term(j, n1, n2, q)
542 call this%budobj%budterm(idx)%update_term(n1, n2, q)
543 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
548 nlist = this%flowbudptr%budterm(this%idxbudevap)%nlist
549 call this%budobj%budterm(idx)%reset(nlist)
551 call this%sft_evap_term(j, n1, n2, q)
552 call this%budobj%budterm(idx)%update_term(n1, n2, q)
553 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
558 nlist = this%flowbudptr%budterm(this%idxbudroff)%nlist
559 call this%budobj%budterm(idx)%reset(nlist)
561 call this%sft_roff_term(j, n1, n2, q)
562 call this%budobj%budterm(idx)%update_term(n1, n2, q)
563 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
568 nlist = this%flowbudptr%budterm(this%idxbudiflw)%nlist
569 call this%budobj%budterm(idx)%reset(nlist)
571 call this%sft_iflw_term(j, n1, n2, q)
572 call this%budobj%budterm(idx)%update_term(n1, n2, q)
573 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
578 nlist = this%flowbudptr%budterm(this%idxbudoutf)%nlist
579 call this%budobj%budterm(idx)%reset(nlist)
581 call this%sft_outf_term(j, n1, n2, q)
582 call this%budobj%budterm(idx)%update_term(n1, n2, q)
583 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
598 call this%TspAptType%allocate_scalars()
601 call mem_allocate(this%idxbudrain,
'IDXBUDRAIN', this%memoryPath)
602 call mem_allocate(this%idxbudevap,
'IDXBUDEVAP', this%memoryPath)
603 call mem_allocate(this%idxbudroff,
'IDXBUDROFF', this%memoryPath)
604 call mem_allocate(this%idxbudiflw,
'IDXBUDIFLW', this%memoryPath)
605 call mem_allocate(this%idxbudoutf,
'IDXBUDOUTF', this%memoryPath)
628 call mem_setptr(this%concrain,
'RAINFALL', this%input_mempath)
629 call mem_setptr(this%concevap,
'EVAPORATION', this%input_mempath)
630 call mem_setptr(this%concroff,
'RUNOFF', this%input_mempath)
631 call mem_setptr(this%conciflw,
'INFLOW', this%input_mempath)
633 call mem_allocate(this%vnew, this%ncv,
'VNEW', this%memoryPath)
634 call mem_allocate(this%vold, this%ncv,
'VOLD', this%memoryPath)
638 call this%TspAptType%apt_allocate_arrays()
659 call this%BndExtType%bnd_ad()
660 call this%apt_ad_resync()
666 this%vold(n) = this%vnew(n)
689 nullify (this%concrain)
690 nullify (this%concevap)
691 nullify (this%concroff)
692 nullify (this%conciflw)
698 call this%TspAptType%bnd_da()
707 integer(I4B),
intent(in) :: ientry
708 integer(I4B),
intent(inout) :: n1
709 integer(I4B),
intent(inout) :: n2
710 real(DP),
intent(inout),
optional :: rrate
711 real(DP),
intent(inout),
optional :: rhsval
712 real(DP),
intent(inout),
optional :: hcofval
717 n1 = this%flowbudptr%budterm(this%idxbudrain)%id1(ientry)
718 n2 = this%flowbudptr%budterm(this%idxbudrain)%id2(ientry)
719 qbnd = this%flowbudptr%budterm(this%idxbudrain)%flow(ientry)
720 ctmp = this%concrain(n1)
721 if (
present(rrate)) rrate = ctmp * qbnd
722 if (
present(rhsval)) rhsval = -rrate
723 if (
present(hcofval)) hcofval =
dzero
732 integer(I4B),
intent(in) :: ientry
733 integer(I4B),
intent(inout) :: n1
734 integer(I4B),
intent(inout) :: n2
735 real(DP),
intent(inout),
optional :: rrate
736 real(DP),
intent(inout),
optional :: rhsval
737 real(DP),
intent(inout),
optional :: hcofval
743 n1 = this%flowbudptr%budterm(this%idxbudevap)%id1(ientry)
744 n2 = this%flowbudptr%budterm(this%idxbudevap)%id2(ientry)
746 qbnd = this%flowbudptr%budterm(this%idxbudevap)%flow(ientry)
747 ctmp = this%concevap(n1)
748 if (this%xnewpak(n1) < ctmp)
then
753 if (
present(rrate)) &
754 rrate = omega * qbnd * this%xnewpak(n1) + &
755 (
done - omega) * qbnd * ctmp
756 if (
present(rhsval)) rhsval = -(
done - omega) * qbnd * ctmp
757 if (
present(hcofval)) hcofval = omega * qbnd
766 integer(I4B),
intent(in) :: ientry
767 integer(I4B),
intent(inout) :: n1
768 integer(I4B),
intent(inout) :: n2
769 real(DP),
intent(inout),
optional :: rrate
770 real(DP),
intent(inout),
optional :: rhsval
771 real(DP),
intent(inout),
optional :: hcofval
776 n1 = this%flowbudptr%budterm(this%idxbudroff)%id1(ientry)
777 n2 = this%flowbudptr%budterm(this%idxbudroff)%id2(ientry)
778 qbnd = this%flowbudptr%budterm(this%idxbudroff)%flow(ientry)
779 ctmp = this%concroff(n1)
780 if (
present(rrate)) rrate = ctmp * qbnd
781 if (
present(rhsval)) rhsval = -rrate
782 if (
present(hcofval)) hcofval =
dzero
795 integer(I4B),
intent(in) :: ientry
796 integer(I4B),
intent(inout) :: n1
797 integer(I4B),
intent(inout) :: n2
798 real(DP),
intent(inout),
optional :: rrate
799 real(DP),
intent(inout),
optional :: rhsval
800 real(DP),
intent(inout),
optional :: hcofval
805 n1 = this%flowbudptr%budterm(this%idxbudiflw)%id1(ientry)
806 n2 = this%flowbudptr%budterm(this%idxbudiflw)%id2(ientry)
807 qbnd = this%flowbudptr%budterm(this%idxbudiflw)%flow(ientry)
808 ctmp = this%conciflw(n1)
809 if (
present(rrate)) rrate = ctmp * qbnd
810 if (
present(rhsval)) rhsval = -rrate
811 if (
present(hcofval)) hcofval =
dzero
823 integer(I4B),
intent(in) :: ientry
824 integer(I4B),
intent(inout) :: n1
825 integer(I4B),
intent(inout) :: n2
826 real(DP),
intent(inout),
optional :: rrate
827 real(DP),
intent(inout),
optional :: rhsval
828 real(DP),
intent(inout),
optional :: hcofval
833 n1 = this%flowbudptr%budterm(this%idxbudoutf)%id1(ientry)
834 n2 = this%flowbudptr%budterm(this%idxbudoutf)%id2(ientry)
835 qbnd = this%flowbudptr%budterm(this%idxbudoutf)%flow(ientry)
836 ctmp = this%xnewpak(n1)
837 if (
present(rrate)) rrate = ctmp * qbnd
838 if (
present(rhsval)) rhsval =
dzero
839 if (
present(hcofval)) hcofval = qbnd
856 call this%obs%StoreObsType(
'concentration', .false., indx)
861 call this%obs%StoreObsType(
'flow-ja-face', .true., indx)
866 call this%obs%StoreObsType(
'from-mvr', .true., indx)
871 call this%obs%StoreObsType(
'to-mvr', .true., indx)
876 call this%obs%StoreObsType(
'storage', .true., indx)
881 call this%obs%StoreObsType(
'constant', .true., indx)
886 call this%obs%StoreObsType(
'sft', .true., indx)
891 call this%obs%StoreObsType(
'rainfall', .true., indx)
896 call this%obs%StoreObsType(
'evaporation', .true., indx)
901 call this%obs%StoreObsType(
'runoff', .true., indx)
906 call this%obs%StoreObsType(
'ext-inflow', .true., indx)
911 call this%obs%StoreObsType(
'ext-outflow', .true., indx)
923 logical,
intent(inout) :: found
927 select case (obsrv%ObsTypeId)
929 call this%rp_obs_byfeature(obsrv)
931 call this%rp_obs_byfeature(obsrv)
933 call this%rp_obs_byfeature(obsrv)
935 call this%rp_obs_byfeature(obsrv)
937 call this%rp_obs_byfeature(obsrv)
939 call this%rp_obs_byfeature(obsrv)
950 character(len=*),
intent(in) :: obstypeid
951 real(DP),
intent(inout) :: v
952 integer(I4B),
intent(in) :: jj
953 logical,
intent(inout) :: found
955 integer(I4B) :: n1, n2
958 select case (obstypeid)
960 if (this%iboundpak(jj) /= 0)
then
961 call this%sft_rain_term(jj, n1, n2, v)
964 if (this%iboundpak(jj) /= 0)
then
965 call this%sft_evap_term(jj, n1, n2, v)
968 if (this%iboundpak(jj) /= 0)
then
969 call this%sft_roff_term(jj, n1, n2, v)
972 if (this%iboundpak(jj) /= 0)
then
973 call this%sft_iflw_term(jj, n1, n2, v)
976 if (this%iboundpak(jj) /= 0)
then
977 call this%sft_outf_term(jj, n1, n2, v)
990 integer(I4B),
intent(in) :: icv
991 real(DP),
intent(inout) :: vnew, vold
992 real(DP),
intent(in) :: delt
999 if (this%idxbudsto /= 0)
then
1000 qss = this%flowbudptr%budterm(this%idxbudsto)%flow(icv)
1001 vnew = this%flowbudptr%budterm(this%idxbudsto)%auxvar(1, icv)
1002 this%vnew(icv) = vnew
1003 if (qss /=
dzero)
then
1004 vold = vnew + qss * delt
1006 if (vnew ==
dzero)
then
1009 vold = this%vold(icv)
This module contains the base boundary package.
class(bndtype) function, pointer, public getbndfromlist(list, idx)
Get boundary from package list.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
real(dp), parameter dnodata
real no data constant
integer(i4b), parameter lenvarname
maximum length of a variable name
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
real(dp), parameter done
real constant 1
subroutine sft_solve(this)
Add terms specific to sft to the explicit sft solve.
subroutine sft_iflw_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Inflow Term.
subroutine allocate_scalars(this)
Allocate scalars specific to the streamflow energy transport (SFE) package.
character(len= *), parameter flowtype
subroutine sft_outf_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Outflow term.
real(dp) function sft_setting_value(this, itemno, key)
Value for a package-specific PERIOD setting.
subroutine sft_roff_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Runoff term.
subroutine find_sft_package(this)
Find corresponding sft package.
subroutine sft_bd_obs(this, obstypeid, jj, v, found)
Calculate observation value and pass it back to APT.
subroutine sft_rp_obs(this, obsrv, found)
Process package specific obs.
subroutine sft_ad(this)
Advance sft package routine.
subroutine sft_da(this)
Deallocate memory.
subroutine sft_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
Copy flow terms into thisbudobj.
subroutine sft_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
Add matrix terms related to SFT.
subroutine sft_get_volumes(this, icv, vnew, vold, delt)
Return the sfr new volume and old volume.
subroutine, public sft_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath, fmi, eqnsclfac, dvt, dvu, dvua)
Create a new sft package.
character(len= *), parameter ftype
subroutine sft_setup_budobj(this, idx)
Set up the budget object that stores all the sft flows.
integer(i4b) function sft_get_nbudterms(this)
Function to return the number of budget terms just for this package.
subroutine sft_evap_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Evaporative term.
subroutine sft_allocate_arrays(this)
Allocate arrays specific to the streamflow energy transport (SFE) package.
subroutine sft_df_obs(this)
Observations.
subroutine sft_rain_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Rain term.
This module defines variable data types.
This module contains the derived types ObserveType and ObsDataType.
This module contains the SFR package methods.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
integer(i4b) ifailedstepretry
current retry for this time step
subroutine, public apt_process_obsid(obsrv, dis, inunitobs, iout)
Process observation IDs for an advanced package.
subroutine, public apt_process_obsid12(obsrv, dis, inunitobs, iout)
Process observation IDs for a package.
This class is used to store a single deferred-length character string. It was designed to work in an ...