--- trunk/src/brains/SimCreator.cpp 2005/12/29 16:03:11 823 +++ trunk/src/brains/SimCreator.cpp 2006/04/25 02:09:01 945 @@ -46,7 +46,7 @@ * @time 13:51am * @version 1.0 */ - +#include #include #include #include @@ -102,7 +102,7 @@ Globals* SimCreator::parseFile(const std::string mdFil streamSize = ppStream.str().size() +1; commStatus = MPI_Bcast(&streamSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD); - commStatus = MPI_Bcast(ppStream.str().c_str(), streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); + commStatus = MPI_Bcast(static_cast(const_cast(ppStream.str().c_str())), streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); } else { @@ -147,37 +147,88 @@ Globals* SimCreator::parseFile(const std::string mdFil simParams = treeParser.walkTree(parser.getAST()); } + catch(antlr::MismatchedCharException& e) { - cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; + sprintf(painCave.errMsg, + "parser exception: %s %s:%d:%d\n", + e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); + painCave.isFatal = 1; + simError(); } catch(antlr::MismatchedTokenException &e) { - cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; + sprintf(painCave.errMsg, + "parser exception: %s %s:%d:%d\n", + e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); + painCave.isFatal = 1; + simError(); } catch(antlr::NoViableAltForCharException &e) { - cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; + sprintf(painCave.errMsg, + "parser exception: %s %s:%d:%d\n", + e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); + painCave.isFatal = 1; + simError(); } catch(antlr::NoViableAltException &e) { - cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; + sprintf(painCave.errMsg, + "parser exception: %s %s:%d:%d\n", + e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); + painCave.isFatal = 1; + simError(); } + catch(antlr::TokenStreamRecognitionException& e) { - cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; + sprintf(painCave.errMsg, + "parser exception: %s %s:%d:%d\n", + e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); + painCave.isFatal = 1; + simError(); } + catch(antlr::TokenStreamIOException& e) { - cerr<< "parser exception: " << e.getMessage() << endl; + sprintf(painCave.errMsg, + "parser exception: %s\n", + e.getMessage().c_str()); + painCave.isFatal = 1; + simError(); } + catch(antlr::TokenStreamException& e) { - cerr<< "parser exception: " << e.getMessage() << endl; + sprintf(painCave.errMsg, + "parser exception: %s\n", + e.getMessage().c_str()); + painCave.isFatal = 1; + simError(); } catch (antlr::RecognitionException& e) { - cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; + sprintf(painCave.errMsg, + "parser exception: %s %s:%d:%d\n", + e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); + painCave.isFatal = 1; + simError(); } catch (antlr::CharStreamException& e) { - cerr << "parser exception: " << e.getMessage() << endl; + sprintf(painCave.errMsg, + "parser exception: %s\n", + e.getMessage().c_str()); + painCave.isFatal = 1; + simError(); } - catch (exception& e) { - cerr << "parser exception: " << e.what() << endl; - } + catch (OOPSEException& e) { + sprintf(painCave.errMsg, + "%s\n", + e.getMessage().c_str()); + painCave.isFatal = 1; + simError(); + } + catch (std::exception& e) { + sprintf(painCave.errMsg, + "parser exception: %s\n", + e.what()); + painCave.isFatal = 1; + simError(); + } return simParams; } @@ -228,7 +279,8 @@ Globals* SimCreator::parseFile(const std::string mdFil //create SimInfo SimInfo * info = new SimInfo(ff, simParams); - //gather parameters (SimCreator only retrieves part of the parameters) + //gather parameters (SimCreator only retrieves part of the + //parameters) gatherParameters(info, mdFileName); //divide the molecules and determine the global index of molecules @@ -240,18 +292,23 @@ Globals* SimCreator::parseFile(const std::string mdFil createMolecules(info); - //allocate memory for DataStorage(circular reference, need to break it) + //allocate memory for DataStorage(circular reference, need to + //break it) info->setSnapshotManager(new SimSnapshotManager(info)); - //set the global index of atoms, rigidbodies and cutoffgroups (only need to be set once, the - //global index will never change again). Local indices of atoms and rigidbodies are already set by - //MoleculeCreator class which actually delegates the responsibility to LocalIndexManager. + //set the global index of atoms, rigidbodies and cutoffgroups + //(only need to be set once, the global index will never change + //again). Local indices of atoms and rigidbodies are already set + //by MoleculeCreator class which actually delegates the + //responsibility to LocalIndexManager. setGlobalIndex(info); - //Alought addExculdePairs is called inside SimInfo's addMolecule method, at that point - //atoms don't have the global index yet (their global index are all initialized to -1). - //Therefore we have to call addExcludePairs explicitly here. A way to work around is that - //we can determine the beginning global indices of atoms before they get created. + //Although addExcludePairs is called inside SimInfo's addMolecule + //method, at that point atoms don't have the global index yet + //(their global index are all initialized to -1). Therefore we + //have to call addExcludePairs explicitly here. A way to work + //around is that we can determine the beginning global indices of + //atoms before they get created. SimInfo::MoleculeIterator mi; Molecule* mol; for (mol= info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) {