#include "globaldata.hpp"
#include "mothurout.h"
+
/**************************************************************************************************/
GlobalData* GlobalData::_uniqueInstance = 0;
CommandFactory* CommandFactory::_uniqueInstance = 0;
MothurOut* MothurOut::_uniqueInstance = 0;
+/***********************************************************************/
+volatile int ctrlc_pressed = 0;
+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[]){
MothurOut* m = MothurOut::getInstance();
try {
- //string log = "mothur.logFile";
- //remove(log.c_str());
-
+ signal(SIGINT, ctrlc_handler );
+
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");
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 ) );
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;
rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
delete mothur;
-
+
+ #ifdef USE_MPI
+ MPI_Finalize();
+ #endif
+
return 0;
}
catch(exception& e) {