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