ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/interface_implementation/SimSetup.cpp
(Generate patch)

Comparing trunk/mdtools/interface_implementation/SimSetup.cpp (file contents):
Revision 144 by mmeineke, Thu Oct 17 21:59:12 2002 UTC vs.
Revision 194 by chuckv, Wed Dec 4 21:19:38 2002 UTC

# Line 6 | Line 6
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"
# Line 15 | Line 16 | SimSetup::SimSetup(){
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(){
# Line 24 | Line 30 | void SimSetup::parseFile( char* fileName ){
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   }
# Line 41 | Line 56 | void SimSetup::receiveParse(void){
56  
57      set_interface_stamps( stamps, globals );
58      mpiEventInit();
59 +    MPIcheckPoint();
60      mpiEventLoop();
61  
62   }
# Line 52 | Line 68 | void SimSetup::createSim( void ){
68    delete dumpMe;
69   }
70   #endif
71 +
72   void SimSetup::createSim( void ){
73  
74    MakeStamps *the_stamps;
# Line 76 | Line 93 | void SimSetup::createSim( void ){
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];
# Line 95 | Line 119 | void SimSetup::createSim( void ){
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();
# Line 105 | Line 131 | void SimSetup::createSim( void ){
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++ ){
# Line 153 | Line 192 | void SimSetup::createSim( void ){
192    simnfo->n_torsions = tot_torsions;
193    simnfo->n_SRI = tot_SRI;
194  
195 +  // divide the molecules among processors here.
196 +
197 +
198    // create the atom and short range interaction arrays
199  
200 +  Atom::createArrays(tot_atoms);
201    the_atoms = new Atom*[tot_atoms];
202    the_molecules = new Molecule[tot_nmol];
203  
# Line 197 | Line 240 | void SimSetup::createSim( void ){
240    if( simnfo->n_dipoles ){
241  
242      if( !the_globals->haveRRF() ){
243 <      std::cerr << "SimSetup Error, system has dipoles, but no rRF was set.\n";
244 <      exit(8);
243 >      sprintf( painCave.errMsg,
244 >               "SimSetup Error, system has dipoles, but no rRF was set.\n");
245 >      painCave.isFatal = 1;
246 >      simError();
247      }
248      if( !the_globals->haveDielectric() ){
249 <      std::cerr << "SimSetup Error, system has dipoles, but no"
250 <                << " dielectric was set.\n";
251 <      exit(8);
249 >      sprintf( painCave.errMsg,
250 >               "SimSetup Error, system has dipoles, but no"
251 >               " dielectric was set.\n" );
252 >      painCave.isFatal = 1;
253 >      simError();
254      }
255  
256      simnfo->rRF        = the_globals->getRRF();
257      simnfo->dielectric = the_globals->getDielectric();
258    }
259  
260 + #ifdef IS_MPI
261 +  strcpy( checkPointMsg, "rRf and dielectric check out" );
262 +  MPIcheckPoint();
263 + #endif // is_mpi
264 +  
265    if( the_globals->haveBox() ){
266      simnfo->box_x = the_globals->getBox();
267      simnfo->box_y = the_globals->getBox();
# Line 225 | Line 277 | void SimSetup::createSim( void ){
277    }
278    else{
279      if( !the_globals->haveBoxX() ){
280 <      std::cerr << "SimSetup error, no periodic BoxX size given.\n";
281 <      exit(8);
280 >      sprintf( painCave.errMsg,
281 >               "SimSetup error, no periodic BoxX size given.\n" );
282 >      painCave.isFatal = 1;
283 >      simError();
284      }
285      simnfo->box_x = the_globals->getBoxX();
286  
287      if( !the_globals->haveBoxY() ){
288 <      std::cerr << "SimSetup error, no periodic BoxY size given.\n";
289 <      exit(8);
288 >      sprintf( painCave.errMsg,
289 >               "SimSetup error, no periodic BoxY size given.\n" );
290 >      painCave.isFatal = 1;
291 >      simError();
292      }
293      simnfo->box_y = the_globals->getBoxY();
294  
295      if( !the_globals->haveBoxZ() ){
296 <      std::cerr << "SimSetup error, no periodic BoxZ size given.\n";
297 <      exit(8);
296 >      sprintf( painCave.errMsg,
297 >               "SimSetup error, no periodic BoxZ size given.\n" );
298 >      painCave.isFatal = 1;
299 >      simError();
300      }
301      simnfo->box_z = the_globals->getBoxZ();
302    }
303  
304 + #ifdef IS_MPI
305 +  strcpy( checkPointMsg, "Box size set up" );
306 +  MPIcheckPoint();
307 + #endif // is_mpi
308  
309 +
310 +
311   //   if( the_globals->haveInitialConfig() ){
312   //        InitializeFromFile* fileInit;
313   //     fileInit = new InitializeFromFile( the_globals->getInitialConfig() );
# Line 254 | Line 318 | void SimSetup::createSim( void ){
318   //   }
319   //   else{
320  
321 <    initFromBass();
322 <
323 <
324 < //   }
325 <
326 < //   if( the_globals->haveFinalConfig() ){
263 < //     strcpy( simnfo->finalName, the_globals->getFinalConfig() );
264 < //   }
265 < //   else{
266 < //     strcpy( simnfo->finalName, inFileName );
267 < //     char* endTest;
268 < //     int nameLength = strlen( simnfo->finalName );
269 < //     endTest = &(simnfo->finalName[nameLength - 5]);
270 < //     if( !strcmp( endTest, ".bass" ) ){
271 < //       strcpy( endTest, ".eor" );
272 < //     }
273 < //     else if( !strcmp( endTest, ".BASS" ) ){
274 < //       strcpy( endTest, ".eor" );
275 < //     }
276 < //     else{
277 < //       endTest = &(simnfo->finalName[nameLength - 4]);
278 < //       if( !strcmp( endTest, ".bss" ) ){
279 < //      strcpy( endTest, ".eor" );
280 < //       }
281 < //       else if( !strcmp( endTest, ".mdl" ) ){
282 < //      strcpy( endTest, ".eor" );
283 < //       }
284 < //       else{
285 < //      strcat( simnfo->finalName, ".eor" );
286 < //       }
287 < //     }
288 < //   }
289 <
290 < //   // make the sample and status out names
321 >  initFromBass();
322 >
323 > #ifdef IS_MPI
324 >  strcpy( checkPointMsg, "initFromBass successfully created the lattice" );
325 >  MPIcheckPoint();
326 > #endif // is_mpi
327  
292 //   strcpy( simnfo->sampleName, inFileName );
293 //   char* endTest;
294 //   int nameLength = strlen( simnfo->sampleName );
295 //   endTest = &(simnfo->sampleName[nameLength - 5]);
296 //   if( !strcmp( endTest, ".bass" ) ){
297 //     strcpy( endTest, ".dump" );
298 //   }
299 //   else if( !strcmp( endTest, ".BASS" ) ){
300 //     strcpy( endTest, ".dump" );
301 //   }
302 //   else{
303 //     endTest = &(simnfo->sampleName[nameLength - 4]);
304 //     if( !strcmp( endTest, ".bss" ) ){
305 //       strcpy( endTest, ".dump" );
306 //     }
307 //     else if( !strcmp( endTest, ".mdl" ) ){
308 //       strcpy( endTest, ".dump" );
309 //     }
310 //     else{
311 //       strcat( simnfo->sampleName, ".dump" );
312 //     }
313 //   }
328  
329 < //   strcpy( simnfo->statusName, inFileName );
330 < //   nameLength = strlen( simnfo->statusName );
331 < //   endTest = &(simnfo->statusName[nameLength - 5]);
332 < //   if( !strcmp( endTest, ".bass" ) ){
333 < //     strcpy( endTest, ".stat" );
334 < //   }
335 < //   else if( !strcmp( endTest, ".BASS" ) ){
336 < //     strcpy( endTest, ".stat" );
337 < //   }
338 < //   else{
339 < //     endTest = &(simnfo->statusName[nameLength - 4]);
340 < //     if( !strcmp( endTest, ".bss" ) ){
341 < //       strcpy( endTest, ".stat" );
342 < //     }
343 < //     else if( !strcmp( endTest, ".mdl" ) ){
344 < //       strcpy( endTest, ".stat" );
345 < //     }
346 < //     else{
347 < //       strcat( simnfo->statusName, ".stat" );
348 < //     }
349 < //   }
350 <
351 <
329 >  
330 >
331 >  
332 >  //   }
333 >  
334 > #ifdef IS_MPI
335 >  if( worldRank == 0 ){
336 > #endif // is_mpi
337 >    
338 >    if( the_globals->haveFinalConfig() ){
339 >      strcpy( simnfo->finalName, the_globals->getFinalConfig() );
340 >    }
341 >    else{
342 >      strcpy( simnfo->finalName, inFileName );
343 >      char* endTest;
344 >      int nameLength = strlen( simnfo->finalName );
345 >      endTest = &(simnfo->finalName[nameLength - 5]);
346 >      if( !strcmp( endTest, ".bass" ) ){
347 >        strcpy( endTest, ".eor" );
348 >      }
349 >      else if( !strcmp( endTest, ".BASS" ) ){
350 >        strcpy( endTest, ".eor" );
351 >      }
352 >      else{
353 >        endTest = &(simnfo->finalName[nameLength - 4]);
354 >        if( !strcmp( endTest, ".bss" ) ){
355 >          strcpy( endTest, ".eor" );
356 >        }
357 >        else if( !strcmp( endTest, ".mdl" ) ){
358 >          strcpy( endTest, ".eor" );
359 >        }
360 >        else{
361 >          strcat( simnfo->finalName, ".eor" );
362 >        }
363 >      }
364 >    }
365 >    
366 >    // make the sample and status out names
367 >    
368 >    strcpy( simnfo->sampleName, inFileName );
369 >    char* endTest;
370 >    int nameLength = strlen( simnfo->sampleName );
371 >    endTest = &(simnfo->sampleName[nameLength - 5]);
372 >    if( !strcmp( endTest, ".bass" ) ){
373 >      strcpy( endTest, ".dump" );
374 >    }
375 >    else if( !strcmp( endTest, ".BASS" ) ){
376 >      strcpy( endTest, ".dump" );
377 >    }
378 >    else{
379 >      endTest = &(simnfo->sampleName[nameLength - 4]);
380 >      if( !strcmp( endTest, ".bss" ) ){
381 >        strcpy( endTest, ".dump" );
382 >      }
383 >      else if( !strcmp( endTest, ".mdl" ) ){
384 >        strcpy( endTest, ".dump" );
385 >      }
386 >      else{
387 >        strcat( simnfo->sampleName, ".dump" );
388 >      }
389 >    }
390 >    
391 >    strcpy( simnfo->statusName, inFileName );
392 >    nameLength = strlen( simnfo->statusName );
393 >    endTest = &(simnfo->statusName[nameLength - 5]);
394 >    if( !strcmp( endTest, ".bass" ) ){
395 >      strcpy( endTest, ".stat" );
396 >    }
397 >    else if( !strcmp( endTest, ".BASS" ) ){
398 >      strcpy( endTest, ".stat" );
399 >    }
400 >    else{
401 >      endTest = &(simnfo->statusName[nameLength - 4]);
402 >      if( !strcmp( endTest, ".bss" ) ){
403 >        strcpy( endTest, ".stat" );
404 >      }
405 >      else if( !strcmp( endTest, ".mdl" ) ){
406 >        strcpy( endTest, ".stat" );
407 >      }
408 >      else{
409 >        strcat( simnfo->statusName, ".stat" );
410 >      }
411 >    }
412 >    
413 > #ifdef IS_MPI
414 >  }
415 > #endif // is_mpi
416 >  
417    // set the status, sample, and themal kick times
418 <
418 >  
419    if( the_globals->haveSampleTime() ){
420      simnfo->sampleTime = the_globals->getSampleTime();
421      simnfo->statusTime = simnfo->sampleTime;
# Line 392 | Line 471 | void SimSetup::makeAtoms( void ){
471          current_atom = comp_stamps[i]->getAtom( k );
472          if( current_atom->haveOrientation() ){
473  
474 <          dAtom = new DirectionalAtom;
474 >          dAtom = new DirectionalAtom(index);
475            simnfo->n_oriented++;
476            the_atoms[index] = dAtom;
477  
# Line 412 | Line 491 | void SimSetup::makeAtoms( void ){
491            dAtom->setSUz( uz );
492          }
493          else{
494 <          the_atoms[index] = new GeneralAtom;
494 >          the_atoms[index] = new GeneralAtom(index);
495          }
496          the_atoms[index]->setType( current_atom->getType() );
497          the_atoms[index]->setIndex( index );
# Line 559 | Line 638 | void SimSetup::initFromBass( void ){
638      n_per_extra = (int)ceil( temp1 );
639  
640      if( n_per_extra > 4){
641 <      std::cerr << "THere has been an error in constructing the non-complete lattice.\n";
642 <      exit(8);
641 >      sprintf( painCave.errMsg,
642 >               "SimSetup error. There has been an error in constructing"
643 >               " the non-complete lattice.\n" );
644 >      painCave.isFatal = 1;
645 >      simError();
646      }
647    }
648    else{
# Line 665 | Line 747 | void SimSetup::makeElement( double x, double y, double
747  
748      current_atom = comp_stamps[current_comp]->getAtom( k );
749      if( !current_atom->havePosition() ){
750 <      std::cerr << "Component " << comp_stamps[current_comp]->getID()
751 <                << ", atom " << current_atom->getType()
752 <                << " does not have a position specified.\n"
753 <                << "The initialization routine is unable to give a start"
754 <                << " position.\n";
755 <      exit(8);
750 >      sprintf( painCave.errMsg,
751 >               "SimSetup:initFromBass error.\n"
752 >               "\tComponent %s, atom %s does not have a position specified.\n"
753 >               "\tThe initialization routine is unable to give a start"
754 >               " position.\n",
755 >               comp_stamps[current_comp]->getID(),
756 >               current_atom->getType() );
757 >      painCave.isFatal = 1;
758 >      simError();
759      }
760  
761      the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines