malloc(sizeof(Particle)*NumParticles);
for (i=0; i<NumParticles; i++) { Particles[i].ForceAccumX=0; Particles[i].ForceAccumY=0; }
// COMPUTE PROC IDS OF LEFT AND RIGHT NEIGHBORING PROCS LeftProc = (MyID+NumProcs-1)%NumProcs; RightProc = (MyID+1)%NumProcs;What is the purpose of %NumProcs?
for (k=0; k<NumProcs/2; k++) { // SEND UPDATED "RECEIVED" PARTICLES TO NEXT PROCESSOR if (k>0) MPI_Send(CommParticles,NumParticles,MPI_PARTICLE,RightProc,0,MPI_COMM_WORLD); // RECEIVE PARTICLES FROM PREV PROCESSOR (LEFT) MPI_Recv(CommParticles,NumParticles,MPI_PARTICLE,LeftProc,0,MPI_COMM_WORLD,&Status); // COMPUTE FORCES BETWEEN RECEIVED AND LOCAL PARTICLES // (UPDATE LOCAL AND RECEIVED PARTICLES) for (i=0; i<NumParticles; i++) for (j=0; j<NumParticles; j++) { ComputeGravForce(Particles[i],CommParticles[j],&ForceX,&ForceY); Particles[i].ForceAccumX+=ForceX; Particles[i].ForceAccumY+=ForceY; CommParticles[j].ForceAccumX-=ForceX; CommParticles[j].ForceAccumY-=ForceY; } }What is this code doing?