MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
explicitsolutionmodule Module Reference

Explicit Solution Module. More...

Data Types

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

Functions/Subroutines

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

Detailed Description

This module contains the Explicit Solution, which is a class for solving explicit models. The explicit solution scrolls through a list of explicit models and calls methods in a prescribed sequence.

Function/Subroutine Documentation

◆ add_exchange()

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

Definition at line 333 of file ExplicitSolution.f90.

334  class(ExplicitSolutionType) :: this
335  class(BaseExchangeType), pointer, intent(in) :: exchange

◆ 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 307 of file ExplicitSolution.f90.

308  ! -- dummy variables
309  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
310  class(BaseModelType), pointer, intent(in) :: mp !< model instance
311  ! -- local variables
312  class(NumericalModelType), pointer :: m => null()
313 
314  ! -- add a model
315  select type (mp)
316  class is (numericalmodeltype)
317  m => mp
318  call addnumericalmodeltolist(this%modellist, m)
319  end select
Here is the call graph for this function:

◆ allocate_scalars()

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

Definition at line 117 of file ExplicitSolution.f90.

118  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
119 
120  ! -- allocate scalars
121  call mem_allocate(this%id, 'ID', this%memoryPath)
122  call mem_allocate(this%iu, 'IU', this%memoryPath)
123  call mem_allocate(this%ttsoln, 'TTSOLN', this%memoryPath)
124  call mem_allocate(this%icnvg, 'ICNVG', this%memoryPath)
125 
126  ! -- initialize
127  this%id = 0
128  this%iu = 0
129  this%ttsoln = dzero
130  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 79 of file ExplicitSolution.f90.

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

268  ! -- dummy variables
269  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
270  integer(I4B), intent(in) :: kiter !< Picard iteration number (always 1 for explicit)
271  integer(I4B), intent(inout) :: isgcnvg !< solution group convergence flag
272  integer(I4B), intent(in) :: isuppress_output !< flag for suppressing output
273  ! -- local variables
274  integer(I4B) :: im
275  class(NumericalModelType), pointer :: mp => null()
276 
277  ! -- Calculate flow for each model
278  do im = 1, this%modellist%Count()
279  mp => getnumericalmodelfromlist(this%modellist, im)
280  call mp%model_cq(this%icnvg, isuppress_output)
281  end do
282 
283  ! -- Budget terms for each model
284  do im = 1, this%modellist%Count()
285  mp => getnumericalmodelfromlist(this%modellist, im)
286  call mp%model_bd(this%icnvg, isuppress_output)
287  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 340 of file ExplicitSolution.f90.

341  class(ExplicitSolutionType) :: this
342  type(ListType), pointer :: exchanges

◆ 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 324 of file ExplicitSolution.f90.

325  type(ListType), pointer :: models !< pointer to the model list
326  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
327 
328  models => this%modellist

◆ preparesolve()

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

Definition at line 228 of file ExplicitSolution.f90.

229  ! -- dummy variables
230  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
231  ! -- local variables
232  integer(I4B) :: im
233  class(NumericalModelType), pointer :: mp => null()
234 
235  ! -- Model advance
236  do im = 1, this%modellist%Count()
237  mp => getnumericalmodelfromlist(this%modellist, im)
238  call mp%model_ad()
239  end do
240 
241  ! advance solution
242  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 292 of file ExplicitSolution.f90.

293  ! -- dummy variables
294  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
295  character(len=*), intent(in) :: filename !< filename to save solution data
296  ! -- local variables
297  integer(I4B) :: inunit
298 
299  inunit = getunit()
300  open (unit=inunit, file=filename, status='unknown')
301  write (inunit, *) 'The save routine currently writes nothing'
302  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 156 of file ExplicitSolution.f90.

157  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
158 
159  ! -- reset convergence flag
160  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 
144  ! -- close ems input file
145  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 191 of file ExplicitSolution.f90.

192  ! -- dummy variables
193  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
194  integer(I4B), intent(inout) :: isgcnvg !< solution group convergence flag
195  integer(I4B), intent(in) :: isuppress_output !< flag for suppressing output
196  ! -- local variables
197  class(NumericalModelType), pointer :: mp => null()
198  character(len=LINELENGTH) :: line
199  character(len=LINELENGTH) :: fmt
200  integer(I4B) :: im
201  integer(I4B) :: kiter
202 
203  kiter = 1
204 
205  ! advance the models and solution
206  call this%prepareSolve()
207 
208  select case (isim_mode)
209  case (mvalidate)
210  line = 'mode="validation" -- Skipping assembly and solution.'
211  fmt = "(/,1x,a,/)"
212  do im = 1, this%modellist%Count()
213  mp => getnumericalmodelfromlist(this%modellist, im)
214  call mp%model_message(line, fmt=fmt)
215  end do
216  case (mnormal)
217 
218  ! solve the models
219  call this%solve(kiter)
220 
221  ! finish up
222  call this%finalizeSolve(kiter, isgcnvg, isuppress_output)
223  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 175 of file ExplicitSolution.f90.

176  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
177 
178  ! -- lists
179  call this%modellist%Clear()
180  deallocate (this%modellist)
181 
182  ! -- Scalars
183  call mem_deallocate(this%id)
184  call mem_deallocate(this%iu)
185  call mem_deallocate(this%ttsoln)
186  call mem_deallocate(this%icnvg)

◆ sln_df()

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

Definition at line 135 of file ExplicitSolution.f90.

136  class(ExplicitSolutionType) :: this

◆ sln_dt()

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

Definition at line 150 of file ExplicitSolution.f90.

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

◆ sln_fp()

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

Definition at line 169 of file ExplicitSolution.f90.

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

◆ sln_ot()

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

Definition at line 165 of file ExplicitSolution.f90.

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

◆ solve()

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

Definition at line 247 of file ExplicitSolution.f90.

248  ! -- dummy variables
249  class(ExplicitSolutionType) :: this !< ExplicitSolutionType instance
250  integer(I4B), intent(in) :: kiter !< Picard iteration (1 for explicit)
251  ! -- local variables
252  class(NumericalModelType), pointer :: mp => null()
253  integer(I4B) :: im
254  real(DP) :: ttsoln
255 
256  call code_timer(0, ttsoln, this%ttsoln)
257  do im = 1, this%modellist%Count()
258  mp => getnumericalmodelfromlist(this%modellist, im)
259  call mp%model_solve()
260  end do
261  call code_timer(1, ttsoln, this%ttsoln)
262  this%icnvg = 1
Here is the call graph for this function: