X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=preclustercommand.cpp;h=05c8b7d42a1ba7de160449f02707097800357bea;hb=250e3b11b1c9c1e1ad458ab6c7e71ac2e67e11d9;hp=fe722a669f2c0ca983c94ef21cc73dc95f5719bc;hpb=ac03f1f6c27b5bfdf2cfb6d45c3667c3e0281f51;p=mothur.git diff --git a/preclustercommand.cpp b/preclustercommand.cpp index fe722a6..05c8b7d 100644 --- a/preclustercommand.cpp +++ b/preclustercommand.cpp @@ -369,13 +369,15 @@ int PreClusterCommand::createProcessesGroups(string newFName, string newNName, s //divide the groups between the processors vector lines; - int numGroupsPerProcessor = groups.size() / processors; - for (int i = 0; i < processors; i++) { - int startIndex = i * numGroupsPerProcessor; - int endIndex = (i+1) * numGroupsPerProcessor; - if(i == (processors - 1)){ endIndex = groups.size(); } - lines.push_back(linePair(startIndex, endIndex)); - } + int remainingPairs = groups.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, (startIndex+numPairs))); //startIndex, endIndex + startIndex = startIndex + numPairs; + remainingPairs = remainingPairs - numPairs; + } #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)