| 1 |
+ |
#define _LARGEFILE_SOURCE64 |
| 2 |
|
#define _FILE_OFFSET_BITS 64 |
| 3 |
|
|
| 4 |
+ |
#include <sys/types.h> |
| 5 |
+ |
#include <sys/stat.h> |
| 6 |
+ |
|
| 7 |
|
#include <iostream> |
| 8 |
< |
#include <cmath> |
| 8 |
> |
#include <math.h> |
| 9 |
|
|
| 10 |
|
#include <stdio.h> |
| 11 |
|
#include <stdlib.h> |
| 12 |
|
#include <string.h> |
| 9 |
– |
#include <unistd.h> |
| 10 |
– |
#include <sys/types.h> |
| 11 |
– |
#include <sys/stat.h> |
| 13 |
|
|
| 14 |
+ |
|
| 15 |
|
#include "ReadWrite.hpp" |
| 16 |
|
#include "simError.h" |
| 17 |
|
|
| 20 |
|
#include "mpiSimulation.hpp" |
| 21 |
|
#define TAKE_THIS_TAG_CHAR 0 |
| 22 |
|
#define TAKE_THIS_TAG_INT 1 |
| 23 |
+ |
#endif // is_mpi |
| 24 |
|
|
| 22 |
– |
namespace dumpRead{ |
| 23 |
– |
void nodeZeroError( void ); |
| 24 |
– |
void anonymousNodeDie( void ); |
| 25 |
– |
} |
| 25 |
|
|
| 26 |
< |
using namespace dumpRead; |
| 26 |
> |
DumpReader :: DumpReader(const char *in_name ){ |
| 27 |
|
|
| 28 |
< |
#endif // is_mpi |
| 28 |
> |
isScanned = false; |
| 29 |
|
|
| 31 |
– |
DumpReader :: DumpReader( char *in_name ){ |
| 30 |
|
#ifdef IS_MPI |
| 31 |
|
if (worldRank == 0) { |
| 32 |
|
#endif |
| 33 |
|
|
| 34 |
< |
c_in_file = fopen(in_name, "r"); |
| 35 |
< |
if(c_in_file == NULL){ |
| 34 |
> |
inFile = fopen(in_name, "r"); |
| 35 |
> |
if(inFile == NULL){ |
| 36 |
|
sprintf(painCave.errMsg, |
| 37 |
|
"Cannot open file: %s\n", in_name); |
| 38 |
|
painCave.isFatal = 1; |
| 39 |
|
simError(); |
| 40 |
|
} |
| 41 |
|
|
| 42 |
< |
strcpy( c_in_name, in_name); |
| 42 |
> |
inFileName = in_name; |
| 43 |
|
#ifdef IS_MPI |
| 44 |
|
} |
| 45 |
|
strcpy( checkPointMsg, "Dump file opened for reading successfully." ); |
| 52 |
|
#ifdef IS_MPI |
| 53 |
|
if (worldRank == 0) { |
| 54 |
|
#endif |
| 55 |
+ |
vector<fpos_t*>::iterator i; |
| 56 |
+ |
|
| 57 |
|
int error; |
| 58 |
< |
error = fclose( c_in_file ); |
| 58 |
> |
error = fclose( inFile ); |
| 59 |
|
if( error ){ |
| 60 |
|
sprintf( painCave.errMsg, |
| 61 |
< |
"Error closing %s\n", c_in_name ); |
| 61 |
> |
"Error closing %s\n", inFileName.c_str()); |
| 62 |
|
simError(); |
| 63 |
|
} |
| 64 |
+ |
|
| 65 |
+ |
for(i = framePos.begin(); i != framePos.end(); ++i) |
| 66 |
+ |
delete *i; |
| 67 |
+ |
framePos.clear(); |
| 68 |
+ |
|
| 69 |
|
#ifdef IS_MPI |
| 70 |
|
} |
| 71 |
|
strcpy( checkPointMsg, "Dump file closed successfully." ); |
| 75 |
|
return; |
| 76 |
|
} |
| 77 |
|
|
| 78 |
+ |
int DumpReader::getNframes( void ){ |
| 79 |
|
|
| 80 |
+ |
if( !isScanned ) |
| 81 |
+ |
scanFile(); |
| 82 |
+ |
return framePos.size(); |
| 83 |
+ |
} |
| 84 |
|
|
| 85 |
< |
void DumpReader :: getFrame( SimInfo* the_simnfo, int whichFrame){ |
| 85 |
> |
void DumpReader::scanFile( void ){ |
| 86 |
|
|
| 87 |
< |
int i, j, done, which_node, which_atom; // loop counter |
| 87 |
> |
int i, j; |
| 88 |
> |
int lineNum = 0; |
| 89 |
> |
char readBuffer[2000]; |
| 90 |
> |
fpos_t *currPos; |
| 91 |
|
|
| 79 |
– |
const int BUFFERSIZE = 2000; // size of the read buffer |
| 80 |
– |
int n_atoms; // the number of atoms |
| 81 |
– |
char read_buffer[BUFFERSIZE]; //the line buffer for reading |
| 92 |
|
#ifdef IS_MPI |
| 93 |
< |
char send_buffer[BUFFERSIZE]; |
| 94 |
< |
#endif |
| 93 |
> |
if( worldRank == 0 ){ |
| 94 |
> |
#endif // is_mpi |
| 95 |
> |
|
| 96 |
> |
rewind( inFile ); |
| 97 |
> |
|
| 98 |
> |
currPos = new fpos_t; |
| 99 |
> |
fgetpos( inFile, currPos ); |
| 100 |
> |
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
| 101 |
> |
lineNum++; |
| 102 |
> |
if( feof( inFile ) ){ |
| 103 |
> |
sprintf( painCave.errMsg, |
| 104 |
> |
"File \"%s\" ended unexpectedly at line %d\n", |
| 105 |
> |
inFileName.c_str(), |
| 106 |
> |
lineNum ); |
| 107 |
> |
painCave.isFatal = 1; |
| 108 |
> |
simError(); |
| 109 |
> |
} |
| 110 |
|
|
| 111 |
< |
char *eof_test; // ptr to see when we reach the end of the file |
| 112 |
< |
char *parseErr; |
| 113 |
< |
int procIndex; |
| 89 |
< |
double boxMat[9]; |
| 90 |
< |
double theBoxMat3[3][3]; |
| 111 |
> |
while( !feof( inFile ) ){ |
| 112 |
> |
|
| 113 |
> |
framePos.push_back(currPos); |
| 114 |
|
|
| 115 |
+ |
i = atoi(readBuffer); |
| 116 |
+ |
|
| 117 |
+ |
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
| 118 |
+ |
lineNum++; |
| 119 |
+ |
if( feof( inFile ) ){ |
| 120 |
+ |
sprintf( painCave.errMsg, |
| 121 |
+ |
"File \"%s\" ended unexpectedly at line %d\n", |
| 122 |
+ |
inFileName.c_str(), |
| 123 |
+ |
lineNum ); |
| 124 |
+ |
painCave.isFatal = 1; |
| 125 |
+ |
simError(); |
| 126 |
+ |
} |
| 127 |
+ |
|
| 128 |
+ |
for(j=0; j<i; j++){ |
| 129 |
+ |
|
| 130 |
+ |
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
| 131 |
+ |
lineNum++; |
| 132 |
+ |
if( feof( inFile ) ){ |
| 133 |
+ |
sprintf( painCave.errMsg, |
| 134 |
+ |
"File \"%s\" ended unexpectedly at line %d," |
| 135 |
+ |
" with atom %d\n", |
| 136 |
+ |
inFileName.c_str(), |
| 137 |
+ |
lineNum, |
| 138 |
+ |
j ); |
| 139 |
+ |
painCave.isFatal = 1; |
| 140 |
+ |
simError(); |
| 141 |
+ |
} |
| 142 |
+ |
|
| 143 |
+ |
} |
| 144 |
+ |
|
| 145 |
+ |
currPos = new fpos_t; |
| 146 |
+ |
fgetpos( inFile, currPos ); |
| 147 |
+ |
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
| 148 |
+ |
lineNum++; |
| 149 |
+ |
} |
| 150 |
+ |
|
| 151 |
+ |
delete currPos; |
| 152 |
+ |
rewind( inFile ); |
| 153 |
+ |
|
| 154 |
+ |
isScanned = true; |
| 155 |
+ |
|
| 156 |
+ |
#ifdef IS_MPI |
| 157 |
+ |
} |
| 158 |
+ |
strcpy( checkPointMsg, "Successfully scanned DumpFile\n" ); |
| 159 |
+ |
MPIcheckPoint(); |
| 160 |
+ |
#endif // is_mpi |
| 161 |
+ |
} |
| 162 |
+ |
|
| 163 |
+ |
void DumpReader :: readFrame( SimInfo* the_simnfo, int whichFrame){ |
| 164 |
+ |
|
| 165 |
|
simnfo = the_simnfo; |
| 166 |
|
|
| 167 |
+ |
this->readSet( whichFrame ); |
| 168 |
+ |
} |
| 169 |
+ |
|
| 170 |
+ |
|
| 171 |
+ |
|
| 172 |
+ |
void DumpReader :: readSet( int whichFrame ){ |
| 173 |
+ |
|
| 174 |
+ |
int i; |
| 175 |
+ |
unsigned int j; |
| 176 |
+ |
|
| 177 |
+ |
#ifdef IS_MPI |
| 178 |
+ |
int done, which_node, which_atom; // loop counter |
| 179 |
+ |
#endif //is_mpi |
| 180 |
+ |
|
| 181 |
+ |
const int BUFFERSIZE = 2000; // size of the read buffer |
| 182 |
+ |
int nTotObjs; // the number of atoms |
| 183 |
+ |
char read_buffer[BUFFERSIZE]; //the line buffer for reading |
| 184 |
+ |
|
| 185 |
+ |
char *eof_test; // ptr to see when we reach the end of the file |
| 186 |
+ |
char *parseErr; |
| 187 |
+ |
|
| 188 |
+ |
vector<StuntDouble*> integrableObjects; |
| 189 |
+ |
|
| 190 |
+ |
|
| 191 |
|
#ifndef IS_MPI |
| 192 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 192 |
> |
|
| 193 |
> |
fsetpos(inFile, framePos[whichFrame]); |
| 194 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 195 |
|
if( eof_test == NULL ){ |
| 196 |
|
sprintf( painCave.errMsg, |
| 197 |
|
"DumpReader error: error reading 1st line of \"%s\"\n", |
| 198 |
< |
c_in_name ); |
| 198 |
> |
inFileName.c_str() ); |
| 199 |
|
painCave.isFatal = 1; |
| 200 |
|
simError(); |
| 201 |
|
} |
| 103 |
– |
|
| 104 |
– |
n_atoms = atoi( read_buffer ); |
| 202 |
|
|
| 203 |
< |
Atom **atoms = simnfo->atoms; |
| 107 |
< |
DirectionalAtom* dAtom; |
| 203 |
> |
nTotObjs = atoi( read_buffer ); |
| 204 |
|
|
| 205 |
< |
if( n_atoms != simnfo->n_atoms ){ |
| 205 |
> |
if( nTotObjs != simnfo->getTotIntegrableObjects() ){ |
| 206 |
|
sprintf( painCave.errMsg, |
| 207 |
|
"DumpReader error. %s n_atoms, %d, " |
| 208 |
|
"does not match the BASS file's n_atoms, %d.\n", |
| 209 |
< |
c_in_name, n_atoms, simnfo->n_atoms ); |
| 209 |
> |
inFileName.c_str(), nTotObjs, simnfo->getTotIntegrableObjects()); |
| 210 |
|
painCave.isFatal = 1; |
| 211 |
|
simError(); |
| 212 |
|
} |
| 213 |
< |
|
| 214 |
< |
//read the box mat from the comment line |
| 215 |
< |
|
| 216 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 213 |
> |
|
| 214 |
> |
//read the box mat from the comment line |
| 215 |
> |
|
| 216 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 217 |
|
if(eof_test == NULL){ |
| 218 |
|
sprintf( painCave.errMsg, |
| 219 |
< |
"error in reading commment in %s\n", c_in_name); |
| 219 |
> |
"error in reading commment in %s\n", inFileName.c_str()); |
| 220 |
|
painCave.isFatal = 1; |
| 221 |
|
simError(); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
< |
parseErr = parseCommentLine( read_buffer, time, boxMat ); |
| 224 |
> |
parseErr = parseCommentLine( read_buffer, simnfo); |
| 225 |
|
if( parseErr != NULL ){ |
| 226 |
|
strcpy( painCave.errMsg, parseErr ); |
| 227 |
|
painCave.isFatal = 1; |
| 228 |
|
simError(); |
| 229 |
|
} |
| 230 |
|
|
| 231 |
< |
simnfo->setTime( time ); |
| 136 |
< |
|
| 137 |
< |
for(i=0;i<3;i++) |
| 138 |
< |
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
| 139 |
< |
|
| 231 |
> |
//parse dump lines |
| 232 |
|
|
| 233 |
< |
simnfo->setBoxM( theBoxMat3 ); |
| 142 |
< |
|
| 233 |
> |
for( i=0; i < simnfo->n_mol; i++){ |
| 234 |
|
|
| 235 |
< |
for( i=0; i < n_atoms; i++){ |
| 145 |
< |
|
| 146 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 147 |
< |
if(eof_test == NULL){ |
| 148 |
< |
sprintf(painCave.errMsg, |
| 149 |
< |
"error in reading file %s\n" |
| 150 |
< |
"natoms = %d; index = %d\n" |
| 151 |
< |
"error reading the line from the file.\n", |
| 152 |
< |
c_in_name, n_atoms, i ); |
| 153 |
< |
painCave.isFatal = 1; |
| 154 |
< |
simError(); |
| 155 |
< |
} |
| 235 |
> |
integrableObjects = (simnfo->molecules[i]).getIntegrableObjects(); |
| 236 |
|
|
| 237 |
< |
|
| 238 |
< |
parseErr = parseDumpLine( read_buffer, i ); |
| 239 |
< |
if( parseErr != NULL ){ |
| 240 |
< |
strcpy( painCave.errMsg, parseErr ); |
| 241 |
< |
painCave.isFatal = 1; |
| 242 |
< |
simError(); |
| 237 |
> |
for(j = 0; j < integrableObjects.size(); j++){ |
| 238 |
> |
|
| 239 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 240 |
> |
if(eof_test == NULL){ |
| 241 |
> |
sprintf(painCave.errMsg, |
| 242 |
> |
"error in reading file %s\n" |
| 243 |
> |
"natoms = %d; index = %d\n" |
| 244 |
> |
"error reading the line from the file.\n", |
| 245 |
> |
inFileName.c_str(), nTotObjs, i ); |
| 246 |
> |
painCave.isFatal = 1; |
| 247 |
> |
simError(); |
| 248 |
> |
} |
| 249 |
> |
|
| 250 |
> |
parseErr = parseDumpLine( read_buffer, integrableObjects[j]); |
| 251 |
> |
if( parseErr != NULL ){ |
| 252 |
> |
strcpy( painCave.errMsg, parseErr ); |
| 253 |
> |
painCave.isFatal = 1; |
| 254 |
> |
simError(); |
| 255 |
> |
} |
| 256 |
|
} |
| 257 |
|
} |
| 258 |
|
|
| 166 |
– |
|
| 259 |
|
// MPI Section of code.......... |
| 260 |
|
#else //IS_MPI |
| 261 |
|
|
| 264 |
|
|
| 265 |
|
int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone |
| 266 |
|
int haveError; |
| 267 |
< |
|
| 267 |
> |
|
| 268 |
|
MPI_Status istatus; |
| 269 |
< |
int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
| 269 |
> |
int *MolToProcMap = mpiSim->getMolToProcMap(); |
| 270 |
> |
int localIndex; |
| 271 |
> |
int nCurObj; |
| 272 |
> |
int nitems; |
| 273 |
|
|
| 274 |
< |
|
| 274 |
> |
nTotObjs = simnfo->getTotIntegrableObjects(); |
| 275 |
|
haveError = 0; |
| 276 |
|
if (worldRank == 0) { |
| 277 |
+ |
fsetpos(inFile, framePos[whichFrame]); |
| 278 |
|
|
| 279 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 279 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 280 |
|
if( eof_test == NULL ){ |
| 281 |
|
sprintf( painCave.errMsg, |
| 282 |
< |
"Error reading 1st line of %d \n ",c_in_name); |
| 282 |
> |
"Error reading 1st line of %s \n ",inFileName.c_str()); |
| 283 |
|
haveError = 1; |
| 284 |
|
simError(); |
| 285 |
|
} |
| 286 |
< |
|
| 287 |
< |
n_atoms = atoi( read_buffer ); |
| 288 |
< |
|
| 289 |
< |
Atom **atoms = simnfo->atoms; |
| 194 |
< |
DirectionalAtom* dAtom; |
| 195 |
< |
|
| 196 |
< |
// Check to see that the number of atoms in the intial configuration file is the |
| 286 |
> |
|
| 287 |
> |
nitems = atoi( read_buffer ); |
| 288 |
> |
|
| 289 |
> |
// Check to see that the number of integrable objects in the intial configuration file is the |
| 290 |
|
// same as declared in simBass. |
| 291 |
< |
|
| 292 |
< |
if( n_atoms != mpiSim->getTotAtoms() ){ |
| 291 |
> |
|
| 292 |
> |
if( nTotObjs != nitems){ |
| 293 |
|
sprintf( painCave.errMsg, |
| 294 |
< |
"Initialize from File error. %s n_atoms, %d, " |
| 294 |
> |
"DumpReadererror. %s n_atoms, %d, " |
| 295 |
|
"does not match the BASS file's n_atoms, %d.\n", |
| 296 |
< |
c_in_name, n_atoms, simnfo->n_atoms ); |
| 296 |
> |
inFileName.c_str(), nTotObjs, simnfo->getTotIntegrableObjects()); |
| 297 |
|
haveError= 1; |
| 298 |
|
simError(); |
| 299 |
|
} |
| 300 |
< |
|
| 301 |
< |
//read the time and boxMat from the comment line |
| 302 |
< |
|
| 303 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 300 |
> |
|
| 301 |
> |
//read the boxMat from the comment line |
| 302 |
> |
|
| 303 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 304 |
|
if(eof_test == NULL){ |
| 305 |
|
sprintf( painCave.errMsg, |
| 306 |
< |
"error in reading commment in %s\n", c_in_name); |
| 306 |
> |
"error in reading commment in %s\n", inFileName.c_str()); |
| 307 |
|
haveError = 1; |
| 308 |
|
simError(); |
| 309 |
|
} |
| 310 |
< |
|
| 311 |
< |
parseErr = parseCommentLine( read_buffer, time, boxMat ); |
| 310 |
> |
|
| 311 |
> |
//Every single processor will parse the comment line by itself |
| 312 |
> |
//By using this way, we might lose some efficiency, but if we want to add |
| 313 |
> |
//more parameters into comment line, we only need to modify function |
| 314 |
> |
//parseCommentLine |
| 315 |
> |
|
| 316 |
> |
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
| 317 |
> |
|
| 318 |
> |
parseErr = parseCommentLine( read_buffer, simnfo); |
| 319 |
> |
|
| 320 |
|
if( parseErr != NULL ){ |
| 321 |
|
strcpy( painCave.errMsg, parseErr ); |
| 322 |
|
haveError = 1; |
| 323 |
|
simError(); |
| 324 |
|
} |
| 325 |
|
|
| 326 |
< |
MPI_Bcast(time, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
| 327 |
< |
|
| 328 |
< |
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
| 329 |
< |
|
| 330 |
< |
if(haveError) nodeZeroError(); |
| 331 |
< |
|
| 332 |
< |
for (i=0 ; i < mpiSim->getTotAtoms(); i++) { |
| 333 |
< |
|
| 334 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 335 |
< |
if(eof_test == NULL){ |
| 336 |
< |
sprintf(painCave.errMsg, |
| 236 |
< |
"error in reading file %s\n" |
| 237 |
< |
"natoms = %d; index = %d\n" |
| 238 |
< |
"error reading the line from the file.\n", |
| 239 |
< |
c_in_name, n_atoms, i ); |
| 240 |
< |
haveError= 1; |
| 241 |
< |
simError(); |
| 326 |
> |
for (i=0 ; i < mpiSim->getNMolGlobal(); i++) { |
| 327 |
> |
which_node = MolToProcMap[i]; |
| 328 |
> |
if(which_node == 0){ |
| 329 |
> |
//molecules belong to master node |
| 330 |
> |
|
| 331 |
> |
localIndex = mpiSim->getGlobalToLocalMol(i); |
| 332 |
> |
|
| 333 |
> |
if(localIndex == -1) { |
| 334 |
> |
strcpy(painCave.errMsg, "Molecule not found on node 0!"); |
| 335 |
> |
haveError = 1; |
| 336 |
> |
simError(); |
| 337 |
|
} |
| 243 |
– |
|
| 244 |
– |
if(haveError) nodeZeroError(); |
| 338 |
|
|
| 339 |
< |
// Get the Node number which wants this atom: |
| 340 |
< |
which_node = AtomToProcMap[i]; |
| 341 |
< |
if (which_node == 0) { |
| 342 |
< |
parseErr = parseDumpLine( read_buffer, i ); |
| 343 |
< |
if( parseErr != NULL ){ |
| 344 |
< |
strcpy( painCave.errMsg, parseErr ); |
| 345 |
< |
haveError = 1; |
| 346 |
< |
simError(); |
| 347 |
< |
} |
| 348 |
< |
if(haveError) nodeZeroError(); |
| 349 |
< |
} |
| 339 |
> |
integrableObjects = (simnfo->molecules[localIndex]).getIntegrableObjects(); |
| 340 |
> |
for(j=0; j < integrableObjects.size(); j++){ |
| 341 |
> |
|
| 342 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 343 |
> |
if(eof_test == NULL){ |
| 344 |
> |
sprintf(painCave.errMsg, |
| 345 |
> |
"error in reading file %s\n" |
| 346 |
> |
"natoms = %d; index = %d\n" |
| 347 |
> |
"error reading the line from the file.\n", |
| 348 |
> |
inFileName.c_str(), nTotObjs, i ); |
| 349 |
> |
haveError= 1; |
| 350 |
> |
simError(); |
| 351 |
> |
} |
| 352 |
> |
|
| 353 |
> |
if(haveError) nodeZeroError(); |
| 354 |
> |
|
| 355 |
> |
parseDumpLine(read_buffer, integrableObjects[j]); |
| 356 |
> |
|
| 357 |
> |
} |
| 358 |
> |
|
| 359 |
> |
|
| 360 |
> |
} |
| 361 |
> |
else{ |
| 362 |
> |
//molecule belongs to slave nodes |
| 363 |
> |
|
| 364 |
> |
MPI_Recv(&nCurObj, 1, MPI_INT, which_node, |
| 365 |
> |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 366 |
|
|
| 367 |
< |
else { |
| 368 |
< |
|
| 369 |
< |
myStatus = 1; |
| 370 |
< |
MPI_Send(&myStatus, 1, MPI_INT, which_node, |
| 371 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 372 |
< |
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
| 373 |
< |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
| 374 |
< |
MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
| 375 |
< |
MPI_COMM_WORLD); |
| 376 |
< |
MPI_Recv(&myStatus, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
| 377 |
< |
MPI_COMM_WORLD, &istatus); |
| 378 |
< |
|
| 379 |
< |
if(!myStatus) nodeZeroError(); |
| 367 |
> |
for(j=0; j < nCurObj; j++){ |
| 368 |
> |
|
| 369 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 370 |
> |
if(eof_test == NULL){ |
| 371 |
> |
sprintf(painCave.errMsg, |
| 372 |
> |
"error in reading file %s\n" |
| 373 |
> |
"natoms = %d; index = %d\n" |
| 374 |
> |
"error reading the line from the file.\n", |
| 375 |
> |
inFileName.c_str(), nTotObjs, i ); |
| 376 |
> |
haveError= 1; |
| 377 |
> |
simError(); |
| 378 |
> |
} |
| 379 |
> |
|
| 380 |
> |
if(haveError) nodeZeroError(); |
| 381 |
> |
|
| 382 |
> |
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
| 383 |
> |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
| 384 |
> |
|
| 385 |
> |
} |
| 386 |
> |
|
| 387 |
|
} |
| 388 |
+ |
|
| 389 |
|
} |
| 273 |
– |
myStatus = -1; |
| 274 |
– |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
| 275 |
– |
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 276 |
– |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 277 |
– |
} |
| 390 |
|
|
| 391 |
< |
} else { |
| 392 |
< |
|
| 393 |
< |
MPI_Bcast(time, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
| 394 |
< |
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
| 391 |
> |
} |
| 392 |
> |
else{ |
| 393 |
> |
//actions taken at slave nodes |
| 394 |
> |
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
| 395 |
|
|
| 396 |
< |
done = 0; |
| 285 |
< |
while (!done) { |
| 396 |
> |
parseErr = parseCommentLine( read_buffer, simnfo); |
| 397 |
|
|
| 398 |
< |
MPI_Recv(&myStatus, 1, MPI_INT, 0, |
| 399 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 398 |
> |
if( parseErr != NULL ){ |
| 399 |
> |
strcpy( painCave.errMsg, parseErr ); |
| 400 |
> |
haveError = 1; |
| 401 |
> |
simError(); |
| 402 |
> |
} |
| 403 |
> |
|
| 404 |
> |
for (i=0 ; i < mpiSim->getNMolGlobal(); i++) { |
| 405 |
> |
which_node = MolToProcMap[i]; |
| 406 |
|
|
| 407 |
< |
if(!myStatus) anonymousNodeDie(); |
| 407 |
> |
if(which_node == worldRank){ |
| 408 |
> |
//molecule with global index i belongs to this processor |
| 409 |
|
|
| 410 |
< |
if(myStatus < 0) break; |
| 410 |
> |
localIndex = mpiSim->getGlobalToLocalMol(i); |
| 411 |
|
|
| 412 |
< |
MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
| 413 |
< |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
| 414 |
< |
MPI_Recv(&which_atom, 1, MPI_INT, 0, |
| 415 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 416 |
< |
|
| 417 |
< |
myStatus = 1; |
| 418 |
< |
parseErr = parseDumpLine( read_buffer, which_atom ); |
| 419 |
< |
if( parseErr != NULL ){ |
| 420 |
< |
strcpy( painCave.errMsg, parseErr ); |
| 421 |
< |
myStatus = 0;; |
| 422 |
< |
simError(); |
| 412 |
> |
if(localIndex == -1) { |
| 413 |
> |
sprintf(painCave.errMsg, "Molecule not found on node %d\n", worldRank); |
| 414 |
> |
haveError = 1; |
| 415 |
> |
simError(); |
| 416 |
> |
} |
| 417 |
> |
|
| 418 |
> |
integrableObjects = (simnfo->molecules[localIndex]).getIntegrableObjects(); |
| 419 |
> |
|
| 420 |
> |
nCurObj = integrableObjects.size(); |
| 421 |
> |
|
| 422 |
> |
MPI_Send(&nCurObj, 1, MPI_INT, 0, |
| 423 |
> |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 424 |
> |
|
| 425 |
> |
for(j = 0; j < integrableObjects.size(); j++){ |
| 426 |
> |
|
| 427 |
> |
MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
| 428 |
> |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
| 429 |
> |
|
| 430 |
> |
parseErr = parseDumpLine(read_buffer, integrableObjects[j]); |
| 431 |
> |
|
| 432 |
> |
if( parseErr != NULL ){ |
| 433 |
> |
strcpy( painCave.errMsg, parseErr ); |
| 434 |
> |
simError(); |
| 435 |
> |
} |
| 436 |
> |
|
| 437 |
> |
} |
| 438 |
> |
|
| 439 |
|
} |
| 306 |
– |
|
| 307 |
– |
MPI_Send( &myStatus, 1, MPI_INT, 0, |
| 308 |
– |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 440 |
|
|
| 441 |
|
} |
| 442 |
+ |
|
| 443 |
|
} |
| 312 |
– |
|
| 313 |
– |
// last thing last, enable fatalities. |
| 314 |
– |
painCave.isEventLoop = 0; |
| 444 |
|
|
| 316 |
– |
simnfo->setTime( time ); |
| 317 |
– |
|
| 318 |
– |
for(i=0;i<3;i++) |
| 319 |
– |
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
| 320 |
– |
|
| 321 |
– |
simnfo->setBoxM( theBoxMat3 ); |
| 322 |
– |
|
| 323 |
– |
|
| 445 |
|
#endif |
| 446 |
|
} |
| 447 |
|
|
| 448 |
< |
char* DumpReader::parseDumpLine(char* readLine, int globalIndex){ |
| 448 |
> |
char* DumpReader::parseDumpLine(char* readLine, StuntDouble* sd){ |
| 449 |
|
|
| 450 |
< |
char *foo; // the pointer to the current string token |
| 451 |
< |
|
| 452 |
< |
double rx, ry, rz; // position place holders |
| 453 |
< |
double vx, vy, vz; // velocity placeholders |
| 450 |
> |
char *foo; // the pointer to the current string token |
| 451 |
> |
|
| 452 |
> |
double pos[3]; // position place holders |
| 453 |
> |
double vel[3]; // velocity placeholders |
| 454 |
|
double q[4]; // the quaternions |
| 455 |
< |
double jx, jy, jz; // angular velocity placeholders; |
| 455 |
> |
double ji[3]; // angular velocity placeholders; |
| 456 |
|
double qSqr, qLength; // needed to normalize the quaternion vector. |
| 336 |
– |
|
| 337 |
– |
Atom **atoms = simnfo->atoms; |
| 338 |
– |
DirectionalAtom* dAtom; |
| 339 |
– |
|
| 340 |
– |
int j, n_atoms, atomIndex; |
| 457 |
|
|
| 342 |
– |
#ifdef IS_MPI |
| 343 |
– |
n_atoms = mpiSim->getTotAtoms(); |
| 344 |
– |
atomIndex=-1; |
| 345 |
– |
for (j=0; j < mpiSim->getMyNlocal(); j++) { |
| 346 |
– |
if (atoms[j]->getGlobalIndex() == globalIndex) atomIndex = j; |
| 347 |
– |
} |
| 348 |
– |
if (atomIndex == -1) { |
| 349 |
– |
sprintf( painCave.errMsg, |
| 350 |
– |
"Initialize from file error. Atom at index %d " |
| 351 |
– |
"in file %s does not exist on processor %d .\n", |
| 352 |
– |
globalIndex, c_in_name, mpiSim->getMyNode() ); |
| 353 |
– |
return strdup( painCave.errMsg ); |
| 354 |
– |
} |
| 355 |
– |
#else |
| 356 |
– |
n_atoms = simnfo->n_atoms; |
| 357 |
– |
atomIndex = globalIndex; |
| 358 |
– |
#endif // is_mpi |
| 458 |
|
|
| 459 |
|
// set the string tokenizer |
| 460 |
< |
|
| 460 |
> |
|
| 461 |
|
foo = strtok(readLine, " ,;\t"); |
| 462 |
< |
|
| 462 |
> |
|
| 463 |
|
// check the atom name to the current atom |
| 464 |
< |
|
| 465 |
< |
if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
| 464 |
> |
|
| 465 |
> |
if( strcmp( foo, sd->getType() ) ){ |
| 466 |
|
sprintf( painCave.errMsg, |
| 467 |
< |
"Initialize from file error. Atom %s at index %d " |
| 369 |
< |
"in file %s does not" |
| 467 |
> |
"DumpReader error. Does not" |
| 468 |
|
" match the BASS atom %s.\n", |
| 469 |
< |
foo, atomIndex, c_in_name, atoms[atomIndex]->getType() ); |
| 469 |
> |
sd->getType() ); |
| 470 |
|
return strdup( painCave.errMsg ); |
| 471 |
|
} |
| 472 |
< |
|
| 472 |
> |
|
| 473 |
|
// get the positions |
| 474 |
|
|
| 475 |
|
foo = strtok(NULL, " ,;\t"); |
| 476 |
|
if(foo == NULL){ |
| 477 |
|
sprintf( painCave.errMsg, |
| 478 |
< |
"error in reading postition x from %s\n" |
| 479 |
< |
"natoms = %d, index = %d\n", |
| 382 |
< |
c_in_name, n_atoms, atomIndex ); |
| 478 |
> |
"error in reading postition x from %s\n", |
| 479 |
> |
inFileName.c_str()); |
| 480 |
|
return strdup( painCave.errMsg ); |
| 481 |
|
} |
| 482 |
< |
rx = atof( foo ); |
| 483 |
< |
|
| 482 |
> |
pos[0] = atof( foo ); |
| 483 |
> |
|
| 484 |
|
foo = strtok(NULL, " ,;\t"); |
| 485 |
|
if(foo == NULL){ |
| 486 |
|
sprintf( painCave.errMsg, |
| 487 |
< |
"error in reading postition y from %s\n" |
| 488 |
< |
"natoms = %d, index = %d\n", |
| 392 |
< |
c_in_name, n_atoms, atomIndex ); |
| 487 |
> |
"error in reading postition y from %s\n", |
| 488 |
> |
inFileName.c_str()); |
| 489 |
|
return strdup( painCave.errMsg ); |
| 490 |
|
} |
| 491 |
< |
ry = atof( foo ); |
| 492 |
< |
|
| 491 |
> |
pos[1] = atof( foo ); |
| 492 |
> |
|
| 493 |
|
foo = strtok(NULL, " ,;\t"); |
| 494 |
|
if(foo == NULL){ |
| 495 |
|
sprintf( painCave.errMsg, |
| 496 |
< |
"error in reading postition z from %s\n" |
| 497 |
< |
"natoms = %d, index = %d\n", |
| 402 |
< |
c_in_name, n_atoms, atomIndex ); |
| 496 |
> |
"error in reading postition z from %s\n", |
| 497 |
> |
inFileName.c_str()); |
| 498 |
|
return strdup( painCave.errMsg ); |
| 499 |
|
} |
| 500 |
< |
rz = atof( foo ); |
| 500 |
> |
pos[2] = atof( foo ); |
| 501 |
|
|
| 502 |
|
|
| 503 |
|
// get the velocities |
| 505 |
|
foo = strtok(NULL, " ,;\t"); |
| 506 |
|
if(foo == NULL){ |
| 507 |
|
sprintf( painCave.errMsg, |
| 508 |
< |
"error in reading velocity x from %s\n" |
| 509 |
< |
"natoms = %d, index = %d\n", |
| 415 |
< |
c_in_name, n_atoms, atomIndex ); |
| 508 |
> |
"error in reading velocity x from %s\n", |
| 509 |
> |
inFileName.c_str() ); |
| 510 |
|
return strdup( painCave.errMsg ); |
| 511 |
|
} |
| 512 |
< |
vx = atof( foo ); |
| 513 |
< |
|
| 512 |
> |
vel[0] = atof( foo ); |
| 513 |
> |
|
| 514 |
|
foo = strtok(NULL, " ,;\t"); |
| 515 |
|
if(foo == NULL){ |
| 516 |
|
sprintf( painCave.errMsg, |
| 517 |
< |
"error in reading velocity y from %s\n" |
| 518 |
< |
"natoms = %d, index = %d\n", |
| 425 |
< |
c_in_name, n_atoms, atomIndex ); |
| 517 |
> |
"error in reading velocity x from %s\n", |
| 518 |
> |
inFileName.c_str() ); |
| 519 |
|
return strdup( painCave.errMsg ); |
| 520 |
|
} |
| 521 |
< |
vy = atof( foo ); |
| 522 |
< |
|
| 521 |
> |
vel[1] = atof( foo ); |
| 522 |
> |
|
| 523 |
|
foo = strtok(NULL, " ,;\t"); |
| 524 |
|
if(foo == NULL){ |
| 525 |
|
sprintf( painCave.errMsg, |
| 526 |
< |
"error in reading velocity z from %s\n" |
| 527 |
< |
"natoms = %d, index = %d\n", |
| 435 |
< |
c_in_name, n_atoms, atomIndex ); |
| 526 |
> |
"error in reading velocity x from %s\n", |
| 527 |
> |
inFileName.c_str() ); |
| 528 |
|
return strdup( painCave.errMsg ); |
| 529 |
|
} |
| 530 |
< |
vz = atof( foo ); |
| 531 |
< |
|
| 532 |
< |
|
| 530 |
> |
vel[2] = atof( foo ); |
| 531 |
> |
|
| 532 |
> |
|
| 533 |
> |
// add the positions and velocities to the atom |
| 534 |
> |
|
| 535 |
> |
sd->setPos( pos ); |
| 536 |
> |
sd->setVel( vel ); |
| 537 |
> |
|
| 538 |
> |
if (!sd->isDirectional()) |
| 539 |
> |
return NULL; |
| 540 |
> |
|
| 541 |
|
// get the quaternions |
| 542 |
< |
|
| 543 |
< |
if( atoms[atomIndex]->isDirectional() ){ |
| 544 |
< |
|
| 542 |
> |
|
| 543 |
> |
if( sd->isDirectional() ){ |
| 544 |
> |
|
| 545 |
|
foo = strtok(NULL, " ,;\t"); |
| 546 |
|
if(foo == NULL){ |
| 547 |
< |
sprintf(painCave.errMsg, |
| 548 |
< |
"error in reading quaternion 0 from %s\n" |
| 549 |
< |
"natoms = %d, index = %d\n", |
| 450 |
< |
c_in_name, n_atoms, atomIndex ); |
| 547 |
> |
sprintf( painCave.errMsg, |
| 548 |
> |
"error in reading velocity x from %s\n", |
| 549 |
> |
inFileName.c_str() ); |
| 550 |
|
return strdup( painCave.errMsg ); |
| 551 |
|
} |
| 552 |
|
q[0] = atof( foo ); |
| 553 |
< |
|
| 553 |
> |
|
| 554 |
|
foo = strtok(NULL, " ,;\t"); |
| 555 |
|
if(foo == NULL){ |
| 556 |
|
sprintf( painCave.errMsg, |
| 557 |
< |
"error in reading quaternion 1 from %s\n" |
| 558 |
< |
"natoms = %d, index = %d\n", |
| 460 |
< |
c_in_name, n_atoms, atomIndex ); |
| 557 |
> |
"error in reading velocity x from %s\n", |
| 558 |
> |
inFileName.c_str() ); |
| 559 |
|
return strdup( painCave.errMsg ); |
| 560 |
|
} |
| 561 |
|
q[1] = atof( foo ); |
| 562 |
< |
|
| 562 |
> |
|
| 563 |
|
foo = strtok(NULL, " ,;\t"); |
| 564 |
|
if(foo == NULL){ |
| 565 |
|
sprintf( painCave.errMsg, |
| 566 |
< |
"error in reading quaternion 2 from %s\n" |
| 567 |
< |
"natoms = %d, index = %d\n", |
| 470 |
< |
c_in_name, n_atoms, atomIndex ); |
| 566 |
> |
"error in reading velocity x from %s\n", |
| 567 |
> |
inFileName.c_str() ); |
| 568 |
|
return strdup( painCave.errMsg ); |
| 569 |
|
} |
| 570 |
|
q[2] = atof( foo ); |
| 571 |
< |
|
| 571 |
> |
|
| 572 |
|
foo = strtok(NULL, " ,;\t"); |
| 573 |
|
if(foo == NULL){ |
| 574 |
|
sprintf( painCave.errMsg, |
| 575 |
< |
"error in reading quaternion 3 from %s\n" |
| 576 |
< |
"natoms = %d, index = %d\n", |
| 480 |
< |
c_in_name, n_atoms, atomIndex ); |
| 575 |
> |
"error in reading velocity x from %s\n", |
| 576 |
> |
inFileName.c_str() ); |
| 577 |
|
return strdup( painCave.errMsg ); |
| 578 |
|
} |
| 579 |
|
q[3] = atof( foo ); |
| 580 |
< |
|
| 580 |
> |
|
| 581 |
|
// get the angular velocities |
| 582 |
< |
|
| 582 |
> |
|
| 583 |
|
foo = strtok(NULL, " ,;\t"); |
| 584 |
|
if(foo == NULL){ |
| 585 |
|
sprintf( painCave.errMsg, |
| 586 |
< |
"error in reading angular momentum jx from %s\n" |
| 587 |
< |
"natoms = %d, index = %d\n", |
| 492 |
< |
c_in_name, n_atoms, atomIndex ); |
| 586 |
> |
"error in reading velocity x from %s\n", |
| 587 |
> |
inFileName.c_str() ); |
| 588 |
|
return strdup( painCave.errMsg ); |
| 589 |
|
} |
| 590 |
< |
jx = atof( foo ); |
| 591 |
< |
|
| 590 |
> |
ji[0] = atof( foo ); |
| 591 |
> |
|
| 592 |
|
foo = strtok(NULL, " ,;\t"); |
| 593 |
|
if(foo == NULL){ |
| 594 |
|
sprintf( painCave.errMsg, |
| 595 |
< |
"error in reading angular momentum jy from %s\n" |
| 596 |
< |
"natoms = %d, index = %d\n", |
| 502 |
< |
c_in_name, n_atoms, atomIndex ); |
| 595 |
> |
"error in reading velocity x from %s\n", |
| 596 |
> |
inFileName.c_str() ); |
| 597 |
|
return strdup( painCave.errMsg ); |
| 598 |
|
} |
| 599 |
< |
jy = atof(foo ); |
| 600 |
< |
|
| 599 |
> |
ji[1] = atof(foo ); |
| 600 |
> |
|
| 601 |
|
foo = strtok(NULL, " ,;\t"); |
| 602 |
|
if(foo == NULL){ |
| 603 |
|
sprintf( painCave.errMsg, |
| 604 |
< |
"error in reading angular momentum jz from %s\n" |
| 605 |
< |
"natoms = %d, index = %d\n", |
| 512 |
< |
c_in_name, n_atoms, atomIndex ); |
| 604 |
> |
"error in reading velocity x from %s\n", |
| 605 |
> |
inFileName.c_str() ); |
| 606 |
|
return strdup( painCave.errMsg ); |
| 607 |
|
} |
| 608 |
< |
jz = atof( foo ); |
| 516 |
< |
|
| 517 |
< |
dAtom = ( DirectionalAtom* )atoms[atomIndex]; |
| 608 |
> |
ji[2] = atof( foo ); |
| 609 |
|
|
| 610 |
+ |
|
| 611 |
|
// check that the quaternion vector is normalized |
| 612 |
|
|
| 613 |
|
qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]); |
| 614 |
< |
|
| 614 |
> |
|
| 615 |
|
qLength = sqrt( qSqr ); |
| 616 |
|
q[0] = q[0] / qLength; |
| 617 |
|
q[1] = q[1] / qLength; |
| 618 |
|
q[2] = q[2] / qLength; |
| 619 |
|
q[3] = q[3] / qLength; |
| 528 |
– |
|
| 529 |
– |
dAtom->setQ( q ); |
| 530 |
– |
|
| 531 |
– |
// add the angular velocities |
| 620 |
|
|
| 621 |
< |
dAtom->setJx( jx ); |
| 622 |
< |
dAtom->setJy( jy ); |
| 623 |
< |
dAtom->setJz( jz ); |
| 621 |
> |
// add quaternion and angular velocities |
| 622 |
> |
|
| 623 |
> |
sd->setQ( q ); |
| 624 |
> |
sd->setJ( ji ); |
| 625 |
|
} |
| 537 |
– |
|
| 538 |
– |
// add the positions and velocities to the atom |
| 539 |
– |
|
| 540 |
– |
atoms[atomIndex]->setX( rx ); |
| 541 |
– |
atoms[atomIndex]->setY( ry ); |
| 542 |
– |
atoms[atomIndex]->setZ( rz ); |
| 543 |
– |
|
| 544 |
– |
atoms[atomIndex]->set_vx( vx ); |
| 545 |
– |
atoms[atomIndex]->set_vy( vy ); |
| 546 |
– |
atoms[atomIndex]->set_vz( vz ); |
| 626 |
|
|
| 627 |
+ |
|
| 628 |
+ |
|
| 629 |
|
return NULL; |
| 630 |
|
} |
| 631 |
|
|
| 632 |
|
|
| 633 |
< |
char* DumpReader::parseCommentLine(char* readLine, double time, |
| 553 |
< |
double boxMat[9]){ |
| 633 |
> |
char* DumpReader::parseCommentLine(char* readLine, SimInfo* entry_plug){ |
| 634 |
|
|
| 635 |
< |
char *foo; // the pointer to the current string token |
| 636 |
< |
int j; |
| 635 |
> |
double currTime; |
| 636 |
> |
double boxMat[9]; |
| 637 |
> |
double theBoxMat3[3][3]; |
| 638 |
> |
double chi; |
| 639 |
> |
double integralOfChidt; |
| 640 |
> |
double eta[9]; |
| 641 |
|
|
| 642 |
+ |
char *foo; // the pointer to the current string token |
| 643 |
+ |
|
| 644 |
|
// set the string tokenizer |
| 645 |
< |
|
| 645 |
> |
|
| 646 |
|
foo = strtok(readLine, " ,;\t"); |
| 647 |
+ |
// set the timeToken. |
| 648 |
+ |
|
| 649 |
|
if(foo == NULL){ |
| 650 |
|
sprintf( painCave.errMsg, |
| 651 |
< |
"error in reading time from %s\n", |
| 652 |
< |
c_in_name ); |
| 651 |
> |
"error in reading Time from %s\n", |
| 652 |
> |
inFileName.c_str() ); |
| 653 |
|
return strdup( painCave.errMsg ); |
| 654 |
|
} |
| 567 |
– |
time = atof( foo ); |
| 655 |
|
|
| 656 |
< |
// get the Hx vector |
| 656 |
> |
currTime = atof( foo ); |
| 657 |
> |
entry_plug->setTime( currTime ); |
| 658 |
|
|
| 659 |
< |
foo = strtok(NULL, " ,;\t"); |
| 660 |
< |
if(foo == NULL){ |
| 661 |
< |
sprintf( painCave.errMsg, |
| 662 |
< |
"error in reading Hx[0] from %s\n", |
| 663 |
< |
c_in_name ); |
| 664 |
< |
return strdup( painCave.errMsg ); |
| 659 |
> |
//get H-Matrix |
| 660 |
> |
|
| 661 |
> |
for(int i = 0 ; i < 9; i++){ |
| 662 |
> |
foo = strtok(NULL, " ,;\t"); |
| 663 |
> |
if(foo == NULL){ |
| 664 |
> |
sprintf( painCave.errMsg, |
| 665 |
> |
"error in reading H[%d] from %s\n", i, inFileName.c_str() ); |
| 666 |
> |
return strdup( painCave.errMsg ); |
| 667 |
> |
} |
| 668 |
> |
boxMat[i] = atof( foo ); |
| 669 |
|
} |
| 578 |
– |
boxMat[0] = atof( foo ); |
| 579 |
– |
|
| 580 |
– |
foo = strtok(NULL, " ,;\t"); |
| 581 |
– |
if(foo == NULL){ |
| 582 |
– |
sprintf( painCave.errMsg, |
| 583 |
– |
"error in reading Hx[1] from %s\n", |
| 584 |
– |
c_in_name ); |
| 585 |
– |
return strdup( painCave.errMsg ); |
| 586 |
– |
} |
| 587 |
– |
boxMat[1] = atof( foo ); |
| 588 |
– |
|
| 589 |
– |
foo = strtok(NULL, " ,;\t"); |
| 590 |
– |
if(foo == NULL){ |
| 591 |
– |
sprintf( painCave.errMsg, |
| 592 |
– |
"error in reading Hx[2] from %s\n", |
| 593 |
– |
c_in_name ); |
| 594 |
– |
return strdup( painCave.errMsg ); |
| 595 |
– |
} |
| 596 |
– |
boxMat[2] = atof( foo ); |
| 670 |
|
|
| 671 |
< |
// get the Hy vector |
| 671 |
> |
for(int i=0;i<3;i++) |
| 672 |
> |
for(int j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
| 673 |
|
|
| 674 |
< |
foo = strtok(NULL, " ,;\t"); |
| 675 |
< |
if(foo == NULL){ |
| 602 |
< |
sprintf( painCave.errMsg, |
| 603 |
< |
"error in reading Hy[0] from %s\n", |
| 604 |
< |
c_in_name ); |
| 605 |
< |
return strdup( painCave.errMsg ); |
| 606 |
< |
} |
| 607 |
< |
boxMat[3] = atof( foo ); |
| 608 |
< |
|
| 609 |
< |
foo = strtok(NULL, " ,;\t"); |
| 610 |
< |
if(foo == NULL){ |
| 611 |
< |
sprintf( painCave.errMsg, |
| 612 |
< |
"error in reading Hy[1] from %s\n", |
| 613 |
< |
c_in_name ); |
| 614 |
< |
return strdup( painCave.errMsg ); |
| 615 |
< |
} |
| 616 |
< |
boxMat[4] = atof( foo ); |
| 617 |
< |
|
| 618 |
< |
foo = strtok(NULL, " ,;\t"); |
| 619 |
< |
if(foo == NULL){ |
| 620 |
< |
sprintf( painCave.errMsg, |
| 621 |
< |
"error in reading Hy[2] from %s\n", |
| 622 |
< |
c_in_name ); |
| 623 |
< |
return strdup( painCave.errMsg ); |
| 624 |
< |
} |
| 625 |
< |
boxMat[5] = atof( foo ); |
| 674 |
> |
//set H-Matrix |
| 675 |
> |
entry_plug->setBoxM( theBoxMat3 ); |
| 676 |
|
|
| 677 |
< |
// get the Hz vector |
| 677 |
> |
//get chi and integralOfChidt, they should appear by pair |
| 678 |
|
|
| 679 |
< |
foo = strtok(NULL, " ,;\t"); |
| 680 |
< |
if(foo == NULL){ |
| 681 |
< |
sprintf( painCave.errMsg, |
| 682 |
< |
"error in reading Hz[0] from %s\n", |
| 683 |
< |
c_in_name ); |
| 684 |
< |
return strdup( painCave.errMsg ); |
| 679 |
> |
if( entry_plug->useInitXSstate ){ |
| 680 |
> |
foo = strtok(NULL, " ,;\t\n"); |
| 681 |
> |
if(foo != NULL){ |
| 682 |
> |
chi = atof(foo); |
| 683 |
> |
|
| 684 |
> |
foo = strtok(NULL, " ,;\t\n"); |
| 685 |
> |
if(foo == NULL){ |
| 686 |
> |
sprintf( painCave.errMsg, |
| 687 |
> |
"chi and integralOfChidt should appear by pair in %s\n", inFileName.c_str() ); |
| 688 |
> |
return strdup( painCave.errMsg ); |
| 689 |
> |
} |
| 690 |
> |
integralOfChidt = atof( foo ); |
| 691 |
> |
|
| 692 |
> |
//push chi and integralOfChidt into SimInfo::properties which can be |
| 693 |
> |
//retrieved by integrator later |
| 694 |
> |
DoubleData* chiValue = new DoubleData(); |
| 695 |
> |
chiValue->setID(CHIVALUE_ID); |
| 696 |
> |
chiValue->setData(chi); |
| 697 |
> |
entry_plug->addProperty(chiValue); |
| 698 |
> |
|
| 699 |
> |
DoubleData* integralOfChidtValue = new DoubleData(); |
| 700 |
> |
integralOfChidtValue->setID(INTEGRALOFCHIDT_ID); |
| 701 |
> |
integralOfChidtValue->setData(integralOfChidt); |
| 702 |
> |
entry_plug->addProperty(integralOfChidtValue); |
| 703 |
> |
|
| 704 |
> |
} |
| 705 |
> |
else |
| 706 |
> |
return NULL; |
| 707 |
> |
|
| 708 |
> |
//get eta |
| 709 |
> |
foo = strtok(NULL, " ,;\t\n"); |
| 710 |
> |
if(foo != NULL ){ |
| 711 |
> |
|
| 712 |
> |
for(int i = 0 ; i < 9; i++){ |
| 713 |
> |
|
| 714 |
> |
if(foo == NULL){ |
| 715 |
> |
sprintf( painCave.errMsg, |
| 716 |
> |
"error in reading eta[%d] from %s\n", i, inFileName.c_str() ); |
| 717 |
> |
return strdup( painCave.errMsg ); |
| 718 |
> |
} |
| 719 |
> |
eta[i] = atof( foo ); |
| 720 |
> |
foo = strtok(NULL, " ,;\t\n"); |
| 721 |
> |
} |
| 722 |
> |
} |
| 723 |
> |
else |
| 724 |
> |
return NULL; |
| 725 |
> |
|
| 726 |
> |
//push eta into SimInfo::properties which can be |
| 727 |
> |
//retrieved by integrator later |
| 728 |
> |
//entry_plug->setBoxM( theBoxMat3 ); |
| 729 |
> |
DoubleArrayData* etaValue = new DoubleArrayData(); |
| 730 |
> |
etaValue->setID(ETAVALUE_ID); |
| 731 |
> |
etaValue->setData(eta, 9); |
| 732 |
> |
entry_plug->addProperty(etaValue); |
| 733 |
|
} |
| 636 |
– |
boxMat[6] = atof( foo ); |
| 637 |
– |
|
| 638 |
– |
foo = strtok(NULL, " ,;\t"); |
| 639 |
– |
if(foo == NULL){ |
| 640 |
– |
sprintf( painCave.errMsg, |
| 641 |
– |
"error in reading Hz[1] from %s\n", |
| 642 |
– |
c_in_name ); |
| 643 |
– |
return strdup( painCave.errMsg ); |
| 644 |
– |
} |
| 645 |
– |
boxMat[7] = atof( foo ); |
| 646 |
– |
|
| 647 |
– |
foo = strtok(NULL, " ,;\t"); |
| 648 |
– |
if(foo == NULL){ |
| 649 |
– |
sprintf( painCave.errMsg, |
| 650 |
– |
"error in reading Hz[2] from %s\n", |
| 651 |
– |
c_in_name ); |
| 652 |
– |
return strdup( painCave.errMsg ); |
| 653 |
– |
} |
| 654 |
– |
boxMat[8] = atof( foo ); |
| 734 |
|
|
| 735 |
|
return NULL; |
| 736 |
|
} |
| 737 |
|
|
| 659 |
– |
|
| 738 |
|
#ifdef IS_MPI |
| 739 |
< |
|
| 662 |
< |
// a couple of functions to let us escape the read loop |
| 663 |
< |
|
| 664 |
< |
void initFile::nodeZeroError( void ){ |
| 739 |
> |
void DumpReader::nodeZeroError( void ){ |
| 740 |
|
int j, myStatus; |
| 741 |
< |
|
| 741 |
> |
|
| 742 |
|
myStatus = 0; |
| 743 |
< |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
| 744 |
< |
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 743 |
> |
for (j = 0; j < mpiSim->getNProcessors(); j++) { |
| 744 |
> |
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 745 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 746 |
< |
} |
| 672 |
< |
|
| 746 |
> |
} |
| 747 |
|
|
| 748 |
+ |
|
| 749 |
|
MPI_Finalize(); |
| 750 |
|
exit (0); |
| 751 |
< |
|
| 751 |
> |
|
| 752 |
|
} |
| 753 |
|
|
| 754 |
< |
void initFile::anonymousNodeDie( void ){ |
| 754 |
> |
void DumpReader::anonymousNodeDie( void ){ |
| 755 |
|
|
| 756 |
|
MPI_Finalize(); |
| 757 |
|
exit (0); |
| 758 |
|
} |
| 759 |
< |
|
| 685 |
< |
#endif //is_mpi |
| 759 |
> |
#endif |