--- trunk/mdtools/mpi_implementation/mpiSimulation.cpp 2002/12/19 21:59:51 215 +++ trunk/mdtools/mpi_implementation/mpiSimulation.cpp 2003/01/30 15:20:21 253 @@ -1,20 +1,31 @@ -i#include +#include #include #include #include "mpiSimulation.hpp" #include "simError.h" +extern "C"{ + void wrapsimparallelmod_( void (*wrapFunction)(void (*fSub)( mpiSimData*, + int*, int*, + int*))); +} + +void wrapSimParallel(void (*fSub)(mpiSimData*, int*, int*, int*)); + + mpiSimulation* mpiSim; mpiSimulation::mpiSimulation(SimInfo* the_entryPlug) { entryPlug = the_entryPlug; - mpiPlug = new MpiSimData; + mpiPlug = new mpiSimData; mpiPlug->numberProcessors = MPI::COMM_WORLD.Get_size(); mpiPlug->myNode = worldRank; + mpiSim = this; + wrapMe(); } @@ -26,9 +37,17 @@ mpiSimulation::~mpiSimulation(){ } +void mpiSimulation::wrapMe(){ -void mpiSimulation::divideLabor( void ){ + wrapsimparallelmod_( wrapSimParallel ); +} + + +int* mpiSimulation::divideLabor( void ){ + + int* globalIndex; + int nComponents; MoleculeStamp** compStamps; int* componentsNmol; @@ -41,7 +60,7 @@ void mpiSimulation::divideLabor( void ){ int molIndex, atomIndex, compIndex, compStart; int done; int nLocal, molLocal; - int i; + int i, index; int smallDiff, bigDiff; int testSum; @@ -55,7 +74,7 @@ void mpiSimulation::divideLabor( void ){ mpiPlug->nBendsGlobal = entryPlug->n_bends; mpiPlug->nTorsionsGlobal = entryPlug->n_torsions; mpiPlug->nSRIGlobal = entryPlug->n_SRI; - mpiPlug->nMolGlobal = entryPlug->n_nmol; + mpiPlug->nMolGlobal = entryPlug->n_mol; numerator = (double) entryPlug->n_atoms; denominator = (double) mpiPlug->numberProcessors; @@ -166,4 +185,46 @@ void mpiSimulation::divideLabor( void ){ MPIcheckPoint(); // lets create the identity array + + globalIndex = new int[mpiPlug->myNlocal]; + index = mpiPlug->myAtomStart; + for( i=0; imyNlocal; i++){ + globalIndex[i] = index; + index++; + } + + return globalIndex; } + + +void wrapSimParallel(void (*fSub)(mpiSimData*, int*, int*, int*)){ + + mpiSim->setInternal( fSub ); +} + + +void mpiSimulation::mpiRefresh( void ){ + + int isError, i; + int *globalIndex = new int[mpiPlug->myNlocal]; + + for(i=0; imyNlocal; i++) globalIndex[i] = entryPlug->atoms[i]->getGlobalIndex(); + + + isError = 0; + setFsimParallel( mpiPlug, &(entryPlug->n_atoms), globalIndex, &isError ); + if( isError ){ + + sprintf( painCave.errMsg, + "mpiRefresh errror: fortran didn't like something we gave it.\n" ); + painCave.isFatal = 1; + simError(); + } + + delete[] globalIndex; + + sprintf( checkPointMsg, + " mpiRefresh successful.\n" ); + MPIcheckPoint(); +} +