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

Comparing trunk/mdtools/interface_implementation/Globals.cpp (file contents):
Revision 11 by mmeineke, Tue Jul 9 18:40:59 2002 UTC vs.
Revision 282 by chuckv, Mon Feb 24 21:26:54 2003 UTC

# Line 3 | Line 3
3   #include <cstring>
4  
5   #include "Globals.hpp"
6 + #include "simError.h"
7 + #ifdef IS_MPI
8 + #include "mpiBASS.h"
9 + #endif // is_mpi
10  
11   /*
12   * The following section lists all of the defined tokens for the
# Line 35 | Line 39
39   #define G_DIELECTRIC    18
40   #define G_TEMPSET       19
41   #define G_THERMALTIME   20
42 + #define G_USEPBC 21
43 + #define G_MIXINGRULE 22
44  
45  
46   Globals::Globals(){
# Line 50 | Line 56 | Globals::Globals(){
56    addHash( "nComponents",   G_NCOMPONENTS );
57    addHash( "targetTemp",    G_TARGETTEMP );
58    addHash( "ensemble",      G_ENSEMBLE );
59 +
60    addHash( "dt",            G_DT );
61    addHash( "runTime",       G_RUNTIME );
62  
# Line 67 | Line 74 | Globals::Globals(){
74    addHash( "dielectric",    G_DIELECTRIC );
75    addHash( "tempSet",       G_TEMPSET );
76    addHash( "thermalTime",   G_THERMALTIME );
77 +  addHash("mixingRule", G_MIXINGRULE);
78 +  mixingRule = "standard"; //default mixing rules to standard.
79 +  addHash("periodicBoundryConditions", G_USEPBC);
80 +  usePBC = 1; //default  periodic boundry conditions to on
81 +  
82  
83    have_force_field =  0;
84    have_n_components = 0;
# Line 90 | Line 102 | Globals::Globals(){
102    have_rrf =            0;
103    have_dielectric =     0;
104    have_tempSet =        0;
105 < }
105 > }
106  
107   Globals::~Globals(){
108    int i;
# Line 138 | Line 150 | int Globals::componentAssign( event* the_event ){
150    switch( the_event->evt.asmt.asmt_type ){
151      
152    case STRING:
153 <    current_component->assignString( the_event->evt.asmt.lhs,
154 <                                     the_event->evt.asmt.rhs.sval );
155 <    return 1;
153 >    return current_component->assignString( the_event->evt.asmt.lhs,
154 >                                            the_event->evt.asmt.rhs.sval,
155 >                                            &(the_event->err_msg));
156      break;
157      
158    case DOUBLE:
159 <    current_component->assignDouble( the_event->evt.asmt.lhs,
160 <                                     the_event->evt.asmt.rhs.dval );
161 <    return 1;
159 >    return current_component->assignDouble( the_event->evt.asmt.lhs,
160 >                                            the_event->evt.asmt.rhs.dval,
161 >                                            &(the_event->err_msg));
162      break;
163      
164    case INT:
165 <    current_component->assignInt( the_event->evt.asmt.lhs,
166 <                                  the_event->evt.asmt.rhs.ival );
167 <    return 1;
165 >    return current_component->assignInt( the_event->evt.asmt.lhs,
166 >                                         the_event->evt.asmt.rhs.ival,
167 >                                         &(the_event->err_msg));
168      break;
169      
170    default:
# Line 269 | Line 281 | int Globals::globalAssign( event* the_event ){
281          strdup( "Global error. ensemble was not assigned to a string\n" );
282        return 0;
283        break;      
284 +
285 +    case G_MIXINGRULE:
286 +      if( the_type == STRING ){
287 +        strcpy( mixingRule, the_event->evt.asmt.rhs.sval );
288 +        return 1;
289 +      }
290        
291 +      the_event->err_msg =
292 +        strdup( "Global error. mixing rule was not assigned to a string\n" );
293 +      return 0;
294 +      break;      
295 +      
296      case G_DT:
297        switch( the_type ){
298          
# Line 689 | Line 712 | int Globals::globalAssign( event* the_event ){
712          strdup( "Global error. tempSet was not \"true\" or \"false\".\n" );
713        return 0;
714        break;
715 +      
716 +    case G_USEPBC:
717 +      if( the_type == STRING ){
718 +        
719 +        if( !strcmp( "true", the_event->evt.asmt.rhs.sval )) usePBC = 1;
720 +        else if( !strcmp( "false", the_event->evt.asmt.rhs.sval )) usePBC = 0;
721 +        else{
722 +          the_event->err_msg =
723 +            strdup( "Global error. periodicBoundryConditions was not \"true\" or \"false\".\n" );
724 +          return 0;
725 +        }
726 +        return 1;
727 +      }
728 +      
729 +      the_event->err_msg =
730 +        strdup( "Global error. tempSet was not \"true\" or \"false\".\n" );
731 +      return 0;
732 +      break;
733      }
734    }
735    
# Line 793 | Line 834 | int Globals::hash( char* text ){
834  
835      // if the key is less than zero, we've had an overflow error
836  
837 <    fprintf( stderr,
837 >    sprintf( painCave.errMsg,
838               "There has been an overflow error in the Globals' hash key.");
839 <    exit(0);
839 >    painCave.isFatal = 1;
840 >    simError();
841 > #ifdef IS_MPI
842 >    if( painCave.isEventLoop ){
843 >      if( worldRank == 0 ) mpiInterfaceExit();
844 >    }
845 > #endif //is_mpi
846    }
847    
848    return key;
# Line 812 | Line 859 | void Globals::addHash( char* text, int token ){
859    key = hash( text );
860    the_element->setNext( command_table[key] );
861    command_table[key] = the_element;
862 < };
862 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines