6 |
|
#include "parse_me.h" |
7 |
|
#include "LRI.hpp" |
8 |
|
#include "Integrator.hpp" |
9 |
+ |
#include "simError.h" |
10 |
|
|
11 |
|
#ifdef IS_MPI |
12 |
|
#include "mpiBASS.h" |
16 |
|
SimSetup::SimSetup(){ |
17 |
|
stamps = new MakeStamps(); |
18 |
|
globals = new Globals(); |
19 |
+ |
|
20 |
+ |
#ifdef IS_MPI |
21 |
+ |
strcpy( checkPointMsg, "SimSetup creation successful" ); |
22 |
+ |
MPIcheckPoint(); |
23 |
+ |
#endif // IS_MPI |
24 |
|
} |
25 |
|
|
26 |
|
SimSetup::~SimSetup(){ |
30 |
|
|
31 |
|
void SimSetup::parseFile( char* fileName ){ |
32 |
|
|
27 |
– |
inFileName = fileName; |
28 |
– |
set_interface_stamps( stamps, globals ); |
33 |
|
#ifdef IS_MPI |
34 |
< |
mpiEventInit(); |
34 |
> |
if( worldRank == 0 ){ |
35 |
> |
#endif // is_mpi |
36 |
> |
|
37 |
> |
inFileName = fileName; |
38 |
> |
set_interface_stamps( stamps, globals ); |
39 |
> |
|
40 |
> |
#ifdef IS_MPI |
41 |
> |
mpiEventInit(); |
42 |
|
#endif |
43 |
< |
yacc_BASS( fileName ); |
43 |
> |
|
44 |
> |
yacc_BASS( fileName ); |
45 |
> |
|
46 |
|
#ifdef IS_MPI |
47 |
< |
throwMPIEvent(NULL); |
47 |
> |
throwMPIEvent(NULL); |
48 |
> |
} |
49 |
> |
else receiveParse(); |
50 |
|
#endif |
51 |
|
|
52 |
|
} |
56 |
|
|
57 |
|
set_interface_stamps( stamps, globals ); |
58 |
|
mpiEventInit(); |
59 |
+ |
MPIcheckPoint(); |
60 |
|
mpiEventLoop(); |
61 |
|
|
62 |
|
} |
68 |
|
delete dumpMe; |
69 |
|
} |
70 |
|
#endif |
71 |
+ |
|
72 |
|
void SimSetup::createSim( void ){ |
73 |
|
|
74 |
|
MakeStamps *the_stamps; |
93 |
|
else if( !strcmp( force_field, "DipoleTest" ) ) the_ff = new DipoleTestFF(); |
94 |
|
else if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF(); |
95 |
|
else{ |
96 |
< |
std::cerr<< "SimSetup Error. Unrecognized force field -> " |
97 |
< |
<< force_field << "\n"; |
98 |
< |
exit(8); |
96 |
> |
sprintf( painCave.errMsg, |
97 |
> |
"SimSetup Error. Unrecognized force field -> %s\n", |
98 |
> |
force_field ); |
99 |
> |
painCave.isFatal = 1; |
100 |
> |
simError(); |
101 |
|
} |
102 |
|
|
103 |
+ |
#ifdef IS_MPI |
104 |
+ |
strcpy( checkPointMsg, "ForceField creation successful" ); |
105 |
+ |
MPIcheckPoint(); |
106 |
+ |
#endif // is_mpi |
107 |
+ |
|
108 |
|
// get the components and calculate the tot_nMol and indvidual n_mol |
109 |
|
the_components = the_globals->getComponents(); |
110 |
|
components_nmol = new int[n_components]; |
119 |
|
|
120 |
|
if( !the_components[i]->haveNMol() ){ |
121 |
|
// we have a problem |
122 |
< |
std::cerr << "SimSetup Error. No global NMol or component NMol" |
123 |
< |
<< " given. Cannot calculate the number of atoms.\n"; |
124 |
< |
exit( 8 ); |
122 |
> |
sprintf( painCave.errMsg, |
123 |
> |
"SimSetup Error. No global NMol or component NMol" |
124 |
> |
" given. Cannot calculate the number of atoms.\n" ); |
125 |
> |
painCave.isFatal = 1; |
126 |
> |
simError(); |
127 |
|
} |
128 |
|
|
129 |
|
tot_nmol += the_components[i]->getNMol(); |
131 |
|
} |
132 |
|
} |
133 |
|
else{ |
134 |
< |
std::cerr << "NOT A SUPPORTED FEATURE\n"; |
135 |
< |
|
136 |
< |
// tot_nmol = the_globals->getNMol(); |
137 |
< |
|
138 |
< |
// //we have the total number of molecules, now we check for molfractions |
139 |
< |
// for( i=0; i<n_components; i++ ){ |
140 |
< |
|
141 |
< |
// if( !the_components[i]->haveMolFraction() ){ |
142 |
< |
|
143 |
< |
// if( !the_components[i]->haveNMol() ){ |
144 |
< |
// //we have a problem |
145 |
< |
// std::cerr << "SimSetup error. Neither molFraction nor " |
146 |
< |
// << " nMol was given in component |
147 |
< |
|
134 |
> |
sprintf( painCave.errMsg, |
135 |
> |
"SimSetup error.\n" |
136 |
> |
"\tSorry, the ability to specify total" |
137 |
> |
" nMols and then give molfractions in the components\n" |
138 |
> |
"\tis not currently supported." |
139 |
> |
" Please give nMol in the components.\n" ); |
140 |
> |
painCave.isFatal = 1; |
141 |
> |
simError(); |
142 |
> |
|
143 |
> |
|
144 |
> |
// tot_nmol = the_globals->getNMol(); |
145 |
> |
|
146 |
> |
// //we have the total number of molecules, now we check for molfractions |
147 |
> |
// for( i=0; i<n_components; i++ ){ |
148 |
> |
|
149 |
> |
// if( !the_components[i]->haveMolFraction() ){ |
150 |
> |
|
151 |
> |
// if( !the_components[i]->haveNMol() ){ |
152 |
> |
// //we have a problem |
153 |
> |
// std::cerr << "SimSetup error. Neither molFraction nor " |
154 |
> |
// << " nMol was given in component |
155 |
> |
|
156 |
|
} |
157 |
|
|
158 |
+ |
#ifdef IS_MPI |
159 |
+ |
strcpy( checkPointMsg, "Have the number of components" ); |
160 |
+ |
MPIcheckPoint(); |
161 |
+ |
#endif // is_mpi |
162 |
+ |
|
163 |
|
// make an array of molecule stamps that match the components used. |
164 |
|
|
165 |
|
for( i=0; i<n_components; i++ ){ |
191 |
|
simnfo->n_bends = tot_bends; |
192 |
|
simnfo->n_torsions = tot_torsions; |
193 |
|
simnfo->n_SRI = tot_SRI; |
194 |
+ |
simnfo->n_mol = tot_nmol; |
195 |
|
|
196 |
+ |
|
197 |
+ |
#ifdef IS_MPI |
198 |
+ |
|
199 |
+ |
// divide the molecules among processors here. |
200 |
+ |
|
201 |
+ |
new mpiSimulation( simnfo ); |
202 |
+ |
|
203 |
+ |
simnfo->mpiSim->divideLabor( n_components, comp_stamps, components_nmol ); |
204 |
+ |
|
205 |
+ |
#endif // is_mpi |
206 |
+ |
|
207 |
+ |
|
208 |
|
// create the atom and short range interaction arrays |
209 |
|
|
210 |
< |
the_atoms = new Atom*[tot_atoms]; |
211 |
< |
Atom::createArrays(tot_atoms); |
212 |
< |
the_molecules = new Molecule[tot_nmol]; |
210 |
> |
Atom::createArrays(simnfo->n_atoms); |
211 |
> |
the_atoms = new Atom*[simnfo->n_atoms]; |
212 |
> |
the_molecules = new Molecule[simnfo->n_mol]; |
213 |
|
|
214 |
|
|
215 |
< |
if( tot_SRI ){ |
216 |
< |
the_sris = new SRI*[tot_SRI]; |
217 |
< |
the_excludes = new ex_pair[tot_SRI]; |
215 |
> |
if( simnfo->n_SRI ){ |
216 |
> |
the_sris = new SRI*[simnfo->n_SRI]; |
217 |
> |
the_excludes = new ex_pair[simnfo->n_SRI]; |
218 |
|
} |
219 |
|
|
220 |
|
// set the arrays into the SimInfo object |
243 |
|
makeTorsions(); |
244 |
|
} |
245 |
|
|
194 |
– |
// makeMolecules(); |
246 |
|
|
247 |
|
// get some of the tricky things that may still be in the globals |
248 |
|
|
249 |
|
if( simnfo->n_dipoles ){ |
250 |
|
|
251 |
|
if( !the_globals->haveRRF() ){ |
252 |
< |
std::cerr << "SimSetup Error, system has dipoles, but no rRF was set.\n"; |
253 |
< |
exit(8); |
252 |
> |
sprintf( painCave.errMsg, |
253 |
> |
"SimSetup Error, system has dipoles, but no rRF was set.\n"); |
254 |
> |
painCave.isFatal = 1; |
255 |
> |
simError(); |
256 |
|
} |
257 |
|
if( !the_globals->haveDielectric() ){ |
258 |
< |
std::cerr << "SimSetup Error, system has dipoles, but no" |
259 |
< |
<< " dielectric was set.\n"; |
260 |
< |
exit(8); |
258 |
> |
sprintf( painCave.errMsg, |
259 |
> |
"SimSetup Error, system has dipoles, but no" |
260 |
> |
" dielectric was set.\n" ); |
261 |
> |
painCave.isFatal = 1; |
262 |
> |
simError(); |
263 |
|
} |
264 |
|
|
265 |
|
simnfo->rRF = the_globals->getRRF(); |
266 |
|
simnfo->dielectric = the_globals->getDielectric(); |
267 |
|
} |
268 |
|
|
269 |
+ |
#ifdef IS_MPI |
270 |
+ |
strcpy( checkPointMsg, "rRf and dielectric check out" ); |
271 |
+ |
MPIcheckPoint(); |
272 |
+ |
#endif // is_mpi |
273 |
+ |
|
274 |
|
if( the_globals->haveBox() ){ |
275 |
|
simnfo->box_x = the_globals->getBox(); |
276 |
|
simnfo->box_y = the_globals->getBox(); |
286 |
|
} |
287 |
|
else{ |
288 |
|
if( !the_globals->haveBoxX() ){ |
289 |
< |
std::cerr << "SimSetup error, no periodic BoxX size given.\n"; |
290 |
< |
exit(8); |
289 |
> |
sprintf( painCave.errMsg, |
290 |
> |
"SimSetup error, no periodic BoxX size given.\n" ); |
291 |
> |
painCave.isFatal = 1; |
292 |
> |
simError(); |
293 |
|
} |
294 |
|
simnfo->box_x = the_globals->getBoxX(); |
295 |
|
|
296 |
|
if( !the_globals->haveBoxY() ){ |
297 |
< |
std::cerr << "SimSetup error, no periodic BoxY size given.\n"; |
298 |
< |
exit(8); |
297 |
> |
sprintf( painCave.errMsg, |
298 |
> |
"SimSetup error, no periodic BoxY size given.\n" ); |
299 |
> |
painCave.isFatal = 1; |
300 |
> |
simError(); |
301 |
|
} |
302 |
|
simnfo->box_y = the_globals->getBoxY(); |
303 |
|
|
304 |
|
if( !the_globals->haveBoxZ() ){ |
305 |
< |
std::cerr << "SimSetup error, no periodic BoxZ size given.\n"; |
306 |
< |
exit(8); |
305 |
> |
sprintf( painCave.errMsg, |
306 |
> |
"SimSetup error, no periodic BoxZ size given.\n" ); |
307 |
> |
painCave.isFatal = 1; |
308 |
> |
simError(); |
309 |
|
} |
310 |
|
simnfo->box_z = the_globals->getBoxZ(); |
311 |
|
} |
312 |
|
|
313 |
+ |
#ifdef IS_MPI |
314 |
+ |
strcpy( checkPointMsg, "Box size set up" ); |
315 |
+ |
MPIcheckPoint(); |
316 |
+ |
#endif // is_mpi |
317 |
|
|
318 |
+ |
|
319 |
+ |
|
320 |
|
// if( the_globals->haveInitialConfig() ){ |
321 |
|
// InitializeFromFile* fileInit; |
322 |
|
// fileInit = new InitializeFromFile( the_globals->getInitialConfig() ); |
327 |
|
// } |
328 |
|
// else{ |
329 |
|
|
330 |
< |
initFromBass(); |
330 |
> |
#ifdef IS_MPI |
331 |
|
|
332 |
+ |
// no init from bass |
333 |
+ |
|
334 |
+ |
sprintf( painCave.errMsg, |
335 |
+ |
"Cannot intialize a parallel simulation without an initial configuration file.\n" ); |
336 |
+ |
painCave.isFatal; |
337 |
+ |
simError(); |
338 |
+ |
|
339 |
+ |
#else |
340 |
|
|
341 |
< |
// } |
341 |
> |
initFromBass(); |
342 |
|
|
343 |
< |
// if( the_globals->haveFinalConfig() ){ |
344 |
< |
// strcpy( simnfo->finalName, the_globals->getFinalConfig() ); |
345 |
< |
// } |
346 |
< |
// else{ |
347 |
< |
// strcpy( simnfo->finalName, inFileName ); |
348 |
< |
// char* endTest; |
269 |
< |
// int nameLength = strlen( simnfo->finalName ); |
270 |
< |
// endTest = &(simnfo->finalName[nameLength - 5]); |
271 |
< |
// if( !strcmp( endTest, ".bass" ) ){ |
272 |
< |
// strcpy( endTest, ".eor" ); |
273 |
< |
// } |
274 |
< |
// else if( !strcmp( endTest, ".BASS" ) ){ |
275 |
< |
// strcpy( endTest, ".eor" ); |
276 |
< |
// } |
277 |
< |
// else{ |
278 |
< |
// endTest = &(simnfo->finalName[nameLength - 4]); |
279 |
< |
// if( !strcmp( endTest, ".bss" ) ){ |
280 |
< |
// strcpy( endTest, ".eor" ); |
281 |
< |
// } |
282 |
< |
// else if( !strcmp( endTest, ".mdl" ) ){ |
283 |
< |
// strcpy( endTest, ".eor" ); |
284 |
< |
// } |
285 |
< |
// else{ |
286 |
< |
// strcat( simnfo->finalName, ".eor" ); |
287 |
< |
// } |
288 |
< |
// } |
289 |
< |
// } |
343 |
> |
#endif // is_mpi |
344 |
> |
|
345 |
> |
#ifdef IS_MPI |
346 |
> |
strcpy( checkPointMsg, "Successfully read in the initial configuration" ); |
347 |
> |
MPIcheckPoint(); |
348 |
> |
#endif // is_mpi |
349 |
|
|
291 |
– |
// // make the sample and status out names |
350 |
|
|
351 |
< |
// strcpy( simnfo->sampleName, inFileName ); |
352 |
< |
// char* endTest; |
353 |
< |
// int nameLength = strlen( simnfo->sampleName ); |
354 |
< |
// endTest = &(simnfo->sampleName[nameLength - 5]); |
355 |
< |
// if( !strcmp( endTest, ".bass" ) ){ |
356 |
< |
// strcpy( endTest, ".dump" ); |
357 |
< |
// } |
358 |
< |
// else if( !strcmp( endTest, ".BASS" ) ){ |
359 |
< |
// strcpy( endTest, ".dump" ); |
360 |
< |
// } |
361 |
< |
// else{ |
362 |
< |
// endTest = &(simnfo->sampleName[nameLength - 4]); |
363 |
< |
// if( !strcmp( endTest, ".bss" ) ){ |
364 |
< |
// strcpy( endTest, ".dump" ); |
365 |
< |
// } |
366 |
< |
// else if( !strcmp( endTest, ".mdl" ) ){ |
367 |
< |
// strcpy( endTest, ".dump" ); |
368 |
< |
// } |
369 |
< |
// else{ |
370 |
< |
// strcat( simnfo->sampleName, ".dump" ); |
371 |
< |
// } |
372 |
< |
// } |
373 |
< |
|
374 |
< |
// strcpy( simnfo->statusName, inFileName ); |
375 |
< |
// nameLength = strlen( simnfo->statusName ); |
376 |
< |
// endTest = &(simnfo->statusName[nameLength - 5]); |
377 |
< |
// if( !strcmp( endTest, ".bass" ) ){ |
378 |
< |
// strcpy( endTest, ".stat" ); |
379 |
< |
// } |
380 |
< |
// else if( !strcmp( endTest, ".BASS" ) ){ |
381 |
< |
// strcpy( endTest, ".stat" ); |
382 |
< |
// } |
383 |
< |
// else{ |
384 |
< |
// endTest = &(simnfo->statusName[nameLength - 4]); |
385 |
< |
// if( !strcmp( endTest, ".bss" ) ){ |
386 |
< |
// strcpy( endTest, ".stat" ); |
387 |
< |
// } |
388 |
< |
// else if( !strcmp( endTest, ".mdl" ) ){ |
389 |
< |
// strcpy( endTest, ".stat" ); |
390 |
< |
// } |
391 |
< |
// else{ |
392 |
< |
// strcat( simnfo->statusName, ".stat" ); |
393 |
< |
// } |
394 |
< |
// } |
395 |
< |
|
396 |
< |
|
351 |
> |
|
352 |
> |
|
353 |
> |
|
354 |
> |
// } |
355 |
> |
|
356 |
> |
#ifdef IS_MPI |
357 |
> |
if( worldRank == 0 ){ |
358 |
> |
#endif // is_mpi |
359 |
> |
|
360 |
> |
if( the_globals->haveFinalConfig() ){ |
361 |
> |
strcpy( simnfo->finalName, the_globals->getFinalConfig() ); |
362 |
> |
} |
363 |
> |
else{ |
364 |
> |
strcpy( simnfo->finalName, inFileName ); |
365 |
> |
char* endTest; |
366 |
> |
int nameLength = strlen( simnfo->finalName ); |
367 |
> |
endTest = &(simnfo->finalName[nameLength - 5]); |
368 |
> |
if( !strcmp( endTest, ".bass" ) ){ |
369 |
> |
strcpy( endTest, ".eor" ); |
370 |
> |
} |
371 |
> |
else if( !strcmp( endTest, ".BASS" ) ){ |
372 |
> |
strcpy( endTest, ".eor" ); |
373 |
> |
} |
374 |
> |
else{ |
375 |
> |
endTest = &(simnfo->finalName[nameLength - 4]); |
376 |
> |
if( !strcmp( endTest, ".bss" ) ){ |
377 |
> |
strcpy( endTest, ".eor" ); |
378 |
> |
} |
379 |
> |
else if( !strcmp( endTest, ".mdl" ) ){ |
380 |
> |
strcpy( endTest, ".eor" ); |
381 |
> |
} |
382 |
> |
else{ |
383 |
> |
strcat( simnfo->finalName, ".eor" ); |
384 |
> |
} |
385 |
> |
} |
386 |
> |
} |
387 |
> |
|
388 |
> |
// make the sample and status out names |
389 |
> |
|
390 |
> |
strcpy( simnfo->sampleName, inFileName ); |
391 |
> |
char* endTest; |
392 |
> |
int nameLength = strlen( simnfo->sampleName ); |
393 |
> |
endTest = &(simnfo->sampleName[nameLength - 5]); |
394 |
> |
if( !strcmp( endTest, ".bass" ) ){ |
395 |
> |
strcpy( endTest, ".dump" ); |
396 |
> |
} |
397 |
> |
else if( !strcmp( endTest, ".BASS" ) ){ |
398 |
> |
strcpy( endTest, ".dump" ); |
399 |
> |
} |
400 |
> |
else{ |
401 |
> |
endTest = &(simnfo->sampleName[nameLength - 4]); |
402 |
> |
if( !strcmp( endTest, ".bss" ) ){ |
403 |
> |
strcpy( endTest, ".dump" ); |
404 |
> |
} |
405 |
> |
else if( !strcmp( endTest, ".mdl" ) ){ |
406 |
> |
strcpy( endTest, ".dump" ); |
407 |
> |
} |
408 |
> |
else{ |
409 |
> |
strcat( simnfo->sampleName, ".dump" ); |
410 |
> |
} |
411 |
> |
} |
412 |
> |
|
413 |
> |
strcpy( simnfo->statusName, inFileName ); |
414 |
> |
nameLength = strlen( simnfo->statusName ); |
415 |
> |
endTest = &(simnfo->statusName[nameLength - 5]); |
416 |
> |
if( !strcmp( endTest, ".bass" ) ){ |
417 |
> |
strcpy( endTest, ".stat" ); |
418 |
> |
} |
419 |
> |
else if( !strcmp( endTest, ".BASS" ) ){ |
420 |
> |
strcpy( endTest, ".stat" ); |
421 |
> |
} |
422 |
> |
else{ |
423 |
> |
endTest = &(simnfo->statusName[nameLength - 4]); |
424 |
> |
if( !strcmp( endTest, ".bss" ) ){ |
425 |
> |
strcpy( endTest, ".stat" ); |
426 |
> |
} |
427 |
> |
else if( !strcmp( endTest, ".mdl" ) ){ |
428 |
> |
strcpy( endTest, ".stat" ); |
429 |
> |
} |
430 |
> |
else{ |
431 |
> |
strcat( simnfo->statusName, ".stat" ); |
432 |
> |
} |
433 |
> |
} |
434 |
> |
|
435 |
> |
#ifdef IS_MPI |
436 |
> |
} |
437 |
> |
#endif // is_mpi |
438 |
> |
|
439 |
|
// set the status, sample, and themal kick times |
440 |
< |
|
440 |
> |
|
441 |
|
if( the_globals->haveSampleTime() ){ |
442 |
|
simnfo->sampleTime = the_globals->getSampleTime(); |
443 |
|
simnfo->statusTime = simnfo->sampleTime; |
660 |
|
n_per_extra = (int)ceil( temp1 ); |
661 |
|
|
662 |
|
if( n_per_extra > 4){ |
663 |
< |
std::cerr << "THere has been an error in constructing the non-complete lattice.\n"; |
664 |
< |
exit(8); |
663 |
> |
sprintf( painCave.errMsg, |
664 |
> |
"SimSetup error. There has been an error in constructing" |
665 |
> |
" the non-complete lattice.\n" ); |
666 |
> |
painCave.isFatal = 1; |
667 |
> |
simError(); |
668 |
|
} |
669 |
|
} |
670 |
|
else{ |
769 |
|
|
770 |
|
current_atom = comp_stamps[current_comp]->getAtom( k ); |
771 |
|
if( !current_atom->havePosition() ){ |
772 |
< |
std::cerr << "Component " << comp_stamps[current_comp]->getID() |
773 |
< |
<< ", atom " << current_atom->getType() |
774 |
< |
<< " does not have a position specified.\n" |
775 |
< |
<< "The initialization routine is unable to give a start" |
776 |
< |
<< " position.\n"; |
777 |
< |
exit(8); |
772 |
> |
sprintf( painCave.errMsg, |
773 |
> |
"SimSetup:initFromBass error.\n" |
774 |
> |
"\tComponent %s, atom %s does not have a position specified.\n" |
775 |
> |
"\tThe initialization routine is unable to give a start" |
776 |
> |
" position.\n", |
777 |
> |
comp_stamps[current_comp]->getID(), |
778 |
> |
current_atom->getType() ); |
779 |
> |
painCave.isFatal = 1; |
780 |
> |
simError(); |
781 |
|
} |
782 |
|
|
783 |
|
the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() ); |