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 176 by mmeineke, Thu Nov 14 22:00:44 2002 UTC vs.
Revision 194 by chuckv, Wed Dec 4 21:19:38 2002 UTC

# Line 119 | 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 129 | 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 177 | 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  
182  the_atoms = new Atom*[tot_atoms];
200    Atom::createArrays(tot_atoms);
201 +  the_atoms = new Atom*[tot_atoms];
202    the_molecules = new Molecule[tot_nmol];
203  
204  
# Line 222 | 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 250 | 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 279 | Line 318 | void SimSetup::createSim( void ){
318   //   }
319   //   else{
320  
321 <    initFromBass();
322 <
323 <
324 < //   }
325 <
326 < //   if( the_globals->haveFinalConfig() ){
288 < //     strcpy( simnfo->finalName, the_globals->getFinalConfig() );
289 < //   }
290 < //   else{
291 < //     strcpy( simnfo->finalName, inFileName );
292 < //     char* endTest;
293 < //     int nameLength = strlen( simnfo->finalName );
294 < //     endTest = &(simnfo->finalName[nameLength - 5]);
295 < //     if( !strcmp( endTest, ".bass" ) ){
296 < //       strcpy( endTest, ".eor" );
297 < //     }
298 < //     else if( !strcmp( endTest, ".BASS" ) ){
299 < //       strcpy( endTest, ".eor" );
300 < //     }
301 < //     else{
302 < //       endTest = &(simnfo->finalName[nameLength - 4]);
303 < //       if( !strcmp( endTest, ".bss" ) ){
304 < //      strcpy( endTest, ".eor" );
305 < //       }
306 < //       else if( !strcmp( endTest, ".mdl" ) ){
307 < //      strcpy( endTest, ".eor" );
308 < //       }
309 < //       else{
310 < //      strcat( simnfo->finalName, ".eor" );
311 < //       }
312 < //     }
313 < //   }
314 <
315 < //   // make the sample and status out names
316 <
317 < //   strcpy( simnfo->sampleName, inFileName );
318 < //   char* endTest;
319 < //   int nameLength = strlen( simnfo->sampleName );
320 < //   endTest = &(simnfo->sampleName[nameLength - 5]);
321 < //   if( !strcmp( endTest, ".bass" ) ){
322 < //     strcpy( endTest, ".dump" );
323 < //   }
324 < //   else if( !strcmp( endTest, ".BASS" ) ){
325 < //     strcpy( endTest, ".dump" );
326 < //   }
327 < //   else{
328 < //     endTest = &(simnfo->sampleName[nameLength - 4]);
329 < //     if( !strcmp( endTest, ".bss" ) ){
330 < //       strcpy( endTest, ".dump" );
331 < //     }
332 < //     else if( !strcmp( endTest, ".mdl" ) ){
333 < //       strcpy( endTest, ".dump" );
334 < //     }
335 < //     else{
336 < //       strcat( simnfo->sampleName, ".dump" );
337 < //     }
338 < //   }
321 >  initFromBass();
322 >
323 > #ifdef IS_MPI
324 >  strcpy( checkPointMsg, "initFromBass successfully created the lattice" );
325 >  MPIcheckPoint();
326 > #endif // is_mpi
327  
340 //   strcpy( simnfo->statusName, inFileName );
341 //   nameLength = strlen( simnfo->statusName );
342 //   endTest = &(simnfo->statusName[nameLength - 5]);
343 //   if( !strcmp( endTest, ".bass" ) ){
344 //     strcpy( endTest, ".stat" );
345 //   }
346 //   else if( !strcmp( endTest, ".BASS" ) ){
347 //     strcpy( endTest, ".stat" );
348 //   }
349 //   else{
350 //     endTest = &(simnfo->statusName[nameLength - 4]);
351 //     if( !strcmp( endTest, ".bss" ) ){
352 //       strcpy( endTest, ".stat" );
353 //     }
354 //     else if( !strcmp( endTest, ".mdl" ) ){
355 //       strcpy( endTest, ".stat" );
356 //     }
357 //     else{
358 //       strcat( simnfo->statusName, ".stat" );
359 //     }
360 //   }
328  
329 <
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 584 | 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 690 | 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