# | Line 4 | Line 4 | |
---|---|---|
4 | #include <cstring> | |
5 | #include <cmath> | |
6 | #include <mpi.h> | |
7 | – | #include <mpi++.h> |
7 | ||
8 | #include "mpiSimulation.hpp" | |
9 | #include "simError.h" | |
# | Line 20 | Line 19 | mpiSimulation::mpiSimulation(SimInfo* the_entryPlug) | |
19 | entryPlug = the_entryPlug; | |
20 | mpiPlug = new mpiSimData; | |
21 | ||
22 | < | mpiPlug->numberProcessors = MPI::COMM_WORLD.Get_size(); |
22 | > | MPI_Comm_size(MPI_COMM_WORLD, &(mpiPlug->numberProcessors) ); |
23 | mpiPlug->myNode = worldRank; | |
24 | ||
25 | MolToProcMap = new int[entryPlug->n_mol]; | |
# | Line 67 | Line 66 | int* mpiSimulation::divideLabor( void ){ | |
66 | int nmol_global, natoms_global; | |
67 | int local_index, index; | |
68 | int smallDiff, bigDiff; | |
69 | < | int baseSeed = BASE_SEED; |
69 | > | int baseSeed = entryPlug->getSeed(); |
70 | ||
71 | int testSum; | |
72 | ||
# | Line 83 | Line 82 | int* mpiSimulation::divideLabor( void ){ | |
82 | mpiPlug->nSRIGlobal = entryPlug->n_SRI; | |
83 | mpiPlug->nMolGlobal = entryPlug->n_mol; | |
84 | ||
85 | + | |
86 | myRandom = new randomSPRNG( baseSeed ); | |
87 | ||
88 | a = 3.0 * (double)mpiPlug->nMolGlobal / (double)mpiPlug->nAtomsGlobal; | |
# | Line 203 | Line 203 | int* mpiSimulation::divideLabor( void ){ | |
203 | ||
204 | // Spray out this nonsense to all other processors: | |
205 | ||
206 | < | MPI::COMM_WORLD.Bcast(MolToProcMap, mpiPlug->nMolGlobal, |
207 | < | MPI_INT, 0); |
206 | > | MPI_Bcast(MolToProcMap, mpiPlug->nMolGlobal, |
207 | > | MPI_INT, 0, MPI_COMM_WORLD); |
208 | ||
209 | < | MPI::COMM_WORLD.Bcast(AtomToProcMap, mpiPlug->nAtomsGlobal, |
210 | < | MPI_INT, 0); |
209 | > | MPI_Bcast(AtomToProcMap, mpiPlug->nAtomsGlobal, |
210 | > | MPI_INT, 0, MPI_COMM_WORLD); |
211 | ||
212 | < | MPI::COMM_WORLD.Bcast(MolComponentType, mpiPlug->nMolGlobal, |
213 | < | MPI_INT, 0); |
212 | > | MPI_Bcast(MolComponentType, mpiPlug->nMolGlobal, |
213 | > | MPI_INT, 0, MPI_COMM_WORLD); |
214 | ||
215 | < | MPI::COMM_WORLD.Bcast(AtomsPerProc, mpiPlug->numberProcessors, |
216 | < | MPI_INT, 0); |
215 | > | MPI_Bcast(AtomsPerProc, mpiPlug->numberProcessors, |
216 | > | MPI_INT, 0, MPI_COMM_WORLD); |
217 | } else { | |
218 | ||
219 | // Listen to your marching orders from processor 0: | |
220 | ||
221 | < | MPI::COMM_WORLD.Bcast(MolToProcMap, mpiPlug->nMolGlobal, |
222 | < | MPI_INT, 0); |
223 | < | |
224 | < | MPI::COMM_WORLD.Bcast(AtomToProcMap, mpiPlug->nAtomsGlobal, |
225 | < | MPI_INT, 0); |
221 | > | MPI_Bcast(MolToProcMap, mpiPlug->nMolGlobal, |
222 | > | MPI_INT, 0, MPI_COMM_WORLD); |
223 | > | |
224 | > | MPI_Bcast(AtomToProcMap, mpiPlug->nAtomsGlobal, |
225 | > | MPI_INT, 0, MPI_COMM_WORLD); |
226 | ||
227 | < | MPI::COMM_WORLD.Bcast(MolComponentType, mpiPlug->nMolGlobal, |
228 | < | MPI_INT, 0); |
227 | > | MPI_Bcast(MolComponentType, mpiPlug->nMolGlobal, |
228 | > | MPI_INT, 0, MPI_COMM_WORLD); |
229 | ||
230 | < | MPI::COMM_WORLD.Bcast(AtomsPerProc, mpiPlug->numberProcessors, |
231 | < | MPI_INT, 0); |
230 | > | MPI_Bcast(AtomsPerProc, mpiPlug->numberProcessors, |
231 | > | MPI_INT, 0, MPI_COMM_WORLD); |
232 | ||
233 | ||
234 | } | |
# | Line 250 | Line 250 | int* mpiSimulation::divideLabor( void ){ | |
250 | } | |
251 | } | |
252 | ||
253 | < | MPI::COMM_WORLD.Allreduce(&nmol_local,&nmol_global,1,MPI_INT,MPI_SUM); |
254 | < | MPI::COMM_WORLD.Allreduce(&natoms_local,&natoms_global,1,MPI_INT,MPI_SUM); |
253 | > | MPI_Allreduce(&nmol_local,&nmol_global,1,MPI_INT,MPI_SUM, |
254 | > | MPI_COMM_WORLD); |
255 | > | MPI_Allreduce(&natoms_local,&natoms_global,1,MPI_INT, |
256 | > | MPI_SUM, MPI_COMM_WORLD); |
257 | ||
258 | if( nmol_global != entryPlug->n_mol ){ | |
259 | sprintf( painCave.errMsg, | |
# | Line 296 | Line 298 | void mpiSimulation::mpiRefresh( void ){ | |
298 | int isError, i; | |
299 | int *globalIndex = new int[mpiPlug->myNlocal]; | |
300 | ||
301 | < | for(i=0; i<mpiPlug->myNlocal; i++) globalIndex[i] = entryPlug->atoms[i]->getGlobalIndex(); |
301 | > | // Fortran indexing needs to be increased by 1 in order to get the 2 languages to |
302 | > | // not barf |
303 | ||
304 | + | for(i=0; i<mpiPlug->myNlocal; i++) globalIndex[i] = entryPlug->atoms[i]->getGlobalIndex()+1; |
305 | + | |
306 | ||
307 | isError = 0; | |
308 | setFsimParallel( mpiPlug, &(entryPlug->n_atoms), globalIndex, &isError ); |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |