Changes in src/parser.cpp [a67d19:e359a8]
- File:
-
- 1 edited
-
src/parser.cpp (modified) (36 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/parser.cpp
ra67d19 re359a8 7 7 // ======================================= INCLUDES ========================================== 8 8 9 #include <cstring>10 11 9 #include "helpers.hpp" 12 10 #include "memoryallocator.hpp" … … 32 30 if (input == NULL) { 33 31 if (!test) 34 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << filename << ", is the directory correct?" << endl);32 Log() << Verbose(0) << endl << "Unable to open " << filename << ", is the directory correct?" << endl; 35 33 return false; 36 34 } … … 109 107 bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix) 110 108 { 111 DoLog(0) && (Log() << Verbose(0) << "Initialising indices");109 Log() << Verbose(0) << "Initialising indices"; 112 110 if (Matrix == NULL) { 113 DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);111 Log() << Verbose(0) << " with trivial mapping." << endl; 114 112 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices"); 115 113 for(int i=MatrixCounter+1;i--;) { … … 119 117 } 120 118 } else { 121 DoLog(0) && (Log() << Verbose(0) << " from other MatrixContainer." << endl);119 Log() << Verbose(0) << " from other MatrixContainer." << endl; 122 120 if (MatrixCounter != Matrix->MatrixCounter) 123 121 return false; … … 158 156 159 157 input.open(name, ios::in); 160 //Log() << Verbose( 1) << "Opening " << name << " ... " << input << endl;158 //Log() << Verbose(0) << "Opening " << name << " ... " << input << endl; 161 159 if (input == NULL) { 162 DoeLog(1) && (eLog()<< Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl);163 //performCriticalExit();160 eLog() << Verbose(0) << endl << "Unable to open " << name << ", is the directory correct?" << endl; 161 performCriticalExit(); 164 162 return false; 165 163 } … … 181 179 } 182 180 //Log() << Verbose(0) << line.str() << endl; 183 //Log() << Verbose( 1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;181 //Log() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl; 184 182 if (ColumnCounter[MatrixNr] == 0) { 185 DoeLog(0) && (eLog()<< Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl);183 eLog() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl; 186 184 performCriticalExit(); 187 185 } … … 197 195 } 198 196 } 199 //Log() << Verbose( 1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;197 //Log() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl; 200 198 if (RowCounter[MatrixNr] == 0) { 201 DoeLog(0) && (eLog()<< Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl);199 eLog() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl; 202 200 performCriticalExit(); 203 201 } … … 220 218 input.getline(filename, 1023); 221 219 stringstream lines(filename); 222 //Log() << Verbose( 2) << "Matrix at level " << j << ":";// << filename << endl;220 //Log() << Verbose(0) << "Matrix at level " << j << ":";// << filename << endl; 223 221 for(int k=skipcolumns;k--;) 224 222 lines >> filename; 225 223 for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) { 226 224 lines >> Matrix[MatrixNr][j][k]; 227 //Log() << Verbose( 1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl;225 //Log() << Verbose(0) << " " << setprecision(2) << Matrix[MatrixNr][j][k];; 228 226 } 227 //Log() << Verbose(0) << endl; 229 228 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]"); 230 229 for(int j=ColumnCounter[MatrixNr];j--;) … … 232 231 } 233 232 } else { 234 DoeLog(1) && (eLog()<< Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl);233 eLog() << Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl; 235 234 } 236 235 input.close(); … … 269 268 input.open(file.str().c_str(), ios::in); 270 269 if (input == NULL) { 271 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl);270 Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl; 272 271 return false; 273 272 } … … 278 277 } 279 278 input.close(); 280 DoLog(0) && (Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl);281 282 DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl);279 Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl; 280 281 Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl; 283 282 Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule 284 283 Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule … … 433 432 //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl; 434 433 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 435 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);434 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl; 436 435 performCriticalExit(); 437 436 return false; … … 469 468 char *FragmentNumber = NULL; 470 469 471 DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl);470 Log() << Verbose(0) << "Writing fragment files." << endl; 472 471 for(int i=0;i<MatrixCounter;i++) { 473 472 stringstream line; … … 477 476 output.open(line.str().c_str(), ios::out); 478 477 if (output == NULL) { 479 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open output energy file " << line.str() << "!" << endl);478 eLog() << Verbose(0) << "Unable to open output energy file " << line.str() << "!" << endl; 480 479 performCriticalExit(); 481 480 return false; … … 503 502 stringstream line; 504 503 505 DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl);504 Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl; 506 505 line << name << prefix << suffix; 507 506 output.open(line.str().c_str(), ios::out); 508 507 if (output == NULL) { 509 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open output matrix file " << line.str() << "!" << endl);508 eLog() << Verbose(0) << "Unable to open output matrix file " << line.str() << "!" << endl; 510 509 performCriticalExit(); 511 510 return false; … … 529 528 bool EnergyMatrix::ParseIndices() 530 529 { 531 DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);530 Log() << Verbose(0) << "Parsing energy indices." << endl; 532 531 Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices"); 533 532 for(int i=MatrixCounter+1;i--;) { … … 588 587 } 589 588 // allocate last plus one matrix 590 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);589 Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl; 591 590 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 592 591 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 615 614 stringstream line; 616 615 617 DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);616 Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl; 618 617 Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices"); 619 618 line << name << FRAGMENTPREFIX << FORCESFILE; … … 621 620 //Log() << Verbose(0) << "Opening " << line.str() << " ... " << input << endl; 622 621 if (input == NULL) { 623 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl);622 Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl; 624 623 return false; 625 624 } … … 664 663 int j = Indices[ FragmentNr ][l]; 665 664 if (j > RowCounter[MatrixCounter]) { 666 DoeLog(0) && (eLog()<< Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl);665 eLog() << Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl; 667 666 performCriticalExit(); 668 667 return false; … … 700 699 input.open(file.str().c_str(), ios::in); 701 700 if (input == NULL) { 702 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl);701 Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl; 703 702 return false; 704 703 } … … 724 723 725 724 // allocate last plus one matrix 726 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);725 Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl; 727 726 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 728 727 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 753 752 stringstream line; 754 753 755 DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);754 Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl; 756 755 Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices"); 757 756 line << name << FRAGMENTPREFIX << FORCESFILE; … … 759 758 //Log() << Verbose(0) << "Opening " << line.str() << " ... " << input << endl; 760 759 if (input == NULL) { 761 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl);760 Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl; 762 761 return false; 763 762 } … … 802 801 int j = Indices[ FragmentNr ][l]; 803 802 if (j > RowCounter[MatrixCounter]) { 804 DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl);803 eLog() << Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl; 805 804 performCriticalExit(); 806 805 return false; … … 810 809 int k = Indices[ FragmentNr ][m]; 811 810 if (k > ColumnCounter[MatrixCounter]) { 812 DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl);811 eLog() << Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl; 813 812 performCriticalExit(); 814 813 return false; … … 863 862 //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl; 864 863 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 865 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);864 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl; 866 865 performCriticalExit(); 867 866 return false; … … 881 880 //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl; 882 881 if (n > ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 883 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);882 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl; 884 883 performCriticalExit(); 885 884 return false; … … 930 929 input.open(file.str().c_str(), ios::in); 931 930 if (input == NULL) { 932 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl);931 Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl; 933 932 return false; 934 933 } … … 952 951 953 952 // allocate last plus one matrix 954 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);953 Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl; 955 954 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 956 955 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 1007 1006 1008 1007 FragmentCounter = FCounter; 1009 DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);1008 Log() << Verbose(0) << "Parsing key sets." << endl; 1010 1009 KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets"); 1011 1010 for(int i=FragmentCounter;i--;) … … 1014 1013 input.open(file.str().c_str(), ios::in); 1015 1014 if (input == NULL) { 1016 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl);1015 Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl; 1017 1016 return false; 1018 1017 } … … 1048 1047 int Counter; 1049 1048 1050 DoLog(0) && (Log() << Verbose(0) << "Creating Fragment terms." << endl);1049 Log() << Verbose(0) << "Creating Fragment terms." << endl; 1051 1050 // scan through all to determine maximum order 1052 1051 Order=0; … … 1059 1058 Order = Counter; 1060 1059 } 1061 DoLog(0) && (Log() << Verbose(0) << "Found Order is " << Order << "." << endl);1060 Log() << Verbose(0) << "Found Order is " << Order << "." << endl; 1062 1061 1063 1062 // scan through all to determine fragments per order … … 1073 1072 } 1074 1073 for(int i=0;i<Order;i++) 1075 DoLog(0) && (Log() << Verbose(0) << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl);1074 Log() << Verbose(0) << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl; 1076 1075 1077 1076 // scan through all to gather indices to each order set … … 1089 1088 FragmentsPerOrder[Counter-1]++; 1090 1089 } 1091 DoLog(0) && (Log() << Verbose(0) << "Printing OrderSet." << endl);1090 Log() << Verbose(0) << "Printing OrderSet." << endl; 1092 1091 for(int i=0;i<Order;i++) { 1093 1092 for (int j=0;j<FragmentsPerOrder[i];j++) { 1094 DoLog(0) && (Log() << Verbose(0) << " " << OrderSet[i][j]);1095 } 1096 DoLog(0) && (Log() << Verbose(0) << endl);1097 } 1098 DoLog(0) && (Log() << Verbose(0) << endl);1093 Log() << Verbose(0) << " " << OrderSet[i][j]; 1094 } 1095 Log() << Verbose(0) << endl; 1096 } 1097 Log() << Verbose(0) << endl; 1099 1098 1100 1099
Note:
See TracChangeset
for help on using the changeset viewer.
