18 character(len=LENPACKAGENAME) ::
text =
' PRTFMI'
28 integer(I4B),
public :: max_faces
29 real(dp),
allocatable,
public :: sourceflows(:)
30 real(dp),
allocatable,
public :: sinkflows(:)
31 real(dp),
allocatable,
public :: storageflows(:)
32 real(dp),
allocatable,
public :: boundaryflows(:, :)
33 integer(I4B),
allocatable,
public :: boundaryfaces(:)
50 subroutine fmi_cr(fmiobj, name_model, input_mempath, inunit, iout)
53 character(len=*),
intent(in) :: name_model
54 character(len=*),
intent(in) :: input_mempath
55 integer(I4B),
intent(inout) :: inunit
56 integer(I4B),
intent(in) :: iout
62 call fmiobj%set_names(1, name_model,
'FMI',
'FMI', input_mempath)
66 call fmiobj%allocate_scalars()
69 fmiobj%inunit = inunit
73 fmiobj%depvartype =
'TRACKS '
85 character(len=15) :: nodestr
86 character(len=*),
parameter :: fmtdry = &
87 &
"(/1X,'WARNING: DRY CELL ENCOUNTERED AT ',a,'; RESET AS INACTIVE')"
88 character(len=*),
parameter :: fmtrewet = &
89 &
"(/1X,'DRY CELL REACTIVATED AT ', a)"
94 this%iflowsupdated = 1
97 if (this%iubud /= 0)
call this%advance_bfr()
100 if (this%iuhds /= 0)
call this%advance_hfr()
103 if (this%iumvr /= 0) &
104 call this%mvrbudobj%bfr_advance(this%dis, this%iout)
107 call this%accumulate_flows()
110 do n = 1, this%dis%nodes
113 if (this%gwfsat(n) > dzero)
then
114 this%ibdgwfsat0(n) = 1
116 this%ibdgwfsat0(n) = 0
120 if (this%ibound(n) > 0)
then
121 if (this%gwfhead(n) ==
dhdry)
then
124 call this%dis%noder_to_string(n, nodestr)
125 write (this%iout, fmtdry) trim(nodestr)
130 if (this%ibound(n) == 0)
then
131 if (this%gwfhead(n) /=
dhdry)
then
134 call this%dis%noder_to_string(n, nodestr)
135 write (this%iout, fmtrewet) trim(nodestr)
146 integer(I4B),
intent(in) :: idryinactive
148 call this%FlowModelInterfaceType%fmi_df(dis, idryinactive)
150 this%max_faces = this%dis%get_max_npolyverts() + 2
151 allocate (this%StorageFlows(this%dis%nodes))
152 allocate (this%SourceFlows(this%dis%nodes))
153 allocate (this%SinkFlows(this%dis%nodes))
154 allocate (this%BoundaryFlows(this%dis%nodes, this%max_faces))
155 allocate (this%BoundaryFaces(this%dis%nodes))
164 integer(I4B) :: j, i, ip, ib
165 integer(I4B) :: iflowface, iauxiflowface, icellface
167 character(len=LENAUXNAME) :: auxname
170 this%StorageFlows =
dzero
171 if (this%igwfstrgss /= 0) &
172 this%StorageFlows = this%StorageFlows + this%gwfstrgss
173 if (this%igwfstrgsy /= 0) &
174 this%StorageFlows = this%StorageFlows + this%gwfstrgsy
176 this%SourceFlows =
dzero
177 this%SinkFlows =
dzero
178 this%BoundaryFlows =
dzero
179 this%BoundaryFaces = 0
180 do ip = 1, this%nflowpack
182 naux = this%gwfpackages(ip)%naux
185 auxname = this%gwfpackages(ip)%auxname(j)
186 if (trim(adjustl(auxname)) ==
"IFLOWFACE")
then
192 do ib = 1, this%gwfpackages(ip)%nbound
193 i = this%gwfpackages(ip)%nodelist(ib)
195 if (this%ibound(i) <= 0) cycle
196 qbnd = this%gwfpackages(ip)%get_flow(ib)
200 if (iauxiflowface > 0)
then
201 iflowface = nint(this%gwfpackages(ip)%auxvar(iauxiflowface, ib))
202 icellface = this%iflowface_to_icellface(iflowface)
204 if (icellface > 0)
then
205 call this%mark_boundary_face(i, icellface)
206 this%BoundaryFlows(i, icellface) = &
207 this%BoundaryFlows(i, icellface) + qbnd
208 else if (qbnd .gt.
dzero)
then
209 this%SourceFlows(i) = this%SourceFlows(i) + qbnd
210 else if (qbnd .lt.
dzero)
then
211 this%SinkFlows(i) = this%SinkFlows(i) + qbnd
221 integer(I4B),
intent(in) :: ic
222 integer(I4B),
intent(in) :: icellface
224 integer(I4B) :: bit_pos
226 if (ic <= 0 .or. ic > this%dis%nodes)
then
227 print *,
'Invalid cell number: ', ic
228 print *,
'Expected a value in range [1, ', this%dis%nodes,
']'
231 if (icellface <= 0)
then
232 print *,
'Invalid face number: ', icellface
233 print *,
'Expected a value in range [1, ', this%max_faces,
']'
236 bit_pos = icellface - 1
237 if (bit_pos < 0 .or. bit_pos > 31)
then
238 print *,
'Invalid bitmask position: ', bit_pos
239 print *,
'Expected a value in range [0, 31]'
242 this%BoundaryFaces(ic) = ibset(this%BoundaryFaces(ic), bit_pos)
248 integer(I4B),
intent(in) :: ic
249 integer(I4B),
intent(in) :: icellface
250 logical(LGP) :: is_boundary
252 integer(I4B) :: bit_pos
254 is_boundary = .false.
255 if (ic <= 0 .or. ic > this%dis%nodes)
then
256 print *,
'Invalid cell number: ', ic
257 print *,
'Expected a value in range [1, ', this%dis%nodes,
']'
260 if (icellface <= 0)
then
261 print *,
'Invalid face number: ', icellface
262 print *,
'Expected a value in range [1, ', this%max_faces,
']'
265 bit_pos = icellface - 1
266 if (bit_pos < 0 .or. bit_pos > 31)
then
267 print *,
'Invalid bitmask position: ', bit_pos
268 print *,
'Expected a value in range [0, 31]'
271 is_boundary = btest(this%BoundaryFaces(ic), bit_pos)
276 result(is_net_out_boundary)
278 integer(I4B),
intent(in) :: ic
279 integer(I4B),
intent(in) :: icellface
280 logical(LGP) :: is_net_out_boundary
282 is_net_out_boundary = .false.
283 if (.not. this%is_boundary_face(ic, icellface))
return
284 if (this%BoundaryFlows(ic, icellface) <
dzero) &
285 is_net_out_boundary = .true.
292 integer(I4B),
intent(in) :: iflowface
293 integer(I4B) :: icellface
295 icellface = iflowface
296 if (icellface < 0) icellface = icellface + this%max_faces -
iflowface_top
This module contains simulation constants.
real(dp), parameter dhdry
real dry cell constant
integer(i4b), parameter lenpackagename
maximum length of the package name
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenauxname
maximum length of a aux variable
real(dp), parameter dzero
real constant zero
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
This module defines variable data types.
subroutine accumulate_flows(this)
Accumulate flows.
subroutine mark_boundary_face(this, ic, icellface)
Mark a face as a boundary face.
integer(i4b) function iflowface_to_icellface(this, iflowface)
Convert an iflowface number to a cell face number. Maps bottom (-2) -> max_faces - 1,...
subroutine fmi_ad(this)
Time step advance.
subroutine prtfmi_df(this, dis, idryinactive)
Define the flow model interface.
logical(lgp) function is_boundary_face(this, ic, icellface)
Check if a face is assigned to a boundary package.
@, public iflowface_bottom
character(len=lenpackagename) text
subroutine, public fmi_cr(fmiobj, name_model, input_mempath, inunit, iout)
Create a new PrtFmi object.
logical(lgp) function is_net_out_boundary_face(this, ic, icellface)
Check if a face is an assigned boundary with net outflow.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string