--- branches/mmeineke/mdtools/interface_implementation/Globals.cpp 2002/07/09 18:40:59 10 +++ trunk/mdtools/interface_implementation/Globals.cpp 2003/02/24 21:26:54 282 @@ -3,6 +3,10 @@ #include #include "Globals.hpp" +#include "simError.h" +#ifdef IS_MPI +#include "mpiBASS.h" +#endif // is_mpi /* * The following section lists all of the defined tokens for the @@ -35,6 +39,8 @@ #define G_DIELECTRIC 18 #define G_TEMPSET 19 #define G_THERMALTIME 20 +#define G_USEPBC 21 +#define G_MIXINGRULE 22 Globals::Globals(){ @@ -50,6 +56,7 @@ Globals::Globals(){ addHash( "nComponents", G_NCOMPONENTS ); addHash( "targetTemp", G_TARGETTEMP ); addHash( "ensemble", G_ENSEMBLE ); + addHash( "dt", G_DT ); addHash( "runTime", G_RUNTIME ); @@ -67,6 +74,11 @@ Globals::Globals(){ addHash( "dielectric", G_DIELECTRIC ); addHash( "tempSet", G_TEMPSET ); addHash( "thermalTime", G_THERMALTIME ); + addHash("mixingRule", G_MIXINGRULE); + mixingRule = "standard"; //default mixing rules to standard. + addHash("periodicBoundryConditions", G_USEPBC); + usePBC = 1; //default periodic boundry conditions to on + have_force_field = 0; have_n_components = 0; @@ -90,7 +102,7 @@ Globals::Globals(){ have_rrf = 0; have_dielectric = 0; have_tempSet = 0; -} + } Globals::~Globals(){ int i; @@ -138,21 +150,21 @@ int Globals::componentAssign( event* the_event ){ switch( the_event->evt.asmt.asmt_type ){ case STRING: - current_component->assignString( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.sval ); - return 1; + return current_component->assignString( the_event->evt.asmt.lhs, + the_event->evt.asmt.rhs.sval, + &(the_event->err_msg)); break; case DOUBLE: - current_component->assignDouble( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.dval ); - return 1; + return current_component->assignDouble( the_event->evt.asmt.lhs, + the_event->evt.asmt.rhs.dval, + &(the_event->err_msg)); break; case INT: - current_component->assignInt( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.ival ); - return 1; + return current_component->assignInt( the_event->evt.asmt.lhs, + the_event->evt.asmt.rhs.ival, + &(the_event->err_msg)); break; default: @@ -269,7 +281,18 @@ int Globals::globalAssign( event* the_event ){ strdup( "Global error. ensemble was not assigned to a string\n" ); return 0; break; + + case G_MIXINGRULE: + if( the_type == STRING ){ + strcpy( mixingRule, the_event->evt.asmt.rhs.sval ); + return 1; + } + the_event->err_msg = + strdup( "Global error. mixing rule was not assigned to a string\n" ); + return 0; + break; + case G_DT: switch( the_type ){ @@ -689,6 +712,24 @@ int Globals::globalAssign( event* the_event ){ strdup( "Global error. tempSet was not \"true\" or \"false\".\n" ); return 0; break; + + case G_USEPBC: + if( the_type == STRING ){ + + if( !strcmp( "true", the_event->evt.asmt.rhs.sval )) usePBC = 1; + else if( !strcmp( "false", the_event->evt.asmt.rhs.sval )) usePBC = 0; + else{ + the_event->err_msg = + strdup( "Global error. periodicBoundryConditions was not \"true\" or \"false\".\n" ); + return 0; + } + return 1; + } + + the_event->err_msg = + strdup( "Global error. tempSet was not \"true\" or \"false\".\n" ); + return 0; + break; } } @@ -793,9 +834,15 @@ int Globals::hash( char* text ){ // if the key is less than zero, we've had an overflow error - fprintf( stderr, + sprintf( painCave.errMsg, "There has been an overflow error in the Globals' hash key."); - exit(0); + painCave.isFatal = 1; + simError(); +#ifdef IS_MPI + if( painCave.isEventLoop ){ + if( worldRank == 0 ) mpiInterfaceExit(); + } +#endif //is_mpi } return key; @@ -812,4 +859,4 @@ void Globals::addHash( char* text, int token ){ key = hash( text ); the_element->setNext( command_table[key] ); command_table[key] = the_element; -}; +}