]> git.donarmstrong.com Git - mothur.git/blobdiff - classifyseqscommand.cpp
a few modifications for 1.9
[mothur.git] / classifyseqscommand.cpp
index a9f0a36a2a440e17e8f4f433954c766abba041ed..e4fcb2b9b61c926dfe996d5c643934cc9a926739 100644 (file)
@@ -327,20 +327,24 @@ int ClassifySeqsCommand::execute(){
                                                        
                                int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
                                int inMode=MPI_MODE_RDONLY; 
-                                                               
-                               char outNewTax[newTaxonomyFile.length()];
-                               strcpy(outNewTax, newTaxonomyFile.c_str());
                                
-                               char outTempTax[tempTaxonomyFile.length()];
-                               strcpy(outTempTax, tempTaxonomyFile.c_str());
-                               
-                               char inFileName[fastaFileNames[s].length()];
-                               strcpy(inFileName, fastaFileNames[s].c_str());
+                               char* outNewTax = new char[newTaxonomyFile.length()];\r
+                               memcpy(outNewTax, newTaxonomyFile.c_str(), newTaxonomyFile.length());
+                       
+                               char* outTempTax = new char[tempTaxonomyFile.length()];\r
+                               memcpy(outTempTax, tempTaxonomyFile.c_str(), tempTaxonomyFile.length());
+
+                               char* inFileName = new char[fastaFileNames[s].length()];\r
+                               memcpy(inFileName, fastaFileNames[s].c_str(), fastaFileNames[s].length());
 
                                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;
+
                                if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);   MPI_File_close(&outMPITempTax);  delete classify; return 0;  }
 
                                if(namefile != "") {  MPIReadNamesFile(namefileNames[s]);  }
@@ -732,12 +736,13 @@ int ClassifySeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File
                
                        //read next sequence
                        int length = MPIPos[start+i+1] - MPIPos[start+i];
-                       char buf4[length];
+                       char* buf4 = new char[length];
                        MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
                        
                        string tempBuf = buf4;
                        if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
                        istringstream iss (tempBuf,istringstream::in);
+                       delete buf4;
 
                        Sequence* candidateSeq = new Sequence(iss);
                        
@@ -753,17 +758,19 @@ int ClassifySeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File
                                        }
                                        
                                        int length = outputString.length();
-                                       char buf2[length];
-                                       strcpy(buf2, outputString.c_str()); 
+                                       char* buf2 = new char[length];\r
+                                       memcpy(buf2, outputString.c_str(), length);
                                
                                        MPI_File_write_shared(newFile, buf2, length, MPI_CHAR, &statusNew);
-                                       
+                                       delete buf2;
+
                                        outputString =  candidateSeq->getName() + "\t" + classify->getSimpleTax() + "\n";
                                        length = outputString.length();
-                                       char buf[length];
-                                       strcpy(buf, outputString.c_str()); 
+                                       char* buf = new char[length];\r
+                                       memcpy(buf, outputString.c_str(), length);
                                
                                        MPI_File_write_shared(tempFile, buf, length, MPI_CHAR, &statusTemp);
+                                       delete buf;
                                }
                        }                               
                        delete candidateSeq;
@@ -791,19 +798,21 @@ int ClassifySeqsCommand::MPIReadNamesFile(string nameFilename){
                MPI_File inMPI;
                MPI_Offset size;
                MPI_Status status;
-               
-               char inFileName[nameFilename.length()];
-               strcpy(inFileName, nameFilename.c_str());
+
+               char* inFileName = new char[nameFilename.length()];\r
+               memcpy(inFileName, nameFilename.c_str(), nameFilename.length());
 
                MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  
                MPI_File_get_size(inMPI, &size);
+               delete inFileName;
 
-               char buffer[size];
+               char* buffer = new char[size];
                MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
 
                string tempBuf = buffer;
                if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size);  }
                istringstream iss (tempBuf,istringstream::in);
+               delete buffer;
                
                string firstCol, secondCol;
                while(!iss.eof()) {