MODFLOW 6  version 6.9.0.dev0
USGS Modular Hydrologic Model
gwe-sfe.f90
Go to the documentation of this file.
1 ! -- Stream Energy Transport Module
2 ! -- todo: Temperature decay?
3 ! -- todo: save the sfe temperature into the sfr aux variable? (perhaps needed for GWT-GWE exchanges)
4 ! -- todo: calculate the sfr VISC aux variable using temperature?
5 !
6 ! SFR flows (sfrbudptr) index var SFE term Transport Type
7 !---------------------------------------------------------------------------------
8 
9 ! -- terms from SFR that will be handled by parent APT Package
10 ! FLOW-JA-FACE idxbudfjf FLOW-JA-FACE cv2cv
11 ! GWF (aux FLOW-AREA) idxbudgwf GWF cv2gwf
12 ! STORAGE (aux VOLUME) idxbudsto none used for cv volumes
13 ! FROM-MVR idxbudfmvr FROM-MVR rhow * cpw * q * tmpext = this%qfrommvr(:)
14 ! TO-MVR idxbudtmvr TO-MVR rhow * cpw * q * tfeat
15 
16 ! -- terms from SFR that will be handled by SFE
17 ! RAINFALL idxbudrain RAINFALL rhow * cpw * q * train
18 ! EVAPORATION idxbudevap EVAPORATION rhow * latheatvap * q
19 ! RUNOFF idxbudroff RUNOFF rhow * cpw * q * troff
20 ! EXT-INFLOW idxbudiflw EXT-INFLOW rhow * cpw * q * tiflw
21 ! EXT-OUTFLOW idxbudoutf EXT-OUTFLOW rhow * cpw * q * tfeat
22 
23 ! -- terms not associated with SFR
24 ! STRMBD-COND none STRMBD-COND ctherm * (tcell - tfeat) (ctherm is a thermal conductance for the streambed)
25 
26 ! -- terms from a flow file that should be skipped
27 ! CONSTANT none none none
28 ! AUXILIARY none none none
29 
30 ! -- terms that are written to the transport budget file
31 ! none none STORAGE (aux MASS) dE/dt
32 ! none none AUXILIARY none
33 ! none none CONSTANT accumulate
34 !
35 !
37 
38  use kindmodule, only: dp, i4b
44  use simvariablesmodule, only: errmsg
46  use bndmodule, only: bndtype, getbndfromlist
47  use tspfmimodule, only: tspfmitype
48  use sfrmodule, only: sfrtype
49  use observemodule, only: observetype
54  !
55  implicit none
56  !
57  private
58  public :: sfe_create
59  !
60  character(len=*), parameter :: ftype = 'SFE'
61  character(len=*), parameter :: flowtype = 'SFR'
62  character(len=16) :: text = ' SFE'
63 
64  type, extends(tspapttype) :: gwesfetype
65 
66  type(gweinputdatatype), pointer :: gwecommon => null() !< pointer to shared gwe data used by multiple packages but set in mst
67 
68  integer(I4B), pointer :: idxbudrain => null() !< index of rainfall terms in flowbudptr
69  integer(I4B), pointer :: idxbudevap => null() !< index of evaporation terms in flowbudptr
70  integer(I4B), pointer :: idxbudroff => null() !< index of runoff terms in flowbudptr
71  integer(I4B), pointer :: idxbudiflw => null() !< index of inflow terms in flowbudptr
72  integer(I4B), pointer :: idxbudoutf => null() !< index of outflow terms in flowbudptr
73 
74  real(dp), dimension(:), pointer, contiguous :: temprain => null() !< rainfall temperature
75  real(dp), dimension(:), pointer, contiguous :: tempevap => null() !< evaporation temperature
76  real(dp), dimension(:), pointer, contiguous :: temproff => null() !< runoff temperature
77  real(dp), dimension(:), pointer, contiguous :: tempiflw => null() !< inflow temperature
78  real(dp), dimension(:), pointer, contiguous :: vnew => null() !< current volume of reach
79  real(dp), dimension(:), pointer, contiguous :: vold => null() !< previous volume of reach
80  real(dp), dimension(:), pointer, contiguous :: ktf => null() !< thermal conductivity between the sfe and groundwater cell
81  real(dp), dimension(:), pointer, contiguous :: rfeatthk => null() !< thickness of streambed material through which thermal conduction occurs
82 
83  contains
84 
85  procedure :: bnd_ad => sfe_ad
86  procedure :: bnd_da => sfe_da
87  procedure :: allocate_scalars
88  procedure :: apt_allocate_arrays => sfe_allocate_arrays
89  procedure :: apt_source_cvs => sfe_read_cvs
90  procedure :: find_apt_package => find_sfe_package
91  procedure :: apt_setting_value => sfe_setting_value
92  procedure :: pak_fc_expanded => sfe_fc_expanded
93  procedure :: pak_solve => sfe_solve
94  procedure :: pak_get_nbudterms => sfe_get_nbudterms
95  procedure :: pak_setup_budobj => sfe_setup_budobj
96  procedure :: pak_fill_budobj => sfe_fill_budobj
97  procedure :: sfe_rain_term
98  procedure :: sfe_evap_term
99  procedure :: sfe_roff_term
100  procedure :: sfe_iflw_term
101  procedure :: sfe_outf_term
102  procedure, private :: sfe_sbcd_term
103  procedure :: pak_df_obs => sfe_df_obs
104  procedure :: pak_rp_obs => sfe_rp_obs
105  procedure :: pak_bd_obs => sfe_bd_obs
106  procedure :: apt_get_volumes => sfe_get_volumes
107 
108  end type gwesfetype
109 
110 contains
111 
112  !> @brief Create a new sfe package
113  !<
114  subroutine sfe_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, &
115  mempath, fmi, eqnsclfac, gwecommon, dvt, dvu, dvua)
116  ! -- dummy
117  class(bndtype), pointer :: packobj
118  integer(I4B), intent(in) :: id
119  integer(I4B), intent(in) :: ibcnum
120  integer(I4B), intent(in) :: inunit
121  integer(I4B), intent(in) :: iout
122  character(len=*), intent(in) :: namemodel
123  character(len=*), intent(in) :: pakname
124  character(len=*), intent(in) :: mempath !< input memory path
125  type(tspfmitype), pointer :: fmi
126  real(dp), intent(in), pointer :: eqnsclfac !< Governing equation scale factor
127  type(gweinputdatatype), intent(in), target :: gwecommon !< Shared data container for use by multiple GWE packages
128  character(len=*), intent(in) :: dvt !< For GWE, set to "TEMPERATURE" in TspAptType
129  character(len=*), intent(in) :: dvu !< For GWE, set to "energy" in TspAptType
130  character(len=*), intent(in) :: dvua !< For GWE, set to "E" in TspAptType
131  ! -- local
132  type(gwesfetype), pointer :: sfeobj
133  !
134  ! -- Allocate the object and assign values to object variables
135  allocate (sfeobj)
136  packobj => sfeobj
137  !
138  ! -- Create name and memory path
139  call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
140  packobj%text = text
141  !
142  ! -- Allocate scalars
143  call sfeobj%allocate_scalars()
144  !
145  ! -- Initialize package
146  call packobj%pack_initialize()
147  !
148  packobj%inunit = inunit
149  packobj%iout = iout
150  packobj%id = id
151  packobj%ibcnum = ibcnum
152  packobj%ncolbnd = 1
153  packobj%iscloc = 1
154  packobj%isadvpak = 1
155  !
156  ! -- Store pointer to flow model interface. When the GwfGwt exchange is
157  ! created, it sets fmi%bndlist so that the GWT model has access to all
158  ! the flow packages
159  sfeobj%fmi => fmi
160  !
161  ! -- Store pointer to governing equation scale factor
162  sfeobj%eqnsclfac => eqnsclfac
163  !
164  ! -- Store pointer to shared data module for accessing cpw, rhow
165  ! for the budget calculations, and for accessing the latent heat of
166  ! vaporization for evaporative cooling.
167  sfeobj%gwecommon => gwecommon
168  !
169  ! -- Set labels that will be used in generalized APT class
170  sfeobj%depvartype = dvt
171  sfeobj%depvarunit = dvu
172  sfeobj%depvarunitabbrev = dvua
173  end subroutine sfe_create
174 
175  !> @brief Find corresponding sfe package
176  !<
177  subroutine find_sfe_package(this)
178  ! -- modules
180  ! -- dummy
181  class(gwesfetype) :: this
182  ! -- local
183  character(len=LINELENGTH) :: errmsg
184  class(bndtype), pointer :: packobj
185  integer(I4B) :: ip, icount
186  integer(I4B) :: nbudterm
187  logical :: found
188  !
189  ! -- Initialize found to false, and error later if flow package cannot
190  ! be found
191  found = .false.
192  !
193  ! -- If user is specifying flows in a binary budget file, then set up
194  ! the budget file reader, otherwise set a pointer to the flow package
195  ! budobj
196  if (this%fmi%flows_from_file) then
197  call this%fmi%set_aptbudobj_pointer(this%flowpackagename, this%flowbudptr)
198  if (associated(this%flowbudptr)) found = .true.
199  !
200  else
201  if (associated(this%fmi%gwfbndlist)) then
202  ! -- Look through gwfbndlist for a flow package with the same name as
203  ! this transport package name
204  do ip = 1, this%fmi%gwfbndlist%Count()
205  packobj => getbndfromlist(this%fmi%gwfbndlist, ip)
206  if (packobj%packName == this%flowpackagename) then
207  found = .true.
208  !
209  ! -- Store BndType pointer to packobj, and then
210  ! use the select type to point to the budobj in flow package
211  this%flowpackagebnd => packobj
212  select type (packobj)
213  type is (sfrtype)
214  this%flowbudptr => packobj%budobj
215  end select
216  end if
217  if (found) exit
218  end do
219  end if
220  end if
221  !
222  ! -- Error if flow package not found
223  if (.not. found) then
224  write (errmsg, '(a)') 'Could not find flow package with name '&
225  &//trim(adjustl(this%flowpackagename))//'.'
226  call store_error(errmsg)
227  call store_error_filename(this%input_fname)
228  end if
229  !
230  ! -- Allocate space for idxbudssm, which indicates whether this is a
231  ! special budget term or one that is a general source and sink
232  nbudterm = this%flowbudptr%nbudterm
233  call mem_allocate(this%idxbudssm, nbudterm, 'IDXBUDSSM', this%memoryPath)
234  !
235  ! -- Process budget terms and identify special budget terms
236  write (this%iout, '(/, a, a)') &
237  'PROCESSING '//ftype//' INFORMATION FOR ', this%packName
238  write (this%iout, '(a)') ' IDENTIFYING FLOW TERMS IN '//flowtype//' PACKAGE'
239  write (this%iout, '(a, i0)') &
240  ' NUMBER OF '//flowtype//' = ', this%flowbudptr%ncv
241  icount = 1
242  do ip = 1, this%flowbudptr%nbudterm
243  select case (trim(adjustl(this%flowbudptr%budterm(ip)%flowtype)))
244  case ('FLOW-JA-FACE')
245  this%idxbudfjf = ip
246  this%idxbudssm(ip) = 0
247  case ('GWF')
248  this%idxbudgwf = ip
249  this%idxbudssm(ip) = 0
250  case ('STORAGE')
251  this%idxbudsto = ip
252  this%idxbudssm(ip) = 0
253  case ('RAINFALL')
254  this%idxbudrain = ip
255  this%idxbudssm(ip) = 0
256  case ('EVAPORATION')
257  this%idxbudevap = ip
258  this%idxbudssm(ip) = 0
259  case ('RUNOFF')
260  this%idxbudroff = ip
261  this%idxbudssm(ip) = 0
262  case ('EXT-INFLOW')
263  this%idxbudiflw = ip
264  this%idxbudssm(ip) = 0
265  case ('EXT-OUTFLOW')
266  this%idxbudoutf = ip
267  this%idxbudssm(ip) = 0
268  case ('TO-MVR')
269  this%idxbudtmvr = ip
270  this%idxbudssm(ip) = 0
271  case ('FROM-MVR')
272  this%idxbudfmvr = ip
273  this%idxbudssm(ip) = 0
274  case ('AUXILIARY')
275  this%idxbudaux = ip
276  this%idxbudssm(ip) = 0
277  case default
278  !
279  ! -- Set idxbudssm equal to a column index for where the temperatures
280  ! are stored in the concbud(nbudssm, ncv) array
281  this%idxbudssm(ip) = icount
282  icount = icount + 1
283  end select
284  write (this%iout, '(a, i0, " = ", a,/, a, i0)') &
285  ' TERM ', ip, trim(adjustl(this%flowbudptr%budterm(ip)%flowtype)), &
286  ' MAX NO. OF ENTRIES = ', this%flowbudptr%budterm(ip)%maxlist
287  end do
288  write (this%iout, '(a, //)') 'DONE PROCESSING '//ftype//' INFORMATION'
289  end subroutine find_sfe_package
290 
291  !> @brief Value for a package-specific PERIOD setting
292  !!
293  !! Already resolved by the input context; this only supplies it for
294  !! the shared apt_rp table echo.
295  !<
296  function sfe_setting_value(this, itemno, key) result(val)
297  ! -- dummy
298  class(gwesfetype), intent(inout) :: this
299  integer(I4B), intent(in) :: itemno
300  character(len=*), intent(in) :: key
301  real(dp) :: val
302  !
303  val = dzero
304  select case (trim(key))
305  case ('RAINFALL')
306  val = this%temprain(itemno)
307  case ('EVAPORATION')
308  val = this%tempevap(itemno)
309  case ('RUNOFF')
310  val = this%temproff(itemno)
311  case ('INFLOW')
312  val = this%tempiflw(itemno)
313  end select
314  end function sfe_setting_value
315 
316  !> @brief Add matrix terms related to SFE
317  !!
318  !! This will be called from TspAptType%apt_fc_expanded()
319  !! in order to add matrix terms specifically for SFE
320  !<
321  subroutine sfe_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
322  ! -- dummy
323  class(gwesfetype) :: this
324  real(DP), dimension(:), intent(inout) :: rhs
325  integer(I4B), dimension(:), intent(in) :: ia
326  integer(I4B), dimension(:), intent(in) :: idxglo
327  class(matrixbasetype), pointer :: matrix_sln
328  ! -- local
329  integer(I4B) :: j, n1, n2
330  integer(I4B) :: iloc
331  integer(I4B) :: iposd, iposoffd
332  integer(I4B) :: ipossymd, ipossymoffd
333  real(DP) :: rrate
334  real(DP) :: rhsval
335  real(DP) :: hcofval
336  !
337  ! -- Add rainfall contribution
338  if (this%idxbudrain /= 0) then
339  do j = 1, this%flowbudptr%budterm(this%idxbudrain)%nlist
340  call this%sfe_rain_term(j, n1, n2, rrate, rhsval, hcofval)
341  iloc = this%idxlocnode(n1)
342  iposd = this%idxpakdiag(n1)
343  call matrix_sln%add_value_pos(iposd, hcofval)
344  rhs(iloc) = rhs(iloc) + rhsval
345  end do
346  end if
347  !
348  ! -- Add evaporation contribution
349  if (this%idxbudevap /= 0) then
350  do j = 1, this%flowbudptr%budterm(this%idxbudevap)%nlist
351  call this%sfe_evap_term(j, n1, n2, rrate, rhsval, hcofval)
352  iloc = this%idxlocnode(n1)
353  iposd = this%idxpakdiag(n1)
354  call matrix_sln%add_value_pos(iposd, hcofval)
355  rhs(iloc) = rhs(iloc) + rhsval
356  end do
357  end if
358  !
359  ! -- Add runoff contribution
360  if (this%idxbudroff /= 0) then
361  do j = 1, this%flowbudptr%budterm(this%idxbudroff)%nlist
362  call this%sfe_roff_term(j, n1, n2, rrate, rhsval, hcofval)
363  iloc = this%idxlocnode(n1)
364  iposd = this%idxpakdiag(n1)
365  call matrix_sln%add_value_pos(iposd, hcofval)
366  rhs(iloc) = rhs(iloc) + rhsval
367  end do
368  end if
369  !
370  ! -- Add inflow contribution
371  if (this%idxbudiflw /= 0) then
372  do j = 1, this%flowbudptr%budterm(this%idxbudiflw)%nlist
373  call this%sfe_iflw_term(j, n1, n2, rrate, rhsval, hcofval)
374  iloc = this%idxlocnode(n1)
375  iposd = this%idxpakdiag(n1)
376  call matrix_sln%add_value_pos(iposd, hcofval)
377  rhs(iloc) = rhs(iloc) + rhsval
378  end do
379  end if
380  !
381  ! -- Add outflow contribution
382  if (this%idxbudoutf /= 0) then
383  do j = 1, this%flowbudptr%budterm(this%idxbudoutf)%nlist
384  call this%sfe_outf_term(j, n1, n2, rrate, rhsval, hcofval)
385  iloc = this%idxlocnode(n1)
386  iposd = this%idxpakdiag(n1)
387  call matrix_sln%add_value_pos(iposd, hcofval)
388  rhs(iloc) = rhs(iloc) + rhsval
389  end do
390  end if
391  !
392  ! -- Add streambed conduction contribution
393  do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
394  !
395  ! -- Set n to feature number and process if active feature
396  n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
397  if (this%iboundpak(n1) /= 0) then
398  !
399  call this%sfe_sbcd_term(j, n1, n2, rrate, rhsval, hcofval)
400  !
401  ! -- Add to sfe row
402  iposd = this%idxdglo(j)
403  iposoffd = this%idxoffdglo(j)
404  call matrix_sln%add_value_pos(iposd, -hcofval)
405  call matrix_sln%add_value_pos(iposoffd, hcofval)
406  !
407  ! -- Add to gwe row for sfe connection
408  ipossymd = this%idxsymdglo(j)
409  ipossymoffd = this%idxsymoffdglo(j)
410  call matrix_sln%add_value_pos(ipossymd, -hcofval)
411  call matrix_sln%add_value_pos(ipossymoffd, hcofval)
412  end if
413  end do
414  end subroutine sfe_fc_expanded
415 
416  !> @ brief Add terms specific to sfr to the explicit sfe solve
417  !<
418  subroutine sfe_solve(this)
419  ! -- dummy
420  class(gwesfetype) :: this
421  ! -- local
422  integer(I4B) :: j
423  integer(I4B) :: n1, n2
424  real(DP) :: rrate
425  !
426  ! -- Add rainfall contribution
427  if (this%idxbudrain /= 0) then
428  do j = 1, this%flowbudptr%budterm(this%idxbudrain)%nlist
429  call this%sfe_rain_term(j, n1, n2, rrate)
430  this%dbuff(n1) = this%dbuff(n1) + rrate
431  end do
432  end if
433  !
434  ! -- Add evaporation contribution
435  if (this%idxbudevap /= 0) then
436  do j = 1, this%flowbudptr%budterm(this%idxbudevap)%nlist
437  call this%sfe_evap_term(j, n1, n2, rrate)
438  this%dbuff(n1) = this%dbuff(n1) + rrate
439  end do
440  end if
441  !
442  ! -- Add runoff contribution
443  if (this%idxbudroff /= 0) then
444  do j = 1, this%flowbudptr%budterm(this%idxbudroff)%nlist
445  call this%sfe_roff_term(j, n1, n2, rrate)
446  this%dbuff(n1) = this%dbuff(n1) + rrate
447  end do
448  end if
449  !
450  ! -- Add inflow contribution
451  if (this%idxbudiflw /= 0) then
452  do j = 1, this%flowbudptr%budterm(this%idxbudiflw)%nlist
453  call this%sfe_iflw_term(j, n1, n2, rrate)
454  this%dbuff(n1) = this%dbuff(n1) + rrate
455  end do
456  end if
457  !
458  ! -- Add outflow contribution
459  if (this%idxbudoutf /= 0) then
460  do j = 1, this%flowbudptr%budterm(this%idxbudoutf)%nlist
461  call this%sfe_outf_term(j, n1, n2, rrate)
462  this%dbuff(n1) = this%dbuff(n1) + rrate
463  end do
464  end if
465  !
466  ! Note: explicit streambed conduction terms???
467  end subroutine sfe_solve
468 
469  !> @brief Function to return the number of budget terms just for this package.
470  !!
471  !! This overrides a function in the parent class.
472  !<
473  function sfe_get_nbudterms(this) result(nbudterms)
474  ! -- dummy
475  class(gwesfetype) :: this
476  ! -- return
477  integer(I4B) :: nbudterms
478  !
479  ! -- Number of budget terms is 6:
480  ! 1. rainfall
481  ! 2. evaporation
482  ! 3. runoff
483  ! 4. ext-inflow
484  ! 5. ext-outflow
485  ! 6. strmbd-cond
486  nbudterms = 6
487  end function sfe_get_nbudterms
488 
489  !> @brief Set up the budget object that stores all the sfe flows
490  !<
491  subroutine sfe_setup_budobj(this, idx)
492  ! -- modules
493  use constantsmodule, only: lenbudtxt
494  ! -- dummy
495  class(gwesfetype) :: this
496  integer(I4B), intent(inout) :: idx
497  ! -- local
498  integer(I4B) :: n, n1, n2
499  integer(I4B) :: maxlist, naux
500  real(DP) :: q
501  character(len=LENBUDTXT) :: text
502  !
503  ! --
504  text = ' RAINFALL'
505  idx = idx + 1
506  maxlist = this%flowbudptr%budterm(this%idxbudrain)%maxlist
507  naux = 0
508  call this%budobj%budterm(idx)%initialize(text, &
509  this%name_model, &
510  this%packName, &
511  this%name_model, &
512  this%packName, &
513  maxlist, .false., .false., &
514  naux)
515  !
516  ! --
517  text = ' EVAPORATION'
518  idx = idx + 1
519  maxlist = this%flowbudptr%budterm(this%idxbudevap)%maxlist
520  naux = 0
521  call this%budobj%budterm(idx)%initialize(text, &
522  this%name_model, &
523  this%packName, &
524  this%name_model, &
525  this%packName, &
526  maxlist, .false., .false., &
527  naux)
528  !
529  ! --
530  text = ' RUNOFF'
531  idx = idx + 1
532  maxlist = this%flowbudptr%budterm(this%idxbudroff)%maxlist
533  naux = 0
534  call this%budobj%budterm(idx)%initialize(text, &
535  this%name_model, &
536  this%packName, &
537  this%name_model, &
538  this%packName, &
539  maxlist, .false., .false., &
540  naux)
541  !
542  ! --
543  text = ' EXT-INFLOW'
544  idx = idx + 1
545  maxlist = this%flowbudptr%budterm(this%idxbudiflw)%maxlist
546  naux = 0
547  call this%budobj%budterm(idx)%initialize(text, &
548  this%name_model, &
549  this%packName, &
550  this%name_model, &
551  this%packName, &
552  maxlist, .false., .false., &
553  naux)
554  !
555  ! --
556  text = ' EXT-OUTFLOW'
557  idx = idx + 1
558  maxlist = this%flowbudptr%budterm(this%idxbudoutf)%maxlist
559  naux = 0
560  call this%budobj%budterm(idx)%initialize(text, &
561  this%name_model, &
562  this%packName, &
563  this%name_model, &
564  this%packName, &
565  maxlist, .false., .false., &
566  naux)
567  !
568  ! -- Conduction through the wetted streambed
569  text = ' STRMBD-COND'
570  idx = idx + 1
571  maxlist = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
572  naux = 0
573  call this%budobj%budterm(idx)%initialize(text, &
574  this%name_model, &
575  this%packName, &
576  this%name_model, &
577  this%packName, &
578  maxlist, .false., .false., &
579  naux)
580  call this%budobj%budterm(idx)%reset(maxlist)
581  q = dzero
582  do n = 1, maxlist
583  n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(n)
584  n2 = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
585  call this%budobj%budterm(idx)%update_term(n1, n2, q)
586  end do
587  end subroutine sfe_setup_budobj
588 
589  !> @brief Copy flow terms into this%budobj
590  !<
591  subroutine sfe_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
592  ! -- dummy
593  class(gwesfetype) :: this
594  integer(I4B), intent(inout) :: idx
595  real(DP), dimension(:), intent(in) :: x
596  real(DP), dimension(:), contiguous, intent(inout) :: flowja
597  real(DP), intent(inout) :: ccratin
598  real(DP), intent(inout) :: ccratout
599  ! -- local
600  integer(I4B) :: j, n1, n2
601  integer(I4B) :: igwfnode
602  integer(I4B) :: nlist
603  integer(I4B) :: idiag
604  real(DP) :: q
605  !
606  ! -- Rain
607  idx = idx + 1
608  nlist = this%flowbudptr%budterm(this%idxbudrain)%nlist
609  call this%budobj%budterm(idx)%reset(nlist)
610  do j = 1, nlist
611  call this%sfe_rain_term(j, n1, n2, q)
612  call this%budobj%budterm(idx)%update_term(n1, n2, q)
613  call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
614  end do
615  !
616  ! -- Evaporation
617  idx = idx + 1
618  nlist = this%flowbudptr%budterm(this%idxbudevap)%nlist
619  call this%budobj%budterm(idx)%reset(nlist)
620  do j = 1, nlist
621  call this%sfe_evap_term(j, n1, n2, q)
622  call this%budobj%budterm(idx)%update_term(n1, n2, q)
623  call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
624  end do
625  !
626  ! -- Runoff
627  idx = idx + 1
628  nlist = this%flowbudptr%budterm(this%idxbudroff)%nlist
629  call this%budobj%budterm(idx)%reset(nlist)
630  do j = 1, nlist
631  call this%sfe_roff_term(j, n1, n2, q)
632  call this%budobj%budterm(idx)%update_term(n1, n2, q)
633  call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
634  end do
635  !
636  ! -- Ext-inflow
637  idx = idx + 1
638  nlist = this%flowbudptr%budterm(this%idxbudiflw)%nlist
639  call this%budobj%budterm(idx)%reset(nlist)
640  do j = 1, nlist
641  call this%sfe_iflw_term(j, n1, n2, q)
642  call this%budobj%budterm(idx)%update_term(n1, n2, q)
643  call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
644  end do
645  !
646  ! -- Ext-outflow
647  idx = idx + 1
648  nlist = this%flowbudptr%budterm(this%idxbudoutf)%nlist
649  call this%budobj%budterm(idx)%reset(nlist)
650  do j = 1, nlist
651  call this%sfe_outf_term(j, n1, n2, q)
652  call this%budobj%budterm(idx)%update_term(n1, n2, q)
653  call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
654  end do
655  !
656  ! -- Strmbd-cond. The idxbudgwf index is used since it contains the
657  ! sfe/cell mapping information
658  idx = idx + 1
659  nlist = this%flowbudptr%budterm(this%idxbudgwf)%nlist
660  call this%budobj%budterm(idx)%reset(nlist)
661  do j = 1, nlist
662  n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
663  if (this%iboundpak(n1) /= 0) then
664  ! -- use igwfnode instead of n2 for consistency with usage in apt;
665  ! helps highlight that cell number is sought and used
666  call this%sfe_sbcd_term(j, n1, igwfnode, q)
667  call this%budobj%budterm(idx)%update_term(n1, igwfnode, q)
668  call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
669  ! -- Contribution to gwe cell budget, which is different than the
670  ! other terms (i.e., ext-inflow, evap, etc.)
671  this%simvals(n1) = this%simvals(n1) - q
672  idiag = this%dis%con%ia(igwfnode)
673  flowja(idiag) = flowja(idiag) - q
674  end if
675  end do
676  end subroutine sfe_fill_budobj
677 
678  !> @brief Allocate scalars specific to the streamflow energy transport (SFE)
679  !! package.
680  !<
681  subroutine allocate_scalars(this)
682  ! -- modules
684  ! -- dummy
685  class(gwesfetype) :: this
686  !
687  ! -- Allocate scalars in TspAptType
688  call this%TspAptType%allocate_scalars()
689  !
690  ! -- Allocate
691  call mem_allocate(this%idxbudrain, 'IDXBUDRAIN', this%memoryPath)
692  call mem_allocate(this%idxbudevap, 'IDXBUDEVAP', this%memoryPath)
693  call mem_allocate(this%idxbudroff, 'IDXBUDROFF', this%memoryPath)
694  call mem_allocate(this%idxbudiflw, 'IDXBUDIFLW', this%memoryPath)
695  call mem_allocate(this%idxbudoutf, 'IDXBUDOUTF', this%memoryPath)
696  !
697  ! -- Initialize
698  this%idxbudrain = 0
699  this%idxbudevap = 0
700  this%idxbudroff = 0
701  this%idxbudiflw = 0
702  this%idxbudoutf = 0
703  end subroutine allocate_scalars
704 
705  !> @brief Allocate arrays specific to the streamflow energy transport (SFE)
706  !! package.
707  !<
708  subroutine sfe_allocate_arrays(this)
709  ! -- modules
711  ! -- dummy
712  class(gwesfetype), intent(inout) :: this
713  ! -- local
714  integer(I4B) :: n
715  !
716  ! -- alias into the input context's permanent, feature-indexed arrays
717  ! (allocated and DZERO-initialized by the input context)
718  call mem_setptr(this%temprain, 'RAINFALL', this%input_mempath)
719  call mem_setptr(this%tempevap, 'EVAPORATION', this%input_mempath)
720  call mem_setptr(this%temproff, 'RUNOFF', this%input_mempath)
721  call mem_setptr(this%tempiflw, 'INFLOW', this%input_mempath)
722  !
723  call mem_allocate(this%vnew, this%ncv, 'VNEW', this%memoryPath)
724  call mem_allocate(this%vold, this%ncv, 'VOLD', this%memoryPath)
725  !
726  ! -- Call standard TspAptType allocate arrays
727  call this%TspAptType%apt_allocate_arrays()
728  !
729  ! -- Initialize
730  do n = 1, this%ncv
731  this%vnew(n) = dzero
732  this%vold(n) = dzero
733  end do
734  end subroutine sfe_allocate_arrays
735 
736  !> @brief Advance sfe package routine
737  !<
738  subroutine sfe_ad(this)
739  ! -- dummy
740  class(gwesfetype) :: this
741  ! -- local
742  integer(I4B) :: n
743  !
744  ! -- call base bnd_ad and run the per-timestep resync directly
745  ! (see apt_ad_resync)
746  call this%BndExtType%bnd_ad()
747  call this%apt_ad_resync()
748  !
749  ! -- update vold
750  do n = 1, this%ncv
751  this%vold(n) = this%vnew(n)
752  end do
753 
754  end subroutine sfe_ad
755 
756  !> @brief Deallocate memory
757  !<
758  subroutine sfe_da(this)
759  ! -- modules
761  ! -- dummy
762  class(gwesfetype) :: this
763  !
764  ! -- Deallocate scalars
765  call mem_deallocate(this%idxbudrain)
766  call mem_deallocate(this%idxbudevap)
767  call mem_deallocate(this%idxbudroff)
768  call mem_deallocate(this%idxbudiflw)
769  call mem_deallocate(this%idxbudoutf)
770  !
771  ! -- input-context-owned aliases, not package-allocated
772  nullify (this%temprain)
773  nullify (this%tempevap)
774  nullify (this%temproff)
775  nullify (this%tempiflw)
776  !
777  call mem_deallocate(this%vnew)
778  call mem_deallocate(this%vold)
779  !
780  ! -- Deallocate arrays
781  call mem_deallocate(this%ktf)
782  call mem_deallocate(this%rfeatthk)
783  !
784  ! -- Deallocate scalars in TspAptType
785  call this%TspAptType%bnd_da()
786  end subroutine sfe_da
787 
788  !> @brief Rain term
789  !<
790  subroutine sfe_rain_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
791  ! -- dummy
792  class(gwesfetype) :: this
793  integer(I4B), intent(in) :: ientry
794  integer(I4B), intent(inout) :: n1
795  integer(I4B), intent(inout) :: n2
796  real(DP), intent(inout), optional :: rrate
797  real(DP), intent(inout), optional :: rhsval
798  real(DP), intent(inout), optional :: hcofval
799  ! -- local
800  real(DP) :: qbnd
801  real(DP) :: ctmp
802  !
803  n1 = this%flowbudptr%budterm(this%idxbudrain)%id1(ientry)
804  n2 = this%flowbudptr%budterm(this%idxbudrain)%id2(ientry)
805  qbnd = this%flowbudptr%budterm(this%idxbudrain)%flow(ientry)
806  ctmp = this%temprain(n1)
807  if (present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
808  if (present(rhsval)) rhsval = -rrate
809  if (present(hcofval)) hcofval = dzero
810  end subroutine sfe_rain_term
811 
812  !> @brief Evaporative term
813  !<
814  subroutine sfe_evap_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
815  ! -- dummy
816  class(gwesfetype) :: this
817  integer(I4B), intent(in) :: ientry
818  integer(I4B), intent(inout) :: n1
819  integer(I4B), intent(inout) :: n2
820  real(DP), intent(inout), optional :: rrate
821  real(DP), intent(inout), optional :: rhsval
822  real(DP), intent(inout), optional :: hcofval
823  ! -- local
824  real(DP) :: qbnd
825  real(DP) :: heatlat
826  !
827  n1 = this%flowbudptr%budterm(this%idxbudevap)%id1(ientry)
828  n2 = this%flowbudptr%budterm(this%idxbudevap)%id2(ientry)
829  ! -- note that qbnd is negative for evap
830  qbnd = this%flowbudptr%budterm(this%idxbudevap)%flow(ientry)
831  heatlat = this%gwecommon%gwerhow * this%gwecommon%gwelatheatvap
832  if (present(rrate)) rrate = qbnd * heatlat
833  if (present(rhsval)) rhsval = -rrate
834  if (present(hcofval)) hcofval = dzero
835  end subroutine sfe_evap_term
836 
837  !> @brief Runoff term
838  !<
839  subroutine sfe_roff_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
840  ! -- dummy
841  class(gwesfetype) :: this
842  integer(I4B), intent(in) :: ientry
843  integer(I4B), intent(inout) :: n1
844  integer(I4B), intent(inout) :: n2
845  real(DP), intent(inout), optional :: rrate
846  real(DP), intent(inout), optional :: rhsval
847  real(DP), intent(inout), optional :: hcofval
848  ! -- local
849  real(DP) :: qbnd
850  real(DP) :: ctmp
851  !
852  n1 = this%flowbudptr%budterm(this%idxbudroff)%id1(ientry)
853  n2 = this%flowbudptr%budterm(this%idxbudroff)%id2(ientry)
854  qbnd = this%flowbudptr%budterm(this%idxbudroff)%flow(ientry)
855  ctmp = this%temproff(n1)
856  if (present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
857  if (present(rhsval)) rhsval = -rrate
858  if (present(hcofval)) hcofval = dzero
859  end subroutine sfe_roff_term
860 
861  !> @brief Inflow Term
862  !!
863  !! Accounts for energy added via streamflow entering into a stream channel;
864  !! for example, energy entering the model domain via a specified flow in a
865  !! stream channel.
866  !<
867  subroutine sfe_iflw_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
868  ! -- dummy
869  class(gwesfetype) :: this
870  integer(I4B), intent(in) :: ientry
871  integer(I4B), intent(inout) :: n1
872  integer(I4B), intent(inout) :: n2
873  real(DP), intent(inout), optional :: rrate
874  real(DP), intent(inout), optional :: rhsval
875  real(DP), intent(inout), optional :: hcofval
876  ! -- local
877  real(DP) :: qbnd
878  real(DP) :: ctmp
879  !
880  n1 = this%flowbudptr%budterm(this%idxbudiflw)%id1(ientry)
881  n2 = this%flowbudptr%budterm(this%idxbudiflw)%id2(ientry)
882  qbnd = this%flowbudptr%budterm(this%idxbudiflw)%flow(ientry)
883  ctmp = this%tempiflw(n1)
884  if (present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
885  if (present(rhsval)) rhsval = -rrate
886  if (present(hcofval)) hcofval = dzero
887  end subroutine sfe_iflw_term
888 
889  !> @brief Outflow term
890  !!
891  !! Accounts for the energy leaving a stream channel, for example, energy exiting the
892  !! model domain via a flow in a stream channel flowing out of the active domain.
893  !<
894  subroutine sfe_outf_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
895  ! -- dummy
896  class(gwesfetype) :: this
897  integer(I4B), intent(in) :: ientry
898  integer(I4B), intent(inout) :: n1
899  integer(I4B), intent(inout) :: n2
900  real(DP), intent(inout), optional :: rrate
901  real(DP), intent(inout), optional :: rhsval
902  real(DP), intent(inout), optional :: hcofval
903  ! -- local
904  real(DP) :: qbnd
905  real(DP) :: ctmp
906  !
907  n1 = this%flowbudptr%budterm(this%idxbudoutf)%id1(ientry)
908  n2 = this%flowbudptr%budterm(this%idxbudoutf)%id2(ientry)
909  qbnd = this%flowbudptr%budterm(this%idxbudoutf)%flow(ientry)
910  ctmp = this%xnewpak(n1)
911  if (present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
912  if (present(rhsval)) rhsval = dzero
913  if (present(hcofval)) hcofval = qbnd * this%eqnsclfac
914  end subroutine sfe_outf_term
915 
916  !> @brief Streambed conduction term
917  !!
918  !! Accounts for the energy entering or leaving a stream channel by
919  !! thermal conduction through the streambed.
920  !<
921  subroutine sfe_sbcd_term(this, ientry, n1, igwfnode, rrate, rhsval, hcofval)
922  ! -- dummy
923  class(gwesfetype) :: this
924  integer(I4B), intent(in) :: ientry
925  integer(I4B), intent(inout) :: n1
926  integer(I4B), intent(inout) :: igwfnode
927  real(DP), intent(inout), optional :: rrate
928  real(DP), intent(inout), optional :: rhsval
929  real(DP), intent(inout), optional :: hcofval
930  ! -- local
931  integer(I4B) :: auxpos
932  real(DP) :: wa !< wetted area
933  real(DP) :: ktf !< thermal conductivity of streambed material
934  real(DP) :: s !< thickness of conductive streambed material
935  real(DP) :: ctherm
936  !
937  rrate = dzero
938  n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(ientry)
939  ! -- use igwfnode instead of n2 for consistency with usage in apt;
940  ! helps highlight that cell number is sought and used
941  igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(ientry)
942  ! -- For now, there is only 1 aux variable under 'GWF'
943  auxpos = this%flowbudptr%budterm(this%idxbudgwf)%naux
944  wa = this%flowbudptr%budterm(this%idxbudgwf)%auxvar(auxpos, ientry)
945  ktf = this%ktf(n1)
946  s = this%rfeatthk(n1)
947  ctherm = ktf * wa / s
948  ! -- this%xnew available b/c set in parent class (TspAptType) using
949  ! routine set_pointers from the "grandparent" class BndType
950  if (present(rrate)) rrate = ctherm * (this%xnew(igwfnode) - this%xnewpak(n1))
951  if (present(rhsval)) rhsval = dzero
952  if (present(hcofval)) hcofval = ctherm
953  end subroutine sfe_sbcd_term
954 
955  !> @brief Observations
956  !!
957  !! Store the observation type supported by the APT package and override
958  !! BndType%bnd_df_obs
959  !<
960  subroutine sfe_df_obs(this)
961  ! -- modules
962  ! -- dummy
963  class(gwesfetype) :: this
964  ! -- local
965  integer(I4B) :: indx
966  !
967  ! -- Store obs type and assign procedure pointer
968  ! for temperature observation type.
969  call this%obs%StoreObsType('temperature', .false., indx)
970  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
971  !
972  ! -- Store obs type and assign procedure pointer
973  ! for flow between reaches.
974  call this%obs%StoreObsType('flow-ja-face', .true., indx)
975  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid12
976  !
977  ! -- Store obs type and assign procedure pointer
978  ! for from-mvr observation type.
979  call this%obs%StoreObsType('from-mvr', .true., indx)
980  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
981  !
982  ! -- Store obs type and assign procedure pointer
983  ! for to-mvr observation type.
984  call this%obs%StoreObsType('to-mvr', .true., indx)
985  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
986  !
987  ! -- Store obs type and assign procedure pointer
988  ! for storage observation type.
989  call this%obs%StoreObsType('storage', .true., indx)
990  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
991  !
992  ! -- Store obs type and assign procedure pointer
993  ! for constant observation type.
994  call this%obs%StoreObsType('constant', .true., indx)
995  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
996  !
997  ! -- Store obs type and assign procedure pointer
998  ! for observation type: sfe
999  call this%obs%StoreObsType('sfe', .true., indx)
1000  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
1001  !
1002  ! -- Store obs type and assign procedure pointer
1003  ! for rainfall observation type.
1004  call this%obs%StoreObsType('rainfall', .true., indx)
1005  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
1006  !
1007  ! -- Store obs type and assign procedure pointer
1008  ! for evaporation observation type.
1009  call this%obs%StoreObsType('evaporation', .true., indx)
1010  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
1011  !
1012  ! -- Store obs type and assign procedure pointer
1013  ! for runoff observation type.
1014  call this%obs%StoreObsType('runoff', .true., indx)
1015  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
1016  !
1017  ! -- Store obs type and assign procedure pointer
1018  ! for inflow observation type.
1019  call this%obs%StoreObsType('ext-inflow', .true., indx)
1020  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
1021  !
1022  ! -- Store obs type and assign procedure pointer
1023  ! for ext-outflow observation type.
1024  call this%obs%StoreObsType('ext-outflow', .true., indx)
1025  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
1026  !
1027  ! -- Store obs type and assign procedure pointer
1028  ! for strmbd-cond observation type.
1029  call this%obs%StoreObsType('strmbd-cond', .true., indx)
1030  this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
1031  end subroutine sfe_df_obs
1032 
1033  !> @brief Process package specific obs
1034  !!
1035  !! Method to process specific observations for this package.
1036  !<
1037  subroutine sfe_rp_obs(this, obsrv, found)
1038  ! -- dummy
1039  class(gwesfetype), intent(inout) :: this !< package class
1040  type(observetype), intent(inout) :: obsrv !< observation object
1041  logical, intent(inout) :: found !< indicate whether observation was found
1042  ! -- local
1043  !
1044  found = .true.
1045  select case (obsrv%ObsTypeId)
1046  case ('RAINFALL')
1047  call this%rp_obs_byfeature(obsrv)
1048  case ('EVAPORATION')
1049  call this%rp_obs_byfeature(obsrv)
1050  case ('RUNOFF')
1051  call this%rp_obs_byfeature(obsrv)
1052  case ('EXT-INFLOW')
1053  call this%rp_obs_byfeature(obsrv)
1054  case ('EXT-OUTFLOW')
1055  call this%rp_obs_byfeature(obsrv)
1056  case ('TO-MVR')
1057  call this%rp_obs_byfeature(obsrv)
1058  case ('STRMBD-COND')
1059  call this%rp_obs_byfeature(obsrv)
1060  case default
1061  found = .false.
1062  end select
1063  end subroutine sfe_rp_obs
1064 
1065  !> @brief Calculate observation value and pass it back to APT
1066  !<
1067  subroutine sfe_bd_obs(this, obstypeid, jj, v, found)
1068  ! -- dummy
1069  class(gwesfetype), intent(inout) :: this
1070  character(len=*), intent(in) :: obstypeid
1071  real(DP), intent(inout) :: v
1072  integer(I4B), intent(in) :: jj
1073  logical, intent(inout) :: found
1074  ! -- local
1075  integer(I4B) :: n1, n2
1076  !
1077  found = .true.
1078  select case (obstypeid)
1079  case ('RAINFALL')
1080  if (this%iboundpak(jj) /= 0) then
1081  call this%sfe_rain_term(jj, n1, n2, v)
1082  end if
1083  case ('EVAPORATION')
1084  if (this%iboundpak(jj) /= 0) then
1085  call this%sfe_evap_term(jj, n1, n2, v)
1086  end if
1087  case ('RUNOFF')
1088  if (this%iboundpak(jj) /= 0) then
1089  call this%sfe_roff_term(jj, n1, n2, v)
1090  end if
1091  case ('EXT-INFLOW')
1092  if (this%iboundpak(jj) /= 0) then
1093  call this%sfe_iflw_term(jj, n1, n2, v)
1094  end if
1095  case ('EXT-OUTFLOW')
1096  if (this%iboundpak(jj) /= 0) then
1097  call this%sfe_outf_term(jj, n1, n2, v)
1098  end if
1099  case ('STRMBD-COND')
1100  if (this%iboundpak(jj) /= 0) then
1101  call this%sfe_sbcd_term(jj, n1, n2, v)
1102  end if
1103  case default
1104  found = .false.
1105  end select
1106  end subroutine sfe_bd_obs
1107 
1108  !> @brief Source SFE PACKAGEDATA, including thermal conduction fields.
1109  !<
1110  subroutine sfe_read_cvs(this)
1113  class(gwesfetype), intent(inout) :: this
1114  integer(I4B) :: n, ifeat
1115  real(DP), dimension(:), pointer, contiguous :: ktf_ptr => null()
1116  real(DP), dimension(:), pointer, contiguous :: rbthcnd_ptr => null()
1117  call this%TspAptType%apt_source_cvs()
1118  call mem_allocate(this%ktf, this%ncv, 'KTF', this%memoryPath)
1119  call mem_allocate(this%rfeatthk, this%ncv, 'RFEATTHK', this%memoryPath)
1120  call mem_setptr(ktf_ptr, 'KTF', this%input_mempath)
1121  call mem_setptr(rbthcnd_ptr, 'RBTHCND', this%input_mempath)
1122  do n = 1, size(this%pkg_ifno)
1123  ifeat = this%pkg_ifno(n)
1124  if (ifeat < 1 .or. ifeat > this%ncv) cycle
1125  this%ktf(ifeat) = ktf_ptr(n)
1126  this%rfeatthk(ifeat) = rbthcnd_ptr(n)
1127  if (this%rfeatthk(ifeat) <= dzero) then
1128  write (errmsg, '(4x,a)') &
1129  '****ERROR. Specified thickness used for thermal '// &
1130  'conduction MUST BE > 0 else divide by zero error occurs'
1131  call store_error(errmsg)
1132  end if
1133  end do
1134  if (count_errors() > 0) then
1135  call store_error_filename(this%input_fname)
1136  end if
1137  call memorystore_release('KTF', this%input_mempath)
1138  call memorystore_release('RBTHCND', this%input_mempath)
1139  end subroutine sfe_read_cvs
1140 
1141  !> @brief Return the sfr new volume and old volume
1142  !<
1143  subroutine sfe_get_volumes(this, icv, vnew, vold, delt)
1144  ! -- dummy
1145  class(gwesfetype) :: this
1146  integer(I4B), intent(in) :: icv
1147  real(DP), intent(inout) :: vnew, vold
1148  real(DP), intent(in) :: delt
1149  ! -- local
1150  real(DP) :: qss
1151  !
1152  ! -- get volumes
1153  vold = dzero
1154  vnew = vold
1155  if (this%idxbudsto /= 0) then
1156  qss = this%flowbudptr%budterm(this%idxbudsto)%flow(icv)
1157  vnew = this%flowbudptr%budterm(this%idxbudsto)%auxvar(1, icv)
1158  this%vnew(icv) = vnew
1159  if (qss /= dzero) then
1160  vold = vnew + qss * delt
1161  else
1162  if (vnew == dzero) then
1163  vold = dzero
1164  else
1165  vold = this%vold(icv)
1166  end if
1167  end if
1168  end if
1169  end subroutine sfe_get_volumes
1170 
1171 end module gwesfemodule
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.
Definition: Constants.f90:9
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 dep20
real constant 1e20
Definition: Constants.f90:91
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
integer(i4b), parameter lenboundname
maximum length of a bound name
Definition: Constants.f90:36
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition: Constants.f90:37
real(dp), parameter done
real constant 1
Definition: Constants.f90:76
subroutine sfe_bd_obs(this, obstypeid, jj, v, found)
Calculate observation value and pass it back to APT.
Definition: gwe-sfe.f90:1068
character(len= *), parameter flowtype
Definition: gwe-sfe.f90:61
real(dp) function sfe_setting_value(this, itemno, key)
Value for a package-specific PERIOD setting.
Definition: gwe-sfe.f90:297
subroutine sfe_df_obs(this)
Observations.
Definition: gwe-sfe.f90:961
subroutine allocate_scalars(this)
Allocate scalars specific to the streamflow energy transport (SFE) package.
Definition: gwe-sfe.f90:682
subroutine sfe_setup_budobj(this, idx)
Set up the budget object that stores all the sfe flows.
Definition: gwe-sfe.f90:492
integer(i4b) function sfe_get_nbudterms(this)
Function to return the number of budget terms just for this package.
Definition: gwe-sfe.f90:474
subroutine sfe_outf_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Outflow term.
Definition: gwe-sfe.f90:895
subroutine sfe_iflw_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Inflow Term.
Definition: gwe-sfe.f90:868
character(len=16) text
Definition: gwe-sfe.f90:62
subroutine sfe_rp_obs(this, obsrv, found)
Process package specific obs.
Definition: gwe-sfe.f90:1038
subroutine sfe_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
Copy flow terms into thisbudobj.
Definition: gwe-sfe.f90:592
subroutine sfe_sbcd_term(this, ientry, n1, igwfnode, rrate, rhsval, hcofval)
Streambed conduction term.
Definition: gwe-sfe.f90:922
subroutine sfe_rain_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Rain term.
Definition: gwe-sfe.f90:791
subroutine sfe_get_volumes(this, icv, vnew, vold, delt)
Return the sfr new volume and old volume.
Definition: gwe-sfe.f90:1144
subroutine sfe_evap_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Evaporative term.
Definition: gwe-sfe.f90:815
character(len= *), parameter ftype
Definition: gwe-sfe.f90:60
subroutine sfe_solve(this)
@ brief Add terms specific to sfr to the explicit sfe solve
Definition: gwe-sfe.f90:419
subroutine, public sfe_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath, fmi, eqnsclfac, gwecommon, dvt, dvu, dvua)
Create a new sfe package.
Definition: gwe-sfe.f90:116
subroutine sfe_allocate_arrays(this)
Allocate arrays specific to the streamflow energy transport (SFE) package.
Definition: gwe-sfe.f90:709
subroutine sfe_roff_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Runoff term.
Definition: gwe-sfe.f90:840
subroutine sfe_read_cvs(this)
Source SFE PACKAGEDATA, including thermal conduction fields.
Definition: gwe-sfe.f90:1111
subroutine sfe_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
Add matrix terms related to SFE.
Definition: gwe-sfe.f90:322
subroutine sfe_da(this)
Deallocate memory.
Definition: gwe-sfe.f90:759
subroutine sfe_ad(this)
Advance sfe package routine.
Definition: gwe-sfe.f90:739
subroutine find_sfe_package(this)
Find corresponding sfe package.
Definition: gwe-sfe.f90:178
This module defines variable data types.
Definition: kind.f90:8
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
This module contains the derived types ObserveType and ObsDataType.
Definition: Observe.f90:15
This module contains the SFR package methods.
Definition: gwf-sfr.f90:7
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
integer(i4b) function, public count_errors()
Return number of errors.
Definition: Sim.f90:59
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition: Sim.f90:204
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=maxcharlen) errmsg
error message string
subroutine, public apt_process_obsid(obsrv, dis, inunitobs, iout)
Process observation IDs for an advanced package.
Definition: tsp-apt.f90:2690
subroutine, public apt_process_obsid12(obsrv, dis, inunitobs, iout)
Process observation IDs for a package.
Definition: tsp-apt.f90:2733
@ brief BndType
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
Data for sharing among multiple packages. Originally read in from.