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