# | Line 46 | Line 46 | |
---|---|---|
46 | * @time 13:51am | |
47 | * @version 1.0 | |
48 | */ | |
49 | < | |
49 | > | #include <exception> |
50 | #include <iostream> | |
51 | #include <sstream> | |
52 | #include <string> | |
# | Line 102 | Line 102 | Globals* SimCreator::parseFile(const std::string mdFil | |
102 | streamSize = ppStream.str().size() +1; | |
103 | commStatus = MPI_Bcast(&streamSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD); | |
104 | ||
105 | < | commStatus = MPI_Bcast(ppStream.str().c_str(), streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
105 | > | commStatus = MPI_Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
106 | ||
107 | ||
108 | } else { | |
# | Line 147 | Line 147 | Globals* SimCreator::parseFile(const std::string mdFil | |
147 | simParams = treeParser.walkTree(parser.getAST()); | |
148 | ||
149 | } | |
150 | + | |
151 | ||
152 | catch(antlr::MismatchedCharException& e) { | |
153 | < | cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; |
153 | > | sprintf(painCave.errMsg, |
154 | > | "parser exception: %s %s:%d:%d\n", |
155 | > | e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); |
156 | > | painCave.isFatal = 1; |
157 | > | simError(); |
158 | } | |
159 | catch(antlr::MismatchedTokenException &e) { | |
160 | < | cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; |
160 | > | sprintf(painCave.errMsg, |
161 | > | "parser exception: %s %s:%d:%d\n", |
162 | > | e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); |
163 | > | painCave.isFatal = 1; |
164 | > | simError(); |
165 | } | |
166 | catch(antlr::NoViableAltForCharException &e) { | |
167 | < | cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; |
167 | > | sprintf(painCave.errMsg, |
168 | > | "parser exception: %s %s:%d:%d\n", |
169 | > | e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); |
170 | > | painCave.isFatal = 1; |
171 | > | simError(); |
172 | } | |
173 | catch(antlr::NoViableAltException &e) { | |
174 | < | cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; |
174 | > | sprintf(painCave.errMsg, |
175 | > | "parser exception: %s %s:%d:%d\n", |
176 | > | e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); |
177 | > | painCave.isFatal = 1; |
178 | > | simError(); |
179 | } | |
180 | + | |
181 | catch(antlr::TokenStreamRecognitionException& e) { | |
182 | < | cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; |
182 | > | sprintf(painCave.errMsg, |
183 | > | "parser exception: %s %s:%d:%d\n", |
184 | > | e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); |
185 | > | painCave.isFatal = 1; |
186 | > | simError(); |
187 | } | |
188 | + | |
189 | catch(antlr::TokenStreamIOException& e) { | |
190 | < | cerr<< "parser exception: " << e.getMessage() << endl; |
190 | > | sprintf(painCave.errMsg, |
191 | > | "parser exception: %s\n", |
192 | > | e.getMessage().c_str()); |
193 | > | painCave.isFatal = 1; |
194 | > | simError(); |
195 | } | |
196 | + | |
197 | catch(antlr::TokenStreamException& e) { | |
198 | < | cerr<< "parser exception: " << e.getMessage() << endl; |
198 | > | sprintf(painCave.errMsg, |
199 | > | "parser exception: %s\n", |
200 | > | e.getMessage().c_str()); |
201 | > | painCave.isFatal = 1; |
202 | > | simError(); |
203 | } | |
204 | catch (antlr::RecognitionException& e) { | |
205 | < | cerr<< "parser exception: " << e.getMessage() << " " << e.getFilename() << ":" << e.getLine() << " " << e.getColumn() << endl; |
205 | > | sprintf(painCave.errMsg, |
206 | > | "parser exception: %s %s:%d:%d\n", |
207 | > | e.getMessage().c_str(),e.getFilename().c_str(), e.getLine(), e.getColumn()); |
208 | > | painCave.isFatal = 1; |
209 | > | simError(); |
210 | } | |
211 | catch (antlr::CharStreamException& e) { | |
212 | < | cerr << "parser exception: " << e.getMessage() << endl; |
212 | > | sprintf(painCave.errMsg, |
213 | > | "parser exception: %s\n", |
214 | > | e.getMessage().c_str()); |
215 | > | painCave.isFatal = 1; |
216 | > | simError(); |
217 | } | |
218 | < | catch (exception& e) { |
219 | < | cerr << "parser exception: " << e.what() << endl; |
220 | < | } |
218 | > | catch (OOPSEException& e) { |
219 | > | sprintf(painCave.errMsg, |
220 | > | "%s\n", |
221 | > | e.getMessage().c_str()); |
222 | > | painCave.isFatal = 1; |
223 | > | simError(); |
224 | > | } |
225 | > | catch (std::exception& e) { |
226 | > | sprintf(painCave.errMsg, |
227 | > | "parser exception: %s\n", |
228 | > | e.what()); |
229 | > | painCave.isFatal = 1; |
230 | > | simError(); |
231 | > | } |
232 | ||
233 | return simParams; | |
234 | } | |
# | Line 228 | Line 279 | Globals* SimCreator::parseFile(const std::string mdFil | |
279 | //create SimInfo | |
280 | SimInfo * info = new SimInfo(ff, simParams); | |
281 | ||
282 | < | //gather parameters (SimCreator only retrieves part of the parameters) |
282 | > | //gather parameters (SimCreator only retrieves part of the |
283 | > | //parameters) |
284 | gatherParameters(info, mdFileName); | |
285 | ||
286 | //divide the molecules and determine the global index of molecules | |
# | Line 240 | Line 292 | Globals* SimCreator::parseFile(const std::string mdFil | |
292 | createMolecules(info); | |
293 | ||
294 | ||
295 | < | //allocate memory for DataStorage(circular reference, need to break it) |
295 | > | //allocate memory for DataStorage(circular reference, need to |
296 | > | //break it) |
297 | info->setSnapshotManager(new SimSnapshotManager(info)); | |
298 | ||
299 | < | //set the global index of atoms, rigidbodies and cutoffgroups (only need to be set once, the |
300 | < | //global index will never change again). Local indices of atoms and rigidbodies are already set by |
301 | < | //MoleculeCreator class which actually delegates the responsibility to LocalIndexManager. |
299 | > | //set the global index of atoms, rigidbodies and cutoffgroups |
300 | > | //(only need to be set once, the global index will never change |
301 | > | //again). Local indices of atoms and rigidbodies are already set |
302 | > | //by MoleculeCreator class which actually delegates the |
303 | > | //responsibility to LocalIndexManager. |
304 | setGlobalIndex(info); | |
305 | ||
306 | < | //Alought addExculdePairs is called inside SimInfo's addMolecule method, at that point |
307 | < | //atoms don't have the global index yet (their global index are all initialized to -1). |
308 | < | //Therefore we have to call addExcludePairs explicitly here. A way to work around is that |
309 | < | //we can determine the beginning global indices of atoms before they get created. |
306 | > | //Although addExcludePairs is called inside SimInfo's addMolecule |
307 | > | //method, at that point atoms don't have the global index yet |
308 | > | //(their global index are all initialized to -1). Therefore we |
309 | > | //have to call addExcludePairs explicitly here. A way to work |
310 | > | //around is that we can determine the beginning global indices of |
311 | > | //atoms before they get created. |
312 | SimInfo::MoleculeIterator mi; | |
313 | Molecule* mol; | |
314 | for (mol= info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) { |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |