From a61980e36d61937acccadc41be260165a1e389f4 Mon Sep 17 00:00:00 2001 From: westcott Date: Tue, 20 Apr 2010 12:50:01 +0000 Subject: [PATCH] a few modifications for 1.9 --- aligncommand.cpp | 35 +++++++++++++++++------------ ccode.cpp | 17 ++++++++------ chimera.cpp | 18 ++++++++++----- chimerabellerophoncommand.cpp | 19 ++++++++++------ chimeraccodecommand.cpp | 31 +++++++++++++++++--------- chimeracheckcommand.cpp | 18 ++++++++++----- chimeracheckrdp.cpp | 22 +++++++++++------- chimerapintailcommand.cpp | 27 ++++++++++++++-------- chimeraslayercommand.cpp | 27 ++++++++++++++-------- classify.cpp | 20 +++++++++++------ classifyseqscommand.cpp | 42 ++++++++++++++++++++++------------- distancecommand.cpp | 35 ++++++++++++++++++----------- filterseqscommand.cpp | 29 +++++++++++++++--------- makefile | 4 ++-- pintail.cpp | 33 +++++++++++++++++---------- 15 files changed, 241 insertions(+), 136 deletions(-) diff --git a/aligncommand.cpp b/aligncommand.cpp index 38afa35..37089b6 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -267,28 +267,35 @@ int AlignCommand::execute(){ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; - char* outAlignFilename = new char[alignFileName.length()]; - memcpy(outAlignFilename, alignFileName.c_str(), alignFileName.length()); - - char* outReportFilename = new char[reportFileName.length()]; - memcpy(outReportFilename, reportFileName.c_str(), reportFileName.length()); + //char* outAlignFilename = new char[alignFileName.length()]; + //memcpy(outAlignFilename, alignFileName.c_str(), alignFileName.length()); + + char outAlignFilename[1024]; + strcpy(outAlignFilename, alignFileName.c_str()); - char* outAccnosFilename = new char[accnosFileName.length()]; - memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); + //char* outReportFilename = new char[reportFileName.length()]; + //memcpy(outReportFilename, reportFileName.c_str(), reportFileName.length()); + + char outReportFilename[1024]; + strcpy(outReportFilename, reportFileName.c_str()); - char* inFileName = new char[candidateFileNames[s].length()]; - memcpy(inFileName, candidateFileNames[s].c_str(), candidateFileNames[s].length()); + //char* outAccnosFilename = new char[accnosFileName.length()]; + //memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); + + char outAccnosFilename[1024]; + strcpy(outAccnosFilename, accnosFileName.c_str()); + //char* inFileName = new char[candidateFileNames[s].length()]; + //memcpy(inFileName, candidateFileNames[s].c_str(), candidateFileNames[s].length()); + + char inFileName[1024]; + strcpy(inFileName, candidateFileNames[s].c_str()); + MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outAlignFilename, outMode, MPI_INFO_NULL, &outMPIAlign); MPI_File_open(MPI_COMM_WORLD, outReportFilename, outMode, MPI_INFO_NULL, &outMPIReport); MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos); - delete outAlignFilename; - delete inFileName; - delete outReportFilename; - delete outAccnosFilename; - if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPIAlign); MPI_File_close(&outMPIReport); MPI_File_close(&outMPIAccnos); return 0; } if (pid == 0) { //you are the root process diff --git a/ccode.cpp b/ccode.cpp index 5fdf5d1..c276448 100644 --- a/ccode.cpp +++ b/ccode.cpp @@ -29,14 +29,17 @@ Ccode::Ccode(string filename, string temp, bool f, string mask, int win, int num #ifdef USE_MPI - char* inFileName = new char[mapInfo.length()]; - memcpy(inFileName, mapInfo.c_str(), mapInfo.length()); + //char* inFileName = new char[mapInfo.length()]; + //memcpy(inFileName, mapInfo.c_str(), mapInfo.length()); + + char inFileName[1024]; + strcpy(inFileName, mapInfo.c_str()); int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; MPI_File_open(MPI_COMM_WORLD, inFileName, outMode, MPI_INFO_NULL, &outMap); //comm, filename, mode, info, filepointer - delete inFileName; + //delete inFileName; int pid; MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are @@ -46,7 +49,7 @@ Ccode::Ccode(string filename, string temp, bool f, string mask, int win, int num MPI_Status status; int length = outString.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outString.c_str(), length); MPI_File_write_shared(outMap, buf2, length, MPI_CHAR, &status); @@ -238,7 +241,7 @@ int Ccode::print(MPI_File& out, MPI_File& outAcc) { MPI_Status status; int length = outString.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outString.c_str(), length); MPI_File_write_shared(out, buf2, length, MPI_CHAR, &status); @@ -250,7 +253,7 @@ int Ccode::print(MPI_File& out, MPI_File& outAcc) { MPI_Status statusAcc; length = outAccString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outAccString.c_str(), length); MPI_File_write_shared(outAcc, buf, length, MPI_CHAR, &statusAcc); @@ -272,7 +275,7 @@ int Ccode::printMapping(string& output) { try { MPI_Status status; int length = output.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, output.c_str(), length); MPI_File_write_shared(outMap, buf, length, MPI_CHAR, &status); diff --git a/chimera.cpp b/chimera.cpp index 83d40fe..b513075 100644 --- a/chimera.cpp +++ b/chimera.cpp @@ -109,11 +109,14 @@ vector Chimera::readSeqs(string file) { MPI_File inMPI; MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are - char* inFileName = new char[file.length()]; - memcpy(inFileName, file.c_str(), file.length()); + //char* inFileName = new char[file.length()]; + //memcpy(inFileName, file.c_str(), file.length()); + + char inFileName[1024]; + strcpy(inFileName, file.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer - delete inFileName; + //delete inFileName; if (pid == 0) { positions = setFilePosFasta(file, numSeqs); //fills MPIPos, returns numSeqs @@ -199,13 +202,16 @@ void Chimera::setMask(string filename) { MPI_Offset size; MPI_Status status; - char* inFileName = new char[filename.length()]; - memcpy(inFileName, filename.c_str(), filename.length()); + //char* inFileName = new char[filename.length()]; + //memcpy(inFileName, filename.c_str(), filename.length()); + + char inFileName[1024]; + strcpy(inFileName, filename.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_get_size(inMPI, &size); - delete inFileName; + //delete inFileName; char* buffer = new char[size]; MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status); diff --git a/chimerabellerophoncommand.cpp b/chimerabellerophoncommand.cpp index 69eb895..67f6b57 100644 --- a/chimerabellerophoncommand.cpp +++ b/chimerabellerophoncommand.cpp @@ -136,18 +136,23 @@ int ChimeraBellerophonCommand::execute(){ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; - char* outFilename = new char[accnosFileName.length()]; - memcpy(outFilename, accnosFileName.c_str(), accnosFileName.length()); - - char* FileName = new char[outputFileName.length()]; - memcpy(FileName, outputFileName.c_str(), outputFileName.length()); + //char* outFilename = new char[accnosFileName.length()]; + //memcpy(outFilename, accnosFileName.c_str(), accnosFileName.length()); + + char outFilename[1024]; + strcpy(outFilename, accnosFileName.c_str()); + //char* FileName = new char[outputFileName.length()]; + //memcpy(FileName, outputFileName.c_str(), outputFileName.length()); + + char FileName[1024]; + strcpy(FileName, outputFileName.c_str()); MPI_File_open(MPI_COMM_WORLD, FileName, outMode, MPI_INFO_NULL, &outMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPIAccnos); - delete FileName; - delete outFilename; + //delete FileName; + //delete outFilename; numSeqs = chimera->print(outMPI, outMPIAccnos); diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp index 6958c00..0b96f21 100644 --- a/chimeraccodecommand.cpp +++ b/chimeraccodecommand.cpp @@ -191,22 +191,31 @@ int ChimeraCcodeCommand::execute(){ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; - char* outFilename = new char[outputFileName.length()]; - memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); + //char* outFilename = new char[outputFileName.length()]; + //memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); - char* outAccnosFilename = new char[accnosFileName.length()]; - memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); + char outFilename[1024]; + strcpy(outFilename, outputFileName.c_str()); + + //char* outAccnosFilename = new char[accnosFileName.length()]; + //memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); + + char outAccnosFilename[1024]; + strcpy(outAccnosFilename, accnosFileName.c_str()); - char* inFileName = new char[fastafile.length()]; - memcpy(inFileName, fastafile.c_str(), fastafile.length()); + //char* inFileName = new char[fastafile.length()]; + //memcpy(inFileName, fastafile.c_str(), fastafile.length()); + + char inFileName[1024]; + strcpy(inFileName, fastafile.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI); MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos); - delete inFileName; - delete outFilename; - delete outAccnosFilename; + //delete inFileName; + //delete outFilename; + //delete outAccnosFilename; if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); delete chimera; return 0; } @@ -215,7 +224,7 @@ int ChimeraCcodeCommand::execute(){ //print header int length = outTemp.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outTemp.c_str(), length); MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &status); @@ -499,7 +508,7 @@ int ChimeraCcodeCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File //read next sequence int length = MPIPos[start+i+1] - MPIPos[start+i]; - char* buf4 = new char[length]; + char* buf4 = new char[length]; MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status); diff --git a/chimeracheckcommand.cpp b/chimeracheckcommand.cpp index fe919de..625314a 100644 --- a/chimeracheckcommand.cpp +++ b/chimeracheckcommand.cpp @@ -167,17 +167,23 @@ int ChimeraCheckCommand::execute(){ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; - char* outFilename = new char[outputFileName.length()]; - memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); + //char* outFilename = new char[outputFileName.length()]; + //memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); + + char outFilename[1024]; + strcpy(outFilename, outputFileName.c_str()); - char* inFileName = new char[fastafile.length()]; - memcpy(inFileName, fastafile.c_str(), fastafile.length()); + //char* inFileName = new char[fastafile.length()]; + //memcpy(inFileName, fastafile.c_str(), fastafile.length()); + + char inFileName[1024]; + strcpy(inFileName, fastafile.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI); - delete outFilename; - delete inFileName; + //delete outFilename; + //delete inFileName; if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); delete chimera; return 0; } diff --git a/chimeracheckrdp.cpp b/chimeracheckrdp.cpp index cb101b6..4c93c1b 100644 --- a/chimeracheckrdp.cpp +++ b/chimeracheckrdp.cpp @@ -97,7 +97,7 @@ int ChimeraCheckRDP::print(MPI_File& out, MPI_File& outAcc) { MPI_Status status; int length = outString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outString.c_str(), length); MPI_File_write_shared(out, buf, length, MPI_CHAR, &status); @@ -263,13 +263,16 @@ void ChimeraCheckRDP::readName(string namefile) { MPI_Offset size; MPI_Status status; - char* inFileName = new char[namefile.length()]; - memcpy(inFileName, namefile.c_str(), namefile.length()); + //char* inFileName = new char[namefile.length()]; + //memcpy(inFileName, namefile.c_str(), namefile.length()); + + char inFileName[1024]; + strcpy(inFileName, namefile.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); MPI_File_get_size(inMPI, &size); - delete inFileName; + //delete inFileName; char* buffer = new char[size]; MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status); @@ -352,12 +355,15 @@ void ChimeraCheckRDP::makeSVGpic(vector info) { MPI_File outSVG; int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; - char* FileName = new char[file.length()]; - memcpy(FileName, file.c_str(), file.length()); + //char* FileName = new char[file.length()]; + //memcpy(FileName, file.c_str(), file.length()); + char FileName[1024]; + strcpy(FileName, file.c_str()); + MPI_File_open(MPI_COMM_SELF, FileName, outMode, MPI_INFO_NULL, &outSVG); //comm, filename, mode, info, filepointer - delete FileName; + //delete FileName; int width = (info.size()*5) + 150; @@ -404,7 +410,7 @@ void ChimeraCheckRDP::makeSVGpic(vector info) { MPI_Status status; int length = outString.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outString.c_str(), length); MPI_File_write(outSVG, buf2, length, MPI_CHAR, &status); diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp index 40a1610..384c885 100644 --- a/chimerapintailcommand.cpp +++ b/chimerapintailcommand.cpp @@ -217,22 +217,31 @@ int ChimeraPintailCommand::execute(){ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; - char* outFilename = new char[outputFileName.length()]; - memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); + //char* outFilename = new char[outputFileName.length()]; + //memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); - char* outAccnosFilename = new char[accnosFileName.length()]; - memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); + char outFilename[1024]; + strcpy(outFilename, outputFileName.c_str()); + + //char* outAccnosFilename = new char[accnosFileName.length()]; + //memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); + + char outAccnosFilename[1024]; + strcpy(outAccnosFilename, accnosFileName.c_str()); - char* inFileName = new char[fastafile.length()]; - memcpy(inFileName, fastafile.c_str(), fastafile.length()); + //char* inFileName = new char[fastafile.length()]; + //memcpy(inFileName, fastafile.c_str(), fastafile.length()); + + char inFileName[1024]; + strcpy(inFileName, fastafile.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI); MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos); - delete inFileName; - delete outFilename; - delete outAccnosFilename; + //delete inFileName; + //delete outFilename; + //delete outAccnosFilename; if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); delete chimera; return 0; } diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index 4b309c0..8bb8c2c 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -217,22 +217,31 @@ int ChimeraSlayerCommand::execute(){ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; - char* outFilename = new char[outputFileName.length()]; - memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); + //char* outFilename = new char[outputFileName.length()]; + //memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); - char* outAccnosFilename = new char[accnosFileName.length()]; - memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); + char outFilename[1024]; + strcpy(outFilename, outputFileName.c_str()); + + //char* outAccnosFilename = new char[accnosFileName.length()]; + //memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); + + char outAccnosFilename[1024]; + strcpy(outAccnosFilename, accnosFileName.c_str()); - char* inFileName = new char[fastafile.length()]; - memcpy(inFileName, fastafile.c_str(), fastafile.length()); + //char* inFileName = new char[fastafile.length()]; + //memcpy(inFileName, fastafile.c_str(), fastafile.length()); + + char inFileName[1024]; + strcpy(inFileName, fastafile.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI); MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos); - delete inFileName; - delete outFilename; - delete outAccnosFilename; + //delete inFileName; + //delete outFilename; + //delete outAccnosFilename; if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); delete chimera; return 0; } diff --git a/classify.cpp b/classify.cpp index f09cbf5..c3e52ab 100644 --- a/classify.cpp +++ b/classify.cpp @@ -32,11 +32,14 @@ Classify::Classify(string tfile, string tempFile, string method, int kmerSize, f MPI_File inMPI; MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are - char* inFileName = new char[tempFile.length()]; - memcpy(inFileName, tempFile.c_str(), tempFile.length()); - + //char* inFileName = new char[tempFile.length()]; + //memcpy(inFileName, tempFile.c_str(), tempFile.length()); + + char inFileName[1024]; + strcpy(inFileName, tempFile.c_str()); + MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer - delete inFileName; + //delete inFileName; if (pid == 0) { //only one process needs to scan file positions = setFilePosFasta(tempFile, numSeqs); //fills MPIPos, returns numSeqs @@ -171,11 +174,14 @@ void Classify::readTaxonomy(string file) { MPI_File inMPI; MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are - char* inFileName = new char[file.length()]; - memcpy(inFileName, file.c_str(), file.length()); + //char* inFileName = new char[file.length()]; + //memcpy(inFileName, file.c_str(), file.length()); + char inFileName[1024]; + strcpy(inFileName, file.c_str()); + MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer - delete inFileName; + //delete inFileName; if (pid == 0) { positions = setFilePosEachLine(file, num); diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index e4fcb2b..bed6580 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -328,22 +328,31 @@ int ClassifySeqsCommand::execute(){ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; - char* outNewTax = new char[newTaxonomyFile.length()]; - memcpy(outNewTax, newTaxonomyFile.c_str(), newTaxonomyFile.length()); - - char* outTempTax = new char[tempTaxonomyFile.length()]; - memcpy(outTempTax, tempTaxonomyFile.c_str(), tempTaxonomyFile.length()); + //char* outNewTax = new char[newTaxonomyFile.length()]; + //memcpy(outNewTax, newTaxonomyFile.c_str(), newTaxonomyFile.length()); + + char outNewTax[1024]; + strcpy(outNewTax, newTaxonomyFile.c_str()); + + //char* outTempTax = new char[tempTaxonomyFile.length()]; + //memcpy(outTempTax, tempTaxonomyFile.c_str(), tempTaxonomyFile.length()); + + char outTempTax[1024]; + strcpy(outTempTax, tempTaxonomyFile.c_str()); - char* inFileName = new char[fastaFileNames[s].length()]; - memcpy(inFileName, fastaFileNames[s].c_str(), fastaFileNames[s].length()); + //char* inFileName = new char[fastaFileNames[s].length()]; + //memcpy(inFileName, fastaFileNames[s].c_str(), fastaFileNames[s].length()); + + char inFileName[1024]; + strcpy(inFileName, fastaFileNames[s].c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outNewTax, outMode, MPI_INFO_NULL, &outMPINewTax); MPI_File_open(MPI_COMM_WORLD, outTempTax, outMode, MPI_INFO_NULL, &outMPITempTax); - delete outNewTax; - delete outTempTax; - delete inFileName; + //delete outNewTax; + //delete outTempTax; + //delete inFileName; if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPINewTax); MPI_File_close(&outMPITempTax); delete classify; return 0; } @@ -758,7 +767,7 @@ int ClassifySeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File } int length = outputString.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outputString.c_str(), length); MPI_File_write_shared(newFile, buf2, length, MPI_CHAR, &statusNew); @@ -766,7 +775,7 @@ int ClassifySeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File outputString = candidateSeq->getName() + "\t" + classify->getSimpleTax() + "\n"; length = outputString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outputString.c_str(), length); MPI_File_write_shared(tempFile, buf, length, MPI_CHAR, &statusTemp); @@ -799,12 +808,15 @@ int ClassifySeqsCommand::MPIReadNamesFile(string nameFilename){ MPI_Offset size; MPI_Status status; - char* inFileName = new char[nameFilename.length()]; - memcpy(inFileName, nameFilename.c_str(), nameFilename.length()); + //char* inFileName = new char[nameFilename.length()]; + //memcpy(inFileName, nameFilename.c_str(), nameFilename.length()); + + char inFileName[1024]; + strcpy(inFileName, nameFilename.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); MPI_File_get_size(inMPI, &size); - delete inFileName; + //delete inFileName; char* buffer = new char[size]; MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status); diff --git a/distancecommand.cpp b/distancecommand.cpp index 58302dd..10a99dd 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -200,11 +200,14 @@ int DistanceCommand::execute(){ MPI_File outMPI; int amode=MPI_MODE_CREATE|MPI_MODE_WRONLY; - char* filename = new char[outputFile.length()]; - memcpy(filename, outputFile.c_str(), outputFile.length()); + //char* filename = new char[outputFile.length()]; + //memcpy(filename, outputFile.c_str(), outputFile.length()); + + char filename[1024]; + strcpy(filename, outputFile.c_str()); MPI_File_open(MPI_COMM_WORLD, filename, amode, MPI_INFO_NULL, &outMPI); - delete filename; + //delete filename; if (pid == 0) { //you are the root process @@ -249,11 +252,14 @@ int DistanceCommand::execute(){ MPI_File outMPI; MPI_File inMPI; - char* filename = new char[outputFile.length()]; - memcpy(filename, outputFile.c_str(), outputFile.length()); - + //char* filename = new char[outputFile.length()]; + //memcpy(filename, outputFile.c_str(), outputFile.length()); + + char filename[1024]; + strcpy(filename, outputFile.c_str()); + MPI_File_open(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL, &outMPI); - delete filename; + //delete filename; //wait on chidren for(int b = 1; b < processors; b++) { @@ -265,7 +271,7 @@ int DistanceCommand::execute(){ string outTemp = outputFile + toString(b) + ".temp"; - char* buf = new char[outTemp.length()]; + char* buf = new char[outTemp.length()]; memcpy(buf, outTemp.c_str(), outTemp.length()); MPI_File_open(MPI_COMM_SELF, buf, MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); @@ -488,7 +494,7 @@ int DistanceCommand::driverMPI(int startLine, int endLine, MPI_File& outMPI, flo //send results to parent int length = outputString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outputString.c_str(), length); MPI_File_write_shared(outMPI, buf, length, MPI_CHAR, &status); @@ -515,11 +521,14 @@ int DistanceCommand::driverMPI(int startLine, int endLine, string file, long& si MPI_File outMPI; int amode=MPI_MODE_CREATE|MPI_MODE_WRONLY; - char* filename = new char[file.length()]; - memcpy(filename, file.c_str(), file.length()); + //char* filename = new char[file.length()]; + //memcpy(filename, file.c_str(), file.length()); + char filename[1024]; + strcpy(filename, file.c_str()); + MPI_File_open(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL, &outMPI); - delete filename; + //delete filename; int startTime = time(NULL); @@ -557,7 +566,7 @@ int DistanceCommand::driverMPI(int startLine, int endLine, string file, long& si //send results to parent int length = outputString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outputString.c_str(), length); MPI_File_write(outMPI, buf, length, MPI_CHAR, &status); diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index c94bf65..b64e2f5 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -256,17 +256,23 @@ int FilterSeqsCommand::filterSequences() { int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; - char* outFilename = new char[filteredFasta.length()]; - memcpy(outFilename, filteredFasta.c_str(), filteredFasta.length()); + //char* outFilename = new char[filteredFasta.length()]; + //memcpy(outFilename, filteredFasta.c_str(), filteredFasta.length()); + + char outFilename[1024]; + strcpy(outFilename, filteredFasta.c_str()); - char* inFileName = new char[fastafileNames[s].length()]; - memcpy(inFileName, fastafileNames[s].c_str(), fastafileNames[s].length()); + //char* inFileName = new char[fastafileNames[s].length()]; + //memcpy(inFileName, fastafileNames[s].c_str(), fastafileNames[s].length()); + + char inFileName[1024]; + strcpy(inFileName, fastafileNames[s].c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI); - delete inFileName; - delete outFilename; + //delete inFileName; + //delete outFilename; if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); return 0; } @@ -409,7 +415,7 @@ int FilterSeqsCommand::driverMPIRun(int start, int num, MPI_File& inMPI, MPI_Fil if(count % 10 == 0){ //output to file //send results to parent int length = outputString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outputString.c_str(), length); MPI_File_write_shared(outMPI, buf, length, MPI_CHAR, &status); @@ -425,7 +431,7 @@ int FilterSeqsCommand::driverMPIRun(int start, int num, MPI_File& inMPI, MPI_Fil if(outputString != ""){ //output to file //send results to parent int length = outputString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outputString.c_str(), length); MPI_File_write_shared(outMPI, buf, length, MPI_CHAR, &status); @@ -554,8 +560,11 @@ string FilterSeqsCommand::createFilter() { MPI_Comm_size(MPI_COMM_WORLD, &processors); MPI_Comm_rank(MPI_COMM_WORLD, &pid); - char* tempFileName = new char(fastafileNames[s].length()); - tempFileName = &(fastafileNames[s][0]); + //char* tempFileName = new char(fastafileNames[s].length()); + //tempFileName = &(fastafileNames[s][0]); + + char tempFileName[1024]; + strcpy(tempFileName, fastafileNames[s].c_str()); MPI_File_open(MPI_COMM_WORLD, tempFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer diff --git a/makefile b/makefile index d95b5ef..d62f029 100644 --- a/makefile +++ b/makefile @@ -10,7 +10,7 @@ # Macros # -CC = g++ +CC = mpic++ CC_OPTIONS = -O3 # if you do not want to use the readline library set to no, default yes. @@ -26,7 +26,7 @@ ifeq ($(strip $(USEREADLINE)),yes) -L../readline-6.0 endif -USEMPI ?= no +USEMPI ?= yes ifeq ($(strip $(USEMPI)),yes) CC_OPTIONS += -DUSE_MPI diff --git a/pintail.cpp b/pintail.cpp index 1122c24..0050a43 100644 --- a/pintail.cpp +++ b/pintail.cpp @@ -310,7 +310,7 @@ int Pintail::print(MPI_File& out, MPI_File& outAcc) { MPI_Status statusAcc; int length = outAccString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outAccString.c_str(), length); MPI_File_write_shared(outAcc, buf, length, MPI_CHAR, &statusAcc); @@ -330,7 +330,7 @@ int Pintail::print(MPI_File& out, MPI_File& outAcc) { MPI_Status status; int length = outputString.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outputString.c_str(), length); MPI_File_write_shared(out, buf2, length, MPI_CHAR, &status); @@ -427,12 +427,15 @@ vector Pintail::readFreq() { MPI_Offset size; MPI_Status status; - char* inFileName = new char[consfile.length()]; - memcpy(inFileName, consfile.c_str(), consfile.length()); + //char* inFileName = new char[consfile.length()]; + //memcpy(inFileName, consfile.c_str(), consfile.length()); + + char inFileName[1024]; + strcpy(inFileName, consfile.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); MPI_File_get_size(inMPI, &size); - delete inFileName; + //delete inFileName; char* buffer = new char[size]; MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status); @@ -625,12 +628,15 @@ vector< vector > Pintail::readQuantiles() { MPI_Offset size; MPI_Status status; - char* inFileName = new char[quanfile.length()]; - memcpy(inFileName, quanfile.c_str(), quanfile.length()); + //char* inFileName = new char[quanfile.length()]; + //memcpy(inFileName, quanfile.c_str(), quanfile.length()); + + char inFileName[1024]; + strcpy(inFileName, quanfile.c_str()); MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); MPI_File_get_size(inMPI, &size); - delete inFileName; + //delete inFileName; char* buffer = new char[size]; @@ -708,14 +714,17 @@ void Pintail::printQuanFile(string file, string outputString) { int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; - char* FileName = new char[file.length()]; - memcpy(FileName, file.c_str(), file.length()); + //char* FileName = new char[file.length()]; + //memcpy(FileName, file.c_str(), file.length()); + + char FileName[1024]; + strcpy(FileName, file.c_str()); if (pid == 0) { MPI_File_open(MPI_COMM_SELF, FileName, outMode, MPI_INFO_NULL, &outQuan); //comm, filename, mode, info, filepointer int length = outputString.length(); - char* buf = new char[length]; + char* buf = new char[length]; memcpy(buf, outputString.c_str(), length); MPI_File_write(outQuan, buf, length, MPI_CHAR, &status); @@ -724,7 +733,7 @@ void Pintail::printQuanFile(string file, string outputString) { MPI_File_close(&outQuan); } - delete FileName; + //delete FileName; #else ofstream outQuan; openOutputFile(file, outQuan); -- 2.39.2