]> git.donarmstrong.com Git - mothur.git/blobdiff - engine.cpp
changed groupfile in classify.seqs to reflect multiple fasta files
[mothur.git] / engine.cpp
index 3bdc484ac64a0a1140feee90e299696c2eb292c3..9e5801b1b057b2f2a1cc4a986e105ae3e73f14b5 100644 (file)
@@ -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();