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

Explicit solutions for solving explicit models. More...

Data Types

type  explicitsolutiontype
 Manages and solves explicit models. More...

Functions/Subroutines

subroutine, public create_explicit_solution (exp_sol, filename, id)
 Create a new solution.
subroutine allocate_scalars (this)
 Allocate scalars.
subroutine sln_df (this)
 Define the solution.
subroutine sln_ar (this)
 Allocate and read.
subroutine sln_dt (this)
 Calculate time step length.
subroutine sln_ad (this)
 Advance the solution.
subroutine sln_ot (this)
 Output.
subroutine sln_fp (this)
subroutine sln_da (this)
 Deallocate.
subroutine sln_ca (this, isgcnvg, isuppress_output)
 Calculate.
subroutine preparesolve (this)
 Prepare to solve.
subroutine solve (this, kiter, isuppress_output)
 Solve models.
subroutine finalizesolve (this, kiter, isgcnvg, isuppress_output)
 Finalize solve.
subroutine save (this, filename)
 Save output.
subroutine add_model (this, mp)
 Add explicit model to list.
type(listtype) function, pointer get_models (this)
 Get a pointer to a list of models in the solution.
subroutine add_exchange (this, exchange)
 Add exchange to list of exchanges.
type(listtype) function, pointer get_exchanges (this)
 Get list of exchanges.

Detailed Description

Explicit solutions manage and solve explicit models. An explicit model solves itself, as opposed to a numerical model which requires a numerical solution procedure. An explicit solution involves a double loop: an outer loop that continues until no model has pending work, as well as an inner loop that scrolls through the models in the solution and tells each to solve itself. The outer loop is necessary because the explicit models may be coupled by exchanges; models may send work during each solve to other models. The outer loop continues until all models have completed all work.

Function/Subroutine Documentation

◆ add_exchange()

subroutine explicitsolutionmodule::add_exchange ( class(explicitsolutiontype) this,
class(baseexchangetype), intent(in), pointer exchange )
private

Definition at line 339 of file ExplicitSolution.f90.

340 class(ExplicitSolutionType) :: this
341 class(BaseExchangeType), pointer, intent(in) :: exchange
342 class(*), pointer :: obj
343 obj => exchange
344 call this%exchangelist%Add(obj)

◆ add_model()

subroutine explicitsolutionmodule::add_model ( class(explicitsolutiontype) this,
class(basemodeltype), intent(in), pointer mp )
private
Parameters
thisExplicitSolutionType instance
[in]mpmodel instance

Definition at line 320 of file ExplicitSolution.f90.

321 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
322 class(BaseModelType), pointer, intent(in) :: mp !< model instance
323 class(ExplicitModelType), pointer :: m => null()
324 select type (mp)
325 class is (explicitmodeltype)
326 m => mp
327 call addexplicitmodeltolist(this%modellist, m)
328 end select
Here is the call graph for this function:

◆ allocate_scalars()

subroutine explicitsolutionmodule::allocate_scalars ( class(explicitsolutiontype) this)
private
Parameters
thisExplicitSolutionType instance

Definition at line 119 of file ExplicitSolution.f90.

120 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
121
122 ! allocate
123 call mem_allocate(this%id, 'ID', this%memoryPath)
124 call mem_allocate(this%iu, 'IU', this%memoryPath)
125 call mem_allocate(this%ttsoln, 'TTSOLN', this%memoryPath)
126 call mem_allocate(this%icnvg, 'ICNVG', this%memoryPath)
127
128 ! initialize
129 this%id = 0
130 this%iu = 0
131 this%ttsoln = dzero
132 this%icnvg = 0

◆ create_explicit_solution()

subroutine, public explicitsolutionmodule::create_explicit_solution ( class(explicitsolutiontype), pointer exp_sol,
character(len=*), intent(in) filename,
integer(i4b), intent(in) id )

Create a new solution using the data in filename, assign this new solution an id number and store the solution in the basesolutionlist. Also open the filename for later reading.

Parameters
exp_solthe create solution
[in]filenamesolution input file name
[in]idsolution id

Definition at line 82 of file ExplicitSolution.f90.

