2 |
|
#include <iostream> |
3 |
|
#include <fstream> |
4 |
|
|
5 |
+ |
#ifdef IS_MPI |
6 |
+ |
#include <mpi.h> |
7 |
+ |
#include "mpiSimulation.hpp" |
8 |
+ |
#endif //is_mpi |
9 |
+ |
|
10 |
|
#include "ReadWrite.hpp" |
11 |
|
#include "simError.h" |
12 |
|
|
13 |
|
|
14 |
+ |
|
15 |
+ |
|
16 |
+ |
|
17 |
|
DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ |
18 |
|
|
19 |
|
#ifdef IS_MPI |
20 |
< |
if(worldRank == TESTWRITE ){ |
20 |
> |
if(worldRank == 0 ){ |
21 |
|
#endif // is_mpi |
22 |
|
|
23 |
|
entry_plug = the_entry_plug; |
47 |
|
DumpWriter::~DumpWriter( ){ |
48 |
|
|
49 |
|
#ifdef IS_MPI |
50 |
< |
if(worldRank == TESTWRITE ){ |
50 |
> |
if(worldRank == 0 ){ |
51 |
|
#endif // is_mpi |
52 |
|
|
53 |
|
outFile.close(); |
58 |
|
} |
59 |
|
|
60 |
|
void DumpWriter::writeDump( double currentTime ){ |
61 |
+ |
|
62 |
+ |
const int BUFFERSIZE = 2000; |
63 |
+ |
char tempBuffer[500]; |
64 |
+ |
char writeLine[BUFFERSIZE]; |
65 |
|
|
66 |
< |
#ifdef IS_MPI |
67 |
< |
if(worldRank == TESTWRITE ){ |
68 |
< |
#endif // is_mpi |
66 |
> |
int i; |
67 |
> |
double q[4]; |
68 |
> |
DirectionalAtom* dAtom; |
69 |
> |
int nAtoms = entry_plug->n_atoms; |
70 |
> |
Atom** atoms = entry_plug->atoms; |
71 |
> |
|
72 |
|
|
73 |
< |
|
59 |
< |
int i; |
60 |
< |
double q[4]; |
61 |
< |
DirectionalAtom* dAtom; |
62 |
< |
int nAtoms = entry_plug->n_atoms; |
63 |
< |
Atom** atoms = entry_plug->atoms; |
73 |
> |
#ifndef IS_MPI |
74 |
|
|
75 |
+ |
outFile << nAtoms << "\n"; |
76 |
|
|
77 |
< |
outFile << nAtoms << "\n"; |
77 |
> |
outFile << currentTime << "\t" |
78 |
> |
<< entry_plug->box_x << "\t" |
79 |
> |
<< entry_plug->box_y << "\t" |
80 |
> |
<< entry_plug->box_z << "\n"; |
81 |
|
|
82 |
+ |
for( i=0; i<nAtoms; i++ ){ |
83 |
+ |
|
84 |
+ |
sprintf( tempBuffer, |
85 |
+ |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
86 |
+ |
atoms[i]->getType(), |
87 |
+ |
atoms[i]->getX(), |
88 |
+ |
atoms[i]->getY(), |
89 |
+ |
atoms[i]->getZ(), |
90 |
+ |
atoms[i]->get_vx(), |
91 |
+ |
atoms[i]->get_vy(), |
92 |
+ |
atoms[i]->get_vz()); |
93 |
+ |
strcpy( writeLine, tempBuffer ); |
94 |
+ |
|
95 |
+ |
if( atoms[i]->isDirectional() ){ |
96 |
+ |
|
97 |
+ |
dAtom = (DirectionalAtom *)atoms[i]; |
98 |
+ |
dAtom->getQ( q ); |
99 |
+ |
|
100 |
+ |
sprintf( tempBuffer, |
101 |
+ |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
102 |
+ |
q[0], |
103 |
+ |
q[1], |
104 |
+ |
q[2], |
105 |
+ |
q[3], |
106 |
+ |
dAtom->getJx(), |
107 |
+ |
dAtom->getJy(), |
108 |
+ |
dAtom->getJz()); |
109 |
+ |
strcat( writeLine, tempBuffer ); |
110 |
+ |
} |
111 |
+ |
else |
112 |
+ |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
113 |
+ |
|
114 |
+ |
outFile << writeLine; |
115 |
+ |
} |
116 |
+ |
outFile.flush(); |
117 |
+ |
|
118 |
+ |
#else // is_mpi |
119 |
+ |
|
120 |
+ |
int masterIndex; |
121 |
+ |
int nodeAtomsStart; |
122 |
+ |
int nodeAtomsEnd; |
123 |
+ |
int mpiErr; |
124 |
+ |
int sendError; |
125 |
+ |
int procIndex; |
126 |
+ |
|
127 |
+ |
MPI_Status istatus[MPI_STATUS_SIZE]; |
128 |
+ |
|
129 |
+ |
|
130 |
+ |
// write out header and node 0's coordinates |
131 |
+ |
|
132 |
+ |
if( worldRank == 0 ){ |
133 |
+ |
outFile << mpiSim->getTotAtoms() << "\n"; |
134 |
+ |
|
135 |
|
outFile << currentTime << "\t" |
136 |
|
<< entry_plug->box_x << "\t" |
137 |
|
<< entry_plug->box_y << "\t" |
138 |
|
<< entry_plug->box_z << "\n"; |
139 |
< |
|
139 |
> |
|
140 |
> |
masterIndex = 0; |
141 |
|
for( i=0; i<nAtoms; i++ ){ |
142 |
|
|
143 |
< |
outFile |
144 |
< |
<< atoms[i]->getType() << "\t" |
145 |
< |
<< atoms[i]->getX() << "\t" |
146 |
< |
<< atoms[i]->getY() << "\t" |
147 |
< |
<< atoms[i]->getZ() << "\t" |
148 |
< |
<< atoms[i]->get_vx() << "\t" |
149 |
< |
<< atoms[i]->get_vy() << "\t" |
150 |
< |
<< atoms[i]->get_vz() << "\t"; |
151 |
< |
|
152 |
< |
if( atoms[i]->isDirectional() ){ |
143 |
> |
sprintf( tempBuffer, |
144 |
> |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
145 |
> |
atoms[i]->getType(), |
146 |
> |
atoms[i]->getX(), |
147 |
> |
atoms[i]->getY(), |
148 |
> |
atoms[i]->getZ(), |
149 |
> |
atoms[i]->get_vx(), |
150 |
> |
atoms[i]->get_vy(), |
151 |
> |
atoms[i]->get_vz()); |
152 |
> |
strcpy( writeLine, tempBuffer ); |
153 |
|
|
154 |
+ |
if( atoms[i]->isDirectional() ){ |
155 |
+ |
|
156 |
|
dAtom = (DirectionalAtom *)atoms[i]; |
157 |
|
dAtom->getQ( q ); |
158 |
+ |
|
159 |
+ |
sprintf( tempBuffer, |
160 |
+ |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
161 |
+ |
q[0], |
162 |
+ |
q[1], |
163 |
+ |
q[2], |
164 |
+ |
q[3], |
165 |
+ |
dAtom->getJx(), |
166 |
+ |
dAtom->getJy(), |
167 |
+ |
dAtom->getJz()); |
168 |
+ |
strcat( writeLine, tempBuffer ); |
169 |
+ |
} |
170 |
+ |
else |
171 |
+ |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
172 |
|
|
173 |
< |
outFile |
174 |
< |
<< q[0] << "\t" |
175 |
< |
<< q[1] << "\t" |
176 |
< |
<< q[2] << "\t" |
177 |
< |
<< q[3] << "\t" |
178 |
< |
<< dAtom->getJx() << "\t" |
179 |
< |
<< dAtom->getJy() << "\t" |
180 |
< |
<< dAtom->getJz() << "\n"; |
173 |
> |
outFile << writeLine; |
174 |
> |
masterIndex++; |
175 |
> |
} |
176 |
> |
outFile.flush(); |
177 |
> |
} |
178 |
> |
|
179 |
> |
for (procIndex = 1; procIndex < mpiSim->getNumberProcessors(); |
180 |
> |
procIndex++){ |
181 |
> |
|
182 |
> |
if( worldRank == 0 ){ |
183 |
> |
|
184 |
> |
mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex, |
185 |
> |
MPI_ANY_TAG,MPI_COMM_WORLD,istatus); |
186 |
> |
|
187 |
> |
mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex, |
188 |
> |
MPI_ANY_TAG,MPI_COMM_WORLD, istatus); |
189 |
> |
|
190 |
> |
// Make sure where node 0 is writing to, matches where the |
191 |
> |
// receiving node expects it to be. |
192 |
> |
|
193 |
> |
if (masterIndex != nodeAtomsStart){ |
194 |
> |
sendError = 1; |
195 |
> |
mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG, |
196 |
> |
MPI_COMM_WORLD); |
197 |
> |
sprintf(painCave.errMsg, |
198 |
> |
"DumpWriter error: atoms start index (%d) for " |
199 |
> |
"node %d not equal to master index (%d)", |
200 |
> |
nodeAtomsStart,procIndex,masterIndex ); |
201 |
> |
painCave.isFatal = 1; |
202 |
> |
simError(); |
203 |
|
} |
204 |
< |
else{ |
205 |
< |
outFile |
206 |
< |
<< 0.0 << "\t" |
207 |
< |
<< 0.0 << "\t" |
208 |
< |
<< 0.0 << "\t" |
209 |
< |
<< 0.0 << "\t" |
210 |
< |
<< 0.0 << "\t" |
211 |
< |
<< 0.0 << "\t" |
212 |
< |
<< 0.0 << "\n"; |
204 |
> |
|
205 |
> |
sendError = 0; |
206 |
> |
mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG, |
207 |
> |
MPI_COMM_WORLD); |
208 |
> |
|
209 |
> |
// recieve the nodes writeLines |
210 |
> |
|
211 |
> |
for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){ |
212 |
> |
|
213 |
> |
mpiErr = MPI_Recv(writeLine,BUFFERSIZE,MPI_CHAR,procIndex, |
214 |
> |
MPI_ANY_TAG,MPI_COMM_WORLD,istatus ); |
215 |
> |
|
216 |
> |
outFile << writeLine; |
217 |
> |
masterIndex++; |
218 |
|
} |
219 |
|
} |
109 |
– |
outFile.flush(); |
220 |
|
|
221 |
< |
#ifdef IS_MPI |
221 |
> |
else if( worldRank == procIndex ){ |
222 |
> |
|
223 |
> |
nodeAtomsStart = mpiSim->getMyAtomStart(); |
224 |
> |
nodeAtomsEnd = mpiSim->getMyAtomEnd(); |
225 |
> |
|
226 |
> |
mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,MPI_ANY_TAG, |
227 |
> |
MPI_COMM_WORLD); |
228 |
> |
mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,MPI_ANY_TAG, |
229 |
> |
MPI_COMM_WORLD); |
230 |
> |
|
231 |
> |
mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,MPI_ANY_TAG, |
232 |
> |
MPI_COMM_WORLD, istatus); |
233 |
> |
if (sendError) MPIcheckPoint(); |
234 |
> |
|
235 |
> |
// send current node's configuration line by line. |
236 |
> |
|
237 |
> |
for( i=0; i<nAtoms; i++ ){ |
238 |
> |
|
239 |
> |
sprintf( tempBuffer, |
240 |
> |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
241 |
> |
atoms[i]->getType(), |
242 |
> |
atoms[i]->getX(), |
243 |
> |
atoms[i]->getY(), |
244 |
> |
atoms[i]->getZ(), |
245 |
> |
atoms[i]->get_vx(), |
246 |
> |
atoms[i]->get_vy(), |
247 |
> |
atoms[i]->get_vz()); |
248 |
> |
strcpy( writeLine, tempBuffer ); |
249 |
> |
|
250 |
> |
if( atoms[i]->isDirectional() ){ |
251 |
> |
|
252 |
> |
dAtom = (DirectionalAtom *)atoms[i]; |
253 |
> |
dAtom->getQ( q ); |
254 |
> |
|
255 |
> |
sprintf( tempBuffer, |
256 |
> |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
257 |
> |
q[0], |
258 |
> |
q[1], |
259 |
> |
q[2], |
260 |
> |
q[3], |
261 |
> |
dAtom->getJx(), |
262 |
> |
dAtom->getJy(), |
263 |
> |
dAtom->getJz()); |
264 |
> |
strcat( writeLine, tempBuffer ); |
265 |
> |
} |
266 |
> |
else |
267 |
> |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
268 |
> |
|
269 |
> |
mpiErr = MPI_Send(writeLine,BUFFERSIZE,MPI_CHAR,0,MPI_ANY_TAG, |
270 |
> |
MPI_COMM_WORLD); |
271 |
> |
} |
272 |
> |
} |
273 |
> |
|
274 |
> |
sprintf(checkPointMsg,"Node %d sent dump configuration.", |
275 |
> |
procIndex); |
276 |
> |
MPIcheckPoint(); |
277 |
|
} |
278 |
+ |
|
279 |
|
#endif // is_mpi |
280 |
|
} |
281 |
|
|
283 |
|
|
284 |
|
void DumpWriter::writeFinal(){ |
285 |
|
|
120 |
– |
#ifdef IS_MPI |
121 |
– |
if(worldRank == TESTWRITE ){ |
122 |
– |
#endif // is_mpi |
286 |
|
|
287 |
< |
char finalName[500]; |
288 |
< |
strcpy( finalName, entry_plug->finalName ); |
287 |
> |
const int BUFFERSIZE = 2000; |
288 |
> |
char tempBuffer[500]; |
289 |
> |
char writeLine[BUFFERSIZE]; |
290 |
> |
|
291 |
> |
char finalName[500]; |
292 |
|
|
293 |
< |
ofstream finalOut( finalName ); |
293 |
> |
int i; |
294 |
> |
double q[4]; |
295 |
> |
DirectionalAtom* dAtom; |
296 |
> |
int nAtoms = entry_plug->n_atoms; |
297 |
> |
Atom** atoms = entry_plug->atoms; |
298 |
> |
|
299 |
> |
ofstream finalOut; |
300 |
> |
|
301 |
> |
#ifdef IS_MPI |
302 |
> |
if(worldRank == 0 ){ |
303 |
> |
#endif // is_mpi |
304 |
> |
|
305 |
> |
strcpy( finalName, entry_plug->finalName ); |
306 |
> |
|
307 |
> |
finalOut.open( finalName, ios::out | ios::trunc ); |
308 |
|
if( !finalOut ){ |
309 |
|
sprintf( painCave.errMsg, |
310 |
|
"Could not open \"%s\" for final dump output.\n", |
315 |
|
|
316 |
|
// finalOut.setf( ios::scientific ); |
317 |
|
|
318 |
+ |
#ifdef IS_MPI |
319 |
+ |
} |
320 |
+ |
|
321 |
+ |
sprintf(checkPointMsg,"Opened file for final configuration\n"); |
322 |
+ |
MPIcheckPoint(); |
323 |
+ |
|
324 |
+ |
#endif //is_mpi |
325 |
+ |
|
326 |
|
|
327 |
< |
int i; |
328 |
< |
double q[4]; |
141 |
< |
DirectionalAtom* dAtom; |
142 |
< |
int nAtoms = entry_plug->n_atoms; |
143 |
< |
Atom** atoms = entry_plug->atoms; |
327 |
> |
|
328 |
> |
#ifndef IS_MPI |
329 |
|
|
330 |
+ |
finalOut << nAtoms << "\n"; |
331 |
|
|
332 |
< |
finalOut << nAtoms << "\n"; |
332 |
> |
finalOut << entry_plug->box_x << "\t" |
333 |
> |
<< entry_plug->box_y << "\t" |
334 |
> |
<< entry_plug->box_z << "\n"; |
335 |
|
|
336 |
< |
finalOut << 0.0 << "\t" |
337 |
< |
<< entry_plug->box_x << "\t" |
336 |
> |
for( i=0; i<nAtoms; i++ ){ |
337 |
> |
|
338 |
> |
sprintf( tempBuffer, |
339 |
> |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
340 |
> |
atoms[i]->getType(), |
341 |
> |
atoms[i]->getX(), |
342 |
> |
atoms[i]->getY(), |
343 |
> |
atoms[i]->getZ(), |
344 |
> |
atoms[i]->get_vx(), |
345 |
> |
atoms[i]->get_vy(), |
346 |
> |
atoms[i]->get_vz()); |
347 |
> |
strcpy( writeLine, tempBuffer ); |
348 |
> |
|
349 |
> |
if( atoms[i]->isDirectional() ){ |
350 |
> |
|
351 |
> |
dAtom = (DirectionalAtom *)atoms[i]; |
352 |
> |
dAtom->getQ( q ); |
353 |
> |
|
354 |
> |
sprintf( tempBuffer, |
355 |
> |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
356 |
> |
q[0], |
357 |
> |
q[1], |
358 |
> |
q[2], |
359 |
> |
q[3], |
360 |
> |
dAtom->getJx(), |
361 |
> |
dAtom->getJy(), |
362 |
> |
dAtom->getJz()); |
363 |
> |
strcat( writeLine, tempBuffer ); |
364 |
> |
} |
365 |
> |
else |
366 |
> |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
367 |
> |
|
368 |
> |
finalOut << writeLine; |
369 |
> |
} |
370 |
> |
finalOut.flush(); |
371 |
> |
|
372 |
> |
#else // is_mpi |
373 |
> |
|
374 |
> |
int masterIndex; |
375 |
> |
int nodeAtomsStart; |
376 |
> |
int nodeAtomsEnd; |
377 |
> |
int mpiErr; |
378 |
> |
int sendError; |
379 |
> |
int procIndex; |
380 |
> |
|
381 |
> |
MPI_Status istatus[MPI_STATUS_SIZE]; |
382 |
> |
|
383 |
> |
|
384 |
> |
// write out header and node 0's coordinates |
385 |
> |
|
386 |
> |
if( worldRank == 0 ){ |
387 |
> |
finalOut << mpiSim->getTotAtoms() << "\n"; |
388 |
> |
|
389 |
> |
finalOut << entry_plug->box_x << "\t" |
390 |
|
<< entry_plug->box_y << "\t" |
391 |
|
<< entry_plug->box_z << "\n"; |
392 |
|
|
393 |
+ |
masterIndex = 0; |
394 |
|
for( i=0; i<nAtoms; i++ ){ |
395 |
|
|
396 |
< |
finalOut |
397 |
< |
<< atoms[i]->getType() << "\t" |
398 |
< |
<< atoms[i]->getX() << "\t" |
399 |
< |
<< atoms[i]->getY() << "\t" |
400 |
< |
<< atoms[i]->getZ() << "\t" |
401 |
< |
<< atoms[i]->get_vx() << "\t" |
402 |
< |
<< atoms[i]->get_vy() << "\t" |
403 |
< |
<< atoms[i]->get_vz() << "\t"; |
404 |
< |
|
405 |
< |
if( atoms[i]->isDirectional() ){ |
396 |
> |
sprintf( tempBuffer, |
397 |
> |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
398 |
> |
atoms[i]->getType(), |
399 |
> |
atoms[i]->getX(), |
400 |
> |
atoms[i]->getY(), |
401 |
> |
atoms[i]->getZ(), |
402 |
> |
atoms[i]->get_vx(), |
403 |
> |
atoms[i]->get_vy(), |
404 |
> |
atoms[i]->get_vz()); |
405 |
> |
strcpy( writeLine, tempBuffer ); |
406 |
|
|
407 |
+ |
if( atoms[i]->isDirectional() ){ |
408 |
+ |
|
409 |
|
dAtom = (DirectionalAtom *)atoms[i]; |
410 |
|
dAtom->getQ( q ); |
411 |
+ |
|
412 |
+ |
sprintf( tempBuffer, |
413 |
+ |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
414 |
+ |
q[0], |
415 |
+ |
q[1], |
416 |
+ |
q[2], |
417 |
+ |
q[3], |
418 |
+ |
dAtom->getJx(), |
419 |
+ |
dAtom->getJy(), |
420 |
+ |
dAtom->getJz()); |
421 |
+ |
strcat( writeLine, tempBuffer ); |
422 |
+ |
} |
423 |
+ |
else |
424 |
+ |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
425 |
|
|
426 |
< |
finalOut |
427 |
< |
<< q[0] << "\t" |
428 |
< |
<< q[1] << "\t" |
429 |
< |
<< q[2] << "\t" |
430 |
< |
<< q[3] << "\t" |
431 |
< |
<< dAtom->getJx() << "\t" |
432 |
< |
<< dAtom->getJy() << "\t" |
433 |
< |
<< dAtom->getJz() << "\n"; |
426 |
> |
outFile << writeLine; |
427 |
> |
masterIndex++; |
428 |
> |
} |
429 |
> |
finalOut.flush(); |
430 |
> |
} |
431 |
> |
|
432 |
> |
for (procIndex = 1; procIndex < mpiSim->getNumberProcessors(); |
433 |
> |
procIndex++){ |
434 |
> |
|
435 |
> |
if( worldRank == 0 ){ |
436 |
> |
|
437 |
> |
mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex, |
438 |
> |
MPI_ANY_TAG,MPI_COMM_WORLD,istatus); |
439 |
> |
|
440 |
> |
mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex, |
441 |
> |
MPI_ANY_TAG,MPI_COMM_WORLD, istatus); |
442 |
> |
|
443 |
> |
// Make sure where node 0 is writing to, matches where the |
444 |
> |
// receiving node expects it to be. |
445 |
> |
|
446 |
> |
if (masterIndex != nodeAtomsStart){ |
447 |
> |
sendError = 1; |
448 |
> |
mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG, |
449 |
> |
MPI_COMM_WORLD); |
450 |
> |
sprintf(painCave.errMsg, |
451 |
> |
"DumpWriter error: atoms start index (%d) for " |
452 |
> |
"node %d not equal to master index (%d)", |
453 |
> |
nodeAtomsStart,procIndex,masterIndex ); |
454 |
> |
painCave.isFatal = 1; |
455 |
> |
simError(); |
456 |
|
} |
457 |
< |
else{ |
458 |
< |
finalOut |
459 |
< |
<< 0.0 << "\t" |
460 |
< |
<< 0.0 << "\t" |
461 |
< |
<< 0.0 << "\t" |
462 |
< |
<< 0.0 << "\t" |
463 |
< |
<< 0.0 << "\t" |
464 |
< |
<< 0.0 << "\t" |
465 |
< |
<< 0.0 << "\n"; |
457 |
> |
|
458 |
> |
sendError = 0; |
459 |
> |
mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG, |
460 |
> |
MPI_COMM_WORLD); |
461 |
> |
|
462 |
> |
// recieve the nodes writeLines |
463 |
> |
|
464 |
> |
for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){ |
465 |
> |
|
466 |
> |
mpiErr = MPI_Recv(writeLine,BUFFERSIZE,MPI_CHAR,procIndex, |
467 |
> |
MPI_ANY_TAG,MPI_COMM_WORLD,istatus ); |
468 |
> |
|
469 |
> |
finalOut << writeLine; |
470 |
> |
masterIndex++; |
471 |
|
} |
472 |
+ |
|
473 |
+ |
finalOut.flush(); |
474 |
|
} |
475 |
< |
finalOut.close(); |
476 |
< |
|
477 |
< |
#ifdef IS_MPI |
475 |
> |
|
476 |
> |
else if( worldRank == procIndex ){ |
477 |
> |
|
478 |
> |
nodeAtomsStart = mpiSim->getMyAtomStart(); |
479 |
> |
nodeAtomsEnd = mpiSim->getMyAtomEnd(); |
480 |
> |
|
481 |
> |
mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,MPI_ANY_TAG, |
482 |
> |
MPI_COMM_WORLD); |
483 |
> |
mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,MPI_ANY_TAG, |
484 |
> |
MPI_COMM_WORLD); |
485 |
> |
|
486 |
> |
mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,MPI_ANY_TAG, |
487 |
> |
MPI_COMM_WORLD, istatus); |
488 |
> |
if (sendError) MPIcheckPoint(); |
489 |
> |
|
490 |
> |
// send current node's configuration line by line. |
491 |
> |
|
492 |
> |
for( i=0; i<nAtoms; i++ ){ |
493 |
> |
|
494 |
> |
sprintf( tempBuffer, |
495 |
> |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
496 |
> |
atoms[i]->getType(), |
497 |
> |
atoms[i]->getX(), |
498 |
> |
atoms[i]->getY(), |
499 |
> |
atoms[i]->getZ(), |
500 |
> |
atoms[i]->get_vx(), |
501 |
> |
atoms[i]->get_vy(), |
502 |
> |
atoms[i]->get_vz()); |
503 |
> |
strcpy( writeLine, tempBuffer ); |
504 |
> |
|
505 |
> |
if( atoms[i]->isDirectional() ){ |
506 |
> |
|
507 |
> |
dAtom = (DirectionalAtom *)atoms[i]; |
508 |
> |
dAtom->getQ( q ); |
509 |
> |
|
510 |
> |
sprintf( tempBuffer, |
511 |
> |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
512 |
> |
q[0], |
513 |
> |
q[1], |
514 |
> |
q[2], |
515 |
> |
q[3], |
516 |
> |
dAtom->getJx(), |
517 |
> |
dAtom->getJy(), |
518 |
> |
dAtom->getJz()); |
519 |
> |
strcat( writeLine, tempBuffer ); |
520 |
> |
} |
521 |
> |
else |
522 |
> |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
523 |
> |
|
524 |
> |
mpiErr = MPI_Send(writeLine,BUFFERSIZE,MPI_CHAR,0,MPI_ANY_TAG, |
525 |
> |
MPI_COMM_WORLD); |
526 |
> |
} |
527 |
> |
} |
528 |
> |
|
529 |
> |
sprintf(checkPointMsg,"Node %d sent dump configuration.", |
530 |
> |
procIndex); |
531 |
> |
MPIcheckPoint(); |
532 |
|
} |
533 |
+ |
|
534 |
+ |
if( worldRank == 0 ) finalOut.close(); |
535 |
+ |
|
536 |
+ |
|
537 |
|
#endif // is_mpi |
538 |
|
} |