Example #1
0
int main( int argc, char** argv )
{
	bool doUnitTests = 0;
	bool doRegressionTests = 0;
	unsigned int benchmark = 0;
	// This reorders the OpFunc to Fid mapping to ensure it is node and
	// compiler independent.
	Id shellId = init( argc, argv, doUnitTests, doRegressionTests, benchmark );
	// Note that the main loop remains the parser loop, though it may
	// spawn a lot of other stuff.
	Element* shelle = shellId.element();
	Shell* s = reinterpret_cast< Shell* >( shelle->data( 0 ) );
	if ( doUnitTests )
		nonMpiTests( s ); // These tests do not need the process loop.

	if ( Shell::myNode() == 0 ) {
		if ( Shell::numNodes() > 1 ) {
			// Use the last clock for the postmaster, so that it is called
			// after everything else has been processed and all messages
			// are ready to send out.
			s->doUseClock( "/postmaster", "process", 9 );
			s->doSetClock( 9, 1.0 ); // Use a sensible default.
		}
#ifdef DO_UNIT_TESTS
		if ( doUnitTests ) {
			mpiTests();
			processTests( s );
		}
		// if ( doRegressionTests ) regressionTests();
#endif
		// These are outside unit tests because they happen in optimized
		// mode, using a command-line argument. As soon as they are done
		// the system quits, in order to estimate timing.
		if ( benchmark != 0 ) {
			mooseBenchmarks( benchmark );
			s->doQuit();
		} else {
			// Here we set off a little event loop to poll user input. 
			// It deals with the doQuit call too.
                        if(! quitFlag)
                            Shell::launchParser(); 
		}
	} else {
		PostMaster* p = reinterpret_cast< PostMaster* >( ObjId( 3 ).data());
		while ( Shell::keepLooping() ) {
			p->clearPending();
		}
	}
	Msg::clearAllMsgs();
	Id::clearAllElements();
#ifdef USE_MPI
	MPI_Finalize();
#endif
	return 0;
}
Example #2
0
/**
 * Launches Parser. Blocking when the parser blocks.
 */
void Shell::launchParser()
{
	Id shellId;
	Shell* s = reinterpret_cast< Shell* >( shellId.eref().data() );
	bool quit = 0;

	cout << "moose : " << flush;
	while ( !quit ) {
		string temp;
		cin >> temp;
		if ( temp == "quit" || temp == "q" ) {
			s->doQuit();
			quit = 1;
		}
	}
	cout << "\nQuitting Moose\n" << flush;
}