ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/interface_implementation/TraPPE_ExFF.cpp
(Generate patch)

Comparing trunk/mdtools/interface_implementation/TraPPE_ExFF.cpp (file contents):
Revision 152 by mmeineke, Mon Oct 21 22:03:00 2002 UTC vs.
Revision 176 by mmeineke, Thu Nov 14 22:00:44 2002 UTC

# Line 7 | Line 7 | using namespace std;
7  
8   #include "ForceFields.hpp"
9   #include "SRI.hpp"
10 + #include "simError.h"
11  
12  
13   #ifdef IS_MPI
14  
15   #include "mpiForceField.h"
16  
16 int myNode;
17  
18   // Declare the structures that will be passed by MPI
19  
# Line 26 | Line 26 | typedef struct{
26    int isDipole;
27    int last;      //  0  -> default
28                   //  1  -> tells nodes to stop listening
29                 // -1  -> an error has occured. (handled in mpiForceField)
29   } atomStruct;
30   MPI_Datatype mpiAtomStructType;
31  
# Line 37 | Line 36 | typedef struct{
36    double d0;
37    int last;      //  0  -> default
38                   //  1  -> tells nodes to stop listening
40                 // -1  -> an error has occured. (handled in mpiForceField)
39   } bondStruct;
40   MPI_Datatype mpiBondStructType;
41  
# Line 49 | Line 47 | typedef struct{
47    double k1, k2, k3, t0;
48    int last;      //  0  -> default
49                   //  1  -> tells nodes to stop listening
52                 // -1  -> an error has occured. (handled in mpiForceField)
50   } bendStruct;
51   MPI_Datatype mpiBendStructType;
52  
# Line 62 | Line 59 | typedef struct{
59    double k1, k2, k3, k4;
60    int last;      //  0  -> default
61                   //  1  -> tells nodes to stop listening
62 <                 // -1  -> an error has occured. (handled in mpiForceField)
66 < } TorsionStruct;
62 > } torsionStruct;
63   MPI_Datatype mpiTorsionStructType;
64  
65   #endif
# Line 80 | Line 76 | TraPPE_ExFF::TraPPE_ExFF(){
76  
77   #ifdef IS_MPI
78    int i;
83  int mpiError;
84  int cleanOpen = 0;
79    
80 <  mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&myNode);
87 <  
88 <  // **********************************************************************
80 >   // **********************************************************************
81    // Init the atomStruct mpi type
82  
83    atomStruct atomProto; // mpiPrototype
# Line 93 | Line 85 | TraPPE_ExFF::TraPPE_ExFF(){
85    MPI_Aint atomDspls[3];           // displacements
86    MPI_Datatype atomMbrTypes[3];    // member mpi types
87  
96  
97  
88    MPI_Address(&atomProto.name, &atomDspls[0]);
89    MPI_Address(&atomProto.mass, &atomDspls[1]);
90    MPI_Address(&atomProto.isDipole, &atomDspls[2]);
# Line 177 | Line 167 | TraPPE_ExFF::TraPPE_ExFF(){
167  
168    // ***********************************************************************
169    
170 <  if( myNode == 0 ){
170 >  if( worldRank == 0 ){
171   #endif
172      
173      // generate the force file name
# Line 195 | Line 185 | TraPPE_ExFF::TraPPE_ExFF(){
185        
186        ffPath = getenv( ffPath_env );
187        if( ffPath == NULL ) {
188 <        sprintf( errMsg,
188 >        sprintf( painCave.errMsg,
189                   "Error opening the force field parameter file: %s\n"
190                   "Have you tried setting the FORCE_PARAM_PATH environment "
191                   "vairable?\n",
192                   fileName );
193 < #ifdef IS_MPI  
194 <        cleanOpen = 0;
205 <        mpiError = MPI_Bcast(cleanOpen,1,MPI_INT,0,MPI_COMM_WORLD);
206 < #endif
207 <        ffError( errMsg );
193 >        painCave.isFatal = 1;
194 >        simError();
195        }
196        
197        
# Line 217 | Line 204 | TraPPE_ExFF::TraPPE_ExFF(){
204        
205        if( frcFile == NULL ){
206          
207 <        sprintf( errMsg,
207 >        sprintf( painCave.errMsg,
208                   "Error opening the force field parameter file: %s\n"
209                   "Have you tried setting the FORCE_PARAM_PATH environment "
210                   "vairable?\n",
211                   fileName );
212 < #ifdef IS_MPI  
213 <        cleanOpen = 0;
227 <        mpiError = MPI_Bcast(cleanOpen,1,MPI_INT,0,MPI_COMM_WORLD);
228 < #endif
229 <        ffError( errMsg );
212 >        painCave.isFatal = 1;
213 >        simError();
214        }
215      }
216 <    cleanOpen = 1;
216 >    
217   #ifdef IS_MPI
218    }
219 <
220 <  mpiError = MPI_Bcast(cleanOpen,1,MPI_INT,0,MPI_COMM_WORLD);
221 <  if( !cleanOpen ) fferror( NULL );
222 < #endif
219 >  
220 >  sprintf( checkPointMsg, "TraPPE_ExFF file opened sucessfully." );
221 >  MPIcheckPoint();
222 >  
223 > #endif // is_mpi
224   }
225  
226  
227   TraPPE_ExFF::~TraPPE_ExFF(){
228 <  
229 <  fclose( frcFile );
228 >
229 > #ifdef IS_MPI
230 >  if( worldRank == 0 ){
231 > #endif // is_mpi
232 >    
233 >    fclose( frcFile );
234 >    
235 > #ifdef IS_MPI
236 >  }
237 > #endif // is_mpi
238   }
239  
240   void TraPPE_ExFF::initializeAtoms( void ){
# Line 302 | Line 295 | void TraPPE_ExFF::initializeAtoms( void ){
295  
296   #ifdef IS_MPI
297    atomStruct info;
298 <  info.last = -1; // initialize last to have the error set.
299 <                  // if things go well, last will be set to 0
298 >  info.last = 1; // initialize last to have the last set.
299 >                 // if things go well, last will be set to 0
300   #endif
301    
302  
# Line 313 | Line 306 | void TraPPE_ExFF::initializeAtoms( void ){
306    int foundAtom = 0;
307    int lineNum = 0;
308    int i;
316  char errMsg[1000];
309  
310    
311    //////////////////////////////////////////////////
# Line 357 | Line 349 | void TraPPE_ExFF::initializeAtoms( void ){
349    
350    
351   #ifdef IS_MPI
352 <  if( myNode == 0 ){
352 >  if( worldRank == 0 ){
353   #endif
354      
355      // read in the atom types.
# Line 369 | Line 361 | void TraPPE_ExFF::initializeAtoms( void ){
361      eof_test = fgets( readLine, sizeof(readLine), frcFile );
362      lineNum++;
363      if( eof_test == NULL ){
364 <      sprintf( errMsg, "Error in reading Atoms from force file.\n" );
365 < #ifdef IS_MPI
366 <      sendFrcStruct( &info, mpiAtomStructType );
375 < #endif
376 <      ffError(errMsg);
364 >      sprintf( painCave.errMsg, "Error in reading Atoms from force file.\n" );
365 >      painCave.isFatal = 1;
366 >      simError();
367      }
368      
369      
# Line 383 | Line 373 | void TraPPE_ExFF::initializeAtoms( void ){
373          lineNum++;
374        }
375        if( eof_test == NULL ){
376 <        sprintf( errMsg,
376 >        sprintf( painCave.errMsg,
377                   "Error in reading Atoms from force file at line %d.\n",
378                   lineNum );
379 < #ifdef IS_MPI
380 <        sendFrcStruct( &info, mpiAtomStructType );
391 < #endif
392 <        ffError(errMsg);
379 >        painCave.isFatal = 1;
380 >        simError();
381        }
382        
383        the_token = strtok( readLine, " ,;\t#\n" );
# Line 400 | Line 388 | void TraPPE_ExFF::initializeAtoms( void ){
388          lineNum++;
389          
390          if( eof_test == NULL ){
391 <          sprintf( errMsg,
391 >          sprintf( painCave.errMsg,
392                     "Error in reading Atoms from force file at line %d.\n",
393                     lineNum );
394 < #ifdef IS_MPI
395 <          sendFrcStruct( &info, mpiAtomStructType );
408 < #endif
409 <          ffError(errMsg);
394 >          painCave.isFatal = 1;
395 >          simError();
396          }
397        }
398      }
# Line 417 | Line 403 | void TraPPE_ExFF::initializeAtoms( void ){
403      lineNum++;
404      
405      if( eof_test == NULL ){
406 <      sprintf( errMsg,
406 >      sprintf( painCave.errMsg,
407                 "Error in reading Atoms from force file at line %d.\n",
408                 lineNum );
409 < #ifdef IS_MPI
410 <      sendFrcStruct( &info, mpiAtomStructType );
425 < #endif      
426 <      ffError(errMsg);
409 >      painCave.isFatal = 1;
410 >      simError();
411      }
412      
413      while( readLine[0] != '#' && eof_test != NULL ){
# Line 436 | Line 420 | void TraPPE_ExFF::initializeAtoms( void ){
420            strcpy( currentAtomType->name, the_token );
421            
422            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
423 <            sprintf( errMsg, "Error parseing AtomTypes: line %d\n", lineNum );
424 < #ifdef IS_MPI
425 <            sendFrcStruct( &info, mpiAtomStructType );
426 < #endif
443 <            ffError(errMsg);
423 >            sprintf( painCave.errMsg,
424 >                     "Error parseing AtomTypes: line %d\n", lineNum );
425 >            painCave.isFatal = 1;
426 >            simError();
427            }
428            
429            sscanf( the_token, "%d", &currentAtomType->isDipole );
430            
431            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
432 <            sprintf( errMsg, "Error parseing AtomTypes: line %d\n", lineNum );
433 < #ifdef IS_MPI
434 <            sendFrcStruct( &info, mpiAtomStructType );
435 < #endif
453 <            ffError(errMsg);
432 >            sprintf( painCave.errMsg,
433 >                     "Error parseing AtomTypes: line %d\n", lineNum );
434 >            painCave.isFatal = 1;
435 >            simError();
436            }
437            
438            sscanf( the_token, "%lf", &currentAtomType->mass );
439            
440            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
441 <            sprintf( errMsg, "Error parseing AtomTypes: line %d\n", lineNum );
442 < #ifdef IS_MPI
443 <            sendFrcStruct( &info, mpiAtomStructType );
444 < #endif
463 <            ffError(errMsg);
441 >            sprintf( painCave.errMsg,
442 >                     "Error parseing AtomTypes: line %d\n", lineNum );
443 >            painCave.isFatal = 1;
444 >            simError();
445            }
446            
447            sscanf( the_token, "%lf", &currentAtomType->epslon );
448            
449            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
450 <            sprintf( errMsg, "Error parseing AtomTypes: line %d\n", lineNum );
451 < #ifdef IS_MPI
452 <            sendFrcStruct( &info, mpiAtomStructType );
453 < #endif
473 <            ffError(errMsg);
450 >            sprintf( painCave.errMsg,
451 >                     "Error parseing AtomTypes: line %d\n", lineNum );
452 >            painCave.isFatal = 1;
453 >            simError();
454            }
455            
456            sscanf( the_token, "%lf", &currentAtomType->sigma );
457            
458            if( currentAtomType->isDipole ){
459              if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
460 <              sprintf( errMsg, "Error parseing AtomTypes: line %d\n",
460 >              sprintf( painCave.errMsg,
461 >                       "Error parseing AtomTypes: line %d\n",
462                         lineNum );
463 < #ifdef IS_MPI
464 <              sendFrcStruct( &info, mpiAtomStructType );
484 < #endif
485 <              ffError(errMsg);
463 >              painCave.isFatal = 1;
464 >              simError();
465              }
466              
467              sscanf( the_token, "%lf", &currentAtomType->dipole );
# Line 501 | Line 480 | void TraPPE_ExFF::initializeAtoms( void ){
480   #ifdef IS_MPI
481      
482      // send out the linked list to all the other processes
483 <    
483 >
484 >    sprintf( checkPointMsg,
485 >             "TraPPE_Ex atom structures read successfully." );
486 >    MPIcheckPoint();
487 >
488      currentAtomType = headAtomType;
489      while( currentAtomType != NULL ){
490        currentAtomType->duplicate( info );
# Line 516 | Line 499 | void TraPPE_ExFF::initializeAtoms( void ){
499    else{
500      
501      // listen for node 0 to send out the force params
502 +    
503 +    MPIcheckPoint();
504  
505      headAtomType = new LinkedType;
506      recieveFrcStruct( &info, mpiAtomStructType );
# Line 524 | Line 509 | void TraPPE_ExFF::initializeAtoms( void ){
509        headAtomType->add( info );
510        recieveFrcStruct( &info, mpiAtomStructType );
511      }
527
528    if( info.last < 0 ) ffError( NULL ); // an error has occured, exit quietly.
529
530    
512    }
513 < #endif
513 > #endif // is_mpi
514  
515    
516    // initialize the atoms
# Line 540 | Line 521 | void TraPPE_ExFF::initializeAtoms( void ){
521      
522      currentAtomType = headAtomType->find( the_atoms[i]->getType() );
523      if( currentAtomType == NULL ){
524 <      sprintf( errMsg, "AtomType error, %s not found in force file.\n",
524 >      sprintf( painCave.errMsg,
525 >               "AtomType error, %s not found in force file.\n",
526                 the_atoms[i]->getType() );
527 <      ffError(errMsg);
527 >      painCave.isFatal = 1;
528 >      simError();
529      }
530      
531      the_atoms[i]->setMass( currentAtomType->mass );
# Line 569 | Line 552 | void TraPPE_ExFF::initializeAtoms( void ){
552            dAtom->setSSD( 0 );
553          }
554          else{
555 <          sprintf(errMsg,
555 >          sprintf(painCave.errMsg,
556                    "AtmType error, %s does not have a moment of inertia set.\n",
557                    the_atoms[i]->getType() );
558 <          ffError(errMsg);
558 >          painCave.isFatal = 1;
559 >          simError();
560          }
561          entry_plug->n_dipoles++;
562        }
563        else{
564          
565 <        sprintf( errMsg,
565 >        sprintf( painCave.errMsg,
566                  "TraPPE_ExFF error: Atom \"%s\" is a dipole, yet no standard"
567                   " orientation was specifed in the BASS file.\n",
568                   currentAtomType->name );
569 <        
570 <        ffError(errMsg);
569 >        painCave.isFatal = 1;
570 >        simError();
571        }
572      }
573      else{
574        if( the_atoms[i]->isDirectional() ){
575 <        sprintf( errMsg,
575 >        sprintf( painCave.errMsg,
576                   "TraPPE_ExFF error: Atom \"%s\" was given a standard"
577                   "orientation in the BASS file, yet it is not a dipole.\n",
578                   currentAtomType->name);
579 <        ffError(errMsg);
579 >        painCave.isFatal = 1;
580 >        simError();
581        }
582      }
583    }
# Line 601 | Line 586 | void TraPPE_ExFF::initializeAtoms( void ){
586    // clean up the memory
587    
588    delete headAtomType;
589 +
590 + #ifdef IS_MPI
591 +  sprintf( checkPointMsg, "TraPPE_Ex atoms initialized succesfully" );
592 +  MPIcheckPoint();
593 + #endif // is_mpi
594 +
595   }
596  
597   void TraPPE_ExFF::initializeBonds( bond_pair* the_bonds ){
# Line 659 | Line 650 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
650    LinkedType* currentBondType;
651    LinkedType* tempBondType;
652  
653 + #ifdef IS_MPI
654 +  bondStruct info;
655 +  info.last = 1; // initialize last to have the last set.
656 +                 // if things go well, last will be set to 0
657 + #endif
658 +
659    char readLine[500];
660    char* the_token;
661    char* eof_test;
# Line 675 | Line 672 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
672    the_atoms = entry_plug->atoms;
673    nBonds = entry_plug->n_bonds;
674  
678  // read in the bond types.
679
680  rewind( frcFile );
681  headBondType = new LinkedType;
682  currentBondType = headBondType;
675    
676 <  eof_test = fgets( readLine, sizeof(readLine), frcFile );
677 <  lineNum++;
678 <  if( eof_test == NULL ){
679 <    fprintf( stderr, "Error in reading Bonds from force file.\n" );
680 <    exit(8);
681 <  }
682 <
683 <  
684 <  while( !foundBond ){
685 <    while( eof_test != NULL && readLine[0] != '#' ){
686 <      eof_test = fgets( readLine, sizeof(readLine), frcFile );
687 <      lineNum++;
696 <    }
676 > #ifdef IS_MPI
677 >  if( worldRank == 0 ){
678 > #endif
679 >    
680 >    // read in the bond types.
681 >    
682 >    rewind( frcFile );
683 >    headBondType = new LinkedType;
684 >    currentBondType = headBondType;
685 >    
686 >    eof_test = fgets( readLine, sizeof(readLine), frcFile );
687 >    lineNum++;
688      if( eof_test == NULL ){
689 <      fprintf( stderr,
690 <               "Error in reading Bonds from force file at line %d.\n",
691 <               lineNum );
701 <      exit(8);
689 >      sprintf( painCave.errMsg, "Error in reading Bonds from force file.\n" );
690 >      painCave.isFatal = 1;
691 >      simError();
692      }
703
704    the_token = strtok( readLine, " ,;\t#\n" );
705    foundBond = !strcmp( "BondTypes", the_token );
693      
694 <    if( !foundBond ){
695 <      eof_test = fgets( readLine, sizeof(readLine), frcFile );
696 <      lineNum++;
697 <
694 >    
695 >    while( !foundBond ){
696 >      while( eof_test != NULL && readLine[0] != '#' ){
697 >        eof_test = fgets( readLine, sizeof(readLine), frcFile );
698 >        lineNum++;
699 >      }
700        if( eof_test == NULL ){
701 <        fprintf( stderr,
701 >        sprintf( painCave.errMsg,
702                   "Error in reading Bonds from force file at line %d.\n",
703                   lineNum );
704 <        exit(8);
705 <      }
706 <    }
718 <  }
719 <
720 <  // we are now at the BondTypes section.
721 <
722 <  eof_test = fgets( readLine, sizeof(readLine), frcFile );
723 <  lineNum++;
724 <  
725 <  if( eof_test == NULL ){
726 <    fprintf( stderr,
727 <             "Error in reading Bonds from force file at line %d.\n",
728 <             lineNum );
729 <    exit(8);
730 <  }
731 <
732 <  while( readLine[0] != '#' && eof_test != NULL ){
733 <    
734 <    if( readLine[0] != '!' ){
704 >        painCave.isFatal = 1;
705 >        simError();
706 >      }
707        
708 <      the_token = strtok( readLine, " \n\t,;" );
709 <      if( the_token != NULL ){
708 >      the_token = strtok( readLine, " ,;\t#\n" );
709 >      foundBond = !strcmp( "BondTypes", the_token );
710 >      
711 >      if( !foundBond ){
712 >        eof_test = fgets( readLine, sizeof(readLine), frcFile );
713 >        lineNum++;
714          
715 <        strcpy( currentBondType->nameA, the_token );
715 >        if( eof_test == NULL ){
716 >          sprintf( painCave.errMsg,
717 >                   "Error in reading Bonds from force file at line %d.\n",
718 >                   lineNum );
719 >          painCave.isFatal = 1;
720 >          simError();
721 >        }
722 >      }
723 >    }
724 >    
725 >    // we are now at the BondTypes section.
726 >    
727 >    eof_test = fgets( readLine, sizeof(readLine), frcFile );
728 >    lineNum++;
729 >    
730 >    if( eof_test == NULL ){
731 >      sprintf( painCave.errMsg,
732 >               "Error in reading Bonds from force file at line %d.\n",
733 >               lineNum );
734 >      painCave.isFatal = 1;
735 >      simError();
736 >    }
737 >    
738 >    while( readLine[0] != '#' && eof_test != NULL ){
739 >      
740 >      if( readLine[0] != '!' ){
741          
742 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
743 <          fprintf( stderr, "Error parseing BondTypes: line %d\n", lineNum );
744 <          exit(8);
745 <        }
746 <
746 <        strcpy( currentBondType->nameB, the_token );
747 <
748 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
749 <          fprintf( stderr, "Error parseing BondTypes: line %d\n", lineNum );
750 <          exit(8);
751 <        }
752 <
753 <        strcpy( currentBondType->type, the_token );
754 <
755 <        if( !strcmp( currentBondType->type, "fixed" ) ){
742 >        the_token = strtok( readLine, " \n\t,;" );
743 >        if( the_token != NULL ){
744 >          
745 >          strcpy( currentBondType->nameA, the_token );
746 >          
747            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
748 <            fprintf( stderr, "Error parseing BondTypes: line %d\n", lineNum );
749 <            exit(8);
748 >            sprintf( painCave.errMsg,
749 >                     "Error parseing BondTypes: line %d\n", lineNum );
750 >            painCave.isFatal = 1;
751 >            simError();
752            }
753            
754 <          sscanf( the_token, "%lf", &currentBondType->d0 );
754 >          strcpy( currentBondType->nameB, the_token );
755 >          
756 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
757 >            sprintf( painCave.errMsg,
758 >                     "Error parseing BondTypes: line %d\n", lineNum );
759 >            painCave.isFatal = 1;
760 >            simError();
761 >          }
762 >          
763 >          strcpy( currentBondType->type, the_token );
764 >          
765 >          if( !strcmp( currentBondType->type, "fixed" ) ){
766 >            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
767 >              sprintf( painCave.errMsg,
768 >                       "Error parseing BondTypes: line %d\n", lineNum );
769 >              painCave.isFatal = 1;
770 >              simError();
771 >            }
772 >            
773 >            sscanf( the_token, "%lf", &currentBondType->d0 );
774 >          }
775 >          
776 >          else{
777 >            sprintf( painCave.errMsg,
778 >                     "Unknown TraPPE_Ex bond type \"%s\" at line %d\n",
779 >                     currentBondType->type,
780 >                     lineNum );
781 >            painCave.isFatal = 1;
782 >            simError();
783 >          }              
784          }
763        
764        else{
765          fprintf(stderr,
766                  "Unknown TraPPE_Ex bond type \"%s\" at line %d\n",
767                  currentBondType->type,
768                  lineNum );
769          exit(8);
770        }                
785        }
786 +      
787 +      tempBondType = new LinkedType;
788 +      currentBondType->next = tempBondType;
789 +      currentBondType = tempBondType;
790 +      
791 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
792 +      lineNum++;
793      }
794      
795 <    tempBondType = new LinkedType;
775 <    currentBondType->next = tempBondType;
776 <    currentBondType = tempBondType;
795 > #ifdef IS_MPI
796      
797 <    eof_test = fgets( readLine, sizeof(readLine), frcFile );
798 <    lineNum++;
797 >    // send out the linked list to all the other processes
798 >    
799 >    sprintf( checkPointMsg,
800 >             "TraPPE_Ex bond structures read successfully." );
801 >    MPIcheckPoint();
802 >    
803 >    currentBondType = headBondType;
804 >    while( currentBondType != NULL ){
805 >      currentBondType->duplicate( info );
806 >      sendFrcStruct( &info, mpiBondStructType );
807 >      currentBondType = currentBondType->next;
808 >    }
809 >    info.last = 1;
810 >    sendFrcStruct( &info, mpiBondStructType );
811 >    
812    }
813  
814 +  else{
815 +    
816 +    // listen for node 0 to send out the force params
817 +    
818 +    MPIcheckPoint();
819 +
820 +    headBondType = new LinkedType;
821 +    recieveFrcStruct( &info, mpiBondStructType );
822 +    while( !info.last ){
823 +
824 +      headBondType->add( info );
825 +      recieveFrcStruct( &info, mpiBondStructType );
826 +    }
827 +  }
828 + #endif // is_mpi
829    
830 +  
831    // initialize the Bonds
832    
833  
# Line 792 | Line 840 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
840      atomB = the_atoms[b]->getType();
841      currentBondType = headBondType->find( atomA, atomB );
842      if( currentBondType == NULL ){
843 <      fprintf( stderr, "BondType error, %s - %s not found in force file.\n",
843 >      sprintf( painCave.errMsg,
844 >               "BondType error, %s - %s not found in force file.\n",
845                 atomA, atomB );
846 <      exit(8);
846 >      painCave.isFatal = 1;
847 >      simError();
848      }
849      
850      if( !strcmp( currentBondType->type, "fixed" ) ){
# Line 811 | Line 861 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
861    
862    delete headBondType;
863  
864 + #ifdef IS_MPI
865 +  sprintf( checkPointMsg, "TraPPE_Ex bonds initialized succesfully" );
866 +  MPIcheckPoint();
867 + #endif // is_mpi
868 +
869   }
870  
871   void TraPPE_ExFF::initializeBends( bend_set* the_bends ){
# Line 864 | Line 919 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
919        info.last = 0;
920      }
921  
922 < #endif
922 > #endif // is_mpi
923  
924      char nameA[15];
925      char nameB[15];
# Line 879 | Line 934 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
934    LinkedType* currentBendType;
935    LinkedType* tempBendType;
936  
937 + #ifdef IS_MPI
938 +  bendStruct info;
939 +  info.last = 1; // initialize last to have the last set.
940 +                 // if things go well, last will be set to 0
941 + #endif
942 +
943    char readLine[500];
944    char* the_token;
945    char* eof_test;
# Line 897 | Line 958 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
958    the_atoms = entry_plug->atoms;
959    nBends = entry_plug->n_bends;
960  
900  // read in the bend types.
961  
962 <  rewind( frcFile );
963 <  headBendType = new LinkedType;
964 <  currentBendType = headBendType;
905 <  
906 <  eof_test = fgets( readLine, sizeof(readLine), frcFile );
907 <  lineNum++;
908 <  if( eof_test == NULL ){
909 <    fprintf( stderr, "Error in reading Bends from force file.\n" );
910 <    exit(8);
911 <  }
962 > #ifdef IS_MPI
963 >  if( worldRank == 0 ){
964 > #endif
965  
966 +    // read in the bend types.
967 +
968 +    rewind( frcFile );
969 +    headBendType = new LinkedType;
970 +    currentBendType = headBendType;
971    
972 <  while( !foundBend ){
973 <    while( eof_test != NULL && readLine[0] != '#' ){
916 <      eof_test = fgets( readLine, sizeof(readLine), frcFile );
917 <      lineNum++;
918 <    }
972 >    eof_test = fgets( readLine, sizeof(readLine), frcFile );
973 >    lineNum++;
974      if( eof_test == NULL ){
975 <      fprintf( stderr,
976 <               "Error in reading Bends from force file at line %d.\n",
977 <               lineNum );
923 <      exit(8);
975 >      sprintf( painCave.errMsg, "Error in reading Bends from force file.\n" );
976 >      painCave.isFatal = 1;
977 >      simError();
978      }
979  
980 <    the_token = strtok( readLine, " ,;\t#\n" );
981 <    foundBend = !strcmp( "BendTypes", the_token );
982 <    
983 <    if( !foundBend ){
984 <      eof_test = fgets( readLine, sizeof(readLine), frcFile );
985 <      lineNum++;
932 <
980 >  
981 >    while( !foundBend ){
982 >      while( eof_test != NULL && readLine[0] != '#' ){
983 >        eof_test = fgets( readLine, sizeof(readLine), frcFile );
984 >        lineNum++;
985 >      }
986        if( eof_test == NULL ){
987 <        fprintf( stderr,
987 >        sprintf( painCave.errMsg,
988                   "Error in reading Bends from force file at line %d.\n",
989                   lineNum );
990 <        exit(8);
991 <      }
990 >        painCave.isFatal = 1;
991 >        simError();
992 >      }
993 >
994 >      the_token = strtok( readLine, " ,;\t#\n" );
995 >      foundBend = !strcmp( "BendTypes", the_token );
996 >    
997 >      if( !foundBend ){
998 >        eof_test = fgets( readLine, sizeof(readLine), frcFile );
999 >        lineNum++;
1000 >
1001 >        if( eof_test == NULL ){
1002 >          sprintf( painCave.errMsg,
1003 >                   "Error in reading Bends from force file at line %d.\n",
1004 >                   lineNum );
1005 >          painCave.isFatal = 1;
1006 >          simError();
1007 >        }
1008 >      }
1009      }
940  }
1010  
1011 <  // we are now at the BendTypes section.
1011 >    // we are now at the BendTypes section.
1012  
1013 <  eof_test = fgets( readLine, sizeof(readLine), frcFile );
1014 <  lineNum++;
1013 >    eof_test = fgets( readLine, sizeof(readLine), frcFile );
1014 >    lineNum++;
1015    
1016 <  if( eof_test == NULL ){
1017 <    fprintf( stderr,
1018 <             "Error in reading Bends from force file at line %d.\n",
1019 <             lineNum );
1020 <    exit(8);
1021 <  }
1016 >    if( eof_test == NULL ){
1017 >      sprintf( painCave.errMsg,
1018 >               "Error in reading Bends from force file at line %d.\n",
1019 >               lineNum );
1020 >      painCave.isFatal = 1;
1021 >      simError();
1022 >    }
1023  
1024 <  while( readLine[0] != '#' && eof_test != NULL ){
1024 >    while( readLine[0] != '#' && eof_test != NULL ){
1025      
1026 <    if( readLine[0] != '!' ){
1026 >      if( readLine[0] != '!' ){
1027        
1028 <      the_token = strtok( readLine, " \n\t,;" );
1029 <      if( the_token != NULL ){
1028 >        the_token = strtok( readLine, " \n\t,;" );
1029 >        if( the_token != NULL ){
1030          
1031 <        strcpy( currentBendType->nameA, the_token );
1031 >          strcpy( currentBendType->nameA, the_token );
1032          
1033 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1034 <          fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum );
1035 <          exit(8);
1036 <        }
1033 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1034 >            sprintf( painCave.errMsg,
1035 >                     "Error parseing BendTypes: line %d\n", lineNum );
1036 >            painCave.isFatal = 1;
1037 >            simError();
1038 >          }
1039  
1040 <        strcpy( currentBendType->nameB, the_token );
1040 >          strcpy( currentBendType->nameB, the_token );
1041  
1042 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1043 <          fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum );
1044 <          exit(8);
1045 <        }
1042 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1043 >            sprintf( painCave.errMsg,
1044 >                     "Error parseing BendTypes: line %d\n", lineNum );
1045 >            painCave.isFatal = 1;
1046 >            simError();
1047 >          }
1048  
1049 <        strcpy( currentBendType->nameC, the_token );
1049 >          strcpy( currentBendType->nameC, the_token );
1050  
977        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
978          fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum );
979          exit(8);
980        }
981
982        strcpy( currentBendType->type, the_token );
983
984        if( !strcmp( currentBendType->type, "quadratic" ) ){
1051            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1052 <            fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum );
1053 <            exit(8);
1052 >            sprintf( painCave.errMsg,
1053 >                     "Error parseing BendTypes: line %d\n", lineNum );
1054 >            painCave.isFatal = 1;
1055 >            simError();
1056            }
1057 +
1058 +          strcpy( currentBendType->type, the_token );
1059 +
1060 +          if( !strcmp( currentBendType->type, "quadratic" ) ){
1061 +            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1062 +              sprintf( painCave.errMsg,
1063 +                       "Error parseing BendTypes: line %d\n", lineNum );
1064 +              painCave.isFatal = 1;
1065 +              simError();
1066 +            }
1067            
1068 <          sscanf( the_token, "%lf", &currentBendType->k1 );
1068 >            sscanf( the_token, "%lf", &currentBendType->k1 );
1069  
1070 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1071 <            fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum );
1072 <            exit(8);
1073 <          }
1070 >            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1071 >              sprintf( painCave.errMsg,
1072 >                       "Error parseing BendTypes: line %d\n", lineNum );
1073 >              painCave.isFatal = 1;
1074 >              simError();
1075 >            }
1076            
1077 <          sscanf( the_token, "%lf", &currentBendType->k2 );
1077 >            sscanf( the_token, "%lf", &currentBendType->k2 );
1078  
1079 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1080 <            fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum );
1081 <            exit(8);
1082 <          }
1079 >            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1080 >              sprintf( painCave.errMsg,
1081 >                       "Error parseing BendTypes: line %d\n", lineNum );
1082 >              painCave.isFatal = 1;
1083 >              simError();
1084 >            }
1085            
1086 <          sscanf( the_token, "%lf", &currentBendType->k3 );
1086 >            sscanf( the_token, "%lf", &currentBendType->k3 );
1087  
1088 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1089 <            fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum );
1090 <            exit(8);
1091 <          }
1088 >            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1089 >              sprintf( painCave.errMsg,
1090 >                       "Error parseing BendTypes: line %d\n", lineNum );
1091 >              painCave.isFatal = 1;
1092 >              simError();
1093 >            }
1094            
1095 <          sscanf( the_token, "%lf", &currentBendType->t0 );
1096 <        }
1095 >            sscanf( the_token, "%lf", &currentBendType->t0 );
1096 >          }
1097          
1098 <        else{
1099 <          fprintf(stderr,
1100 <                  "Unknown TraPPE_Ex bend type \"%s\" at line %d\n",
1101 <                  currentBendType->type,
1102 <                  lineNum );
1103 <          exit(8);
1104 <        }                
1098 >          else{
1099 >            sprintf( painCave.errMsg,
1100 >                     "Unknown TraPPE_Ex bend type \"%s\" at line %d\n",
1101 >                     currentBendType->type,
1102 >                     lineNum );
1103 >            painCave.isFatal = 1;
1104 >            simError();
1105 >          }              
1106 >        }
1107        }
1022    }
1108      
1109 <    tempBendType = new LinkedType;
1110 <    currentBendType->next = tempBendType;
1111 <    currentBendType = tempBendType;
1109 >      tempBendType = new LinkedType;
1110 >      currentBendType->next = tempBendType;
1111 >      currentBendType = tempBendType;
1112      
1113 <    eof_test = fgets( readLine, sizeof(readLine), frcFile );
1114 <    lineNum++;
1113 >      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1114 >      lineNum++;
1115 >    }
1116 >
1117 > #ifdef IS_MPI
1118 >    
1119 >    // send out the linked list to all the other processes
1120 >
1121 >    sprintf( checkPointMsg,
1122 >             "TraPPE_Ex bend structures read successfully." );
1123 >    MPIcheckPoint();
1124 >
1125 >    currentBendType = headBendType;
1126 >    while( currentBendType != NULL ){
1127 >      currentBendType->duplicate( info );
1128 >      sendFrcStruct( &info, mpiBendStructType );
1129 >      currentBendType = currentBendType->next;
1130 >    }
1131 >    info.last = 1;
1132 >    sendFrcStruct( &info, mpiBendStructType );
1133 >    
1134    }
1135  
1136 +  else{
1137 +    
1138 +    // listen for node 0 to send out the force params
1139 +    
1140 +    MPIcheckPoint();
1141 +
1142 +    headBendType = new LinkedType;
1143 +    recieveFrcStruct( &info, mpiBendStructType );
1144 +    while( !info.last ){
1145 +
1146 +      headBendType->add( info );
1147 +      recieveFrcStruct( &info, mpiBendStructType );
1148 +    }
1149 +  }
1150 + #endif // is_mpi
1151    
1152    // initialize the Bends
1153  
# Line 1043 | Line 1162 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1162      atomC = the_atoms[c]->getType();
1163      currentBendType = headBendType->find( atomA, atomB, atomC );
1164      if( currentBendType == NULL ){
1165 <      fprintf( stderr, "BendType error, %s - %s - %s not found"
1165 >      sprintf( painCave.errMsg, "BendType error, %s - %s - %s not found"
1166                 " in force file.\n",
1167                 atomA, atomB, atomC );
1168 <      exit(8);
1168 >      painCave.isFatal = 1;
1169 >      simError();
1170      }
1171      
1172      if( !strcmp( currentBendType->type, "quadratic" ) ){
# Line 1068 | Line 1188 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1188    
1189    delete headBendType;
1190  
1191 + #ifdef IS_MPI
1192 +  sprintf( checkPointMsg, "TraPPE_Ex bends initialized succesfully" );
1193 +  MPIcheckPoint();
1194 + #endif // is_mpi
1195 +
1196   }
1197  
1198   void TraPPE_ExFF::initializeTorsions( torsion_set* the_torsions ){
# Line 1140 | Line 1265 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1265    LinkedType* currentTorsionType;
1266    LinkedType* tempTorsionType;
1267  
1268 + #ifdef IS_MPI
1269 +  torsionStruct info;
1270 +  info.last = 1; // initialize last to have the last set.
1271 +                 // if things go well, last will be set to 0
1272 + #endif
1273 +
1274    char readLine[500];
1275    char* the_token;
1276    char* eof_test;
# Line 1159 | Line 1290 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1290    the_atoms = entry_plug->atoms;
1291    nTorsions = entry_plug->n_torsions;
1292  
1293 <  // read in the torsion types.
1293 > #ifdef IS_MPI
1294 >  if( worldRank == 0 ){
1295 > #endif
1296  
1297 <  rewind( frcFile );
1165 <  headTorsionType = new LinkedType;
1166 <  currentTorsionType = headTorsionType;
1167 <  
1168 <  eof_test = fgets( readLine, sizeof(readLine), frcFile );
1169 <  lineNum++;
1170 <  if( eof_test == NULL ){
1171 <    fprintf( stderr, "Error in reading Torsions from force file.\n" );
1172 <    exit(8);
1173 <  }
1297 >    // read in the torsion types.
1298  
1299 +    rewind( frcFile );
1300 +    headTorsionType = new LinkedType;
1301 +    currentTorsionType = headTorsionType;
1302    
1303 <  while( !foundTorsion ){
1304 <    while( eof_test != NULL && readLine[0] != '#' ){
1178 <      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1179 <      lineNum++;
1180 <    }
1303 >    eof_test = fgets( readLine, sizeof(readLine), frcFile );
1304 >    lineNum++;
1305      if( eof_test == NULL ){
1306 <      fprintf( stderr,
1307 <               "Error in reading Torsions from force file at line %d.\n",
1308 <               lineNum );
1309 <      exit(8);
1306 >      sprintf( painCave.errMsg,
1307 >               "Error in reading Torsions from force file.\n" );
1308 >      painCave.isFatal = 1;
1309 >      simError();
1310      }
1311  
1312 <    the_token = strtok( readLine, " ,;\t#\n" );
1313 <    foundTorsion = !strcmp( "TorsionTypes", the_token );
1314 <    
1315 <    if( !foundTorsion ){
1316 <      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1317 <      lineNum++;
1194 <
1312 >  
1313 >    while( !foundTorsion ){
1314 >      while( eof_test != NULL && readLine[0] != '#' ){
1315 >        eof_test = fgets( readLine, sizeof(readLine), frcFile );
1316 >        lineNum++;
1317 >      }
1318        if( eof_test == NULL ){
1319 <        fprintf( stderr,
1319 >        sprintf( painCave.errMsg,
1320                   "Error in reading Torsions from force file at line %d.\n",
1321                   lineNum );
1322 <        exit(8);
1323 <      }
1322 >        painCave.isFatal = 1;
1323 >        simError();
1324 >      }
1325 >
1326 >      the_token = strtok( readLine, " ,;\t#\n" );
1327 >      foundTorsion = !strcmp( "TorsionTypes", the_token );
1328 >    
1329 >      if( !foundTorsion ){
1330 >        eof_test = fgets( readLine, sizeof(readLine), frcFile );
1331 >        lineNum++;
1332 >
1333 >        if( eof_test == NULL ){
1334 >          sprintf( painCave.errMsg,
1335 >                   "Error in reading Torsions from force file at line %d.\n",
1336 >                   lineNum );
1337 >          painCave.isFatal = 1;
1338 >          simError();
1339 >        }
1340 >      }
1341      }
1202  }
1342  
1343 <  // we are now at the TorsionTypes section.
1343 >    // we are now at the TorsionTypes section.
1344  
1345 <  eof_test = fgets( readLine, sizeof(readLine), frcFile );
1346 <  lineNum++;
1345 >    eof_test = fgets( readLine, sizeof(readLine), frcFile );
1346 >    lineNum++;
1347    
1348 <  if( eof_test == NULL ){
1349 <    fprintf( stderr,
1350 <             "Error in reading Torsions from force file at line %d.\n",
1351 <             lineNum );
1352 <    exit(8);
1353 <  }
1348 >    if( eof_test == NULL ){
1349 >      sprintf( painCave.errMsg,
1350 >               "Error in reading Torsions from force file at line %d.\n",
1351 >               lineNum );
1352 >      painCave.isFatal = 1;
1353 >      simError();
1354 >    }
1355  
1356 <  while( readLine[0] != '#' && eof_test != NULL ){
1356 >    while( readLine[0] != '#' && eof_test != NULL ){
1357      
1358 <    if( readLine[0] != '!' ){
1358 >      if( readLine[0] != '!' ){
1359        
1360 <      the_token = strtok( readLine, " \n\t,;" );
1361 <      if( the_token != NULL ){
1360 >        the_token = strtok( readLine, " \n\t,;" );
1361 >        if( the_token != NULL ){
1362          
1363 <        strcpy( currentTorsionType->nameA, the_token );
1363 >          strcpy( currentTorsionType->nameA, the_token );
1364          
1365 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1366 <          fprintf( stderr, "Error parseing TorsionTypes: line %d\n", lineNum );
1367 <          exit(8);
1368 <        }
1365 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1366 >            sprintf( painCave.errMsg,
1367 >                     "Error parseing TorsionTypes: line %d\n", lineNum );
1368 >            painCave.isFatal = 1;
1369 >            simError();
1370 >          }
1371  
1372 <        strcpy( currentTorsionType->nameB, the_token );
1372 >          strcpy( currentTorsionType->nameB, the_token );
1373  
1374 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1375 <          fprintf( stderr, "Error parseing TorsionTypes: line %d\n", lineNum );
1376 <          exit(8);
1377 <        }
1374 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1375 >            sprintf( painCave.errMsg,
1376 >                     "Error parseing TorsionTypes: line %d\n", lineNum );
1377 >            painCave.isFatal = 1;
1378 >            simError();
1379 >          }
1380  
1381 <        strcpy( currentTorsionType->nameC, the_token );
1381 >          strcpy( currentTorsionType->nameC, the_token );
1382  
1383 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1384 <          fprintf( stderr, "Error parseing TorsionTypes: line %d\n", lineNum );
1385 <          exit(8);
1386 <        }
1383 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1384 >            sprintf( painCave.errMsg,
1385 >                     "Error parseing TorsionTypes: line %d\n", lineNum );
1386 >            painCave.isFatal = 1;
1387 >            simError();
1388 >          }
1389  
1390 <        strcpy( currentTorsionType->nameD, the_token );
1390 >          strcpy( currentTorsionType->nameD, the_token );
1391  
1246        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1247          fprintf( stderr, "Error parseing TorsionTypes: line %d\n", lineNum );
1248          exit(8);
1249        }
1250
1251        strcpy( currentTorsionType->type, the_token );
1252
1253        if( !strcmp( currentTorsionType->type, "cubic" ) ){
1392            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1393 <            fprintf(stderr,"Error parseing TorsionTypes: line %d\n", lineNum );
1394 <            exit(8);
1393 >            sprintf( painCave.errMsg,
1394 >                     "Error parseing TorsionTypes: line %d\n", lineNum );
1395 >            painCave.isFatal = 1;
1396 >            simError();
1397            }
1398 +
1399 +          strcpy( currentTorsionType->type, the_token );
1400 +
1401 +          if( !strcmp( currentTorsionType->type, "cubic" ) ){
1402 +            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1403 +              sprintf( painCave.errMsg,
1404 +                       "Error parseing TorsionTypes: line %d\n", lineNum );
1405 +              painCave.isFatal = 1;
1406 +              simError();
1407 +            }
1408            
1409 <          sscanf( the_token, "%lf", &currentTorsionType->k1 );
1409 >            sscanf( the_token, "%lf", &currentTorsionType->k1 );
1410  
1411 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1412 <            fprintf(stderr,"Error parseing TorsionTypes: line %d\n", lineNum );
1413 <            exit(8);
1414 <          }
1411 >            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1412 >              sprintf( painCave.errMsg,
1413 >                       "Error parseing TorsionTypes: line %d\n", lineNum );
1414 >              painCave.isFatal = 1;
1415 >              simError();
1416 >            }
1417            
1418 <          sscanf( the_token, "%lf", &currentTorsionType->k2 );
1418 >            sscanf( the_token, "%lf", &currentTorsionType->k2 );
1419  
1420 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1421 <            fprintf(stderr,"Error parseing TorsionTypes: line %d\n", lineNum );
1422 <            exit(8);
1423 <          }
1420 >            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1421 >              sprintf( painCave.errMsg,
1422 >                       "Error parseing TorsionTypes: line %d\n", lineNum );
1423 >              painCave.isFatal = 1;
1424 >              simError();
1425 >            }
1426            
1427 <          sscanf( the_token, "%lf", &currentTorsionType->k3 );
1427 >            sscanf( the_token, "%lf", &currentTorsionType->k3 );
1428  
1429 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1430 <            fprintf(stderr,"Error parseing TorsionTypes: line %d\n", lineNum );
1431 <            exit(8);
1432 <          }
1429 >            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1430 >              sprintf( painCave.errMsg,
1431 >                       "Error parseing TorsionTypes: line %d\n", lineNum );
1432 >              painCave.isFatal = 1;
1433 >              simError();
1434 >            }
1435            
1436 <          sscanf( the_token, "%lf", &currentTorsionType->k4 );
1437 <        }
1436 >            sscanf( the_token, "%lf", &currentTorsionType->k4 );
1437 >          }
1438          
1439 <        else{
1440 <          fprintf(stderr,
1441 <                  "Unknown TraPPE_Ex torsion type \"%s\" at line %d\n",
1442 <                  currentTorsionType->type,
1443 <                  lineNum );
1444 <          exit(8);
1445 <        }                
1439 >          else{
1440 >            sprintf( painCave.errMsg,
1441 >                     "Unknown TraPPE_Ex torsion type \"%s\" at line %d\n",
1442 >                     currentTorsionType->type,
1443 >                     lineNum );
1444 >            painCave.isFatal = 1;
1445 >            simError();
1446 >          }              
1447 >        }
1448        }
1449 +    
1450 +      tempTorsionType = new LinkedType;
1451 +      currentTorsionType->next = tempTorsionType;
1452 +      currentTorsionType = tempTorsionType;
1453 +    
1454 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1455 +      lineNum++;
1456      }
1457 +
1458 + #ifdef IS_MPI
1459      
1460 <    tempTorsionType = new LinkedType;
1294 <    currentTorsionType->next = tempTorsionType;
1295 <    currentTorsionType = tempTorsionType;
1460 >    // send out the linked list to all the other processes
1461      
1462 <    eof_test = fgets( readLine, sizeof(readLine), frcFile );
1463 <    lineNum++;
1462 >    sprintf( checkPointMsg,
1463 >             "TraPPE_Ex torsion structures read successfully." );
1464 >    MPIcheckPoint();
1465 >    
1466 >    currentTorsionType = headTorsionType;
1467 >    while( currentTorsionType != NULL ){
1468 >      currentTorsionType->duplicate( info );
1469 >      sendFrcStruct( &info, mpiTorsionStructType );
1470 >      currentTorsionType = currentTorsionType->next;
1471 >    }
1472 >    info.last = 1;
1473 >    sendFrcStruct( &info, mpiTorsionStructType );
1474 >    
1475    }
1476  
1477 +  else{
1478 +    
1479 +    // listen for node 0 to send out the force params
1480 +    
1481 +    MPIcheckPoint();
1482 +
1483 +    headTorsionType = new LinkedType;
1484 +    recieveFrcStruct( &info, mpiTorsionStructType );
1485 +    while( !info.last ){
1486 +
1487 +      headTorsionType->add( info );
1488 +      recieveFrcStruct( &info, mpiTorsionStructType );
1489 +    }
1490 +  }
1491 + #endif // is_mpi
1492    
1493    // initialize the Torsions
1494  
# Line 1314 | Line 1505 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1505      atomD = the_atoms[d]->getType();
1506      currentTorsionType = headTorsionType->find( atomA, atomB, atomC, atomD );
1507      if( currentTorsionType == NULL ){
1508 <      fprintf( stderr, "TorsionType error, %s - %s - %s - %s not found"
1508 >      sprintf( painCave.errMsg,
1509 >               "TorsionType error, %s - %s - %s - %s not found"
1510                 " in force file.\n",
1511                 atomA, atomB, atomC, atomD );
1512 <      exit(8);
1512 >      painCave.isFatal = 1;
1513 >      simError();
1514      }
1515      
1516      if( !strcmp( currentTorsionType->type, "cubic" ) ){
# Line 1336 | Line 1529 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1529    
1530    delete headTorsionType;
1531  
1532 + #ifdef IS_MPI
1533 +  sprintf( checkPointMsg, "TraPPE_Ex torsions initialized succesfully" );
1534 +  MPIcheckPoint();
1535 + #endif // is_mpi
1536 +
1537   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines