X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=engine.cpp;h=9e5801b1b057b2f2a1cc4a986e105ae3e73f14b5;hb=5c80ce8b80938d41cf6c64a017fa6fd50d45de5b;hp=3bdc484ac64a0a1140feee90e299696c2eb292c3;hpb=aa9238c0a9e6e7aa0ed8b8b606b08ad4fd7dcfe3;p=mothur.git diff --git a/engine.cpp b/engine.cpp index 3bdc484..9e5801b 100644 --- a/engine.cpp +++ b/engine.cpp @@ -68,11 +68,22 @@ bool InteractEngine::getInput(){ if (commandName != "") { mout->executing = true; + + #ifdef USE_MPI + int pid; + MPI_Comm_rank(MPI_COMM_WORLD, &pid); + + if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) { + #endif //executes valid command Command* command = cFactory->getCommand(commandName, options); quitCommandCalled = command->execute(); mout->control_pressed = 0; mout->executing = false; + + #ifdef USE_MPI + } + #endif }else { mout->mothurOut("Your input contains errors. Please try again."); mout->mothurOutEndLine(); @@ -96,7 +107,7 @@ string Engine::getCommand() { if(nextCommand != NULL) { add_history(nextCommand); } else{ //^D causes null string and we want it to quit mothur nextCommand = "quit"; - cout << nextCommand << endl; + mout->mothurOut(nextCommand); } mout->mothurOutJustToLog("mothur > " + toString(nextCommand)); @@ -106,17 +117,19 @@ string Engine::getCommand() { mout->mothurOut("mothur > "); getline(cin, nextCommand); mout->mothurOutJustToLog("mothur > " + toString(nextCommand)); + return nextCommand; #endif #else - string nextCommand = ""; - mout->mothurOut("mothur > "); - getline(cin, nextCommand); - mout->mothurOutJustToLog("mothur > " + toString(nextCommand)); - return nextCommand; + string nextCommand = ""; + + mout->mothurOut("mothur > "); + getline(cin, nextCommand); + mout->mothurOutJustToLog(toString(nextCommand)); + + return nextCommand; #endif - - mout->mothurOutEndLine(); + } catch(exception& e) { @@ -172,7 +185,7 @@ bool BatchEngine::getInput(){ mout->mothurOutEndLine(); mout->mothurOut("mothur > " + input); mout->mothurOutEndLine(); - + if (mout->control_pressed) { input = "quit()"; } //allow user to omit the () on the quit command @@ -184,11 +197,21 @@ bool BatchEngine::getInput(){ if (commandName != "") { mout->executing = true; + #ifdef USE_MPI + int pid; + MPI_Comm_rank(MPI_COMM_WORLD, &pid); + + if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) { + #endif //executes valid command Command* command = cFactory->getCommand(commandName, options); quitCommandCalled = command->execute(); mout->control_pressed = 0; mout->executing = false; + + #ifdef USE_MPI + } + #endif }else { mout->mothurOut("Invalid."); mout->mothurOutEndLine(); @@ -250,11 +273,10 @@ bool ScriptEngine::getInput(){ if (input == "") { input = "quit()"; } - mout->mothurOutEndLine(); mout->mothurOut("mothur > " + input); mout->mothurOutEndLine(); - + if (mout->control_pressed) { input = "quit()"; } //allow user to omit the () on the quit command @@ -266,11 +288,21 @@ bool ScriptEngine::getInput(){ if (commandName != "") { mout->executing = true; + #ifdef USE_MPI + int pid; + MPI_Comm_rank(MPI_COMM_WORLD, &pid); + + if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) { + #endif //executes valid command Command* command = cFactory->getCommand(commandName, options); quitCommandCalled = command->execute(); mout->control_pressed = 0; mout->executing = false; + + #ifdef USE_MPI + } + #endif }else { mout->mothurOut("Invalid."); mout->mothurOutEndLine();