180 class(MpiRunControlType) :: this
182 integer(I4B) :: i, j, id, irank
183 integer(I4B) :: nr_models, nr_exgs, nr_remotes, max_nr_remotes
184 type(STLVecInt) :: remote_models, remote_exgs
185 integer(I4B),
dimension(:, :),
pointer :: remote_models_per_process
186 integer(I4B),
dimension(:, :),
pointer :: remote_exgs_per_process
187 class(VirtualModelType),
pointer :: vm
188 class(VirtualExchangeType),
pointer :: ve
189 type(MpiWorldType),
pointer :: mpi_world
192 mpi_world => get_mpi_world()
195 call this%RunControlType%after_con_cr()
198 call remote_models%init()
202 if (vm%is_active .and. .not. vm%is_local)
then
204 call remote_models%push_back(vm%id)
207 call remote_exgs%init()
211 if (ve%is_active .and. .not. ve%is_local)
then
213 call remote_exgs%push_back(ve%id)
218 nr_remotes = remote_models%size
219 call mpi_allreduce(nr_remotes, max_nr_remotes, 1, mpi_integer, mpi_max, &
220 mpi_world%comm, ierr)
223 allocate (remote_models_per_process(max_nr_remotes, nr_procs))
224 remote_models_per_process = 0
227 do i = 1, remote_models%size
228 remote_models_per_process(i, proc_id + 1) = remote_models%at(i)
230 call mpi_allreduce(mpi_in_place, remote_models_per_process, &
231 max_nr_remotes * nr_procs, mpi_integer, mpi_max, &
232 mpi_world%comm, ierr)
237 do j = 1, max_nr_remotes
238 id = remote_models_per_process(j, i)
242 if (vm%is_local)
then
245 call vm%rcv_ranks%push_back_unique(irank)
252 nr_remotes = remote_exgs%size
253 call mpi_allreduce(nr_remotes, max_nr_remotes, 1, mpi_integer, mpi_max, &
254 mpi_world%comm, ierr)
257 allocate (remote_exgs_per_process(max_nr_remotes, nr_procs))
258 remote_exgs_per_process = 0
261 do i = 1, remote_exgs%size
262 remote_exgs_per_process(i, proc_id + 1) = remote_exgs%at(i)
264 call mpi_allreduce(mpi_in_place, remote_exgs_per_process, &
265 max_nr_remotes * nr_procs, mpi_integer, mpi_max, &
266 mpi_world%comm, ierr)
271 do j = 1, max_nr_remotes
272 id = remote_exgs_per_process(j, i)
276 if (ve%is_local)
then
279 call ve%rcv_ranks%push_back_unique(irank)
286 call remote_models%destroy()
287 call remote_exgs%destroy()
289 deallocate (remote_models_per_process)
290 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...