--- trunk/mdtools/interface_implementation/SimSetup.cpp 2002/11/21 20:33:06 184 +++ trunk/mdtools/interface_implementation/SimSetup.cpp 2002/11/26 21:04:43 189 @@ -119,9 +119,11 @@ void SimSetup::createSim( void ){ if( !the_components[i]->haveNMol() ){ // we have a problem - std::cerr << "SimSetup Error. No global NMol or component NMol" - << " given. Cannot calculate the number of atoms.\n"; - exit( 8 ); + sprintf( painCave.errMsg, + "SimSetup Error. No global NMol or component NMol" + " given. Cannot calculate the number of atoms.\n" ); + painCave.isFatal = 1; + simError(); } tot_nmol += the_components[i]->getNMol(); @@ -129,22 +131,35 @@ void SimSetup::createSim( void ){ } } else{ - std::cerr << "NOT A SUPPORTED FEATURE\n"; - -// tot_nmol = the_globals->getNMol(); - -// //we have the total number of molecules, now we check for molfractions -// for( i=0; ihaveMolFraction() ){ - -// if( !the_components[i]->haveNMol() ){ -// //we have a problem -// std::cerr << "SimSetup error. Neither molFraction nor " -// << " nMol was given in component - + sprintf( painCave.errMsg, + "SimSetup error.\n" + "\tSorry, the ability to specify total" + " nMols and then give molfractions in the components\n" + "\tis not currently supported." + " Please give nMol in the components.\n" ); + painCave.isFatal = 1; + simError(); + + + // tot_nmol = the_globals->getNMol(); + + // //we have the total number of molecules, now we check for molfractions + // for( i=0; ihaveMolFraction() ){ + + // if( !the_components[i]->haveNMol() ){ + // //we have a problem + // std::cerr << "SimSetup error. Neither molFraction nor " + // << " nMol was given in component + } +#ifdef IS_MPI + strcpy( checkPointMsg, "Have the number of components" ); + MPIcheckPoint(); +#endif // is_mpi + // make an array of molecule stamps that match the components used. for( i=0; in_dipoles ){ if( !the_globals->haveRRF() ){ - std::cerr << "SimSetup Error, system has dipoles, but no rRF was set.\n"; - exit(8); + sprintf( painCave.errMsg, + "SimSetup Error, system has dipoles, but no rRF was set.\n"); + painCave.isFatal = 1; + simError(); } if( !the_globals->haveDielectric() ){ - std::cerr << "SimSetup Error, system has dipoles, but no" - << " dielectric was set.\n"; - exit(8); + sprintf( painCave.errMsg, + "SimSetup Error, system has dipoles, but no" + " dielectric was set.\n" ); + painCave.isFatal = 1; + simError(); } simnfo->rRF = the_globals->getRRF(); simnfo->dielectric = the_globals->getDielectric(); } +#ifdef IS_MPI + strcpy( checkPointMsg, "rRf and dielectric check out" ); + MPIcheckPoint(); +#endif // is_mpi + if( the_globals->haveBox() ){ simnfo->box_x = the_globals->getBox(); simnfo->box_y = the_globals->getBox(); @@ -250,25 +274,37 @@ void SimSetup::createSim( void ){ } else{ if( !the_globals->haveBoxX() ){ - std::cerr << "SimSetup error, no periodic BoxX size given.\n"; - exit(8); + sprintf( painCave.errMsg, + "SimSetup error, no periodic BoxX size given.\n" ); + painCave.isFatal = 1; + simError(); } simnfo->box_x = the_globals->getBoxX(); if( !the_globals->haveBoxY() ){ - std::cerr << "SimSetup error, no periodic BoxY size given.\n"; - exit(8); + sprintf( painCave.errMsg, + "SimSetup error, no periodic BoxY size given.\n" ); + painCave.isFatal = 1; + simError(); } simnfo->box_y = the_globals->getBoxY(); if( !the_globals->haveBoxZ() ){ - std::cerr << "SimSetup error, no periodic BoxZ size given.\n"; - exit(8); + sprintf( painCave.errMsg, + "SimSetup error, no periodic BoxZ size given.\n" ); + painCave.isFatal = 1; + simError(); } simnfo->box_z = the_globals->getBoxZ(); } +#ifdef IS_MPI + strcpy( checkPointMsg, "Box size set up" ); + MPIcheckPoint(); +#endif // is_mpi + + // if( the_globals->haveInitialConfig() ){ // InitializeFromFile* fileInit; // fileInit = new InitializeFromFile( the_globals->getInitialConfig() ); @@ -279,102 +315,104 @@ void SimSetup::createSim( void ){ // } // else{ - initFromBass(); + initFromBass(); + +#ifdef IS_MPI + strcpy( checkPointMsg, "initFromBass successfully created the lattice" ); + MPIcheckPoint(); +#endif // is_mpi -// } - + + + + // } + #ifdef IS_MPI - if( worldRank == TESTWRITE ){ + if( worldRank == 0 ){ #endif // is_mpi - - fprintf( stderr, - "infile name is \"%s\"\n", - inFileName ); - - inFileName = "./butane.bass"; - - if( the_globals->haveFinalConfig() ){ - strcpy( simnfo->finalName, the_globals->getFinalConfig() ); + + if( the_globals->haveFinalConfig() ){ + strcpy( simnfo->finalName, the_globals->getFinalConfig() ); + } + else{ + strcpy( simnfo->finalName, inFileName ); + char* endTest; + int nameLength = strlen( simnfo->finalName ); + endTest = &(simnfo->finalName[nameLength - 5]); + if( !strcmp( endTest, ".bass" ) ){ + strcpy( endTest, ".eor" ); + } + else if( !strcmp( endTest, ".BASS" ) ){ + strcpy( endTest, ".eor" ); } else{ - strcpy( simnfo->finalName, inFileName ); - char* endTest; - int nameLength = strlen( simnfo->finalName ); - endTest = &(simnfo->finalName[nameLength - 5]); - if( !strcmp( endTest, ".bass" ) ){ + endTest = &(simnfo->finalName[nameLength - 4]); + if( !strcmp( endTest, ".bss" ) ){ strcpy( endTest, ".eor" ); } - else if( !strcmp( endTest, ".BASS" ) ){ + else if( !strcmp( endTest, ".mdl" ) ){ strcpy( endTest, ".eor" ); } else{ - endTest = &(simnfo->finalName[nameLength - 4]); - if( !strcmp( endTest, ".bss" ) ){ - strcpy( endTest, ".eor" ); - } - else if( !strcmp( endTest, ".mdl" ) ){ - strcpy( endTest, ".eor" ); - } - else{ - strcat( simnfo->finalName, ".eor" ); - } + strcat( simnfo->finalName, ".eor" ); } } - - // make the sample and status out names - - strcpy( simnfo->sampleName, inFileName ); - char* endTest; - int nameLength = strlen( simnfo->sampleName ); - endTest = &(simnfo->sampleName[nameLength - 5]); - if( !strcmp( endTest, ".bass" ) ){ + } + + // make the sample and status out names + + strcpy( simnfo->sampleName, inFileName ); + char* endTest; + int nameLength = strlen( simnfo->sampleName ); + endTest = &(simnfo->sampleName[nameLength - 5]); + if( !strcmp( endTest, ".bass" ) ){ + strcpy( endTest, ".dump" ); + } + else if( !strcmp( endTest, ".BASS" ) ){ + strcpy( endTest, ".dump" ); + } + else{ + endTest = &(simnfo->sampleName[nameLength - 4]); + if( !strcmp( endTest, ".bss" ) ){ strcpy( endTest, ".dump" ); } - else if( !strcmp( endTest, ".BASS" ) ){ + else if( !strcmp( endTest, ".mdl" ) ){ strcpy( endTest, ".dump" ); } else{ - endTest = &(simnfo->sampleName[nameLength - 4]); - if( !strcmp( endTest, ".bss" ) ){ - strcpy( endTest, ".dump" ); - } - else if( !strcmp( endTest, ".mdl" ) ){ - strcpy( endTest, ".dump" ); - } - else{ - strcat( simnfo->sampleName, ".dump" ); - } + strcat( simnfo->sampleName, ".dump" ); } - - strcpy( simnfo->statusName, inFileName ); - nameLength = strlen( simnfo->statusName ); - endTest = &(simnfo->statusName[nameLength - 5]); - if( !strcmp( endTest, ".bass" ) ){ + } + + strcpy( simnfo->statusName, inFileName ); + nameLength = strlen( simnfo->statusName ); + endTest = &(simnfo->statusName[nameLength - 5]); + if( !strcmp( endTest, ".bass" ) ){ + strcpy( endTest, ".stat" ); + } + else if( !strcmp( endTest, ".BASS" ) ){ + strcpy( endTest, ".stat" ); + } + else{ + endTest = &(simnfo->statusName[nameLength - 4]); + if( !strcmp( endTest, ".bss" ) ){ strcpy( endTest, ".stat" ); } - else if( !strcmp( endTest, ".BASS" ) ){ + else if( !strcmp( endTest, ".mdl" ) ){ strcpy( endTest, ".stat" ); } else{ - endTest = &(simnfo->statusName[nameLength - 4]); - if( !strcmp( endTest, ".bss" ) ){ - strcpy( endTest, ".stat" ); - } - else if( !strcmp( endTest, ".mdl" ) ){ - strcpy( endTest, ".stat" ); - } - else{ - strcat( simnfo->statusName, ".stat" ); - } + strcat( simnfo->statusName, ".stat" ); } - -#ifdef IS_MPI } -#endif // is_mpi - + +#ifdef IS_MPI + } +#endif // is_mpi + // set the status, sample, and themal kick times - + if( the_globals->haveSampleTime() ){ simnfo->sampleTime = the_globals->getSampleTime(); simnfo->statusTime = simnfo->sampleTime; @@ -597,8 +635,11 @@ void SimSetup::initFromBass( void ){ n_per_extra = (int)ceil( temp1 ); if( n_per_extra > 4){ - std::cerr << "THere has been an error in constructing the non-complete lattice.\n"; - exit(8); + sprintf( painCave.errMsg, + "SimSetup error. There has been an error in constructing" + " the non-complete lattice.\n" ); + painCave.isFatal = 1; + simError(); } } else{ @@ -703,12 +744,15 @@ void SimSetup::makeElement( double x, double y, double current_atom = comp_stamps[current_comp]->getAtom( k ); if( !current_atom->havePosition() ){ - std::cerr << "Component " << comp_stamps[current_comp]->getID() - << ", atom " << current_atom->getType() - << " does not have a position specified.\n" - << "The initialization routine is unable to give a start" - << " position.\n"; - exit(8); + sprintf( painCave.errMsg, + "SimSetup:initFromBass error.\n" + "\tComponent %s, atom %s does not have a position specified.\n" + "\tThe initialization routine is unable to give a start" + " position.\n", + comp_stamps[current_comp]->getID(), + current_atom->getType() ); + painCave.isFatal = 1; + simError(); } the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() );