Commit 35522baa authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

latest changes in Coupling*-files

parent 249f590b
...@@ -50,14 +50,14 @@ namespace AMDiS { ...@@ -50,14 +50,14 @@ namespace AMDiS {
/// Fill an initfile from a file with filename fn /// Fill an initfile from a file with filename fn
void Initfile::read(std::string fn) void Initfile::read(std::string fn, bool force)
{ {
// read file if its not parsed already // read file if its not parsed already
if (fn_include_list.find(fn) == fn_include_list.end()) { if (fn_include_list.find(fn) == fn_include_list.end() || force) {
std::ifstream inputFile; std::ifstream inputFile;
inputFile.open(fn.c_str(), std::ios::in); inputFile.open(fn.c_str(), std::ios::in);
if (!inputFile.is_open()) if (!inputFile.is_open())
throw runtime_error("init-file '" + fn + "' cannot be opened for reading"); throw runtime_error("init-file '" + fn + "' cannot be opened for reading");
fn_include_list.insert(fn); fn_include_list.insert(fn);
read(inputFile); read(inputFile);
...@@ -84,12 +84,26 @@ namespace AMDiS { ...@@ -84,12 +84,26 @@ namespace AMDiS {
Parser parser(sw); Parser parser(sw);
// add parameter to map after variable replacement // add parameter to map after variable replacement
operator[](variableReplacement(InitfileInternal::trim(parser.name))) = variableReplacement(InitfileInternal::trim(parser.value)); std::string paramName = variableReplacement(InitfileInternal::trim(parser.name));
std::string paramValue = variableReplacement(InitfileInternal::trim(parser.value));
operator[](paramName) = paramValue;
#ifndef DEBUG
int info = 0;
get("parameter information", info, 0);
if (info >= 2)
#endif
std::cout << "read [" << paramName << " => " << paramValue << "]" << std::endl;
} else if (sw[pos0] == '#' } else if (sw[pos0] == '#'
&& static_cast<size_t>(sw.find("#include")) == pos0) { && static_cast<size_t>(sw.find("#include")) == pos0) {
// include file by '#include "filename"' or '#include <filename>' // include file by '#include "filename"' or '#include <filename>'
bool forceRead = false;
int posAdd = 1;
if (sw[pos0 + std::string("#include").size()] == '!') {
forceRead = true;
posAdd++;
}
size_t pos = sw.find_first_not_of(whitespaces, size_t pos = sw.find_first_not_of(whitespaces,
std::string("#include").size() + 1); pos0 + std::string("#include").size() + posAdd);
size_t epos = 0; size_t epos = 0;
std::string fn = ""; std::string fn = "";
std::stringstream errorMsg; std::stringstream errorMsg;
...@@ -109,7 +123,7 @@ namespace AMDiS { ...@@ -109,7 +123,7 @@ namespace AMDiS {
default: default:
throw std::runtime_error("no filename given for #include"); throw std::runtime_error("no filename given for #include");
} }
read(fn); read(fn, forceRead);
} }
in.getline(swap, line_length); in.getline(swap, line_length);
} }
......
...@@ -596,7 +596,7 @@ protected: ...@@ -596,7 +596,7 @@ protected:
void read(std::istream& in); void read(std::istream& in);
/// Fill the initfile from a file with filename fn /// Fill the initfile from a file with filename fn
void read(std::string fn); void read(std::string fn, bool force = false);
/** Write data-map to initfile /** Write data-map to initfile
* @param out: the stream to fill the data in. * @param out: the stream to fill the data in.
......
...@@ -92,27 +92,27 @@ namespace AMDiS { ...@@ -92,27 +92,27 @@ namespace AMDiS {
/// Clear recovery structure /// Clear recovery structure
inline void clear() inline void clear()
{ {
if (coords) { if (coords != NULL) {
delete coords; delete coords;
coords = NULL; coords = NULL;
} }
if (A) { if (A != NULL) {
delete A; delete A;
A = NULL; A = NULL;
} }
if (rec_uh) { if (rec_uh != NULL) {
delete rec_uh; delete rec_uh;
rec_uh = NULL; rec_uh = NULL;
} }
if (rec_grdUh) { if (rec_grdUh != NULL) {
delete rec_grdUh; delete rec_grdUh;
rec_grdUh = NULL; rec_grdUh = NULL;
} }
if (neighbors) { if (neighbors != NULL) {
delete neighbors; delete neighbors;
neighbors = NULL; neighbors = NULL;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment