Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/parser.cpp

    re359a8 ra67d19  
    77// ======================================= INCLUDES ==========================================
    88
     9#include <cstring>
     10
    911#include "helpers.hpp"
    1012#include "memoryallocator.hpp"
     
    3032  if (input == NULL) {
    3133    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);
    3335    return false;
    3436  }
     
    107109bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix)
    108110{
    109   Log() << Verbose(0) << "Initialising indices";
     111  DoLog(0) && (Log() << Verbose(0) << "Initialising indices");
    110112  if (Matrix == NULL) {
    111     Log() << Verbose(0) << " with trivial mapping." << endl;
     113    DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);
    112114    Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
    113115    for(int i=MatrixCounter+1;i--;) {
     
    117119    }
    118120  } else {
    119     Log() << Verbose(0) << " from other MatrixContainer." << endl;
     121    DoLog(0) && (Log() << Verbose(0) << " from other MatrixContainer." << endl);
    120122    if (MatrixCounter != Matrix->MatrixCounter)
    121123      return false;
     
    156158
    157159  input.open(name, ios::in);
    158   //Log() << Verbose(0) << "Opening " << name << " ... "  << input << endl;
     160  //Log() << Verbose(1) << "Opening " << name << " ... "  << input << endl;
    159161  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();
    162164    return false;
    163165  }
     
    179181  }
    180182  //Log() << Verbose(0) << line.str() << endl;
    181   //Log() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
     183  //Log() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
    182184  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);
    184186    performCriticalExit();
    185187  }
     
    195197    }
    196198  }
    197   //Log() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
     199  //Log() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
    198200  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);
    200202    performCriticalExit();
    201203  }
     
    218220      input.getline(filename, 1023);
    219221      stringstream lines(filename);
    220       //Log() << Verbose(0) << "Matrix at level " << j << ":";// << filename << endl;
     222      //Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl;
    221223      for(int k=skipcolumns;k--;)
    222224        lines >> filename;
    223225      for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
    224226        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;
    226228      }
    227       //Log() << Verbose(0) << endl;
    228229      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");
    229230      for(int j=ColumnCounter[MatrixNr];j--;)
     
    231232    }
    232233  } 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);
    234235  }
    235236  input.close();
     
    268269  input.open(file.str().c_str(), ios::in);
    269270  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);
    271272    return false;
    272273  }
     
    277278  }
    278279  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);
    282283  Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule
    283284  Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
     
    432433              //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl;
    433434              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);
    435436                performCriticalExit();
    436437                return false;
     
    468469  char *FragmentNumber = NULL;
    469470
    470   Log() << Verbose(0) << "Writing fragment files." << endl;
     471  DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl);
    471472  for(int i=0;i<MatrixCounter;i++) {
    472473    stringstream line;
     
    476477    output.open(line.str().c_str(), ios::out);
    477478    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);
    479480      performCriticalExit();
    480481      return false;
     
    502503  stringstream line;
    503504
    504   Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl;
     505  DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl);
    505506  line << name << prefix << suffix;
    506507  output.open(line.str().c_str(), ios::out);
    507508  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);
    509510    performCriticalExit();
    510511    return false;
     
    528529bool EnergyMatrix::ParseIndices()
    529530{
    530   Log() << Verbose(0) << "Parsing energy indices." << endl;
     531  DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
    531532  Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");
    532533  for(int i=MatrixCounter+1;i--;) {
     
    587588    }
    588589    // 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);
    590591    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    591592    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    614615  stringstream line;
    615616
    616   Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl;
     617  DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);
    617618  Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");
    618619  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    620621  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    621622  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);
    623624    return false;
    624625  }
     
    663664      int j = Indices[ FragmentNr ][l];
    664665      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);
    666667        performCriticalExit();
    667668        return false;
     
    699700    input.open(file.str().c_str(), ios::in);
    700701    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);
    702703      return false;
    703704    }
     
    723724 
    724725    // 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);
    726727    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    727728    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    752753  stringstream line;
    753754 
    754   Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl;
     755  DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);
    755756  Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");
    756757  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    758759  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    759760  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);
    761762    return false;
    762763  }
     
    801802      int j = Indices[ FragmentNr ][l];
    802803      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);
    804805        performCriticalExit();
    805806        return false;
     
    809810          int k = Indices[ FragmentNr ][m];
    810811          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);
    812813            performCriticalExit();
    813814            return false;
     
    862863              //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl;
    863864              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);
    865866                performCriticalExit();
    866867                return false;
     
    880881                  //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl;
    881882                  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);
    883884                    performCriticalExit();
    884885                    return false;
     
    929930    input.open(file.str().c_str(), ios::in);
    930931    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);
    932933      return false;
    933934    }
     
    951952 
    952953    // 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);
    954955    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    955956    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    10061007
    10071008  FragmentCounter = FCounter;
    1008   Log() << Verbose(0) << "Parsing key sets." << endl;
     1009  DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
    10091010  KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");
    10101011  for(int i=FragmentCounter;i--;)
     
    10131014  input.open(file.str().c_str(), ios::in);
    10141015  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);
    10161017    return false;
    10171018  }
     
    10471048  int Counter;
    10481049
    1049   Log() << Verbose(0) << "Creating Fragment terms." << endl;
     1050  DoLog(0) && (Log() << Verbose(0) << "Creating Fragment terms." << endl);
    10501051  // scan through all to determine maximum order
    10511052  Order=0;
     
    10581059      Order = Counter;
    10591060  }
    1060   Log() << Verbose(0) << "Found Order is " << Order << "." << endl;
     1061  DoLog(0) && (Log() << Verbose(0) << "Found Order is " << Order << "." << endl);
    10611062
    10621063  // scan through all to determine fragments per order
     
    10721073  }
    10731074  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);
    10751076
    10761077  // scan through all to gather indices to each order set
     
    10881089    FragmentsPerOrder[Counter-1]++;
    10891090  }
    1090   Log() << Verbose(0) << "Printing OrderSet." << endl;
     1091  DoLog(0) && (Log() << Verbose(0) << "Printing OrderSet." << endl);
    10911092  for(int i=0;i<Order;i++) {
    10921093    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);
    10981099
    10991100
Note: See TracChangeset for help on using the changeset viewer.