ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/io/Globals.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/io/Globals.cpp (file contents):
Revision 1492 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
Revision 2279 by chrisfen, Tue Aug 30 18:23:50 2005 UTC

# Line 1 | Line 1
1 + /*
2 + * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 + *
4 + * The University of Notre Dame grants you ("Licensee") a
5 + * non-exclusive, royalty free, license to use, modify and
6 + * redistribute this software in source and binary code form, provided
7 + * that the following conditions are met:
8 + *
9 + * 1. Acknowledgement of the program authors must be made in any
10 + *    publication of scientific results based in part on use of the
11 + *    program.  An acceptable form of acknowledgement is citation of
12 + *    the article in which the program was described (Matthew
13 + *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 + *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 + *    Parallel Simulation Engine for Molecular Dynamics,"
16 + *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 + *
18 + * 2. Redistributions of source code must retain the above copyright
19 + *    notice, this list of conditions and the following disclaimer.
20 + *
21 + * 3. Redistributions in binary form must reproduce the above copyright
22 + *    notice, this list of conditions and the following disclaimer in the
23 + *    documentation and/or other materials provided with the
24 + *    distribution.
25 + *
26 + * This software is provided "AS IS," without a warranty of any
27 + * kind. All express or implied conditions, representations and
28 + * warranties, including any implied warranty of merchantability,
29 + * fitness for a particular purpose or non-infringement, are hereby
30 + * excluded.  The University of Notre Dame and its licensors shall not
31 + * be liable for any damages suffered by licensee as a result of
32 + * using, modifying or distributing the software or its
33 + * derivatives. In no event will the University of Notre Dame or its
34 + * licensors be liable for any lost revenue, profit or data, or for
35 + * direct, indirect, special, consequential, incidental or punitive
36 + * damages, however caused and regardless of the theory of liability,
37 + * arising out of the use of or inability to use software, even if the
38 + * University of Notre Dame has been advised of the possibility of
39 + * such damages.
40 + */
41 +
42   #include <stdlib.h>
43   #include <stdio.h>
44   #include <string.h>
# Line 10 | Line 51
51  
52   /*
53   * The following section lists all of the defined tokens for the
54 < * gloabal assignment statements. All are prefixed with a G_ to avoid
54 > * global assignment statements. All are prefixed with a G_ to avoid
55   * stepping on any previously defined enumerations.
56   *
57   * NOTE: tokens start at 1, 0 is a resrved token number
# Line 71 | Line 112
112   #define G_THERM_INT_LAMBDA  50
113   #define G_THERM_INT_K       51
114   #define G_FORCEFIELD_VARIANT 52
115 + #define G_FORCEFIELD_FILENAME 53
116 + #define G_THERM_INT_DIST_SPRING  54
117 + #define G_THERM_INT_THETA_SPRING 55
118 + #define G_THERM_INT_OMEGA_SPRING 56
119 + #define G_SURFACETENSION 57
120 + #define G_PRINTPREESURETENSOR   58
121 + #define G_USE_UNDAMPED_WOLF 59
122 + #define G_USE_DAMPED_WOLF   60
123  
124   Globals::Globals(){
125    initalize();
# Line 78 | Line 127 | Globals::~Globals(){
127  
128   Globals::~Globals(){
129    int i;
81
82  for( i=0; i<hash_size; i++ ){
83    if( command_table[i] != NULL ) delete command_table[i];
84  }
85  delete[] command_table;
86
130    if( components != NULL ){
131      for( i=0; i<n_components; i++ ) delete components[i];
132      delete[] components;
# Line 93 | Line 136 | void Globals::initalize(){
136   void Globals::initalize(){
137    int i;
138    
96  hash_size = 23;
97  hash_shift = 4;
98  
139    components = NULL;
140    
141 <  command_table = new LinkedCommand*[hash_size];
142 <  for( i=0; i<hash_size; i++ ) command_table[i] = NULL;
143 <  
144 <  addHash( "forceField",    G_FORCEFIELD );
145 <  addHash( "nComponents",   G_NCOMPONENTS );
146 <  addHash( "targetTemp",    G_TARGETTEMP );
147 <  addHash( "ensemble",      G_ENSEMBLE );
148 <  
149 <  addHash( "dt",            G_DT );
150 <  addHash( "runTime",       G_RUNTIME );
151 <  
152 <  addHash( "initialConfig", G_INITIALCONFIG );
153 <  addHash( "finalConfig",   G_FINALCONFIG );
154 <  addHash( "nMol",          G_NMOL );
155 <  addHash( "density",       G_DENSITY );
156 <  addHash( "box",           G_BOX );
157 <  addHash( "boxX",          G_BOXX );
158 <  addHash( "boxY",          G_BOXY );
159 <  addHash( "boxZ",          G_BOXZ );
160 <  addHash( "sampleTime",    G_SAMPLETIME );
161 <  addHash( "resetTime",     G_RESETTIME );
162 <  addHash( "statusTime",    G_STATUSTIME );
163 <  addHash( "cutoffRadius",  G_RCUT );
164 <  addHash( "switchingRadius",  G_RSW );
165 <  addHash( "dielectric",    G_DIELECTRIC );
166 <  addHash( "tempSet",       G_TEMPSET );
167 <  addHash( "thermalTime",   G_THERMALTIME );
168 <  addHash( "mixingRule",    G_MIXINGRULE);
169 <  addHash( "usePeriodicBoundaryConditions",        G_USEPBC);
170 <  addHash( "useReactionField",                     G_USERF );
171 <  addHash( "targetPressure",                       G_TARGETPRESSURE);
172 <  addHash( "tauThermostat",                        G_TAUTHERMOSTAT);
173 <  addHash( "tauBarostat",                          G_TAUBAROSTAT);
174 <  addHash( "zconsTime",                            G_ZCONSTIME);
175 <  addHash( "nZconstraints",                        G_NZCONSTRAINTS);
176 <  addHash( "zconsTol",                             G_ZCONSTOL);
177 <  addHash( "zconsForcePolicy",                     G_ZCONSFORCEPOLICY);
178 <  addHash( "seed",                                 G_SEED);
179 <  addHash( "useInitialTime",                       G_USEINITTIME);
180 <  addHash( "useInitialExtendedSystemState",        G_USEINIT_XS_STATE);
181 <  addHash( "orthoBoxTolerance",                    G_ORTHOBOXTOLERANCE);
182 <  addHash( "minimizer",                            G_MINIMIZER);
183 <  addHash( "minimizerMaxIter",                     G_MIN_MAXITER);
184 <  addHash( "minimizerWriteFrq",                    G_MIN_WRITEFRQ);
185 <  addHash( "minimizerStepSize",                    G_MIN_STEPSIZE);
186 <  addHash( "minimizerFTol",                        G_MIN_FTOL);
187 <  addHash( "minimizerGTol",                        G_MIN_GTOL);
188 <  addHash( "minimizerLSTol",                       G_MIN_LSTOL);
189 <  addHash( "minimizerLSMaxIter",                   G_MIN_LSMAXITER);
190 <  addHash( "zconsGap",                             G_ZCONSGAP);
191 <  addHash( "zconsFixtime",                         G_ZCONSFIXTIME);
192 <  addHash( "zconsUsingSMD",                        G_ZCONSUSINGSMD);
193 <  addHash( "useSolidThermInt",                     G_USE_SOLID_THERM_INT);
194 <  addHash( "useLiquidThermInt",                    G_USE_LIQUID_THERM_INT);
195 <  addHash( "thermodynamicIntegrationLambda",       G_THERM_INT_LAMBDA);
196 <  addHash( "thermodynamicIntegrationK",            G_THERM_INT_K);
197 <  addHash( "forceFieldVariant",                    G_FORCEFIELD_VARIANT);
141 >  command_table.insert(CommandMapType::value_type("forceField", G_FORCEFIELD));
142 >  command_table.insert(CommandMapType::value_type("nComponents", G_NCOMPONENTS));
143 >  command_table.insert(CommandMapType::value_type("targetTemp", G_TARGETTEMP));
144 >  command_table.insert(CommandMapType::value_type("ensemble", G_ENSEMBLE));
145 >  command_table.insert(CommandMapType::value_type("dt", G_DT));
146 >  command_table.insert(CommandMapType::value_type("runTime", G_RUNTIME));
147 >  command_table.insert(CommandMapType::value_type("initialConfig", G_INITIALCONFIG));
148 >  command_table.insert(CommandMapType::value_type("finalConfig", G_FINALCONFIG));
149 >  command_table.insert(CommandMapType::value_type("nMol", G_NMOL));
150 >  command_table.insert(CommandMapType::value_type("density", G_DENSITY));
151 >  command_table.insert(CommandMapType::value_type("box", G_BOX));
152 >  command_table.insert(CommandMapType::value_type("boxX", G_BOXX));
153 >  command_table.insert(CommandMapType::value_type("boxY", G_BOXY));
154 >  command_table.insert(CommandMapType::value_type("boxZ", G_BOXZ));
155 >  command_table.insert(CommandMapType::value_type("sampleTime", G_SAMPLETIME));
156 >  command_table.insert(CommandMapType::value_type("resetTime", G_RESETTIME));
157 >  command_table.insert(CommandMapType::value_type("statusTime", G_STATUSTIME));
158 >  command_table.insert(CommandMapType::value_type("cutoffRadius", G_RCUT));
159 >  command_table.insert(CommandMapType::value_type("switchingRadius", G_RSW));
160 >  command_table.insert(CommandMapType::value_type("dielectric", G_DIELECTRIC));
161 >  command_table.insert(CommandMapType::value_type("tempSet", G_TEMPSET));
162 >  command_table.insert(CommandMapType::value_type("thermalTime", G_THERMALTIME));
163 >  command_table.insert(CommandMapType::value_type("mixingRule", G_MIXINGRULE));
164 >  command_table.insert(CommandMapType::value_type("usePeriodicBoundaryConditions", G_USEPBC));
165 >  command_table.insert(CommandMapType::value_type("useReactionField", G_USERF));
166 >  command_table.insert(CommandMapType::value_type("targetPressure", G_TARGETPRESSURE));
167 >  command_table.insert(CommandMapType::value_type("tauThermostat", G_TAUTHERMOSTAT));
168 >  command_table.insert(CommandMapType::value_type("tauBarostat", G_TAUBAROSTAT));
169 >  command_table.insert(CommandMapType::value_type("zconsTime", G_ZCONSTIME));
170 >  command_table.insert(CommandMapType::value_type("nZconstraints", G_NZCONSTRAINTS));
171 >  command_table.insert(CommandMapType::value_type("zconsTol", G_ZCONSTOL));
172 >  command_table.insert(CommandMapType::value_type("zconsForcePolicy", G_ZCONSFORCEPOLICY));
173 >  command_table.insert(CommandMapType::value_type("seed", G_SEED));
174 >  command_table.insert(CommandMapType::value_type("useInitialTime", G_USEINITTIME));
175 >  command_table.insert(CommandMapType::value_type("useInitialExtendedSystemState", G_USEINIT_XS_STATE));
176 >  command_table.insert(CommandMapType::value_type("orthoBoxTolerance", G_ORTHOBOXTOLERANCE));
177 >  command_table.insert(CommandMapType::value_type("minimizer", G_MINIMIZER));
178 >  command_table.insert(CommandMapType::value_type("minimizerMaxIter", G_MIN_MAXITER));
179 >  command_table.insert(CommandMapType::value_type("minimizerWriteFrq", G_MIN_WRITEFRQ));
180 >  command_table.insert(CommandMapType::value_type("minimizerStepSize", G_MIN_STEPSIZE));
181 >  command_table.insert(CommandMapType::value_type("minimizerFTol", G_MIN_FTOL));
182 >  command_table.insert(CommandMapType::value_type("minimizerGTol", G_MIN_GTOL));
183 >  command_table.insert(CommandMapType::value_type("minimizerLSTol", G_MIN_LSTOL));
184 >  command_table.insert(CommandMapType::value_type("minimizerLSMaxIter", G_MIN_LSMAXITER));
185 >  command_table.insert(CommandMapType::value_type("zconsGap", G_ZCONSGAP));
186 >  command_table.insert(CommandMapType::value_type("zconsFixtime", G_ZCONSFIXTIME));
187 >  command_table.insert(CommandMapType::value_type("zconsUsingSMD", G_ZCONSUSINGSMD));
188 >  command_table.insert(CommandMapType::value_type("useSolidThermInt", G_USE_SOLID_THERM_INT));
189 >  command_table.insert(CommandMapType::value_type("useLiquidThermInt", G_USE_LIQUID_THERM_INT));
190 >  command_table.insert(CommandMapType::value_type("thermodynamicIntegrationLambda", G_THERM_INT_LAMBDA));
191 >  command_table.insert(CommandMapType::value_type("thermodynamicIntegrationK", G_THERM_INT_K));
192 >  command_table.insert(CommandMapType::value_type("forceFieldVariant", G_FORCEFIELD_VARIANT));
193 >  command_table.insert(CommandMapType::value_type("forceFieldFileName", G_FORCEFIELD_FILENAME));
194 >  command_table.insert(CommandMapType::value_type("thermIntDistSpringConst", G_THERM_INT_DIST_SPRING));
195 >  command_table.insert(CommandMapType::value_type("thermIntThetaSpringConst", G_THERM_INT_THETA_SPRING));
196 >  command_table.insert(CommandMapType::value_type("thermIntOmegaSpringConst", G_THERM_INT_OMEGA_SPRING));
197 >  command_table.insert(CommandMapType::value_type("surfaceTension", G_SURFACETENSION));
198 >  command_table.insert(CommandMapType::value_type("printPressureTensor", G_PRINTPREESURETENSOR));
199 >  command_table.insert(CommandMapType::value_type("useUndampedWolf", G_USE_UNDAMPED_WOLF));
200 >  command_table.insert(CommandMapType::value_type("useDampedWolf", G_USE_DAMPED_WOLF));
201  
202    strcpy( mixingRule,"standard");  //default mixing rules to standard.
203    usePBC = 1; //default  periodic boundry conditions to on
# Line 212 | Line 255 | void Globals::initalize(){
255    have_thermodynamic_integration_lambda = 0;
256    have_thermodynamic_integration_k = 0;
257    have_forcefield_variant = 0;
258 <
258 >  have_forcefield_filename = 0;
259 >  have_dist_spring_constant =  0;
260 >  have_theta_spring_constant = 0;
261 >  have_omega_spring_constant = 0;
262 >  have_surface_tension = 0;
263 >  have_print_pressure_tensor = 0;
264   }
265  
266   int Globals::newComponent( event* the_event ){
# Line 360 | Line 408 | int Globals::globalAssign( event* the_event ){
408    char err[300];
409    
410    token = 0;
411 <  key = hash( lhs );
412 <  if( command_table[key] != NULL ) token = command_table[key]->match( lhs );
411 >
412 >  CommandMapType::iterator iter;
413 >  std::string keyword(lhs);
414 >  iter = command_table.find(keyword);
415 >  if (iter != command_table.end()) {
416 >    token = iter->second;
417 >  }
418    
419    if( token ){
420      
# Line 1205 | Line 1258 | int Globals::globalAssign( event* the_event ){
1258        switch( the_type ){
1259          
1260        case STRING:
1261 <   strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval);
1261 >        strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval);
1262  
1263 <   for(int i = 0; zconsForcePolicy[i] != '\0'; i++)
1264 <        {
1265 <      zconsForcePolicy[i] = toupper(zconsForcePolicy[i]);
1266 <   }
1263 >        for(int i = 0; zconsForcePolicy[i] != '\0'; i++)
1264 >          {
1265 >            zconsForcePolicy[i] = toupper(zconsForcePolicy[i]);
1266 >          }
1267          have_zcons_force_policy = 1;
1268 <   return 1;
1268 >        return 1;
1269          break;
1270          
1271        case DOUBLE:
# Line 1389 | Line 1442 | int Globals::globalAssign( event* the_event ){
1442  
1443        case STRING:
1444          the_event->err_msg =
1445 <          strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not a double or int.\n" );
1445 >          strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not an int.\n" );
1446          return 1;
1447          break;
1448          
1449        case DOUBLE:
1450 <        minimizer_writefrq= the_event->evt.asmt.rhs.dval;
1451 <        have_minimizer_writefrq = 1;
1450 >        the_event->err_msg =
1451 >          strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not an  int.\n" );
1452          return 1;
1453          break;
1454          
# Line 1505 | Line 1558 | int Globals::globalAssign( event* the_event ){
1558  
1559        case STRING:
1560          the_event->err_msg =
1561 <          strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not a double or int.\n" );
1561 >          strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not an int.\n" );
1562          return 1;
1563          break;
1564          
1565        case DOUBLE:
1566 <        minimizer_ls_maxiteration = the_event->evt.asmt.rhs.dval;
1567 <        have_minimizer_ls_maxiteration = 1;
1566 >        the_event->err_msg =
1567 >          strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not an int.\n" );
1568          return 1;
1569          break;
1570          
# Line 1563 | Line 1616 | int Globals::globalAssign( event* the_event ){
1616        switch( the_type ){
1617          
1618        case STRING:
1619 <   the_event->err_msg =
1619 >        the_event->err_msg =
1620            strdup( "Error in parsing meta-data file!\n\tseed is not a string.\n" );
1621          return 0;
1622 <   return 0;
1622 >        return 0;
1623          break;
1624          
1625        case DOUBLE:
1626 <   have_seed = 1;
1627 <   seed = (int)the_event->evt.asmt.rhs.dval;
1626 >        have_seed = 1;
1627 >        seed = (int)the_event->evt.asmt.rhs.dval;
1628          return 1;
1629          break;
1630          
1631        case INT:
1632 <   have_seed = 1;
1633 <   seed =  the_event->evt.asmt.rhs.ival ;
1632 >        have_seed = 1;
1633 >        seed =  the_event->evt.asmt.rhs.ival ;
1634          return 1;
1635          break;
1636          
# Line 1681 | Line 1734 | int Globals::globalAssign( event* the_event ){
1734          return 0;
1735          break;
1736        }
1737 <      break;      
1737 >      break;  
1738 >  
1739      case G_FORCEFIELD_VARIANT:
1740        if( the_type == STRING ){
1741          strcpy( forcefield_variant, the_event->evt.asmt.rhs.sval );
# Line 1694 | Line 1748 | int Globals::globalAssign( event* the_event ){
1748        return 0;
1749        break;      
1750        // add more token cases here.      
1751 +
1752 +    case G_FORCEFIELD_FILENAME:
1753 +      if( the_type == STRING ){
1754 +        strcpy( forcefield_filename, the_event->evt.asmt.rhs.sval );
1755 +        have_forcefield_filename = 1;
1756 +        return 1;
1757 +      }
1758 +      
1759 +      the_event->err_msg =
1760 +        strdup( "Error in parsing meta-data file!\n\tforceFieldFileName was not a string assignment.\n" );
1761 +      return 0;
1762 +      break;      
1763 +
1764 +    case G_THERM_INT_DIST_SPRING:
1765 +      switch( the_type ){
1766 +        
1767 +      case STRING:
1768 +        the_event->err_msg =
1769 +          strdup( "Error in parsing meta-data file!\n\tthermIntDistSpringConst is not a double or int.\n" );
1770 +        return 1;
1771 +        break;
1772 +        
1773 +      case DOUBLE:
1774 +        therm_int_dist_spring = the_event->evt.asmt.rhs.dval;
1775 +        have_dist_spring_constant = 1;
1776 +        return 1;
1777 +        break;
1778 +        
1779 +      case INT:
1780 +        therm_int_dist_spring = (double)the_event->evt.asmt.rhs.dval;
1781 +        have_dist_spring_constant = 1;
1782 +        return 1;
1783 +        break;
1784 +        
1785 +      default:
1786 +        the_event->err_msg =
1787 +          strdup( "Error in parsing meta-data file!\n\tthermIntDistSpringConst unrecognized.\n" );
1788 +        return 0;
1789 +        break;
1790 +      }
1791 +      break;  
1792 +
1793 +    case G_THERM_INT_THETA_SPRING:
1794 +      switch( the_type ){
1795 +        
1796 +      case STRING:
1797 +        the_event->err_msg =
1798 +          strdup( "Error in parsing meta-data file!\n\tthermIntThetaSpringConst is not a double or int.\n" );
1799 +        return 1;
1800 +        break;
1801 +        
1802 +      case DOUBLE:
1803 +        therm_int_theta_spring = the_event->evt.asmt.rhs.dval;
1804 +        have_theta_spring_constant = 1;
1805 +        return 1;
1806 +        break;
1807 +        
1808 +      case INT:
1809 +        therm_int_theta_spring = (double)the_event->evt.asmt.rhs.dval;
1810 +        have_theta_spring_constant = 1;
1811 +        return 1;
1812 +        break;
1813 +        
1814 +      default:
1815 +        the_event->err_msg =
1816 +          strdup( "Error in parsing meta-data file!\n\tthermIntThetaSpringConst unrecognized.\n" );
1817 +        return 0;
1818 +        break;
1819 +      }
1820 +      break;
1821 +
1822 +    case G_THERM_INT_OMEGA_SPRING:
1823 +      switch( the_type ){
1824 +        
1825 +      case STRING:
1826 +        the_event->err_msg =
1827 +          strdup( "Error in parsing meta-data file!\n\tthermIntOmegaSpringConst is not a double or int.\n" );
1828 +        return 1;
1829 +        break;
1830 +        
1831 +      case DOUBLE:
1832 +        therm_int_omega_spring = the_event->evt.asmt.rhs.dval;
1833 +        have_omega_spring_constant = 1;
1834 +        return 1;
1835 +        break;
1836 +        
1837 +      case INT:
1838 +        therm_int_omega_spring = (double)the_event->evt.asmt.rhs.dval;
1839 +        have_omega_spring_constant = 1;
1840 +        return 1;
1841 +        break;
1842 +        
1843 +      default:
1844 +        the_event->err_msg =
1845 +          strdup( "Error in parsing meta-data file!\n\tthermIntOmegaSpringConst unrecognized.\n" );
1846 +        return 0;
1847 +        break;
1848 +      }
1849 +      break;  
1850 +
1851 +    case G_SURFACETENSION:
1852 +        switch( the_type ){
1853 +      
1854 +        case STRING:
1855 +          the_event->err_msg =
1856 +            strdup( "Error in parsing meta-data file!\n\tsurfaceTension is not a double or int.\n" );
1857 +          return 1;
1858 +          break;
1859 +          
1860 +        case DOUBLE:
1861 +          surface_tension= the_event->evt.asmt.rhs.dval;
1862 +          have_surface_tension = 1;
1863 +          return 1;
1864 +          break;
1865 +          
1866 +        case INT:
1867 +          surface_tension = (double)the_event->evt.asmt.rhs.dval;
1868 +          have_surface_tension = 1;
1869 +          return 1;
1870 +          break;
1871 +          
1872 +        default:
1873 +          the_event->err_msg =
1874 +            strdup( "Error in parsing meta-data file!\n\tsurfaceTension unrecognized.\n" );
1875 +          return 0;
1876 +          break;
1877 +        }
1878 +        break;
1879 +
1880 +    case G_PRINTPREESURETENSOR:
1881 +          if( the_type == STRING ){
1882 +        
1883 +        if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) {
1884 +            have_print_pressure_tensor= 1;
1885 +            print_pressure_tensor = 1;
1886 +        } else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) {
1887 +            have_print_pressure_tensor= 1;
1888 +            print_pressure_tensor = 0;
1889 +        } else{
1890 +          the_event->err_msg =
1891 +            strdup( "Error in parsing meta-data file!\n\tprintPressureTensor was not \"true\" or \"false\".\n" );
1892 +          return 0;
1893 +        }
1894 +        return 1;
1895 +          }
1896 +          
1897 +          the_event->err_msg =
1898 +        strdup( "Error in parsing meta-data file!\n\tprintPressureTensor was not \"true\" or \"false\".\n" );
1899 +          return 0;
1900 +          break;
1901 +
1902 +    case G_USE_UNDAMPED_WOLF:
1903 +      if( the_type == STRING ){
1904 +        
1905 +        if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) useUndampedWolf = 1;
1906 +        else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) useUndampedWolf = 0;
1907 +        else{
1908 +          the_event->err_msg =
1909 +          strdup( "Error in parsing meta-data file!\n\tuseUndampedWolf was not \"true\" or \"false\".\n" );
1910 +          return 0;
1911 +        }
1912 +        return 1;
1913 +      }
1914 +      
1915 +      the_event->err_msg =
1916 +      strdup( "Error in parsing meta-data file!\n\tuseUndampedWolf was not \"true\" or \"false\".\n" );
1917 +      return 0;
1918 +      break;
1919 +      
1920 +    case G_USE_DAMPED_WOLF:
1921 +      if( the_type == STRING ){
1922 +        
1923 +        if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) useDampedWolf = 1;
1924 +        else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) useDampedWolf = 0;
1925 +        else{
1926 +          the_event->err_msg =
1927 +          strdup( "Error in parsing meta-data file!\n\tuseDampedWolf was not \"true\" or \"false\".\n" );
1928 +          return 0;
1929 +        }
1930 +        return 1;
1931 +      }
1932 +      
1933 +      the_event->err_msg =
1934 +      strdup( "Error in parsing meta-data file!\n\tuseDampedWolf was not \"true\" or \"false\".\n" );
1935 +      return 0;
1936 +      break;
1937 +      
1938 +      
1939 +      // add more token cases here.      
1940      }
1941    }
1942    
# Line 1784 | Line 2027 | int Globals::hash( char* text ){
2027    return 1;
2028   }
2029  
1787 int Globals::hash( char* text ){
1788
1789  register unsigned short int i = 0; // loop counter
1790  int key = 0; // the hash key
1791  
1792  while( text[i] != '\0' ){
1793    
1794    key = ( ( key << hash_shift ) + text[i] ) % hash_size;
1795    
1796    i++;
1797  }
1798  
1799  if( key < 0 ){
1800
1801    // if the key is less than zero, we've had an overflow error
1802
1803    sprintf( painCave.errMsg,
1804             "There has been an overflow error in the Globals' hash key.");
1805    painCave.isFatal = 1;
1806    simError();
1807 #ifdef IS_MPI
1808    if( painCave.isEventLoop ){
1809      if( worldRank == 0 ) mpiInterfaceExit();
1810    }
1811 #endif //is_mpi
1812  }
1813  
1814  return key;
1815 }
1816
1817 void Globals::addHash( char* text, int token ){
1818
1819  int key;
1820  LinkedCommand* the_element;
1821
1822  the_element = new LinkedCommand;
1823  the_element->setValues( text, token );
1824
1825  key = hash( text );
1826
1827  the_element->setNext( command_table[key] );
1828  command_table[key] = the_element;
1829 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines