Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/parser.cpp

    ra67d19 re359a8  
    77// ======================================= INCLUDES ==========================================
    88
    9 #include <cstring>
    10 
    119#include "helpers.hpp"
    1210#include "memoryallocator.hpp"
     
    3230  if (input == NULL) {
    3331    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;
    3533    return false;
    3634  }
     
    109107bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix)
    110108{
    111   DoLog(0) && (Log() << Verbose(0) << "Initialising indices");
     109  Log() << Verbose(0) << "Initialising indices";
    112110  if (Matrix == NULL) {
    113     DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);
     111    Log() << Verbose(0) << " with trivial mapping." << endl;
    114112    Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
    115113    for(int i=MatrixCounter+1;i--;) {
     
    119117    }
    120118  } else {
    121     DoLog(0) && (Log() << Verbose(0) << " from other MatrixContainer." << endl);
     119    Log() << Verbose(0) << " from other MatrixContainer." << endl;
    122120    if (MatrixCounter != Matrix->MatrixCounter)
    123121      return false;
     
    158156
    159157  input.open(name, ios::in);
    160   //Log() << Verbose(1) << "Opening " << name << " ... "  << input << endl;
     158  //Log() << Verbose(0) << "Opening " << name << " ... "  << input << endl;
    161159  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();
    164162    return false;
    165163  }
     
    181179  }
    182180  //Log() << Verbose(0) << line.str() << endl;
    183   //Log() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
     181  //Log() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
    184182  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;
    186184    performCriticalExit();
    187185  }
     
    197195    }
    198196  }
    199   //Log() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
     197  //Log() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
    200198  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;
    202200    performCriticalExit();
    203201  }
     
    220218      input.getline(filename, 1023);
    221219      stringstream lines(filename);
    222       //Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl;
     220      //Log() << Verbose(0) << "Matrix at level " << j << ":";// << filename << endl;
    223221      for(int k=skipcolumns;k--;)
    224222        lines >> filename;
    225223      for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
    226224        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];;
    228226      }
     227      //Log() << Verbose(0) << endl;
    229228      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");
    230229      for(int j=ColumnCounter[MatrixNr];j--;)
     
    232231    }
    233232  } 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;
    235234  }
    236235  input.close();
     
    269268  input.open(file.str().c_str(), ios::in);
    270269  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;
    272271    return false;
    273272  }
     
    278277  }
    279278  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;
    283282  Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule
    284283  Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
     
    433432              //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl;
    434433              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;
    436435                performCriticalExit();
    437436                return false;
     
    469468  char *FragmentNumber = NULL;
    470469
    471   DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl);
     470  Log() << Verbose(0) << "Writing fragment files." << endl;
    472471  for(int i=0;i<MatrixCounter;i++) {
    473472    stringstream line;
     
    477476    output.open(line.str().c_str(), ios::out);
    478477    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;
    480479      performCriticalExit();
    481480      return false;
     
    503502  stringstream line;
    504503
    505   DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl);
     504  Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl;
    506505  line << name << prefix << suffix;
    507506  output.open(line.str().c_str(), ios::out);
    508507  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;
    510509    performCriticalExit();
    511510    return false;
     
    529528bool EnergyMatrix::ParseIndices()
    530529{
    531   DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
     530  Log() << Verbose(0) << "Parsing energy indices." << endl;
    532531  Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");
    533532  for(int i=MatrixCounter+1;i--;) {
     
    588587    }
    589588    // 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;
    591590    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    592591    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    615614  stringstream line;
    616615
    617   DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);
     616  Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl;
    618617  Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");
    619618  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    621620  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    622621  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;
    624623    return false;
    625624  }
     
    664663      int j = Indices[ FragmentNr ][l];
    665664      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;
    667666        performCriticalExit();
    668667        return false;
     
    700699    input.open(file.str().c_str(), ios::in);
    701700    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;
    703702      return false;
    704703    }
     
    724723 
    725724    // 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;
    727726    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    728727    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    753752  stringstream line;
    754753 
    755   DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);
     754  Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl;
    756755  Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");
    757756  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    759758  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    760759  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;
    762761    return false;
    763762  }
     
    802801      int j = Indices[ FragmentNr ][l];
    803802      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;
    805804        performCriticalExit();
    806805        return false;
     
    810809          int k = Indices[ FragmentNr ][m];
    811810          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;
    813812            performCriticalExit();
    814813            return false;
     
    863862              //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl;
    864863              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;
    866865                performCriticalExit();
    867866                return false;
     
    881880                  //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl;
    882881                  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;
    884883                    performCriticalExit();
    885884                    return false;
     
    930929    input.open(file.str().c_str(), ios::in);
    931930    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;
    933932      return false;
    934933    }
     
    952951 
    953952    // 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;
    955954    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    956955    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    10071006
    10081007  FragmentCounter = FCounter;
    1009   DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
     1008  Log() << Verbose(0) << "Parsing key sets." << endl;
    10101009  KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");
    10111010  for(int i=FragmentCounter;i--;)
     
    10141013  input.open(file.str().c_str(), ios::in);
    10151014  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;
    10171016    return false;
    10181017  }
     
    10481047  int Counter;
    10491048
    1050   DoLog(0) && (Log() << Verbose(0) << "Creating Fragment terms." << endl);
     1049  Log() << Verbose(0) << "Creating Fragment terms." << endl;
    10511050  // scan through all to determine maximum order
    10521051  Order=0;
     
    10591058      Order = Counter;
    10601059  }
    1061   DoLog(0) && (Log() << Verbose(0) << "Found Order is " << Order << "." << endl);
     1060  Log() << Verbose(0) << "Found Order is " << Order << "." << endl;
    10621061
    10631062  // scan through all to determine fragments per order
     
    10731072  }
    10741073  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;
    10761075
    10771076  // scan through all to gather indices to each order set
     
    10891088    FragmentsPerOrder[Counter-1]++;
    10901089  }
    1091   DoLog(0) && (Log() << Verbose(0) << "Printing OrderSet." << endl);
     1090  Log() << Verbose(0) << "Printing OrderSet." << endl;
    10921091  for(int i=0;i<Order;i++) {
    10931092    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;
    10991098
    11001099
Note: See TracChangeset for help on using the changeset viewer.