From 90f28a2737c4f26f7a778e75ea86d97fff3a9128 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Tue, 8 Nov 2011 09:47:17 +0000 Subject: [PATCH] Fixed serious bug on serialization/deserialization. --- AMDiS/src/AMDiS.h | 1 + AMDiS/src/AdaptInstationary.cc | 19 ++++++++++++++++--- AMDiS/src/DOFVector.hh | 4 ++-- AMDiS/src/Initfile.cc | 8 ++++---- AMDiS/src/ProblemStat.cc | 11 ++++++++--- AMDiS/src/parallel/MeshDistributor.cc | 15 +++++++++++++++ 6 files changed, 46 insertions(+), 12 deletions(-) diff --git a/AMDiS/src/AMDiS.h b/AMDiS/src/AMDiS.h index 82b62be9..1a873c9a 100644 --- a/AMDiS/src/AMDiS.h +++ b/AMDiS/src/AMDiS.h @@ -134,6 +134,7 @@ #if HAVE_PARALLEL_DOMAIN_AMDIS #include "parallel/InteriorBoundary.h" #include "parallel/MpiHelper.h" +#include "parallel/StdMpi.h" #if HAVE_PARALLEL_MTL4 #include "parallel/Mtl4Solver.h" diff --git a/AMDiS/src/AdaptInstationary.cc b/AMDiS/src/AdaptInstationary.cc index 2cef8377..c402888a 100644 --- a/AMDiS/src/AdaptInstationary.cc +++ b/AMDiS/src/AdaptInstationary.cc @@ -85,6 +85,12 @@ namespace AMDiS { MSG("Deserialization from file: %s\n", queueSerializationFilename.c_str()); std::ifstream in(queueSerializationFilename.c_str() , ios::in); + + // Read the revision number of the AMDiS version which was used to create + // the serialization file. + int revNumber = -1; + SerUtil::deserialize(in, revNumber); + deserialize(in); in.close(); @@ -108,6 +114,12 @@ namespace AMDiS { MSG("Deserialization with AdaptInfo from file: %s\n", serializationFilename.c_str()); std::ifstream in(serializationFilename.c_str()); + + // Read the revision number of the AMDiS version which was used to create + // the serialization file. + int revNumber = -1; + SerUtil::deserialize(in, revNumber); + deserialize(in); in.close(); } @@ -372,7 +384,6 @@ namespace AMDiS { { FUNCNAME("AdaptInstationary::serialize()"); - SerUtil::serialize(out, amdisRevisionNumber); problemIteration->serialize(out); adaptInfo->serialize(out); if (problemTime) @@ -383,8 +394,10 @@ namespace AMDiS { void AdaptInstationary::deserialize(std::istream &in) { FUNCNAME("AdaptInstationary::deserialize()"); - if(in.fail()) - ERROR_EXIT("File not found for deserialization \n"); + + if (in.fail()) + ERROR_EXIT("File not found for deserialization!\n"); + problemIteration->deserialize(in); adaptInfo->deserialize(in); if (problemTime) diff --git a/AMDiS/src/DOFVector.hh b/AMDiS/src/DOFVector.hh index 94cf9fa6..7ca24888 100644 --- a/AMDiS/src/DOFVector.hh +++ b/AMDiS/src/DOFVector.hh @@ -120,10 +120,10 @@ namespace AMDiS { { if (this->feSpace && this->feSpace->getAdmin()) (this->feSpace->getAdmin())->removeDOFIndexed(this); - + if (this->boundaryManager) delete this->boundaryManager; - + vec.clear(); } diff --git a/AMDiS/src/Initfile.cc b/AMDiS/src/Initfile.cc index 72899ec6..c5a06345 100644 --- a/AMDiS/src/Initfile.cc +++ b/AMDiS/src/Initfile.cc @@ -15,8 +15,8 @@ namespace AMDiS { { size_t pos = line.find(':'); if (pos == string::npos) { - throw runtime_error("cannot find the delimiter ':' in line " - "'" + line + "'"); + throw runtime_error("cannot find the delimiter ':' in line " + "'" + line + "'"); } name = line.substr(0, pos); value = line.substr(pos + 1, line.length() - (pos + 1)); @@ -24,7 +24,7 @@ namespace AMDiS { // remove everything after the % pos = value.find('%'); if (pos != string::npos) - value = value.substr(0, pos); + value = value.substr(0, pos); } string name; string value; @@ -72,7 +72,7 @@ namespace AMDiS { char swap[line_length]; in.getline(swap, line_length); while (in.good() || in.gcount()>0) { - std::string whitespaces = " \t\r\f"; + std::string whitespaces = " \t\r\f\n"; std::string sw(swap); size_t pos0 = sw.find_first_not_of(whitespaces); diff --git a/AMDiS/src/ProblemStat.cc b/AMDiS/src/ProblemStat.cc index 348423d9..79bc39b8 100644 --- a/AMDiS/src/ProblemStat.cc +++ b/AMDiS/src/ProblemStat.cc @@ -217,9 +217,14 @@ namespace AMDiS { #ifndef HAVE_PARALLEL_DOMAIN_AMDIS MSG("Deserialization from file: %s\n", serializationFilename.c_str()); ifstream in(serializationFilename.c_str()); + + // Read the revision number of the AMDiS version which was used to create + // the serialization file. + int revNumber = -1; + SerUtil::deserialize(in, revNumber); + deserialize(in); in.close(); - #endif deserialized = true; @@ -1697,8 +1702,8 @@ namespace AMDiS { void ProblemStatSeq::deserialize(istream &in) { FUNCNAME("ProblemStat::deserialize()"); - if(in.fail()) - ERROR_EXIT("File not found for deserialization \n"); + if (in.fail()) + ERROR_EXIT("File not found for deserialization!\n"); for (unsigned int i = 0; i < meshes.size(); i++) meshes[i]->deserialize(in); diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc index b55ad5bf..937ea8b3 100644 --- a/AMDiS/src/parallel/MeshDistributor.cc +++ b/AMDiS/src/parallel/MeshDistributor.cc @@ -349,6 +349,11 @@ namespace AMDiS { if (feSpace != NULL) { vector<FiniteElemSpace*> feSpaces = probStat->getFeSpaces(); for (unsigned int i = 0; i < feSpaces.size(); i++) { + MSG("MESH %p <-> %p BF %p <-> %p\n", + feSpace->getMesh(), + feSpaces[i]->getMesh(), + feSpace->getBasisFcts(), + feSpaces[i]->getBasisFcts()); TEST_EXIT(feSpace == feSpaces[i]) ("Parallelizaton is not supported for multiple FE spaces!\n"); } @@ -409,6 +414,11 @@ namespace AMDiS { TEST_EXIT(!in.fail())("Could not open deserialization file: %s\n", filename.c_str()); + // Read the revision number of the AMDiS version which was used to create + // the serialization file. + int revNumber = -1; + SerUtil::deserialize(in, revNumber); + probStat->deserialize(in); in.close(); MSG("Deserialization from file: %s\n", filename.c_str()); @@ -424,6 +434,11 @@ namespace AMDiS { TEST_EXIT(!in.fail())("Could not open parallel deserialization file: %s\n", filename.c_str()); + + // Read the revision number of the AMDiS version which was used to create + // the serialization file. + revNumber = -1; + SerUtil::deserialize(in, revNumber); deserialize(in); in.close(); -- GitLab