MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
exg-olfgwf.f90
Go to the documentation of this file.
1!> @brief This module contains the OlfGwfExchangeModule Module
2!!
3!! This module contains a lightweight OLF-GWF exchange class which is
4!! primarily based on the underlying and generic SWF-GWF code for connecting
5!< a SWF model (either CHF or OLF) with a GWF model.
6module olfgwfexchangemodule
7
8 use kindmodule, only: dp, i4b, lgp
16 use gwfmodule, only: gwfmodeltype
17 use swfmodule, only: swfmodeltype
18 use obsmodule, only: obs_cr
19
20 implicit none
21 private
22 public :: olfgwf_cr
23
25 contains
26 procedure :: exg_df => olf_gwf_df
27 procedure :: source_options
28 procedure :: source_dimensions
29 procedure :: source_data
30 end type olfgwfexchangetype
31
32contains
33
34 !> @brief Create OLF GWF exchange
35 !!
36 !! High level wrapper over the SWF-GWF exchange, which is generic in that
37 !! it can be used to couple either a CHF or OLF surface water model to a
38 !! GWF model.
39 !<
40 subroutine olfgwf_cr(filename, name, id, m1_id, m2_id, input_mempath)
41 ! modules
42 ! dummy
43 character(len=*), intent(in) :: filename !< filename for reading
44 character(len=*) :: name !< exchange name
45 integer(I4B), intent(in) :: id !< id for the exchange
46 integer(I4B), intent(in) :: m1_id !< id for model 1
47 integer(I4B), intent(in) :: m2_id !< id for model 2
48 character(len=*), intent(in) :: input_mempath
49 ! local
50 type(olfgwfexchangetype), pointer :: exchange
51 class(baseexchangetype), pointer :: baseexchange
52
53 ! Create a new exchange and add it to the baseexchangelist container
54 allocate (exchange)
55 baseexchange => exchange
56 call addbaseexchangetolist(baseexchangelist, baseexchange)
57
58 call exchange%initialize(filename, name, 'OLF', id, m1_id, m2_id, &
59 input_mempath)
60
61 end subroutine olfgwf_cr
62
63 !> @brief Define OLF GWF exchange
64 !<
65 subroutine olf_gwf_df(this)
66 ! modules
67 ! dummy
68 class(olfgwfexchangetype) :: this !< SwfGwfExchangeType
69 ! local
70
71 ! log the exchange
72 write (iout, '(/a,a)') ' Creating exchange: ', this%name
73 !
74 ! Ensure models are in same solution
75 if (associated(this%swfmodel) .and. associated(this%gwfmodel)) then
76 if (this%swfmodel%idsoln /= this%gwfmodel%idsoln) then
77 call store_error('Two models are connected in a SWF-GWF '// &
78 'exchange but they are in different solutions. '// &
79 'Models must be in same solution: '// &
80 trim(this%swfmodel%name)//' '// &
81 trim(this%gwfmodel%name))
82 call store_error_filename(this%filename)
83 end if
84 end if
85
86 ! source options
87 call this%source_options(iout)
88
89 ! source dimensions
90 call this%source_dimensions(iout)
91
92 ! allocate arrays
93 call this%allocate_arrays()
94
95 ! source exchange data
96 call this%source_data(iout)
97
98 ! Store obs
99 ! call this%swf_gwf_df_obs()
100 ! if (associated(this%swfmodel1)) then
101 ! call this%obs%obs_df(iout, this%name, 'SWF-GWF', this%swfmodel1%dis)
102 ! end if
103
104 ! ! validate
105 ! call this%validate_exchange()
106
107 end subroutine olf_gwf_df
108
109 !> @brief Source options
110 !<
111 subroutine source_options(this, iout)
112 ! modules
119 ! dummy
120 class(olfgwfexchangetype) :: this !< GwfExchangeType
121 integer(I4B), intent(in) :: iout
122 ! local
123 type(exgolfgwfparamfoundtype) :: found
124
125 ! update defaults with idm sourced values
126 call mem_set_value(this%ipr_input, 'IPR_INPUT', &
127 this%input_mempath, found%ipr_input)
128 call mem_set_value(this%ipr_flow, 'IPR_FLOW', &
129 this%input_mempath, found%ipr_flow)
130 call mem_set_value(this%ifixedcond, 'IFIXEDCOND', &
131 this%input_mempath, found%ifixedcond)
132
133 write (iout, '(1x,a)') 'Processing OLF-GWF exchange options'
134
135 if (found%ipr_input) then
136 write (iout, '(4x,a)') &
137 'The list of exchanges will be printed.'
138 end if
139
140 if (found%ipr_flow) then
141 write (iout, '(4x,a)') &
142 'Exchange flows will be printed to list files.'
143 end if
144
145 if (found%ifixedcond) then
146 write (iout, '(4x,a)') &
147 'Conductance is fixed as product of BEDLEAK and CFACT.'
148 end if
149
150 ! enforce 0 or 1 OBS6_FILENAME entries in option block
151 ! if (.not. this%is_datacopy) then
152 ! if (filein_fname(this%obs%inputFilename, 'OBS6_FILENAME', &
153 ! this%input_mempath, this%filename)) then
154 ! this%obs%active = .true.
155 ! this%obs%inUnitObs = GetUnit()
156 ! call openfile(this%obs%inUnitObs, iout, this%obs%inputFilename, 'OBS')
157 ! end if
158 ! end if
159
160 write (iout, '(1x,a)') 'End of OLF-GWF exchange options'
161
162 end subroutine source_options
163
164 !> @brief Source dimension from input context
165 !<
166 subroutine source_dimensions(this, iout)
167 ! modules
170 ! dummy
171 class(olfgwfexchangetype) :: this !< instance of exchange object
172 integer(I4B), intent(in) :: iout !< for logging
173 ! local
174 type(exgolfgwfparamfoundtype) :: found
175
176 ! update defaults with idm sourced values
177 call mem_set_value(this%nexg, 'NEXG', this%input_mempath, found%nexg)
178
179 write (iout, '(1x,a)') 'PROCESSING EXCHANGE DIMENSIONS'
180
181 if (found%nexg) then
182 write (iout, '(4x,a,i0)') 'NEXG = ', this%nexg
183 end if
184
185 write (iout, '(1x,a)') 'END OF EXCHANGE DIMENSIONS'
186
187 end subroutine source_dimensions
188
189 !> @brief Source exchange data from input context
190 !<
191 subroutine source_data(this, iout)
192 ! modules
195 ! dummy
196 class(olfgwfexchangetype) :: this !< instance of exchange object
197 integer(I4B), intent(in) :: iout !< the output file unit
198 ! local
199 integer(I4B), dimension(:, :), contiguous, pointer :: cellidm1
200 integer(I4B), dimension(:, :), contiguous, pointer :: cellidm2
201 real(DP), dimension(:), contiguous, pointer :: bedleak
202 real(DP), dimension(:), contiguous, pointer :: cfact
203 character(len=20) :: cellstr1, cellstr2
204 integer(I4B) :: nerr
205 integer(I4B) :: iexg, nodeswf, nodegwf
206 ! format
207 character(len=*), parameter :: fmtexglabel = "(1x, 3a10, 50(a16))"
208 character(len=*), parameter :: fmtexgdata = &
209 "(5x, a, 1x, a ,50(1pg16.6))"
210
211 call mem_setptr(cellidm1, 'CELLIDM1', this%input_mempath)
212 call mem_setptr(cellidm2, 'CELLIDM2', this%input_mempath)
213 call mem_setptr(bedleak, 'BEDLEAK', this%input_mempath)
214 call mem_setptr(cfact, 'CFACT', this%input_mempath)
215
216 write (iout, '(1x,a)') 'PROCESSING EXCHANGEDATA'
217
218 if (this%ipr_input /= 0) then
219 write (iout, fmtexglabel) 'NODEM1', 'NODEM2', 'BEDLEAK', 'CFACT'
220 end if
221
222 do iexg = 1, this%nexg
223
224 if (associated(this%model1)) then
225 ! Determine user node number
226 nodeswf = this%noder(this%model1, cellidm1(:, iexg), iout)
227 this%nodeswf(iexg) = nodeswf
228 else
229 this%nodeswf(iexg) = -1
230 end if
231
232 if (associated(this%model2)) then
233 ! Determine user node number
234 nodegwf = this%noder(this%model2, cellidm2(:, iexg), iout)
235 this%nodegwf(iexg) = nodegwf
236 else
237 this%nodegwf(iexg) = -1
238 end if
239
240 ! Read rest of input line
241 this%bedleak(iexg) = bedleak(iexg)
242 this%cfact(iexg) = cfact(iexg)
243
244 ! Write the data to listing file if requested
245 if (this%ipr_input /= 0) then
246 cellstr1 = this%cellstr(this%model1, cellidm1(:, iexg), iout)
247 cellstr2 = this%cellstr(this%model2, cellidm2(:, iexg), iout)
248 write (iout, fmtexgdata) trim(cellstr1), trim(cellstr2), &
249 this%bedleak(iexg), this%cfact(iexg)
250 end if
251
252 ! Check to see if nodeswf is outside of active domain
253 if (associated(this%model1)) then
254 if (nodeswf <= 0) then
255 cellstr1 = this%cellstr(this%model1, cellidm1(:, iexg), iout)
256 write (errmsg, *) &
257 trim(adjustl(this%model1%name))// &
258 ' Cell is outside active grid domain ('// &
259 trim(adjustl(cellstr1))//').'
260 call store_error(errmsg)
261 end if
262 end if
263
264 ! Check to see if nodegwf is outside of active domain
265 if (associated(this%model2)) then
266 if (nodegwf <= 0) then
267 cellstr2 = this%cellstr(this%model2, cellidm2(:, iexg), iout)
268 write (errmsg, *) &
269 trim(adjustl(this%model2%name))// &
270 ' Cell is outside active grid domain ('// &
271 trim(adjustl(cellstr2))//').'
272 call store_error(errmsg)
273 end if
274 end if
275 end do
276
277 write (iout, '(1x,a)') 'END OF EXCHANGEDATA'
278
279 ! Stop if errors
280 nerr = count_errors()
281 if (nerr > 0) then
282 call store_error('Errors encountered in exchange input file.')
283 call store_error_filename(this%filename)
284 end if
285
286 call memorystore_release('CELLIDM1', this%input_mempath)
287 call memorystore_release('CELLIDM2', this%input_mempath)
288 call memorystore_release('BEDLEAK', this%input_mempath)
289 call memorystore_release('CFACT', this%input_mempath)
290
291 end subroutine source_data
292
293end module olfgwfexchangemodule
subroutine source_data(this, iout)
Source exchange data from input context.
subroutine olf_gwf_df(this)
Define OLF GWF exchange.
subroutine olfgwf_cr(filename, name, id, m1_id, m2_id, input_mempath)
Create OLF GWF exchange.
subroutine source_options(this, iout)
Source options.
subroutine source_dimensions(this, iout)
Source dimension from input context.
subroutine, public addbaseexchangetolist(list, exchange)
Add the exchange object (BaseExchangeType) to a list.
class(basemodeltype) function, pointer, public getbasemodelfromlist(list, idx)
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition Constants.f90:17
real(dp), parameter dem6
real constant 1e-6
integer(i4b) function, public getunit()
Get a free unit number.
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
This module defines variable data types.
Definition kind.f90:8
type(listtype), public basemodellist
Definition mf6lists.f90:16
type(listtype), public baseexchangelist
Definition mf6lists.f90:25
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
This module contains the derived type ObsType.
Definition Obs.f90:127
subroutine, public obs_cr(obs, inobs)
Create a new ObsType object.
Definition Obs.f90:225
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
integer(i4b) function, public count_errors()
Return number of errors.
Definition Sim.f90:60
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
integer(i4b), dimension(:), allocatable model_loc_idx
equals the local index into the basemodel list (-1 when not available)
integer(i4b) iout
file unit number for simulation output
This module contains the SourceCommonModule.
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
This module contains the SwfGwfExchangeModule Module.
Definition exg-swfgwf.f90:8
Surface Water Flow (SWF) Module.
Definition swf.f90:3
Highest level model type. All models extend this parent type.
Definition BaseModel.f90:16
This class is used to store a single deferred-length character string. It was designed to work in an ...