--- trunk/mdtools/interface_implementation/SimSetup.cpp 2002/11/14 22:00:44 176 +++ trunk/mdtools/interface_implementation/SimSetup.cpp 2002/12/04 21:19:38 194 @@ -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_torsions = tot_torsions; simnfo->n_SRI = tot_SRI; + // divide the molecules among processors here. + + // create the atom and short range interaction arrays - the_atoms = new Atom*[tot_atoms]; Atom::createArrays(tot_atoms); + the_atoms = new Atom*[tot_atoms]; the_molecules = new Molecule[tot_nmol]; @@ -222,19 +240,28 @@ void SimSetup::createSim( void ){ if( simnfo->n_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 +277,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,89 +318,104 @@ void SimSetup::createSim( void ){ // } // else{ - initFromBass(); - - -// } - -// 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{ -// 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" ); -// } -// } -// } - -// // 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, ".mdl" ) ){ -// strcpy( endTest, ".dump" ); -// } -// else{ -// strcat( simnfo->sampleName, ".dump" ); -// } -// } + initFromBass(); + +#ifdef IS_MPI + strcpy( checkPointMsg, "initFromBass successfully created the lattice" ); + MPIcheckPoint(); +#endif // is_mpi -// 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, ".mdl" ) ){ -// strcpy( endTest, ".stat" ); -// } -// else{ -// strcat( simnfo->statusName, ".stat" ); -// } -// } - + + + + // } + +#ifdef IS_MPI + if( worldRank == 0 ){ +#endif // is_mpi + + 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{ + 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" ); + } + } + } + + // 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, ".mdl" ) ){ + strcpy( endTest, ".dump" ); + } + else{ + strcat( simnfo->sampleName, ".dump" ); + } + } + + 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, ".mdl" ) ){ + strcpy( endTest, ".stat" ); + } + else{ + strcat( simnfo->statusName, ".stat" ); + } + } + +#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; @@ -584,8 +638,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{ @@ -690,12 +747,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() );