X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=sequence.cpp;h=19adf796b5d1d26f3a681144c6c801cdb4b4f63d;hp=4b5667584a07fd1ca5f6832efd16c192e04c5f1c;hb=fdc1f6eaf544f695fc1511f24bddd7e6069c33ba;hpb=aba5f8811829037b0a3004ef33f0ad4ed5e5fcf8 diff --git a/sequence.cpp b/sequence.cpp index 4b56675..19adf79 100644 --- a/sequence.cpp +++ b/sequence.cpp @@ -443,5 +443,65 @@ void Sequence::reverseComplement(){ aligned = temp; } - +#ifdef USE_MPI //******************************************************************************************************************** +int Sequence::MPISend(int receiver) { + try { + //send name - string + int length = name.length(); + char buf[name.length()]; + strcpy(buf, name.c_str()); + + MPI_Send(&length, 1, MPI_INT, receiver, 2001, MPI_COMM_WORLD); + + MPI_Send(&buf, length, MPI_CHAR, receiver, 2001, MPI_COMM_WORLD); + + //send aligned - string + length = aligned.length(); + char buf2[aligned.length()]; + strcpy(buf2, aligned.c_str()); + + MPI_Send(&length, 1, MPI_INT, receiver, 2001, MPI_COMM_WORLD); + + MPI_Send(&buf2, length, MPI_CHAR, receiver, 2001, MPI_COMM_WORLD); + + return 0; + + } + catch(exception& e) { + m->errorOut(e, "Sequence", "MPISend"); + exit(1); + } +} +/**************************************************************************************************/ +int Sequence::MPIRecv(int sender) { + try { + MPI_Status status; + + //receive name - string + int length; + MPI_Recv(&length, 1, MPI_INT, sender, 2001, MPI_COMM_WORLD, &status); + + char buf[length]; + MPI_Recv(&buf, length, MPI_CHAR, sender, 2001, MPI_COMM_WORLD, &status); + name = buf; + + //receive aligned - string + MPI_Recv(&length, 1, MPI_INT, sender, 2001, MPI_COMM_WORLD, &status); + + char buf2[length]; + MPI_Recv(&buf2, length, MPI_CHAR, sender, 2001, MPI_COMM_WORLD, &status); + aligned = buf2; + + setAligned(aligned); + + return 0; + + } + catch(exception& e) { + m->errorOut(e, "Sequence", "MPIRecv"); + exit(1); + } +} +#endif +/**************************************************************************************************/