MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
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_dt
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  end subroutine exg_rp
61 
62  !> @brief Calculate time step length
63  !<
64  subroutine exg_dt(this)
65  ! -- dummy
66  class(baseexchangetype) :: this
67  !
68  ! -- Nothing to do for TU
69  end subroutine exg_dt
70 
71  !> @brief Run output routines
72  !<
73  subroutine exg_ot(this)
74  ! -- dummy
75  class(baseexchangetype) :: this
76  end subroutine exg_ot
77 
78  !> @brief Final processing
79  !<
80  subroutine exg_fp(this)
81  ! -- dummy
82  class(baseexchangetype) :: this
83  end subroutine exg_fp
84 
85  !> @brief Deallocate memory
86  !<
87  subroutine exg_da(this)
88  ! -- dummy
89  class(baseexchangetype) :: this
90  end subroutine exg_da
91 
92  !> @brief Should return true when the exchange should be added to the
93  !! solution where the model resides
94  !<
95  function connects_model(this, model) result(is_connected)
96  ! -- dummy
97  class(baseexchangetype) :: this !< the instance of the exchange
98  class(basemodeltype), pointer, intent(in) :: model !< the model to which the exchange might hold a connection
99  ! -- return
100  logical(LGP) :: is_connected !< true, when connected
101  !
102  is_connected = .false.
103  end function
104 
105  !> @brief Cast the object passed in as BaseExchangeType and return it
106  !<
107  function castasbaseexchangeclass(obj) result(res)
108  ! -- dummy
109  class(*), pointer, intent(inout) :: obj
110  ! -- return
111  class(baseexchangetype), pointer :: res
112  !
113  res => null()
114  if (.not. associated(obj)) return
115  !
116  select type (obj)
117  class is (baseexchangetype)
118  res => obj
119  end select
120  end function castasbaseexchangeclass
121 
122  !> @brief Add the exchange object (BaseExchangeType) to a list
123  !<
124  subroutine addbaseexchangetolist(list, exchange)
125  ! -- dummy
126  type(listtype), intent(inout) :: list
127  class(baseexchangetype), pointer, intent(inout) :: exchange
128  ! -- local
129  class(*), pointer :: obj
130  !
131  obj => exchange
132  call list%Add(obj)
133  end subroutine addbaseexchangetolist
134 
135  !> @brief Retrieve a specific BaseExchangeType object from a list
136  !<
137  function getbaseexchangefromlist(list, idx) result(res)
138  ! -- dummy
139  type(listtype), intent(inout) :: list
140  integer(I4B), intent(in) :: idx
141  class(baseexchangetype), pointer :: res
142  ! -- local
143  class(*), pointer :: obj
144  !
145  obj => list%GetItem(idx)
146  res => castasbaseexchangeclass(obj)
147  end function getbaseexchangefromlist
148 
149 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_ot(this)
Run output routines.
subroutine exg_dt(this)
Calculate time step length.
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:24
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:27
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:14