--- trunk/src/brains/SimCreator.cpp 2012/11/05 19:41:28 1809 +++ trunk/src/brains/SimCreator.cpp 2012/11/08 14:23:43 1810 @@ -255,11 +255,28 @@ namespace OpenMD { std::string mdRawData; int metaDataBlockStart = -1; int metaDataBlockEnd = -1; - int i; + int i, j; streamoff mdOffset(0); int mdFileVersion; + // Create a string for embedding the version information in the MetaData + std::string version; + version.assign("## Last run using OpenMD Version: "); + version.append(OPENMD_VERSION_MAJOR); + version.append("."); + version.append(OPENMD_VERSION_MINOR); + std::string svnrev; + //convert a macro from compiler to a string in c++ + STR_DEFINE(svnrev, SVN_REV ); + version.append(" Revision: "); + // If there's no SVN revision, just call this the RELEASE revision. + if (!svnrev.empty()) { + version.append(svnrev); + } else { + version.append("RELEASE"); + } + #ifdef IS_MPI const int masterNode = 0; if (worldRank == masterNode) { @@ -354,12 +371,23 @@ namespace OpenMD { mdRawData.clear(); + bool foundVersion = false; + for (int i = 0; i < metaDataBlockEnd - metaDataBlockStart - 1; ++i) { mdFile_.getline(buffer, bufferSize); - mdRawData += buffer; + std::string line = trimLeftCopy(buffer); + j = CaseInsensitiveFind(line, "## Last run using OpenMD Version"); + if (static_cast(j) != string::npos) { + foundVersion = true; + mdRawData += version; + } else { + mdRawData += buffer; + } mdRawData += "\n"; } - + + if (!foundVersion) mdRawData += version + "\n"; + mdFile_.close(); #ifdef IS_MPI