+ MPI_Status status;
+ MPI_Comm_size(MPI_COMM_WORLD, &processors); //set processors to the number of mpi processes running
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
+
+ //each process gets where it should start and stop in the file
+ start = int (sqrt(float(pid)/float(processors)) * numSeqs);
+ end = int (sqrt(float(pid+1)/float(processors)) * numSeqs);
+
+ if (pid == 0) { //you are the root process
+ //do your part
+ string outputMyPart;
+ driverMPI(start, end, outputMyPart, cutoff);
+
+ ofstream out;
+ openOutputFile(outputFile, out);
+
+ out << outputMyPart;
+
+ //get the childrens parts
+ for(int i = 1; i < processors; i++) {
+ int length;
+ MPI_Recv(&length, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
+
+ char buf[length];
+
+ MPI_Recv(buf, length, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status);
+
+ outputMyPart = buf;
+ out << outputMyPart;
+ }
+
+ out.close();
+
+ }else { //you are a child process
+ //do your part
+ string outputMyPart;
+ driverMPI(start, end, outputMyPart, cutoff);
+
+ //send results to parent
+ int length = outputMyPart.length();
+ char buf[length];
+ strcpy(buf, outputMyPart.c_str());
+
+ MPI_Send( &length, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
+ MPI_Send(buf, length, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
+ }
+
+
+#else
+
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)