- //align your part
- driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos);
-
- if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); remove(outputFileName.c_str()); delete chimera; return 0; }
-
- //wait on chidren
- for(int i = 1; i < processors; i++) {
- char buf[4];
- MPI_Recv(buf, 4, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status);
- }
- }else{ //you are a child process
- MPI_Bcast(&numSeqs, 1, MPI_INT, 0, MPI_COMM_WORLD); //get numSeqs
- MPIPos.resize(numSeqs+1);
- MPI_Bcast(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, MPI_COMM_WORLD); //get file positions
-
- //figure out how many sequences you have to align
- numSeqsPerProcessor = numSeqs / processors;
- if(pid == (processors - 1)){ numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor; }
- int startIndex = pid * numSeqsPerProcessor;
-
- //align your part
- driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos);
-
- if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); delete chimera; return 0; }
-
- //tell parent you are done.
- char buf[4];
- strcpy(buf, "done");
- MPI_Send(buf, 4, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
- }
-
- //close files
- MPI_File_close(&inMPI);
- MPI_File_close(&outMPI);
- #else