54 character(len=LENMEMPATH) :: virt_mem_path, local_mem_path
59 if (.not. virt_exg%v_model1%is_local)
then
60 virt_mem_path = virt_exg%get_vrt_mem_path(
'NODEM1',
'')
61 call this%map_data_full(0,
'NODEM1', conn%prim_exchange%memoryPath, &
65 if (virt_exg%has_mover())
then
67 virt_mem_path = virt_exg%get_vrt_mem_path(
'QPACTUAL_M1',
'MVR')
68 call this%map_data_full(conn%owner%idsoln,
'QPACTUAL_M1', &
69 local_mem_path,
'QPACTUAL_M1', &
71 virt_mem_path = virt_exg%get_vrt_mem_path(
'QAVAILABLE_M1',
'MVR')
72 call this%map_data_full(conn%owner%idsoln,
'QAVAILABLE_M1', &
73 local_mem_path,
'QAVAILABLE_M1', &
75 virt_mem_path = virt_exg%get_vrt_mem_path(
'ID_MAPPED_M1',
'MVR')
76 call this%map_data_full(conn%owner%idsoln,
'ID_MAPPED_M1', &
77 local_mem_path,
'ID_MAPPED_M1', &
81 if (.not. virt_exg%v_model2%is_local)
then
82 virt_mem_path = virt_exg%get_vrt_mem_path(
'NODEM2',
'')
83 call this%map_data_full(0,
'NODEM2', conn%prim_exchange%memoryPath, &
87 if (virt_exg%has_mover())
then
89 virt_mem_path = virt_exg%get_vrt_mem_path(
'QPACTUAL_M2',
'MVR')
90 call this%map_data_full(conn%owner%idsoln,
'QPACTUAL_M2', &
91 local_mem_path,
'QPACTUAL_M2', &
93 virt_mem_path = virt_exg%get_vrt_mem_path(
'QAVAILABLE_M2',
'MVR')
94 call this%map_data_full(conn%owner%idsoln,
'QAVAILABLE_M2', &
95 local_mem_path,
'QAVAILABLE_M2', &
97 virt_mem_path = virt_exg%get_vrt_mem_path(
'ID_MAPPED_M2',
'MVR')
98 call this%map_data_full(conn%owner%idsoln,
'ID_MAPPED_M2', &
99 local_mem_path,
'ID_MAPPED_M2', &
115 integer(I4B) :: iconn
121 call this%add_dist_vars(conn%owner%idsoln, &
122 conn%iface_dist_vars, &
130 integer(I4B) :: sol_id
134 integer(I4B) :: i, m, e
138 do i = 1, var_list%Count()
140 if (dist_var%map_type ==
sync_nds .or. &
142 do m = 1, iface_map%nr_models
143 call this%map_model_data(sol_id, iface_map, m, dist_var)
145 else if (dist_var%map_type ==
sync_exg)
then
146 do e = 1, iface_map%nr_exchanges
147 call this%map_exg_data(sol_id, iface_map, e, dist_var)
162 integer(I4B) :: sol_id
164 integer(I4B) :: model_idx
167 character(len=LENVARNAME) :: src_var_name
168 character(len=LENMEMPATH) :: src_mem_path, tgt_mem_path
171 integer(I4B),
dimension(:),
pointer,
contiguous :: lookup_table
175 vd => v_model%get_virtual_data(dist_var%var_name, dist_var%subcomp_name)
179 lookup_table => null()
180 if (dist_var%map_type ==
sync_nds)
then
181 idx_map => iface_map%node_maps(model_idx)
182 if (vd%is_reduced)
then
183 lookup_table => v_model%element_luts(
map_node_type)%remote_to_virtual
185 else if (dist_var%map_type ==
sync_con)
then
186 idx_map => iface_map%conn_maps(model_idx)
187 if (vd%is_reduced)
then
188 lookup_table => v_model%element_luts(
map_conn_type)%remote_to_virtual
191 write (*, *)
"Unknown map type for distributed variable ", dist_var%var_name
195 if (len_trim(dist_var%subcomp_name) > 0)
then
196 tgt_mem_path =
create_mem_path(dist_var%comp_name, dist_var%subcomp_name)
201 src_var_name = dist_var%var_name
202 src_mem_path = v_model%get_vrt_mem_path(src_var_name, dist_var%subcomp_name)
203 call this%map_data(sol_id, &
204 src_var_name, tgt_mem_path, idx_map%tgt_idx, &
205 src_var_name, src_mem_path, idx_map%src_idx, &
206 null(), lookup_table, dist_var%sync_stages)
214 integer(I4B) :: sol_id
216 integer(I4B),
intent(in) :: exg_idx
219 character(len=LENMEMPATH) :: src_mem_path, tgt_mem_path
225 idx_map => iface_map%exchange_maps(exg_idx)
227 if (len_trim(dist_var%subcomp_name) > 0)
then
228 tgt_mem_path =
create_mem_path(dist_var%comp_name, dist_var%subcomp_name)
233 src_mem_path = v_exchange%get_vrt_mem_path(dist_var%exg_var_name,
'')
234 call this%map_data(sol_id, &
235 dist_var%var_name, tgt_mem_path, idx_map%tgt_idx, &
236 dist_var%exg_var_name, src_mem_path, idx_map%src_idx, &
237 idx_map%sign, null(), dist_var%sync_stages)
243 src_name, src_path, stages)
245 integer(I4B) :: controller_id
246 character(len=*),
intent(in) :: tgt_name
247 character(len=*),
intent(in) :: tgt_path
248 character(len=*),
intent(in) :: src_name
249 character(len=*),
intent(in) :: src_path
250 integer(I4B),
dimension(:),
intent(in) :: stages
252 call this%map_data(controller_id, tgt_name, tgt_path, null(), &
253 src_name, src_path, null(), &
254 null(), null(), stages)
260 subroutine map_data(this, controller_id, tgt_name, tgt_path, tgt_idx, &
261 src_name, src_path, src_idx, sign_array, &
262 lookup_table, stages)
264 integer(I4B) :: controller_id
265 character(len=*),
intent(in) :: tgt_name
266 character(len=*),
intent(in) :: tgt_path
267 integer(I4B),
dimension(:),
pointer :: tgt_idx
268 character(len=*),
intent(in) :: src_name
269 character(len=*),
intent(in) :: src_path
270 integer(I4B),
dimension(:),
pointer :: src_idx
271 integer(I4B),
dimension(:),
pointer :: sign_array
272 integer(I4B),
dimension(:),
pointer :: lookup_table
273 integer(I4B),
dimension(:),
intent(in) :: stages
275 integer(I4B) :: istage, i
277 class(*),
pointer :: obj
281 do i = 1,
size(stages)
282 istage = ibset(istage, stages(i))
286 allocate (mapped_data)
287 mapped_data%controller_id = controller_id
288 mapped_data%sync_stage = istage
289 mapped_data%src_name = src_name
290 mapped_data%src_path = src_path
291 mapped_data%src => null()
292 mapped_data%tgt_name = tgt_name
293 mapped_data%tgt_path = tgt_path
294 mapped_data%tgt => null()
295 mapped_data%copy_all = .not.
associated(src_idx)
296 mapped_data%src_idx => src_idx
297 mapped_data%tgt_idx => tgt_idx
298 mapped_data%sign => sign_array
299 mapped_data%lut => lookup_table
301 call this%mapped_data_list%Add(obj)
307 subroutine scatter(this, controller_id, stage)
309 integer(I4B) :: controller_id
310 integer(I4B),
intent(in) :: stage
313 class(*),
pointer :: obj
317 do i = 1, this%mapped_data_list%Count()
318 obj => this%mapped_data_list%GetItem(i)
320 if (controller_id > 0 .and. &
321 mapped_data%controller_id /= controller_id) cycle
322 if (.not.
check_stage(mapped_data%sync_stage, stage)) cycle
325 call mapped_data%sync()
331 integer(I4B) :: var_stage
332 integer(I4B) :: current_stage
333 logical(LGP) :: is_sync
335 is_sync = iand(var_stage, ibset(0, current_stage)) == ibset(0, current_stage)
342 call this%mapped_data_list%Clear(
destroy=.true.)
This module contains simulation constants.
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenmempath
maximum length of the memory path
class(distvartype) function, pointer, public getdistvarfromlist(list, idx)
integer(i4b), parameter, public sync_nds
synchronize over nodes
integer(i4b), parameter, public sync_exg
synchronize as exchange variable
integer(i4b), parameter, public sync_con
synchronize over connections
subroutine init(this, nr_models, nr_exchanges)
This module defines variable data types.
type(listtype), public baseconnectionlist
class(mappedmemorytype) function, pointer, public castasmappeddata(obj)
subroutine map_data(this, controller_id, tgt_name, tgt_path, tgt_idx, src_name, src_path, src_idx, sign_array, lookup_table, stages)
Generic mapping between two variables in memory, using.
subroutine map_model_data(this, sol_id, iface_map, model_idx, dist_var)
Map data from model memory to a target memory entry, with the specified map. The source and target it...
subroutine map_exg_data(this, sol_id, iface_map, exg_idx, dist_var)
Map memory from a Exchange to the specified memory entry,.
subroutine add_dist_vars(this, sol_id, var_list, iface_map)
subroutine add_interface_vars(this)
Add distributed interface variables as memory mapped items.
subroutine add_exchange_vars(this)
Add virtual exchange variables.
logical(lgp) function check_stage(var_stage, current_stage)
subroutine map_data_full(this, controller_id, tgt_name, tgt_path, src_name, src_path, stages)
Full copy between two variables in memory.
subroutine scatter(this, controller_id, stage)
Scatter the mapped memory, typically into.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains simulation methods.
subroutine, public ustop(stopmess, ioutlocal)
Stop the simulation.
integer(i4b), parameter, public stg_bfr_exg_fc
before exchange formulate (per solution)
integer(i4b), parameter, public stg_aft_con_rp
after connection read prepare
integer(i4b), parameter, public stg_bfr_con_df
before connection define
class(spatialmodelconnectiontype) function, pointer, public get_smc_from_list(list, idx)
Get the connection from a list.
integer(i4b), parameter, public map_conn_type
integer(i4b), parameter, public map_node_type
class(virtualexchangetype) function, pointer, public get_virtual_exchange(exg_id)
Returns a virtual exchange with the specified id.
A generic heterogeneous doubly-linked list.
Class to manage spatial connection of a model to one or more models of the same type....
This is a generic data structure to virtualize pieces of memory in 2 distinct ways:
The Virtual Exchange is based on two Virtual Models and is therefore not always strictly local or rem...