MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
VirtualGweModel.f90
Go to the documentation of this file.
2  use kindmodule, only: i4b
8  implicit none
9  private
10 
11  public :: add_virtual_gwe_model
12 
14  ! CND
15  !type(VirtualIntType), pointer :: cnd_idiffc => null()
16  type(virtualinttype), pointer :: cnd_idisp => null()
17  !type(VirtualDbl1dType), pointer :: cnd_diffc => null()
18  type(virtualdbl1dtype), pointer :: cnd_alh => null()
19  type(virtualdbl1dtype), pointer :: cnd_alv => null()
20  type(virtualdbl1dtype), pointer :: cnd_ath1 => null()
21  type(virtualdbl1dtype), pointer :: cnd_ath2 => null()
22  type(virtualdbl1dtype), pointer :: cnd_atv => null()
23  type(virtualdbl1dtype), pointer :: cnd_ktw => null()
24  type(virtualdbl1dtype), pointer :: cnd_kts => null()
25  ! FMI
26  type(virtualdbl1dtype), pointer :: fmi_gwfhead => null()
27  type(virtualdbl1dtype), pointer :: fmi_gwfsat => null()
28  type(virtualdbl2dtype), pointer :: fmi_gwfspdis => null()
29  type(virtualdbl1dtype), pointer :: fmi_gwfflowja => null()
30  ! EST
31  type(virtualdbl1dtype), pointer :: est_porosity => null()
32  ! GWE Model fields
33  type(virtualinttype), pointer :: incnd => null()
34  type(virtualinttype), pointer :: inest => null()
35  contains
36  ! public
37  procedure :: create => vgwe_create
38  procedure :: prepare_stage => vgwe_prepare_stage
39  procedure :: destroy => vgwe_destroy
40  ! private
41  procedure, private :: init_virtual_data
42  procedure, private :: allocate_data
43  procedure, private :: deallocate_data
44  end type virtualgwemodeltype
45 
46 contains
47 
48  subroutine add_virtual_gwe_model(model_id, model_name, model)
50  integer(I4B) :: model_id !< global model id
51  character(len=*) :: model_name !< model name
52  class(numericalmodeltype), pointer :: model !< the actual model (can be null() when remote)
53  ! local
54  class(virtualgwemodeltype), pointer :: virtual_gwe_model
55  class(*), pointer :: obj
56 
57  allocate (virtual_gwe_model)
58  call virtual_gwe_model%create(model_name, model_id, model)
59 
60  obj => virtual_gwe_model
61  call virtual_model_list%Add(obj)
62 
63  end subroutine add_virtual_gwe_model
64 
65  subroutine vgwe_create(this, name, id, model)
66  class(virtualgwemodeltype) :: this
67  character(len=*) :: name
68  integer(I4B) :: id
69  class(numericalmodeltype), pointer :: model
70 
71  ! create base
72  call this%VirtualModelType%create(name, id, model)
73  this%container_type = vdc_gwemodel_type
74 
75  call this%allocate_data()
76  call this%init_virtual_data()
77 
78  end subroutine vgwe_create
79 
80  subroutine init_virtual_data(this)
81  class(virtualgwemodeltype) :: this
82 
83  !call this%set(this%cnd_idiffc%base(), 'IDIFFC', 'CND', MAP_ALL_TYPE)
84  call this%set(this%cnd_idisp%base(), 'IDISP', 'CND', map_all_type)
85  !call this%set(this%cnd_diffc%base(), 'DIFFC', 'CND', MAP_NODE_TYPE)
86  call this%set(this%cnd_alh%base(), 'ALH', 'CND', map_node_type)
87  call this%set(this%cnd_alv%base(), 'ALV', 'CND', map_node_type)
88  call this%set(this%cnd_ath1%base(), 'ATH1', 'CND', map_node_type)
89  call this%set(this%cnd_ath2%base(), 'ATH2', 'CND', map_node_type)
90  call this%set(this%cnd_atv%base(), 'ATV', 'CND', map_node_type)
91  call this%set(this%cnd_ktw%base(), 'KTW', 'CND', map_node_type)
92  call this%set(this%cnd_kts%base(), 'KTS', 'CND', map_node_type)
93  call this%set(this%fmi_gwfhead%base(), 'GWFHEAD', 'FMI', map_node_type)
94  call this%set(this%fmi_gwfsat%base(), 'GWFSAT', 'FMI', map_node_type)
95  call this%set(this%fmi_gwfspdis%base(), 'GWFSPDIS', 'FMI', map_node_type)
96  call this%set(this%fmi_gwfflowja%base(), 'GWFFLOWJA', 'FMI', map_conn_type)
97  call this%set(this%est_porosity%base(), 'POROSITY', 'EST', map_node_type)
98  call this%set(this%incnd%base(), 'INCND', '', map_all_type)
99  call this%set(this%inest%base(), 'INEST', '', map_all_type)
100 
101  end subroutine init_virtual_data
102 
103  subroutine vgwe_prepare_stage(this, stage)
104  class(virtualgwemodeltype) :: this
105  integer(I4B) :: stage
106  ! local
107  integer(I4B) :: nr_nodes, nr_conns
108 
109  ! prepare base (=numerical) model data items
110  call this%VirtualModelType%prepare_stage(stage)
111 
112  nr_nodes = 0
113  nr_conns = 0
114 
115  if (stage == stg_aft_mdl_df) then
116 
117  !call this%map(this%cnd_idiffc%base(), (/STG_AFT_MDL_DF/))
118  call this%map(this%cnd_idisp%base(), (/stg_aft_mdl_df/))
119  call this%map(this%incnd%base(), (/stg_aft_mdl_df/))
120  call this%map(this%inest%base(), (/stg_aft_mdl_df/))
121 
122  else if (stage == stg_bfr_con_ar) then
123 
124  nr_nodes = this%element_maps(map_node_type)%nr_virt_elems
125  nr_conns = this%element_maps(map_conn_type)%nr_virt_elems
126 
127  call this%map(this%x%base(), nr_nodes, &
129  call this%map(this%ibound%base(), nr_nodes, (/stg_bfr_con_ar/))
130 
131  !if (this%cnd_idiffc%get() > 0) then
132  ! call this%map(this%cnd_diffc%base(), nr_nodes, (/STG_BFR_CON_AR/))
133  !end if
134 
135  if (this%cnd_idisp%get() > 0) then
136  call this%map(this%cnd_alh%base(), nr_nodes, (/stg_bfr_con_ar/))
137  call this%map(this%cnd_alv%base(), nr_nodes, (/stg_bfr_con_ar/))
138  call this%map(this%cnd_ath1%base(), nr_nodes, (/stg_bfr_con_ar/))
139  call this%map(this%cnd_ath2%base(), nr_nodes, (/stg_bfr_con_ar/))
140  call this%map(this%cnd_atv%base(), nr_nodes, (/stg_bfr_con_ar/))
141  call this%map(this%cnd_ktw%base(), nr_nodes, (/stg_bfr_con_ar/))
142  call this%map(this%cnd_kts%base(), nr_nodes, (/stg_bfr_con_ar/))
143  end if
144 
145  call this%map(this%fmi_gwfhead%base(), nr_nodes, (/stg_bfr_exg_ad/))
146  call this%map(this%fmi_gwfsat%base(), nr_nodes, (/stg_bfr_exg_ad/))
147  call this%map(this%fmi_gwfspdis%base(), 3, nr_nodes, (/stg_bfr_exg_ad/))
148  call this%map(this%fmi_gwfflowja%base(), nr_conns, (/stg_bfr_exg_ad/))
149 
150  if (this%incnd%get() > 0 .and. this%inest%get() > 0) then
151  call this%map(this%est_porosity%base(), nr_nodes, (/stg_aft_con_ar/))
152  end if
153 
154  end if
155 
156  end subroutine vgwe_prepare_stage
157 
158  subroutine allocate_data(this)
159  class(virtualgwemodeltype) :: this
160 
161  !allocate (this%cnd_idiffc)
162  allocate (this%cnd_idisp)
163  !allocate (this%cnd_diffc)
164  allocate (this%cnd_alh)
165  allocate (this%cnd_alv)
166  allocate (this%cnd_ath1)
167  allocate (this%cnd_ath2)
168  allocate (this%cnd_atv)
169  allocate (this%cnd_ktw)
170  allocate (this%cnd_kts)
171  allocate (this%fmi_gwfhead)
172  allocate (this%fmi_gwfsat)
173  allocate (this%fmi_gwfspdis)
174  allocate (this%fmi_gwfflowja)
175  allocate (this%est_porosity)
176  allocate (this%incnd)
177  allocate (this%inest)
178 
179  end subroutine allocate_data
180 
181  subroutine deallocate_data(this)
182  class(virtualgwemodeltype) :: this
183 
184  !deallocate (this%cnd_idiffc)
185  deallocate (this%cnd_idisp)
186  !deallocate (this%cnd_diffc)
187  deallocate (this%cnd_alh)
188  deallocate (this%cnd_alv)
189  deallocate (this%cnd_ath1)
190  deallocate (this%cnd_ath2)
191  deallocate (this%cnd_atv)
192  deallocate (this%cnd_ktw)
193  deallocate (this%cnd_kts)
194  deallocate (this%fmi_gwfhead)
195  deallocate (this%fmi_gwfsat)
196  deallocate (this%fmi_gwfspdis)
197  deallocate (this%fmi_gwfflowja)
198  deallocate (this%est_porosity)
199  deallocate (this%incnd)
200  deallocate (this%inest)
201 
202  end subroutine deallocate_data
203 
204  subroutine vgwe_destroy(this)
205  class(virtualgwemodeltype) :: this
206 
207  call this%VirtualModelType%destroy()
208  call this%deallocate_data()
209 
210  end subroutine vgwe_destroy
211 
212 end module virtualgwemodelmodule
This module defines variable data types.
Definition: kind.f90:8
integer(i4b), parameter, public stg_aft_con_ar
afterr connection allocate read
Definition: SimStages.f90:18
integer(i4b), parameter, public stg_aft_mdl_df
after model define
Definition: SimStages.f90:11
integer(i4b), parameter, public stg_bfr_exg_ad
before exchange advance (per solution)
Definition: SimStages.f90:21
integer(i4b), parameter, public stg_bfr_exg_cf
before exchange calculate (per solution)
Definition: SimStages.f90:22
integer(i4b), parameter, public stg_bfr_con_ar
before connection allocate read
Definition: SimStages.f90:17
integer(i4b), parameter, public map_conn_type
Definition: VirtualBase.f90:15
integer(i4b), parameter, public map_all_type
Definition: VirtualBase.f90:13
integer(i4b), parameter, public map_node_type
Definition: VirtualBase.f90:14
integer(i4b), parameter, public vdc_gwemodel_type
type(listtype), public virtual_model_list
subroutine vgwe_prepare_stage(this, stage)
subroutine allocate_data(this)
subroutine vgwe_destroy(this)
subroutine, public add_virtual_gwe_model(model_id, model_name, model)
subroutine init_virtual_data(this)
subroutine vgwe_create(this, name, id, model)
subroutine deallocate_data(this)