void walksub(nodeptr n, real dsq, long ProcessId) { nodeptr* nn; leafptr l; bodyptr p; long i; if (subdivp(n, dsq, ProcessId)) { if (Type(n) == CELL) { for (nn = Subp(n); nn < Subp(n) + NSUB; nn++) { if (*nn != NULL) { walksub(*nn, dsq / 4.0, ProcessId); } } } else { l = (leafptr) n; for (i = 0; i < l->num_bodies; i++) { p = Bodyp(l)[i]; if (p != Local[ProcessId].pskip) { gravsub(p, ProcessId); } else { Local[ProcessId].skipself = TRUE; } } } } else { gravsub(n, ProcessId); } }
local void treescan(nodeptr q) { while (q != NULL) { /* while not at end of scan */ if (Type(q) == CELL && /* is node a cell and... */ subdivp(q)) /* too close to accept? */ { cellptr SAFE c = TC(q); q = More(c); /* follow to next level */ } else { /* else accept this term */ if (q == (nodeptr) &pskip->bodynode) /* self-interaction? */ skipself = TRUE; /* then just skip it */ else { /* not self-interaction */ gravsub(q); /* so compute gravity */ if (Type(q) == BODY) n2bterm++; /* count body-body */ else nbcterm++; /* count body-cell */ } q = Next(q); /* follow next link */ } } }