# | Line 1 | Line 1 | |
---|---|---|
1 | #include <iostream> | |
2 | < | #include <cmath> |
2 | > | #include <math.h> |
3 | ||
4 | #include <stdio.h> | |
5 | #include <stdlib.h> | |
# | Line 12 | Line 12 | |
12 | #include "simError.h" | |
13 | ||
14 | #ifdef IS_MPI | |
15 | + | #include <mpi.h> |
16 | #include "mpiSimulation.hpp" | |
17 | + | #define TAKE_THIS_TAG_CHAR 0 |
18 | + | #define TAKE_THIS_TAG_INT 1 |
19 | ||
20 | < | #define TAKE_THIS_TAG 0 |
20 | > | namespace initFile{ |
21 | > | void nodeZeroError( void ); |
22 | > | void anonymousNodeDie( void ); |
23 | > | } |
24 | > | |
25 | > | using namespace initFile; |
26 | > | |
27 | #endif // is_mpi | |
28 | ||
29 | < | InitializeFromFile :: InitializeFromFile( char *in_name ){ |
29 | > | InitializeFromFile::InitializeFromFile( char *in_name ){ |
30 | > | |
31 | #ifdef IS_MPI | |
32 | if (worldRank == 0) { | |
33 | #endif | |
# | Line 39 | Line 49 | InitializeFromFile :: InitializeFromFile( char *in_nam | |
49 | return; | |
50 | } | |
51 | ||
52 | < | InitializeFromFile :: ~InitializeFromFile( ){ |
52 | > | InitializeFromFile::~InitializeFromFile( ){ |
53 | #ifdef IS_MPI | |
54 | if (worldRank == 0) { | |
55 | #endif | |
# | Line 60 | Line 70 | InitializeFromFile :: ~InitializeFromFile( ){ | |
70 | } | |
71 | ||
72 | ||
73 | < | void InitializeFromFile :: read_xyz( SimInfo* the_entry_plug ){ |
73 | > | void InitializeFromFile :: readInit( SimInfo* the_simnfo ){ |
74 | ||
75 | < | int i; // loop counter |
75 | > | int i, j; |
76 | > | |
77 | > | #ifdef IS_MPI |
78 | > | int done, which_node, which_atom; // loop counter |
79 | > | #endif //is_mpi |
80 | ||
81 | const int BUFFERSIZE = 2000; // size of the read buffer | |
82 | int n_atoms; // the number of atoms | |
83 | char read_buffer[BUFFERSIZE]; //the line buffer for reading | |
70 | – | #ifdef IS_MPI |
71 | – | char send_buffer[BUFFERSIZE]; |
72 | – | #endif |
84 | ||
85 | char *eof_test; // ptr to see when we reach the end of the file | |
86 | char *parseErr; | |
76 | – | int procIndex; |
87 | ||
88 | < | entry_plug = the_entry_plug; |
88 | > | double currTime; |
89 | > | double boxMat[9]; |
90 | > | double theBoxMat3[3][3]; |
91 | ||
92 | + | simnfo = the_simnfo; |
93 | ||
94 | + | |
95 | #ifndef IS_MPI | |
96 | eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); | |
97 | if( eof_test == NULL ){ | |
# | Line 90 | Line 104 | void InitializeFromFile :: read_xyz( SimInfo* the_entr | |
104 | ||
105 | n_atoms = atoi( read_buffer ); | |
106 | ||
107 | < | Atom **atoms = entry_plug->atoms; |
94 | < | DirectionalAtom* dAtom; |
95 | < | |
96 | < | if( n_atoms != entry_plug->n_atoms ){ |
107 | > | if( n_atoms != simnfo->n_atoms ){ |
108 | sprintf( painCave.errMsg, | |
109 | "Initialize from File error. %s n_atoms, %d, " | |
110 | "does not match the BASS file's n_atoms, %d.\n", | |
111 | < | c_in_name, n_atoms, entry_plug->n_atoms ); |
111 | > | c_in_name, n_atoms, simnfo->n_atoms ); |
112 | painCave.isFatal = 1; | |
113 | simError(); | |
114 | } | |
115 | ||
116 | < | //read and toss the comment line |
116 | > | //read the box mat from the comment line |
117 | ||
118 | eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); | |
119 | if(eof_test == NULL){ | |
# | Line 112 | Line 123 | void InitializeFromFile :: read_xyz( SimInfo* the_entr | |
123 | simError(); | |
124 | } | |
125 | ||
126 | + | parseErr = parseBoxLine( read_buffer, boxMat, currTime ); |
127 | + | if( parseErr != NULL ){ |
128 | + | strcpy( painCave.errMsg, parseErr ); |
129 | + | painCave.isFatal = 1; |
130 | + | simError(); |
131 | + | } |
132 | + | |
133 | + | for(i=0;i<3;i++) |
134 | + | for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
135 | + | |
136 | + | simnfo->setBoxM( theBoxMat3 ); |
137 | + | simnfo->setTime( currTime ); |
138 | + | |
139 | + | |
140 | for( i=0; i < n_atoms; i++){ | |
141 | ||
142 | eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); | |
# | Line 131 | Line 156 | void InitializeFromFile :: read_xyz( SimInfo* the_entr | |
156 | strcpy( painCave.errMsg, parseErr ); | |
157 | painCave.isFatal = 1; | |
158 | simError(); | |
159 | < | } |
159 | > | } |
160 | } | |
161 | ||
162 | ||
163 | // MPI Section of code.......... | |
164 | #else //IS_MPI | |
165 | ||
166 | < | int masterIndex; |
167 | < | int nodeAtomsStart; |
143 | < | int nodeAtomsEnd; |
144 | < | int mpiErr; |
145 | < | int sendError; |
166 | > | // first thing first, suspend fatalities. |
167 | > | painCave.isEventLoop = 1; |
168 | ||
169 | < | MPI_Status istatus[MPI_STATUS_SIZE]; |
169 | > | int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone |
170 | > | int haveError; |
171 | > | |
172 | > | MPI_Status istatus; |
173 | > | int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
174 | ||
175 | + | |
176 | + | haveError = 0; |
177 | if (worldRank == 0) { | |
178 | + | |
179 | eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); | |
180 | if( eof_test == NULL ){ | |
181 | sprintf( painCave.errMsg, | |
182 | < | "Error reading 1st line of %d \n ",c_in_name); |
183 | < | painCave.isFatal = 1; |
182 | > | "Error reading 1st line of %s \n ",c_in_name); |
183 | > | haveError = 1; |
184 | simError(); | |
185 | } | |
186 | ||
187 | n_atoms = atoi( read_buffer ); | |
188 | ||
160 | – | Atom **atoms = entry_plug->atoms; |
161 | – | DirectionalAtom* dAtom; |
162 | – | |
189 | // Check to see that the number of atoms in the intial configuration file is the | |
190 | // same as declared in simBass. | |
191 | ||
# | Line 167 | Line 193 | void InitializeFromFile :: read_xyz( SimInfo* the_entr | |
193 | sprintf( painCave.errMsg, | |
194 | "Initialize from File error. %s n_atoms, %d, " | |
195 | "does not match the BASS file's n_atoms, %d.\n", | |
196 | < | c_in_name, n_atoms, entry_plug->n_atoms ); |
197 | < | painCave.isFatal = 1; |
196 | > | c_in_name, n_atoms, simnfo->n_atoms ); |
197 | > | haveError= 1; |
198 | simError(); | |
199 | } | |
200 | ||
201 | < | //read and toss the comment line |
201 | > | //read the boxMat from the comment line |
202 | ||
203 | eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); | |
204 | if(eof_test == NULL){ | |
205 | sprintf( painCave.errMsg, | |
206 | "error in reading commment in %s\n", c_in_name); | |
207 | < | painCave.isFatal = 1; |
207 | > | haveError = 1; |
208 | simError(); | |
209 | } | |
184 | – | |
185 | – | // Read Proc 0 share of the xyz file... |
186 | – | masterIndex = 0; |
187 | – | for( i=0; i <= mpiSim->getMyAtomEnd(); i++){ |
210 | ||
211 | + | parseErr = parseBoxLine( read_buffer, boxMat, currTime ); |
212 | + | if( parseErr != NULL ){ |
213 | + | strcpy( painCave.errMsg, parseErr ); |
214 | + | haveError = 1; |
215 | + | simError(); |
216 | + | } |
217 | + | |
218 | + | MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
219 | + | MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
220 | + | |
221 | + | if(haveError) nodeZeroError(); |
222 | + | |
223 | + | for (i=0 ; i < mpiSim->getTotAtoms(); i++) { |
224 | + | |
225 | eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); | |
226 | if(eof_test == NULL){ | |
227 | sprintf(painCave.errMsg, | |
# | Line 193 | Line 229 | void InitializeFromFile :: read_xyz( SimInfo* the_entr | |
229 | "natoms = %d; index = %d\n" | |
230 | "error reading the line from the file.\n", | |
231 | c_in_name, n_atoms, i ); | |
232 | < | painCave.isFatal = 1; |
232 | > | haveError= 1; |
233 | simError(); | |
234 | } | |
235 | ||
236 | < | parseErr = parseDumpLine( read_buffer, i ); |
201 | < | if( parseErr != NULL ){ |
202 | < | strcpy( painCave.errMsg, parseErr ); |
203 | < | painCave.isFatal = 1; |
204 | < | simError(); |
205 | < | } |
206 | < | masterIndex++; |
207 | < | } |
208 | < | } |
236 | > | if(haveError) nodeZeroError(); |
237 | ||
238 | < | sprintf(checkPointMsg, |
239 | < | "Node 0 has successfully read positions from input file."); |
240 | < | MPIcheckPoint(); |
241 | < | |
242 | < | for (procIndex = 1; procIndex < mpiSim->getNumberProcessors(); |
243 | < | procIndex++){ |
244 | < | if (worldRank == 0) { |
245 | < | |
246 | < | mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD, |
247 | < | istatus); |
248 | < | |
221 | < | mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD, |
222 | < | istatus); |
223 | < | // Make sure where node 0 is reading from, matches where the receiving node |
224 | < | // expects it to be. |
225 | < | |
226 | < | if (masterIndex != nodeAtomsStart){ |
227 | < | sendError = 1; |
228 | < | mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD); |
229 | < | sprintf(painCave.errMsg, |
230 | < | "Initialize from file error: atoms start index (%d) for " |
231 | < | "node %d not equal to master index (%d)",nodeAtomsStart,procIndex,masterIndex ); |
232 | < | painCave.isFatal = 1; |
233 | < | simError(); |
234 | < | } |
235 | < | sendError = 0; |
236 | < | mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD); |
238 | > | // Get the Node number which wants this atom: |
239 | > | which_node = AtomToProcMap[i]; |
240 | > | if (which_node == 0) { |
241 | > | parseErr = parseDumpLine( read_buffer, i ); |
242 | > | if( parseErr != NULL ){ |
243 | > | strcpy( painCave.errMsg, parseErr ); |
244 | > | haveError = 1; |
245 | > | simError(); |
246 | > | } |
247 | > | if(haveError) nodeZeroError(); |
248 | > | } |
249 | ||
250 | < | for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){ |
251 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
252 | < | if(eof_test == NULL){ |
253 | < | |
254 | < | sprintf(read_buffer,"ERROR"); |
255 | < | mpiErr = MPI_Send(read_buffer,BUFFERSIZE,MPI_CHAR,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD); |
256 | < | |
257 | < | sprintf(painCave.errMsg, |
258 | < | "error in reading file %s\n" |
259 | < | "natoms = %d; index = %d\n" |
260 | < | "error reading the line from the file.\n", |
249 | < | c_in_name, n_atoms, i ); |
250 | < | painCave.isFatal = 1; |
251 | < | simError(); |
252 | < | } |
250 | > | else { |
251 | > | |
252 | > | myStatus = 1; |
253 | > | MPI_Send(&myStatus, 1, MPI_INT, which_node, |
254 | > | TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
255 | > | MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
256 | > | TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
257 | > | MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
258 | > | MPI_COMM_WORLD); |
259 | > | MPI_Recv(&myStatus, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
260 | > | MPI_COMM_WORLD, &istatus); |
261 | ||
262 | < | mpiErr = MPI_Send(read_buffer,BUFFERSIZE,MPI_CHAR,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD); |
255 | < | mpiErr = MPI_Recv(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD, |
256 | < | istatus); |
257 | < | if (sendError) MPIcheckPoint(); |
258 | < | |
259 | < | masterIndex++; |
262 | > | if(!myStatus) nodeZeroError(); |
263 | } | |
264 | } | |
265 | + | myStatus = -1; |
266 | + | for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
267 | + | MPI_Send( &myStatus, 1, MPI_INT, j, |
268 | + | TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
269 | + | } |
270 | + | |
271 | + | } else { |
272 | + | |
273 | + | MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
274 | + | MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
275 | ||
276 | + | done = 0; |
277 | + | while (!done) { |
278 | ||
279 | < | else if(worldRank == procIndex){ |
280 | < | nodeAtomsStart = mpiSim->getMyAtomStart(); |
266 | < | nodeAtomsEnd = mpiSim->getMyAtomEnd(); |
267 | < | mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD); |
268 | < | mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD); |
279 | > | MPI_Recv(&myStatus, 1, MPI_INT, 0, |
280 | > | TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
281 | ||
282 | < | mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD, |
283 | < | istatus); |
284 | < | if (sendError) MPIcheckPoint(); |
273 | < | |
274 | < | for ( i = 0; i < entry_plug->n_atoms; i++){ |
275 | < | |
276 | < | mpiErr = MPI_Recv(&read_buffer,BUFFERSIZE,MPI_CHAR,0,TAKE_THIS_TAG,MPI_COMM_WORLD, |
277 | < | istatus); |
278 | < | |
279 | < | if(!strcmp(read_buffer, "ERROR")) MPIcheckPoint(); |
280 | < | |
281 | < | parseErr = parseDumpLine( read_buffer, i ); |
282 | < | if( parseErr != NULL ){ |
283 | < | sendError = 1; |
284 | < | mpiErr = MPI_Send(&sendError,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD); |
282 | > | if(!myStatus) anonymousNodeDie(); |
283 | > | |
284 | > | if(myStatus < 0) break; |
285 | ||
286 | < | |
287 | < | strcpy( painCave.errMsg, parseErr ); |
288 | < | painCave.isFatal = 1; |
289 | < | simError(); |
290 | < | } |
291 | < | sendError = 0; |
292 | < | mpiErr = MPI_Send(&sendError,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD); |
286 | > | MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
287 | > | TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
288 | > | MPI_Recv(&which_atom, 1, MPI_INT, 0, |
289 | > | TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
290 | > | |
291 | > | myStatus = 1; |
292 | > | parseErr = parseDumpLine( read_buffer, which_atom ); |
293 | > | if( parseErr != NULL ){ |
294 | > | strcpy( painCave.errMsg, parseErr ); |
295 | > | myStatus = 0;; |
296 | > | simError(); |
297 | } | |
298 | + | |
299 | + | MPI_Send( &myStatus, 1, MPI_INT, 0, |
300 | + | TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
301 | + | |
302 | } | |
295 | – | sprintf(checkPointMsg,"Node %d received initial configuration.",procIndex); |
296 | – | MPIcheckPoint(); |
303 | } | |
304 | + | |
305 | + | // last thing last, enable fatalities. |
306 | + | painCave.isEventLoop = 0; |
307 | ||
308 | + | for(i=0;i<3;i++) |
309 | + | for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
310 | + | |
311 | + | simnfo->setBoxM( theBoxMat3 ); |
312 | + | simnfo->setTime( currTime ); |
313 | + | |
314 | + | |
315 | #endif | |
316 | } | |
317 | ||
318 | + | char* InitializeFromFile::parseDumpLine(char* readLine, int globalIndex){ |
319 | ||
303 | – | char* InitializeFromFile::parseDumpLine(char* readLine, int atomIndex){ |
304 | – | |
320 | char *foo; // the pointer to the current string token | |
321 | ||
322 | < | double rx, ry, rz; // position place holders |
323 | < | double vx, vy, vz; // velocity placeholders |
322 | > | double pos[3]; // position place holders |
323 | > | double vel[3]; // velocity placeholders |
324 | double q[4]; // the quaternions | |
325 | double jx, jy, jz; // angular velocity placeholders; | |
326 | double qSqr, qLength; // needed to normalize the quaternion vector. | |
327 | ||
328 | < | Atom **atoms = entry_plug->atoms; |
328 | > | Atom **atoms = simnfo->atoms; |
329 | DirectionalAtom* dAtom; | |
330 | ||
331 | < | int n_atoms; |
331 | > | int n_atoms, atomIndex; |
332 | ||
333 | #ifdef IS_MPI | |
334 | + | int j; |
335 | + | |
336 | n_atoms = mpiSim->getTotAtoms(); | |
337 | + | atomIndex=-1; |
338 | + | for (j=0; j < mpiSim->getMyNlocal(); j++) { |
339 | + | if (atoms[j]->getGlobalIndex() == globalIndex) atomIndex = j; |
340 | + | } |
341 | + | if (atomIndex == -1) { |
342 | + | sprintf( painCave.errMsg, |
343 | + | "Initialize from file error. Atom at index %d " |
344 | + | "in file %s does not exist on processor %d .\n", |
345 | + | globalIndex, c_in_name, mpiSim->getMyNode() ); |
346 | + | return strdup( painCave.errMsg ); |
347 | + | } |
348 | #else | |
349 | < | n_atoms = entry_plug->n_atoms; |
349 | > | n_atoms = simnfo->n_atoms; |
350 | > | atomIndex = globalIndex; |
351 | #endif // is_mpi | |
352 | ||
324 | – | |
353 | // set the string tokenizer | |
354 | ||
355 | foo = strtok(readLine, " ,;\t"); | |
# | Line 347 | Line 375 | char* InitializeFromFile::parseDumpLine(char* readLine | |
375 | c_in_name, n_atoms, atomIndex ); | |
376 | return strdup( painCave.errMsg ); | |
377 | } | |
378 | < | rx = atof( foo ); |
378 | > | pos[0] = atof( foo ); |
379 | ||
380 | foo = strtok(NULL, " ,;\t"); | |
381 | if(foo == NULL){ | |
# | Line 357 | Line 385 | char* InitializeFromFile::parseDumpLine(char* readLine | |
385 | c_in_name, n_atoms, atomIndex ); | |
386 | return strdup( painCave.errMsg ); | |
387 | } | |
388 | < | ry = atof( foo ); |
388 | > | pos[1] = atof( foo ); |
389 | ||
390 | foo = strtok(NULL, " ,;\t"); | |
391 | if(foo == NULL){ | |
# | Line 367 | Line 395 | char* InitializeFromFile::parseDumpLine(char* readLine | |
395 | c_in_name, n_atoms, atomIndex ); | |
396 | return strdup( painCave.errMsg ); | |
397 | } | |
398 | < | rz = atof( foo ); |
398 | > | pos[2] = atof( foo ); |
399 | ||
400 | ||
401 | // get the velocities | |
# | Line 380 | Line 408 | char* InitializeFromFile::parseDumpLine(char* readLine | |
408 | c_in_name, n_atoms, atomIndex ); | |
409 | return strdup( painCave.errMsg ); | |
410 | } | |
411 | < | vx = atof( foo ); |
411 | > | vel[0] = atof( foo ); |
412 | ||
413 | foo = strtok(NULL, " ,;\t"); | |
414 | if(foo == NULL){ | |
# | Line 390 | Line 418 | char* InitializeFromFile::parseDumpLine(char* readLine | |
418 | c_in_name, n_atoms, atomIndex ); | |
419 | return strdup( painCave.errMsg ); | |
420 | } | |
421 | < | vy = atof( foo ); |
421 | > | vel[1] = atof( foo ); |
422 | ||
423 | foo = strtok(NULL, " ,;\t"); | |
424 | if(foo == NULL){ | |
# | Line 400 | Line 428 | char* InitializeFromFile::parseDumpLine(char* readLine | |
428 | c_in_name, n_atoms, atomIndex ); | |
429 | return strdup( painCave.errMsg ); | |
430 | } | |
431 | < | vz = atof( foo ); |
431 | > | vel[2] = atof( foo ); |
432 | ||
433 | ||
434 | // get the quaternions | |
# | Line 502 | Line 530 | char* InitializeFromFile::parseDumpLine(char* readLine | |
530 | ||
531 | // add the positions and velocities to the atom | |
532 | ||
533 | < | atoms[atomIndex]->setX( rx ); |
534 | < | atoms[atomIndex]->setY( ry ); |
535 | < | atoms[atomIndex]->setZ( rz ); |
536 | < | |
537 | < | atoms[atomIndex]->set_vx( vx ); |
538 | < | atoms[atomIndex]->set_vy( vy ); |
539 | < | atoms[atomIndex]->set_vz( vz ); |
533 | > | atoms[atomIndex]->setPos( pos ); |
534 | > | atoms[atomIndex]->setVel( vel ); |
535 | > | |
536 | > | return NULL; |
537 | > | } |
538 | > | |
539 | > | |
540 | > | char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9], |
541 | > | double &time ){ |
542 | > | |
543 | > | char *foo; // the pointer to the current string token |
544 | > | |
545 | > | // set the string tokenizer |
546 | > | |
547 | > | foo = strtok(readLine, " ,;\t"); |
548 | > | // set the timeToken. |
549 | > | |
550 | > | if(foo == NULL){ |
551 | > | sprintf( painCave.errMsg, |
552 | > | "error in reading Time from %s\n", |
553 | > | c_in_name ); |
554 | > | return strdup( painCave.errMsg ); |
555 | > | } |
556 | > | time = atof( foo ); |
557 | > | |
558 | > | // get the Hx vector |
559 | > | |
560 | > | foo = strtok(NULL, " ,;\t"); |
561 | > | if(foo == NULL){ |
562 | > | sprintf( painCave.errMsg, |
563 | > | "error in reading Hx[0] from %s\n", |
564 | > | c_in_name ); |
565 | > | return strdup( painCave.errMsg ); |
566 | > | } |
567 | > | boxMat[0] = atof( foo ); |
568 | > | |
569 | > | foo = strtok(NULL, " ,;\t"); |
570 | > | if(foo == NULL){ |
571 | > | sprintf( painCave.errMsg, |
572 | > | "error in reading Hx[1] from %s\n", |
573 | > | c_in_name ); |
574 | > | return strdup( painCave.errMsg ); |
575 | > | } |
576 | > | boxMat[1] = atof( foo ); |
577 | > | |
578 | > | foo = strtok(NULL, " ,;\t"); |
579 | > | if(foo == NULL){ |
580 | > | sprintf( painCave.errMsg, |
581 | > | "error in reading Hx[2] from %s\n", |
582 | > | c_in_name ); |
583 | > | return strdup( painCave.errMsg ); |
584 | > | } |
585 | > | boxMat[2] = atof( foo ); |
586 | ||
587 | + | // get the Hy vector |
588 | + | |
589 | + | foo = strtok(NULL, " ,;\t"); |
590 | + | if(foo == NULL){ |
591 | + | sprintf( painCave.errMsg, |
592 | + | "error in reading Hy[0] from %s\n", |
593 | + | c_in_name ); |
594 | + | return strdup( painCave.errMsg ); |
595 | + | } |
596 | + | boxMat[3] = atof( foo ); |
597 | + | |
598 | + | foo = strtok(NULL, " ,;\t"); |
599 | + | if(foo == NULL){ |
600 | + | sprintf( painCave.errMsg, |
601 | + | "error in reading Hy[1] from %s\n", |
602 | + | c_in_name ); |
603 | + | return strdup( painCave.errMsg ); |
604 | + | } |
605 | + | boxMat[4] = atof( foo ); |
606 | + | |
607 | + | foo = strtok(NULL, " ,;\t"); |
608 | + | if(foo == NULL){ |
609 | + | sprintf( painCave.errMsg, |
610 | + | "error in reading Hy[2] from %s\n", |
611 | + | c_in_name ); |
612 | + | return strdup( painCave.errMsg ); |
613 | + | } |
614 | + | boxMat[5] = atof( foo ); |
615 | + | |
616 | + | // get the Hz vector |
617 | + | |
618 | + | foo = strtok(NULL, " ,;\t"); |
619 | + | if(foo == NULL){ |
620 | + | sprintf( painCave.errMsg, |
621 | + | "error in reading Hz[0] from %s\n", |
622 | + | c_in_name ); |
623 | + | return strdup( painCave.errMsg ); |
624 | + | } |
625 | + | boxMat[6] = atof( foo ); |
626 | + | |
627 | + | foo = strtok(NULL, " ,;\t"); |
628 | + | if(foo == NULL){ |
629 | + | sprintf( painCave.errMsg, |
630 | + | "error in reading Hz[1] from %s\n", |
631 | + | c_in_name ); |
632 | + | return strdup( painCave.errMsg ); |
633 | + | } |
634 | + | boxMat[7] = atof( foo ); |
635 | + | |
636 | + | foo = strtok(NULL, " ,;\t"); |
637 | + | if(foo == NULL){ |
638 | + | sprintf( painCave.errMsg, |
639 | + | "error in reading Hz[2] from %s\n", |
640 | + | c_in_name ); |
641 | + | return strdup( painCave.errMsg ); |
642 | + | } |
643 | + | boxMat[8] = atof( foo ); |
644 | + | |
645 | return NULL; | |
646 | } | |
647 | + | |
648 | + | |
649 | + | #ifdef IS_MPI |
650 | + | |
651 | + | // a couple of functions to let us escape the read loop |
652 | + | |
653 | + | void initFile::nodeZeroError( void ){ |
654 | + | int j, myStatus; |
655 | + | |
656 | + | myStatus = 0; |
657 | + | for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
658 | + | MPI_Send( &myStatus, 1, MPI_INT, j, |
659 | + | TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
660 | + | } |
661 | + | |
662 | + | |
663 | + | MPI_Finalize(); |
664 | + | exit (0); |
665 | + | |
666 | + | } |
667 | + | |
668 | + | void initFile::anonymousNodeDie( void ){ |
669 | + | |
670 | + | MPI_Finalize(); |
671 | + | exit (0); |
672 | + | } |
673 | + | |
674 | + | #endif //is_mpi |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |