Changeset 920c70 for src/parser.cpp
- Timestamp:
- May 31, 2010, 1:09:58 PM (16 years ago)
- 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:
- 42af9e
- Parents:
- 87b597
- File:
-
- 1 edited
-
src/parser.cpp (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/parser.cpp
r87b597 r920c70 59 59 MatrixContainer::MatrixContainer() { 60 60 Indices = NULL; 61 Header = Malloc<char*>(1, "MatrixContainer::MatrixContainer: **Header");62 Matrix = Malloc<double**>(1, "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule63 RowCounter = Malloc<int>(1, "MatrixContainer::MatrixContainer: *RowCounter");64 ColumnCounter = Malloc<int>(1, "MatrixContainer::MatrixContainer: *ColumnCounter");61 Header = new char*[1]; 62 Matrix = new double**[1]; // one more each for the total molecule 63 RowCounter = new int[1]; 64 ColumnCounter = new int[1]; 65 65 Header[0] = NULL; 66 66 Matrix[0] = NULL; … … 77 77 if ((ColumnCounter != NULL) && (RowCounter != NULL)) { 78 78 for(int j=RowCounter[i]+1;j--;) 79 Free(&Matrix[i][j]);80 Free(&Matrix[i]);79 delete[](Matrix[i][j]); 80 delete[](Matrix[i]); 81 81 } 82 82 } 83 83 if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL)) 84 84 for(int j=RowCounter[MatrixCounter]+1;j--;) 85 Free(&Matrix[MatrixCounter][j]);85 delete[](Matrix[MatrixCounter][j]); 86 86 if (MatrixCounter != 0) 87 Free(&Matrix[MatrixCounter]);88 Free(&Matrix);87 delete[](Matrix[MatrixCounter]); 88 delete[](Matrix); 89 89 } 90 90 if (Indices != NULL) 91 91 for(int i=MatrixCounter+1;i--;) { 92 Free(&Indices[i]);93 } 94 Free(&Indices);92 delete[](Indices[i]); 93 } 94 delete[](Indices); 95 95 96 96 if (Header != NULL) 97 97 for(int i=MatrixCounter+1;i--;) 98 Free(&Header[i]);99 Free(&Header);100 Free(&RowCounter);101 Free(&ColumnCounter);98 delete[](Header[i]); 99 delete[](Header); 100 delete[](RowCounter); 101 delete[](ColumnCounter); 102 102 }; 103 103 … … 112 112 if (Matrix == NULL) { 113 113 DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl); 114 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");114 Indices = new int*[MatrixCounter + 1]; 115 115 for(int i=MatrixCounter+1;i--;) { 116 Indices[i] = Malloc<int>(RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");116 Indices[i] = new int[RowCounter[i]]; 117 117 for(int j=RowCounter[i];j--;) 118 118 Indices[i][j] = j; … … 122 122 if (MatrixCounter != Matrix->MatrixCounter) 123 123 return false; 124 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");124 Indices = new int*[MatrixCounter + 1]; 125 125 for(int i=MatrixCounter+1;i--;) { 126 126 if (RowCounter[i] != Matrix->RowCounter[i]) 127 127 return false; 128 Indices[i] = Malloc<int>(Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");128 Indices[i] = new int[Matrix->RowCounter[i]]; 129 129 for(int j=Matrix->RowCounter[i];j--;) { 130 130 Indices[i][j] = Matrix->Indices[i][j]; … … 166 166 167 167 // parse header 168 Header[MatrixNr] = Malloc<char>(1024, "MatrixContainer::ParseMatrix: *Header[]");168 Header[MatrixNr] = new char[1024]; 169 169 for (int m=skiplines+1;m--;) 170 170 input.getline(Header[MatrixNr], 1023); … … 205 205 // allocate matrix if it's not zero dimension in one direction 206 206 if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) { 207 Matrix[MatrixNr] = Malloc<double*>(RowCounter[MatrixNr] + 1, "MatrixContainer::ParseMatrix: **Matrix[]");207 Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1]; 208 208 209 209 // parse in each entry for this matrix … … 217 217 strncpy(Header[MatrixNr], line.str().c_str(), 1023); 218 218 for(int j=0;j<RowCounter[MatrixNr];j++) { 219 Matrix[MatrixNr][j] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[][]");219 Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]]; 220 220 input.getline(filename, 1023); 221 221 stringstream lines(filename); … … 227 227 //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl; 228 228 } 229 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");229 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]]; 230 230 for(int j=ColumnCounter[MatrixNr];j--;) 231 231 Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.; … … 281 281 282 282 DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl); 283 Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule 284 Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule 285 RowCounter = ReAlloc<int>(RowCounter, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: *RowCounter"); 286 ColumnCounter = ReAlloc<int>(ColumnCounter, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: *ColumnCounter"); 283 delete[](Header); 284 delete[](Matrix); 285 delete[](RowCounter); 286 delete[](ColumnCounter); 287 Header = new char*[MatrixCounter + 1]; // one more each for the total molecule 288 Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule 289 RowCounter = new int[MatrixCounter + 1]; 290 ColumnCounter = new int[MatrixCounter + 1]; 287 291 for(int i=MatrixCounter+1;i--;) { 288 292 Matrix[i] = NULL; … … 298 302 if (!ParseMatrix(file.str().c_str(), skiplines, skipcolumns, i)) 299 303 return false; 300 Free(&FragmentNumber);304 delete[](FragmentNumber); 301 305 } 302 306 return true; … … 313 317 { 314 318 MatrixCounter = MCounter; 315 Header = Malloc<char*>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *Header");316 Matrix = Malloc<double**>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: ***Matrix"); // one more each for the total molecule317 RowCounter = Malloc<int>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *RowCounter");318 ColumnCounter = Malloc<int>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *ColumnCounter");319 Header = new char*[MatrixCounter + 1]; 320 Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule 321 RowCounter = new int[MatrixCounter + 1]; 322 ColumnCounter = new int[MatrixCounter + 1]; 319 323 for(int i=MatrixCounter+1;i--;) { 320 Header[i] = Malloc<char>(1024, "MatrixContainer::AllocateMatrix: *Header[i]");324 Header[i] = new char[1024]; 321 325 strncpy(Header[i], GivenHeader[i], 1023); 322 326 RowCounter[i] = RCounter[i]; 323 327 ColumnCounter[i] = CCounter[i]; 324 Matrix[i] = Malloc<double*>(RowCounter[i] + 1, "MatrixContainer::AllocateMatrix: **Matrix[]");328 Matrix[i] = new double*[RowCounter[i] + 1]; 325 329 for(int j=RowCounter[i]+1;j--;) { 326 Matrix[i][j] = Malloc<double>(ColumnCounter[i], "MatrixContainer::AllocateMatrix: *Matrix[][]");330 Matrix[i][j] = new double[ColumnCounter[i]]; 327 331 for(int k=ColumnCounter[i];k--;) 328 332 Matrix[i][j][k] = 0.; … … 474 478 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 475 479 line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix; 476 Free(&FragmentNumber);480 delete[](FragmentNumber); 477 481 output.open(line.str().c_str(), ios::out); 478 482 if (output == NULL) { … … 530 534 { 531 535 DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl); 532 Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");536 Indices = new int*[MatrixCounter + 1]; 533 537 for(int i=MatrixCounter+1;i--;) { 534 Indices[i] = Malloc<int>(RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");538 Indices[i] = new int[RowCounter[i]]; 535 539 for(int j=RowCounter[i];j--;) 536 540 Indices[i][j] = j; … … 589 593 // allocate last plus one matrix 590 594 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 591 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");595 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 592 596 for(int j=0;j<=RowCounter[MatrixCounter];j++) 593 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");597 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 594 598 595 599 // try independently to parse global energysuffix file if present … … 616 620 617 621 DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl); 618 Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");622 Indices = new int*[MatrixCounter + 1]; 619 623 line << name << FRAGMENTPREFIX << FORCESFILE; 620 624 input.open(line.str().c_str(), ios::in); … … 629 633 line.str(filename); 630 634 // parse the values 631 Indices[i] = Malloc<int>(RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]");635 Indices[i] = new int[RowCounter[i]]; 632 636 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 633 637 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 634 Free(&FragmentNumber);638 delete[](FragmentNumber); 635 639 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 636 640 line >> Indices[i][j]; … … 639 643 //Log() << Verbose(0) << endl; 640 644 } 641 Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]");645 Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]]; 642 646 for(int j=RowCounter[MatrixCounter];j--;) { 643 647 Indices[MatrixCounter][j] = j; … … 725 729 // allocate last plus one matrix 726 730 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 727 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");731 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 728 732 for(int j=0;j<=RowCounter[MatrixCounter];j++) 729 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");733 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 730 734 731 735 // try independently to parse global forcesuffix file if present … … 754 758 755 759 DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl); 756 Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");760 Indices = new int*[MatrixCounter + 1]; 757 761 line << name << FRAGMENTPREFIX << FORCESFILE; 758 762 input.open(line.str().c_str(), ios::in); … … 767 771 line.str(filename); 768 772 // parse the values 769 Indices[i] = Malloc<int>(RowCounter[i], "HessianMatrix::ParseIndices: *Indices[]");773 Indices[i] = new int[RowCounter[i]]; 770 774 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 771 775 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 772 Free(&FragmentNumber);776 delete[](FragmentNumber); 773 777 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 774 778 line >> Indices[i][j]; … … 777 781 //Log() << Verbose(0) << endl; 778 782 } 779 Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "HessianMatrix::ParseIndices: *Indices[]");783 Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]]; 780 784 for(int j=RowCounter[MatrixCounter];j--;) { 781 785 Indices[MatrixCounter][j] = j; … … 953 957 // allocate last plus one matrix 954 958 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 955 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");959 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 956 960 for(int j=0;j<=RowCounter[MatrixCounter];j++) 957 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");961 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 958 962 959 963 // try independently to parse global forcesuffix file if present … … 985 989 KeySetsContainer::~KeySetsContainer() { 986 990 for(int i=FragmentCounter;i--;) 987 Free(&KeySets[i]);991 delete[](KeySets[i]); 988 992 for(int i=Order;i--;) 989 Free(&OrderSet[i]);990 Free(&KeySets);991 Free(&OrderSet);992 Free(&AtomCounter);993 Free(&FragmentsPerOrder);993 delete[](OrderSet[i]); 994 delete[](KeySets); 995 delete[](OrderSet); 996 delete[](AtomCounter); 997 delete[](FragmentsPerOrder); 994 998 }; 995 999 … … 1008 1012 FragmentCounter = FCounter; 1009 1013 DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl); 1010 KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");1014 KeySets = new int*[FragmentCounter]; 1011 1015 for(int i=FragmentCounter;i--;) 1012 1016 KeySets[i] = NULL; … … 1018 1022 } 1019 1023 1020 AtomCounter = Malloc<int>(FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter");1024 AtomCounter = new int[FragmentCounter]; 1021 1025 for(int i=0;(i<FragmentCounter) && (!input.eof());i++) { 1022 1026 stringstream line; 1023 1027 AtomCounter[i] = ACounter[i]; 1024 1028 // parse the values 1025 KeySets[i] = Malloc<int>(AtomCounter[i], "KeySetsContainer::ParseKeySets: *KeySets[]");1029 KeySets[i] = new int[AtomCounter[i]]; 1026 1030 for(int j=AtomCounter[i];j--;) 1027 1031 KeySets[i][j] = -1; 1028 1032 FragmentNumber = FixedDigitNumber(FragmentCounter, i); 1029 1033 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:"; 1030 Free(&FragmentNumber);1034 delete[](FragmentNumber); 1031 1035 input.getline(filename, 1023); 1032 1036 line.str(filename); … … 1062 1066 1063 1067 // scan through all to determine fragments per order 1064 FragmentsPerOrder = Malloc<int>(Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder");1068 FragmentsPerOrder = new int[Order]; 1065 1069 for(int i=Order;i--;) 1066 1070 FragmentsPerOrder[i] = 0; … … 1076 1080 1077 1081 // scan through all to gather indices to each order set 1078 OrderSet = Malloc<int*>(Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet");1082 OrderSet = new int*[Order]; 1079 1083 for(int i=Order;i--;) 1080 OrderSet[i] = Malloc<int>(FragmentsPerOrder[i], "KeySetsContainer::ParseManyBodyTermsKeySetsContainer::ParseManyBodyTerms: *OrderSet[]");1084 OrderSet[i] = new int[FragmentsPerOrder[i]]; 1081 1085 for(int i=Order;i--;) 1082 1086 FragmentsPerOrder[i] = 0;
Note:
See TracChangeset
for help on using the changeset viewer.
