| 1 |
< |
#define _LARGEFILE_SOURCE64 |
| 2 |
< |
#define _FILE_OFFSET_BITS 64 |
| 1 |
> |
/* |
| 2 |
> |
* Copyright (c) 2009 The University of Notre Dame. All Rights Reserved. |
| 3 |
> |
* |
| 4 |
> |
* The University of Notre Dame grants you ("Licensee") a |
| 5 |
> |
* non-exclusive, royalty free, license to use, modify and |
| 6 |
> |
* redistribute this software in source and binary code form, provided |
| 7 |
> |
* that the following conditions are met: |
| 8 |
> |
* |
| 9 |
> |
* 1. Redistributions of source code must retain the above copyright |
| 10 |
> |
* notice, this list of conditions and the following disclaimer. |
| 11 |
> |
* |
| 12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
> |
* notice, this list of conditions and the following disclaimer in the |
| 14 |
> |
* documentation and/or other materials provided with the |
| 15 |
> |
* distribution. |
| 16 |
> |
* |
| 17 |
> |
* This software is provided "AS IS," without a warranty of any |
| 18 |
> |
* kind. All express or implied conditions, representations and |
| 19 |
> |
* warranties, including any implied warranty of merchantability, |
| 20 |
> |
* fitness for a particular purpose or non-infringement, are hereby |
| 21 |
> |
* excluded. The University of Notre Dame and its licensors shall not |
| 22 |
> |
* be liable for any damages suffered by licensee as a result of |
| 23 |
> |
* using, modifying or distributing the software or its |
| 24 |
> |
* derivatives. In no event will the University of Notre Dame or its |
| 25 |
> |
* licensors be liable for any lost revenue, profit or data, or for |
| 26 |
> |
* direct, indirect, special, consequential, incidental or punitive |
| 27 |
> |
* damages, however caused and regardless of the theory of liability, |
| 28 |
> |
* arising out of the use of or inability to use software, even if the |
| 29 |
> |
* University of Notre Dame has been advised of the possibility of |
| 30 |
> |
* such damages. |
| 31 |
> |
* |
| 32 |
> |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
| 33 |
> |
* research, please cite the appropriate papers when you publish your |
| 34 |
> |
* work. Good starting points are: |
| 35 |
> |
* |
| 36 |
> |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
> |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
| 38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
| 39 |
> |
* [4] Vardeman & Gezelter, in progress (2009). |
| 40 |
> |
*/ |
| 41 |
> |
|
| 42 |
> |
#include "io/DumpWriter.hpp" |
| 43 |
> |
#include "primitives/Molecule.hpp" |
| 44 |
> |
#include "utils/simError.h" |
| 45 |
> |
#include "io/basic_teebuf.hpp" |
| 46 |
> |
#include "io/gzstream.hpp" |
| 47 |
> |
#include "io/Globals.hpp" |
| 48 |
|
|
| 4 |
– |
#include <string.h> |
| 5 |
– |
#include <iostream> |
| 6 |
– |
#include <fstream> |
| 7 |
– |
#include <algorithm> |
| 8 |
– |
#include <utility> |
| 9 |
– |
|
| 49 |
|
#ifdef IS_MPI |
| 50 |
|
#include <mpi.h> |
| 12 |
– |
#include "brains/mpiSimulation.hpp" |
| 13 |
– |
|
| 14 |
– |
namespace dWrite{ |
| 15 |
– |
void DieDieDie( void ); |
| 16 |
– |
} |
| 17 |
– |
|
| 18 |
– |
using namespace dWrite; |
| 51 |
|
#endif //is_mpi |
| 52 |
|
|
| 53 |
< |
#include "io/ReadWrite.hpp" |
| 22 |
< |
#include "utils/simError.h" |
| 53 |
> |
namespace OpenMD { |
| 54 |
|
|
| 55 |
< |
DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ |
| 55 |
> |
DumpWriter::DumpWriter(SimInfo* info) |
| 56 |
> |
: info_(info), filename_(info->getDumpFileName()), eorFilename_(info->getFinalConfigFileName()){ |
| 57 |
|
|
| 58 |
< |
entry_plug = the_entry_plug; |
| 59 |
< |
|
| 58 |
> |
Globals* simParams = info->getSimParams(); |
| 59 |
> |
needCompression_ = simParams->getCompressDumpFile(); |
| 60 |
> |
needForceVector_ = simParams->getOutputForceVector(); |
| 61 |
> |
createDumpFile_ = true; |
| 62 |
> |
#ifdef HAVE_LIBZ |
| 63 |
> |
if (needCompression_) { |
| 64 |
> |
filename_ += ".gz"; |
| 65 |
> |
eorFilename_ += ".gz"; |
| 66 |
> |
} |
| 67 |
> |
#endif |
| 68 |
> |
|
| 69 |
|
#ifdef IS_MPI |
| 70 |
< |
if(worldRank == 0 ){ |
| 70 |
> |
|
| 71 |
> |
if (worldRank == 0) { |
| 72 |
|
#endif // is_mpi |
| 73 |
+ |
|
| 74 |
+ |
dumpFile_ = createOStream(filename_); |
| 75 |
|
|
| 76 |
< |
dumpFile.open(entry_plug->sampleName.c_str(), ios::out | ios::trunc ); |
| 76 |
> |
if (!dumpFile_) { |
| 77 |
> |
sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n", |
| 78 |
> |
filename_.c_str()); |
| 79 |
> |
painCave.isFatal = 1; |
| 80 |
> |
simError(); |
| 81 |
> |
} |
| 82 |
|
|
| 83 |
< |
if( !dumpFile ){ |
| 83 |
> |
#ifdef IS_MPI |
| 84 |
|
|
| 36 |
– |
sprintf( painCave.errMsg, |
| 37 |
– |
"Could not open \"%s\" for dump output.\n", |
| 38 |
– |
entry_plug->sampleName.c_str()); |
| 39 |
– |
painCave.isFatal = 1; |
| 40 |
– |
simError(); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
< |
#ifdef IS_MPI |
| 87 |
> |
#endif // is_mpi |
| 88 |
> |
|
| 89 |
|
} |
| 90 |
|
|
| 46 |
– |
//sort the local atoms by global index |
| 47 |
– |
sortByGlobalIndex(); |
| 48 |
– |
|
| 49 |
– |
sprintf( checkPointMsg, |
| 50 |
– |
"Sucessfully opened output file for dumping.\n"); |
| 51 |
– |
MPIcheckPoint(); |
| 52 |
– |
#endif // is_mpi |
| 53 |
– |
} |
| 91 |
|
|
| 92 |
< |
DumpWriter::~DumpWriter( ){ |
| 92 |
> |
DumpWriter::DumpWriter(SimInfo* info, const std::string& filename) |
| 93 |
> |
: info_(info), filename_(filename){ |
| 94 |
|
|
| 95 |
+ |
Globals* simParams = info->getSimParams(); |
| 96 |
+ |
eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor"; |
| 97 |
+ |
|
| 98 |
+ |
needCompression_ = simParams->getCompressDumpFile(); |
| 99 |
+ |
needForceVector_ = simParams->getOutputForceVector(); |
| 100 |
+ |
createDumpFile_ = true; |
| 101 |
+ |
#ifdef HAVE_LIBZ |
| 102 |
+ |
if (needCompression_) { |
| 103 |
+ |
filename_ += ".gz"; |
| 104 |
+ |
eorFilename_ += ".gz"; |
| 105 |
+ |
} |
| 106 |
+ |
#endif |
| 107 |
+ |
|
| 108 |
|
#ifdef IS_MPI |
| 109 |
< |
if(worldRank == 0 ){ |
| 109 |
> |
|
| 110 |
> |
if (worldRank == 0) { |
| 111 |
|
#endif // is_mpi |
| 112 |
|
|
| 113 |
< |
dumpFile.close(); |
| 113 |
> |
|
| 114 |
> |
dumpFile_ = createOStream(filename_); |
| 115 |
|
|
| 116 |
< |
#ifdef IS_MPI |
| 117 |
< |
} |
| 118 |
< |
#endif // is_mpi |
| 119 |
< |
} |
| 116 |
> |
if (!dumpFile_) { |
| 117 |
> |
sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n", |
| 118 |
> |
filename_.c_str()); |
| 119 |
> |
painCave.isFatal = 1; |
| 120 |
> |
simError(); |
| 121 |
> |
} |
| 122 |
|
|
| 123 |
|
#ifdef IS_MPI |
| 124 |
|
|
| 125 |
< |
/** |
| 71 |
< |
* A hook function to load balancing |
| 72 |
< |
*/ |
| 125 |
> |
} |
| 126 |
|
|
| 127 |
< |
void DumpWriter::update(){ |
| 75 |
< |
sortByGlobalIndex(); |
| 76 |
< |
} |
| 77 |
< |
|
| 78 |
< |
/** |
| 79 |
< |
* Auxiliary sorting function |
| 80 |
< |
*/ |
| 81 |
< |
|
| 82 |
< |
bool indexSortingCriterion(const pair<int, int>& p1, const pair<int, int>& p2){ |
| 83 |
< |
return p1.second < p2.second; |
| 84 |
< |
} |
| 127 |
> |
#endif // is_mpi |
| 128 |
|
|
| 129 |
< |
/** |
| 87 |
< |
* Sorting the local index by global index |
| 88 |
< |
*/ |
| 89 |
< |
|
| 90 |
< |
void DumpWriter::sortByGlobalIndex(){ |
| 91 |
< |
Molecule* mols = entry_plug->molecules; |
| 92 |
< |
indexArray.clear(); |
| 129 |
> |
} |
| 130 |
|
|
| 131 |
< |
for(int i = 0; i < entry_plug->n_mol;i++) |
| 132 |
< |
indexArray.push_back(make_pair(i, mols[i].getGlobalIndex())); |
| 133 |
< |
|
| 134 |
< |
sort(indexArray.begin(), indexArray.end(), indexSortingCriterion); |
| 135 |
< |
} |
| 136 |
< |
|
| 131 |
> |
DumpWriter::DumpWriter(SimInfo* info, const std::string& filename, bool writeDumpFile) |
| 132 |
> |
: info_(info), filename_(filename){ |
| 133 |
> |
|
| 134 |
> |
Globals* simParams = info->getSimParams(); |
| 135 |
> |
eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor"; |
| 136 |
> |
|
| 137 |
> |
needCompression_ = simParams->getCompressDumpFile(); |
| 138 |
> |
needForceVector_ = simParams->getOutputForceVector(); |
| 139 |
> |
|
| 140 |
> |
#ifdef HAVE_LIBZ |
| 141 |
> |
if (needCompression_) { |
| 142 |
> |
filename_ += ".gz"; |
| 143 |
> |
eorFilename_ += ".gz"; |
| 144 |
> |
} |
| 145 |
|
#endif |
| 146 |
< |
|
| 102 |
< |
void DumpWriter::writeDump(double currentTime){ |
| 103 |
< |
|
| 104 |
< |
ofstream finalOut; |
| 105 |
< |
vector<ofstream*> fileStreams; |
| 106 |
< |
|
| 146 |
> |
|
| 147 |
|
#ifdef IS_MPI |
| 148 |
< |
if(worldRank == 0 ){ |
| 149 |
< |
#endif |
| 110 |
< |
finalOut.open( entry_plug->finalName.c_str(), ios::out | ios::trunc ); |
| 111 |
< |
if( !finalOut ){ |
| 112 |
< |
sprintf( painCave.errMsg, |
| 113 |
< |
"Could not open \"%s\" for final dump output.\n", |
| 114 |
< |
entry_plug->finalName.c_str() ); |
| 115 |
< |
painCave.isFatal = 1; |
| 116 |
< |
simError(); |
| 117 |
< |
} |
| 118 |
< |
#ifdef IS_MPI |
| 119 |
< |
} |
| 148 |
> |
|
| 149 |
> |
if (worldRank == 0) { |
| 150 |
|
#endif // is_mpi |
| 151 |
< |
|
| 152 |
< |
fileStreams.push_back(&finalOut); |
| 153 |
< |
fileStreams.push_back(&dumpFile); |
| 154 |
< |
|
| 155 |
< |
writeFrame(fileStreams, currentTime); |
| 156 |
< |
|
| 151 |
> |
|
| 152 |
> |
createDumpFile_ = writeDumpFile; |
| 153 |
> |
if (createDumpFile_) { |
| 154 |
> |
dumpFile_ = createOStream(filename_); |
| 155 |
> |
|
| 156 |
> |
if (!dumpFile_) { |
| 157 |
> |
sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n", |
| 158 |
> |
filename_.c_str()); |
| 159 |
> |
painCave.isFatal = 1; |
| 160 |
> |
simError(); |
| 161 |
> |
} |
| 162 |
> |
} |
| 163 |
|
#ifdef IS_MPI |
| 164 |
< |
finalOut.close(); |
| 165 |
< |
#endif |
| 130 |
< |
|
| 131 |
< |
} |
| 164 |
> |
|
| 165 |
> |
} |
| 166 |
|
|
| 167 |
< |
void DumpWriter::writeFinal(double currentTime){ |
| 167 |
> |
|
| 168 |
> |
#endif // is_mpi |
| 169 |
> |
|
| 170 |
> |
} |
| 171 |
|
|
| 172 |
< |
ofstream finalOut; |
| 136 |
< |
vector<ofstream*> fileStreams; |
| 172 |
> |
DumpWriter::~DumpWriter() { |
| 173 |
|
|
| 174 |
|
#ifdef IS_MPI |
| 175 |
< |
if(worldRank == 0 ){ |
| 175 |
> |
|
| 176 |
> |
if (worldRank == 0) { |
| 177 |
|
#endif // is_mpi |
| 178 |
+ |
if (createDumpFile_){ |
| 179 |
+ |
writeClosing(*dumpFile_); |
| 180 |
+ |
delete dumpFile_; |
| 181 |
+ |
} |
| 182 |
+ |
#ifdef IS_MPI |
| 183 |
|
|
| 142 |
– |
finalOut.open( entry_plug->finalName.c_str(), ios::out | ios::trunc ); |
| 143 |
– |
|
| 144 |
– |
if( !finalOut ){ |
| 145 |
– |
sprintf( painCave.errMsg, |
| 146 |
– |
"Could not open \"%s\" for final dump output.\n", |
| 147 |
– |
entry_plug->finalName.c_str() ); |
| 148 |
– |
painCave.isFatal = 1; |
| 149 |
– |
simError(); |
| 184 |
|
} |
| 185 |
|
|
| 152 |
– |
#ifdef IS_MPI |
| 153 |
– |
} |
| 186 |
|
#endif // is_mpi |
| 155 |
– |
|
| 156 |
– |
fileStreams.push_back(&finalOut); |
| 157 |
– |
writeFrame(fileStreams, currentTime); |
| 187 |
|
|
| 188 |
< |
#ifdef IS_MPI |
| 160 |
< |
finalOut.close(); |
| 161 |
< |
#endif |
| 162 |
< |
|
| 163 |
< |
} |
| 188 |
> |
} |
| 189 |
|
|
| 190 |
< |
void DumpWriter::writeFrame( vector<ofstream*>& outFile, double currentTime ){ |
| 190 |
> |
void DumpWriter::writeFrameProperties(std::ostream& os, Snapshot* s) { |
| 191 |
|
|
| 192 |
< |
const int BUFFERSIZE = 2000; |
| 168 |
< |
const int MINIBUFFERSIZE = 100; |
| 192 |
> |
char buffer[1024]; |
| 193 |
|
|
| 194 |
< |
char tempBuffer[BUFFERSIZE]; |
| 171 |
< |
char writeLine[BUFFERSIZE]; |
| 194 |
> |
os << " <FrameData>\n"; |
| 195 |
|
|
| 196 |
< |
int i; |
| 197 |
< |
unsigned int k; |
| 196 |
> |
RealType currentTime = s->getTime(); |
| 197 |
> |
sprintf(buffer, " Time: %.10g\n", currentTime); |
| 198 |
> |
os << buffer; |
| 199 |
|
|
| 200 |
< |
#ifdef IS_MPI |
| 201 |
< |
|
| 202 |
< |
/********************************************************************* |
| 203 |
< |
* Documentation? You want DOCUMENTATION? |
| 204 |
< |
* |
| 205 |
< |
* Why all the potatoes below? |
| 206 |
< |
* |
| 183 |
< |
* To make a long story short, the original version of DumpWriter |
| 184 |
< |
* worked in the most inefficient way possible. Node 0 would |
| 185 |
< |
* poke each of the node for an individual atom's formatted data |
| 186 |
< |
* as node 0 worked its way down the global index. This was particularly |
| 187 |
< |
* inefficient since the method blocked all processors at every atom |
| 188 |
< |
* (and did it twice!). |
| 189 |
< |
* |
| 190 |
< |
* An intermediate version of DumpWriter could be described from Node |
| 191 |
< |
* zero's perspective as follows: |
| 192 |
< |
* |
| 193 |
< |
* 1) Have 100 of your friends stand in a circle. |
| 194 |
< |
* 2) When you say go, have all of them start tossing potatoes at |
| 195 |
< |
* you (one at a time). |
| 196 |
< |
* 3) Catch the potatoes. |
| 197 |
< |
* |
| 198 |
< |
* It was an improvement, but MPI has buffers and caches that could |
| 199 |
< |
* best be described in this analogy as "potato nets", so there's no |
| 200 |
< |
* need to block the processors atom-by-atom. |
| 201 |
< |
* |
| 202 |
< |
* This new and improved DumpWriter works in an even more efficient |
| 203 |
< |
* way: |
| 204 |
< |
* |
| 205 |
< |
* 1) Have 100 of your friend stand in a circle. |
| 206 |
< |
* 2) When you say go, have them start tossing 5-pound bags of |
| 207 |
< |
* potatoes at you. |
| 208 |
< |
* 3) Once you've caught a friend's bag of potatoes, |
| 209 |
< |
* toss them a spud to let them know they can toss another bag. |
| 210 |
< |
* |
| 211 |
< |
* How's THAT for documentation? |
| 212 |
< |
* |
| 213 |
< |
*********************************************************************/ |
| 200 |
> |
Mat3x3d hmat; |
| 201 |
> |
hmat = s->getHmat(); |
| 202 |
> |
sprintf(buffer, " Hmat: {{ %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }}\n", |
| 203 |
> |
hmat(0, 0), hmat(1, 0), hmat(2, 0), |
| 204 |
> |
hmat(0, 1), hmat(1, 1), hmat(2, 1), |
| 205 |
> |
hmat(0, 2), hmat(1, 2), hmat(2, 2)); |
| 206 |
> |
os << buffer; |
| 207 |
|
|
| 208 |
< |
int *potatoes; |
| 209 |
< |
int myPotato; |
| 208 |
> |
RealType chi = s->getChi(); |
| 209 |
> |
RealType integralOfChiDt = s->getIntegralOfChiDt(); |
| 210 |
> |
sprintf(buffer, " Thermostat: %.10g , %.10g\n", chi, integralOfChiDt); |
| 211 |
> |
os << buffer; |
| 212 |
|
|
| 213 |
< |
int nProc; |
| 214 |
< |
int j, which_node, done, which_atom, local_index, currentIndex; |
| 215 |
< |
double atomData[13]; |
| 216 |
< |
int isDirectional; |
| 217 |
< |
char* atomTypeString; |
| 218 |
< |
char MPIatomTypeString[MINIBUFFERSIZE]; |
| 219 |
< |
int nObjects; |
| 225 |
< |
int msgLen; // the length of message actually recieved at master nodes |
| 226 |
< |
#endif //is_mpi |
| 213 |
> |
Mat3x3d eta; |
| 214 |
> |
eta = s->getEta(); |
| 215 |
> |
sprintf(buffer, " Barostat: {{ %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }}\n", |
| 216 |
> |
eta(0, 0), eta(1, 0), eta(2, 0), |
| 217 |
> |
eta(0, 1), eta(1, 1), eta(2, 1), |
| 218 |
> |
eta(0, 2), eta(1, 2), eta(2, 2)); |
| 219 |
> |
os << buffer; |
| 220 |
|
|
| 221 |
< |
double q[4], ji[3]; |
| 229 |
< |
DirectionalAtom* dAtom; |
| 230 |
< |
double pos[3], vel[3]; |
| 231 |
< |
int nTotObjects; |
| 232 |
< |
StuntDouble* sd; |
| 233 |
< |
char* molName; |
| 234 |
< |
vector<StuntDouble*> integrableObjects; |
| 235 |
< |
vector<StuntDouble*>::iterator iter; |
| 236 |
< |
nTotObjects = entry_plug->getTotIntegrableObjects(); |
| 237 |
< |
#ifndef IS_MPI |
| 238 |
< |
|
| 239 |
< |
for(k = 0; k < outFile.size(); k++){ |
| 240 |
< |
*outFile[k] << nTotObjects << "\n"; |
| 241 |
< |
|
| 242 |
< |
*outFile[k] << currentTime << ";\t" |
| 243 |
< |
<< entry_plug->Hmat[0][0] << "\t" |
| 244 |
< |
<< entry_plug->Hmat[1][0] << "\t" |
| 245 |
< |
<< entry_plug->Hmat[2][0] << ";\t" |
| 246 |
< |
|
| 247 |
< |
<< entry_plug->Hmat[0][1] << "\t" |
| 248 |
< |
<< entry_plug->Hmat[1][1] << "\t" |
| 249 |
< |
<< entry_plug->Hmat[2][1] << ";\t" |
| 250 |
< |
|
| 251 |
< |
<< entry_plug->Hmat[0][2] << "\t" |
| 252 |
< |
<< entry_plug->Hmat[1][2] << "\t" |
| 253 |
< |
<< entry_plug->Hmat[2][2] << ";"; |
| 254 |
< |
|
| 255 |
< |
//write out additional parameters, such as chi and eta |
| 256 |
< |
*outFile[k] << entry_plug->the_integrator->getAdditionalParameters() << endl; |
| 221 |
> |
os << " </FrameData>\n"; |
| 222 |
|
} |
| 258 |
– |
|
| 259 |
– |
for( i=0; i< entry_plug->n_mol; i++ ){ |
| 223 |
|
|
| 224 |
< |
integrableObjects = entry_plug->molecules[i].getIntegrableObjects(); |
| 262 |
< |
molName = (entry_plug->compStamps[entry_plug->molecules[i].getStampID()])->getID(); |
| 263 |
< |
|
| 264 |
< |
for( iter = integrableObjects.begin();iter != integrableObjects.end(); ++iter){ |
| 265 |
< |
sd = *iter; |
| 266 |
< |
sd->getPos(pos); |
| 267 |
< |
sd->getVel(vel); |
| 224 |
> |
void DumpWriter::writeFrame(std::ostream& os) { |
| 225 |
|
|
| 226 |
< |
sprintf( tempBuffer, |
| 227 |
< |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
| 228 |
< |
sd->getType(), |
| 272 |
< |
pos[0], |
| 273 |
< |
pos[1], |
| 274 |
< |
pos[2], |
| 275 |
< |
vel[0], |
| 276 |
< |
vel[1], |
| 277 |
< |
vel[2]); |
| 278 |
< |
strcpy( writeLine, tempBuffer ); |
| 226 |
> |
#ifdef IS_MPI |
| 227 |
> |
MPI_Status istatus; |
| 228 |
> |
#endif |
| 229 |
|
|
| 230 |
< |
if( sd->isDirectional() ){ |
| 230 |
> |
Molecule* mol; |
| 231 |
> |
StuntDouble* integrableObject; |
| 232 |
> |
SimInfo::MoleculeIterator mi; |
| 233 |
> |
Molecule::IntegrableObjectIterator ii; |
| 234 |
|
|
| 235 |
< |
sd->getQ( q ); |
| 236 |
< |
sd->getJ( ji ); |
| 235 |
> |
#ifndef IS_MPI |
| 236 |
> |
os << " <Snapshot>\n"; |
| 237 |
> |
|
| 238 |
> |
writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot()); |
| 239 |
|
|
| 240 |
< |
sprintf( tempBuffer, |
| 241 |
< |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
| 242 |
< |
q[0], |
| 243 |
< |
q[1], |
| 244 |
< |
q[2], |
| 245 |
< |
q[3], |
| 246 |
< |
ji[0], |
| 247 |
< |
ji[1], |
| 293 |
< |
ji[2]); |
| 294 |
< |
strcat( writeLine, tempBuffer ); |
| 240 |
> |
os << " <StuntDoubles>\n"; |
| 241 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
| 242 |
> |
|
| 243 |
> |
|
| 244 |
> |
for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
| 245 |
> |
integrableObject = mol->nextIntegrableObject(ii)) { |
| 246 |
> |
os << prepareDumpLine(integrableObject); |
| 247 |
> |
|
| 248 |
|
} |
| 249 |
< |
else |
| 250 |
< |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
| 249 |
> |
} |
| 250 |
> |
os << " </StuntDoubles>\n"; |
| 251 |
|
|
| 252 |
< |
for(k = 0; k < outFile.size(); k++) |
| 300 |
< |
*outFile[k] << writeLine; |
| 301 |
< |
} |
| 252 |
> |
os << " </Snapshot>\n"; |
| 253 |
|
|
| 254 |
< |
} |
| 254 |
> |
os.flush(); |
| 255 |
> |
#else |
| 256 |
> |
//every node prepares the dump lines for integrable objects belong to itself |
| 257 |
> |
std::string buffer; |
| 258 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
| 259 |
|
|
| 305 |
– |
#else // is_mpi |
| 260 |
|
|
| 261 |
< |
/* code to find maximum tag value */ |
| 262 |
< |
|
| 263 |
< |
int *tagub, flag, MAXTAG; |
| 264 |
< |
MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &tagub, &flag); |
| 265 |
< |
if (flag) { |
| 266 |
< |
MAXTAG = *tagub; |
| 267 |
< |
} else { |
| 314 |
< |
MAXTAG = 32767; |
| 315 |
< |
} |
| 261 |
> |
for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
| 262 |
> |
integrableObject = mol->nextIntegrableObject(ii)) { |
| 263 |
> |
buffer += prepareDumpLine(integrableObject); |
| 264 |
> |
} |
| 265 |
> |
} |
| 266 |
> |
|
| 267 |
> |
const int masterNode = 0; |
| 268 |
|
|
| 269 |
< |
int haveError; |
| 269 |
> |
if (worldRank == masterNode) { |
| 270 |
> |
os << " <Snapshot>\n"; |
| 271 |
> |
writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot()); |
| 272 |
> |
os << " <StuntDoubles>\n"; |
| 273 |
> |
|
| 274 |
> |
os << buffer; |
| 275 |
|
|
| 276 |
< |
MPI_Status istatus; |
| 277 |
< |
int nCurObj; |
| 278 |
< |
int *MolToProcMap = mpiSim->getMolToProcMap(); |
| 276 |
> |
int nProc; |
| 277 |
> |
MPI_Comm_size(MPI_COMM_WORLD, &nProc); |
| 278 |
> |
for (int i = 1; i < nProc; ++i) { |
| 279 |
|
|
| 280 |
< |
// write out header and node 0's coordinates |
| 280 |
> |
// receive the length of the string buffer that was |
| 281 |
> |
// prepared by processor i |
| 282 |
|
|
| 283 |
< |
if( worldRank == 0 ){ |
| 284 |
< |
|
| 285 |
< |
// Node 0 needs a list of the magic potatoes for each processor; |
| 286 |
< |
|
| 287 |
< |
nProc = mpiSim->getNProcessors(); |
| 288 |
< |
potatoes = new int[nProc]; |
| 289 |
< |
|
| 290 |
< |
//write out the comment lines |
| 291 |
< |
for (i = 0; i < nProc; i++) |
| 292 |
< |
potatoes[i] = 0; |
| 293 |
< |
|
| 294 |
< |
for(k = 0; k < outFile.size(); k++){ |
| 295 |
< |
*outFile[k] << nTotObjects << "\n"; |
| 296 |
< |
|
| 297 |
< |
*outFile[k] << currentTime << ";\t" |
| 298 |
< |
<< entry_plug->Hmat[0][0] << "\t" |
| 299 |
< |
<< entry_plug->Hmat[1][0] << "\t" |
| 300 |
< |
<< entry_plug->Hmat[2][0] << ";\t" |
| 343 |
< |
|
| 344 |
< |
<< entry_plug->Hmat[0][1] << "\t" |
| 345 |
< |
<< entry_plug->Hmat[1][1] << "\t" |
| 346 |
< |
<< entry_plug->Hmat[2][1] << ";\t" |
| 347 |
< |
|
| 348 |
< |
<< entry_plug->Hmat[0][2] << "\t" |
| 349 |
< |
<< entry_plug->Hmat[1][2] << "\t" |
| 350 |
< |
<< entry_plug->Hmat[2][2] << ";"; |
| 351 |
< |
|
| 352 |
< |
*outFile[k] << entry_plug->the_integrator->getAdditionalParameters() << endl; |
| 283 |
> |
int recvLength; |
| 284 |
> |
MPI_Recv(&recvLength, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &istatus); |
| 285 |
> |
char* recvBuffer = new char[recvLength]; |
| 286 |
> |
if (recvBuffer == NULL) { |
| 287 |
> |
} else { |
| 288 |
> |
MPI_Recv(recvBuffer, recvLength, MPI_CHAR, i, 0, MPI_COMM_WORLD, &istatus); |
| 289 |
> |
os << recvBuffer; |
| 290 |
> |
delete [] recvBuffer; |
| 291 |
> |
} |
| 292 |
> |
} |
| 293 |
> |
os << " </StuntDoubles>\n"; |
| 294 |
> |
|
| 295 |
> |
os << " </Snapshot>\n"; |
| 296 |
> |
os.flush(); |
| 297 |
> |
} else { |
| 298 |
> |
int sendBufferLength = buffer.size() + 1; |
| 299 |
> |
MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD); |
| 300 |
> |
MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD); |
| 301 |
|
} |
| 302 |
|
|
| 303 |
< |
currentIndex = 0; |
| 303 |
> |
#endif // is_mpi |
| 304 |
|
|
| 305 |
< |
for (i = 0 ; i < mpiSim->getNMolGlobal(); i++ ) { |
| 358 |
< |
|
| 359 |
< |
// Get the Node number which has this atom; |
| 360 |
< |
|
| 361 |
< |
which_node = MolToProcMap[i]; |
| 362 |
< |
|
| 363 |
< |
if (which_node != 0) { |
| 364 |
< |
|
| 365 |
< |
if (potatoes[which_node] + 1 >= MAXTAG) { |
| 366 |
< |
// The potato was going to exceed the maximum value, |
| 367 |
< |
// so wrap this processor potato back to 0: |
| 305 |
> |
} |
| 306 |
|
|
| 307 |
< |
potatoes[which_node] = 0; |
| 308 |
< |
MPI_Send(&potatoes[which_node], 1, MPI_INT, which_node, 0, MPI_COMM_WORLD); |
| 309 |
< |
|
| 310 |
< |
} |
| 307 |
> |
std::string DumpWriter::prepareDumpLine(StuntDouble* integrableObject) { |
| 308 |
> |
|
| 309 |
> |
int index = integrableObject->getGlobalIntegrableObjectIndex(); |
| 310 |
> |
std::string type("pv"); |
| 311 |
> |
std::string line; |
| 312 |
> |
char tempBuffer[4096]; |
| 313 |
|
|
| 314 |
< |
myPotato = potatoes[which_node]; |
| 314 |
> |
Vector3d pos; |
| 315 |
> |
Vector3d vel; |
| 316 |
> |
pos = integrableObject->getPos(); |
| 317 |
> |
vel = integrableObject->getVel(); |
| 318 |
> |
sprintf(tempBuffer, "%18.10g %18.10g %18.10g %13e %13e %13e", |
| 319 |
> |
pos[0], pos[1], pos[2], |
| 320 |
> |
vel[0], vel[1], vel[2]); |
| 321 |
> |
line += tempBuffer; |
| 322 |
|
|
| 323 |
< |
//recieve the number of integrableObject in current molecule |
| 324 |
< |
MPI_Recv(&nCurObj, 1, MPI_INT, which_node, |
| 325 |
< |
myPotato, MPI_COMM_WORLD, &istatus); |
| 326 |
< |
myPotato++; |
| 327 |
< |
|
| 328 |
< |
for(int l = 0; l < nCurObj; l++){ |
| 323 |
> |
if (integrableObject->isDirectional()) { |
| 324 |
> |
type += "qj"; |
| 325 |
> |
Quat4d q; |
| 326 |
> |
Vector3d ji; |
| 327 |
> |
q = integrableObject->getQ(); |
| 328 |
> |
ji = integrableObject->getJ(); |
| 329 |
> |
sprintf(tempBuffer, " %13e %13e %13e %13e %13e %13e %13e", |
| 330 |
> |
q[0], q[1], q[2], q[3], |
| 331 |
> |
ji[0], ji[1], ji[2]); |
| 332 |
> |
line += tempBuffer; |
| 333 |
> |
} |
| 334 |
|
|
| 335 |
< |
if (potatoes[which_node] + 2 >= MAXTAG) { |
| 336 |
< |
// The potato was going to exceed the maximum value, |
| 337 |
< |
// so wrap this processor potato back to 0: |
| 338 |
< |
|
| 339 |
< |
potatoes[which_node] = 0; |
| 340 |
< |
MPI_Send(&potatoes[which_node], 1, MPI_INT, which_node, 0, MPI_COMM_WORLD); |
| 389 |
< |
|
| 390 |
< |
} |
| 391 |
< |
|
| 392 |
< |
MPI_Recv(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, which_node, |
| 393 |
< |
myPotato, MPI_COMM_WORLD, &istatus); |
| 394 |
< |
|
| 395 |
< |
atomTypeString = MPIatomTypeString; |
| 396 |
< |
|
| 397 |
< |
myPotato++; |
| 398 |
< |
|
| 399 |
< |
MPI_Recv(atomData, 13, MPI_DOUBLE, which_node, myPotato, MPI_COMM_WORLD, &istatus); |
| 400 |
< |
myPotato++; |
| 401 |
< |
|
| 402 |
< |
MPI_Get_count(&istatus, MPI_DOUBLE, &msgLen); |
| 403 |
< |
|
| 404 |
< |
if(msgLen == 13) |
| 405 |
< |
isDirectional = 1; |
| 406 |
< |
else |
| 407 |
< |
isDirectional = 0; |
| 408 |
< |
|
| 409 |
< |
// If we've survived to here, format the line: |
| 410 |
< |
|
| 411 |
< |
if (!isDirectional) { |
| 412 |
< |
|
| 413 |
< |
sprintf( writeLine, |
| 414 |
< |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
| 415 |
< |
atomTypeString, |
| 416 |
< |
atomData[0], |
| 417 |
< |
atomData[1], |
| 418 |
< |
atomData[2], |
| 419 |
< |
atomData[3], |
| 420 |
< |
atomData[4], |
| 421 |
< |
atomData[5]); |
| 422 |
< |
|
| 423 |
< |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
| 424 |
< |
|
| 425 |
< |
} |
| 426 |
< |
else { |
| 427 |
< |
|
| 428 |
< |
sprintf( writeLine, |
| 429 |
< |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
| 430 |
< |
atomTypeString, |
| 431 |
< |
atomData[0], |
| 432 |
< |
atomData[1], |
| 433 |
< |
atomData[2], |
| 434 |
< |
atomData[3], |
| 435 |
< |
atomData[4], |
| 436 |
< |
atomData[5], |
| 437 |
< |
atomData[6], |
| 438 |
< |
atomData[7], |
| 439 |
< |
atomData[8], |
| 440 |
< |
atomData[9], |
| 441 |
< |
atomData[10], |
| 442 |
< |
atomData[11], |
| 443 |
< |
atomData[12]); |
| 444 |
< |
|
| 445 |
< |
} |
| 446 |
< |
|
| 447 |
< |
for(k = 0; k < outFile.size(); k++) |
| 448 |
< |
*outFile[k] << writeLine; |
| 449 |
< |
|
| 450 |
< |
}// end for(int l =0) |
| 451 |
< |
potatoes[which_node] = myPotato; |
| 452 |
< |
|
| 453 |
< |
} |
| 454 |
< |
else { |
| 455 |
< |
|
| 456 |
< |
haveError = 0; |
| 457 |
< |
|
| 458 |
< |
local_index = indexArray[currentIndex].first; |
| 459 |
< |
|
| 460 |
< |
integrableObjects = (entry_plug->molecules[local_index]).getIntegrableObjects(); |
| 461 |
< |
|
| 462 |
< |
for(iter= integrableObjects.begin(); iter != integrableObjects.end(); ++iter){ |
| 463 |
< |
sd = *iter; |
| 464 |
< |
atomTypeString = sd->getType(); |
| 465 |
< |
|
| 466 |
< |
sd->getPos(pos); |
| 467 |
< |
sd->getVel(vel); |
| 468 |
< |
|
| 469 |
< |
atomData[0] = pos[0]; |
| 470 |
< |
atomData[1] = pos[1]; |
| 471 |
< |
atomData[2] = pos[2]; |
| 472 |
< |
|
| 473 |
< |
atomData[3] = vel[0]; |
| 474 |
< |
atomData[4] = vel[1]; |
| 475 |
< |
atomData[5] = vel[2]; |
| 335 |
> |
if (needForceVector_) { |
| 336 |
> |
type += "ft"; |
| 337 |
> |
Vector3d frc; |
| 338 |
> |
Vector3d trq; |
| 339 |
> |
frc = integrableObject->getFrc(); |
| 340 |
> |
trq = integrableObject->getTrq(); |
| 341 |
|
|
| 342 |
< |
isDirectional = 0; |
| 342 |
> |
sprintf(tempBuffer, " %13e %13e %13e %13e %13e %13e", |
| 343 |
> |
frc[0], frc[1], frc[2], |
| 344 |
> |
trq[0], trq[1], trq[2]); |
| 345 |
> |
line += tempBuffer; |
| 346 |
> |
} |
| 347 |
> |
|
| 348 |
> |
sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str()); |
| 349 |
> |
return std::string(tempBuffer); |
| 350 |
> |
} |
| 351 |
|
|
| 352 |
< |
if( sd->isDirectional() ){ |
| 352 |
> |
void DumpWriter::writeDump() { |
| 353 |
> |
writeFrame(*dumpFile_); |
| 354 |
> |
} |
| 355 |
|
|
| 356 |
< |
isDirectional = 1; |
| 357 |
< |
|
| 483 |
< |
sd->getQ( q ); |
| 484 |
< |
sd->getJ( ji ); |
| 485 |
< |
|
| 486 |
< |
for (int j = 0; j < 6 ; j++) |
| 487 |
< |
atomData[j] = atomData[j]; |
| 488 |
< |
|
| 489 |
< |
atomData[6] = q[0]; |
| 490 |
< |
atomData[7] = q[1]; |
| 491 |
< |
atomData[8] = q[2]; |
| 492 |
< |
atomData[9] = q[3]; |
| 493 |
< |
|
| 494 |
< |
atomData[10] = ji[0]; |
| 495 |
< |
atomData[11] = ji[1]; |
| 496 |
< |
atomData[12] = ji[2]; |
| 497 |
< |
} |
| 498 |
< |
|
| 499 |
< |
// If we've survived to here, format the line: |
| 500 |
< |
|
| 501 |
< |
if (!isDirectional) { |
| 502 |
< |
|
| 503 |
< |
sprintf( writeLine, |
| 504 |
< |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
| 505 |
< |
atomTypeString, |
| 506 |
< |
atomData[0], |
| 507 |
< |
atomData[1], |
| 508 |
< |
atomData[2], |
| 509 |
< |
atomData[3], |
| 510 |
< |
atomData[4], |
| 511 |
< |
atomData[5]); |
| 512 |
< |
|
| 513 |
< |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
| 514 |
< |
|
| 515 |
< |
} |
| 516 |
< |
else { |
| 517 |
< |
|
| 518 |
< |
sprintf( writeLine, |
| 519 |
< |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
| 520 |
< |
atomTypeString, |
| 521 |
< |
atomData[0], |
| 522 |
< |
atomData[1], |
| 523 |
< |
atomData[2], |
| 524 |
< |
atomData[3], |
| 525 |
< |
atomData[4], |
| 526 |
< |
atomData[5], |
| 527 |
< |
atomData[6], |
| 528 |
< |
atomData[7], |
| 529 |
< |
atomData[8], |
| 530 |
< |
atomData[9], |
| 531 |
< |
atomData[10], |
| 532 |
< |
atomData[11], |
| 533 |
< |
atomData[12]); |
| 534 |
< |
|
| 535 |
< |
} |
| 536 |
< |
|
| 537 |
< |
for(k = 0; k < outFile.size(); k++) |
| 538 |
< |
*outFile[k] << writeLine; |
| 539 |
< |
|
| 540 |
< |
|
| 541 |
< |
}//end for(iter = integrableObject.begin()) |
| 542 |
< |
|
| 543 |
< |
currentIndex++; |
| 544 |
< |
} |
| 545 |
< |
|
| 546 |
< |
}//end for(i = 0; i < mpiSim->getNmol()) |
| 356 |
> |
void DumpWriter::writeEor() { |
| 357 |
> |
std::ostream* eorStream; |
| 358 |
|
|
| 359 |
< |
for(k = 0; k < outFile.size(); k++) |
| 360 |
< |
outFile[k]->flush(); |
| 361 |
< |
|
| 551 |
< |
sprintf( checkPointMsg, |
| 552 |
< |
"Sucessfully took a dump.\n"); |
| 553 |
< |
|
| 554 |
< |
MPIcheckPoint(); |
| 555 |
< |
|
| 556 |
< |
delete[] potatoes; |
| 557 |
< |
|
| 558 |
< |
} else { |
| 359 |
> |
#ifdef IS_MPI |
| 360 |
> |
if (worldRank == 0) { |
| 361 |
> |
#endif // is_mpi |
| 362 |
|
|
| 363 |
< |
// worldRank != 0, so I'm a remote node. |
| 363 |
> |
eorStream = createOStream(eorFilename_); |
| 364 |
|
|
| 365 |
< |
// Set my magic potato to 0: |
| 365 |
> |
#ifdef IS_MPI |
| 366 |
> |
} |
| 367 |
> |
#endif // is_mpi |
| 368 |
|
|
| 369 |
< |
myPotato = 0; |
| 565 |
< |
currentIndex = 0; |
| 566 |
< |
|
| 567 |
< |
for (i = 0 ; i < mpiSim->getNMolGlobal(); i++ ) { |
| 568 |
< |
|
| 569 |
< |
// Am I the node which has this integrableObject? |
| 570 |
< |
|
| 571 |
< |
if (MolToProcMap[i] == worldRank) { |
| 369 |
> |
writeFrame(*eorStream); |
| 370 |
|
|
| 371 |
+ |
#ifdef IS_MPI |
| 372 |
+ |
if (worldRank == 0) { |
| 373 |
+ |
#endif // is_mpi |
| 374 |
+ |
writeClosing(*eorStream); |
| 375 |
+ |
delete eorStream; |
| 376 |
+ |
#ifdef IS_MPI |
| 377 |
+ |
} |
| 378 |
+ |
#endif // is_mpi |
| 379 |
|
|
| 380 |
< |
if (myPotato + 1 >= MAXTAG) { |
| 575 |
< |
|
| 576 |
< |
// The potato was going to exceed the maximum value, |
| 577 |
< |
// so wrap this processor potato back to 0 (and block until |
| 578 |
< |
// node 0 says we can go: |
| 579 |
< |
|
| 580 |
< |
MPI_Recv(&myPotato, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &istatus); |
| 581 |
< |
|
| 582 |
< |
} |
| 380 |
> |
} |
| 381 |
|
|
| 584 |
– |
local_index = indexArray[currentIndex].first; |
| 585 |
– |
integrableObjects = entry_plug->molecules[local_index].getIntegrableObjects(); |
| 586 |
– |
|
| 587 |
– |
nCurObj = integrableObjects.size(); |
| 588 |
– |
|
| 589 |
– |
MPI_Send(&nCurObj, 1, MPI_INT, 0, |
| 590 |
– |
myPotato, MPI_COMM_WORLD); |
| 591 |
– |
myPotato++; |
| 382 |
|
|
| 383 |
< |
for( iter = integrableObjects.begin(); iter != integrableObjects.end(); iter++){ |
| 383 |
> |
void DumpWriter::writeDumpAndEor() { |
| 384 |
> |
std::vector<std::streambuf*> buffers; |
| 385 |
> |
std::ostream* eorStream; |
| 386 |
> |
#ifdef IS_MPI |
| 387 |
> |
if (worldRank == 0) { |
| 388 |
> |
#endif // is_mpi |
| 389 |
|
|
| 390 |
< |
if (myPotato + 2 >= MAXTAG) { |
| 596 |
< |
|
| 597 |
< |
// The potato was going to exceed the maximum value, |
| 598 |
< |
// so wrap this processor potato back to 0 (and block until |
| 599 |
< |
// node 0 says we can go: |
| 600 |
< |
|
| 601 |
< |
MPI_Recv(&myPotato, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &istatus); |
| 602 |
< |
|
| 603 |
< |
} |
| 604 |
< |
|
| 605 |
< |
sd = *iter; |
| 606 |
< |
|
| 607 |
< |
atomTypeString = sd->getType(); |
| 390 |
> |
buffers.push_back(dumpFile_->rdbuf()); |
| 391 |
|
|
| 392 |
< |
sd->getPos(pos); |
| 610 |
< |
sd->getVel(vel); |
| 392 |
> |
eorStream = createOStream(eorFilename_); |
| 393 |
|
|
| 394 |
< |
atomData[0] = pos[0]; |
| 395 |
< |
atomData[1] = pos[1]; |
| 396 |
< |
atomData[2] = pos[2]; |
| 615 |
< |
|
| 616 |
< |
atomData[3] = vel[0]; |
| 617 |
< |
atomData[4] = vel[1]; |
| 618 |
< |
atomData[5] = vel[2]; |
| 619 |
< |
|
| 620 |
< |
isDirectional = 0; |
| 621 |
< |
|
| 622 |
< |
if( sd->isDirectional() ){ |
| 623 |
< |
|
| 624 |
< |
isDirectional = 1; |
| 625 |
< |
|
| 626 |
< |
sd->getQ( q ); |
| 627 |
< |
sd->getJ( ji ); |
| 628 |
< |
|
| 629 |
< |
|
| 630 |
< |
atomData[6] = q[0]; |
| 631 |
< |
atomData[7] = q[1]; |
| 632 |
< |
atomData[8] = q[2]; |
| 633 |
< |
atomData[9] = q[3]; |
| 634 |
< |
|
| 635 |
< |
atomData[10] = ji[0]; |
| 636 |
< |
atomData[11] = ji[1]; |
| 637 |
< |
atomData[12] = ji[2]; |
| 638 |
< |
} |
| 639 |
< |
|
| 640 |
< |
|
| 641 |
< |
strncpy(MPIatomTypeString, atomTypeString, MINIBUFFERSIZE); |
| 642 |
< |
|
| 643 |
< |
// null terminate the string before sending (just in case): |
| 644 |
< |
MPIatomTypeString[MINIBUFFERSIZE-1] = '\0'; |
| 645 |
< |
|
| 646 |
< |
MPI_Send(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, 0, |
| 647 |
< |
myPotato, MPI_COMM_WORLD); |
| 648 |
< |
|
| 649 |
< |
myPotato++; |
| 650 |
< |
|
| 651 |
< |
if (isDirectional) { |
| 652 |
< |
|
| 653 |
< |
MPI_Send(atomData, 13, MPI_DOUBLE, 0, |
| 654 |
< |
myPotato, MPI_COMM_WORLD); |
| 655 |
< |
|
| 656 |
< |
} else { |
| 657 |
< |
|
| 658 |
< |
MPI_Send(atomData, 6, MPI_DOUBLE, 0, |
| 659 |
< |
myPotato, MPI_COMM_WORLD); |
| 660 |
< |
} |
| 661 |
< |
|
| 662 |
< |
myPotato++; |
| 663 |
< |
|
| 664 |
< |
} |
| 665 |
< |
|
| 666 |
< |
currentIndex++; |
| 667 |
< |
|
| 668 |
< |
} |
| 669 |
< |
|
| 670 |
< |
} |
| 671 |
< |
|
| 672 |
< |
sprintf( checkPointMsg, |
| 673 |
< |
"Sucessfully took a dump.\n"); |
| 674 |
< |
MPIcheckPoint(); |
| 675 |
< |
|
| 394 |
> |
buffers.push_back(eorStream->rdbuf()); |
| 395 |
> |
|
| 396 |
> |
#ifdef IS_MPI |
| 397 |
|
} |
| 398 |
+ |
#endif // is_mpi |
| 399 |
|
|
| 400 |
+ |
TeeBuf tbuf(buffers.begin(), buffers.end()); |
| 401 |
+ |
std::ostream os(&tbuf); |
| 402 |
|
|
| 403 |
< |
|
| 680 |
< |
#endif // is_mpi |
| 681 |
< |
} |
| 403 |
> |
writeFrame(os); |
| 404 |
|
|
| 405 |
|
#ifdef IS_MPI |
| 406 |
+ |
if (worldRank == 0) { |
| 407 |
+ |
#endif // is_mpi |
| 408 |
+ |
writeClosing(*eorStream); |
| 409 |
+ |
delete eorStream; |
| 410 |
+ |
#ifdef IS_MPI |
| 411 |
+ |
} |
| 412 |
+ |
#endif // is_mpi |
| 413 |
+ |
|
| 414 |
+ |
} |
| 415 |
|
|
| 416 |
< |
// a couple of functions to let us escape the write loop |
| 416 |
> |
std::ostream* DumpWriter::createOStream(const std::string& filename) { |
| 417 |
|
|
| 418 |
< |
void dWrite::DieDieDie( void ){ |
| 418 |
> |
std::ostream* newOStream; |
| 419 |
> |
#ifdef HAVE_LIBZ |
| 420 |
> |
if (needCompression_) { |
| 421 |
> |
newOStream = new ogzstream(filename.c_str()); |
| 422 |
> |
} else { |
| 423 |
> |
newOStream = new std::ofstream(filename.c_str()); |
| 424 |
> |
} |
| 425 |
> |
#else |
| 426 |
> |
newOStream = new std::ofstream(filename.c_str()); |
| 427 |
> |
#endif |
| 428 |
> |
//write out MetaData first |
| 429 |
> |
(*newOStream) << "<OpenMD version=1>" << std::endl; |
| 430 |
> |
(*newOStream) << " <MetaData>" << std::endl; |
| 431 |
> |
(*newOStream) << info_->getRawMetaData(); |
| 432 |
> |
(*newOStream) << " </MetaData>" << std::endl; |
| 433 |
> |
return newOStream; |
| 434 |
> |
} |
| 435 |
|
|
| 436 |
< |
MPI_Finalize(); |
| 690 |
< |
exit (0); |
| 691 |
< |
} |
| 436 |
> |
void DumpWriter::writeClosing(std::ostream& os) { |
| 437 |
|
|
| 438 |
< |
#endif //is_mpi |
| 438 |
> |
os << "</OpenMD>\n"; |
| 439 |
> |
os.flush(); |
| 440 |
> |
} |
| 441 |
> |
|
| 442 |
> |
}//end namespace OpenMD |