Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/parser.cpp

    re138de 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;
     162    DoeLog(1) && (eLog()<< Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl);
     163    //performCriticalExit();
    161164    return false;
    162165  }
     
    178181  }
    179182  //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  }
    183188 
    184189  // scan rest for number of rows/lines
     
    192197    }
    193198  }
    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  }
    197204
    198205  // allocate matrix if it's not zero dimension in one direction
     
    213220      input.getline(filename, 1023);
    214221      stringstream lines(filename);
    215       //Log() << Verbose(0) << "Matrix at level " << j << ":";// << filename << endl;
     222      //Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl;
    216223      for(int k=skipcolumns;k--;)
    217224        lines >> filename;
    218225      for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
    219226        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;
    221228      }
    222       //Log() << Verbose(0) << endl;
    223229      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");
    224230      for(int j=ColumnCounter[MatrixNr];j--;)
     
    226232    }
    227233  } 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);
    229235  }
    230236  input.close();
     
    263269  input.open(file.str().c_str(), ios::in);
    264270  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);
    266272    return false;
    267273  }
     
    272278  }
    273279  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);
    277283  Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule
    278284  Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
     
    427433              //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl;
    428434              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();
    430437                return false;
    431438              }
     
    462469  char *FragmentNumber = NULL;
    463470
    464   Log() << Verbose(0) << "Writing fragment files." << endl;
     471  DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl);
    465472  for(int i=0;i<MatrixCounter;i++) {
    466473    stringstream line;
     
    470477    output.open(line.str().c_str(), ios::out);
    471478    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();
    473481      return false;
    474482    }
     
    495503  stringstream line;
    496504
    497   Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl;
     505  DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl);
    498506  line << name << prefix << suffix;
    499507  output.open(line.str().c_str(), ios::out);
    500508  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();
    502511    return false;
    503512  }
     
    520529bool EnergyMatrix::ParseIndices()
    521530{
    522   Log() << Verbose(0) << "Parsing energy indices." << endl;
     531  DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
    523532  Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");
    524533  for(int i=MatrixCounter+1;i--;) {
     
    579588    }
    580589    // 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);
    582591    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    583592    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    606615  stringstream line;
    607616
    608   Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl;
     617  DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);
    609618  Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");
    610619  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    612621  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    613622  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);
    615624    return false;
    616625  }
     
    655664      int j = Indices[ FragmentNr ][l];
    656665      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();
    658668        return false;
    659669      }
     
    690700    input.open(file.str().c_str(), ios::in);
    691701    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);
    693703      return false;
    694704    }
     
    714724 
    715725    // 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);
    717727    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    718728    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    743753  stringstream line;
    744754 
    745   Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl;
     755  DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);
    746756  Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");
    747757  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    749759  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    750760  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);
    752762    return false;
    753763  }
     
    792802      int j = Indices[ FragmentNr ][l];
    793803      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();
    795806        return false;
    796807      }
     
    799810          int k = Indices[ FragmentNr ][m];
    800811          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();
    802814            return false;
    803815          }
     
    851863              //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl;
    852864              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();
    854867                return false;
    855868              }
     
    868881                  //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl;
    869882                  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();
    871885                    return false;
    872886                  }
     
    916930    input.open(file.str().c_str(), ios::in);
    917931    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);
    919933      return false;
    920934    }
     
    938952 
    939953    // 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);
    941955    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    942956    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    9931007
    9941008  FragmentCounter = FCounter;
    995   Log() << Verbose(0) << "Parsing key sets." << endl;
     1009  DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
    9961010  KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");
    9971011  for(int i=FragmentCounter;i--;)
     
    10001014  input.open(file.str().c_str(), ios::in);
    10011015  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);
    10031017    return false;
    10041018  }
     
    10341048  int Counter;
    10351049
    1036   Log() << Verbose(0) << "Creating Fragment terms." << endl;
     1050  DoLog(0) && (Log() << Verbose(0) << "Creating Fragment terms." << endl);
    10371051  // scan through all to determine maximum order
    10381052  Order=0;
     
    10451059      Order = Counter;
    10461060  }
    1047   Log() << Verbose(0) << "Found Order is " << Order << "." << endl;
     1061  DoLog(0) && (Log() << Verbose(0) << "Found Order is " << Order << "." << endl);
    10481062
    10491063  // scan through all to determine fragments per order
     
    10591073  }
    10601074  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);
    10621076
    10631077  // scan through all to gather indices to each order set
     
    10751089    FragmentsPerOrder[Counter-1]++;
    10761090  }
    1077   Log() << Verbose(0) << "Printing OrderSet." << endl;
     1091  DoLog(0) && (Log() << Verbose(0) << "Printing OrderSet." << endl);
    10781092  for(int i=0;i<Order;i++) {
    10791093    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);
    10851099
    10861100
Note: See TracChangeset for help on using the changeset viewer.