]> git.donarmstrong.com Git - mothur.git/blobdiff - mothur.cpp
added MPI to dist.seqs command
[mothur.git] / mothur.cpp
index 7cd77a1c2fd8fec087e740a7340f4a74c19ea801..75d03e16d62a4c01b20236b42c00c1e00cd0bfc0 100644 (file)
@@ -12,6 +12,7 @@
 #include "globaldata.hpp"
 #include "mothurout.h"
 
+
 /**************************************************************************************************/
 
 GlobalData* GlobalData::_uniqueInstance = 0;
@@ -24,6 +25,13 @@ void ctrlc_handler ( int sig ) {
        MothurOut* m = MothurOut::getInstance();
     ctrlc_pressed = 1;
        m->control_pressed = ctrlc_pressed;
+       
+       if (m->executing) { //if mid command quit execution, else quit mothur
+               m->mothurOutEndLine(); m->mothurOut("quitting command...");  m->mothurOutEndLine();
+       }else{
+               m->mothurOut("quitting mothur");  m->mothurOutEndLine();
+               exit(1);
+       }
 }
 /***********************************************************************/
 int main(int argc, char *argv[]){
@@ -35,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");
@@ -92,8 +105,11 @@ int main(int argc, char *argv[]){
                m->mothurOutEndLine();                  
                m->mothurOut("Type 'quit()' to exit program");
                m->mothurOutEndLine();  
-
-                               
+               
+               #ifdef USE_MPI
+                       m->mothurOutJustToLog("Using MPI\n");
+               #endif
+               
                //srand(54321);
                srand( (unsigned)time( NULL ) );
                
@@ -123,7 +139,7 @@ int main(int argc, char *argv[]){
                        mothur = new InteractEngine(argv[0]);   
                }
                
-               while(bail == 0)                {       bail = mothur->getInput();                      }
+               while(bail == 0)        {       bail = mothur->getInput();      }
                
                string outputDir = mothur->getOutputDir();
                string newlogFileName = outputDir + logFileName;
@@ -132,7 +148,11 @@ int main(int argc, char *argv[]){
                rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
                
                delete mothur;
-
+               
+               #ifdef USE_MPI
+                       MPI_Finalize();
+               #endif
+               
                return 0;
        }
        catch(exception& e) {