MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
prtfmimodule Module Reference

Data Types

type  prtfmitype

Enumerations

enum  { iflowface_top = -1 , iflowface_bottom = -2 }
 IFLOWFACE numbers for top and bottom faces. More...

Functions/Subroutines

subroutine, public fmi_cr (fmiobj, name_model, input_mempath, inunit, iout)
 Create a new PrtFmi object.
subroutine fmi_ad (this)
 Time step advance.
subroutine prtfmi_df (this, dis, idryinactive)
 Define the flow model interface.
subroutine prtfmi_allocate_scalars (this)
 Allocate scalars.
subroutine prtfmi_allocate_arrays (this, nodes)
 Allocate arrays.
subroutine prtfmi_da (this)
 Deallocate memory.
subroutine accumulate_flows (this)
 Accumulate flows.
subroutine mark_boundary_face (this, ic, icellface)
 Mark a face as a boundary face.
logical(lgp) function is_boundary_face (this, ic, icellface)
 Check if a face is assigned to a boundary package.
logical(lgp) function is_net_out_boundary_face (this, ic, icellface)
 Check if a face is an assigned boundary with net outflow.
integer(i4b) function iflowface_to_icellface (this, iflowface)
 Convert an iflowface number to a cell face number. Maps bottom (-2) -> max_faces - 1, top (-1) -> max_faces.

Variables

character(len=lenpackagename) text = ' PRTFMI'

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
iflowface_top 
iflowface_bottom 

Definition at line 22 of file prt-fmi.f90.

Function/Subroutine Documentation

◆ accumulate_flows()

subroutine prtfmimodule::accumulate_flows ( class(prtfmitype) this)
private

Definition at line 219 of file prt-fmi.f90.

220 ! dummy
221 class(PrtFmiType) :: this
222 ! local
223 integer(I4B) :: j, i, ip, ib
224 integer(I4B) :: iflowface, iauxiflowface, icellface
225 real(DP) :: qbnd
226 character(len=LENAUXNAME) :: auxname
227 integer(I4B) :: naux
228
229 this%StorageFlows = dzero
230 if (this%igwfstrgss /= 0) &
231 this%StorageFlows = this%StorageFlows + this%gwfstrgss
232 if (this%igwfstrgsy /= 0) &
233 this%StorageFlows = this%StorageFlows + this%gwfstrgsy
234
235 this%SourceFlows = dzero
236 this%SinkFlows = dzero
237 this%BoundaryFlows = dzero
238 this%BoundaryFaces = 0
239 do ip = 1, this%nflowpack
240 iauxiflowface = 0
241 naux = this%gwfpackages(ip)%naux
242 if (naux > 0) then
243 do j = 1, naux
244 auxname = this%gwfpackages(ip)%auxname(j)
245 if (trim(adjustl(auxname)) == "IFLOWFACE") then
246 iauxiflowface = j
247 exit
248 end if
249 end do
250 end if
251 do ib = 1, this%gwfpackages(ip)%nbound
252 i = this%gwfpackages(ip)%nodelist(ib)
253 if (i <= 0) cycle
254 if (this%ibound(i) <= 0) cycle
255 qbnd = this%gwfpackages(ip)%get_flow(ib)
256 ! todo, after initial release: default iflowface values for different packages
257 iflowface = 0
258 icellface = 0
259 if (iauxiflowface > 0) then
260 iflowface = nint(this%gwfpackages(ip)%auxvar(iauxiflowface, ib))
261 icellface = this%iflowface_to_icellface(iflowface)
262 end if
263 if (icellface > 0) then
264 call this%mark_boundary_face(i, icellface)
265 this%BoundaryFlows(i, icellface) = &
266 this%BoundaryFlows(i, icellface) + qbnd
267 else if (qbnd .gt. dzero) then
268 this%SourceFlows(i) = this%SourceFlows(i) + qbnd
269 else if (qbnd .lt. dzero) then
270 this%SinkFlows(i) = this%SinkFlows(i) + qbnd
271 end if
272 end do
273 end do
274

◆ fmi_ad()

subroutine prtfmimodule::fmi_ad ( class(prtfmitype) this)
private

Definition at line 87 of file prt-fmi.f90.

