MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
BaseExchange.f90
Go to the documentation of this file.
2 
3  use kindmodule, only: dp, i4b, lgp
5  use listmodule, only: listtype
7 
8  implicit none
9 
10  private
12  private :: castasbaseexchangeclass
13 
14  type, abstract :: baseexchangetype
15  character(len=LENEXCHANGENAME) :: name !< the name of this exchange
16  character(len=LENMEMPATH) :: memorypath !< the location in the memory manager where the variables are stored
17  character(len=LENMEMPATH) :: input_mempath
18  integer(I4B) :: id
19 
20  contains
21 
22  procedure(exg_df), deferred :: exg_df
23  procedure(exg_ar), deferred :: exg_ar
24  procedure :: exg_rp
25  procedure :: exg_calculate_delt
26  procedure :: exg_ot
27  procedure :: exg_fp
28  procedure :: exg_da
29  procedure :: connects_model
30  end type baseexchangetype
31 
32  abstract interface
33 
34  subroutine exg_df(this)
35  import baseexchangetype
36  class(baseexchangetype) :: this
37  end subroutine
38 
39  subroutine exg_ar(this)
40  import baseexchangetype
41  class(baseexchangetype) :: this
42  end subroutine
43 
44  end interface
45 
46 contains
47 
48  !> @brief Read and prepare
49  !<
50  subroutine exg_rp(this)
51  ! -- modules
52  use tdismodule, only: readnewdata
53  ! -- dummy
54  class(baseexchangetype) :: this
55  !
56  ! -- Check with TDIS on whether or not it is time to RP
57  if (.not. readnewdata) return
58  !
59  ! -- Nothing to do for RP
60  !
61  ! -- Return
62  return
63  end subroutine exg_rp
64 
65  !> @brief Calculate time step length
66  !<
67  subroutine exg_calculate_delt(this)
68  ! -- dummy
69  class(baseexchangetype) :: this
70  !
71  ! -- Nothing to do for TU
72  !
73  ! -- Return
74  return
75  end subroutine exg_calculate_delt
76 
77  !> @brief Run output routines
78  !<
79  subroutine exg_ot(this)
80  ! -- dummy
81  class(baseexchangetype) :: this
82  !
83  ! -- Return
84  return
85  end subroutine exg_ot
86 
87  !> @brief Final processing
88  !<
89  subroutine exg_fp(this)
90  ! -- dummy
91  class(baseexchangetype) :: this
92  !
93  ! -- Return
94  return
95  end subroutine exg_fp
96 
97  !> @brief Deallocate memory
98  !<
99  subroutine exg_da(this)
100  ! -- dummy
101  class(baseexchangetype) :: this
102  !
103  ! -- Return
104  return
105  end subroutine exg_da
106 
107  !> @brief Should return true when the exchange should be added to the
108  !! solution where the model resides
109  !<
110  function connects_model(this, model) result(is_connected)
111  ! -- dummy
112  class(baseexchangetype) :: this !< the instance of the exchange
113  class(basemodeltype), pointer, intent(in) :: model !< the model to which the exchange might hold a connection
114  ! -- return
115  logical(LGP) :: is_connected !< true, when connected
116  !
117  is_connected = .false.
118  !
119  ! -- Return
120  return
121  end function
122 
123  !> @brief Cast the object passed in as BaseExchangeType and return it
124  !<
125  function castasbaseexchangeclass(obj) result(res)
126  ! -- dummy
127  class(*), pointer, intent(inout) :: obj
128  ! -- return
129  class(baseexchangetype), pointer :: res
130  !
131  res => null()
132  if (.not. associated(obj)) return
133  !
134  select type (obj)
135  class is (baseexchangetype)
136  res => obj
137  end select
138  !
139  ! -- Return
140  return
141  end function castasbaseexchangeclass
142 
143  !> @brief Add the exchange object (BaseExchangeType) to a list
144  !<
145  subroutine addbaseexchangetolist(list, exchange)
146  ! -- dummy
147  type(listtype), intent(inout) :: list
148  class(baseexchangetype), pointer, intent(inout) :: exchange
149  ! -- local
150  class(*), pointer :: obj
151  !
152  obj => exchange
153  call list%Add(obj)
154  !
155  ! -- Return
156  return
157  end subroutine addbaseexchangetolist
158 
159  !> @brief Retrieve a specific BaseExchangeType object from a list
160  !<
161  function getbaseexchangefromlist(list, idx) result(res)
162  ! -- dummy
163  type(listtype), intent(inout) :: list
164  integer(I4B), intent(in) :: idx
165  class(baseexchangetype), pointer :: res
166  ! -- local
167  class(*), pointer :: obj
168  !
169  obj => list%GetItem(idx)
170  res => castasbaseexchangeclass(obj)
171  !
172  ! -- Return
173  return
174  end function getbaseexchangefromlist
175 
176 end module baseexchangemodule
subroutine exg_fp(this)
Final processing.
subroutine exg_da(this)
Deallocate memory.
subroutine exg_rp(this)
Read and prepare.
class(baseexchangetype) function, pointer, private castasbaseexchangeclass(obj)
Cast the object passed in as BaseExchangeType and return it.
logical(lgp) function connects_model(this, model)
Should return true when the exchange should be added to the solution where the model resides.
subroutine, public addbaseexchangetolist(list, exchange)
Add the exchange object (BaseExchangeType) to a list.
subroutine exg_calculate_delt(this)
Calculate time step length.
subroutine exg_ot(this)
Run output routines.
class(baseexchangetype) function, pointer, public getbaseexchangefromlist(list, idx)
Retrieve a specific BaseExchangeType object from a list.
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenexchangename
maximum length of the exchange name
Definition: Constants.f90:23
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:26
This module defines variable data types.
Definition: kind.f90:8
logical(lgp), pointer, public readnewdata
flag indicating time to read new data
Definition: tdis.f90:26
Highest level model type. All models extend this parent type.
Definition: BaseModel.f90:13
A generic heterogeneous doubly-linked list.
Definition: List.f90:10