| 26 |
|
} |
| 27 |
|
|
| 28 |
|
|
| 29 |
< |
void mpiSimulation::divideLabor(int nComponents, MoleculeStamp** compStamps, int* componentsNmol ){ |
| 30 |
< |
|
| 29 |
> |
void mpiSimulation::divideLabor( void ){ |
| 30 |
> |
|
| 31 |
> |
int nComponents; |
| 32 |
> |
MoleculeStamp** compStamps; |
| 33 |
> |
int* componentsNmol; |
| 34 |
> |
|
| 35 |
|
double numerator; |
| 36 |
|
double denominator; |
| 37 |
|
double precast; |
| 39 |
|
int nTarget; |
| 40 |
|
int molIndex, atomIndex, compIndex, compStart; |
| 41 |
|
int done; |
| 42 |
< |
int nLocal; |
| 42 |
> |
int nLocal, molLocal; |
| 43 |
|
int i; |
| 44 |
|
int smallDiff, bigDiff; |
| 45 |
|
|
| 46 |
|
int testSum; |
| 47 |
|
|
| 48 |
+ |
nComponents = entryPlug->nComponents; |
| 49 |
+ |
compStamps = entryPlug->compStamps; |
| 50 |
+ |
componentsNmol = entryPlug->componentsNmol; |
| 51 |
+ |
|
| 52 |
|
numerator = (double) entryPlug->n_atoms; |
| 53 |
|
denominator = (double) numberProcessors; |
| 54 |
|
precast = numerator / denominator; |
| 62 |
|
|
| 63 |
|
done = 0; |
| 64 |
|
nLocal = 0; |
| 65 |
+ |
molLocal = 0; |
| 66 |
|
|
| 67 |
|
if( i == myNode ){ |
| 68 |
|
myMolStart = molIndex; |
| 80 |
|
nLocal += compStamps[compIndex]->getNAtoms(); |
| 81 |
|
atomIndex += compStamps[compIndex]->getNAtoms(); |
| 82 |
|
molIndex++; |
| 83 |
+ |
molLocal++; |
| 84 |
|
|
| 85 |
|
if ( nLocal == nTarget ) done = 1; |
| 86 |
|
|
| 93 |
|
if( bigDiff < smallDiff ) done = 1; |
| 94 |
|
else{ |
| 95 |
|
molIndex--; |
| 96 |
+ |
molLocal--; |
| 97 |
|
atomIndex -= compStamps[compIndex]->getNAtoms(); |
| 98 |
|
nLocal -= compStamps[compIndex]->getNAtoms(); |
| 99 |
|
done = 1; |
| 105 |
|
myMolEnd = (molIndex - 1); |
| 106 |
|
myAtomEnd = (atomIndex - 1); |
| 107 |
|
myNlocal = nLocal; |
| 108 |
+ |
myMol = molLocal; |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
numerator = (double)( entryPlug->n_atoms - atomIndex ); |
| 119 |
|
myAtomStart = atomIndex; |
| 120 |
|
|
| 121 |
|
nLocal = 0; |
| 122 |
+ |
molLocal = 0; |
| 123 |
|
while( compIndex < nComponents ){ |
| 124 |
|
|
| 125 |
|
if( (molIndex-compStart) >= componentsNmol[compIndex] ){ |
| 131 |
|
nLocal += compStamps[compIndex]->getNAtoms(); |
| 132 |
|
atomIndex += compStamps[compIndex]->getNAtoms(); |
| 133 |
|
molIndex++; |
| 134 |
+ |
molLocal++; |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
myMolEnd = (molIndex - 1); |
| 138 |
|
myAtomEnd = (atomIndex - 1); |
| 139 |
< |
myNlocal = nLocal; |
| 139 |
> |
myNlocal = nLocal; |
| 140 |
> |
myMol = molLocal; |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
|
| 156 |
|
sprintf( checkPointMsg, |
| 157 |
|
"Successfully divided the molecules among the processors.\n" ); |
| 158 |
|
MPIcheckPoint(); |
| 159 |
+ |
|
| 160 |
+ |
// lets create the identity array |
| 161 |
|
} |