| 11 |
|
|
| 12 |
|
#include "ReadWrite.hpp" |
| 13 |
|
#include "simError.h" |
| 14 |
+ |
#include "GenericData.hpp" |
| 15 |
|
|
| 16 |
|
#ifdef IS_MPI |
| 17 |
|
#include <mpi.h> |
| 41 |
|
painCave.isFatal = 1; |
| 42 |
|
simError(); |
| 43 |
|
} |
| 44 |
< |
|
| 44 |
> |
|
| 45 |
|
strcpy( c_in_name, in_name); |
| 46 |
|
#ifdef IS_MPI |
| 47 |
|
} |
| 48 |
|
strcpy( checkPointMsg, "Infile opened for reading successfully." ); |
| 49 |
|
MPIcheckPoint(); |
| 50 |
|
#endif |
| 51 |
< |
return; |
| 51 |
> |
return; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
InitializeFromFile::~InitializeFromFile( ){ |
| 75 |
|
void InitializeFromFile :: readInit( SimInfo* the_simnfo ){ |
| 76 |
|
|
| 77 |
|
int i, j; |
| 78 |
< |
|
| 78 |
> |
|
| 79 |
|
#ifdef IS_MPI |
| 80 |
|
int done, which_node, which_atom; // loop counter |
| 81 |
|
#endif //is_mpi |
| 82 |
|
|
| 83 |
|
const int BUFFERSIZE = 2000; // size of the read buffer |
| 84 |
|
int n_atoms; // the number of atoms |
| 85 |
< |
char read_buffer[BUFFERSIZE]; //the line buffer for reading |
| 85 |
> |
char read_buffer[BUFFERSIZE]; //the line buffer for reading |
| 86 |
|
|
| 87 |
< |
char *eof_test; // ptr to see when we reach the end of the file |
| 87 |
> |
char *eof_test; // ptr to see when we reach the end of the file |
| 88 |
|
char *parseErr; |
| 89 |
|
|
| 89 |
– |
double currTime; |
| 90 |
– |
double boxMat[9]; |
| 91 |
– |
double theBoxMat3[3][3]; |
| 92 |
– |
|
| 90 |
|
simnfo = the_simnfo; |
| 91 |
|
|
| 92 |
|
|
| 110 |
|
painCave.isFatal = 1; |
| 111 |
|
simError(); |
| 112 |
|
} |
| 113 |
< |
|
| 114 |
< |
//read the box mat from the comment line |
| 115 |
< |
|
| 113 |
> |
|
| 114 |
> |
//read the box mat from the comment line |
| 115 |
> |
|
| 116 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 117 |
|
if(eof_test == NULL){ |
| 118 |
|
sprintf( painCave.errMsg, |
| 121 |
|
simError(); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
< |
parseErr = parseBoxLine( read_buffer, boxMat, currTime ); |
| 124 |
> |
|
| 125 |
> |
|
| 126 |
> |
parseErr = parseCommentLine( read_buffer, simnfo); |
| 127 |
|
if( parseErr != NULL ){ |
| 128 |
|
strcpy( painCave.errMsg, parseErr ); |
| 129 |
|
painCave.isFatal = 1; |
| 130 |
|
simError(); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
< |
for(i=0;i<3;i++) |
| 135 |
< |
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
| 133 |
> |
//parse dump lines |
| 134 |
|
|
| 137 |
– |
simnfo->setBoxM( theBoxMat3 ); |
| 138 |
– |
simnfo->setTime( currTime ); |
| 139 |
– |
|
| 140 |
– |
|
| 135 |
|
for( i=0; i < n_atoms; i++){ |
| 136 |
< |
|
| 136 |
> |
|
| 137 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 138 |
|
if(eof_test == NULL){ |
| 139 |
|
sprintf(painCave.errMsg, |
| 145 |
|
simError(); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
< |
|
| 148 |
> |
|
| 149 |
|
parseErr = parseDumpLine( read_buffer, i ); |
| 150 |
|
if( parseErr != NULL ){ |
| 151 |
|
strcpy( painCave.errMsg, parseErr ); |
| 163 |
|
|
| 164 |
|
int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone |
| 165 |
|
int haveError; |
| 166 |
< |
|
| 166 |
> |
|
| 167 |
|
MPI_Status istatus; |
| 168 |
|
int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
| 169 |
|
|
| 170 |
< |
|
| 170 |
> |
|
| 171 |
|
haveError = 0; |
| 172 |
|
if (worldRank == 0) { |
| 173 |
|
|
| 178 |
|
haveError = 1; |
| 179 |
|
simError(); |
| 180 |
|
} |
| 181 |
< |
|
| 181 |
> |
|
| 182 |
|
n_atoms = atoi( read_buffer ); |
| 183 |
< |
|
| 183 |
> |
|
| 184 |
|
// Check to see that the number of atoms in the intial configuration file is the |
| 185 |
|
// same as declared in simBass. |
| 186 |
< |
|
| 186 |
> |
|
| 187 |
|
if( n_atoms != mpiSim->getTotAtoms() ){ |
| 188 |
|
sprintf( painCave.errMsg, |
| 189 |
|
"Initialize from File error. %s n_atoms, %d, " |
| 192 |
|
haveError= 1; |
| 193 |
|
simError(); |
| 194 |
|
} |
| 195 |
< |
|
| 196 |
< |
//read the boxMat from the comment line |
| 197 |
< |
|
| 195 |
> |
|
| 196 |
> |
//read the boxMat from the comment line |
| 197 |
> |
|
| 198 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 199 |
|
if(eof_test == NULL){ |
| 200 |
|
sprintf( painCave.errMsg, |
| 202 |
|
haveError = 1; |
| 203 |
|
simError(); |
| 204 |
|
} |
| 205 |
< |
|
| 206 |
< |
parseErr = parseBoxLine( read_buffer, boxMat, currTime ); |
| 205 |
> |
|
| 206 |
> |
//Every single processor will parse the comment line by itself |
| 207 |
> |
//By using this way, we might lose some efficiency, but if we want to add |
| 208 |
> |
//more parameters into comment line, we only need to modify function |
| 209 |
> |
//parseCommentLine |
| 210 |
> |
|
| 211 |
> |
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
| 212 |
> |
|
| 213 |
> |
parseErr = parseCommentLine( read_buffer, simnfo); |
| 214 |
> |
|
| 215 |
|
if( parseErr != NULL ){ |
| 216 |
|
strcpy( painCave.errMsg, parseErr ); |
| 217 |
|
haveError = 1; |
| 218 |
|
simError(); |
| 219 |
|
} |
| 220 |
|
|
| 219 |
– |
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
| 220 |
– |
MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
| 221 |
– |
|
| 222 |
– |
if(haveError) nodeZeroError(); |
| 223 |
– |
|
| 221 |
|
for (i=0 ; i < mpiSim->getTotAtoms(); i++) { |
| 222 |
< |
|
| 222 |
> |
|
| 223 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 224 |
|
if(eof_test == NULL){ |
| 225 |
|
sprintf(painCave.errMsg, |
| 230 |
|
haveError= 1; |
| 231 |
|
simError(); |
| 232 |
|
} |
| 233 |
< |
|
| 233 |
> |
|
| 234 |
|
if(haveError) nodeZeroError(); |
| 235 |
|
|
| 236 |
|
// Get the Node number which wants this atom: |
| 237 |
< |
which_node = AtomToProcMap[i]; |
| 237 |
> |
which_node = AtomToProcMap[i]; |
| 238 |
|
if (which_node == 0) { |
| 239 |
|
parseErr = parseDumpLine( read_buffer, i ); |
| 240 |
|
if( parseErr != NULL ){ |
| 241 |
|
strcpy( painCave.errMsg, parseErr ); |
| 242 |
|
haveError = 1; |
| 243 |
|
simError(); |
| 244 |
< |
} |
| 244 |
> |
} |
| 245 |
|
if(haveError) nodeZeroError(); |
| 246 |
< |
} |
| 247 |
< |
|
| 246 |
> |
} |
| 247 |
> |
|
| 248 |
|
else { |
| 249 |
< |
|
| 249 |
> |
|
| 250 |
|
myStatus = 1; |
| 251 |
< |
MPI_Send(&myStatus, 1, MPI_INT, which_node, |
| 251 |
> |
MPI_Send(&myStatus, 1, MPI_INT, which_node, |
| 252 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 253 |
< |
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
| 253 |
> |
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
| 254 |
|
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
| 255 |
|
MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
| 256 |
|
MPI_COMM_WORLD); |
| 257 |
< |
MPI_Recv(&myStatus, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
| 257 |
> |
MPI_Recv(&myStatus, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
| 258 |
|
MPI_COMM_WORLD, &istatus); |
| 259 |
< |
|
| 259 |
> |
|
| 260 |
|
if(!myStatus) nodeZeroError(); |
| 261 |
|
} |
| 262 |
|
} |
| 263 |
|
myStatus = -1; |
| 264 |
< |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
| 265 |
< |
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 264 |
> |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
| 265 |
> |
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 266 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 267 |
|
} |
| 268 |
< |
|
| 268 |
> |
|
| 269 |
|
} else { |
| 270 |
< |
|
| 271 |
< |
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
| 272 |
< |
MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
| 270 |
> |
|
| 271 |
> |
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
| 272 |
> |
|
| 273 |
> |
parseErr = parseCommentLine( read_buffer, simnfo); |
| 274 |
> |
|
| 275 |
> |
if( parseErr != NULL ){ |
| 276 |
> |
strcpy( painCave.errMsg, parseErr ); |
| 277 |
> |
haveError = 1; |
| 278 |
> |
simError(); |
| 279 |
> |
} |
| 280 |
|
|
| 281 |
+ |
|
| 282 |
|
done = 0; |
| 283 |
|
while (!done) { |
| 284 |
|
|
| 285 |
< |
MPI_Recv(&myStatus, 1, MPI_INT, 0, |
| 285 |
> |
MPI_Recv(&myStatus, 1, MPI_INT, 0, |
| 286 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 287 |
< |
|
| 287 |
> |
|
| 288 |
|
if(!myStatus) anonymousNodeDie(); |
| 289 |
< |
|
| 289 |
> |
|
| 290 |
|
if(myStatus < 0) break; |
| 291 |
|
|
| 292 |
< |
MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
| 292 |
> |
MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
| 293 |
|
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
| 294 |
< |
MPI_Recv(&which_atom, 1, MPI_INT, 0, |
| 294 |
> |
MPI_Recv(&which_atom, 1, MPI_INT, 0, |
| 295 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 296 |
< |
|
| 296 |
> |
|
| 297 |
|
myStatus = 1; |
| 298 |
|
parseErr = parseDumpLine( read_buffer, which_atom ); |
| 299 |
|
if( parseErr != NULL ){ |
| 301 |
|
myStatus = 0;; |
| 302 |
|
simError(); |
| 303 |
|
} |
| 304 |
< |
|
| 305 |
< |
MPI_Send( &myStatus, 1, MPI_INT, 0, |
| 304 |
> |
|
| 305 |
> |
MPI_Send( &myStatus, 1, MPI_INT, 0, |
| 306 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 307 |
< |
|
| 307 |
> |
|
| 308 |
|
} |
| 309 |
|
} |
| 310 |
< |
|
| 310 |
> |
|
| 311 |
|
// last thing last, enable fatalities. |
| 312 |
|
painCave.isEventLoop = 0; |
| 313 |
|
|
| 309 |
– |
for(i=0;i<3;i++) |
| 310 |
– |
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
| 314 |
|
|
| 312 |
– |
simnfo->setBoxM( theBoxMat3 ); |
| 313 |
– |
simnfo->setTime( currTime ); |
| 315 |
|
|
| 315 |
– |
|
| 316 |
|
#endif |
| 317 |
|
} |
| 318 |
|
|
| 319 |
|
char* InitializeFromFile::parseDumpLine(char* readLine, int globalIndex){ |
| 320 |
|
|
| 321 |
< |
char *foo; // the pointer to the current string token |
| 322 |
< |
|
| 321 |
> |
char *foo; // the pointer to the current string token |
| 322 |
> |
|
| 323 |
|
double pos[3]; // position place holders |
| 324 |
|
double vel[3]; // velocity placeholders |
| 325 |
|
double q[4]; // the quaternions |
| 326 |
|
double jx, jy, jz; // angular velocity placeholders; |
| 327 |
|
double qSqr, qLength; // needed to normalize the quaternion vector. |
| 328 |
< |
|
| 328 |
> |
|
| 329 |
|
Atom **atoms = simnfo->atoms; |
| 330 |
|
DirectionalAtom* dAtom; |
| 331 |
< |
|
| 331 |
> |
|
| 332 |
|
int n_atoms, atomIndex; |
| 333 |
|
|
| 334 |
|
#ifdef IS_MPI |
| 335 |
|
int j; |
| 336 |
|
|
| 337 |
|
n_atoms = mpiSim->getTotAtoms(); |
| 338 |
< |
atomIndex=-1; |
| 338 |
> |
atomIndex=-1; |
| 339 |
|
for (j=0; j < mpiSim->getMyNlocal(); j++) { |
| 340 |
|
if (atoms[j]->getGlobalIndex() == globalIndex) atomIndex = j; |
| 341 |
|
} |
| 345 |
|
"in file %s does not exist on processor %d .\n", |
| 346 |
|
globalIndex, c_in_name, mpiSim->getMyNode() ); |
| 347 |
|
return strdup( painCave.errMsg ); |
| 348 |
< |
} |
| 348 |
> |
} |
| 349 |
|
#else |
| 350 |
|
n_atoms = simnfo->n_atoms; |
| 351 |
|
atomIndex = globalIndex; |
| 352 |
|
#endif // is_mpi |
| 353 |
|
|
| 354 |
|
// set the string tokenizer |
| 355 |
< |
|
| 355 |
> |
|
| 356 |
|
foo = strtok(readLine, " ,;\t"); |
| 357 |
< |
|
| 357 |
> |
|
| 358 |
|
// check the atom name to the current atom |
| 359 |
< |
|
| 359 |
> |
|
| 360 |
|
if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
| 361 |
|
sprintf( painCave.errMsg, |
| 362 |
|
"Initialize from file error. Atom %s at index %d " |
| 365 |
|
foo, atomIndex, c_in_name, atoms[atomIndex]->getType() ); |
| 366 |
|
return strdup( painCave.errMsg ); |
| 367 |
|
} |
| 368 |
< |
|
| 368 |
> |
|
| 369 |
|
// get the positions |
| 370 |
|
|
| 371 |
|
foo = strtok(NULL, " ,;\t"); |
| 377 |
|
return strdup( painCave.errMsg ); |
| 378 |
|
} |
| 379 |
|
pos[0] = atof( foo ); |
| 380 |
< |
|
| 380 |
> |
|
| 381 |
|
foo = strtok(NULL, " ,;\t"); |
| 382 |
|
if(foo == NULL){ |
| 383 |
|
sprintf( painCave.errMsg, |
| 387 |
|
return strdup( painCave.errMsg ); |
| 388 |
|
} |
| 389 |
|
pos[1] = atof( foo ); |
| 390 |
< |
|
| 390 |
> |
|
| 391 |
|
foo = strtok(NULL, " ,;\t"); |
| 392 |
|
if(foo == NULL){ |
| 393 |
|
sprintf( painCave.errMsg, |
| 396 |
|
c_in_name, n_atoms, atomIndex ); |
| 397 |
|
return strdup( painCave.errMsg ); |
| 398 |
|
} |
| 399 |
< |
pos[2] = atof( foo ); |
| 399 |
> |
pos[2] = atof( foo ); |
| 400 |
|
|
| 401 |
|
|
| 402 |
|
// get the velocities |
| 410 |
|
return strdup( painCave.errMsg ); |
| 411 |
|
} |
| 412 |
|
vel[0] = atof( foo ); |
| 413 |
< |
|
| 413 |
> |
|
| 414 |
|
foo = strtok(NULL, " ,;\t"); |
| 415 |
|
if(foo == NULL){ |
| 416 |
|
sprintf( painCave.errMsg, |
| 420 |
|
return strdup( painCave.errMsg ); |
| 421 |
|
} |
| 422 |
|
vel[1] = atof( foo ); |
| 423 |
< |
|
| 423 |
> |
|
| 424 |
|
foo = strtok(NULL, " ,;\t"); |
| 425 |
|
if(foo == NULL){ |
| 426 |
|
sprintf( painCave.errMsg, |
| 430 |
|
return strdup( painCave.errMsg ); |
| 431 |
|
} |
| 432 |
|
vel[2] = atof( foo ); |
| 433 |
< |
|
| 434 |
< |
|
| 433 |
> |
|
| 434 |
> |
|
| 435 |
|
// get the quaternions |
| 436 |
< |
|
| 436 |
> |
|
| 437 |
|
if( atoms[atomIndex]->isDirectional() ){ |
| 438 |
< |
|
| 438 |
> |
|
| 439 |
|
foo = strtok(NULL, " ,;\t"); |
| 440 |
|
if(foo == NULL){ |
| 441 |
|
sprintf(painCave.errMsg, |
| 445 |
|
return strdup( painCave.errMsg ); |
| 446 |
|
} |
| 447 |
|
q[0] = atof( foo ); |
| 448 |
< |
|
| 448 |
> |
|
| 449 |
|
foo = strtok(NULL, " ,;\t"); |
| 450 |
|
if(foo == NULL){ |
| 451 |
|
sprintf( painCave.errMsg, |
| 455 |
|
return strdup( painCave.errMsg ); |
| 456 |
|
} |
| 457 |
|
q[1] = atof( foo ); |
| 458 |
< |
|
| 458 |
> |
|
| 459 |
|
foo = strtok(NULL, " ,;\t"); |
| 460 |
|
if(foo == NULL){ |
| 461 |
|
sprintf( painCave.errMsg, |
| 465 |
|
return strdup( painCave.errMsg ); |
| 466 |
|
} |
| 467 |
|
q[2] = atof( foo ); |
| 468 |
< |
|
| 468 |
> |
|
| 469 |
|
foo = strtok(NULL, " ,;\t"); |
| 470 |
|
if(foo == NULL){ |
| 471 |
|
sprintf( painCave.errMsg, |
| 475 |
|
return strdup( painCave.errMsg ); |
| 476 |
|
} |
| 477 |
|
q[3] = atof( foo ); |
| 478 |
< |
|
| 478 |
> |
|
| 479 |
|
// get the angular velocities |
| 480 |
< |
|
| 480 |
> |
|
| 481 |
|
foo = strtok(NULL, " ,;\t"); |
| 482 |
|
if(foo == NULL){ |
| 483 |
|
sprintf( painCave.errMsg, |
| 487 |
|
return strdup( painCave.errMsg ); |
| 488 |
|
} |
| 489 |
|
jx = atof( foo ); |
| 490 |
< |
|
| 490 |
> |
|
| 491 |
|
foo = strtok(NULL, " ,;\t"); |
| 492 |
|
if(foo == NULL){ |
| 493 |
|
sprintf( painCave.errMsg, |
| 497 |
|
return strdup( painCave.errMsg ); |
| 498 |
|
} |
| 499 |
|
jy = atof(foo ); |
| 500 |
< |
|
| 500 |
> |
|
| 501 |
|
foo = strtok(NULL, " ,;\t"); |
| 502 |
|
if(foo == NULL){ |
| 503 |
|
sprintf( painCave.errMsg, |
| 507 |
|
return strdup( painCave.errMsg ); |
| 508 |
|
} |
| 509 |
|
jz = atof( foo ); |
| 510 |
< |
|
| 510 |
> |
|
| 511 |
|
dAtom = ( DirectionalAtom* )atoms[atomIndex]; |
| 512 |
|
|
| 513 |
|
// check that the quaternion vector is normalized |
| 514 |
|
|
| 515 |
|
qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]); |
| 516 |
< |
|
| 516 |
> |
|
| 517 |
|
qLength = sqrt( qSqr ); |
| 518 |
|
q[0] = q[0] / qLength; |
| 519 |
|
q[1] = q[1] / qLength; |
| 520 |
|
q[2] = q[2] / qLength; |
| 521 |
|
q[3] = q[3] / qLength; |
| 522 |
< |
|
| 522 |
> |
|
| 523 |
|
dAtom->setQ( q ); |
| 524 |
< |
|
| 524 |
> |
|
| 525 |
|
// add the angular velocities |
| 526 |
|
|
| 527 |
|
dAtom->setJx( jx ); |
| 528 |
|
dAtom->setJy( jy ); |
| 529 |
|
dAtom->setJz( jz ); |
| 530 |
|
} |
| 531 |
< |
|
| 531 |
> |
|
| 532 |
|
// add the positions and velocities to the atom |
| 533 |
< |
|
| 533 |
> |
|
| 534 |
|
atoms[atomIndex]->setPos( pos ); |
| 535 |
|
atoms[atomIndex]->setVel( vel ); |
| 536 |
|
|
| 538 |
|
} |
| 539 |
|
|
| 540 |
|
|
| 541 |
< |
char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9], |
| 542 |
< |
double &time ){ |
| 541 |
> |
char* InitializeFromFile::parseCommentLine(char* readLine, SimInfo* entry_plug){ |
| 542 |
|
|
| 543 |
< |
char *foo; // the pointer to the current string token |
| 543 |
> |
double currTime; |
| 544 |
> |
double boxMat[9]; |
| 545 |
> |
double theBoxMat3[3][3]; |
| 546 |
> |
double chi; |
| 547 |
> |
double integralOfChidt; |
| 548 |
> |
double eta[9]; |
| 549 |
|
|
| 550 |
+ |
char *foo; // the pointer to the current string token |
| 551 |
+ |
|
| 552 |
|
// set the string tokenizer |
| 553 |
< |
|
| 553 |
> |
|
| 554 |
|
foo = strtok(readLine, " ,;\t"); |
| 555 |
|
// set the timeToken. |
| 556 |
|
|
| 560 |
|
c_in_name ); |
| 561 |
|
return strdup( painCave.errMsg ); |
| 562 |
|
} |
| 557 |
– |
time = atof( foo ); |
| 563 |
|
|
| 564 |
< |
// get the Hx vector |
| 564 |
> |
currTime = atof( foo ); |
| 565 |
> |
entry_plug->setTime( currTime ); |
| 566 |
|
|
| 567 |
< |
foo = strtok(NULL, " ,;\t"); |
| 568 |
< |
if(foo == NULL){ |
| 569 |
< |
sprintf( painCave.errMsg, |
| 570 |
< |
"error in reading Hx[0] from %s\n", |
| 571 |
< |
c_in_name ); |
| 572 |
< |
return strdup( painCave.errMsg ); |
| 567 |
> |
//get H-Matrix |
| 568 |
> |
|
| 569 |
> |
for(int i = 0 ; i < 9; i++){ |
| 570 |
> |
foo = strtok(NULL, " ,;\t"); |
| 571 |
> |
if(foo == NULL){ |
| 572 |
> |
sprintf( painCave.errMsg, |
| 573 |
> |
"error in reading H[%d] from %s\n", i, c_in_name ); |
| 574 |
> |
return strdup( painCave.errMsg ); |
| 575 |
> |
} |
| 576 |
> |
boxMat[i] = atof( foo ); |
| 577 |
|
} |
| 568 |
– |
boxMat[0] = atof( foo ); |
| 569 |
– |
|
| 570 |
– |
foo = strtok(NULL, " ,;\t"); |
| 571 |
– |
if(foo == NULL){ |
| 572 |
– |
sprintf( painCave.errMsg, |
| 573 |
– |
"error in reading Hx[1] from %s\n", |
| 574 |
– |
c_in_name ); |
| 575 |
– |
return strdup( painCave.errMsg ); |
| 576 |
– |
} |
| 577 |
– |
boxMat[1] = atof( foo ); |
| 578 |
– |
|
| 579 |
– |
foo = strtok(NULL, " ,;\t"); |
| 580 |
– |
if(foo == NULL){ |
| 581 |
– |
sprintf( painCave.errMsg, |
| 582 |
– |
"error in reading Hx[2] from %s\n", |
| 583 |
– |
c_in_name ); |
| 584 |
– |
return strdup( painCave.errMsg ); |
| 585 |
– |
} |
| 586 |
– |
boxMat[2] = atof( foo ); |
| 578 |
|
|
| 579 |
< |
// get the Hy vector |
| 579 |
> |
for(int i=0;i<3;i++) |
| 580 |
> |
for(int j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
| 581 |
|
|
| 582 |
< |
foo = strtok(NULL, " ,;\t"); |
| 583 |
< |
if(foo == NULL){ |
| 592 |
< |
sprintf( painCave.errMsg, |
| 593 |
< |
"error in reading Hy[0] from %s\n", |
| 594 |
< |
c_in_name ); |
| 595 |
< |
return strdup( painCave.errMsg ); |
| 596 |
< |
} |
| 597 |
< |
boxMat[3] = atof( foo ); |
| 598 |
< |
|
| 599 |
< |
foo = strtok(NULL, " ,;\t"); |
| 600 |
< |
if(foo == NULL){ |
| 601 |
< |
sprintf( painCave.errMsg, |
| 602 |
< |
"error in reading Hy[1] from %s\n", |
| 603 |
< |
c_in_name ); |
| 604 |
< |
return strdup( painCave.errMsg ); |
| 605 |
< |
} |
| 606 |
< |
boxMat[4] = atof( foo ); |
| 607 |
< |
|
| 608 |
< |
foo = strtok(NULL, " ,;\t"); |
| 609 |
< |
if(foo == NULL){ |
| 610 |
< |
sprintf( painCave.errMsg, |
| 611 |
< |
"error in reading Hy[2] from %s\n", |
| 612 |
< |
c_in_name ); |
| 613 |
< |
return strdup( painCave.errMsg ); |
| 614 |
< |
} |
| 615 |
< |
boxMat[5] = atof( foo ); |
| 582 |
> |
//set H-Matrix |
| 583 |
> |
entry_plug->setBoxM( theBoxMat3 ); |
| 584 |
|
|
| 585 |
< |
// get the Hz vector |
| 585 |
> |
//get chi and integralOfChidt, they should appear by pair |
| 586 |
> |
foo = strtok(NULL, " ,;\t\n"); |
| 587 |
> |
if(foo != NULL){ |
| 588 |
> |
chi = atof(foo); |
| 589 |
|
|
| 590 |
< |
foo = strtok(NULL, " ,;\t"); |
| 591 |
< |
if(foo == NULL){ |
| 592 |
< |
sprintf( painCave.errMsg, |
| 593 |
< |
"error in reading Hz[0] from %s\n", |
| 594 |
< |
c_in_name ); |
| 595 |
< |
return strdup( painCave.errMsg ); |
| 590 |
> |
foo = strtok(NULL, " ,;\t\n"); |
| 591 |
> |
if(foo == NULL){ |
| 592 |
> |
sprintf( painCave.errMsg, |
| 593 |
> |
"chi and integralOfChidt should appear by pair in %s\n", c_in_name ); |
| 594 |
> |
return strdup( painCave.errMsg ); |
| 595 |
> |
} |
| 596 |
> |
integralOfChidt = atof( foo ); |
| 597 |
> |
|
| 598 |
> |
//push chi and integralOfChidt into SimInfo::properties which can be |
| 599 |
> |
//retrieved by integrator later |
| 600 |
> |
DoubleData* chiValue = new DoubleData(); |
| 601 |
> |
chiValue->setID(CHIVALUE_ID); |
| 602 |
> |
chiValue->setData(chi); |
| 603 |
> |
entry_plug->addProperty(chiValue); |
| 604 |
> |
|
| 605 |
> |
DoubleData* integralOfChidtValue = new DoubleData(); |
| 606 |
> |
integralOfChidtValue->setID(INTEGRALOFCHIDT_ID); |
| 607 |
> |
integralOfChidtValue->setData(integralOfChidt); |
| 608 |
> |
entry_plug->addProperty(integralOfChidtValue); |
| 609 |
> |
|
| 610 |
|
} |
| 611 |
< |
boxMat[6] = atof( foo ); |
| 612 |
< |
|
| 613 |
< |
foo = strtok(NULL, " ,;\t"); |
| 614 |
< |
if(foo == NULL){ |
| 615 |
< |
sprintf( painCave.errMsg, |
| 616 |
< |
"error in reading Hz[1] from %s\n", |
| 617 |
< |
c_in_name ); |
| 618 |
< |
return strdup( painCave.errMsg ); |
| 611 |
> |
else |
| 612 |
> |
return NULL; |
| 613 |
> |
|
| 614 |
> |
//get eta |
| 615 |
> |
for(int i = 0 ; i < 9; i++){ |
| 616 |
> |
foo = strtok(NULL, " ,;\t"); |
| 617 |
> |
if(foo == NULL){ |
| 618 |
> |
sprintf( painCave.errMsg, |
| 619 |
> |
"error in reading eta[%d] from %s\n", i, c_in_name ); |
| 620 |
> |
return strdup( painCave.errMsg ); |
| 621 |
> |
} |
| 622 |
> |
eta[i] = atof( foo ); |
| 623 |
|
} |
| 635 |
– |
boxMat[7] = atof( foo ); |
| 636 |
– |
|
| 637 |
– |
foo = strtok(NULL, " ,;\t"); |
| 638 |
– |
if(foo == NULL){ |
| 639 |
– |
sprintf( painCave.errMsg, |
| 640 |
– |
"error in reading Hz[2] from %s\n", |
| 641 |
– |
c_in_name ); |
| 642 |
– |
return strdup( painCave.errMsg ); |
| 643 |
– |
} |
| 644 |
– |
boxMat[8] = atof( foo ); |
| 624 |
|
|
| 625 |
+ |
//push eta into SimInfo::properties which can be |
| 626 |
+ |
//retrieved by integrator later |
| 627 |
+ |
//entry_plug->setBoxM( theBoxMat3 ); |
| 628 |
+ |
DoubleArrayData* etaValue = new DoubleArrayData(); |
| 629 |
+ |
etaValue->setID(ETAVALUE_ID); |
| 630 |
+ |
etaValue->setData(eta, 9); |
| 631 |
+ |
entry_plug->addProperty(etaValue); |
| 632 |
+ |
|
| 633 |
+ |
|
| 634 |
|
return NULL; |
| 635 |
|
} |
| 636 |
|
|
| 649 |
– |
|
| 637 |
|
#ifdef IS_MPI |
| 638 |
|
|
| 639 |
|
// a couple of functions to let us escape the read loop |
| 640 |
|
|
| 641 |
|
void initFile::nodeZeroError( void ){ |
| 642 |
|
int j, myStatus; |
| 643 |
< |
|
| 643 |
> |
|
| 644 |
|
myStatus = 0; |
| 645 |
< |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
| 646 |
< |
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 645 |
> |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
| 646 |
> |
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 647 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 648 |
< |
} |
| 662 |
< |
|
| 648 |
> |
} |
| 649 |
|
|
| 650 |
+ |
|
| 651 |
|
MPI_Finalize(); |
| 652 |
|
exit (0); |
| 653 |
< |
|
| 653 |
> |
|
| 654 |
|
} |
| 655 |
|
|
| 656 |
|
void initFile::anonymousNodeDie( void ){ |