# | Line 70 | Line 70 | namespace oopse { | |
---|---|---|
70 | RestReader::RestReader( SimInfo* info ) : info_(info){ | |
71 | ||
72 | idealName = "idealCrystal.in"; | |
73 | < | |
74 | < | isScanned = false; |
75 | < | |
73 | > | |
74 | #ifdef IS_MPI | |
75 | if (worldRank == 0) { | |
76 | #endif | |
77 | < | |
78 | < | inIdealFile = fopen(idealName, "r"); |
79 | < | if(inIdealFile == NULL){ |
77 | > | |
78 | > | inIdealFile = new std::ifstream(idealName.c_str()); |
79 | > | |
80 | > | if(inIdealFile->fail()){ |
81 | sprintf(painCave.errMsg, | |
82 | < | "RestReader: Cannot open file: %s\n", idealName); |
82 | > | "RestReader: Cannot open file: %s\n", |
83 | > | idealName.c_str()); |
84 | painCave.isFatal = 1; | |
85 | simError(); | |
86 | } | |
87 | ||
88 | – | inIdealFileName = idealName; |
88 | #ifdef IS_MPI | |
89 | } | |
90 | strcpy( checkPointMsg, | |
# | Line 100 | Line 99 | namespace oopse { | |
99 | #ifdef IS_MPI | |
100 | if (worldRank == 0) { | |
101 | #endif | |
102 | < | int error; |
103 | < | error = fclose( inIdealFile ); |
104 | < | |
105 | < | if( error ){ |
107 | < | sprintf( painCave.errMsg, |
108 | < | "Error closing %s\n", inIdealFileName.c_str()); |
109 | < | simError(); |
110 | < | } |
111 | < | |
112 | < | MemoryUtils::deletePointers(framePos); |
113 | < | |
102 | > | |
103 | > | delete inIdealFile; |
104 | > | delete inAngFile; |
105 | > | |
106 | #ifdef IS_MPI | |
107 | } | |
108 | < | strcpy( checkPointMsg, "Restraint file closed successfully." ); |
108 | > | strcpy( checkPointMsg, |
109 | > | "File idealCrystal.in (and .zang0 if present) closed successfully." ); |
110 | MPIcheckPoint(); | |
111 | #endif | |
112 | ||
# | Line 122 | Line 115 | namespace oopse { | |
115 | ||
116 | ||
117 | void RestReader :: readIdealCrystal(){ | |
118 | < | |
126 | < | int i; |
127 | < | unsigned int j; |
128 | < | |
118 | > | |
119 | #ifdef IS_MPI | |
120 | < | int done, which_node, which_atom; // loop counter |
120 | > | int which_node; |
121 | > | int i, j; |
122 | #endif //is_mpi | |
123 | ||
124 | const int BUFFERSIZE = 2000; // size of the read buffer | |
125 | int nTotObjs; // the number of atoms | |
126 | char read_buffer[BUFFERSIZE]; //the line buffer for reading | |
127 | ||
137 | – | char *eof_test; // ptr to see when we reach the end of the file |
128 | char *parseErr; | |
129 | ||
130 | std::vector<StuntDouble*> integrableObjects; | |
# | Line 146 | Line 136 | namespace oopse { | |
136 | ||
137 | #ifndef IS_MPI | |
138 | ||
139 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inIdealFile); |
140 | < | if( eof_test == NULL ){ |
139 | > | inIdealFile->getline(read_buffer, sizeof(read_buffer)); |
140 | > | |
141 | > | if( inIdealFile->eof() ){ |
142 | sprintf( painCave.errMsg, | |
143 | "RestraintReader error: error reading 1st line of \"%s\"\n", | |
144 | < | inIdealFileName.c_str() ); |
144 | > | idealName.c_str() ); |
145 | painCave.isFatal = 1; | |
146 | simError(); | |
147 | } | |
# | Line 161 | Line 152 | namespace oopse { | |
152 | sprintf( painCave.errMsg, | |
153 | "RestraintReader error. %s nIntegrable, %d, " | |
154 | "does not match the meta-data file's nIntegrable, %d.\n", | |
155 | < | inIdealFileName.c_str(), nTotObjs, |
155 | > | idealName.c_str(), |
156 | > | nTotObjs, |
157 | info_->getNGlobalIntegrableObjects()); | |
158 | painCave.isFatal = 1; | |
159 | simError(); | |
160 | } | |
161 | ||
162 | // skip over the comment line | |
163 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inIdealFile); |
164 | < | if(eof_test == NULL){ |
163 | > | inIdealFile->getline(read_buffer, sizeof(read_buffer)); |
164 | > | |
165 | > | if( inIdealFile->eof() ){ |
166 | sprintf( painCave.errMsg, | |
167 | < | "error in reading commment in %s\n", inIdealFileName.c_str()); |
167 | > | "error in reading commment in %s\n", |
168 | > | idealName.c_str()); |
169 | painCave.isFatal = 1; | |
170 | simError(); | |
171 | } | |
# | Line 188 | Line 182 | namespace oopse { | |
182 | for (integrableObject = mol->beginIntegrableObject(ii); | |
183 | integrableObject != NULL; | |
184 | integrableObject = mol->nextIntegrableObject(ii)) { | |
185 | < | |
186 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inIdealFile); |
187 | < | if(eof_test == NULL){ |
185 | > | |
186 | > | inIdealFile->getline(read_buffer, sizeof(read_buffer)); |
187 | > | |
188 | > | if( inIdealFile->eof() ){ |
189 | sprintf(painCave.errMsg, | |
190 | "RestReader Error: error in reading file %s\n" | |
191 | "natoms = %d; index = %d\n" | |
192 | "error reading the line from the file.\n", | |
193 | < | inIdealFileName.c_str(), nTotObjs, |
193 | > | idealName.c_str(), nTotObjs, |
194 | integrableObject->getGlobalIndex() ); | |
195 | painCave.isFatal = 1; | |
196 | simError(); | |
# | Line 217 | Line 212 | namespace oopse { | |
212 | painCave.isEventLoop = 1; | |
213 | ||
214 | int masterNode = 0; | |
220 | – | int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone |
215 | ||
216 | MPI_Status istatus; | |
217 | int nCurObj; | |
# | Line 228 | Line 222 | namespace oopse { | |
222 | haveError = 0; | |
223 | ||
224 | if (worldRank == masterNode) { | |
225 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inIdealFile); |
226 | < | if( eof_test == NULL ){ |
225 | > | inIdealFile->getline(read_buffer, sizeof(read_buffer)); |
226 | > | |
227 | > | if( inIdealFile->eof() ){ |
228 | sprintf( painCave.errMsg, | |
229 | < | "Error reading 1st line of %s \n ",inIdealFileName.c_str()); |
229 | > | "Error reading 1st line of %s \n ",idealName.c_str()); |
230 | painCave.isFatal = 1; | |
231 | simError(); | |
232 | } | |
# | Line 245 | Line 240 | namespace oopse { | |
240 | sprintf( painCave.errMsg, | |
241 | "RestraintReader Error. %s nIntegrable, %d, " | |
242 | "does not match the meta-data file's nIntegrable, %d.\n", | |
243 | < | inIdealFileName.c_str(), nTotObjs, |
243 | > | idealName.c_str(), nTotObjs, |
244 | info_->getNGlobalIntegrableObjects()); | |
245 | painCave.isFatal = 1; | |
246 | simError(); | |
247 | } | |
248 | ||
249 | // skip over the comment line | |
250 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inIdealFile); |
251 | < | if(eof_test == NULL){ |
250 | > | inIdealFile->getline(read_buffer, sizeof(read_buffer)); |
251 | > | |
252 | > | if( inIdealFile->eof() ){ |
253 | sprintf( painCave.errMsg, | |
254 | < | "error in reading commment in %s\n", inIdealFileName.c_str()); |
254 | > | "error in reading commment in %s\n", idealName.c_str()); |
255 | painCave.isFatal = 1; | |
256 | simError(); | |
257 | } | |
258 | ||
259 | + | MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
260 | + | |
261 | for (i=0 ; i < info_->getNGlobalMolecules(); i++) { | |
262 | < | int which_node = info_->getMolToProc(i); |
262 | > | which_node = info_->getMolToProc(i); |
263 | ||
264 | if(which_node == masterNode){ | |
265 | //molecules belong to master node | |
# | Line 280 | Line 278 | namespace oopse { | |
278 | integrableObject != NULL; | |
279 | integrableObject = mol->nextIntegrableObject(ii)){ | |
280 | ||
281 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inIdealFile); |
281 | > | inIdealFile->getline(read_buffer, sizeof(read_buffer)); |
282 | ||
283 | < | if(eof_test == NULL){ |
283 | > | if( inIdealFile->eof() ){ |
284 | sprintf(painCave.errMsg, | |
285 | "RestReader Error: error in reading file %s\n" | |
286 | "natoms = %d; index = %d\n" | |
287 | "error reading the line from the file.\n", | |
288 | < | inIdealFileName.c_str(), nTotObjs, i ); |
288 | > | idealName.c_str(), nTotObjs, i ); |
289 | painCave.isFatal = 1; | |
290 | simError(); | |
291 | } | |
# | Line 295 | Line 293 | namespace oopse { | |
293 | parseIdealLine(read_buffer, integrableObject); | |
294 | ||
295 | } | |
296 | + | |
297 | } else { | |
298 | //molecule belongs to slave nodes | |
299 | ||
300 | MPI_Recv(&nCurObj, 1, MPI_INT, which_node, | |
301 | TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); | |
302 | ||
303 | < | for(j=0; j < nCurObj; j++){ |
304 | < | |
305 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inIdealFile); |
306 | < | if(eof_test == NULL){ |
303 | > | for(j = 0; j < nCurObj; j++){ |
304 | > | inIdealFile->getline(read_buffer, sizeof(read_buffer)); |
305 | > | |
306 | > | if( inIdealFile->eof() ){ |
307 | sprintf(painCave.errMsg, | |
308 | "RestReader Error: error in reading file %s\n" | |
309 | "natoms = %d; index = %d\n" | |
310 | "error reading the line from the file.\n", | |
311 | < | inIdealFileName.c_str(), nTotObjs, i ); |
311 | > | idealName.c_str(), nTotObjs, i ); |
312 | painCave.isFatal = 1; | |
313 | simError(); | |
314 | } | |
# | Line 320 | Line 319 | namespace oopse { | |
319 | } | |
320 | } | |
321 | } else { | |
322 | < | //actions taken at slave nodes |
322 | > | //actions taken at slave nodes |
323 | > | MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
324 | > | |
325 | for (i=0 ; i < info_->getNGlobalMolecules(); i++) { | |
326 | < | int which_node = info_->getMolToProc(i); |
327 | < | |
326 | > | int which_node = info_->getMolToProc(i); |
327 | > | |
328 | if(which_node == worldRank){ | |
329 | //molecule with global index i belongs to this processor | |
330 | ||
# | Line 364 | Line 365 | namespace oopse { | |
365 | ||
366 | char* RestReader::parseIdealLine(char* readLine, StuntDouble* sd){ | |
367 | ||
368 | < | char *foo; // the pointer to the current string token |
369 | < | |
370 | < | double pos[3]; // position place holders |
371 | < | double q[4]; // the quaternions |
372 | < | double RfromQ[3][3]; // the rotation matrix |
373 | < | double normalize; // to normalize the reference unit vector |
373 | < | double uX, uY, uZ; // reference unit vector place holders |
374 | < | double uselessToken; |
368 | > | RealType pos[3]; // position place holders |
369 | > | RealType q[4]; // the quaternions |
370 | > | RealType RfromQ[3][3]; // the rotation matrix |
371 | > | RealType normalize; // to normalize the reference unit vector |
372 | > | RealType uX, uY, uZ; // reference unit vector place holders |
373 | > | RealType uselessToken; |
374 | StringTokenizer tokenizer(readLine); | |
375 | int nTokens; | |
376 | ||
# | Line 391 | Line 390 | namespace oopse { | |
390 | sprintf(painCave.errMsg, | |
391 | "RestReader Error: Atom type [%s] in %s does not " | |
392 | "match Atom Type [%s] in .md file.\n", | |
393 | < | name.c_str(), inIdealFileName.c_str(), |
393 | > | name.c_str(), idealName.c_str(), |
394 | sd->getType().c_str()); | |
395 | painCave.isFatal = 1; | |
396 | simError(); | |
# | Line 470 | Line 469 | namespace oopse { | |
469 | void RestReader::readZangle(){ | |
470 | ||
471 | int i; | |
473 | – | unsigned int j; |
472 | int isPresent; | |
473 | ||
474 | Molecule* mol; | |
# | Line 479 | Line 477 | namespace oopse { | |
477 | Molecule::IntegrableObjectIterator ii; | |
478 | ||
479 | #ifdef IS_MPI | |
480 | < | int done, which_node, which_atom; // loop counter |
483 | < | int nProc; |
480 | > | int which_node; |
481 | MPI_Status istatus; | |
482 | #endif //is_mpi | |
483 | ||
484 | const int BUFFERSIZE = 2000; // size of the read buffer | |
485 | < | int nTotObjs; // the number of atoms |
485 | > | unsigned int nTotObjs; // the number of atoms |
486 | char read_buffer[BUFFERSIZE]; //the line buffer for reading | |
487 | ||
491 | – | char *eof_test; // ptr to see when we reach the end of the file |
492 | – | char *parseErr; |
493 | – | |
488 | std::vector<StuntDouble*> vecParticles; | |
489 | < | std::vector<double> tempZangs; |
489 | > | std::vector<RealType> tempZangs; |
490 | ||
491 | < | inAngFileName = info_->getRestFileName(); |
491 | > | angFile = info_->getRestFileName(); |
492 | ||
493 | < | inAngFileName += "0"; |
493 | > | angFile += "0"; |
494 | ||
495 | // open the omega value file for reading | |
496 | #ifdef IS_MPI | |
497 | if (worldRank == 0) { | |
498 | #endif | |
499 | isPresent = 1; | |
500 | < | inAngFile = fopen(inAngFileName.c_str(), "r"); |
501 | < | if(!inAngFile){ |
500 | > | |
501 | > | inAngFile = new std::ifstream(angFile.c_str()); |
502 | > | |
503 | > | if(inAngFile->fail()){ |
504 | sprintf(painCave.errMsg, | |
505 | "Restraints Warning: %s file is not present\n" | |
506 | "\tAll omega values will be initialized to zero. If the\n" | |
507 | "\tsimulation is starting from the idealCrystal.in reference\n" | |
508 | "\tconfiguration, this is the desired action. If this is not\n" | |
509 | "\tthe case, the energy calculations will be incorrect.\n", | |
510 | < | inAngFileName.c_str()); |
510 | > | angFile.c_str()); |
511 | painCave.severity = OOPSE_WARNING; | |
512 | painCave.isFatal = 0; | |
513 | simError(); | |
# | Line 529 | Line 525 | namespace oopse { | |
525 | } | |
526 | ||
527 | #ifdef IS_MPI | |
528 | + | if (!isPresent) { |
529 | + | // master node zeroes out its zAngles if .zang0 isn't present |
530 | + | zeroZangle(); |
531 | + | return; |
532 | + | } |
533 | + | |
534 | } | |
535 | ||
536 | // listen to node 0 to see if we should exit this function | |
# | Line 546 | Line 548 | namespace oopse { | |
548 | ||
549 | #ifndef IS_MPI | |
550 | ||
551 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inAngFile); |
552 | < | if( eof_test == NULL ){ |
551 | > | // read the first line and die if there is a failure |
552 | > | inAngFile->getline(read_buffer, sizeof(read_buffer)); |
553 | > | |
554 | > | if( inAngFile->eof() ){ |
555 | sprintf( painCave.errMsg, | |
556 | "RestraintReader error: error reading 1st line of \"%s\"\n", | |
557 | < | inAngFileName.c_str() ); |
557 | > | angFile.c_str() ); |
558 | painCave.isFatal = 1; | |
559 | simError(); | |
560 | } | |
561 | + | |
562 | + | // read the file and load the values into a vector |
563 | + | inAngFile->getline(read_buffer, sizeof(read_buffer)); |
564 | ||
565 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inAngFile); |
559 | < | while ( eof_test != NULL ) { |
565 | > | while ( !inAngFile->eof() ) { |
566 | // check for and ignore blank lines | |
567 | if ( read_buffer != NULL ) | |
568 | tempZangs.push_back( atof(read_buffer) ); | |
569 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inAngFile); |
569 | > | |
570 | > | inAngFile->getline(read_buffer, sizeof(read_buffer)); |
571 | } | |
572 | ||
573 | nTotObjs = info_->getNGlobalIntegrableObjects(); | |
# | Line 568 | Line 575 | namespace oopse { | |
575 | if( nTotObjs != tempZangs.size() ){ | |
576 | sprintf( painCave.errMsg, | |
577 | "RestraintReader zAngle reading error. %s nIntegrable, %d, " | |
578 | < | "does not match the meta-data file's nIntegrable, %d.\n", |
579 | < | inAngFileName.c_str(), tempZangs.size(), nTotObjs ); |
578 | > | "does not match the meta-data file's nIntegrable, %i.\n", |
579 | > | angFile.c_str(), |
580 | > | tempZangs.size(), |
581 | > | nTotObjs ); |
582 | painCave.isFatal = 1; | |
583 | simError(); | |
584 | } | |
# | Line 595 | Line 604 | namespace oopse { | |
604 | painCave.isEventLoop = 1; | |
605 | ||
606 | int masterNode = 0; | |
607 | < | int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone |
607 | > | |
608 | int haveError; | |
609 | < | int index; |
609 | > | int intObjIndex; |
610 | > | int intObjIndexTransfer; |
611 | ||
612 | + | int j; |
613 | int nCurObj; | |
614 | < | double angleTranfer; |
614 | > | RealType angleTransfer; |
615 | ||
616 | nTotObjs = info_->getNGlobalIntegrableObjects(); | |
617 | haveError = 0; | |
618 | ||
619 | if (worldRank == masterNode) { | |
620 | ||
621 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inAngFile); |
622 | < | if( eof_test == NULL ){ |
621 | > | inAngFile->getline(read_buffer, sizeof(read_buffer)); |
622 | > | |
623 | > | if( inAngFile->eof() ){ |
624 | sprintf( painCave.errMsg, | |
625 | < | "Error reading 1st line of %s \n ",inAngFileName.c_str()); |
625 | > | "Error reading 1st line of %s \n ",angFile.c_str()); |
626 | haveError = 1; | |
627 | simError(); | |
628 | } | |
629 | ||
630 | < | // let node 0 load the temporary angle vector |
631 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inAngFile); |
632 | < | while ( eof_test != NULL ) { |
630 | > | // let the master node read the file and load the temporary angle vector |
631 | > | inAngFile->getline(read_buffer, sizeof(read_buffer)); |
632 | > | |
633 | > | while ( !inAngFile->eof() ) { |
634 | // check for and ignore blank lines | |
635 | if ( read_buffer != NULL ) | |
636 | tempZangs.push_back( atof(read_buffer) ); | |
637 | < | eof_test = fgets(read_buffer, sizeof(read_buffer), inAngFile); |
637 | > | |
638 | > | inAngFile->getline(read_buffer, sizeof(read_buffer)); |
639 | } | |
640 | < | |
640 | > | |
641 | // Check to see that the number of integrable objects in the | |
642 | // intial configuration file is the same as derived from the | |
643 | // meta-data file. | |
# | Line 631 | Line 645 | namespace oopse { | |
645 | sprintf( painCave.errMsg, | |
646 | "RestraintReader zAngle reading Error. %s nIntegrable, %d, " | |
647 | "does not match the meta-data file's nIntegrable, %d.\n", | |
648 | < | inAngFileName.c_str(), tempZangs.size(), nTotObjs); |
648 | > | angFile.c_str(), |
649 | > | tempZangs.size(), |
650 | > | nTotObjs); |
651 | haveError= 1; | |
652 | simError(); | |
653 | } | |
654 | ||
655 | // At this point, node 0 has a tempZangs vector completed, and | |
656 | // everyone else has nada | |
641 | – | index = 0; |
657 | ||
658 | for (i=0 ; i < info_->getNGlobalMolecules(); i++) { | |
659 | // Get the Node number which has this atom | |
660 | which_node = info_->getMolToProc(i); | |
661 | ||
662 | < | if (worldRank == masterNode) { |
662 | > | if (which_node == masterNode) { |
663 | mol = info_->getMoleculeByGlobalIndex(i); | |
664 | < | |
664 | > | |
665 | if(mol == NULL) { | |
666 | strcpy(painCave.errMsg, "Molecule not found on node 0!"); | |
667 | haveError = 1; | |
668 | simError(); | |
669 | } | |
670 | < | |
670 | > | |
671 | for (integrableObject = mol->beginIntegrableObject(ii); | |
672 | integrableObject != NULL; | |
673 | integrableObject = mol->nextIntegrableObject(ii)){ | |
674 | < | |
675 | < | integrableObject->setZangle(tempZangs[index]); |
661 | < | index++; |
674 | > | intObjIndex = integrableObject->getGlobalIndex(); |
675 | > | integrableObject->setZangle(tempZangs[intObjIndex]); |
676 | } | |
677 | ||
678 | } else { | |
679 | // I am MASTER OF THE UNIVERSE, but I don't own this molecule | |
680 | < | |
680 | > | // listen for the number of integrableObjects in the molecule |
681 | MPI_Recv(&nCurObj, 1, MPI_INT, which_node, | |
682 | TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); | |
683 | ||
684 | < | for(j=0; j < nCurObj; j++){ |
685 | < | angleTransfer = tempZangs[index]; |
686 | < | MPI_Send(&angleTransfer, 1, MPI_DOUBLE, which_node, |
684 | > | for(j=0; j < nCurObj; j++){ |
685 | > | // listen for which integrableObject we need to send the value for |
686 | > | MPI_Recv(&intObjIndexTransfer, 1, MPI_INT, which_node, |
687 | > | TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
688 | > | angleTransfer = tempZangs[intObjIndexTransfer]; |
689 | > | // send the value to the node so it can initialize the object |
690 | > | MPI_Send(&angleTransfer, 1, MPI_REALTYPE, which_node, |
691 | TAKE_THIS_TAG_DOUBLE, MPI_COMM_WORLD); | |
674 | – | index++; |
692 | } | |
676 | – | |
693 | } | |
694 | } | |
695 | } else { | |
696 | // I am SLAVE TO THE MASTER | |
697 | for (i=0 ; i < info_->getNGlobalMolecules(); i++) { | |
698 | < | int which_node = info_->getMolToProc(i); |
698 | > | which_node = info_->getMolToProc(i); |
699 | ||
700 | if (which_node == worldRank) { | |
701 | ||
# | Line 696 | Line 712 | namespace oopse { | |
712 | } | |
713 | ||
714 | nCurObj = mol->getNIntegrableObjects(); | |
715 | < | |
715 | > | // send the number of integrableObjects in the molecule |
716 | MPI_Send(&nCurObj, 1, MPI_INT, 0, | |
717 | TAKE_THIS_TAG_INT, MPI_COMM_WORLD); | |
718 | ||
719 | for (integrableObject = mol->beginIntegrableObject(ii); | |
720 | integrableObject != NULL; | |
721 | integrableObject = mol->nextIntegrableObject(ii)){ | |
722 | < | |
723 | < | MPI_Recv(&angleTransfer, 1, MPI_DOUBLE, 0, |
722 | > | intObjIndexTransfer = integrableObject->getGlobalIndex(); |
723 | > | // send the global index of the integrableObject |
724 | > | MPI_Send(&intObjIndexTransfer, 1, MPI_INT, 0, |
725 | > | TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
726 | > | // listen for the value we want to set locally |
727 | > | MPI_Recv(&angleTransfer, 1, MPI_REALTYPE, 0, |
728 | TAKE_THIS_TAG_DOUBLE, MPI_COMM_WORLD, &istatus); | |
729 | ||
730 | integrableObject->setZangle(angleTransfer); | |
# | Line 717 | Line 737 | namespace oopse { | |
737 | ||
738 | void RestReader :: zeroZangle(){ | |
739 | ||
720 | – | int i; |
721 | – | unsigned int j; |
722 | – | int nTotObjs; // the number of atoms |
723 | – | |
740 | Molecule* mol; | |
741 | StuntDouble* integrableObject; | |
742 | SimInfo::MoleculeIterator mi; | |
743 | Molecule::IntegrableObjectIterator ii; | |
744 | < | |
729 | < | std::vector<StuntDouble*> vecParticles; |
730 | < | |
744 | > | |
745 | #ifndef IS_MPI | |
746 | // set all zAngles to 0.0 | |
747 | for (mol = info_->beginMolecule(mi); mol != NULL; | |
# | Line 745 | Line 759 | namespace oopse { | |
759 | // first thing first, suspend fatalities. | |
760 | painCave.isEventLoop = 1; | |
761 | ||
748 | – | int masterNode = 0; |
762 | int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone | |
763 | int haveError; | |
764 | int which_node; | |
765 | ||
753 | – | MPI_Status istatus; |
754 | – | |
755 | – | int nCurObj; |
756 | – | double angleTranfer; |
757 | – | |
758 | – | nTotObjs = info_->getNGlobalIntegrableObjects(); |
766 | haveError = 0; | |
760 | – | if (worldRank == masterNode) { |
767 | ||
768 | < | for (i=0 ; i < info_->getNGlobalMolecules(); i++) { |
769 | < | // Get the Node number which has this atom |
770 | < | which_node = info_->getMolToProc(i); |
768 | > | for (int i=0 ; i < info_->getNGlobalMolecules(); i++) { |
769 | > | |
770 | > | // Get the Node number which has this atom |
771 | > | which_node = info_->getMolToProc(i); |
772 | ||
773 | < | // let's let node 0 pass out constant values to all the processors |
774 | < | if (worldRank == masterNode) { |
775 | < | mol = info_->getMoleculeByGlobalIndex(i); |
776 | < | |
777 | < | if(mol == NULL) { |
778 | < | strcpy(painCave.errMsg, "Molecule not found on node 0!"); |
779 | < | haveError = 1; |
780 | < | simError(); |
781 | < | } |
782 | < | |
776 | < | for (integrableObject = mol->beginIntegrableObject(ii); |
777 | < | integrableObject != NULL; |
778 | < | integrableObject = mol->nextIntegrableObject(ii)){ |
779 | < | |
780 | < | integrableObject->setZangle( 0.0 ); |
781 | < | |
782 | < | } |
783 | < | |
784 | < | } else { |
785 | < | // I am MASTER OF THE UNIVERSE, but I don't own this molecule |
786 | < | |
787 | < | MPI_Recv(&nCurObj, 1, MPI_INT, which_node, |
788 | < | TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
789 | < | |
790 | < | for(j=0; j < nCurObj; j++){ |
791 | < | angleTransfer = 0.0; |
792 | < | MPI_Send(&angleTransfer, 1, MPI_DOUBLE, which_node, |
793 | < | TAKE_THIS_TAG_DOUBLE, MPI_COMM_WORLD); |
794 | < | |
795 | < | } |
773 | > | // each processor zeroes its own integrable objects |
774 | > | if (which_node == worldRank) { |
775 | > | mol = info_->getMoleculeByGlobalIndex(i); |
776 | > | |
777 | > | if(mol == NULL) { |
778 | > | sprintf( painCave.errMsg, |
779 | > | "Molecule not found on node %i!", |
780 | > | which_node ); |
781 | > | haveError = 1; |
782 | > | simError(); |
783 | } | |
797 | – | } |
798 | – | } else { |
799 | – | // I am SLAVE TO THE MASTER |
800 | – | for (i=0 ; i < info_->getNGlobalMolecules(); i++) { |
801 | – | int which_node = info_->getMolToProc(i); |
784 | ||
785 | < | if (which_node == worldRank) { |
785 | > | for (integrableObject = mol->beginIntegrableObject(ii); |
786 | > | integrableObject != NULL; |
787 | > | integrableObject = mol->nextIntegrableObject(ii)){ |
788 | ||
789 | < | // BUT I OWN THIS MOLECULE!!! |
806 | < | mol = info_->getMoleculeByGlobalIndex(i); |
789 | > | integrableObject->setZangle( 0.0 ); |
790 | ||
791 | < | if(mol == NULL) { |
809 | < | sprintf(painCave.errMsg, |
810 | < | "RestReader Error: molecule not found on node %d\n", |
811 | < | worldRank); |
812 | < | painCave.isFatal = 1; |
813 | < | simError(); |
814 | < | } |
815 | < | |
816 | < | nCurObj = mol->getNIntegrableObjects(); |
817 | < | |
818 | < | MPI_Send(&nCurObj, 1, MPI_INT, 0, |
819 | < | TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
820 | < | |
821 | < | for (integrableObject = mol->beginIntegrableObject(ii); |
822 | < | integrableObject != NULL; |
823 | < | integrableObject = mol->nextIntegrableObject(ii)){ |
824 | < | |
825 | < | MPI_Recv(&angleTransfer, 1, MPI_DOUBLE, 0, |
826 | < | TAKE_THIS_TAG_DOUBLE, MPI_COMM_WORLD, &istatus); |
827 | < | vecParticles[j]->setZangle(angleTransfer); |
828 | < | } |
829 | < | } |
791 | > | } |
792 | } | |
793 | } | |
794 | + | |
795 | #endif | |
796 | } | |
797 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |