--- trunk/mdtools/interface_implementation/SimSetup.cpp 2002/10/17 21:59:12 144 +++ trunk/mdtools/interface_implementation/SimSetup.cpp 2002/11/21 20:33:06 184 @@ -6,6 +6,7 @@ #include "parse_me.h" #include "LRI.hpp" #include "Integrator.hpp" +#include "simError.h" #ifdef IS_MPI #include "mpiBASS.h" @@ -15,6 +16,11 @@ SimSetup::SimSetup(){ SimSetup::SimSetup(){ stamps = new MakeStamps(); globals = new Globals(); + +#ifdef IS_MPI + strcpy( checkPointMsg, "SimSetup creation successful" ); + MPIcheckPoint(); +#endif // IS_MPI } SimSetup::~SimSetup(){ @@ -24,14 +30,23 @@ void SimSetup::parseFile( char* fileName ){ void SimSetup::parseFile( char* fileName ){ - inFileName = fileName; - set_interface_stamps( stamps, globals ); #ifdef IS_MPI - mpiEventInit(); + if( worldRank == 0 ){ +#endif // is_mpi + + inFileName = fileName; + set_interface_stamps( stamps, globals ); + +#ifdef IS_MPI + mpiEventInit(); #endif - yacc_BASS( fileName ); + + yacc_BASS( fileName ); + #ifdef IS_MPI - throwMPIEvent(NULL); + throwMPIEvent(NULL); + } + else receiveParse(); #endif } @@ -41,6 +56,7 @@ void SimSetup::receiveParse(void){ set_interface_stamps( stamps, globals ); mpiEventInit(); + MPIcheckPoint(); mpiEventLoop(); } @@ -52,6 +68,7 @@ void SimSetup::testMe(void){ delete dumpMe; } #endif + void SimSetup::createSim( void ){ MakeStamps *the_stamps; @@ -76,11 +93,18 @@ void SimSetup::createSim( void ){ else if( !strcmp( force_field, "DipoleTest" ) ) the_ff = new DipoleTestFF(); else if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF(); else{ - std::cerr<< "SimSetup Error. Unrecognized force field -> " - << force_field << "\n"; - exit(8); + sprintf( painCave.errMsg, + "SimSetup Error. Unrecognized force field -> %s\n", + force_field ); + painCave.isFatal = 1; + simError(); } +#ifdef IS_MPI + strcpy( checkPointMsg, "ForceField creation successful" ); + MPIcheckPoint(); +#endif // is_mpi + // get the components and calculate the tot_nMol and indvidual n_mol the_components = the_globals->getComponents(); components_nmol = new int[n_components]; @@ -155,6 +179,7 @@ void SimSetup::createSim( void ){ // create the atom and short range interaction arrays + Atom::createArrays(tot_atoms); the_atoms = new Atom*[tot_atoms]; the_molecules = new Molecule[tot_nmol]; @@ -255,85 +280,98 @@ 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" ); -// } -// } - -// 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 == TESTWRITE ){ +#endif // is_mpi + + fprintf( stderr, + "infile name is \"%s\"\n", + inFileName ); + + inFileName = "./butane.bass"; + + 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 @@ -392,7 +430,7 @@ void SimSetup::makeAtoms( void ){ current_atom = comp_stamps[i]->getAtom( k ); if( current_atom->haveOrientation() ){ - dAtom = new DirectionalAtom; + dAtom = new DirectionalAtom(index); simnfo->n_oriented++; the_atoms[index] = dAtom; @@ -412,7 +450,7 @@ void SimSetup::makeAtoms( void ){ dAtom->setSUz( uz ); } else{ - the_atoms[index] = new GeneralAtom; + the_atoms[index] = new GeneralAtom(index); } the_atoms[index]->setType( current_atom->getType() ); the_atoms[index]->setIndex( index );