Changeset fb9364 for src


Ignore:
Timestamp:
Aug 6, 2008, 8:37:04 AM (16 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, 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:
b4b7c3
Parents:
4aa03a
Message:

The entries in the Header of ForceMatrix are now separated by tabs, not white spaces in general

This fixes problems with the headers of the speed entries of MPQC which are multiple words separated by spaces. As we already use tabs to separate each entries, we just had to rewrite the code to split by '\t' which is done by getline.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/datacreator.cpp

    r4aa03a rfb9364  
    520520void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
    521521{
    522   char item[1024];
    523522  stringstream line(Energy.Header);
    524 
    525   line >> item;
     523  string token;
     524
     525  getline(line, token, '\t');
    526526  for (int i=2; i<= Energy.ColumnCounter;i++) {
    527     line >> item;
    528     output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses;
     527    getline(line, token, '\t');
     528    while (token[0] == ' ') // remove leading white spaces
     529      token.erase(0,1);
     530    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses;
    529531    if (i != (Energy.ColumnCounter))
    530532      output << ", \\";
     
    542544void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
    543545{
    544   char item[1024];
    545546  stringstream line(Energy.Header);
    546 
    547   line >> item;
    548   for (int i=2; i<= Energy.ColumnCounter;i++) {
    549     line >> item;
    550     output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":" << i+2 << " " << uses;
     547  string token;
     548
     549  getline(line, token, '\t');
     550  for (int i=1; i<= Energy.ColumnCounter;i++) {
     551    getline(line, token, '\t');
     552    while (token[0] == ' ') // remove leading white spaces
     553      token.erase(0,1);
     554    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":" << i+2 << " " << uses;
    551555    if (i != (Energy.ColumnCounter))
    552556      output << ", \\";
     
    564568void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    565569{
    566   char item[1024];
    567570  stringstream line(Force.Header);
    568 
    569   line >> item;
    570   line >> item;
    571   line >> item;
    572   line >> item;
    573   line >> item;
     571  string token;
     572
     573  getline(line, token, '\t');
     574  getline(line, token, '\t');
     575  getline(line, token, '\t');
     576  getline(line, token, '\t');
     577  getline(line, token, '\t');
    574578  for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
    575     line >> item;
    576     item[strlen(item)-1] = '\0';  // kill residual index char (the '0')
    577     output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses;
     579    getline(line, token, '\t');
     580    while (token[0] == ' ') // remove leading white spaces
     581      token.erase(0,1);
     582    token.erase(token.length(), 1);  // kill residual index char (the '0')
     583    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses;
    578584    if (i != (Force.ColumnCounter-1))
    579585      output << ", \\";
    580586    output << endl;
    581     line >> item;
    582     line >> item;
     587    getline(line, token, '\t');
     588    getline(line, token, '\t');
    583589  }
    584590};
     
    593599void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    594600{
    595   char item[1024];
    596601  stringstream line(Force.Header);
    597 
    598   line >> item;
    599   line >> item;
    600   line >> item;
    601   line >> item;
    602   line >> item;
     602  string token;
     603
     604  getline(line, token, '\t');
     605  getline(line, token, '\t');
     606  getline(line, token, '\t');
     607  getline(line, token, '\t');
     608  getline(line, token, '\t');
    603609  for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
    604     line >> item;
    605     item[strlen(item)-1] = '\0';  // kill residual index char (the '0')
    606     output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses;
     610    getline(line, token, '\t');
     611    while (token[0] == ' ') // remove leading white spaces
     612      token.erase(0,1);
     613    token.erase(token.length(), 1);  // kill residual index char (the '0')
     614    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses;
    607615    if (i != (Force.ColumnCounter-1))
    608616      output << ", \\";
    609617    output << endl;
    610     line >> item;
    611     line >> item;
     618    getline(line, token, '\t');
     619    getline(line, token, '\t');
    612620  }
    613621};
     
    622630void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    623631{
    624   char item[1024];
    625632  stringstream line(Force.Header);
    626633  char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
    627 
    628   line >> item;
    629   line >> item;
    630   line >> item;
    631   line >> item;
    632   line >> item;
     634  string token;
     635
     636  getline(line, token, '\t');
     637  getline(line, token, '\t');
     638  getline(line, token, '\t');
     639  getline(line, token, '\t');
     640  getline(line, token, '\t');
    633641  for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
    634     line >> item;
    635     item[strlen(item)-1] = '\0';  // kill residual index char (the '0')
    636     output << "'" << prefix << ".dat' title '" << item << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses << " " << fillcolor[(i-7)/3];
     642    getline(line, token, '\t');
     643    while (token[0] == ' ') // remove leading white spaces
     644      token.erase(0,1);
     645    token.erase(token.length(), 1);  // kill residual index char (the '0')
     646    output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses << " " << fillcolor[(i-7)/3];
    637647    if (i != (Force.ColumnCounter-1))
    638648      output << ", \\";
    639649    output << endl;
    640     line >> item;
    641     line >> item;
     650    getline(line, token, '\t');
     651    getline(line, token, '\t');
    642652  }
    643653};
     
    652662void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    653663{
    654   char item[1024];
    655664  stringstream line(Force.Header);
    656665  char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
    657 
    658   line >> item;
    659   line >> item;
    660   line >> item;
    661   line >> item;
    662   line >> item;
     666  string token;
     667
     668  getline(line, token, '\t');
     669  getline(line, token, '\t');
     670  getline(line, token, '\t');
     671  getline(line, token, '\t');
     672  getline(line, token, '\t');
    663673  for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
    664     line >> item;
    665     item[strlen(item)-1] = '\0';  // kill residual index char (the '0')
    666     output << "'" << prefix << ".dat' title '" << item << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):" << i+1 << " " << uses << " " << fillcolor[(i-7)/3];
     674    getline(line, token, '\t');
     675    while (token[0] == ' ') // remove leading white spaces
     676      token.erase(0,1);
     677    token.erase(token.length(), 1);  // kill residual index char (the '0')
     678    output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):" << i+1 << " " << uses << " " << fillcolor[(i-7)/3];
    667679    if (i != (Force.ColumnCounter-1))
    668680      output << ", \\";
    669681    output << endl;
    670     line >> item;
    671     line >> item;
    672   }
    673 };
     682    getline(line, token, '\t');
     683    getline(line, token, '\t');
     684  }
     685};
  • src/parser.cpp

    r4aa03a rfb9364  
    115115  char *FragmentNumber = NULL;
    116116  stringstream file;
     117  string token;
    117118 
    118119  Header = (char *) Malloc(sizeof(char)*1023, "MatrixContainer::ParseMatrix: *EnergyHeader");
     
    167168    //cout << line.str() << endl;
    168169    ColumnCounter=0;
    169     while (!line.eof()) {   
    170       strcpy(filename,"@");
    171       line >> filename;
    172       if (filename[0] != '@')
     170    while ( getline(line,token, '\t') ) {
     171      if (token.length() > 0)
    173172        ColumnCounter++;
    174173    }
Note: See TracChangeset for help on using the changeset viewer.