}
lines.clear();
- int numPairs = namesOfGroupCombos.size();
- int numPairsPerProcessor = numPairs / processors;
-
- for (int i = 0; i < processors; i++) {
- int startPos = i * numPairsPerProcessor;
- if(i == processors - 1){ numPairsPerProcessor = numPairs - i * numPairsPerProcessor; }
- lines.push_back(linePair(startPos, numPairsPerProcessor));
+ int remainingPairs = namesOfGroupCombos.size();
+ int startIndex = 0;
+ for (int remainingProcessors = processors; remainingProcessors > 0; remainingProcessors--) {
+ int numPairs = remainingPairs; //case for last processor
+ if (remainingProcessors != 1) { numPairs = ceil(remainingPairs / remainingProcessors); }
+ lines.push_back(linePair(startIndex, numPairs)); //startIndex, numPairs
+ startIndex = startIndex + numPairs;
+ remainingPairs = remainingPairs - numPairs;
}
data = createProcesses(t, namesOfGroupCombos, ct);
//pass numSeqs to parent
ofstream out;
- string tempFile = outputDir + toString(getpid()) + ".unweighted.results.temp";
+ string tempFile = outputDir + m->mothurGetpid(process) + ".unweighted.results.temp";
m->openOutputFile(tempFile, out);
out << myresults.size() << endl;
for (int i = 0; i < myresults.size(); i++) { out << myresults[i] << '\t'; } out << endl;
lines.clear();
int numPairs = namesOfGroupCombos.size();
- int numPairsPerProcessor = numPairs / processors;
+ int numPairsPerProcessor = ceil(numPairs / processors);
for (int i = 0; i < processors; i++) {
int startPos = i * numPairsPerProcessor;
//pass numSeqs to parent
ofstream out;
- string tempFile = outputDir + toString(getpid()) + ".unweighted.results.temp";
+ string tempFile = outputDir + m->mothurGetpid(process) + ".unweighted.results.temp";
m->openOutputFile(tempFile, out);
out << myresults.size() << endl;
for (int i = 0; i < myresults.size(); i++) { out << myresults[i] << '\t'; } out << endl;