88 ! modules
89 use constantsmodule, only: dhdry
90 ! dummy
91 class(PrtFmiType) :: this
92 ! local
93 integer(I4B) :: n
94 character(len=15) :: nodestr
95 character(len=*), parameter :: fmtdry = &
96 &"(/1X,'WARNING: DRY CELL ENCOUNTERED AT ',a,'; RESET AS INACTIVE')"
97 character(len=*), parameter :: fmtrewet = &
98 &"(/1X,'DRY CELL REACTIVATED AT ', a)"
99
100 ! Set flag to indicated that flows are being updated. For the case where
101 ! flows may be reused (only when flows are read from a file) then set
102 ! the flag to zero to indicated that flows were not updated
103 this%iflowsupdated = 1
104
105 ! If reading flows from a budget file, read the next set of records
106 if (this%iubud /= 0) call this%advance_bfr()
107
108 ! If reading heads from a head file, read the next set of records
109 if (this%iuhds /= 0) call this%advance_hfr()
110
111 ! If mover flows are being read from file, read the next set of records
112 if (this%iumvr /= 0) &
113 call this%mvrbudobj%bfr_advance(this%dis, this%iout)
114
115 ! Accumulate flows
116 call this%accumulate_flows()
117
118 ! if flow cell is dry, then set this%ibound = 0
119 do n = 1, this%dis%nodes
120 ! Calculate the ibound-like array that has 0 if saturation
121 ! is zero and 1 otherwise
122 if (this%gwfsat(n) > dzero) then
123 this%ibdgwfsat0(n) = 1
124 else
125 this%ibdgwfsat0(n) = 0
126 end if
127
128 ! Check if active model cell is inactive for flow
129 if (this%ibound(n) > 0) then
130 if (this%gwfhead(n) == dhdry) then
131 ! cell should be made inactive
132 this%ibound(n) = 0
133 call this%dis%noder_to_string(n, nodestr)
134 write (this%iout, fmtdry) trim(nodestr)
135 end if
136 end if
137
138 ! Convert dry model cell to active if flow has rewet
139 if (this%ibound(n) == 0) then
140 if (this%gwfhead(n) /= dhdry) then
141 ! cell is now wet
142 this%ibound(n) = 1
143 call this%dis%noder_to_string(n, nodestr)
144 write (this%iout, fmtrewet) trim(nodestr)
145 end if
146 end if
147 end do
148
This module contains simulation constants.
Definition Constants.f90:9
real(dp), parameter dhdry
real dry cell constant
Definition Constants.f90:94
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65

◆ fmi_cr()

subroutine, public prtfmimodule::fmi_cr ( type(prtfmitype), pointer fmiobj,
character(len=*), intent(in) name_model,
character(len=*), intent(in) input_mempath,
integer(i4b), intent(inout) inunit,
integer(i4b), intent(in) iout )

Definition at line 59 of file prt-fmi.f90.

60 ! dummy
61 type(PrtFmiType), pointer :: fmiobj
62 character(len=*), intent(in) :: name_model
63 character(len=*), intent(in) :: input_mempath
64 integer(I4B), intent(inout) :: inunit
65 integer(I4B), intent(in) :: iout
66
67 ! Create the object
68 allocate (fmiobj)
69
70 ! create name and memory path
71 call fmiobj%set_names(1, name_model, 'FMI', 'FMI', input_mempath)
72 fmiobj%text = text
73
74 ! Allocate scalars
75 call fmiobj%allocate_scalars()
76
77 ! Set variables
78 fmiobj%inunit = inunit
79 fmiobj%iout = iout
80
81 ! Assign dependent variable label
82 fmiobj%depvartype = 'TRACKS '
83
Here is the caller graph for this function:

◆ iflowface_to_icellface()

integer(i4b) function prtfmimodule::iflowface_to_icellface ( class(prtfmitype), intent(inout) this,
integer(i4b), intent(in) iflowface )
private

Definition at line 349 of file prt-fmi.f90.

350 class(PrtFmiType), intent(inout) :: this
351 integer(I4B), intent(in) :: iflowface
352 integer(I4B) :: icellface
353
354 icellface = iflowface
355 if (icellface < 0) icellface = icellface + this%max_faces - iflowface_top

◆ is_boundary_face()

logical(lgp) function prtfmimodule::is_boundary_face ( class(prtfmitype) this,
integer(i4b), intent(in) ic,
integer(i4b), intent(in) icellface )
private
Parameters
[in]icnode number (reduced)
[in]icellfacecell face number

Definition at line 305 of file prt-fmi.f90.

306 class(PrtFmiType) :: this
307 integer(I4B), intent(in) :: ic !< node number (reduced)
308 integer(I4B), intent(in) :: icellface !< cell face number
309 logical(LGP) :: is_boundary
310 ! local
311 integer(I4B) :: bit_pos
312
313 is_boundary = .false.
314 if (ic <= 0 .or. ic > this%dis%nodes) then
315 print *, 'Invalid cell number: ', ic
316 print *, 'Expected a value in range [1, ', this%dis%nodes, ']'
317 call pstop(1)
318 end if
319 if (icellface <= 0) then
320 print *, 'Invalid face number: ', icellface
321 print *, 'Expected a value in range [1, ', this%max_faces, ']'
322 call pstop(1)
323 end if
324 bit_pos = icellface - 1 ! bit position 0-based
325 if (bit_pos < 0 .or. bit_pos > 31) then
326 print *, 'Invalid bitmask position: ', bit_pos
327 print *, 'Expected a value in range [0, 31]'
328 call pstop(1)
329 end if
330 is_boundary = btest(this%BoundaryFaces(ic), bit_pos)
Here is the call graph for this function:

◆ is_net_out_boundary_face()

logical(lgp) function prtfmimodule::is_net_out_boundary_face ( class(prtfmitype) this,
integer(i4b), intent(in) ic,
integer(i4b), intent(in) icellface )
private
Parameters
[in]icnode number (reduced)
[in]icellfacecell face number

Definition at line 334 of file prt-fmi.f90.

