| 16 |
|
#ifdef IS_MPI |
| 17 |
|
#include <mpi.h> |
| 18 |
|
#include "mpiSimulation.hpp" |
| 19 |
< |
#define TAKE_THIS_TAG_CHAR 0 |
| 20 |
< |
#define TAKE_THIS_TAG_INT 1 |
| 19 |
> |
#define TAKE_THIS_TAG_CHAR 3134 |
| 20 |
> |
#define TAKE_THIS_TAG_INT 3135 |
| 21 |
|
|
| 22 |
|
namespace initFile{ |
| 23 |
|
void nodeZeroError( void ); |
| 175 |
|
int *MolToProcMap = mpiSim->getMolToProcMap(); |
| 176 |
|
int localIndex; |
| 177 |
|
int nCurObj; |
| 178 |
+ |
int nItems; |
| 179 |
|
|
| 180 |
+ |
nTotObjs = simnfo->getTotIntegrableObjects(); |
| 181 |
|
haveError = 0; |
| 182 |
|
if (worldRank == 0) { |
| 183 |
|
|
| 189 |
|
simError(); |
| 190 |
|
} |
| 191 |
|
|
| 192 |
< |
nTotObjs = atoi( read_buffer ); |
| 192 |
> |
nItems = atoi( read_buffer ); |
| 193 |
|
|
| 194 |
|
// Check to see that the number of integrable objects in the intial configuration file is the |
| 195 |
|
// same as declared in simBass. |
| 196 |
|
|
| 197 |
< |
if( nTotObjs != simnfo->getTotIntegrableObjects()){ |
| 197 |
> |
if( nTotObjs != nItems){ |
| 198 |
|
sprintf( painCave.errMsg, |
| 199 |
|
"Initialize from File error. %s n_atoms, %d, " |
| 200 |
|
"does not match the BASS file's n_atoms, %d.\n", |
| 220 |
|
|
| 221 |
|
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
| 222 |
|
|
| 223 |
+ |
|
| 224 |
|
parseErr = parseCommentLine( read_buffer, simnfo); |
| 225 |
|
|
| 226 |
|
if( parseErr != NULL ){ |
| 229 |
|
simError(); |
| 230 |
|
} |
| 231 |
|
|
| 232 |
< |
for (i=0 ; i < mpiSim->getTotNmol(); i++) { |
| 232 |
> |
for (i=0 ; i < mpiSim->getNMolGlobal(); i++) { |
| 233 |
|
which_node = MolToProcMap[i]; |
| 234 |
|
if(which_node == 0){ |
| 235 |
|
//molecules belong to master node |
| 258 |
|
|
| 259 |
|
if(haveError) nodeZeroError(); |
| 260 |
|
|
| 261 |
< |
parseDumpLine(read_buffer, integrableObjects[i]); |
| 261 |
> |
parseDumpLine(read_buffer, integrableObjects[j]); |
| 262 |
|
|
| 263 |
|
} |
| 264 |
|
|
| 267 |
|
else{ |
| 268 |
|
//molecule belongs to slave nodes |
| 269 |
|
|
| 270 |
< |
MPI_Recv(&nCurObj, 1, MPI_INT, 0, |
| 270 |
> |
MPI_Recv(&nCurObj, 1, MPI_INT, which_node, |
| 271 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 272 |
< |
|
| 273 |
< |
for(j=0; j < integrableObjects.size(); j++){ |
| 272 |
> |
|
| 273 |
> |
for(j=0; j < nCurObj; j++){ |
| 274 |
|
|
| 275 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 276 |
|
if(eof_test == NULL){ |
| 287 |
|
|
| 288 |
|
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
| 289 |
|
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
| 290 |
< |
|
| 290 |
> |
|
| 291 |
|
} |
| 292 |
|
|
| 293 |
|
} |
| 297 |
|
} |
| 298 |
|
else{ |
| 299 |
|
//actions taken at slave nodes |
| 300 |
< |
for (i=0 ; i < mpiSim->getTotNmol(); i++) { |
| 300 |
> |
|
| 301 |
> |
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
| 302 |
> |
|
| 303 |
> |
parseErr = parseCommentLine( read_buffer, simnfo); |
| 304 |
> |
|
| 305 |
> |
if( parseErr != NULL ){ |
| 306 |
> |
strcpy( painCave.errMsg, parseErr ); |
| 307 |
> |
haveError = 1; |
| 308 |
> |
simError(); |
| 309 |
> |
} |
| 310 |
> |
|
| 311 |
> |
for (i=0 ; i < mpiSim->getNMolGlobal(); i++) { |
| 312 |
|
which_node = MolToProcMap[i]; |
| 313 |
|
|
| 314 |
|
if(which_node == worldRank){ |
| 326 |
|
|
| 327 |
|
nCurObj = integrableObjects.size(); |
| 328 |
|
|
| 329 |
< |
MPI_Recv(&nCurObj, 1, MPI_INT, 0, |
| 330 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
| 329 |
> |
MPI_Send(&nCurObj, 1, MPI_INT, 0, |
| 330 |
> |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 331 |
|
|
| 332 |
|
for(j = 0; j < integrableObjects.size(); j++){ |
| 333 |
|
|
| 518 |
|
|
| 519 |
|
qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]); |
| 520 |
|
|
| 521 |
+ |
if (fabs(qSqr) < 1e-6) { |
| 522 |
+ |
sprintf(painCave.errMsg, |
| 523 |
+ |
"initial quaternion error (q0^2 + q1^2 + q2^2 + q3^2 ~ 0).\n"); |
| 524 |
+ |
return strdup(painCave.errMsg); |
| 525 |
+ |
} |
| 526 |
+ |
|
| 527 |
|
qLength = sqrt( qSqr ); |
| 528 |
|
q[0] = q[0] / qLength; |
| 529 |
|
q[1] = q[1] / qLength; |
| 637 |
|
|
| 638 |
|
//push eta into SimInfo::properties which can be |
| 639 |
|
//retrieved by integrator later |
| 640 |
< |
//entry_plug->setBoxM( theBoxMat3 ); |
| 640 |
> |
|
| 641 |
|
DoubleArrayData* etaValue = new DoubleArrayData(); |
| 642 |
|
etaValue->setID(ETAVALUE_ID); |
| 643 |
|
etaValue->setData(eta, 9); |
| 655 |
|
int j, myStatus; |
| 656 |
|
|
| 657 |
|
myStatus = 0; |
| 658 |
< |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
| 658 |
> |
for (j = 0; j < mpiSim->getNProcessors(); j++) { |
| 659 |
|
MPI_Send( &myStatus, 1, MPI_INT, j, |
| 660 |
|
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
| 661 |
|
} |