160 class(MpiRunControlType) :: this
162 integer(I4B) :: i, j, id, irank
163 integer(I4B) :: nr_models, nr_exgs, nr_remotes, max_nr_remotes
164 type(STLVecInt) :: remote_models, remote_exgs
165 integer(I4B),
dimension(:, :),
pointer :: remote_models_per_process
166 integer(I4B),
dimension(:, :),
pointer :: remote_exgs_per_process
167 class(VirtualModelType),
pointer :: vm
168 class(VirtualExchangeType),
pointer :: ve
169 type(MpiWorldType),
pointer :: mpi_world
172 mpi_world => get_mpi_world()
175 call this%RunControlType%after_con_cr()
178 call remote_models%init()
182 if (vm%is_active .and. .not. vm%is_local)
then
184 call remote_models%push_back(vm%id)
187 call remote_exgs%init()
191 if (ve%is_active .and. .not. ve%is_local)
then
193 call remote_exgs%push_back(ve%id)
198 nr_remotes = remote_models%size
199 call mpi_allreduce(nr_remotes, max_nr_remotes, 1, mpi_integer, mpi_max, &
200 mpi_world%comm, ierr)
203 allocate (remote_models_per_process(max_nr_remotes, nr_procs))
204 remote_models_per_process = 0
207 do i = 1, remote_models%size
208 remote_models_per_process(i, proc_id + 1) = remote_models%at(i)
210 call mpi_allreduce(mpi_in_place, remote_models_per_process, &
211 max_nr_remotes * nr_procs, mpi_integer, mpi_max, &
212 mpi_world%comm, ierr)
217 do j = 1, max_nr_remotes
218 id = remote_models_per_process(j, i)
222 if (vm%is_local)
then
225 call vm%rcv_ranks%push_back_unique(irank)
232 nr_remotes = remote_exgs%size
233 call mpi_allreduce(nr_remotes, max_nr_remotes, 1, mpi_integer, mpi_max, &
234 mpi_world%comm, ierr)
237 allocate (remote_exgs_per_process(max_nr_remotes, nr_procs))
238 remote_exgs_per_process = 0
241 do i = 1, remote_exgs%size
242 remote_exgs_per_process(i, proc_id + 1) = remote_exgs%at(i)
244 call mpi_allreduce(mpi_in_place, remote_exgs_per_process, &
245 max_nr_remotes * nr_procs, mpi_integer, mpi_max, &
246 mpi_world%comm, ierr)
251 do j = 1, max_nr_remotes
252 id = remote_exgs_per_process(j, i)
256 if (ve%is_local)
then
259 call ve%rcv_ranks%push_back_unique(irank)
266 call remote_models%destroy()
267 call remote_exgs%destroy()
269 deallocate (remote_models_per_process)
270 deallocate (remote_exgs_per_process)
type(listtype), public virtual_model_list
type(listtype), public virtual_exchange_list
class(virtualexchangetype) function, pointer, public get_virtual_exchange_from_list(list, idx)
class(virtualexchangetype) function, pointer, public get_virtual_exchange(exg_id)
Returns a virtual exchange with the specified id.
class(virtualmodeltype) function, pointer, public get_virtual_model_from_list(model_list, idx)
The Virtual Exchange is based on two Virtual Models and is therefore not always strictly local or rem...