83 ! modules
85 ! dummy
86 class(ExplicitSolutionType), pointer :: exp_sol !< the create solution
87 character(len=*), intent(in) :: filename !< solution input file name
88 integer(I4B), intent(in) :: id !< solution id
89 ! local
90 integer(I4B) :: inunit
91 class(BaseSolutionType), pointer :: solbase => null()
92 character(len=LENSOLUTIONNAME) :: solutionname
93
94 ! Create a new solution and add it to the basesolutionlist container
95 solbase => exp_sol
96 write (solutionname, '(a, i0)') 'SLN_', id
97 exp_sol%name = solutionname
98 exp_sol%memoryPath = create_mem_path(solutionname)
99 allocate (exp_sol%modellist)
100 allocate (exp_sol%exchangelist)
101 call exp_sol%allocate_scalars()
102 call addbasesolutiontolist(basesolutionlist, solbase)
103 exp_sol%id = id
104
105 ! Open solution input file for reading later after problem size is known
106 ! Check to see if the file is already opened, which can happen when
107 ! running in single model mode
108 inquire (file=filename, number=inunit)
109 if (inunit < 0) inunit = getunit()
110 exp_sol%iu = inunit
111 write (iout, '(/a,a/)') ' Creating explicit solution (EMS): ', exp_sol%name
112 call openfile(exp_sol%iu, iout, filename, 'EMS')
113
114 ! Initialize block parser
115 call exp_sol%parser%Initialize(exp_sol%iu, iout)
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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalizesolve()

subroutine explicitsolutionmodule::finalizesolve ( class(explicitsolutiontype) this,
integer(i4b), intent(in) kiter,
integer(i4b), intent(inout) isgcnvg,
integer(i4b), intent(in) isuppress_output )
private
Parameters
thisExplicitSolutionType instance
[in]kiterPicard iteration number (always 1 for explicit)
[in,out]isgcnvgsolution group convergence flag
[in]isuppress_outputflag for suppressing output

Definition at line 285 of file ExplicitSolution.f90.

286 ! dummy
287 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
288 integer(I4B), intent(in) :: kiter !< Picard iteration number (always 1 for explicit)
289 integer(I4B), intent(inout) :: isgcnvg !< solution group convergence flag
290 integer(I4B), intent(in) :: isuppress_output !< flag for suppressing output
291 ! local
292 integer(I4B) :: im
293 class(ExplicitModelType), pointer :: mp => null()
294
295 ! Calculate flow for each model
296 do im = 1, this%modellist%Count()
297 mp => getexplicitmodelfromlist(this%modellist, im)
298 call mp%model_cq(this%icnvg, isuppress_output)
299 end do
300
301 ! Budget terms for each model
302 do im = 1, this%modellist%Count()
303 mp => getexplicitmodelfromlist(this%modellist, im)
304 call mp%model_bd(this%icnvg, isuppress_output)
305 end do
Here is the call graph for this function:

◆ get_exchanges()

type(listtype) function, pointer explicitsolutionmodule::get_exchanges ( class(explicitsolutiontype) this)
private

Definition at line 348 of file ExplicitSolution.f90.

349 class(ExplicitSolutionType) :: this
350 type(ListType), pointer :: exchanges
351 exchanges => this%exchangelist

◆ get_models()

type(listtype) function, pointer explicitsolutionmodule::get_models ( class(explicitsolutiontype) this)
private
Returns
pointer to the model list
Parameters
thisExplicitSolutionType instance

Definition at line 332 of file ExplicitSolution.f90.

333 type(ListType), pointer :: models !< pointer to the model list
334 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
335 models => this%modellist

◆ preparesolve()

subroutine explicitsolutionmodule::preparesolve ( class(explicitsolutiontype) this)
private
Parameters
thisExplicitSolutionType instance

Definition at line 222 of file ExplicitSolution.f90.

223 ! dummy
224 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
225 ! local
226 integer(I4B) :: i
227 class(ExplicitModelType), pointer :: mp => null()
228 class(BaseExchangeType), pointer :: ep => null()
229
230 ! advance exchanges
231 do i = 1, this%exchangelist%Count()
232 ep => getbaseexchangefromlist(this%exchangelist, i)
233 call ep%exg_ad()
234 end do
235
236 ! advance models
237 do i = 1, this%modellist%Count()
238 mp => getexplicitmodelfromlist(this%modellist, i)
239 call mp%model_ad()
240 end do
241
242 ! advance solution
243 call this%sln_ad()
Here is the call graph for this function:

◆ save()

subroutine explicitsolutionmodule::save ( class(explicitsolutiontype) this,
character(len=*), intent(in) filename )
private
Parameters
thisExplicitSolutionType instance
[in]filenamefilename to save solution data

Definition at line 309 of file ExplicitSolution.f90.

310 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
311 character(len=*), intent(in) :: filename !< filename to save solution data
312 integer(I4B) :: inunit
313 inunit = getunit()
314 open (unit=inunit, file=filename, status='unknown')
315 write (inunit, *) 'The save routine currently writes nothing'
316 close (inunit)
Here is the call graph for this function:

◆ sln_ad()

subroutine explicitsolutionmodule::sln_ad ( class(explicitsolutiontype) this)
private
Parameters
thisExplicitSolutionType instance

Definition at line 153 of file ExplicitSolution.f90.

154 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
155
156 ! reset convergence flag
157 this%icnvg = 0

◆ sln_ar()

subroutine explicitsolutionmodule::sln_ar ( class(explicitsolutiontype) this)
private
Parameters
thisExplicitSolutionType instance

