--- trunk/mdtools/interface_implementation/SimSetup.cpp 2002/11/26 21:04:43 189 +++ trunk/mdtools/interface_implementation/SimSetup.cpp 2002/12/06 21:20:42 198 @@ -161,15 +161,51 @@ void SimSetup::createSim( void ){ #endif // is_mpi // make an array of molecule stamps that match the components used. + // also extract the used stamps out into a separate linked list + simnfo->nComponents = n_components; + simnfo->componentsNmol = components_nmol; + simnfo->compStamps = comp_stamps; + simnfo->headStamp = new LinkedMolStamp(); + + char* id; + LinkedMolStamp* headStamp = simnfo->headStamp; + LinkedMolStamp* currentStamp = NULL; for( i=0; igetMolecule( the_components[i]->getType() ); + id = the_components[i]->getType(); + comp_stamps[i] = NULL; + + // check to make sure the component isn't already in the list + + comp_stamps[i] = headStamp->match( id ); + if( comp_stamps[i] == NULL ){ + + // extract the component from the list; + + currentStamp = the_stamps->extractMolStamp( id ); + if( currentStamp == NULL ){ + sprintf( painCave.errMsg, + "SimSetup error: Component \"%s\" was not found in the " + "list of declared molecules\n" + id ); + painCave.isFatal = 1; + simError(); + } + + headStamp->add( currentStamp ); + comp_stamps[i] = headStamp->match( id ); + } } +#ifdef IS_MPI + strcpy( checkPointMsg, "Component stamps successfully extracted\n" ); + MPIcheckPoint(); +#endif // is_mpi + + // caclulate the number of atoms, bonds, bends and torsions tot_atoms = 0; @@ -191,17 +227,30 @@ void SimSetup::createSim( void ){ simnfo->n_bends = tot_bends; simnfo->n_torsions = tot_torsions; simnfo->n_SRI = tot_SRI; + simnfo->n_mol = tot_nmol; + +#ifdef IS_MPI + + // divide the molecules among processors here. + + new mpiSimulation( simnfo ); + + simnfo->mpiSim->divideLabor( n_components, comp_stamps, components_nmol ); + +#endif // is_mpi + + // create the atom and short range interaction arrays - Atom::createArrays(tot_atoms); - the_atoms = new Atom*[tot_atoms]; - the_molecules = new Molecule[tot_nmol]; + Atom::createArrays(simnfo->n_atoms); + the_atoms = new Atom*[simnfo->n_atoms]; + the_molecules = new Molecule[simnfo->n_mol]; - if( tot_SRI ){ - the_sris = new SRI*[tot_SRI]; - the_excludes = new ex_pair[tot_SRI]; + if( simnfo->n_SRI ){ + the_sris = new SRI*[simnfo->n_SRI]; + the_excludes = new ex_pair[simnfo->n_SRI]; } // set the arrays into the SimInfo object @@ -230,7 +279,6 @@ void SimSetup::createSim( void ){ makeTorsions(); } - // makeMolecules(); // get some of the tricky things that may still be in the globals @@ -315,10 +363,23 @@ void SimSetup::createSim( void ){ // } // else{ +#ifdef IS_MPI + + // no init from bass + + sprintf( painCave.errMsg, + "Cannot intialize a parallel simulation without an initial configuration file.\n" ); + painCave.isFatal; + simError(); + +#else + initFromBass(); + +#endif // is_mpi #ifdef IS_MPI - strcpy( checkPointMsg, "initFromBass successfully created the lattice" ); + strcpy( checkPointMsg, "Successfully read in the initial configuration" ); MPIcheckPoint(); #endif // is_mpi