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
97 character(len=*) :: name
99 logical(LGP) :: is_local
105 this%is_local = is_local
106 this%vmem_ctx =
'undefined'
108 this%is_active = .true.
111 do i = 1,
size(this%element_maps)
112 this%element_maps(i)%nr_virt_elems = 0
113 this%element_maps(i)%remote_elem_shift => null()
115 do i = 1,
size(this%element_luts)
116 this%element_luts(i)%max_remote_idx = 0
117 this%element_luts(i)%remote_to_virtual => null()
120 call this%rcv_ranks%init()
126 subroutine set(this, field, var_name, subcmp_name, map_id, is_local)
129 character(len=*) :: var_name
130 character(len=*) :: subcmp_name
131 integer(I4B) :: map_id
132 logical(LGP),
optional :: is_local
134 field%is_remote = .not. this%is_local
135 field%map_type = map_id
136 if (
present(is_local)) field%is_remote = .not. is_local
137 field%var_name = var_name
138 field%subcmp_name = subcmp_name
139 if (subcmp_name ==
'')
then
144 field%is_reduced = (field%is_remote .and. field%map_type > 0)
145 field%remote_elem_shift => null()
146 field%remote_to_virtual => null()
147 field%virtual_mt => null()
148 call this%add_to_list(field)
156 class(*),
pointer :: vdata_ptr
158 vdata_ptr => virtual_data
159 call this%virtual_data_list%Add(vdata_ptr)
166 integer(I4B) :: stage
168 write (*, *)
'Error: prepare_stage should be overridden'
177 integer(I4B) :: stage
180 class(*),
pointer :: vdi
182 do i = 1, this%virtual_data_list%Count()
183 vdi => this%virtual_data_list%GetItem(i)
186 if (vdi%is_remote) cycle
187 if (vdi%check_stage(stage))
call vdi%link()
198 integer(I4B),
dimension(:),
pointer,
contiguous :: src_indexes
199 integer(I4B) :: map_id
201 integer(I4B) :: i, idx_remote, max_remote_idx
203 if (this%element_maps(map_id)%nr_virt_elems > 0)
then
204 write (*, *)
"Error, VDC element map already set"
208 this%element_maps(map_id)%nr_virt_elems =
size(src_indexes)
209 allocate (this%element_maps(map_id)%remote_elem_shift(
size(src_indexes)))
210 do i = 1,
size(src_indexes)
211 this%element_maps(map_id)%remote_elem_shift(i) = src_indexes(i) - 1
214 max_remote_idx = maxval(src_indexes)
215 this%element_luts(map_id)%max_remote_idx = max_remote_idx
216 allocate (this%element_luts(map_id)%remote_to_virtual(max_remote_idx))
217 do i = 1, max_remote_idx
218 this%element_luts(map_id)%remote_to_virtual(i) = -1
220 do i = 1,
size(src_indexes)
221 idx_remote = src_indexes(i)
222 this%element_luts(map_id)%remote_to_virtual(idx_remote) = i
230 integer(I4B),
dimension(:) :: stages
232 call this%map_internal(vd, (/0/), stages)
240 integer(I4B),
dimension(:) :: stages
242 call this%map_internal(vd, (/nrow/), stages)
251 integer(I4B),
dimension(:) :: stages
253 call this%map_internal(vd, (/ncol, nrow/), stages)
260 integer(I4B),
dimension(:) :: shape
261 integer(I4B),
dimension(:) :: stages
263 character(len=LENMEMPATH) :: vm_pth
264 logical(LGP) :: found
266 vd%sync_stages = stages
267 if (vd%is_remote)
then
269 vm_pth = this%get_vrt_mem_path(vd%var_name, vd%subcmp_name)
270 call vd%vm_allocate(vd%var_name, vm_pth, shape)
272 if (vd%map_type > 0)
then
273 vd%remote_to_virtual => this%element_luts(vd%map_type)%remote_to_virtual
274 vd%remote_elem_shift => this%element_maps(vd%map_type)%remote_elem_shift
284 integer(I4B) :: stage
288 call this%get_items_for_stage(stage, virtual_items)
296 integer(I4B) :: stage
300 call this%get_items_for_stage(stage, virtual_items)
306 integer(I4B) :: stage
310 class(*),
pointer :: obj_ptr
312 do i = 1, this%virtual_data_list%Count()
313 obj_ptr => this%virtual_data_list%GetItem(i)
314 select type (obj_ptr)
316 if (.not. obj_ptr%check_stage(stage)) cycle
317 call virtual_items%push_back(i)
331 write (imon, *)
"=====> items"
334 write (imon, *) vdi%var_name,
":", vdi%mem_path
336 if (items%size == 0)
then
337 write (imon, *)
"... empty ...", this%name
339 write (imon, *)
"<===== items"
347 character(len=*) :: var_name
348 character(len=*) :: subcomp_name
349 character(len=LENMEMPATH) :: vrt_path
353 vdi => this%vdc_get_virtual_data(var_name, subcomp_name)
354 if (vdi%is_remote)
then
355 if (subcomp_name ==
'')
then
358 vrt_path =
create_mem_path(this%name, subcomp_name, context=this%vmem_ctx)
361 if (subcomp_name ==
'')
then
373 character(len=*) :: var_name
374 character(len=*) :: subcomp_name
380 virtual_data => null()
381 do i = 1, this%virtual_data_list%Count()
383 if (vd%var_name == var_name .and. &
384 vd%subcmp_name == subcomp_name)
then
390 write (*, *)
'Error: unknown virtual variable ', var_name,
' ', subcomp_name
399 class(*),
pointer :: obj
401 call this%rcv_ranks%destroy()
403 do i = 1,
size(this%element_maps)
404 if (
associated(this%element_maps(i)%remote_elem_shift))
then
405 deallocate (this%element_maps(i)%remote_elem_shift)
408 do i = 1,
size(this%element_luts)
409 if (
associated(this%element_luts(i)%remote_to_virtual))
then
410 deallocate (this%element_luts(i)%remote_to_virtual)
414 do i = 1, this%virtual_data_list%Count()
415 obj => this%virtual_data_list%GetItem(i)
418 if (
associated(obj%virtual_mt))
then
419 call obj%vm_deallocate()
423 call this%virtual_data_list%Clear()
431 this%orig_rank = rank
432 write (this%vmem_ctx,
'(a,i0,a)')
'__P', rank,
'__'
441 class(*),
pointer :: obj_ptr
444 obj_ptr => list%GetItem(idx)
445 select type (obj_ptr)
455 integer(I4B) :: cntr_type
456 character(len=24) :: cntr_str
468 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 vdc_get_recv_items(this, stage, rank, virtual_items)
Get indexes of virtual data items to be.
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 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 vdc_get_send_items(this, stage, rank, virtual_items)
Get indexes of virtual data items to be.
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)
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.