| 64 |
|
#include "brains/ForceField.hpp" |
| 65 |
|
#include "utils/simError.h" |
| 66 |
|
#include "utils/StringUtils.hpp" |
| 67 |
+ |
#include "utils/Revision.hpp" |
| 68 |
|
#include "math/SeqRandNumGen.hpp" |
| 69 |
|
#include "mdParser/MDLexer.hpp" |
| 70 |
|
#include "mdParser/MDParser.hpp" |
| 105 |
|
|
| 106 |
|
if (worldRank == masterNode) { |
| 107 |
|
MPI_Bcast(&mdFileVersion, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
| 107 |
– |
// MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode); |
| 108 |
|
#endif |
| 109 |
|
SimplePreprocessor preprocessor; |
| 110 |
|
preprocessor.preprocess(rawMetaDataStream, filename, |
| 113 |
|
#ifdef IS_MPI |
| 114 |
|
//broadcasting the stream size |
| 115 |
|
streamSize = ppStream.str().size() +1; |
| 116 |
< |
MPI_Bcast(&streamSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD); |
| 117 |
< |
MPI_Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), |
| 116 |
> |
MPI_Bcast(&streamSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
| 117 |
> |
MPI_Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), |
| 118 |
|
streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
| 119 |
– |
|
| 120 |
– |
// MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode); |
| 121 |
– |
// MPI::COMM_WORLD.Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), |
| 122 |
– |
// streamSize, MPI::CHAR, masterNode); |
| 123 |
– |
|
| 119 |
|
} else { |
| 120 |
|
|
| 121 |
|
MPI_Bcast(&mdFileVersion, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
| 127 |
– |
// MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode); |
| 122 |
|
|
| 123 |
|
//get stream size |
| 124 |
< |
MPI_Bcast(&streamSize, 1, MPI_LONG, masterNode, MPI_COMM_WORLD); |
| 131 |
< |
// MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode); |
| 124 |
> |
MPI_Bcast(&streamSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
| 125 |
|
char* buf = new char[streamSize]; |
| 126 |
|
assert(buf); |
| 127 |
|
|
| 128 |
|
//receive file content |
| 129 |
|
MPI_Bcast(buf, streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
| 137 |
– |
// MPI::COMM_WORLD.Bcast(buf, streamSize, MPI::CHAR, masterNode); |
| 130 |
|
|
| 131 |
|
ppStream.str(buf); |
| 132 |
|
delete [] buf; |
| 228 |
|
catch (OpenMDException& e) { |
| 229 |
|
sprintf(painCave.errMsg, |
| 230 |
|
"%s\n", |
| 231 |
< |
e.getMessage().c_str()); |
| 231 |
> |
e.what()); |
| 232 |
|
painCave.isFatal = 1; |
| 233 |
|
simError(); |
| 234 |
|
} |
| 253 |
|
std::string mdRawData; |
| 254 |
|
int metaDataBlockStart = -1; |
| 255 |
|
int metaDataBlockEnd = -1; |
| 264 |
– |
int i, j; |
| 256 |
|
streamoff mdOffset; |
| 257 |
|
int mdFileVersion; |
| 258 |
|
|
| 263 |
|
version.append("."); |
| 264 |
|
version.append(OPENMD_VERSION_MINOR); |
| 265 |
|
|
| 266 |
< |
std::string svnrev; |
| 266 |
> |
std::string svnrev(g_REVISION, strnlen(g_REVISION, 20)); |
| 267 |
|
//convert a macro from compiler to a string in c++ |
| 268 |
< |
STR_DEFINE(svnrev, SVN_REV ); |
| 268 |
> |
// STR_DEFINE(svnrev, SVN_REV ); |
| 269 |
|
version.append(" Revision: "); |
| 270 |
|
// If there's no SVN revision, just call this the RELEASE revision. |
| 271 |
|
if (!svnrev.empty()) { |
| 293 |
|
mdFile_.getline(buffer, bufferSize); |
| 294 |
|
++lineNo; |
| 295 |
|
std::string line = trimLeftCopy(buffer); |
| 296 |
< |
i = CaseInsensitiveFind(line, "<OpenMD"); |
| 297 |
< |
if (static_cast<size_t>(i) == string::npos) { |
| 296 |
> |
std::size_t i = CaseInsensitiveFind(line, "<OpenMD"); |
| 297 |
> |
if (i == string::npos) { |
| 298 |
|
// try the older file strings to see if that works: |
| 299 |
|
i = CaseInsensitiveFind(line, "<OOPSE"); |
| 300 |
|
} |
| 301 |
|
|
| 302 |
< |
if (static_cast<size_t>(i) == string::npos) { |
| 302 |
> |
if (i == string::npos) { |
| 303 |
|
// still no luck! |
| 304 |
|
sprintf(painCave.errMsg, |
| 305 |
|
"SimCreator: File: %s is not a valid OpenMD file!\n", |
| 334 |
|
|
| 335 |
|
std::string line = trimLeftCopy(buffer); |
| 336 |
|
if (metaDataBlockStart == -1) { |
| 337 |
< |
i = CaseInsensitiveFind(line, "<MetaData>"); |
| 337 |
> |
std::size_t i = CaseInsensitiveFind(line, "<MetaData>"); |
| 338 |
|
if (i != string::npos) { |
| 339 |
|
metaDataBlockStart = lineNo; |
| 340 |
|
mdOffset = mdFile_.tellg(); |
| 341 |
|
} |
| 342 |
|
} else { |
| 343 |
< |
i = CaseInsensitiveFind(line, "</MetaData>"); |
| 343 |
> |
std::size_t i = CaseInsensitiveFind(line, "</MetaData>"); |
| 344 |
|
if (i != string::npos) { |
| 345 |
|
metaDataBlockEnd = lineNo; |
| 346 |
|
} |
| 373 |
|
for (int i = 0; i < metaDataBlockEnd - metaDataBlockStart - 1; ++i) { |
| 374 |
|
mdFile_.getline(buffer, bufferSize); |
| 375 |
|
std::string line = trimLeftCopy(buffer); |
| 376 |
< |
j = CaseInsensitiveFind(line, "## Last run using OpenMD Version"); |
| 377 |
< |
if (static_cast<size_t>(j) != string::npos) { |
| 376 |
> |
std::size_t j = CaseInsensitiveFind(line, |
| 377 |
> |
"## Last run using OpenMD Version"); |
| 378 |
> |
if (j != string::npos) { |
| 379 |
|
foundVersion = true; |
| 380 |
|
mdRawData += version; |
| 381 |
|
} else { |
| 522 |
|
// condition: |
| 523 |
|
|
| 524 |
|
MPI_Comm_size( MPI_COMM_WORLD, &nProcessors); |
| 533 |
– |
//nProcessors = MPI::COMM_WORLD.Get_size(); |
| 525 |
|
|
| 526 |
|
if (nProcessors > nGlobalMols) { |
| 527 |
|
sprintf(painCave.errMsg, |
| 641 |
|
|
| 642 |
|
// Spray out this nonsense to all other processors: |
| 643 |
|
MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD); |
| 644 |
< |
// MPI::COMM_WORLD.Bcast(&molToProcMap[0], nGlobalMols, MPI::INT, 0); |
| 644 |
> |
|
| 645 |
|
} else { |
| 646 |
|
|
| 647 |
|
// Listen to your marching orders from processor 0: |
| 648 |
|
MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD); |
| 658 |
– |
// MPI::COMM_WORLD.Bcast(&molToProcMap[0], nGlobalMols, MPI::INT, 0); |
| 649 |
|
|
| 650 |
|
} |
| 651 |
|
|
| 785 |
|
} |
| 786 |
|
} |
| 787 |
|
|
| 788 |
< |
if (simParams->getOutputElectricField() | simParams->haveElectricField()) { |
| 788 |
> |
if (simParams->getOutputElectricField() | |
| 789 |
> |
simParams->haveElectricField() | simParams->haveUniformField() | |
| 790 |
> |
simParams->haveUniformGradientStrength() | |
| 791 |
> |
simParams->haveUniformGradientDirection1() | |
| 792 |
> |
simParams->haveUniformGradientDirection2() ) { |
| 793 |
|
storageLayout |= DataStorage::dslElectricField; |
| 794 |
|
} |
| 795 |
|
|
| 796 |
+ |
if (simParams->getOutputSitePotential() ) { |
| 797 |
+ |
storageLayout |= DataStorage::dslSitePotential; |
| 798 |
+ |
} |
| 799 |
+ |
|
| 800 |
|
if (simParams->getOutputFluctuatingCharges()) { |
| 801 |
|
storageLayout |= DataStorage::dslFlucQPosition; |
| 802 |
|
storageLayout |= DataStorage::dslFlucQVelocity; |
| 833 |
|
int beginBendIndex; |
| 834 |
|
int beginTorsionIndex; |
| 835 |
|
int beginInversionIndex; |
| 836 |
+ |
#ifdef IS_MPI |
| 837 |
|
int nGlobalAtoms = info->getNGlobalAtoms(); |
| 838 |
|
int nGlobalRigidBodies = info->getNGlobalRigidBodies(); |
| 839 |
+ |
#endif |
| 840 |
|
|
| 841 |
|
beginAtomIndex = 0; |
| 842 |
|
// The rigid body indices begin immediately after the atom indices: |
| 932 |
|
MPI_Allreduce(&globalGroupMembership[0], |
| 933 |
|
&tmpGroupMembership[0], nGlobalAtoms, |
| 934 |
|
MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
| 935 |
< |
// MPI::COMM_WORLD.Allreduce(&globalGroupMembership[0], |
| 936 |
< |
// &tmpGroupMembership[0], nGlobalAtoms, |
| 937 |
< |
// MPI::INT, MPI::SUM); |
| 935 |
> |
|
| 936 |
|
info->setGlobalGroupMembership(tmpGroupMembership); |
| 937 |
|
#else |
| 938 |
|
info->setGlobalGroupMembership(globalGroupMembership); |
| 959 |
|
MPI_Allreduce(&globalMolMembership[0], &tmpMolMembership[0], |
| 960 |
|
nGlobalAtoms + nGlobalRigidBodies, |
| 961 |
|
MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
| 964 |
– |
// MPI::COMM_WORLD.Allreduce(&globalMolMembership[0], &tmpMolMembership[0], |
| 965 |
– |
// nGlobalAtoms + nGlobalRigidBodies, |
| 966 |
– |
// MPI::INT, MPI::SUM); |
| 962 |
|
|
| 963 |
|
info->setGlobalMolMembership(tmpMolMembership); |
| 964 |
|
#else |
| 978 |
|
std::vector<int> numIntegrableObjectsPerMol(info->getNGlobalMolecules(), 0); |
| 979 |
|
MPI_Allreduce(&nIOPerMol[0], &numIntegrableObjectsPerMol[0], |
| 980 |
|
info->getNGlobalMolecules(), MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
| 986 |
– |
// MPI::COMM_WORLD.Allreduce(&nIOPerMol[0], &numIntegrableObjectsPerMol[0], |
| 987 |
– |
// info->getNGlobalMolecules(), MPI::INT, MPI::SUM); |
| 981 |
|
#else |
| 982 |
|
std::vector<int> numIntegrableObjectsPerMol = nIOPerMol; |
| 983 |
|
#endif |