60 |
|
Globals* simParams = info->getSimParams(); |
61 |
|
needCompression_ = simParams->getCompressDumpFile(); |
62 |
|
needForceVector_ = simParams->getOutputForceVector(); |
63 |
+ |
needParticlePot_ = simParams->getOutputParticlePotential(); |
64 |
|
createDumpFile_ = true; |
65 |
|
#ifdef HAVE_LIBZ |
66 |
|
if (needCompression_) { |
139 |
|
|
140 |
|
needCompression_ = simParams->getCompressDumpFile(); |
141 |
|
needForceVector_ = simParams->getOutputForceVector(); |
142 |
+ |
needParticlePot_ = simParams->getOutputParticlePotential(); |
143 |
|
|
144 |
|
#ifdef HAVE_LIBZ |
145 |
|
if (needCompression_) { |
308 |
|
} |
309 |
|
|
310 |
|
const int masterNode = 0; |
311 |
< |
|
311 |
> |
int nProc; |
312 |
> |
MPI_Comm_size(MPI_COMM_WORLD, &nProc); |
313 |
|
if (worldRank == masterNode) { |
314 |
|
os << " <Snapshot>\n"; |
315 |
|
writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot()); |
317 |
|
|
318 |
|
os << buffer; |
319 |
|
|
317 |
– |
int nProc; |
318 |
– |
MPI_Comm_size(MPI_COMM_WORLD, &nProc); |
320 |
|
for (int i = 1; i < nProc; ++i) { |
321 |
|
|
322 |
|
// receive the length of the string buffer that was |
323 |
|
// prepared by processor i |
324 |
|
|
325 |
+ |
MPI_Bcast(&i, 1, MPI_INT,masterNode,MPI_COMM_WORLD); |
326 |
|
int recvLength; |
327 |
|
MPI_Recv(&recvLength, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &istatus); |
328 |
|
char* recvBuffer = new char[recvLength]; |
339 |
|
os.flush(); |
340 |
|
} else { |
341 |
|
int sendBufferLength = buffer.size() + 1; |
342 |
< |
MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD); |
343 |
< |
MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD); |
342 |
> |
int myturn = 0; |
343 |
> |
for (int i = 1; i < nProc; ++i){ |
344 |
> |
MPI_Bcast(&myturn,1, MPI_INT,masterNode,MPI_COMM_WORLD); |
345 |
> |
if (myturn == worldRank){ |
346 |
> |
MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD); |
347 |
> |
MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD); |
348 |
> |
} |
349 |
> |
} |
350 |
|
} |
351 |
|
|
352 |
|
#endif // is_mpi |
466 |
|
line += tempBuffer; |
467 |
|
} |
468 |
|
} |
469 |
+ |
if (needParticlePot_) { |
470 |
+ |
type += "u"; |
471 |
+ |
RealType particlePot; |
472 |
+ |
|
473 |
+ |
particlePot = integrableObject->getParticlePot(); |
474 |
+ |
|
475 |
+ |
if (isinf(particlePot) || isnan(particlePot)) { |
476 |
+ |
sprintf( painCave.errMsg, |
477 |
+ |
"DumpWriter detected a numerical error writing the particle " |
478 |
+ |
" potential for object %d", index); |
479 |
+ |
painCave.isFatal = 1; |
480 |
+ |
simError(); |
481 |
+ |
} |
482 |
+ |
sprintf(tempBuffer, " %13e", particlePot); |
483 |
+ |
line += tempBuffer; |
484 |
+ |
} |
485 |
|
|
486 |
|
sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str()); |
487 |
|
return std::string(tempBuffer); |