-cout << endl << " rc groups ";
- //add in all the groups the users wanted
- for (it = t->tree[rc].pGroups.begin(); it != t->tree[rc].pGroups.end(); it++) {
-cout << it->first << " ";
- //if (inUsersGroups(it->first, globaldata->Groups) != true) { rcSize--; }
- }
-cout << endl << " lc groups ";
- //add in all the groups the users wanted
- for (it = t->tree[lc].pGroups.begin(); it != t->tree[lc].pGroups.end(); it++) {
-cout << it->first << " ";
- //if (inUsersGroups(it->first, globaldata->Groups) != true) { lcSize--; }
+ }
+
+ 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));
+ }
+
+ data = createProcesses(t, namesOfGroupCombos, ct);
+
+ return data;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Parsimony", "getValues");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+
+EstOutput Parsimony::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos, CountTable* ct) {
+ try {
+ int process = 1;
+ vector<int> processIDS;
+
+ EstOutput results;
+
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+
+ //loop through and create all the processes you want
+ while (process != processors) {
+ int pid = fork();
+
+ if (pid > 0) {
+ processIDS.push_back(pid); //create map from line number to pid so you can append files in correct order later
+ process++;
+ }else if (pid == 0){
+ EstOutput myresults;
+ myresults = driver(t, namesOfGroupCombos, lines[process].start, lines[process].num, ct);
+
+ if (m->control_pressed) { exit(0); }
+
+ //pass numSeqs to parent
+ ofstream out;
+ string tempFile = outputDir + toString(getpid()) + ".pars.results.temp";
+ m->openOutputFile(tempFile, out);
+ out << myresults.size() << endl;
+ for (int i = 0; i < myresults.size(); i++) { out << myresults[i] << '\t'; } out << endl;
+ out.close();
+
+ exit(0);
+ }else {
+ m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine();
+ for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
+ exit(0);