# | Line 4 | Line 4 | |
---|---|---|
4 | ||
5 | #ifdef IS_MPI | |
6 | #include <mpi.h> | |
7 | + | #include <mpi++.h> |
8 | #include "mpiSimulation.hpp" | |
9 | < | #define TAKE_THIS_TAG 0 |
9 | > | #define TAKE_THIS_TAG 1 |
10 | #endif //is_mpi | |
11 | ||
12 | #include "ReadWrite.hpp" | |
13 | #include "simError.h" | |
14 | ||
14 | – | |
15 | – | |
16 | – | |
17 | – | |
15 | DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ | |
16 | ||
17 | entry_plug = the_entry_plug; | |
# | Line 68 | Line 65 | void DumpWriter::writeDump( double currentTime ){ | |
65 | char tempBuffer[BUFFERSIZE]; | |
66 | char writeLine[BUFFERSIZE]; | |
67 | ||
68 | < | int i; |
68 | > | int i, j, which_node, done, game_over, which_atom, local_index; |
69 | double q[4]; | |
70 | DirectionalAtom* dAtom; | |
71 | int nAtoms = entry_plug->n_atoms; | |
# | Line 123 | Line 120 | void DumpWriter::writeDump( double currentTime ){ | |
120 | ||
121 | #else // is_mpi | |
122 | ||
123 | < | int masterIndex; |
124 | < | int nodeAtomsStart; |
125 | < | int nodeAtomsEnd; |
129 | < | int mpiErr; |
130 | < | int sendError; |
131 | < | int procIndex; |
132 | < | |
133 | < | MPI_Status istatus[MPI_STATUS_SIZE]; |
134 | < | |
135 | < | |
123 | > | MPI::Status istatus; |
124 | > | int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
125 | > | |
126 | // write out header and node 0's coordinates | |
127 | < | |
127 | > | |
128 | if( worldRank == 0 ){ | |
129 | outFile << mpiSim->getTotAtoms() << "\n"; | |
130 | < | |
130 | > | |
131 | outFile << currentTime << "\t" | |
132 | << entry_plug->box_x << "\t" | |
133 | << entry_plug->box_y << "\t" | |
134 | << entry_plug->box_z << "\n"; | |
135 | < | |
136 | < | masterIndex = 0; |
137 | < | for( i=0; i<nAtoms; i++ ){ |
135 | > | outFile.flush(); |
136 | > | for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { |
137 | > | // Get the Node number which has this atom; |
138 | ||
139 | < | sprintf( tempBuffer, |
140 | < | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
141 | < | atoms[i]->getType(), |
142 | < | atoms[i]->getX(), |
143 | < | atoms[i]->getY(), |
144 | < | atoms[i]->getZ(), |
145 | < | atoms[i]->get_vx(), |
146 | < | atoms[i]->get_vy(), |
147 | < | atoms[i]->get_vz()); |
148 | < | strcpy( writeLine, tempBuffer ); |
139 | > | which_node = AtomToProcMap[i]; |
140 | > | |
141 | > | if (which_node == mpiSim->getMyNode()) { |
142 | > | sprintf( tempBuffer, |
143 | > | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
144 | > | atoms[i]->getType(), |
145 | > | atoms[i]->getX(), |
146 | > | atoms[i]->getY(), |
147 | > | atoms[i]->getZ(), |
148 | > | atoms[i]->get_vx(), |
149 | > | atoms[i]->get_vy(), |
150 | > | atoms[i]->get_vz()); |
151 | > | strcpy( writeLine, tempBuffer ); |
152 | ||
153 | < | if( atoms[i]->isDirectional() ){ |
153 | > | if( atoms[i]->isDirectional() ){ |
154 | ||
155 | < | dAtom = (DirectionalAtom *)atoms[i]; |
156 | < | dAtom->getQ( q ); |
155 | > | dAtom = (DirectionalAtom *)atoms[i]; |
156 | > | dAtom->getQ( q ); |
157 | ||
158 | < | sprintf( tempBuffer, |
159 | < | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
160 | < | q[0], |
161 | < | q[1], |
162 | < | q[2], |
163 | < | q[3], |
164 | < | dAtom->getJx(), |
165 | < | dAtom->getJy(), |
166 | < | dAtom->getJz()); |
167 | < | strcat( writeLine, tempBuffer ); |
158 | > | sprintf( tempBuffer, |
159 | > | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
160 | > | q[0], |
161 | > | q[1], |
162 | > | q[2], |
163 | > | q[3], |
164 | > | dAtom->getJx(), |
165 | > | dAtom->getJy(), |
166 | > | dAtom->getJz()); |
167 | > | strcat( writeLine, tempBuffer ); |
168 | > | } |
169 | > | else |
170 | > | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
171 | > | |
172 | > | } else { |
173 | > | |
174 | > | std::cerr << "node 0: sending node " << which_node << " request for atom " << i << "\n"; |
175 | > | MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG); |
176 | > | std::cerr << "node 0: sent!\n"; |
177 | > | MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, |
178 | > | TAKE_THIS_TAG, istatus); |
179 | > | std::cerr << "node 0: got this line: " << writeLine; |
180 | } | |
181 | < | else |
177 | < | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
178 | < | |
181 | > | |
182 | outFile << writeLine; | |
183 | < | masterIndex++; |
183 | > | outFile.flush(); |
184 | } | |
182 | – | outFile.flush(); |
183 | – | } |
184 | – | |
185 | – | sprintf( checkPointMsg, |
186 | – | "Sucessfully wrote node 0's dump configuration.\n"); |
187 | – | MPIcheckPoint(); |
185 | ||
186 | < | for (procIndex = 1; procIndex < mpiSim->getNumberProcessors(); |
187 | < | procIndex++){ |
188 | < | |
189 | < | if( worldRank == 0 ){ |
193 | < | |
194 | < | mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex, |
195 | < | TAKE_THIS_TAG,MPI_COMM_WORLD,istatus); |
196 | < | |
197 | < | mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex, |
198 | < | TAKE_THIS_TAG,MPI_COMM_WORLD, istatus); |
199 | < | |
200 | < | // Make sure where node 0 is writing to, matches where the |
201 | < | // receiving node expects it to be. |
202 | < | |
203 | < | if (masterIndex != nodeAtomsStart){ |
204 | < | sendError = 1; |
205 | < | mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG, |
206 | < | MPI_COMM_WORLD); |
207 | < | sprintf(painCave.errMsg, |
208 | < | "DumpWriter error: atoms start index (%d) for " |
209 | < | "node %d not equal to master index (%d)", |
210 | < | nodeAtomsStart,procIndex,masterIndex ); |
211 | < | painCave.isFatal = 1; |
212 | < | simError(); |
213 | < | } |
214 | < | |
215 | < | sendError = 0; |
216 | < | mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG, |
217 | < | MPI_COMM_WORLD); |
218 | < | |
219 | < | // recieve the nodes writeLines |
220 | < | |
221 | < | for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){ |
222 | < | |
223 | < | mpiErr = MPI_Recv(writeLine,BUFFERSIZE,MPI_CHAR,procIndex, |
224 | < | TAKE_THIS_TAG,MPI_COMM_WORLD,istatus ); |
225 | < | |
226 | < | outFile << writeLine; |
227 | < | masterIndex++; |
228 | < | } |
186 | > | // kill everyone off: |
187 | > | game_over = -1; |
188 | > | for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
189 | > | MPI::COMM_WORLD.Send(&game_over, 1, MPI_INT, j, TAKE_THIS_TAG); |
190 | } | |
191 | ||
192 | < | else if( worldRank == procIndex ){ |
193 | < | |
194 | < | nodeAtomsStart = mpiSim->getMyAtomStart(); |
195 | < | nodeAtomsEnd = mpiSim->getMyAtomEnd(); |
196 | < | |
197 | < | mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,TAKE_THIS_TAG, |
198 | < | MPI_COMM_WORLD); |
199 | < | mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,TAKE_THIS_TAG, |
200 | < | MPI_COMM_WORLD); |
201 | < | |
202 | < | sendError = -1; |
203 | < | mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,TAKE_THIS_TAG, |
204 | < | MPI_COMM_WORLD, istatus); |
205 | < | |
206 | < | if (sendError) MPIcheckPoint(); |
207 | < | |
208 | < | // send current node's configuration line by line. |
209 | < | |
210 | < | for( i=0; i<nAtoms; i++ ){ |
211 | < | |
212 | < | sprintf( tempBuffer, |
213 | < | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
214 | < | atoms[i]->getType(), |
215 | < | atoms[i]->getX(), |
216 | < | atoms[i]->getY(), |
217 | < | atoms[i]->getZ(), |
218 | < | atoms[i]->get_vx(), |
219 | < | atoms[i]->get_vy(), |
259 | < | atoms[i]->get_vz()); // check here. |
260 | < | strcpy( writeLine, tempBuffer ); |
192 | > | } else { |
193 | > | |
194 | > | done = 0; |
195 | > | while (!done) { |
196 | > | std::cerr << "node: " << mpiSim->getMyNode() << " Waiting for receive \n"; |
197 | > | MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0, |
198 | > | TAKE_THIS_TAG, istatus); |
199 | > | std::cerr << "node: " << mpiSim->getMyNode() << " got request for atom " << which_atom << "\n"; |
200 | > | if (which_atom == -1) { |
201 | > | done=1; |
202 | > | continue; |
203 | > | } else { |
204 | > | local_index=-1; |
205 | > | for (j=0; j < mpiSim->getMyNlocal(); j++) { |
206 | > | if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; |
207 | > | } |
208 | > | if (local_index != -1) { |
209 | > | //format the line |
210 | > | sprintf( tempBuffer, |
211 | > | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
212 | > | atoms[local_index]->getType(), |
213 | > | atoms[local_index]->getX(), |
214 | > | atoms[local_index]->getY(), |
215 | > | atoms[local_index]->getZ(), |
216 | > | atoms[local_index]->get_vx(), |
217 | > | atoms[local_index]->get_vy(), |
218 | > | atoms[local_index]->get_vz()); // check here. |
219 | > | strcpy( writeLine, tempBuffer ); |
220 | ||
221 | < | if( atoms[i]->isDirectional() ){ |
222 | < | |
223 | < | dAtom = (DirectionalAtom *)atoms[i]; |
224 | < | dAtom->getQ( q ); |
225 | < | |
226 | < | sprintf( tempBuffer, |
227 | < | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
228 | < | q[0], |
229 | < | q[1], |
230 | < | q[2], |
231 | < | q[3], |
232 | < | dAtom->getJx(), |
233 | < | dAtom->getJy(), |
234 | < | dAtom->getJz()); |
235 | < | strcat( writeLine, tempBuffer ); |
236 | < | } |
237 | < | else |
238 | < | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
239 | < | |
240 | < | mpiErr = MPI_Send(writeLine,BUFFERSIZE,MPI_CHAR,0,TAKE_THIS_TAG, |
241 | < | MPI_COMM_WORLD); |
221 | > | if( atoms[local_index]->isDirectional() ){ |
222 | > | |
223 | > | dAtom = (DirectionalAtom *)atoms[local_index]; |
224 | > | dAtom->getQ( q ); |
225 | > | |
226 | > | sprintf( tempBuffer, |
227 | > | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
228 | > | q[0], |
229 | > | q[1], |
230 | > | q[2], |
231 | > | q[3], |
232 | > | dAtom->getJx(), |
233 | > | dAtom->getJy(), |
234 | > | dAtom->getJz()); |
235 | > | strcat( writeLine, tempBuffer ); |
236 | > | } |
237 | > | else |
238 | > | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
239 | > | std::cerr << "node: " << mpiSim->getMyNode() << " sending this line" << writeLine; |
240 | > | MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
241 | > | TAKE_THIS_TAG); |
242 | > | } else { |
243 | > | strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR"); |
244 | > | MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
245 | > | TAKE_THIS_TAG); |
246 | > | } |
247 | } | |
248 | } | |
249 | < | |
250 | < | sprintf(checkPointMsg,"Node %d sent dump configuration.", |
251 | < | procIndex); |
252 | < | MPIcheckPoint(); |
253 | < | } |
290 | < | |
249 | > | } |
250 | > | outFile.flush(); |
251 | > | sprintf( checkPointMsg, |
252 | > | "Sucessfully took a dump.\n"); |
253 | > | MPIcheckPoint(); |
254 | #endif // is_mpi | |
255 | } | |
256 | ||
294 | – | |
295 | – | |
257 | void DumpWriter::writeFinal(){ | |
258 | ||
259 | + | char finalName[500]; |
260 | + | ofstream finalOut; |
261 | ||
262 | const int BUFFERSIZE = 2000; | |
263 | < | char tempBuffer[500]; |
264 | < | char writeLine[BUFFERSIZE]; |
302 | < | |
303 | < | char finalName[500]; |
263 | > | char tempBuffer[BUFFERSIZE]; |
264 | > | char writeLine[BUFFERSIZE]; |
265 | ||
305 | – | int i; |
266 | double q[4]; | |
267 | DirectionalAtom* dAtom; | |
268 | int nAtoms = entry_plug->n_atoms; | |
269 | Atom** atoms = entry_plug->atoms; | |
270 | + | int i, j, which_node, done, game_over, which_atom, local_index; |
271 | ||
311 | – | ofstream finalOut; |
272 | ||
273 | #ifdef IS_MPI | |
274 | if(worldRank == 0 ){ | |
# | Line 335 | Line 295 | void DumpWriter::writeFinal(){ | |
295 | ||
296 | #endif //is_mpi | |
297 | ||
298 | < | |
339 | < | |
298 | > | |
299 | #ifndef IS_MPI | |
300 | ||
301 | finalOut << nAtoms << "\n"; | |
# | Line 344 | Line 303 | void DumpWriter::writeFinal(){ | |
303 | finalOut << entry_plug->box_x << "\t" | |
304 | << entry_plug->box_y << "\t" | |
305 | << entry_plug->box_z << "\n"; | |
306 | < | |
306 | > | |
307 | for( i=0; i<nAtoms; i++ ){ | |
308 | ||
309 | sprintf( tempBuffer, | |
# | Line 380 | Line 339 | void DumpWriter::writeFinal(){ | |
339 | finalOut << writeLine; | |
340 | } | |
341 | finalOut.flush(); | |
342 | + | finalOut.close(); |
343 | ||
344 | #else // is_mpi | |
345 | + | |
346 | + | MPI::Status istatus; |
347 | + | int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
348 | ||
386 | – | int masterIndex; |
387 | – | int nodeAtomsStart; |
388 | – | int nodeAtomsEnd; |
389 | – | int mpiErr; |
390 | – | int sendError; |
391 | – | int procIndex; |
392 | – | |
393 | – | MPI_Status istatus[MPI_STATUS_SIZE]; |
394 | – | |
395 | – | |
349 | // write out header and node 0's coordinates | |
350 | < | |
350 | > | |
351 | if( worldRank == 0 ){ | |
352 | finalOut << mpiSim->getTotAtoms() << "\n"; | |
353 | < | |
353 | > | |
354 | finalOut << entry_plug->box_x << "\t" | |
355 | < | << entry_plug->box_y << "\t" |
356 | < | << entry_plug->box_z << "\n"; |
355 | > | << entry_plug->box_y << "\t" |
356 | > | << entry_plug->box_z << "\n"; |
357 | ||
358 | < | masterIndex = 0; |
359 | < | |
407 | < | for( i=0; i<nAtoms; i++ ){ |
358 | > | for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { |
359 | > | // Get the Node number which has this molecule: |
360 | ||
361 | < | sprintf( tempBuffer, |
362 | < | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
363 | < | atoms[i]->getType(), |
364 | < | atoms[i]->getX(), |
365 | < | atoms[i]->getY(), |
366 | < | atoms[i]->getZ(), |
367 | < | atoms[i]->get_vx(), |
368 | < | atoms[i]->get_vy(), |
369 | < | atoms[i]->get_vz()); |
370 | < | strcpy( writeLine, tempBuffer ); |
361 | > | which_node = AtomToProcMap[i]; |
362 | > | |
363 | > | if (which_node == mpiSim->getMyNode()) { |
364 | > | |
365 | > | sprintf( tempBuffer, |
366 | > | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
367 | > | atoms[i]->getType(), |
368 | > | atoms[i]->getX(), |
369 | > | atoms[i]->getY(), |
370 | > | atoms[i]->getZ(), |
371 | > | atoms[i]->get_vx(), |
372 | > | atoms[i]->get_vy(), |
373 | > | atoms[i]->get_vz()); |
374 | > | strcpy( writeLine, tempBuffer ); |
375 | ||
376 | < | if( atoms[i]->isDirectional() ){ |
376 | > | if( atoms[i]->isDirectional() ){ |
377 | ||
378 | < | dAtom = (DirectionalAtom *)atoms[i]; |
379 | < | dAtom->getQ( q ); |
378 | > | dAtom = (DirectionalAtom *)atoms[i]; |
379 | > | dAtom->getQ( q ); |
380 | ||
381 | < | sprintf( tempBuffer, |
382 | < | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
383 | < | q[0], |
384 | < | q[1], |
385 | < | q[2], |
386 | < | q[3], |
387 | < | dAtom->getJx(), |
388 | < | dAtom->getJy(), |
389 | < | dAtom->getJz()); |
390 | < | strcat( writeLine, tempBuffer ); |
381 | > | sprintf( tempBuffer, |
382 | > | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
383 | > | q[0], |
384 | > | q[1], |
385 | > | q[2], |
386 | > | q[3], |
387 | > | dAtom->getJx(), |
388 | > | dAtom->getJy(), |
389 | > | dAtom->getJz()); |
390 | > | strcat( writeLine, tempBuffer ); |
391 | > | } |
392 | > | else |
393 | > | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
394 | > | |
395 | > | } else { |
396 | > | |
397 | > | MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG); |
398 | > | MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, |
399 | > | TAKE_THIS_TAG, istatus); |
400 | } | |
401 | < | else |
437 | < | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
438 | < | |
401 | > | |
402 | finalOut << writeLine; | |
440 | – | masterIndex++; |
403 | } | |
442 | – | finalOut.flush(); |
443 | – | } |
404 | ||
405 | < | for (procIndex = 1; procIndex < mpiSim->getNumberProcessors(); |
406 | < | procIndex++){ |
407 | < | |
408 | < | if( worldRank == 0 ){ |
449 | < | |
450 | < | mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex, |
451 | < | TAKE_THIS_TAG,MPI_COMM_WORLD,istatus); |
452 | < | |
453 | < | mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex, |
454 | < | TAKE_THIS_TAG,MPI_COMM_WORLD, istatus); |
455 | < | |
456 | < | // Make sure where node 0 is writing to, matches where the |
457 | < | // receiving node expects it to be. |
458 | < | |
459 | < | if (masterIndex != nodeAtomsStart){ |
460 | < | sendError = 1; |
461 | < | mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG, |
462 | < | MPI_COMM_WORLD); |
463 | < | sprintf(painCave.errMsg, |
464 | < | "DumpWriter error: atoms start index (%d) for " |
465 | < | "node %d not equal to master index (%d)", |
466 | < | nodeAtomsStart,procIndex,masterIndex ); |
467 | < | painCave.isFatal = 1; |
468 | < | simError(); |
469 | < | } |
470 | < | |
471 | < | sendError = 0; |
472 | < | mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG, |
473 | < | MPI_COMM_WORLD); |
474 | < | |
475 | < | // recieve the nodes writeLines |
476 | < | |
477 | < | for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){ |
478 | < | |
479 | < | mpiErr = MPI_Recv(writeLine,BUFFERSIZE,MPI_CHAR,procIndex, |
480 | < | TAKE_THIS_TAG,MPI_COMM_WORLD,istatus ); |
481 | < | |
482 | < | finalOut << writeLine; |
483 | < | masterIndex++; |
484 | < | } |
485 | < | |
486 | < | finalOut.flush(); |
405 | > | // kill everyone off: |
406 | > | game_over = -1; |
407 | > | for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
408 | > | MPI::COMM_WORLD.Send(&game_over, 1, MPI_INT, j, TAKE_THIS_TAG); |
409 | } | |
410 | ||
411 | < | else if( worldRank == procIndex ){ |
411 | > | } else { |
412 | > | |
413 | > | done = 0; |
414 | > | while (!done) { |
415 | > | MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0, |
416 | > | TAKE_THIS_TAG, istatus); |
417 | ||
418 | < | nodeAtomsStart = mpiSim->getMyAtomStart(); |
419 | < | nodeAtomsEnd = mpiSim->getMyAtomEnd(); |
420 | < | |
421 | < | mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,TAKE_THIS_TAG, |
495 | < | MPI_COMM_WORLD); |
496 | < | mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,TAKE_THIS_TAG, |
497 | < | MPI_COMM_WORLD); |
498 | < | |
499 | < | mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,TAKE_THIS_TAG, |
500 | < | MPI_COMM_WORLD, istatus); |
501 | < | if (sendError) MPIcheckPoint(); |
418 | > | if (which_atom == -1) { |
419 | > | done=1; |
420 | > | continue; |
421 | > | } else { |
422 | ||
423 | < | // send current node's configuration line by line. |
423 | > | local_index=-1; |
424 | > | for (j=0; j < mpiSim->getMyNlocal(); j++) { |
425 | > | if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; |
426 | > | } |
427 | > | if (local_index != -1) { |
428 | ||
429 | < | for( i=0; i<nAtoms; i++ ){ |
429 | > | //format the line |
430 | > | sprintf( tempBuffer, |
431 | > | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
432 | > | atoms[local_index]->getType(), |
433 | > | atoms[local_index]->getX(), |
434 | > | atoms[local_index]->getY(), |
435 | > | atoms[local_index]->getZ(), |
436 | > | atoms[local_index]->get_vx(), |
437 | > | atoms[local_index]->get_vy(), |
438 | > | atoms[local_index]->get_vz()); // check here. |
439 | > | strcpy( writeLine, tempBuffer ); |
440 | ||
441 | < | sprintf( tempBuffer, |
442 | < | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
443 | < | atoms[i]->getType(), |
444 | < | atoms[i]->getX(), |
511 | < | atoms[i]->getY(), |
512 | < | atoms[i]->getZ(), |
513 | < | atoms[i]->get_vx(), |
514 | < | atoms[i]->get_vy(), |
515 | < | atoms[i]->get_vz()); |
516 | < | strcpy( writeLine, tempBuffer ); |
517 | < | |
518 | < | if( atoms[i]->isDirectional() ){ |
441 | > | if( atoms[local_index]->isDirectional() ){ |
442 | > | |
443 | > | dAtom = (DirectionalAtom *)atoms[local_index]; |
444 | > | dAtom->getQ( q ); |
445 | ||
446 | < | dAtom = (DirectionalAtom *)atoms[i]; |
447 | < | dAtom->getQ( q ); |
448 | < | |
449 | < | sprintf( tempBuffer, |
450 | < | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
451 | < | q[0], |
452 | < | q[1], |
453 | < | q[2], |
454 | < | q[3], |
455 | < | dAtom->getJx(), |
456 | < | dAtom->getJy(), |
457 | < | dAtom->getJz()); |
458 | < | strcat( writeLine, tempBuffer ); |
459 | < | } |
460 | < | else |
461 | < | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
462 | < | |
463 | < | mpiErr = MPI_Send(writeLine,BUFFERSIZE,MPI_CHAR,0,TAKE_THIS_TAG, |
464 | < | MPI_COMM_WORLD); |
446 | > | sprintf( tempBuffer, |
447 | > | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
448 | > | q[0], |
449 | > | q[1], |
450 | > | q[2], |
451 | > | q[3], |
452 | > | dAtom->getJx(), |
453 | > | dAtom->getJy(), |
454 | > | dAtom->getJz()); |
455 | > | strcat( writeLine, tempBuffer ); |
456 | > | } |
457 | > | else |
458 | > | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
459 | > | |
460 | > | MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
461 | > | TAKE_THIS_TAG); |
462 | > | } else { |
463 | > | strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR"); |
464 | > | MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
465 | > | TAKE_THIS_TAG); |
466 | > | } |
467 | } | |
468 | } | |
541 | – | |
542 | – | sprintf(checkPointMsg,"Node %d sent dump configuration.", |
543 | – | procIndex); |
544 | – | MPIcheckPoint(); |
469 | } | |
470 | + | finalOut.flush(); |
471 | + | sprintf( checkPointMsg, |
472 | + | "Sucessfully took a dump.\n"); |
473 | + | MPIcheckPoint(); |
474 | ||
475 | < | if( worldRank == 0 ) finalOut.close(); |
548 | < | |
549 | < | |
475 | > | if( worldRank == 0 ) finalOut.close(); |
476 | #endif // is_mpi | |
477 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |