]> git.donarmstrong.com Git - mothur.git/blobdiff - mothur.cpp
added set.logfile command
[mothur.git] / mothur.cpp
index 6631489a1f67fa5ba486108c0421d562a8953fa5..4f91c2e90a0b52aa8c3f51140e857660e8ba038f 100644 (file)
@@ -43,8 +43,13 @@ int main(int argc, char *argv[]){
                time_t ltime = time(NULL); /* calendar time */  
                string logFileName = "mothur." + toString(ltime) + ".logfile";
                
+               #ifdef USE_MPI
+                       MPI_Init(&argc, &argv); 
+               #endif
+
                m->setFileName(logFileName);
                
+                               
                //version
                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                        system("clear");
@@ -68,9 +73,9 @@ int main(int argc, char *argv[]){
                #endif
                
                //header
-               m->mothurOut("mothur v.1.8");
+               m->mothurOut("mothur v.1.9");
                m->mothurOutEndLine();          
-               m->mothurOut("Last updated: 2/02/2010");
+               m->mothurOut("Last updated: 4/16/2010");
                m->mothurOutEndLine();  
                m->mothurOutEndLine();          
                m->mothurOut("by");
@@ -102,10 +107,12 @@ int main(int argc, char *argv[]){
                m->mothurOutEndLine();  
                
                #ifdef USE_MPI
-                       m->mothurOutJustToLog("Using MPI\n");
-                       MPI_Init(&argc, &argv); 
+                       m->mothurOutJustToLog("Using MPI\tversion ");
+                       int version, subversion;
+                       MPI_Get_version(&version, &subversion);
+                       m->mothurOutJustToLog(toString(version) + "." + toString(subversion) + "\n");
                #endif
-                               
+               
                //srand(54321);
                srand( (unsigned)time( NULL ) );
                
@@ -137,12 +144,37 @@ int main(int argc, char *argv[]){
                
                while(bail == 0)        {       bail = mothur->getInput();      }
                
+               //closes logfile so we can rename
+               m->closeLog();
+               
                string outputDir = mothur->getOutputDir();
-               string newlogFileName = outputDir + logFileName;
-       
-               //need this because m->mothurOut makes the logfile, but doesn't know where to put it
-               rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
+               string tempLog = mothur->getLogFileName();
+               bool append = mothur->getAppend();
+               
+               string newlogFileName;
+               if (tempLog != "") {
+                       newlogFileName = outputDir + tempLog;
+                       
+                       if (!append) {  
+                               //need this because m->mothurOut makes the logfile, but doesn't know where to put it
+                               rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
+
+                       }else {
+                               ofstream outNewLog;
+                               openOutputFileAppend(newlogFileName, outNewLog);
+                               outNewLog << endl << endl << "*********************************************************************************" << endl << endl;
+                               outNewLog.close();
+                               
+                               appendFiles(logFileName, newlogFileName);
+                               remove(logFileName.c_str());
+                       }
+               }else{  
+                       newlogFileName = outputDir + logFileName;
+                       //need this because m->mothurOut makes the logfile, but doesn't know where to put it
+                       rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
+               }
                
+                               
                delete mothur;
                
                #ifdef USE_MPI