MODFLOW 6  version 6.9.0.dev0
USGS Modular Hydrologic Model
tspspcmodule Module Reference

This module contains the TspSpc Module. More...

Data Types

type  tspspctype
 Derived type for managing SPC input. More...
 

Functions/Subroutines

subroutine initialize (this, dis, id, input_mempath, iout, name_model, packNameFlow, dvn, input_fname)
 Initialize the SPC type. More...
 
subroutine allocate_scalars (this)
 Allocate package scalars. More...
 
subroutine allocate_arrays (this)
 Allocate package arrays. More...
 
real(dp) function get_value (this, ientry, nbound_flow)
 Get the data value from this package. More...
 
subroutine apply_input_values (this)
 Apply current input mempath values to dblvec, then echo them. More...
 
subroutine spc_rp (this, nbound_flowpack, budtxt)
 Read and prepare stress period data. More...
 
subroutine spc_ad (this, nbound_flowpack, budtxt)
 Advance. More...
 
subroutine spc_da (this)
 Deallocate variables. More...
 
subroutine check_flow_package (this, nbound_flowpack, budtxt)
 Check flow package consistency. More...
 

Variables

character(len=lenftype) ftype = 'SPC'
 

Detailed Description

This module contains the code for reading and storing a generic input file of source and sink concentrations or temperatures.

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine tspspcmodule::allocate_arrays ( class(tspspctype this)
Parameters
thisTspSpcType object

Definition at line 163 of file TspSpc.f90.

164  ! -- modules
166  ! -- dummy variables
167  class(TspSpcType) :: this !< TspSpcType object
168  ! -- local
169  integer(I4B) :: i
170  !
171  if (this%readasarrays) then
172  call mem_allocate(this%dblvec, this%maxbound, 'DBLVEC', this%memoryPath)
173  do i = 1, this%maxbound
174  this%dblvec(i) = dzero
175  end do
176  else
177  ! list mode: alias into the loader's permanent, BNDNO-indexed array
178  ! (allocated and DZERO-initialized by the loader)
179  call mem_setptr(this%dblvec, trim(this%depvarname), this%input_mempath)
180  end if

◆ allocate_scalars()

subroutine tspspcmodule::allocate_scalars ( class(tspspctype this)
private
Parameters
thisTspSpcType object

Definition at line 142 of file TspSpc.f90.

143  ! -- modules
145  ! -- dummy variables
146  class(TspSpcType) :: this !< TspSpcType object
147  !
148  call mem_allocate(this%id, 'ID', this%memoryPath)
149  call mem_allocate(this%iout, 'IOUT', this%memoryPath)
150  call mem_allocate(this%maxbound, 'MAXBOUND', this%memoryPath)
151  call mem_allocate(this%iprpak, 'IPRPAK', this%memoryPath)
152  call mem_allocate(this%readasarrays, 'READASARRAYS', this%memoryPath)
153  !
154  this%id = 0
155  this%iout = 0
156  this%maxbound = 0
157  this%iprpak = 0
158  this%readasarrays = .false.

◆ apply_input_values()

subroutine tspspcmodule::apply_input_values ( class(tspspctype), intent(inout)  this)
private

Array mode copies the depvarname array into dblvec. List mode's dblvec is already a permanent, BNDNO-indexed alias into the input context, so there is nothing to copy.

Parameters
[in,out]thisTspSpcType object

Definition at line 225 of file TspSpc.f90.

226  ! -- dummy
227  class(TspSpcType), intent(inout) :: this !< TspSpcType object
228  ! -- local
229  real(DP), dimension(:), pointer, contiguous :: val_arr
230  integer(I4B) :: n
231  ! -- formats
232  character(len=*), parameter :: fmthdr = &
233  &"(1X,/1X,'INPUT VALUES FOR ',A,' PACKAGE (PACKAGE ',A,')')"
234  character(len=*), parameter :: fmtdvhdr = &
235  &"(5X,'NO.',5X,A)"
236  character(len=*), parameter :: fmtdvval = &
237  &"(5X,I6,2X,G12.5)"
238  !
239  if (this%readasarrays) then
240  call mem_setptr(val_arr, trim(this%depvarname), this%input_mempath)
241  do n = 1, this%maxbound
242  this%dblvec(n) = val_arr(n)
243  end do
244  end if
245  if (this%iprpak /= 0) then
246  write (this%iout, fmthdr) trim(this%depvarname), &
247  trim(this%packNameFlow)
248  write (this%iout, fmtdvhdr) trim(this%depvarname)
249  do n = 1, this%maxbound
250  write (this%iout, fmtdvval) n, this%dblvec(n)
251  end do
252  end if

◆ check_flow_package()

subroutine tspspcmodule::check_flow_package ( class(tspspctype), intent(inout)  this,
integer(i4b), intent(in)  nbound_flowpack,
character(len=*), intent(in)  budtxt 
)

Check that MAXBOUND is not less than nbound_flowpack and that readasarrays is consistent with the flow package type.

Parameters
[in,out]thisTspSpcType object

Definition at line 330 of file TspSpc.f90.

331  ! -- dummy
332  class(TspSpcType), intent(inout) :: this !< TspSpcType object
333  integer(I4B), intent(in) :: nbound_flowpack
334  character(len=*), intent(in) :: budtxt
335  !
336  ! -- Check and make sure MAXBOUND is not less than nbound_flowpack
337  if (this%maxbound < nbound_flowpack) then
338  write (errmsg, '(a,a,a,i0,a,i0,a)') &
339  'The SPC Package corresponding to flow package ', &
340  trim(this%packNameFlow), &
341  ' has MAXBOUND set less than the number of boundaries &
342  &active in this package. Found MAXBOUND equal ', &
343  this%maxbound, &
344  ' and number of flow boundaries (NBOUND) equal ', &
345  nbound_flowpack, &
346  '. Increase MAXBOUND in the SPC input file for this package.'
347  call store_error(errmsg)
348  call store_error_filename(this%input_fname)
349  end if
350  !
351  ! -- If budtxt is RCHA or EVTA, then readasarrays must be used, otherwise
352  ! readasarrays cannot be used
353  select case (trim(adjustl(budtxt)))
354  case ('RCHA')
355  if (.not. this%readasarrays) then
356  write (errmsg, '(a,a,a)') &
357  'Array-based recharge must be used with array-based stress package &
358  &concentrations. GWF Package ', trim(this%packNameFlow), ' is being &
359  &used with list-based SPC6 input. Use array-based SPC6 input instead.'
360  call store_error(errmsg)
361  call store_error_filename(this%input_fname)
362  end if
363  case ('EVTA')
364  if (.not. this%readasarrays) then
365  write (errmsg, '(a,a,a)') &
366  'Array-based evapotranspiration must be used with array-based stress &
367  &package concentrations. GWF Package ', trim(this%packNameFlow), &
368  &' is being used with list-based SPC6 input. Use array-based SPC6 &
369  &input instead.'
370  call store_error(errmsg)
371  call store_error_filename(this%input_fname)
372  end if
373  case default
374  if (this%readasarrays) then
375  write (errmsg, '(a,a,a)') &
376  'List-based packages must be used with list-based stress &
377  &package concentrations. GWF Package ', trim(this%packNameFlow), &
378  &' is being used with array-based SPC6 input. Use list-based SPC6 &
379  &input instead.'
380  call store_error(errmsg)
381  call store_error_filename(this%input_fname)
382  end if
383  end select
Here is the call graph for this function:

◆ get_value()

real(dp) function tspspcmodule::get_value ( class(tspspctype this,
integer(i4b), intent(in)  ientry,
integer(i4b), intent(in)  nbound_flow 
)

Get the floating point value from the dblvec array.

Parameters
thisTspSpcType object
[in]ientryindex of the data to return
[in]nbound_flowsize of bound list in flow package

Definition at line 188 of file TspSpc.f90.

189  class(TspSpcType) :: this !< TspSpcType object
190  integer(I4B), intent(in) :: ientry !< index of the data to return
191  integer(I4B), intent(in) :: nbound_flow !< size of bound list in flow package
192  real(DP) :: value
193  integer(I4B) :: nu
194  if (this%readasarrays) then
195  ! -- Special handling for reduced grids and readasarrays.
196  ! -- If flow and transport are in the same simulation, ientry is a user
197  ! -- node number and corresponds to the correct position in dblvec.
198  ! -- If flow and transport are not in the same simulation, ientry is a
199  ! -- reduced node number, because the list of flows in the budget file
200  ! -- does not include idomain < 1 entries. In that case, ientry must be
201  ! -- converted to a user node number so that it corresponds to a user
202  ! -- array, which includes idomain < 1 values.
203  if (nbound_flow == this%maxbound) then
204  ! -- flow and transport are in the same simulation or there
205  ! -- are no idomain < 1 cells.
206  value = this%dblvec(ientry)
207  else
208  ! -- flow and transport are in separate simulations; nbound_flow
209  ! -- would equal ncpl if in the same simulation, but boundary cells
210  ! -- with idomain < 1 are excluded from the binary budget file.
211  nu = this%dis%get_nodeuser(ientry)
212  value = this%dblvec(nu)
213  end if
214  else
215  value = this%dblvec(ientry)
216  end if

◆ initialize()

subroutine tspspcmodule::initialize ( class(tspspctype this,
class(disbasetype), intent(in), pointer  dis,
integer(i4b), intent(in)  id,
character(len=*), intent(in)  input_mempath,
integer(i4b), intent(in)  iout,
character(len=*), intent(in)  name_model,
character(len=*), intent(in)  packNameFlow,
character(len=*), intent(in)  dvn,
character(len=*), intent(in)  input_fname 
)
private

Initialize the SPC object using input context data.

Parameters
thisTspSpcType
[in]disdiscretization package
[in]idid number for this spc package
[in]input_mempathinput memory path
[in]ioutunit number for output
[in]name_modelmodel name
[in]packnameflowname of corresponding flow package
[in]dvndependent variable name (CONCENTRATION or TEMPERATURE)
[in]input_fnameSPC input file name

Definition at line 73 of file TspSpc.f90.

75  ! -- dummy variables
76  class(TspSpcType) :: this !< TspSpcType
77  class(DisBaseType), pointer, intent(in) :: dis !< discretization package
78  integer(I4B), intent(in) :: id !< id number for this spc package
79  character(len=*), intent(in) :: input_mempath !< input memory path
80  integer(I4B), intent(in) :: iout !< unit number for output
81  character(len=*), intent(in) :: name_model !< model name
82  character(len=*), intent(in) :: packNameFlow !< name of corresponding flow package
83  character(len=*), intent(in) :: dvn !< dependent variable name (CONCENTRATION or TEMPERATURE)
84  character(len=*), intent(in) :: input_fname !< SPC input file name
85  ! -- local
86  integer(I4B), pointer :: maxbound_ptr
87  integer(I4B) :: isize
88  logical(LGP) :: found_print_input
89  !
90  write (this%packName, '(a,i0)') 'SPC-', id
91  !
92  call this%allocate_scalars()
93  !
94  this%name_model = name_model
95  this%memoryPath = create_mem_path(this%name_model, this%packName)
96  this%input_mempath = input_mempath
97  this%input_fname = input_fname
98  this%id = id
99  this%iout = iout
100  this%packNameFlow = packnameflow
101  this%depvarname = dvn
102  this%dis => dis
103  !
104  ! -- READASARRAYS determine array or list based input
105  call get_isize('READASARRAYS', input_mempath, isize)
106  this%readasarrays = (isize > 0)
107  !
108  ! -- set maxbound
109  if (this%readasarrays) then
110  this%maxbound = dis%get_ncpl()
111  else
112  call mem_setptr(maxbound_ptr, 'MAXBOUND', input_mempath)
113  this%maxbound = maxbound_ptr
114  end if
115  !
116  call this%allocate_arrays()
117  !
118  ! -- read PRINT_INPUT flag from input context
119  call mem_set_value(this%iprpak, 'PRINT_INPUT', this%input_mempath, &
120  found_print_input)
121  if (found_print_input) then
122  write (this%iout, '(4x,a)') 'TIME-VARYING INPUT WILL BE PRINTED.'
123  end if
124  !
125  ! -- check for idm managed active timeseries
126  call get_isize('TS6_FILENAME', input_mempath, isize)
127  if (isize > 0) this%ts_active = .true.
128  call get_isize('TAS6_FILENAME', input_mempath, isize)
129  if (isize > 0) this%ts_active = .true.
130  !
131  write (this%iout, '(4x,a,a,a,a,a)') 'USING SPC INPUT FILE ', &
132  trim(input_fname), ' TO SET ', trim(dvn), &
133  'S FOR PACKAGE '//trim(packnameflow)
134  !
135  if (count_errors() > 0) then
136  call store_error_filename(this%input_fname)
137  end if
Here is the call graph for this function:

◆ spc_ad()

subroutine tspspcmodule::spc_ad ( class(tspspctype), intent(inout)  this,
integer(i4b), intent(in)  nbound_flowpack,
character(len=*), intent(in)  budtxt 
)
private

Apply advanced input values at each time step.

Parameters
[in,out]thisTspSpcType object

Definition at line 290 of file TspSpc.f90.

291  ! -- dummy
292  class(TspSpcType), intent(inout) :: this !< TspSpcType object
293  integer(I4B), intent(in) :: nbound_flowpack
294  character(len=*), intent(in) :: budtxt
295  !
296  ! -- no-op if timeseries inactive
297  if (.not. this%ts_active) return
298  !
299  call this%apply_input_values()
300  call this%check_flow_package(nbound_flowpack, budtxt)

◆ spc_da()

subroutine tspspcmodule::spc_da ( class(tspspctype this)
private
Parameters
thisTspSpcType object

Definition at line 305 of file TspSpc.f90.

306  ! -- modules
308  ! -- dummy variables
309  class(TspSpcType) :: this !< TspSpcType object
310  !
311  nullify (this%dis)
312  if (this%readasarrays) then
313  call mem_deallocate(this%dblvec)
314  else
315  nullify (this%dblvec) ! input-context-owned alias, not package-allocated
316  end if
317  call mem_deallocate(this%id)
318  call mem_deallocate(this%iout)
319  call mem_deallocate(this%maxbound)
320  call mem_deallocate(this%iprpak)
321  call mem_deallocate(this%readasarrays)

◆ spc_rp()

subroutine tspspcmodule::spc_rp ( class(tspspctype), intent(inout)  this,
integer(i4b), intent(in)  nbound_flowpack,
character(len=*), intent(in)  budtxt 
)
private

Copies input period data into dblvec when new data has been loaded for this stress period.

Parameters
[in,out]thisTspSpcType object

Definition at line 261 of file TspSpc.f90.

262  ! -- dummy
263  class(TspSpcType), intent(inout) :: this !< TspSpcType object
264  integer(I4B), intent(in) :: nbound_flowpack
265  character(len=*), intent(in) :: budtxt
266  ! -- local
267  integer(I4B), pointer :: iper
268  ! -- formats
269  character(len=*), parameter :: fmtlsp = &
270  &"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
271  !
272  call mem_setptr(iper, 'IPER', this%input_mempath)
273  if (iper /= kper) then
274  write (this%iout, fmtlsp) trim(ftype)
275  return
276  end if
277  !
278  ! -- spc_ad applies each time step
279  if (this%ts_active) return
280  !
281  call this%apply_input_values()
282  call this%check_flow_package(nbound_flowpack, budtxt)

Variable Documentation

◆ ftype

character(len=lenftype) tspspcmodule::ftype = 'SPC'
private

Definition at line 26 of file TspSpc.f90.

26  character(len=LENFTYPE) :: ftype = 'SPC'