Changes in src/parser.cpp [e138de:a67d19]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/parser.cpp
re138de 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; 162 DoeLog(1) && (eLog()<< Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl); 163 //performCriticalExit(); 161 164 return false; 162 165 } … … 178 181 } 179 182 //Log() << Verbose(0) << line.str() << endl; 180 //Log() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl; 181 if (ColumnCounter[MatrixNr] == 0) 182 eLog() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl; 183 //Log() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl; 184 if (ColumnCounter[MatrixNr] == 0) { 185 DoeLog(0) && (eLog()<< Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl); 186 performCriticalExit(); 187 } 183 188 184 189 // scan rest for number of rows/lines … … 192 197 } 193 198 } 194 //Log() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl; 195 if (RowCounter[MatrixNr] == 0) 196 eLog() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl; 199 //Log() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl; 200 if (RowCounter[MatrixNr] == 0) { 201 DoeLog(0) && (eLog()<< Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl); 202 performCriticalExit(); 203 } 197 204 198 205 // allocate matrix if it's not zero dimension in one direction … … 213 220 input.getline(filename, 1023); 214 221 stringstream lines(filename); 215 //Log() << Verbose( 0) << "Matrix at level " << j << ":";// << filename << endl;222 //Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl; 216 223 for(int k=skipcolumns;k--;) 217 224 lines >> filename; 218 225 for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) { 219 226 lines >> Matrix[MatrixNr][j][k]; 220 //Log() << Verbose( 0) << " " << setprecision(2) << Matrix[MatrixNr][j][k];;227 //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl; 221 228 } 222 //Log() << Verbose(0) << endl;223 229 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]"); 224 230 for(int j=ColumnCounter[MatrixNr];j--;) … … 226 232 } 227 233 } else { 228 eLog() << Verbose(0) << "ERROR: 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); 229 235 } 230 236 input.close(); … … 263 269 input.open(file.str().c_str(), ios::in); 264 270 if (input == NULL) { 265 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); 266 272 return false; 267 273 } … … 272 278 } 273 279 input.close(); 274 Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl;275 276 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); 277 283 Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule 278 284 Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule … … 427 433 //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl; 428 434 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 429 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); 436 performCriticalExit(); 430 437 return false; 431 438 } … … 462 469 char *FragmentNumber = NULL; 463 470 464 Log() << Verbose(0) << "Writing fragment files." << endl;471 DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl); 465 472 for(int i=0;i<MatrixCounter;i++) { 466 473 stringstream line; … … 470 477 output.open(line.str().c_str(), ios::out); 471 478 if (output == NULL) { 472 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); 480 performCriticalExit(); 473 481 return false; 474 482 } … … 495 503 stringstream line; 496 504 497 Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl;505 DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl); 498 506 line << name << prefix << suffix; 499 507 output.open(line.str().c_str(), ios::out); 500 508 if (output == NULL) { 501 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); 510 performCriticalExit(); 502 511 return false; 503 512 } … … 520 529 bool EnergyMatrix::ParseIndices() 521 530 { 522 Log() << Verbose(0) << "Parsing energy indices." << endl;531 DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl); 523 532 Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices"); 524 533 for(int i=MatrixCounter+1;i--;) { … … 579 588 } 580 589 // allocate last plus one matrix 581 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); 582 591 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 583 592 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 606 615 stringstream line; 607 616 608 Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl;617 DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl); 609 618 Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices"); 610 619 line << name << FRAGMENTPREFIX << FORCESFILE; … … 612 621 //Log() << Verbose(0) << "Opening " << line.str() << " ... " << input << endl; 613 622 if (input == NULL) { 614 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); 615 624 return false; 616 625 } … … 655 664 int j = Indices[ FragmentNr ][l]; 656 665 if (j > RowCounter[MatrixCounter]) { 657 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); 667 performCriticalExit(); 658 668 return false; 659 669 } … … 690 700 input.open(file.str().c_str(), ios::in); 691 701 if (input == NULL) { 692 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); 693 703 return false; 694 704 } … … 714 724 715 725 // allocate last plus one matrix 716 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); 717 727 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 718 728 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 743 753 stringstream line; 744 754 745 Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl;755 DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl); 746 756 Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices"); 747 757 line << name << FRAGMENTPREFIX << FORCESFILE; … … 749 759 //Log() << Verbose(0) << "Opening " << line.str() << " ... " << input << endl; 750 760 if (input == NULL) { 751 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); 752 762 return false; 753 763 } … … 792 802 int j = Indices[ FragmentNr ][l]; 793 803 if (j > RowCounter[MatrixCounter]) { 794 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); 805 performCriticalExit(); 795 806 return false; 796 807 } … … 799 810 int k = Indices[ FragmentNr ][m]; 800 811 if (k > ColumnCounter[MatrixCounter]) { 801 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); 813 performCriticalExit(); 802 814 return false; 803 815 } … … 851 863 //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl; 852 864 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 853 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); 866 performCriticalExit(); 854 867 return false; 855 868 } … … 868 881 //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl; 869 882 if (n > ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 870 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); 884 performCriticalExit(); 871 885 return false; 872 886 } … … 916 930 input.open(file.str().c_str(), ios::in); 917 931 if (input == NULL) { 918 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); 919 933 return false; 920 934 } … … 938 952 939 953 // allocate last plus one matrix 940 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); 941 955 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 942 956 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 993 1007 994 1008 FragmentCounter = FCounter; 995 Log() << Verbose(0) << "Parsing key sets." << endl;1009 DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl); 996 1010 KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets"); 997 1011 for(int i=FragmentCounter;i--;) … … 1000 1014 input.open(file.str().c_str(), ios::in); 1001 1015 if (input == NULL) { 1002 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); 1003 1017 return false; 1004 1018 } … … 1034 1048 int Counter; 1035 1049 1036 Log() << Verbose(0) << "Creating Fragment terms." << endl;1050 DoLog(0) && (Log() << Verbose(0) << "Creating Fragment terms." << endl); 1037 1051 // scan through all to determine maximum order 1038 1052 Order=0; … … 1045 1059 Order = Counter; 1046 1060 } 1047 Log() << Verbose(0) << "Found Order is " << Order << "." << endl;1061 DoLog(0) && (Log() << Verbose(0) << "Found Order is " << Order << "." << endl); 1048 1062 1049 1063 // scan through all to determine fragments per order … … 1059 1073 } 1060 1074 for(int i=0;i<Order;i++) 1061 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); 1062 1076 1063 1077 // scan through all to gather indices to each order set … … 1075 1089 FragmentsPerOrder[Counter-1]++; 1076 1090 } 1077 Log() << Verbose(0) << "Printing OrderSet." << endl;1091 DoLog(0) && (Log() << Verbose(0) << "Printing OrderSet." << endl); 1078 1092 for(int i=0;i<Order;i++) { 1079 1093 for (int j=0;j<FragmentsPerOrder[i];j++) { 1080 Log() << Verbose(0) << " " << OrderSet[i][j];1081 } 1082 Log() << Verbose(0) << endl;1083 } 1084 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); 1085 1099 1086 1100
Note:
See TracChangeset
for help on using the changeset viewer.