Gathering positions of small subset of atoms with mpi

I want to gather the positions {x,y,z} of ~600 atoms (out of >1M) by tag located around multiple unknown mpi ranks.

Is this a job for Irregular?

Basically my parallel algorithm is something like this:

  • rank 0 broadcasts to all ranks the atom tags im looking for

  • all the mpi ranks fill a 600x3 array on rank 0 with the x y z of each selected atom sorted by tag

This has to be super fast because it happens at every timestep.

What would the mpi code look like ? How to avoid all the ranks clobbering each other in the array on rank 0 ?

Please have a look at how gather_atoms_subset() is implemented in the library interface.