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

latest changes in Coupling*-files

parent 249f590b
......@@ -50,14 +50,14 @@ namespace AMDiS {
/// 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
if (fn_include_list.find(fn) == fn_include_list.end()) {
if (fn_include_list.find(fn) == fn_include_list.end() || force) {
std::ifstream inputFile;
inputFile.open(fn.c_str(), std::ios::in);
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);
read(inputFile);
......@@ -84,12 +84,26 @@ namespace AMDiS {
Parser parser(sw);
// 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] == '#'
&& static_cast<size_t>(sw.find("#include")) == pos0) {
// 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,
std::string("#include").size() + 1);
pos0 + std::string("#include").size() + posAdd);
size_t epos = 0;
std::string fn = "";
std::stringstream errorMsg;
......@@ -109,7 +123,7 @@ namespace AMDiS {
default:
throw std::runtime_error("no filename given for #include");
}
read(fn);
read(fn, forceRead);
}
in.getline(swap, line_length);
}
......
......@@ -596,7 +596,7 @@ protected:
void read(std::istream& in);
/// 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
* @param out: the stream to fill the data in.
......
......@@ -92,27 +92,27 @@ namespace AMDiS {
/// Clear recovery structure
inline void clear()
{
if (coords) {
if (coords != NULL) {
delete coords;
coords = NULL;
}
if (A) {
if (A != NULL) {
delete A;
A = NULL;
}
if (rec_uh) {
if (rec_uh != NULL) {
delete rec_uh;
rec_uh = NULL;
}
if (rec_grdUh) {
if (rec_grdUh != NULL) {
delete rec_grdUh;
rec_grdUh = NULL;
}
if (neighbors) {
if (neighbors != NULL) {
delete neighbors;
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