MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
gwf-uzf-obs.f90
Go to the documentation of this file.
1!> @brief UZF package observations
2!<
3submodule(uzfmodule) uzfmoduleobs
4contains
5
6 !> @brief Return true because uzf package supports observations
7 !!
8 !! Overrides BndType%bnd_obs_supported
9 !<
10 module procedure uzf_obs_supported
11 uzf_obs_supported = .true.
12 end procedure uzf_obs_supported
13
14 !> @brief Implements bnd_df_obs
15 !!
16 !! Store observation type supported by uzf package.
17 !! Overrides BndType%bnd_df_obs
18 !<
19 module procedure uzf_df_obs
20 ! -- local
21 integer(I4B) :: indx
22 !
23 call this%obs%StoreObsType('uzf-gwrch', .true., indx)
24 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
25 !
26 ! for discharge observation type.
27 call this%obs%StoreObsType('uzf-gwd', .true., indx)
28 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
29 !
30 ! for discharge observation type.
31 call this%obs%StoreObsType('uzf-gwd-to-mvr', .true., indx)
32 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
33 !
34 ! for gwet observation type.
35 call this%obs%StoreObsType('uzf-gwet', .true., indx)
36 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
37 !
38 ! for infiltration observation type.
39 call this%obs%StoreObsType('infiltration', .true., indx)
40 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
41 !
42 ! for from mover observation type.
43 call this%obs%StoreObsType('from-mvr', .true., indx)
44 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
45 !
46 ! for rejected infiltration observation type.
47 call this%obs%StoreObsType('rej-inf', .true., indx)
48 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
49 !
50 ! for rejected infiltration to mover observation type.
51 call this%obs%StoreObsType('rej-inf-to-mvr', .true., indx)
52 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
53 !
54 ! for uzet observation type.
55 call this%obs%StoreObsType('uzet', .true., indx)
56 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
57 !
58 ! for storage observation type.
59 call this%obs%StoreObsType('storage', .true., indx)
60 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
61 !
62 ! for net infiltration observation type.
63 call this%obs%StoreObsType('net-infiltration', .true., indx)
64 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
65 !
66 ! for water-content observation type.
67 call this%obs%StoreObsType('water-content', .false., indx)
68 this%obs%obsData(indx)%ProcessIdPtr => uzf_process_obsid
69 end procedure uzf_df_obs
70
71 !> @brief Process each observation
72 !!
73 !! Only done the first stress period since boundaries are fixed for the
74 !! simulation
75 !<
76 module procedure uzf_rp_obs
77 ! -- modules
78 use tdismodule, only: kper
79 ! -- local
80 integer(I4B) :: i
81 integer(I4B) :: j
82 integer(I4B) :: n
83 integer(I4B) :: nn
84 integer(I4B) :: iuzid
85 real(DP) :: obsdepth
86 real(DP) :: dmax
87 character(len=LENBOUNDNAME) :: bname
88 class(ObserveType), pointer :: obsrv => null()
89 !
9010 format('Boundary "', a, '" for observation "', a, &
91 '" is invalid in package "', a, '"')
9260 format('Invalid node number in OBS input: ', i0)
93 !
94 if (kper == 1) then
95 do i = 1, this%obs%npakobs
96 obsrv => this%obs%pakobs(i)%obsrv
97 !
98 ! -- get node number 1
99 nn = obsrv%NodeNumber
100 if (nn == namedboundflag) then
101 bname = obsrv%FeatureName
102 !
103 ! -- Observation location(s) is(are) based on a boundary name.
104 ! Iterate through all boundaries to identify and store
105 ! corresponding index(indices) in bound array.
106 if (this%inamedbound /= 0) then
107 do n = 1, this%nodes
108 if (this%boundname(n) == bname) then
109 obsrv%BndFound = .true.
110 obsrv%CurrentTimeStepEndValue = dzero
111 call obsrv%AddObsIndex(n)
112 if (obsrv%indxbnds_count == 1) then
113 !
114 ! -- Define intPak1 so that obs_theta is stored (for first uzf
115 ! cell if multiple cells share the same boundname).
116 obsrv%intPak1 = n
117 end if
118 end if
119 end do
120 end if
121 if (.not. obsrv%BndFound) then
122 write (errmsg, 10) trim(bname), trim(obsrv%Name), trim(this%packName)
123 call store_error(errmsg)
124 cycle
125 end if
126 else
127 !
128 ! -- get node number
129 nn = obsrv%NodeNumber
130 !
131 ! -- put nn (a value meaningful only to UZF) in intPak1
132 obsrv%intPak1 = nn
133 ! -- check that node number is valid; call store_error if not
134 if (nn < 1 .or. nn > this%nodes) then
135 write (errmsg, 60) nn
136 call store_error(errmsg)
137 else
138 obsrv%BndFound = .true.
139 end if
140 obsrv%CurrentTimeStepEndValue = dzero
141 call obsrv%AddObsIndex(nn)
142 end if
143 !
144 ! -- catch non-cumulative observation assigned to observation defined
145 ! by a boundname that is assigned to more than one element
146 if (obsrv%ObsTypeId == 'WATER-CONTENT') then
147 n = obsrv%indxbnds_count
148 if (n /= 1) then
149 write (errmsg, '(a,3(1x,a))') &
150 trim(adjustl(obsrv%ObsTypeId)), 'for observation', &
151 trim(adjustl(obsrv%Name)), &
152 'must be assigned to a UZF cell with a unique boundname.'
153 call store_error(errmsg, terminate=.true.)
154 end if
155 !
156 ! -- check WATER-CONTENT depth
157 obsdepth = obsrv%Obsdepth
158 !
159 ! -- put obsdepth (a value meaningful only to UZF) in dblPak1
160 obsrv%dblPak1 = obsdepth
161 !
162 ! -- determine maximum cell depth
163 ! -- This is presently complicated for landflag = 1 cells and surfdep
164 ! greater than zero. In this case, celtop is dis%top - surfdep.
165 iuzid = obsrv%intPak1
166 dmax = this%uzfobj%celtop(iuzid) - this%uzfobj%celbot(iuzid)
167 ! -- check that obs depth is valid; call store_error if not
168 ! -- need to think about a way to put bounds on this depth
169 ! -- Also, an observation depth of 0.0, whether a landflag == 1 object
170 ! -- or a subsurface object, is not legit since this would be at a
171 ! -- a layer interface and therefore a discontinuity.
172 if (obsdepth <= dzero .or. obsdepth > dmax) then
173 write (errmsg, '(a,3(1x,a),1x,g0,1x,a,1x,g0,a)') &
174 trim(adjustl(obsrv%ObsTypeId)), 'for observation', &
175 trim(adjustl(obsrv%Name)), 'specified depth (', obsdepth, &
176 ') must be greater than 0.0 and less than ', dmax, '.'
177 call store_error(errmsg)
178 end if
179 else
180 do j = 1, obsrv%indxbnds_count
181 nn = obsrv%indxbnds(j)
182 if (nn < 1 .or. nn > this%maxbound) then
183 write (errmsg, '(a,2(1x,a),1x,i0,1x,a,1x,i0,a)') &
184 trim(adjustl(obsrv%ObsTypeId)), 'uzfno must be greater than 0 ', &
185 'and less than or equal to', this%maxbound, &
186 '(specified value is ', nn, ').'
187 call store_error(errmsg)
188 end if
189 end do
190 end if
191 end do
192 !
193 ! -- evaluate if there are any observation errors
194 if (count_errors() > 0) then
195 call store_error_filename(this%input_fname)
196 end if
197 end if
198 end procedure uzf_rp_obs
199
200 !> @brief Calculate observations this time step and call ObsType%SaveOneSimval
201 !! for each UzfType observation
202 !<
203 module procedure uzf_bd_obs
204 ! -- local
205 integer(I4B) :: i
206 integer(I4B) :: ii
207 integer(I4B) :: n
208 real(DP) :: v
209 type(ObserveType), pointer :: obsrv => null()
210 !
211 call this%uzf_solve(reset_state=.false.)
212 !
213 ! Write simulated values for all uzf observations
214 if (this%obs%npakobs > 0) then
215 call this%obs%obs_bd_clear()
216 do i = 1, this%obs%npakobs
217 obsrv => this%obs%pakobs(i)%obsrv
218 do ii = 1, obsrv%indxbnds_count
219 n = obsrv%indxbnds(ii)
220 v = dnodata
221 select case (obsrv%ObsTypeId)
222 case ('UZF-GWRCH')
223 v = this%rch(n)
224 case ('UZF-GWD')
225 v = this%gwd(n)
226 if (v > dzero) then
227 v = -v
228 end if
229 case ('UZF-GWD-TO-MVR')
230 if (this%imover == 1) then
231 v = this%gwdtomvr(n)
232 if (v > dzero) then
233 v = -v
234 end if
235 end if
236 case ('UZF-GWET')
237 if (this%igwetflag > 0) then
238 v = this%uzfobj%gwet(n)
239 if (v > dzero) then
240 v = -v
241 end if
242 end if
243 case ('INFILTRATION')
244 v = this%appliedinf(n)
245 case ('FROM-MVR')
246 if (this%imover == 1) then
247 v = this%pakmvrobj%get_qfrommvr(n)
248 end if
249 case ('REJ-INF')
250 v = this%rejinf(n)
251 if (v > dzero) then
252 v = -v
253 end if
254 case ('REJ-INF-TO-MVR')
255 if (this%imover == 1) then
256 v = this%rejinftomvr(n)
257 if (v > dzero) then
258 v = -v
259 end if
260 end if
261 case ('UZET')
262 if (this%ietflag /= 0) then
263 v = this%uzet(n)
264 if (v > dzero) then
265 v = -v
266 end if
267 end if
268 case ('STORAGE')
269 v = -this%qsto(n)
270 case ('NET-INFILTRATION')
271 v = this%infiltration(n)
272 case ('WATER-CONTENT')
273 v = this%uzfobj%get_water_content_at_depth(n, obsrv%obsDepth)
274 case default
275 errmsg = 'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
276 call store_error(errmsg)
277 end select
278 call this%obs%SaveOneSimval(obsrv, v)
279 end do
280 end do
281 !
282 ! -- write summary of error messages
283 if (count_errors() > 0) then
284 call store_error_filename(this%input_fname)
285 end if
286 end if
287 end procedure uzf_bd_obs
288
289 !> @brief This procedure is pointed to by ObsDataType%ProcesssIdPtr
290 !!
291 !! Process the ID string of an observation definition for UZF-package
292 !! observations
293 !<
294 subroutine uzf_process_obsid(obsrv, dis, inunitobs, iout)
295 ! -- .
296 ! -- dummy
297 type(ObserveType), intent(inout) :: obsrv
298 class(DisBaseType), intent(in) :: dis
299 integer(I4B), intent(in) :: inunitobs
300 integer(I4B), intent(in) :: iout
301 ! -- local
302 integer(I4B) :: n, nn
303 real(DP) :: obsdepth
304 integer(I4B) :: icol, istart, istop, istat
305 real(DP) :: r
306 character(len=LINELENGTH) :: string
307 ! formats
30830 format(i10)
309 !
310 string = obsrv%IDstring
311 ! -- Extract node number from string and store it.
312 ! If 1st item is not an integer(I4B), it should be a
313 ! feature name--deal with it.
314 icol = 1
315 ! -- get node number
316 call urword(string, icol, istart, istop, 1, n, r, iout, inunitobs)
317 read (string(istart:istop), 30, iostat=istat) nn
318 if (istat == 0) then
319 ! -- store uzf node number (NodeNumber)
320 obsrv%NodeNumber = nn
321 else
322 ! Integer can't be read from string; it's presumed to be a boundary
323 ! name (already converted to uppercase)
324 obsrv%FeatureName = string(istart:istop)
325 !obsrv%FeatureName = trim(adjustl(string))
326 ! -- Observation may require summing rates from multiple boundaries,
327 ! so assign NodeNumber as a value that indicates observation
328 ! is for a named boundary or group of boundaries.
329 obsrv%NodeNumber = namedboundflag
330 end if
331 !
332 ! -- for soil water observation, store depth
333 if (obsrv%ObsTypeId == 'WATER-CONTENT') then
334 call urword(string, icol, istart, istop, 3, n, r, iout, inunitobs)
335 obsdepth = r
336 ! -- store observations depth
337 obsrv%Obsdepth = obsdepth
338 end if
339 end subroutine uzf_process_obsid
340
341end submodule uzfmoduleobs
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26