MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
BaseSolution.f90
Go to the documentation of this file.
1 ! -- A solution contains a list of models, packages, and exchanges
3 
4  use kindmodule, only: dp, i4b
8  use listmodule, only: listtype
9  implicit none
10 
11  private
13  private :: castasbasesolutionclass
14 
15  type, abstract :: basesolutiontype
16  character(len=LENSOLUTIONNAME) :: name
17  contains
18  procedure(sln_df), deferred :: sln_df
19  procedure(sln_ar), deferred :: sln_ar
20  procedure(sln_dt), deferred :: sln_dt
21  procedure(sln_ad), deferred :: sln_ad
22  procedure(sln_ca), deferred :: sln_ca
23  procedure(sln_ot), deferred :: sln_ot
24  procedure(sln_fp), deferred :: sln_fp
25  procedure(sln_da), deferred :: sln_da
26  procedure(slnsave), deferred :: save
27  procedure(slnaddmodel), deferred :: add_model
28  procedure(slnaddexchange), deferred :: add_exchange
29  procedure(slngetmodels), deferred :: get_models
30  procedure(slngetexchanges), deferred :: get_exchanges
31 
32  ! Expose these for use through the BMI/XMI:
33  procedure(preparesolve), deferred :: preparesolve
34  procedure(solve), deferred :: solve
35  procedure(finalizesolve), deferred :: finalizesolve
36  end type basesolutiontype
37 
38  abstract interface
39 
40  subroutine sln_df(this)
41  import basesolutiontype
42  class(basesolutiontype) :: this
43  end subroutine
44 
45  subroutine slnaddexchange(this, exchange)
46  import basesolutiontype
47  import baseexchangetype
48  class(basesolutiontype) :: this
49  class(baseexchangetype), pointer, intent(in) :: exchange
50  end subroutine
51 
52  subroutine assignconnectionsiface(this)
53  import basesolutiontype
54  class(basesolutiontype) :: this
55  end subroutine
56 
57  subroutine sln_ar(this)
58  import basesolutiontype
59  class(basesolutiontype) :: this
60  end subroutine
61 
62  subroutine sln_rp(this)
63  import basesolutiontype
64  class(basesolutiontype) :: this
65  end subroutine
66 
67  subroutine sln_dt(this)
68  import basesolutiontype
69  class(basesolutiontype) :: this
70  end subroutine
71 
72  subroutine sln_ad(this)
73  import basesolutiontype
74  class(basesolutiontype) :: this
75  end subroutine
76 
77  subroutine sln_ot(this)
78  import basesolutiontype
79  class(basesolutiontype) :: this
80  end subroutine
81 
82  subroutine sln_ca(this, isgcnvg, isuppress_output)
83  use kindmodule, only: dp, i4b
84  import basesolutiontype
85  class(basesolutiontype) :: this
86  integer(I4B), intent(in) :: isuppress_output
87  integer(I4B), intent(inout) :: isgcnvg
88  end subroutine
89 
90  subroutine slnsave(this, filename)
91  import basesolutiontype
92  class(basesolutiontype) :: this
93  character(len=*), intent(in) :: filename
94  end subroutine
95 
96  subroutine slnaddmodel(this, mp)
97  import basesolutiontype
98  import basemodeltype
99  class(basesolutiontype) :: this
100  class(basemodeltype), pointer, intent(in) :: mp
101  end subroutine
102 
103  function slngetmodels(this) result(models)
104  import basesolutiontype
105  import listtype
106  class(basesolutiontype) :: this
107  type(listtype), pointer :: models
108  end function
109 
110  function slngetexchanges(this) result(models)
111  import basesolutiontype
112  import listtype
113  class(basesolutiontype) :: this
114  type(listtype), pointer :: models
115  end function
116 
117  subroutine sln_fp(this)
118  import basesolutiontype
119  class(basesolutiontype) :: this
120  end subroutine
121 
122  subroutine sln_da(this)
123  import basesolutiontype
124  class(basesolutiontype) :: this
125  end subroutine
126 
127  subroutine preparesolve(this)
128  import basesolutiontype
129  class(basesolutiontype) :: this
130  end subroutine preparesolve
131 
132  subroutine solve(this, kiter)
133  use kindmodule, only: i4b
134  import basesolutiontype
135  class(basesolutiontype) :: this
136  integer(I4B), intent(in) :: kiter
137  end subroutine solve
138 
139  subroutine finalizesolve(this, kiter, isgcnvg, isuppress_output)
140  use kindmodule, only: i4b
141  import basesolutiontype
142  class(basesolutiontype) :: this
143  integer(I4B), intent(in) :: kiter
144  integer(I4B), intent(inout) :: isgcnvg
145  integer(I4B), intent(in) :: isuppress_output
146  end subroutine finalizesolve
147 
148  end interface
149 
150 contains
151 
152  function castasbasesolutionclass(obj) result(res)
153  implicit none
154  class(*), pointer, intent(inout) :: obj
155  class(basesolutiontype), pointer :: res
156  !
157  res => null()
158  if (.not. associated(obj)) return
159  !
160  select type (obj)
161  class is (basesolutiontype)
162  res => obj
163  end select
164  end function castasbasesolutionclass
165 
166  subroutine addbasesolutiontolist(list, solution)
167  implicit none
168  ! -- dummy
169  type(listtype), intent(inout) :: list
170  class(basesolutiontype), pointer, intent(in) :: solution
171  ! -- local
172  class(*), pointer :: obj
173  !
174  obj => solution
175  call list%Add(obj)
176  end subroutine addbasesolutiontolist
177 
178  function getbasesolutionfromlist(list, idx) result(res)
179  implicit none
180  ! -- dummy
181  type(listtype), intent(inout) :: list
182  integer(I4B), intent(in) :: idx
183  class(basesolutiontype), pointer :: res
184  ! -- local
185  class(*), pointer :: obj
186  !
187  obj => list%GetItem(idx)
188  res => castasbasesolutionclass(obj)
189  end function getbasesolutionfromlist
190 
191 end module basesolutionmodule
subroutine, public addbasesolutiontolist(list, solution)
class(basesolutiontype) function, pointer, public getbasesolutionfromlist(list, idx)
class(basesolutiontype) function, pointer, private castasbasesolutionclass(obj)
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lensolutionname
maximum length of the solution name
Definition: Constants.f90:21
This module defines variable data types.
Definition: kind.f90:8
Highest level model type. All models extend this parent type.
Definition: BaseModel.f90:13
A generic heterogeneous doubly-linked list.
Definition: List.f90:14