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

Comparing trunk/OOPSE_old/src/mdtools/libmdCode/TraPPE_ExFF.cpp (file contents):
Revision 270 by mmeineke, Fri Feb 14 17:08:46 2003 UTC vs.
Revision 294 by mmeineke, Thu Mar 6 17:04:09 2003 UTC

# Line 9 | Line 9 | using namespace std;
9   #include "SRI.hpp"
10   #include "simError.h"
11  
12 + #include <fortranWrappers.hpp>
13  
14   #ifdef IS_MPI
14
15   #include "mpiForceField.h"
16 + #endif // is_mpi
17  
18 + namespace TPE {  // restrict the access of the folowing to this file only.
19  
18 // Declare the structures that will be passed by MPI
20  
21 < typedef struct{
22 <  char name[15];
23 <  double mass;
24 <  double epslon;
25 <  double sigma;
26 <  double dipole;
27 <  int isDipole;
28 <  int last;      //  0  -> default
29 <                 //  1  -> tells nodes to stop listening
30 < } atomStruct;
31 < MPI_Datatype mpiAtomStructType;
21 >  // Declare the structures that will be passed by MPI
22 >  
23 >  typedef struct{
24 >    char name[15];
25 >    double mass;
26 >    double epslon;
27 >    double sigma;
28 >    double dipole;
29 >    double w0;
30 >    double v0;
31 >    int isSSD;
32 >    int isDipole;
33 >    int ident;
34 >    int last;      //  0  -> default
35 >                   //  1  -> tells nodes to stop listening
36 >  } atomStruct;
37 >  
38 >  
39 >  typedef struct{
40 >    char nameA[15];
41 >    char nameB[15];
42 >    char type[30];
43 >    double d0;
44 >    int last;      //  0  -> default
45 >                   //  1  -> tells nodes to stop listening
46 >  } bondStruct;
47 >  
48 >  
49 >  typedef struct{
50 >    char nameA[15];
51 >    char nameB[15];
52 >    char nameC[15];
53 >    char type[30];
54 >    double k1, k2, k3, t0;
55 >    int last;      //  0  -> default
56 >                   //  1  -> tells nodes to stop listening
57 >  } bendStruct;
58 >  
59  
60 < typedef struct{
61 <  char nameA[15];
62 <  char nameB[15];
63 <  char type[30];
64 <  double d0;
65 <  int last;      //  0  -> default
66 <                 //  1  -> tells nodes to stop listening
67 < } bondStruct;
68 < MPI_Datatype mpiBondStructType;
69 <
70 < typedef struct{
71 <  char nameA[15];
72 <  char nameB[15];
73 <  char nameC[15];
74 <  char type[30];
75 <  double k1, k2, k3, t0;
76 <  int last;      //  0  -> default
77 <                 //  1  -> tells nodes to stop listening
78 < } bendStruct;
51 < MPI_Datatype mpiBendStructType;
60 >  typedef struct{
61 >    char nameA[15];
62 >    char nameB[15];
63 >    char nameC[15];
64 >    char nameD[15];
65 >    char type[30];
66 >    double k1, k2, k3, k4;
67 >    int last;      //  0  -> default
68 >                   //  1  -> tells nodes to stop listening
69 >  } torsionStruct;
70 >  
71 >  
72 >  int parseAtom(    char *lineBuffer, int lineNum, atomStruct     &info );
73 >  int parseBond(    char *lineBuffer, int lineNum, bondStruct     &info );
74 >  int parseBend(    char *lineBuffer, int lineNum, bendStruct     &info );
75 >  int parseTorsion( char *lineBuffer, int lineNum, torsionStruct  &info );
76 >  
77 >  
78 > #ifdef IS_MPI
79  
80 < typedef struct{
81 <  char nameA[15];
82 <  char nameB[15];
83 <  char nameC[15];
57 <  char nameD[15];
58 <  char type[30];
59 <  double k1, k2, k3, k4;
60 <  int last;      //  0  -> default
61 <                 //  1  -> tells nodes to stop listening
62 < } torsionStruct;
63 < MPI_Datatype mpiTorsionStructType;
80 >  MPI_Datatype mpiAtomStructType;
81 >  MPI_Datatype mpiBondStructType;
82 >  MPI_Datatype mpiBendStructType;
83 >  MPI_Datatype mpiTorsionStructType;
84  
85   #endif
86  
87 + } // namespace
88  
89 + using namespace TPE;
90  
91 +
92 + //****************************************************************
93 + // begins the actual forcefield stuff.  
94 + //****************************************************************
95 +
96 +
97   TraPPE_ExFF::TraPPE_ExFF(){
98  
99    char fileName[200];
# Line 74 | Line 102 | TraPPE_ExFF::TraPPE_ExFF(){
102    char temp[200];
103    char errMsg[1000];
104  
105 +  // do the funtion wrapping
106 +  wrapMeFF( this );
107 +
108 +
109   #ifdef IS_MPI
110    int i;
111    
112 <   // **********************************************************************
112 >  // **********************************************************************
113    // Init the atomStruct mpi type
114  
115    atomStruct atomProto; // mpiPrototype
116 <  int atomBC[3] = {15,4,2};  // block counts
116 >  int atomBC[3] = {15,6,4};  // block counts
117    MPI_Aint atomDspls[3];           // displacements
118    MPI_Datatype atomMbrTypes[3];    // member mpi types
119  
120    MPI_Address(&atomProto.name, &atomDspls[0]);
121    MPI_Address(&atomProto.mass, &atomDspls[1]);
122 <  MPI_Address(&atomProto.isDipole, &atomDspls[2]);
122 >  MPI_Address(&atomProto.isSSD, &atomDspls[2]);
123    
124    atomMbrTypes[0] = MPI_CHAR;
125    atomMbrTypes[1] = MPI_DOUBLE;
# Line 236 | Line 268 | TraPPE_ExFF::~TraPPE_ExFF(){
268    }
269   #endif // is_mpi
270   }
271 +
272  
273   void TraPPE_ExFF::initializeAtoms( void ){
274    
# Line 253 | Line 286 | void TraPPE_ExFF::initializeAtoms( void ){
286        return NULL;
287      }
288      
256 #ifdef IS_MPI
289      void add( atomStruct &info ){
290 +
291 +      // check for duplicates
292 +      
293 +      if( !strcmp( info.name, name ) ){
294 +        sprintf( painCave.errMsg,
295 +                 "Duplicate TraPPE_Ex atom type \"%s\" found in "
296 +                 "the TraPPE_ExFF param file./n",
297 +                 name );
298 +        painCave.isFatal = 1;
299 +        simError();
300 +      }
301 +
302        if( next != NULL ) next->add(info);
303        else{
304          next = new LinkedType();
305          strcpy(next->name, info.name);
306 <        next->isDipole = info.dipole;
306 >        next->isDipole = info.isDipole;
307 >        next->isSSD    = info.isSSD;
308          next->mass     = info.mass;
309          next->epslon   = info.epslon;
310          next->sigma    = info.sigma;
311          next->dipole   = info.dipole;
312 +        next->w0       = info.w0;
313 +        next->v0       = info.v0;
314 +        next->ident    = info.ident;
315        }
316      }
317 +
318 + #ifdef IS_MPI
319      
320      void duplicate( atomStruct &info ){
321        strcpy(info.name, name);
322 <      info.isDipole = dipole;
322 >      info.isDipole = isDipole;
323 >      info.isSSD    = isSSD;
324        info.mass     = mass;
325        info.epslon   = epslon;
326        info.sigma    = sigma;
327        info.dipole   = dipole;
328 +      info.w0       = w0;
329 +      info.v0       = v0;
330        info.last     = 0;
331      }
332  
# Line 282 | Line 335 | void TraPPE_ExFF::initializeAtoms( void ){
335  
336      char name[15];
337      int isDipole;
338 +    int isSSD;
339      double mass;
340      double epslon;
341      double sigma;
342      double dipole;
343 +    double w0;
344 +    double v0;
345 +    int ident;
346      LinkedType* next;
347    };
348    
349    LinkedType* headAtomType;
350    LinkedType* currentAtomType;
294  LinkedType* tempAtomType;
295
296 #ifdef IS_MPI
351    atomStruct info;
352    info.last = 1; // initialize last to have the last set.
353                   // if things go well, last will be set to 0
354 < #endif
354 >
355    
356  
303  char readLine[500];
304  char* the_token;
305  char* eof_test;
306  int foundAtom = 0;
307  int lineNum = 0;
357    int i;
358 <
358 >  int identNum;
359    
360 +  Atom** the_atoms;
361 +  int nAtoms;
362 +  the_atoms = entry_plug->atoms;
363 +  nAtoms = entry_plug->n_atoms;
364 +  
365 +  
366    //////////////////////////////////////////////////
367    // a quick water fix
368  
# Line 342 | Line 397 | void TraPPE_ExFF::initializeAtoms( void ){
397  
398    //////////////////////////////////////////////////
399  
400 <  Atom** the_atoms;
346 <  int nAtoms;
347 <  the_atoms = entry_plug->atoms;
348 <  nAtoms = entry_plug->n_atoms;
349 <  
350 <  
400 >
401   #ifdef IS_MPI
402    if( worldRank == 0 ){
403   #endif
404      
405      // read in the atom types.
406 <    
357 <    rewind( frcFile );
406 >
407      headAtomType = new LinkedType;
359    currentAtomType = headAtomType;
408      
409 <    eof_test = fgets( readLine, sizeof(readLine), frcFile );
410 <    lineNum++;
363 <    if( eof_test == NULL ){
364 <      sprintf( painCave.errMsg, "Error in reading Atoms from force file.\n" );
365 <      painCave.isFatal = 1;
366 <      simError();
367 <    }
368 <    
369 <    
370 <    while( !foundAtom ){
371 <      while( eof_test != NULL && readLine[0] != '#' ){
372 <        eof_test = fgets( readLine, sizeof(readLine), frcFile );
373 <        lineNum++;
374 <      }
375 <      if( eof_test == NULL ){
376 <        sprintf( painCave.errMsg,
377 <                 "Error in reading Atoms from force file at line %d.\n",
378 <                 lineNum );
379 <        painCave.isFatal = 1;
380 <        simError();
381 <      }
382 <      
383 <      the_token = strtok( readLine, " ,;\t#\n" );
384 <      foundAtom = !strcmp( "AtomTypes", the_token );
385 <      
386 <      if( !foundAtom ){
387 <        eof_test = fgets( readLine, sizeof(readLine), frcFile );
388 <        lineNum++;
389 <        
390 <        if( eof_test == NULL ){
391 <          sprintf( painCave.errMsg,
392 <                   "Error in reading Atoms from force file at line %d.\n",
393 <                   lineNum );
394 <          painCave.isFatal = 1;
395 <          simError();
396 <        }
397 <      }
398 <    }
399 <    
409 >    fastForward( "AtomTypes", "initializeAtoms" );
410 >
411      // we are now at the AtomTypes section.
412      
413      eof_test = fgets( readLine, sizeof(readLine), frcFile );
414      lineNum++;
415      
416 +    
417 +    // read a line, and start parseing out the atom types
418 +
419      if( eof_test == NULL ){
420        sprintf( painCave.errMsg,
421                 "Error in reading Atoms from force file at line %d.\n",
# Line 410 | Line 424 | void TraPPE_ExFF::initializeAtoms( void ){
424        simError();
425      }
426      
427 +    identNum = 1;
428 +    // stop reading at end of file, or at next section
429      while( readLine[0] != '#' && eof_test != NULL ){
430 <      
430 >
431 >      // toss comment lines
432        if( readLine[0] != '!' ){
433          
434 <        the_token = strtok( readLine, " \n\t,;" );
435 <        if( the_token != NULL ){
436 <          
437 <          strcpy( currentAtomType->name, the_token );
438 <          
422 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
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( 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( 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( 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( painCave.errMsg,
461 <                       "Error parseing AtomTypes: line %d\n",
462 <                       lineNum );
463 <              painCave.isFatal = 1;
464 <              simError();
465 <            }
466 <            
467 <            sscanf( the_token, "%lf", &currentAtomType->dipole );
468 <          }
434 >        // the parser returns 0 if the line was blank
435 >        if( parseAtom( readLine, lineNum, info ) ){
436 >          info.ident = identNum;
437 >          headAtomType->add( info );;
438 >          identNum++;
439          }
440        }
471      
472      tempAtomType = new LinkedType;
473      currentAtomType->next = tempAtomType;
474      currentAtomType = tempAtomType;
475      
441        eof_test = fgets( readLine, sizeof(readLine), frcFile );
442        lineNum++;
443      }
# Line 482 | Line 447 | void TraPPE_ExFF::initializeAtoms( void ){
447      // send out the linked list to all the other processes
448  
449      sprintf( checkPointMsg,
450 <             "TraPPE_Ex atom structures read successfully." );
450 >             "TraPPE_ExFF atom structures read successfully." );
451      MPIcheckPoint();
452  
453 <    currentAtomType = headAtomType;
453 >    currentAtomType = headAtomType->next; //skip the first element who is a place holder.
454      while( currentAtomType != NULL ){
455        currentAtomType->duplicate( info );
456 +
457 +
458 +
459        sendFrcStruct( &info, mpiAtomStructType );
460 +
461 +      sprintf( checkPointMsg,
462 +               "successfully sent TraPPE_Ex force type: \"%s\"\n",
463 +               info.name );
464 +      MPIcheckPoint();
465 +
466        currentAtomType = currentAtomType->next;
467      }
468      info.last = 1;
# Line 504 | Line 478 | void TraPPE_ExFF::initializeAtoms( void ){
478  
479      headAtomType = new LinkedType;
480      recieveFrcStruct( &info, mpiAtomStructType );
481 +    
482      while( !info.last ){
483  
484 +
485 +
486        headAtomType->add( info );
487 +      
488 +      MPIcheckPoint();
489 +
490        recieveFrcStruct( &info, mpiAtomStructType );
491 +    }
492 +  }
493 + #endif // is_mpi
494 +
495 +  // call new A_types in fortran
496 +  
497 +  int isError;
498 +  currentAtomType = headAtomType;
499 +  while( currentAtomType != NULL ){
500 +    
501 +    if( currentAtomType->name[0] != '\0' ){
502 +      isError = 0;
503 +          newTPEtype( &(currentAtomType->ident),
504 +                      &(currentAtomType->mass),
505 +                      &(currentAtomType->epslon),
506 +                      &(currentAtomType->sigma),
507 +                      &(currentAtomType->isDipole),
508 +                      &(currentAtomType->isSSD),
509 +                      &(currentAtomType->dipole),
510 +                      &(currentAtomType->w0),
511 +                      &(currentAtomType->v0),
512 +                      &isError );
513 +      if( isError ){
514 +        sprintf( painCave.errMsg,
515 +                 "Error initializing the \"%s\" atom type in fortran\n",
516 +                 currentAtomType->name );
517 +        painCave.isFatal = 1;
518 +        simError();
519 +      }
520      }
521 +    currentAtomType = currentAtomType->next;
522    }
523 +      
524 + #ifdef IS_MPI
525 +  sprintf( checkPointMsg,
526 +           "TraPPE_ExFF atom structures successfully sent to fortran\n" );
527 +  MPIcheckPoint();
528   #endif // is_mpi
529  
530    
531    // initialize the atoms
532    
533 +  double bigSigma = 0.0;
534    DirectionalAtom* dAtom;
535  
536    for( i=0; i<nAtoms; i++ ){
# Line 533 | Line 549 | void TraPPE_ExFF::initializeAtoms( void ){
549      the_atoms[i]->setSigma( currentAtomType->sigma );
550      the_atoms[i]->setLJ();
551  
552 +    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
553 +
554      if( currentAtomType->isDipole ){
555        if( the_atoms[i]->isDirectional() ){
556          
# Line 582 | Line 600 | void TraPPE_ExFF::initializeAtoms( void ){
600      }
601    }
602  
603 + #ifdef IS_MPI
604 +  double tempBig = bigSigma;
605 +  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
606 + #endif  //is_mpi
607  
608 +  //calc rCut and rList
609 +
610 +  entry_plug->rCut = 2.5 * bigSigma;
611 +  
612 +  if(entry_plug->rCut > (entry_plug->box_x / 2.0))
613 +    entry_plug->rCut = entry_plug->box_x / 2.0;
614 +  
615 +  if(entry_plug->rCut > (entry_plug->box_y / 2.0))
616 +    entry_plug->rCut = entry_plug->box_y / 2.0;
617 +  
618 +  if(entry_plug->rCut > (entry_plug->box_z / 2.0))
619 +    entry_plug->rCut = entry_plug->box_z / 2.0;
620 +
621 +  entry_plug->rList = entry_plug->rCut + 1.0;
622 +
623 +
624    // clean up the memory
625    
626    delete headAtomType;
# Line 613 | Line 651 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
651        return NULL;
652      }
653      
654 < #ifdef IS_MPI
654 >
655      void add( bondStruct &info ){
656 +      
657 +      // check for duplicates
658 +      int dup = 0;
659 +
660 +      if( !strcmp(nameA, info.nameA ) && !strcmp( nameB, info.nameB ) ) dup = 1;
661 +      if( !strcmp(nameA, info.nameB ) && !strcmp( nameB, info.nameA ) ) dup = 1;
662 +      
663 +      if(dup){
664 +        sprintf( painCave.errMsg,
665 +                 "Duplicate TraPPE_Ex bond type \"%s - %s\" found in "
666 +                 "the TraPPE_ExFF param file./n",
667 +                 nameA, nameB );
668 +        painCave.isFatal = 1;
669 +        simError();
670 +      }
671 +
672 +        
673        if( next != NULL ) next->add(info);
674        else{
675          next = new LinkedType();
# Line 625 | Line 680 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
680        }
681      }
682      
683 + #ifdef IS_MPI
684      void duplicate( bondStruct &info ){
685        strcpy(info.nameA, nameA);
686        strcpy(info.nameB, nameB);
# Line 648 | Line 704 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
704    
705    LinkedType* headBondType;
706    LinkedType* currentBondType;
651  LinkedType* tempBondType;
652
653 #ifdef IS_MPI
707    bondStruct info;
708    info.last = 1; // initialize last to have the last set.
709                   // if things go well, last will be set to 0
657 #endif
710  
659  char readLine[500];
660  char* the_token;
661  char* eof_test;
662  int foundBond = 0;
663  int lineNum = 0;
664  int i, a, b;
665  char* atomA;
666  char* atomB;
667
711    SRI **the_sris;
712    Atom** the_atoms;
713    int nBonds;
# Line 672 | Line 715 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
715    the_atoms = entry_plug->atoms;
716    nBonds = entry_plug->n_bonds;
717  
718 +  int i, a, b;
719 +  char* atomA;
720 +  char* atomB;
721    
722   #ifdef IS_MPI
723    if( worldRank == 0 ){
# Line 679 | Line 725 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
725      
726      // read in the bond types.
727      
682    rewind( frcFile );
728      headBondType = new LinkedType;
684    currentBondType = headBondType;
729      
730 <    eof_test = fgets( readLine, sizeof(readLine), frcFile );
730 >    fastForward( "BondTypes", "initializeBonds" );
731 >
732 >    // we are now at the bondTypes section
733 >
734 >    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
735      lineNum++;
688    if( eof_test == NULL ){
689      sprintf( painCave.errMsg, "Error in reading Bonds from force file.\n" );
690      painCave.isFatal = 1;
691      simError();
692    }
736      
737      
738 <    while( !foundBond ){
739 <      while( eof_test != NULL && readLine[0] != '#' ){
697 <        eof_test = fgets( readLine, sizeof(readLine), frcFile );
698 <        lineNum++;
699 <      }
700 <      if( eof_test == NULL ){
701 <        sprintf( painCave.errMsg,
702 <                 "Error in reading Bonds from force file at line %d.\n",
703 <                 lineNum );
704 <        painCave.isFatal = 1;
705 <        simError();
706 <      }
707 <      
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 <        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 <    
738 >    // read a line, and start parseing out the atom types
739 >
740      if( eof_test == NULL ){
741        sprintf( painCave.errMsg,
742 <               "Error in reading Bonds from force file at line %d.\n",
742 >               "Error in reading bonds from force file at line %d.\n",
743                 lineNum );
744        painCave.isFatal = 1;
745        simError();
746      }
747      
748 +    // stop reading at end of file, or at next section
749      while( readLine[0] != '#' && eof_test != NULL ){
750 <      
750 >
751 >      // toss comment lines
752        if( readLine[0] != '!' ){
753          
754 <        the_token = strtok( readLine, " \n\t,;" );
755 <        if( the_token != NULL ){
756 <          
745 <          strcpy( currentBondType->nameA, the_token );
746 <          
747 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
748 <            sprintf( painCave.errMsg,
749 <                     "Error parseing BondTypes: line %d\n", lineNum );
750 <            painCave.isFatal = 1;
751 <            simError();
752 <          }
753 <          
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 <          }              
754 >        // the parser returns 0 if the line was blank
755 >        if( parseBond( readLine, lineNum, info ) ){
756 >          headBondType->add( info );
757          }
758        }
786      
787      tempBondType = new LinkedType;
788      currentBondType->next = tempBondType;
789      currentBondType = tempBondType;
790      
759        eof_test = fgets( readLine, sizeof(readLine), frcFile );
760        lineNum++;
761      }
762 <    
762 >        
763   #ifdef IS_MPI
764      
765      // send out the linked list to all the other processes
# Line 890 | Line 858 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
858        return NULL;
859      }
860      
893 #ifdef IS_MPI
894
861      void add( bendStruct &info ){
862 +
863 +      // check for duplicates
864 +      int dup = 0;
865 +      
866 +      if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB )
867 +          && !strcmp( nameC, info.nameC ) ) dup = 1;
868 +      if( !strcmp( nameA, info.nameC ) && !strcmp( nameB, info.nameB )
869 +          && !strcmp( nameC, info.nameA ) ) dup = 1;
870 +
871 +      if(dup){
872 +        sprintf( painCave.errMsg,
873 +                 "Duplicate TraPPE_Ex bend type \"%s - %s - %s\" found in "
874 +                 "the TraPPE_ExFF param file./n",
875 +                 nameA, nameB, nameC );
876 +        painCave.isFatal = 1;
877 +        simError();
878 +      }
879 +
880        if( next != NULL ) next->add(info);
881        else{
882          next = new LinkedType();
# Line 906 | Line 890 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
890          next->t0 = info.t0;
891        }
892      }
893 <    
893 >
894 > #ifdef IS_MPI    
895 >
896      void duplicate( bendStruct &info ){
897        strcpy(info.nameA, nameA);
898        strcpy(info.nameB, nameB);
# Line 932 | Line 918 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
918    
919    LinkedType* headBendType;
920    LinkedType* currentBendType;
935  LinkedType* tempBendType;
936
937 #ifdef IS_MPI
921    bendStruct info;
922    info.last = 1; // initialize last to have the last set.
923                   // if things go well, last will be set to 0
941 #endif
924  
943  char readLine[500];
944  char* the_token;
945  char* eof_test;
946  int foundBend = 0;
947  int lineNum = 0;
948  int i, a, b, c, index;
949  char* atomA;
950  char* atomB;
951  char* atomC;
925    QuadraticBend* qBend;
953
926    SRI **the_sris;
927    Atom** the_atoms;
928    int nBends;
# Line 958 | Line 930 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
930    the_atoms = entry_plug->atoms;
931    nBends = entry_plug->n_bends;
932  
933 +  int i, a, b, c;
934 +  char* atomA;
935 +  char* atomB;
936 +  char* atomC;
937  
938 +
939   #ifdef IS_MPI
940    if( worldRank == 0 ){
941   #endif
942  
943      // read in the bend types.
944  
968    rewind( frcFile );
945      headBendType = new LinkedType;
970    currentBendType = headBendType;
971  
972    eof_test = fgets( readLine, sizeof(readLine), frcFile );
973    lineNum++;
974    if( eof_test == NULL ){
975      sprintf( painCave.errMsg, "Error in reading Bends from force file.\n" );
976      painCave.isFatal = 1;
977      simError();
978    }
979
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        sprintf( painCave.errMsg,
988                 "Error in reading Bends from force file at line %d.\n",
989                 lineNum );
990        painCave.isFatal = 1;
991        simError();
992      }
993
994      the_token = strtok( readLine, " ,;\t#\n" );
995      foundBend = !strcmp( "BendTypes", the_token );
946      
947 <      if( !foundBend ){
998 <        eof_test = fgets( readLine, sizeof(readLine), frcFile );
999 <        lineNum++;
947 >    fastForward( "BendTypes", "initializeBends" );
948  
949 <        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 <    }
949 >    // we are now at the bendTypes section
950  
951 <    // we are now at the BendTypes section.
1012 <
1013 <    eof_test = fgets( readLine, sizeof(readLine), frcFile );
951 >    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
952      lineNum++;
953 <  
953 >        
954 >    // read a line, and start parseing out the bend types
955 >
956      if( eof_test == NULL ){
957        sprintf( painCave.errMsg,
958 <               "Error in reading Bends from force file at line %d.\n",
958 >               "Error in reading bends from force file at line %d.\n",
959                 lineNum );
960        painCave.isFatal = 1;
961        simError();
962      }
1023
1024    while( readLine[0] != '#' && eof_test != NULL ){
963      
964 <      if( readLine[0] != '!' ){
964 >    // stop reading at end of file, or at next section
965 >    while( readLine[0] != '#' && eof_test != NULL ){
966        
967 <        the_token = strtok( readLine, " \n\t,;" );
968 <        if( the_token != NULL ){
967 >      // toss comment lines
968 >      if( readLine[0] != '!' ){
969          
970 <          strcpy( currentBendType->nameA, the_token );
971 <        
972 <          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 );
1041 <
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 );
1050 <
1051 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
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 );
1069 <
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 );
1078 <
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 );
1087 <
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 <          }
1097 <        
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 <          }              
970 >        // the parser returns 0 if the line was blank
971 >        if( parseBend( readLine, lineNum, info ) ){
972 >          headBendType->add( info );
973          }
974        }
1108    
1109      tempBendType = new LinkedType;
1110      currentBendType->next = tempBendType;
1111      currentBendType = tempBendType;
1112    
975        eof_test = fgets( readLine, sizeof(readLine), frcFile );
976        lineNum++;
977      }
978 <
978 >    
979   #ifdef IS_MPI
980      
981      // send out the linked list to all the other processes
# Line 1150 | Line 1012 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1012   #endif // is_mpi
1013    
1014    // initialize the Bends
1015 +  
1016 +  int index;
1017  
1018    for( i=0; i<nBends; i++ ){
1019      
# Line 1213 | Line 1077 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1077            !strcmp( nameC, key3 ) && !strcmp( nameD, key4 ) ) return this;
1078  
1079        if( !strcmp( nameA, key4 ) && !strcmp( nameB, key3 ) &&
1080 <          !strcmp( nameC, key2 ) && !strcmp( nameD, key4 ) ) return this;
1080 >          !strcmp( nameC, key2 ) && !strcmp( nameD, key1 ) ) return this;
1081  
1082        if( next != NULL ) return next->find(key1, key2, key3, key4);
1083        return NULL;
1084      }
1221    
1222 #ifdef IS_MPI
1085  
1086      void add( torsionStruct &info ){
1087 +
1088 +      // check for duplicates
1089 +      int dup = 0;
1090 +
1091 +      if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB ) &&
1092 +          !strcmp( nameC, info.nameC ) && !strcmp( nameD, info.nameD ) ) dup = 1;
1093 +      
1094 +      if( !strcmp( nameA, info.nameD ) && !strcmp( nameB, info.nameC ) &&
1095 +          !strcmp( nameC, info.nameB ) && !strcmp( nameD, info.nameA ) ) dup = 1;
1096 +      
1097 +      if(dup){
1098 +        sprintf( painCave.errMsg,
1099 +                 "Duplicate TraPPE_Ex torsion type \"%s - %s - %s - %s\" found in "
1100 +                 "the TraPPE_ExFF param file./n", nameA, nameB, nameC, nameD );
1101 +        painCave.isFatal = 1;
1102 +        simError();
1103 +      }
1104 +
1105        if( next != NULL ) next->add(info);
1106        else{
1107          next = new LinkedType();
# Line 1235 | Line 1115 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1115          next->k4 = info.k4;
1116        }
1117      }
1118 +
1119 + #ifdef IS_MPI
1120      
1121      void duplicate( torsionStruct &info ){
1122        strcpy(info.nameA, nameA);
# Line 1263 | Line 1145 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1145    
1146    LinkedType* headTorsionType;
1147    LinkedType* currentTorsionType;
1266  LinkedType* tempTorsionType;
1267
1268 #ifdef IS_MPI
1148    torsionStruct info;
1149    info.last = 1; // initialize last to have the last set.
1150                   // if things go well, last will be set to 0
1272 #endif
1151  
1274  char readLine[500];
1275  char* the_token;
1276  char* eof_test;
1277  int foundTorsion = 0;
1278  int lineNum = 0;
1152    int i, a, b, c, d, index;
1153    char* atomA;
1154    char* atomB;
# Line 1296 | Line 1169 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1169  
1170      // read in the torsion types.
1171  
1299    rewind( frcFile );
1172      headTorsionType = new LinkedType;
1301    currentTorsionType = headTorsionType;
1302  
1303    eof_test = fgets( readLine, sizeof(readLine), frcFile );
1304    lineNum++;
1305    if( eof_test == NULL ){
1306      sprintf( painCave.errMsg,
1307               "Error in reading Torsions from force file.\n" );
1308      painCave.isFatal = 1;
1309      simError();
1310    }
1311
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        sprintf( painCave.errMsg,
1320                 "Error in reading Torsions from force file at line %d.\n",
1321                 lineNum );
1322        painCave.isFatal = 1;
1323        simError();
1324      }
1325
1326      the_token = strtok( readLine, " ,;\t#\n" );
1327      foundTorsion = !strcmp( "TorsionTypes", the_token );
1173      
1174 <      if( !foundTorsion ){
1330 <        eof_test = fgets( readLine, sizeof(readLine), frcFile );
1331 <        lineNum++;
1174 >    fastForward( "TorsionTypes", "initializeTorsions" );
1175  
1176 <        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 <    }
1176 >    // we are now at the torsionTypes section
1177  
1178 <    // we are now at the TorsionTypes section.
1344 <
1345 <    eof_test = fgets( readLine, sizeof(readLine), frcFile );
1178 >    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
1179      lineNum++;
1180 <  
1180 >    
1181 >    
1182 >    // read a line, and start parseing out the atom types
1183 >
1184      if( eof_test == NULL ){
1185        sprintf( painCave.errMsg,
1186 <               "Error in reading Torsions from force file at line %d.\n",
1186 >               "Error in reading torsions from force file at line %d.\n",
1187                 lineNum );
1188        painCave.isFatal = 1;
1189        simError();
1190      }
1355
1356    while( readLine[0] != '#' && eof_test != NULL ){
1191      
1192 +    // stop reading at end of file, or at next section
1193 +    while( readLine[0] != '#' && eof_test != NULL ){
1194 +
1195 +      // toss comment lines
1196        if( readLine[0] != '!' ){
1359      
1360        the_token = strtok( readLine, " \n\t,;" );
1361        if( the_token != NULL ){
1197          
1198 <          strcpy( currentTorsionType->nameA, the_token );
1199 <        
1200 <          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 );
1373 <
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 );
1382 <
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 );
1391 <
1392 <          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
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 );
1410 <
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 );
1419 <
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 );
1428 <
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 <          }
1438 <        
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 <          }              
1198 >        // the parser returns 0 if the line was blank
1199 >        if( parseTorsion( readLine, lineNum, info ) ){
1200 >          headTorsionType->add( info );
1201          }
1202        }
1449    
1450      tempTorsionType = new LinkedType;
1451      currentTorsionType->next = tempTorsionType;
1452      currentTorsionType = tempTorsionType;
1453    
1203        eof_test = fgets( readLine, sizeof(readLine), frcFile );
1204        lineNum++;
1205      }
# Line 1533 | Line 1282 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1282    sprintf( checkPointMsg, "TraPPE_Ex torsions initialized succesfully" );
1283    MPIcheckPoint();
1284   #endif // is_mpi
1285 +
1286 + }
1287 +
1288 + void TraPPE_ExFF::fastForward( char* stopText, char* searchOwner ){
1289 +
1290 +  int foundText = 0;
1291 +  char* the_token;
1292 +
1293 +  rewind( frcFile );
1294 +  lineNum = 0;
1295 +
1296 +  eof_test = fgets( readLine, sizeof(readLine), frcFile );
1297 +  lineNum++;
1298 +  if( eof_test == NULL ){
1299 +    sprintf( painCave.errMsg, "Error fast forwarding force file for %s: "
1300 +             " file is empty.\n",
1301 +             searchOwner );
1302 +    painCave.isFatal = 1;
1303 +    simError();
1304 +  }
1305 +  
1306 +  
1307 +  while( !foundText ){
1308 +    while( eof_test != NULL && readLine[0] != '#' ){
1309 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1310 +      lineNum++;
1311 +    }
1312 +    if( eof_test == NULL ){
1313 +      sprintf( painCave.errMsg,
1314 +               "Error fast forwarding force file for %s at "
1315 +               "line %d: file ended unexpectedly.\n",
1316 +               searchOwner,
1317 +               lineNum );
1318 +      painCave.isFatal = 1;
1319 +      simError();
1320 +    }
1321 +    
1322 +    the_token = strtok( readLine, " ,;\t#\n" );
1323 +    foundText = !strcmp( stopText, the_token );
1324 +    
1325 +    if( !foundText ){
1326 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1327 +      lineNum++;
1328 +      
1329 +      if( eof_test == NULL ){
1330 +        sprintf( painCave.errMsg,
1331 +                 "Error fast forwarding force file for %s at "
1332 +                 "line %d: file ended unexpectedly.\n",
1333 +                 searchOwner,
1334 +                 lineNum );
1335 +        painCave.isFatal = 1;
1336 +        simError();
1337 +      }
1338 +    }
1339 +  }  
1340 + }
1341 +
1342 +
1343 + int parseAtom( char *lineBuffer, int lineNum, atomStruct &info ){
1344 +
1345 +  char* the_token;
1346 +  
1347 +  the_token = strtok( lineBuffer, " \n\t,;" );
1348 +  if( the_token != NULL ){
1349 +    
1350 +    strcpy( info.name, the_token );
1351 +
1352 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1353 +      sprintf( painCave.errMsg,
1354 +               "Error parseing AtomTypes: line %d\n", lineNum );
1355 +      painCave.isFatal = 1;
1356 +      simError();
1357 +    }
1358 +    
1359 +    info.isDipole = atoi( the_token );
1360  
1361 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1362 +      sprintf( painCave.errMsg,
1363 +               "Error parseing AtomTypes: line %d\n", lineNum );
1364 +      painCave.isFatal = 1;
1365 +      simError();
1366 +    }
1367 +
1368 +    info.isSSD = atoi( the_token );
1369 +
1370 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1371 +      sprintf( painCave.errMsg,
1372 +               "Error parseing AtomTypes: line %d\n", lineNum );
1373 +      painCave.isFatal = 1;
1374 +      simError();
1375 +    }
1376 +    
1377 +    info.mass = atof( the_token );
1378 +    
1379 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1380 +      sprintf( painCave.errMsg,
1381 +               "Error parseing AtomTypes: line %d\n", lineNum );
1382 +      painCave.isFatal = 1;
1383 +      simError();
1384 +    }
1385 +        
1386 +    info.epslon = atof( the_token );
1387 +          
1388 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1389 +      sprintf( painCave.errMsg,
1390 +               "Error parseing AtomTypes: line %d\n", lineNum );
1391 +      painCave.isFatal = 1;
1392 +      simError();
1393 +    }
1394 +        
1395 +    info.sigma = atof( the_token );
1396 +
1397 +    if( info.isDipole ){
1398 +      
1399 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1400 +        sprintf( painCave.errMsg,
1401 +                 "Error parseing AtomTypes: line %d\n", lineNum );
1402 +        painCave.isFatal = 1;
1403 +        simError();
1404 +      }
1405 +      
1406 +      info.dipole = atof( the_token );
1407 +    }
1408 +    else info.dipole = 0.0;
1409 +
1410 +    if( info.isSSD ){
1411 +
1412 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1413 +        sprintf( painCave.errMsg,
1414 +                 "Error parseing AtomTypes: line %d\n", lineNum );
1415 +        painCave.isFatal = 1;
1416 +        simError();
1417 +      }
1418 +      
1419 +      info.w0 = atof( the_token );
1420 +
1421 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1422 +        sprintf( painCave.errMsg,
1423 +                 "Error parseing AtomTypes: line %d\n", lineNum );
1424 +        painCave.isFatal = 1;
1425 +        simError();
1426 +      }
1427 +      
1428 +      info.v0 = atof( the_token );
1429 +    }
1430 +    else info.v0 = info.w0 = 0.0;
1431 +
1432 +    return 1;
1433 +  }
1434 +  else return 0;
1435   }
1436 +
1437 + int parseBond( char *lineBuffer, int lineNum, bondStruct &info ){
1438 +
1439 +  char* the_token;
1440 +  
1441 +  the_token = strtok( lineBuffer, " \n\t,;" );
1442 +  if( the_token != NULL ){
1443 +    
1444 +    strcpy( info.nameA, the_token );
1445 +
1446 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1447 +      sprintf( painCave.errMsg,
1448 +               "Error parseing BondTypes: line %d\n", lineNum );
1449 +      painCave.isFatal = 1;
1450 +      simError();
1451 +    }
1452 +    
1453 +    strcpy( info.nameB, the_token );
1454 +
1455 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1456 +      sprintf( painCave.errMsg,
1457 +               "Error parseing BondTypes: line %d\n", lineNum );
1458 +      painCave.isFatal = 1;
1459 +      simError();
1460 +    }
1461 +    
1462 +    strcpy( info.type, the_token );
1463 +    
1464 +    if( !strcmp( info.type, "fixed" ) ){
1465 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1466 +        sprintf( painCave.errMsg,
1467 +                 "Error parseing BondTypes: line %d\n", lineNum );
1468 +        painCave.isFatal = 1;
1469 +        simError();
1470 +      }
1471 +      
1472 +      info.d0 = atof( the_token );
1473 +    }
1474 +    else{
1475 +      sprintf( painCave.errMsg,
1476 +               "Unknown TraPPE_Ex bond type \"%s\" at line %d\n",
1477 +               info.type,
1478 +               lineNum );
1479 +      painCave.isFatal = 1;
1480 +      simError();
1481 +    }            
1482 +    
1483 +    return 1;
1484 +  }
1485 +  else return 0;
1486 + }
1487 +
1488 +
1489 + int parseBend( char *lineBuffer, int lineNum, bendStruct &info ){
1490 +
1491 +  char* the_token;
1492 +  
1493 +  the_token = strtok( lineBuffer, " \n\t,;" );
1494 +  if( the_token != NULL ){
1495 +    
1496 +    strcpy( info.nameA, the_token );
1497 +
1498 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1499 +      sprintf( painCave.errMsg,
1500 +               "Error parseing BondTypes: line %d\n", lineNum );
1501 +      painCave.isFatal = 1;
1502 +      simError();
1503 +    }
1504 +    
1505 +    strcpy( info.nameB, the_token );
1506 +
1507 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1508 +      sprintf( painCave.errMsg,
1509 +               "Error parseing BondTypes: line %d\n", lineNum );
1510 +      painCave.isFatal = 1;
1511 +      simError();
1512 +    }
1513 +    
1514 +    strcpy( info.nameC, the_token );
1515 +
1516 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1517 +      sprintf( painCave.errMsg,
1518 +               "Error parseing BondTypes: line %d\n", lineNum );
1519 +      painCave.isFatal = 1;
1520 +      simError();
1521 +    }
1522 +    
1523 +    strcpy( info.type, the_token );
1524 +
1525 +    if( !strcmp( info.type, "quadratic" ) ){
1526 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1527 +        sprintf( painCave.errMsg,
1528 +                 "Error parseing BendTypes: line %d\n", lineNum );
1529 +        painCave.isFatal = 1;
1530 +        simError();
1531 +      }
1532 +        
1533 +      info.k1 = atof( the_token );
1534 +      
1535 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1536 +        sprintf( painCave.errMsg,
1537 +                 "Error parseing BendTypes: line %d\n", lineNum );
1538 +        painCave.isFatal = 1;
1539 +        simError();
1540 +      }
1541 +      
1542 +      info.k2 = atof( the_token );
1543 +      
1544 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1545 +        sprintf( painCave.errMsg,
1546 +                 "Error parseing BendTypes: line %d\n", lineNum );
1547 +        painCave.isFatal = 1;
1548 +        simError();
1549 +      }
1550 +        
1551 +      info.k3 = atof( the_token );
1552 +      
1553 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1554 +        sprintf( painCave.errMsg,
1555 +                 "Error parseing BendTypes: line %d\n", lineNum );
1556 +        painCave.isFatal = 1;
1557 +        simError();
1558 +      }
1559 +      
1560 +      info.t0 = atof( the_token );
1561 +    }
1562 +    
1563 +    else{
1564 +      sprintf( painCave.errMsg,
1565 +               "Unknown TraPPE_Ex bend type \"%s\" at line %d\n",
1566 +               info.type,
1567 +               lineNum );
1568 +      painCave.isFatal = 1;
1569 +      simError();
1570 +    }            
1571 +        
1572 +    return 1;
1573 +  }
1574 +  else return 0;
1575 + }
1576 +
1577 + int parseTorsion( char *lineBuffer, int lineNum, torsionStruct &info ){
1578 +  
1579 +  char*  the_token;
1580 +
1581 +  the_token = strtok( lineBuffer, " \n\t,;" );
1582 +  if( the_token != NULL ){
1583 +    
1584 +    strcpy( info.nameA, the_token );
1585 +        
1586 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1587 +      sprintf( painCave.errMsg,
1588 +               "Error parseing TorsionTypes: line %d\n", lineNum );
1589 +      painCave.isFatal = 1;
1590 +      simError();
1591 +    }
1592 +    
1593 +    strcpy( info.nameB, the_token );
1594 +
1595 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1596 +      sprintf( painCave.errMsg,
1597 +               "Error parseing TorsionTypes: line %d\n", lineNum );
1598 +      painCave.isFatal = 1;
1599 +      simError();
1600 +    }
1601 +    
1602 +    strcpy( info.nameC, the_token );
1603 +    
1604 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1605 +      sprintf( painCave.errMsg,
1606 +               "Error parseing TorsionTypes: line %d\n", lineNum );
1607 +      painCave.isFatal = 1;
1608 +      simError();
1609 +    }
1610 +    
1611 +    strcpy( info.nameD, the_token );
1612 +    
1613 +    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1614 +      sprintf( painCave.errMsg,
1615 +               "Error parseing TorsionTypes: line %d\n", lineNum );
1616 +      painCave.isFatal = 1;
1617 +      simError();
1618 +    }
1619 +    
1620 +    strcpy( info.type, the_token );
1621 +    
1622 +    if( !strcmp( info.type, "cubic" ) ){
1623 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1624 +        sprintf( painCave.errMsg,
1625 +                 "Error parseing TorsionTypes: line %d\n", lineNum );
1626 +        painCave.isFatal = 1;
1627 +        simError();
1628 +      }
1629 +      
1630 +      info.k1 = atof( the_token );
1631 +      
1632 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1633 +        sprintf( painCave.errMsg,
1634 +                 "Error parseing TorsionTypes: line %d\n", lineNum );
1635 +        painCave.isFatal = 1;
1636 +        simError();
1637 +      }
1638 +      
1639 +      info.k2 = atof( the_token );
1640 +      
1641 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1642 +        sprintf( painCave.errMsg,
1643 +                 "Error parseing TorsionTypes: line %d\n", lineNum );
1644 +        painCave.isFatal = 1;
1645 +        simError();
1646 +      }
1647 +      
1648 +      info.k3 = atof( the_token );
1649 +      
1650 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1651 +        sprintf( painCave.errMsg,
1652 +                 "Error parseing TorsionTypes: line %d\n", lineNum );
1653 +        painCave.isFatal = 1;
1654 +        simError();
1655 +      }
1656 +      
1657 +      info.k4 = atof( the_token );
1658 +    
1659 +    }
1660 +    
1661 +    else{
1662 +      sprintf( painCave.errMsg,
1663 +               "Unknown TraPPE_Ex torsion type \"%s\" at line %d\n",
1664 +               info.type,
1665 +               lineNum );
1666 +      painCave.isFatal = 1;
1667 +      simError();
1668 +    }            
1669 +    
1670 +    return 1;
1671 +  }
1672 +  
1673 +  else return 0;
1674 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines