(new) Run a new FOF loop over the particles this time on the attachable and find their nearest linkable. Record the distance for this and assign the linkable's groupID to the attachable.
At this stage each particle knows which group it is in.
Allocate arrays on each node to collect all the group info by looping over every particle.
All-reduce these arrays.
If needed, seed black holes.
As all nodes now have all the info about every group, simplify the i/o and have only rank 0 dump the file.