20 character(len=12),
dimension(4) ::
mvrtypes = &
21 &[character(len=12) ::
'FACTOR',
'EXCESS',
'THRESHOLD',
'UPTO']
30 character(len=LENMEMPATH) :: mem_path_src =
''
31 character(len=LENMEMPATH) :: mem_path_tgt =
''
32 integer(I4B),
pointer :: irchnrsrc => null()
33 integer(I4B) :: irchnrsrcmapped
34 integer(I4B),
pointer :: irchnrtgt => null()
35 integer(I4B),
pointer :: imvrtype => null()
36 real(dp),
pointer ::
value => null()
37 logical(LGP) :: is_provider_active = .true.
38 logical(LGP) :: is_receiver_active = .true.
41 real(dp),
pointer :: qtformvr_ptr => null()
42 real(dp),
pointer :: qformvr_ptr => null()
43 real(dp),
pointer :: qtomvr_ptr => null()
44 real(dp),
pointer :: qfrommvr_ptr => null()
63 subroutine set_values(this, mname1, pname1, id1, mname2, pname2, &
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
80 this%imvrtype => imvrtype
84 this%iRchNrSrcMapped = -1
94 subroutine prepare(this, inunit, pckMemPaths, pakmovers)
99 integer(I4B),
intent(in) :: inunit
100 character(len=LENMEMPATH), &
101 dimension(:),
pointer,
contiguous :: pckMemPaths
104 real(DP),
dimension(:),
pointer,
contiguous :: temp_ptr => null()
107 integer(I4B) :: ipakloc1, ipakloc2
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))
121 do i = 1,
size(pckmempaths)
122 if (this%mem_path_src == pckmempaths(i))
then
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.')
134 do i = 1,
size(pckmempaths)
135 if (this%mem_path_tgt == pckmempaths(i))
then
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.')
149 if (this%is_provider_active)
then
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)
160 this%qtomvr_ptr => temp_ptr(this%iRchNrSrc)
163 temp_ptr => pakmovers(ipakloc1)%qformvr
164 this%qformvr_ptr => temp_ptr(this%iRchNrSrc)
167 temp_ptr => pakmovers(ipakloc1)%qtformvr
168 this%qtformvr_ptr => temp_ptr(this%iRchNrSrc)
171 if (this%is_receiver_active)
then
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)
182 this%qfrommvr_ptr => temp_ptr(this%iRchNrTgt)
195 integer(I4B),
intent(in) :: iout
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
228 real(DP) :: qavailable, qtanew, qpactual
231 qavailable = this%qformvr_ptr
232 qtanew = this%qtformvr_ptr
233 this%qavailable = qavailable
237 qpactual = this%qrcalc(qavailable, qtanew)
240 this%qpactual = qpactual
244 this%qtomvr_ptr = this%qtomvr_ptr + qpactual
248 this%qformvr_ptr = this%qformvr_ptr - qpactual
260 this%qfrommvr_ptr = this%qfrommvr_ptr + this%qpactual
268 function qrcalc(this, qa, qta)
result(qr)
274 real(dp),
intent(in) :: qa
275 real(dp),
intent(in) :: qta
281 select case (this%imvrtype)
285 if (qta >
dzero) qr = qta * this%value
289 if (qa > this%value)
then
296 if (this%value > qa)
then
303 if (qa > this%value)
then
320 integer(I4B),
intent(in) :: iout
322 character(len=*),
parameter :: fmt = &
323 "(1x, a, ' ID ', i0, ' AVAILABLE ', 1(1pg15.6), &
324 &' PROVIDED ', 1(1pg15.6), ' TO ', a, ' ID ', i0)"
326 write (iout, fmt) trim(this%mem_path_src), this%iRchNrSrc, this%qavailable, &
327 this%qpactual, trim(this%mem_path_tgt), this%iRchNrTgt
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenmodelname
maximum length of the model name
integer(i4b), parameter lenauxname
maximum length of a aux variable
integer(i4b), parameter lenboundname
maximum length of a bound name
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
integer(i4b), parameter lenmempath
maximum length of the memory path
real(dp), parameter done
real constant 1
This module defines variable data types.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains the MvrModule Module.
subroutine prepare(this, inunit, pckMemPaths, pakmovers)
@ brief Prepare object
subroutine echo(this, iout)
@ brief Echo data to list file
character(len=12), dimension(4) mvrtypes
subroutine update_receiver(this)
@ brief Formulate coefficients
real(dp) function qrcalc(this, qa, qta)
@ brief Flow to receiver
subroutine set_values(this, mname1, pname1, id1, mname2, pname2, id2, imvrtype, value)
@ brief Set values from input data
subroutine writeflow(this, iout)
@ brief Write flow
subroutine update_provider(this)
@ brief Formulate coefficients
subroutine advance(this)
@ brief Advance
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_unit(iunit, terminate)
Store the file unit number.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
Derived type for MvrType.