printf(">>> local (%d) i=%d Task=%d Head=%d \n",ThisTask,i,TopTSfrGroups_local[i].Task,TopTSfrGroups_local[i].Head);
if (ThisTask==0)
for (i=0;i<Tot_Ntsfrgroups;i++)
printf(">>> global (%d) i=%d Task=%d Head=%d \n",ThisTask,i,TopTSfrGroups[i].Task,TopTSfrGroups[i].Head);
*/
/*
Here, we want to fill the FoF_P structure that contains particles information for a group that will form an IMF. This structure is shared by all Tasks.
Loop over all TopTSfrGroups and check if a local Group corresponds to it.
1) fill FoF_P_local with local information
2) send FoF_P_local to all and create FoF_P
*/
RearrangeParticlesFlag=0;
for(i=0;i<Tot_Ntsfrgroups;i++)
{
Np_local=-1;
pass=0;
if(Ngroups>0)
{
for(gid=0;gid<Ngroups;gid++)
{
if(Groups[gid].SfrFlag==1)/* the group must be flagged as forming stars */
{
if((Groups[gid].Task==TopTSfrGroups[i].Task)&&((Groups[gid].Head==TopTSfrGroups[i].Head)))/* the pseudo group fit the top group */
{
/* count number of stars */
/* Note : Groups[gid].N != Np_local as it corresponds to the total group for the true Groups */
Np_local=0;
next=Groups[gid].LocalHead;
while(next!=-1)
{
Np_local+=1;
next=SphP[next].FOF_Next;
}
if(pass!=0)
{
printf("(%d) we already found a group linked to Task=%d Head=%d in this proc. \n",ThisTask,TopTSfrGroups[i].Task,TopTSfrGroups[i].Head);
printf("we should reduce such groups before... we prefere to stop.\n");
FOFDataResult[target].FOF_CPUPrev=-2;/* this is to keep the trace that the particle was as pseudo head, as its new FOF_CPUHead could be now its own CPU */
FOFDataResult[target].FOF_Head=FOFDataGet[target].Index;/* WARNING : THOSE PARTICLES ARE PSEUDO HEAD THAT LINK TO OTHER CPU THAN THE INITIAL ONE */
FOFDataResult[target].FOF_CPUHead=SphP[head].FOF_CPUHead;/* instead of this ThisTask */
FOFDataResult[target].FOF_CPUPrev=-2;/* this is to keep the trace that the particle was as pseudo head, as its new FOF_CPUHead could be now its own CPU */
FOFDataResult[target].FOF_Head=FOFDataGet[target].Index;/* WARNING : THOSE PARTICLES ARE PSEUDO HEAD THAT LINK TO OTHER CPU THAN THE INITIAL ONE */
FOFDataResult[target].FOF_CPUHead=SphP[head].FOF_CPUHead;/* instead of this ThisTask */
FOFDataResult[target].FOF_Done=1;
return;
}
printf("we have a problem here !!\n");
endrun(1974);
}
/*! This is a comparison kernel for a sort routine, which is used to group
* particles that are going to be exported to the same CPU.