37 integer(I4B) :: nr_virt_elems
38 integer(I4B),
dimension(:),
pointer,
contiguous :: remote_elem_shift => null()
42 integer(I4B) :: max_remote_idx
43 integer(I4B),
dimension(:),
pointer,
contiguous :: remote_to_virtual => null()
55 integer(I4B) :: container_type
56 character(LENCOMPONENTNAME) :: name
57 character(LENCONTEXTNAME) :: vmem_ctx
58 logical(LGP) :: is_local
60 logical(LGP) :: is_active
61 integer(I4B) :: orig_rank
99 character(len=*) :: name
101 logical(LGP) :: is_local
107 this%is_local = is_local
108 this%vmem_ctx =
'undefined'
110 this%is_active = .true.
113 do i = 1,
size(this%element_maps)
114 this%element_maps(i)%nr_virt_elems = 0
115 this%element_maps(i)%remote_elem_shift => null()
117 do i = 1,
size(this%element_luts)
118 this%element_luts(i)%max_remote_idx = 0
119 this%element_luts(i)%remote_to_virtual => null()
122 call this%rcv_ranks%init()
128 subroutine set(this, field, var_name, subcmp_name, map_id, is_local)
131 character(len=*) :: var_name
132 character(len=*) :: subcmp_name
133 integer(I4B) :: map_id
134 logical(LGP),
optional :: is_local
136 field%is_remote = .not. this%is_local
137 field%map_type = map_id
138 if (
present(is_local)) field%is_remote = .not. is_local
139 field%var_name = var_name
140 field%subcmp_name = subcmp_name
141 if (subcmp_name ==
'')
then
146 field%is_reduced = (field%is_remote .and. field%map_type > 0)
147 field%remote_elem_shift => null()
148 field%remote_to_virtual => null()
149 field%virtual_mt => null()
150 call this%add_to_list(field)
158 class(*),
pointer :: vdata_ptr
160 vdata_ptr => virtual_data
161 call this%virtual_data_list%Add(vdata_ptr)
168 integer(I4B) :: stage
170 write (*, *)
'Error: prepare_stage should be overridden'
179 integer(I4B) :: stage
182 class(*),
pointer :: vdi
184 do i = 1, this%virtual_data_list%Count()
185 vdi => this%virtual_data_list%GetItem(i)
188 if (vdi%is_remote) cycle
189 if (vdi%check_stage(stage))
call vdi%link()
200 integer(I4B),
dimension(:),
pointer,
contiguous :: src_indexes
201 integer(I4B) :: map_id
203 integer(I4B) :: i, idx_remote, max_remote_idx
205 if (this%element_maps(map_id)%nr_virt_elems > 0)
then
206 write (*, *)
"Error, VDC element map already set"
210 this%element_maps(map_id)%nr_virt_elems =
size(src_indexes)
211 allocate (this%element_maps(map_id)%remote_elem_shift(
size(src_indexes)))
212 do i = 1,
size(src_indexes)
213 this%element_maps(map_id)%remote_elem_shift(i) = src_indexes(i) - 1
216 max_remote_idx = maxval(src_indexes)
217 this%element_luts(map_id)%max_remote_idx = max_remote_idx
218 allocate (this%element_luts(map_id)%remote_to_virtual(max_remote_idx))
219 do i = 1, max_remote_idx
220 this%element_luts(map_id)%remote_to_virtual(i) = -1
222 do i = 1,
size(src_indexes)
223 idx_remote = src_indexes(i)
224 this%element_luts(map_id)%remote_to_virtual(idx_remote) = i
232 integer(I4B),
dimension(:) :: stages
234 call this%map_internal(vd, (/0/), stages)
242 integer(I4B),
dimension(:) :: stages
244 call this%map_internal(vd, (/nrow/), stages)
253 integer(I4B),
dimension(:) :: stages
255 call this%map_internal(vd, (/ncol, nrow/), stages)
262 integer(I4B),
dimension(:) :: shape
263 integer(I4B),
dimension(:) :: stages
265 character(len=LENMEMPATH) :: vm_pth
266 logical(LGP) :: found
268 vd%sync_stages = stages
269 if (vd%is_remote)
then
271 vm_pth = this%get_vrt_mem_path(vd%var_name, vd%subcmp_name)
272 call vd%vm_allocate(vd%var_name, vm_pth, shape)
274 if (vd%map_type > 0)
then
275 vd%remote_to_virtual => this%element_luts(vd%map_type)%remote_to_virtual
276 vd%remote_elem_shift => this%element_maps(vd%map_type)%remote_elem_shift
290 call this%get_items_for_stage(stg, vi)
302 call this%get_items_for_stage(stg, vi)
308 integer(I4B) :: stage
312 class(*),
pointer :: obj_ptr
314 do i = 1, this%virtual_data_list%Count()
315 obj_ptr => this%virtual_data_list%GetItem(i)
316 select type (obj_ptr)
318 if (.not. obj_ptr%check_stage(stage)) cycle
319 call virtual_items%push_back(i)
333 write (imon, *)
"=====> items"
336 write (imon, *) vdi%var_name,
":", vdi%mem_path
338 if (items%size == 0)
then
339 write (imon, *)
"... empty ...", this%name
341 write (imon, *)
"<===== items"
349 character(len=*) :: var_name
350 character(len=*) :: subcomp_name
351 character(len=LENMEMPATH) :: vrt_path
355 vdi => this%vdc_get_virtual_data(var_name, subcomp_name)
356 if (vdi%is_remote)
then
357 if (subcomp_name ==
'')
then
360 vrt_path =
create_mem_path(this%name, subcomp_name, context=this%vmem_ctx)
363 if (subcomp_name ==
'')
then
375 character(len=*) :: var_name
376 character(len=*) :: subcomp_name
382 virtual_data => null()
383 do i = 1, this%virtual_data_list%Count()
385 if (vd%var_name == var_name .and. &
386 vd%subcmp_name == subcomp_name)
then
392 write (*, *)
'Error: unknown virtual variable ', var_name,
' ', subcomp_name
401 class(*),
pointer :: obj
403 call this%rcv_ranks%destroy()
405 do i = 1,
size(this%element_maps)
406 if (
associated(this%element_maps(i)%remote_elem_shift))
then
407 deallocate (this%element_maps(i)%remote_elem_shift)
410 do i = 1,
size(this%element_luts)
411 if (
associated(this%element_luts(i)%remote_to_virtual))
then
412 deallocate (this%element_luts(i)%remote_to_virtual)
416 do i = 1, this%virtual_data_list%Count()
417 obj => this%virtual_data_list%GetItem(i)
420 if (
associated(obj%virtual_mt))
then
421 call obj%vm_deallocate()
425 call this%virtual_data_list%Clear()
433 this%orig_rank = rank
434 write (this%vmem_ctx,
'(a,i0,a)')
'__P', rank,
'__'
443 class(*),
pointer :: obj_ptr
446 obj_ptr => list%GetItem(idx)
447 select type (obj_ptr)
457 integer(I4B) :: cntr_type
458 character(len=24) :: cntr_str
470 else; cntr_str =
"Undefined"
This module contains simulation constants.
integer(i4b), parameter lencomponentname
maximum length of a component name
integer(i4b), parameter lencontextname
maximum length of a memory manager context
integer(i4b), parameter lenmempath
maximum length of the memory path
This module defines variable data types.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public get_from_memorystore(name, mem_path, mt, found, check)
@ brief Get a memory type entry from the memory list
This module contains simulation methods.
subroutine, public ustop(stopmess, ioutlocal)
Stop the simulation.
class(virtualdatatype) function, pointer, public get_virtual_data_from_list(list, idx)
class(virtualdatatype) function, pointer vdc_get_virtual_data(this, var_name, subcomp_name)
integer(i4b), parameter, public vdc_gwtmodel_type
subroutine vdc_create(this, name, id, is_local)
integer(i4b), parameter, public vdc_gwtmvt_type
subroutine map_internal(this, vd, shape, stages)
subroutine set(this, field, var_name, subcmp_name, map_id, is_local)
Init virtual data item, without allocation,.
integer(i4b), parameter, public vdc_gwemodel_type
character(len=24) function, public vdc_type_to_str(cntr_type)
@ Converts a virtual container type to its string representation
subroutine map_array2d(this, vd, ncol, nrow, stages)
subroutine vdc_link_items(this, stage)
Link all local data items to memory.
subroutine vdc_get_recv_items(this, stg, rank, vi)
Get indexes of virtual data items to be.
subroutine map_scalar(this, vd, stages)
subroutine vdc_set_element_map(this, src_indexes, map_id)
Add the source indexes associated with map_id as a element map to this container, such that.
subroutine add_to_list(this, virtual_data)
integer(i4b), parameter, public vdc_gwfmvr_type
integer(i4b), parameter, public vdc_unknown_type
character(len=lenmempath) function vdc_get_vrt_mem_path(this, var_name, subcomp_name)
Get virtual memory path for a certain variable.
subroutine vdc_set_orig_rank(this, rank)
integer(i4b), parameter, public vdc_gwemve_type
of VdcPtrType instead.
subroutine vdc_prepare_stage(this, stage)
subroutine vdc_get_send_items(this, stg, rank, vi)
Get indexes of virtual data items to be.
integer(i4b), parameter, public vdc_gwfmodel_type
subroutine print_items(this, imon, items)
subroutine vdc_destroy(this)
integer(i4b), parameter, public vdc_gwtexg_type
class(virtualdatacontainertype) function, pointer, public get_vdc_from_list(list, idx)
subroutine map_array1d(this, vd, nrow, stages)
integer(i4b), parameter, public vdc_gwfexg_type
integer(i4b), parameter, public vdc_gweexg_type
subroutine get_items_for_stage(this, stage, virtual_items)
A generic heterogeneous doubly-linked list.
This is a generic data structure to virtualize pieces of memory in 2 distinct ways:
Wrapper for virtual data containers.
Container (list) of virtual data items.