336 class(PrtFmiType) :: this
337 integer(I4B), intent(in) :: ic !< node number (reduced)
338 integer(I4B), intent(in) :: icellface !< cell face number
339 logical(LGP) :: is_net_out_boundary
340
341 is_net_out_boundary = .false.
342 if (.not. this%is_boundary_face(ic, icellface)) return
343 if (this%BoundaryFlows(ic, icellface) < dzero) &
344 is_net_out_boundary = .true.

◆ mark_boundary_face()

subroutine prtfmimodule::mark_boundary_face ( class(prtfmitype) this,
integer(i4b), intent(in) ic,
integer(i4b), intent(in) icellface )
private
Parameters
[in]icnode number (reduced)
[in]icellfacecell face number

Definition at line 278 of file prt-fmi.f90.

279 class(PrtFmiType) :: this
280 integer(I4B), intent(in) :: ic !< node number (reduced)
281 integer(I4B), intent(in) :: icellface !< cell face number
282 ! local
283 integer(I4B) :: bit_pos
284
285 if (ic <= 0 .or. ic > this%dis%nodes) then
286 print *, 'Invalid cell number: ', ic
287 print *, 'Expected a value in range [1, ', this%dis%nodes, ']'
288 call pstop(1)
289 end if
290 if (icellface <= 0) then
291 print *, 'Invalid face number: ', icellface
292 print *, 'Expected a value in range [1, ', this%max_faces, ']'
293 call pstop(1)
294 end if
295 bit_pos = icellface - 1 ! bit position 0-based
296 if (bit_pos < 0 .or. bit_pos > 31) then
297 print *, 'Invalid bitmask position: ', bit_pos
298 print *, 'Expected a value in range [0, 31]'
299 call pstop(1)
300 end if
301 this%BoundaryFaces(ic) = ibset(this%BoundaryFaces(ic), bit_pos)
Here is the call graph for this function:

◆ prtfmi_allocate_arrays()

subroutine prtfmimodule::prtfmi_allocate_arrays ( class(prtfmitype) this,
integer(i4b), intent(in) nodes )
private

Definition at line 183 of file prt-fmi.f90.

184 class(PrtFmiType) :: this
185 integer(I4B), intent(in) :: nodes
186
187 ! allocate parent arrays
188 call this%FlowModelInterfaceType%allocate_arrays(nodes)
189
190 call mem_allocate(this%StorageFlows, nodes, &
191 'STORAGEFLOWS', this%memoryPath)
192 call mem_allocate(this%SourceFlows, nodes, &
193 'SOURCEFLOWS', this%memoryPath)
194 call mem_allocate(this%SinkFlows, nodes, &
195 'SINKFLOWS', this%memoryPath)
196 call mem_allocate(this%BoundaryFlows, nodes, this%max_faces, &
197 'BOUNDARYFLOWS', this%memoryPath)
198 call mem_allocate(this%BoundaryFaces, nodes, &
199 'BOUNDARYFACES', this%memoryPath)
200

◆ prtfmi_allocate_scalars()

subroutine prtfmimodule::prtfmi_allocate_scalars ( class(prtfmitype) this)
private

Definition at line 172 of file prt-fmi.f90.

173 class(PrtFmiType) :: this
174
175 call this%FlowModelInterfaceType%allocate_scalars()
176
177 call mem_allocate(this%max_faces, 'MAX_FACES', this%memoryPath)
178 this%max_faces = 0
179

◆ prtfmi_da()

subroutine prtfmimodule::prtfmi_da ( class(prtfmitype) this)
private

Definition at line 204 of file prt-fmi.f90.

205 class(PrtFmiType) :: this
206
207 call mem_deallocate(this%max_faces)
208 call mem_deallocate(this%StorageFlows)
209 call mem_deallocate(this%SourceFlows)
210 call mem_deallocate(this%SinkFlows)
211 call mem_deallocate(this%BoundaryFlows)
212 call mem_deallocate(this%BoundaryFaces)
213
214 call this%FlowModelInterfaceType%fmi_da()
215

◆ prtfmi_df()

subroutine prtfmimodule::prtfmi_df ( class(prtfmitype) this,
class(disbasetype), intent(in), pointer dis,
integer(i4b), intent(in) idryinactive )
private

Definition at line 152 of file prt-fmi.f90.

153 class(PrtFmiType) :: this
154 class(DisBaseType), pointer, intent(in) :: dis
155 integer(I4B), intent(in) :: idryinactive
156
157 call this%FlowModelInterfaceType%fmi_df(dis, idryinactive)
158
159 this%max_faces = this%dis%get_max_npolyverts() + 2
160 if (this%max_faces > 32) then
161 write (errmsg, '(a,i0,a,i0,a)') &
162 'DISV grid contains a cell with ', this%max_faces - 2, &
163 ' lateral faces. Cells may have at most 30 lateral faces.'
164 call store_error(errmsg)
165 call this%parser%StoreErrorUnit()
166 return
167 end if
168
Here is the call graph for this function:

Variable Documentation

◆ text

character(len=lenpackagename) prtfmimodule::text = ' PRTFMI'
private

Definition at line 19 of file prt-fmi.f90.