Ignore:
Timestamp:
Feb 10, 2011, 6:58:48 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
b6b3b2
Parents:
4cbca0
git-author:
Frederik Heber <heber@…> (02/10/11 18:36:56)
git-committer:
Frederik Heber <heber@…> (02/10/11 18:58:48)
Message:

FIX: Changed MpqcParser.

  • some ASSERTs were missing and showed up failure in parsings.
  • in MpqcSection keywords molecule and basis are now ignored.
  • BUGFIX: due to missing whitespacefilter most of the keys were actually not really parsed which lead to strange "A'" and ""A'"" behavior, because in unit test key was without whitespace, hence recognized (and there we switch theories from CLHF parsed file only), whereas in regression test key was not recognized.
  • TESTFIX: ParserMpqcUnitTest - now checks whether MpqcParser_Parameters:: getInt() throws and also if ::operator>> throws in case of debugging.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/MpqcParser.cpp

    r4cbca0 r311da7b  
    6464  boost::char_separator<char> sep("[]");
    6565  boost::char_separator<char> angularsep("<>");
    66   boost::char_separator<char> equalitysep("=");
     66  boost::char_separator<char> equalitysep(" =");
    6767  boost::char_separator<char> whitesep(" \t");
    6868  ConvertTo<double> toDouble;
     
    9090  //        throw MpqcParseException;
    9191        tokenizer::iterator tok_iter = tokens.begin();
     92        ASSERT(tok_iter != tokens.end(),
     93            "MpqcParser::load() - missing token for MoleculeSection in line "+linestring+"!");
    9294        std::stringstream whitespacefilter(*tok_iter++);
    9395        std::string element;
    94         whitespacefilter >> element;
     96        whitespacefilter >> ws >> element;
     97        ASSERT(tok_iter != tokens.end(),
     98            "MpqcParser::load() - missing token for MoleculeSection in line "+linestring+"!");
    9599        std::string vector = *tok_iter;
    96100        tokenizer vectorcomponents(vector, whitesep);
     
    111115    }
    112116    if (MpqcSection) {
    113       tokenizer tokens(linestring, equalitysep);
    114       tokenizer::iterator tok_iter = tokens.begin();
    115       std::stringstream whitespacefilter(*tok_iter++);
    116       std::string key(*tok_iter++);
    117       if (params.haveParam(key)) {
    118         std::stringstream linestream(linestring);
    119         linestream >> params;
    120       } else if (linestring.find("mole<") != string::npos) { // get theory
     117      if (linestring.find("mole<") != string::npos) { // get theory
    121118        tokenizer tokens(linestring, angularsep);
    122119        tokenizer::iterator tok_iter = tokens.begin();
    123         std::string value(*(++tok_iter));
     120        ++tok_iter;
     121        ASSERT(tok_iter != tokens.end(),
     122            "MpqcParser::load() - missing token in brackets<> for mole< in line "+linestring+"!");
     123        std::string value(*tok_iter);
    124124        std::stringstream linestream("theory = "+value);
    125125        linestream >> params;
     
    127127        tokenizer tokens(linestring, angularsep);
    128128        tokenizer::iterator tok_iter = tokens.begin();
    129         std::string value(*(++tok_iter));
     129        ++tok_iter;
     130        ASSERT(tok_iter != tokens.end(),
     131            "MpqcParser::load() - missing token in brackets<> for integrals< in line "+linestring+"!");
     132        std::string value(*tok_iter);
    130133        std::stringstream linestream("integration = "+value);
    131134        linestream >> params;
     135      } else if ((linestring.find("molecule") == string::npos) && (linestring.find("basis") == string::npos)){
     136        // molecule and basis must not be parsed in this section
     137        tokenizer tokens(linestring, equalitysep);
     138        tokenizer::iterator tok_iter = tokens.begin();
     139        ASSERT(tok_iter != tokens.end(),
     140            "MpqcParser::load() - missing token before '=' for MpqcSection in line "+linestring+"!");
     141        std::stringstream whitespacefilter(*tok_iter);
     142        std::string key;
     143        whitespacefilter >> ws >> key;
     144        if (params.haveParam(key)) {
     145          std::stringstream linestream(linestring);
     146          linestream >> params;
     147        } else { // unknown keys are simply ignored as long as parser is incomplete
     148          DoLog(2) && (Log() << Verbose(2) << "INFO: '"+key+"' is unknown and ignored." << std::endl);
     149        }
    132150      }
    133151    }
     
    135153      tokenizer tokens(linestring, equalitysep);
    136154      tokenizer::iterator tok_iter = tokens.begin();
     155      ASSERT(tok_iter != tokens.end(),
     156          "MpqcParser::load() - missing token for BasisSection in line "+linestring+"!");
    137157      std::string key(*tok_iter++);
     158      ASSERT(tok_iter != tokens.end(),
     159          "MpqcParser::load() - missing value for BasisSection after key "+key+" in line "+linestring+"!");
    138160      std::string value(*tok_iter);
     161      tok_iter++;
    139162      // TODO: use exception instead of ASSERT
    140163      ASSERT(tok_iter == tokens.end(),
     
    148171      tokenizer tokens(linestring, equalitysep);
    149172      tokenizer::iterator tok_iter = tokens.begin();
     173      ASSERT(tok_iter != tokens.end(),
     174          "MpqcParser::load() - missing token for AuxBasisSection in line "+linestring+"!");
    150175      std::string key(*tok_iter++);
     176      ASSERT(tok_iter != tokens.end(),
     177          "MpqcParser::load() - missing value for BasisSection after key "+key+" in line "+linestring+"!");
    151178      std::string value(*tok_iter);
     179      tok_iter++;
    152180      // TODO: use exception instead of ASSERT
    153181      ASSERT(tok_iter == tokens.end(),
Note: See TracChangeset for help on using the changeset viewer.