MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
mvrmodule Module Reference

This module contains the MvrModule Module. More...

Data Types

type  mvrtype
 Derived type for MvrType. More...
 

Functions/Subroutines

subroutine set_values (this, mname1, pname1, id1, mname2, pname2, id2, imvrtype, value)
 @ brief Set values from input data More...
 
subroutine prepare (this, inunit, pckMemPaths, pakmovers)
 @ brief Prepare object More...
 
subroutine echo (this, iout)
 @ brief Echo data to list file More...
 
subroutine advance (this)
 @ brief Advance More...
 
subroutine update_provider (this)
 @ brief Formulate coefficients More...
 
subroutine update_receiver (this)
 @ brief Formulate coefficients More...
 
real(dp) function qrcalc (this, qa, qta)
 @ brief Flow to receiver More...
 
subroutine writeflow (this, iout)
 @ brief Write flow More...
 

Variables

character(len=12), dimension(4) mvrtypes = [character(len=12) :: 'FACTOR', 'EXCESS', 'THRESHOLD', 'UPTO']
 

Detailed Description

This module contains the code for the low-level MvrType object.

Function/Subroutine Documentation

◆ advance()

subroutine mvrmodule::advance ( class(mvrtype this)
private

Advance mover object. Does nothing now.

Definition at line 211 of file Mover.f90.

212  ! -- modules
213  ! -- dummy
214  class(MvrType) :: this
215  ! -- local

◆ echo()

subroutine mvrmodule::echo ( class(mvrtype this,
integer(i4b), intent(in)  iout 
)

Write mover values to output file.

Parameters
thisMvrType
[in]ioutunit number for output file

Definition at line 191 of file Mover.f90.

192  ! -- modules
193  ! -- dummy
194  class(MvrType) :: this !< MvrType
195  integer(I4B), intent(in) :: iout !< unit number for output file
196  ! -- local
197  !
198  write (iout, '(4x, a, a, a, i0)') 'FROM PACKAGE: ', trim(this%mem_path_src), &
199  ' FROM ID: ', this%iRchNrSrc
200  write (iout, '(4x, a, a, a, i0)') 'TO PACKAGE: ', trim(this%mem_path_tgt), &
201  ' TO ID: ', this%iRchNrTgt
202  write (iout, '(4x, a, a, a, 1pg15.6,/)') 'MOVER TYPE: ', &
203  trim(mvrtypes(this%imvrtype)), ' ', this%value

◆ prepare()

subroutine mvrmodule::prepare ( class(mvrtype this,
integer(i4b), intent(in)  inunit,
character(len=lenmempath), dimension(:), pointer, contiguous  pckMemPaths,
type(packagemovertype), dimension(:), pointer, contiguous  pakmovers 
)

Set values and pointers for mover object. pckMemPaths is an array of strings which are the memory paths for those packages. They are composed of model names and package names. The mover entries must be in pckMemPaths, or this routine will terminate with an error.

Parameters
thisMvrType object
[in]inunitinput file unit number
pckmempathsarray of strings
pakmoversArray of package mover objects

Definition at line 94 of file Mover.f90.

95  ! -- modules
97  ! -- dummy
98  class(MvrType) :: this !< MvrType object
99  integer(I4B), intent(in) :: inunit !< input file unit number
100  character(len=LENMEMPATH), &
101  dimension(:), pointer, contiguous :: pckMemPaths !< array of strings
102  type(PackageMoverType), dimension(:), pointer, contiguous :: pakmovers !< Array of package mover objects
103  ! -- local
104  real(DP), dimension(:), pointer, contiguous :: temp_ptr => null()
105  logical :: found
106  integer(I4B) :: i
107  integer(I4B) :: ipakloc1, ipakloc2
108  !
109  ! -- Check to make sure provider and receiver are not the same
110  if (this%mem_path_src == this%mem_path_tgt .and. &
111  this%iRchNrSrc == this%iRchNrTgt) then
112  call store_error('Provider and receiver are the same: '// &
113  trim(this%mem_path_src)//' : '//trim(this%mem_path_tgt))
114  call store_error_unit(inunit)
115  end if
116  !
117  ! -- Check to make sure pname1 and pname2 are both listed in pckMemPaths
118  ! pname1 is the provider package; pname2 is the receiver package
119  found = .false.
120  ipakloc1 = 0
121  do i = 1, size(pckmempaths)
122  if (this%mem_path_src == pckmempaths(i)) then
123  found = .true.
124  ipakloc1 = i
125  exit
126  end if
127  end do
128  if (.not. found) then
129  call store_error('Mover capability not activated in '//this%mem_path_src)
130  call store_error('Add "MOVER" keyword to package options block.')
131  end if
132  found = .false.
133  ipakloc2 = 0
134  do i = 1, size(pckmempaths)
135  if (this%mem_path_tgt == pckmempaths(i)) then
136  found = .true.
137  ipakloc2 = i
138  exit
139  end if
140  end do
141  if (.not. found) then
142  call store_error('Mover capability not activated in '//this%mem_path_tgt)
143  call store_error('Add "MOVER" keyword to package options block.')
144  end if
145  if (count_errors() > 0) then
146  call store_error_unit(inunit)
147  end if
148 
149  if (this%is_provider_active) then
150  !
151  ! -- Set pointer to QTOMVR array in the provider boundary package
152  temp_ptr => pakmovers(ipakloc1)%qtomvr
153  if (this%iRchNrSrc < 1 .or. this%iRchNrSrc > size(temp_ptr)) then
154  call store_error('Provider ID < 1 or greater than package size ')
155  write (errmsg, '(a,i0,a,i0)') 'Provider ID = ', this%iRchNrSrc, &
156  '; Package size = ', size(temp_ptr)
157  call store_error(trim(errmsg))
158  call store_error_unit(inunit)
159  end if
160  this%qtomvr_ptr => temp_ptr(this%iRchNrSrc)
161  !
162  ! -- Set pointer to QFORMVR array in the provider boundary package
163  temp_ptr => pakmovers(ipakloc1)%qformvr
164  this%qformvr_ptr => temp_ptr(this%iRchNrSrc)
165  !
166  ! -- Set pointer to QTFORMVR array in the provider boundary package
167  temp_ptr => pakmovers(ipakloc1)%qtformvr
168  this%qtformvr_ptr => temp_ptr(this%iRchNrSrc)
169  end if
170 
171  if (this%is_receiver_active) then
172  !
173  ! -- Set pointer to QFROMMVR array in the receiver boundary package
174  temp_ptr => pakmovers(ipakloc2)%qfrommvr
175  if (this%iRchNrTgt < 1 .or. this%iRchNrTgt > size(temp_ptr)) then
176  call store_error('Receiver ID < 1 or greater than package size ')
177  write (errmsg, '(a,i0,a,i0)') 'Receiver ID = ', this%iRchNrTgt, &
178  '; package size = ', size(temp_ptr)
179  call store_error(trim(errmsg))
180  call store_error_unit(inunit)
181  end if
182  this%qfrommvr_ptr => temp_ptr(this%iRchNrTgt)
183  end if
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_unit(iunit, terminate)
Store the file unit number.
Definition: Sim.f90:168
Here is the call graph for this function:

◆ qrcalc()

real(dp) function mvrmodule::qrcalc ( class(mvrtype this,
real(dp), intent(in)  qa,
real(dp), intent(in)  qta 
)
private

Calculate the rate of water provided to receiver.

Parameters
thisMvrType
[in]qaactual flow
[in]qtatotal available flow

Definition at line 268 of file Mover.f90.

269  ! -- modules
270  ! -- return
271  real(DP) :: qr
272  ! -- dummy
273  class(MvrType) :: this !< MvrType
274  real(DP), intent(in) :: qa !< actual flow
275  real(DP), intent(in) :: qta !< total available flow
276  ! -- local
277  ! -- Using the mover rules, calculate how much of the available water will
278  ! go to the receiver.
279  qr = dzero
280  ! -- Calculate qr
281  select case (this%imvrtype)
282  case (1)
283  ! -- FACTOR uses total available to make calculation, and then
284  ! limits qr by consumed available
285  if (qta > dzero) qr = qta * this%value
286  qr = min(qr, qa)
287  case (2)
288  ! -- EXCESS
289  if (qa > this%value) then
290  qr = qa - this%value
291  else
292  qr = dzero
293  end if
294  case (3)
295  ! -- THRESHOLD
296  if (this%value > qa) then
297  qr = dzero
298  else
299  qr = this%value
300  end if
301  case (4)
302  ! -- UPTO
303  if (qa > this%value) then
304  qr = this%value
305  else
306  qr = qa
307  end if
308  end select

◆ set_values()

subroutine mvrmodule::set_values ( class(mvrtype this,
character(len=*), intent(in)  mname1,
character(len=*), intent(in)  pname1,
integer(i4b), intent(in), target  id1,
character(len=*), intent(in)  mname2,
character(len=*), intent(in)  pname2,
integer(i4b), intent(in), target  id2,
integer(i4b), intent(in), target  imvrtype,
real(dp), intent(in), target  value 
)
private

Set values and pointers for mover object.

Definition at line 63 of file Mover.f90.

66  class(MvrType) :: this
67  character(len=*), intent(in) :: mname1
68  character(len=*), intent(in) :: pname1
69  integer(I4B), intent(in), target :: id1
70  character(len=*), intent(in) :: mname2
71  character(len=*), intent(in) :: pname2
72  integer(I4B), intent(in), target :: id2
73  integer(I4B), intent(in), target :: imvrtype
74  real(DP), intent(in), target :: value
75 
76  this%mem_path_src = create_mem_path(mname1, pname1)
77  this%iRchNrSrc => id1
78  this%mem_path_tgt = create_mem_path(mname2, pname2)
79  this%iRchNrTgt => id2
80  this%imvrtype => imvrtype
81  this%value => value
82 
83  ! to be set later
84  this%iRchNrSrcMapped = -1
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
Here is the call graph for this function:

◆ update_provider()

subroutine mvrmodule::update_provider ( class(mvrtype this)
private

Make mover calculations for provider.

Parameters
thisMvrType

Definition at line 223 of file Mover.f90.

224  ! -- modules
225  ! -- dummy
226  class(MvrType) :: this !< MvrType
227  ! -- local
228  real(DP) :: qavailable, qtanew, qpactual
229  !
230  ! -- Set qa and this%qavailable equal to available water in package (qtomvr)
231  qavailable = this%qformvr_ptr
232  qtanew = this%qtformvr_ptr
233  this%qavailable = qavailable
234  !
235  ! -- Using the mover rules, calculate how much of the available water will
236  ! be provided from the mover to the receiver.
237  qpactual = this%qrcalc(qavailable, qtanew)
238  !
239  ! -- Store qpactual
240  this%qpactual = qpactual
241  !
242  ! -- Add the calculated qpactual term directly into the provider package
243  ! qtomvr array.
244  this%qtomvr_ptr = this%qtomvr_ptr + qpactual
245  !
246  ! -- Reduce the amount of water that is available in the provider package
247  ! qformvr array.
248  this%qformvr_ptr = this%qformvr_ptr - qpactual

◆ update_receiver()

subroutine mvrmodule::update_receiver ( class(mvrtype this)
private

Make mover calculations for receiver.

Parameters
thisMvrType

Definition at line 256 of file Mover.f90.

257  class(MvrType) :: this !< MvrType
258  ! -- Add the calculated qpactual term directly into the receiver package
259  ! qfrommvr array.
260  this%qfrommvr_ptr = this%qfrommvr_ptr + this%qpactual

◆ writeflow()

subroutine mvrmodule::writeflow ( class(mvrtype this,
integer(i4b), intent(in)  iout 
)
private

Write a line of output for this mover object.

Parameters
thisMvrType
[in]ioutoutput file unit number

Definition at line 316 of file Mover.f90.

317  ! -- modules
318  ! -- dummy
319  class(MvrType) :: this !< MvrType
320  integer(I4B), intent(in) :: iout !< output file unit number
321  ! -- local
322  character(len=*), parameter :: fmt = &
323  "(1x, a, ' ID ', i0, ' AVAILABLE ', 1(1pg15.6), &
324  &' PROVIDED ', 1(1pg15.6), ' TO ', a, ' ID ', i0)"
325  !
326  write (iout, fmt) trim(this%mem_path_src), this%iRchNrSrc, this%qavailable, &
327  this%qpactual, trim(this%mem_path_tgt), this%iRchNrTgt

Variable Documentation

◆ mvrtypes

character(len=12), dimension(4) mvrmodule::mvrtypes = [character(len=12) :: 'FACTOR', 'EXCESS', 'THRESHOLD', 'UPTO']
private

Definition at line 20 of file Mover.f90.

20  character(len=12), dimension(4) :: mvrtypes = &
21  &[character(len=12) :: 'FACTOR', 'EXCESS', 'THRESHOLD', 'UPTO']