Definition at line 141 of file ExplicitSolution.f90.

142 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
143 ! close ems input file
144 call this%parser%Clear()

◆ sln_ca()

subroutine explicitsolutionmodule::sln_ca ( class(explicitsolutiontype) this,
integer(i4b), intent(inout) isgcnvg,
integer(i4b), intent(in) isuppress_output )
private
Parameters
thisExplicitSolutionType instance
[in,out]isgcnvgsolution group convergence flag
[in]isuppress_outputflag for suppressing output

Definition at line 187 of file ExplicitSolution.f90.

188 ! dummy
189 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
190 integer(I4B), intent(inout) :: isgcnvg !< solution group convergence flag
191 integer(I4B), intent(in) :: isuppress_output !< flag for suppressing output
192 ! local
193 class(ExplicitModelType), pointer :: mp => null()
194 character(len=LINELENGTH) :: line
195 character(len=LINELENGTH) :: fmt
196 integer(I4B) :: im
197 integer(I4B) :: kiter
198
199 kiter = 1
200
201 call this%prepareSolve()
202
203 select case (isim_mode)
204 case (mvalidate)
205 line = 'mode="validation" -- Skipping assembly and solution.'
206 fmt = "(/,1x,a,/)"
207 do im = 1, this%modellist%Count()
208 mp => getexplicitmodelfromlist(this%modellist, im)
209 call mp%model_message(line, fmt=fmt)
210 end do
211 case (mnormal)
212
213 ! solve the models
214 call this%solve(kiter, isuppress_output)
215
216 ! finish up
217 call this%finalizeSolve(kiter, isgcnvg, isuppress_output)
218 end select
Here is the call graph for this function:

◆ sln_da()

subroutine explicitsolutionmodule::sln_da ( class(explicitsolutiontype) this)
private
Parameters
thisExplicitSolutionType instance

Definition at line 170 of file ExplicitSolution.f90.

171 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
172
173 ! lists
174 call this%modellist%Clear()
175 deallocate (this%modellist)
176 call this%exchangelist%Clear()
177 deallocate (this%exchangelist)
178
179 ! scalars
180 call mem_deallocate(this%id)
181 call mem_deallocate(this%iu)
182 call mem_deallocate(this%ttsoln)
183 call mem_deallocate(this%icnvg)

◆ sln_df()

subroutine explicitsolutionmodule::sln_df ( class(explicitsolutiontype) this)
private

Definition at line 136 of file ExplicitSolution.f90.

137 class(ExplicitSolutionType) :: this

◆ sln_dt()

subroutine explicitsolutionmodule::sln_dt ( class(explicitsolutiontype) this)
private
Parameters
thisExplicitSolutionType instance

Definition at line 148 of file ExplicitSolution.f90.

149 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance

◆ sln_fp()

subroutine explicitsolutionmodule::sln_fp ( class(explicitsolutiontype) this)
private
Parameters
thisExplicitSolutionType instance

Definition at line 165 of file ExplicitSolution.f90.

166 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance

◆ sln_ot()

subroutine explicitsolutionmodule::sln_ot ( class(explicitsolutiontype) this)
private
Parameters
thisExplicitSolutionType instance

Definition at line 161 of file ExplicitSolution.f90.

162 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance

◆ solve()

subroutine explicitsolutionmodule::solve ( class(explicitsolutiontype) this,
integer(i4b), intent(in) kiter,
integer(i4b), intent(in) isuppress_output )
private
Parameters
thisExplicitSolutionType instance
[in]kiterPicard iteration (1 for explicit)
[in]isuppress_outputflag for suppressing output

Definition at line 247 of file ExplicitSolution.f90.

248 ! dummy
249 class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
250 integer(I4B), intent(in) :: kiter !< Picard iteration (1 for explicit)
251 integer(I4B), intent(in) :: isuppress_output !< flag for suppressing output
252 ! local
253 class(ExplicitModelType), pointer :: mp => null()
254 integer(I4B) :: im
255 logical :: any_pending
256 real(DP) :: ttsoln
257
258 call code_timer(0, ttsoln, this%ttsoln)
259
260 ! Outer loop: repeat until no model has pending work
261 do
262 ! Solve every model in the solution
263 do im = 1, this%modellist%Count()
264 mp => getexplicitmodelfromlist(this%modellist, im)
265 call mp%model_solve(isuppress_output)
266 end do
267
268 ! Continue if any have pending work
269 any_pending = .false.
270 do im = 1, this%modellist%Count()
271 mp => getexplicitmodelfromlist(this%modellist, im)
272 if (mp%has_pending()) then
273 any_pending = .true.
274 exit
275 end if
276 end do
277 if (.not. any_pending) exit
278 end do
279
280 call code_timer(1, ttsoln, this%ttsoln)
281 this%icnvg = 1
Here is the call graph for this function: