# | Line 64 | Line 64 | |
---|---|---|
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" | |
# | Line 103 | Line 104 | namespace OpenMD { | |
104 | const int masterNode = 0; | |
105 | ||
106 | if (worldRank == masterNode) { | |
107 | < | MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode); |
107 | > | MPI_Bcast(&mdFileVersion, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
108 | > | // MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode); |
109 | #endif | |
110 | SimplePreprocessor preprocessor; | |
111 | < | preprocessor.preprocess(rawMetaDataStream, filename, startOfMetaDataBlock, ppStream); |
111 | > | preprocessor.preprocess(rawMetaDataStream, filename, |
112 | > | startOfMetaDataBlock, ppStream); |
113 | ||
114 | #ifdef IS_MPI | |
115 | < | //brocasting the stream size |
115 | > | //broadcasting the stream size |
116 | streamSize = ppStream.str().size() +1; | |
117 | < | MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode); |
118 | < | MPI::COMM_WORLD.Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), streamSize, MPI::CHAR, masterNode); |
117 | > | MPI_Bcast(&streamSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
118 | > | MPI_Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), |
119 | > | streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
120 | > | |
121 | > | // MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode); |
122 | > | // MPI::COMM_WORLD.Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), |
123 | > | // streamSize, MPI::CHAR, masterNode); |
124 | ||
125 | } else { | |
118 | – | MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode); |
126 | ||
127 | < | //get stream size |
128 | < | MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode); |
127 | > | MPI_Bcast(&mdFileVersion, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
128 | > | // MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode); |
129 | ||
130 | + | //get stream size |
131 | + | MPI_Bcast(&streamSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD); |
132 | + | // MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode); |
133 | char* buf = new char[streamSize]; | |
134 | assert(buf); | |
135 | ||
136 | //receive file content | |
137 | < | MPI::COMM_WORLD.Bcast(buf, streamSize, MPI::CHAR, masterNode); |
138 | < | |
137 | > | MPI_Bcast(buf, streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD); |
138 | > | // MPI::COMM_WORLD.Bcast(buf, streamSize, MPI::CHAR, masterNode); |
139 | > | |
140 | ppStream.str(buf); | |
141 | delete [] buf; | |
142 | } | |
# | Line 149 | Line 160 | namespace OpenMD { | |
160 | parser.initializeASTFactory(factory); | |
161 | parser.setASTFactory(&factory); | |
162 | parser.mdfile(); | |
152 | – | |
163 | // Create a tree parser that reads information into Globals | |
164 | MDTreeParser treeParser; | |
165 | treeParser.initializeASTFactory(factory); | |
# | Line 263 | Line 273 | namespace OpenMD { | |
273 | version.append("."); | |
274 | version.append(OPENMD_VERSION_MINOR); | |
275 | ||
276 | < | std::string svnrev; |
276 | > | std::string svnrev(g_REVISION, strnlen(g_REVISION, 20)); |
277 | //convert a macro from compiler to a string in c++ | |
278 | < | STR_DEFINE(svnrev, SVN_REV ); |
278 | > | // STR_DEFINE(svnrev, SVN_REV ); |
279 | version.append(" Revision: "); | |
280 | // If there's no SVN revision, just call this the RELEASE revision. | |
281 | if (!svnrev.empty()) { | |
# | Line 520 | Line 530 | namespace OpenMD { | |
530 | // error | |
531 | // condition: | |
532 | ||
533 | < | nProcessors = MPI::COMM_WORLD.Get_size(); |
533 | > | MPI_Comm_size( MPI_COMM_WORLD, &nProcessors); |
534 | > | //nProcessors = MPI::COMM_WORLD.Get_size(); |
535 | ||
536 | if (nProcessors > nGlobalMols) { | |
537 | sprintf(painCave.errMsg, | |
# | Line 639 | Line 650 | namespace OpenMD { | |
650 | delete myRandom; | |
651 | ||
652 | // Spray out this nonsense to all other processors: | |
653 | < | MPI::COMM_WORLD.Bcast(&molToProcMap[0], nGlobalMols, MPI::INT, 0); |
653 | > | MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD); |
654 | > | // MPI::COMM_WORLD.Bcast(&molToProcMap[0], nGlobalMols, MPI::INT, 0); |
655 | } else { | |
656 | ||
657 | // Listen to your marching orders from processor 0: | |
658 | < | MPI::COMM_WORLD.Bcast(&molToProcMap[0], nGlobalMols, MPI::INT, 0); |
658 | > | MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD); |
659 | > | // MPI::COMM_WORLD.Bcast(&molToProcMap[0], nGlobalMols, MPI::INT, 0); |
660 | ||
661 | } | |
662 | ||
# | Line 803 | Line 816 | namespace OpenMD { | |
816 | Molecule::AtomIterator ai; | |
817 | Molecule::RigidBodyIterator ri; | |
818 | Molecule::CutoffGroupIterator ci; | |
819 | + | Molecule::BondIterator boi; |
820 | + | Molecule::BendIterator bei; |
821 | + | Molecule::TorsionIterator ti; |
822 | + | Molecule::InversionIterator ii; |
823 | Molecule::IntegrableObjectIterator ioi; | |
824 | < | Molecule * mol; |
825 | < | Atom * atom; |
826 | < | RigidBody * rb; |
827 | < | CutoffGroup * cg; |
824 | > | Molecule* mol; |
825 | > | Atom* atom; |
826 | > | RigidBody* rb; |
827 | > | CutoffGroup* cg; |
828 | > | Bond* bond; |
829 | > | Bend* bend; |
830 | > | Torsion* torsion; |
831 | > | Inversion* inversion; |
832 | int beginAtomIndex; | |
833 | int beginRigidBodyIndex; | |
834 | int beginCutoffGroupIndex; | |
835 | + | int beginBondIndex; |
836 | + | int beginBendIndex; |
837 | + | int beginTorsionIndex; |
838 | + | int beginInversionIndex; |
839 | int nGlobalAtoms = info->getNGlobalAtoms(); | |
840 | int nGlobalRigidBodies = info->getNGlobalRigidBodies(); | |
841 | ||
842 | beginAtomIndex = 0; | |
843 | < | //rigidbody's index begins right after atom's |
843 | > | // The rigid body indices begin immediately after the atom indices: |
844 | beginRigidBodyIndex = info->getNGlobalAtoms(); | |
845 | beginCutoffGroupIndex = 0; | |
846 | < | |
846 | > | beginBondIndex = 0; |
847 | > | beginBendIndex = 0; |
848 | > | beginTorsionIndex = 0; |
849 | > | beginInversionIndex = 0; |
850 | > | |
851 | for(int i = 0; i < info->getNGlobalMolecules(); i++) { | |
852 | ||
853 | #ifdef IS_MPI | |
# | Line 827 | Line 856 | namespace OpenMD { | |
856 | // stuff to do if I own this molecule | |
857 | mol = info->getMoleculeByGlobalIndex(i); | |
858 | ||
859 | < | //local index(index in DataStorge) of atom is important |
860 | < | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
859 | > | // The local index(index in DataStorge) of the atom is important: |
860 | > | for(atom = mol->beginAtom(ai); atom != NULL; |
861 | > | atom = mol->nextAtom(ai)) { |
862 | atom->setGlobalIndex(beginAtomIndex++); | |
863 | } | |
864 | ||
# | Line 837 | Line 867 | namespace OpenMD { | |
867 | rb->setGlobalIndex(beginRigidBodyIndex++); | |
868 | } | |
869 | ||
870 | < | //local index of cutoff group is trivial, it only depends on |
871 | < | //the order of travesing |
870 | > | // The local index of other objects only depends on the order |
871 | > | // of traversal: |
872 | for(cg = mol->beginCutoffGroup(ci); cg != NULL; | |
873 | cg = mol->nextCutoffGroup(ci)) { | |
874 | cg->setGlobalIndex(beginCutoffGroupIndex++); | |
875 | } | |
876 | + | for(bond = mol->beginBond(boi); bond != NULL; |
877 | + | bond = mol->nextBond(boi)) { |
878 | + | bond->setGlobalIndex(beginBondIndex++); |
879 | + | } |
880 | + | for(bend = mol->beginBend(bei); bend != NULL; |
881 | + | bend = mol->nextBend(bei)) { |
882 | + | bend->setGlobalIndex(beginBendIndex++); |
883 | + | } |
884 | + | for(torsion = mol->beginTorsion(ti); torsion != NULL; |
885 | + | torsion = mol->nextTorsion(ti)) { |
886 | + | torsion->setGlobalIndex(beginTorsionIndex++); |
887 | + | } |
888 | + | for(inversion = mol->beginInversion(ii); inversion != NULL; |
889 | + | inversion = mol->nextInversion(ii)) { |
890 | + | inversion->setGlobalIndex(beginInversionIndex++); |
891 | + | } |
892 | ||
893 | #ifdef IS_MPI | |
894 | } else { | |
# | Line 855 | Line 901 | namespace OpenMD { | |
901 | beginAtomIndex += stamp->getNAtoms(); | |
902 | beginRigidBodyIndex += stamp->getNRigidBodies(); | |
903 | beginCutoffGroupIndex += stamp->getNCutoffGroups() + stamp->getNFreeAtoms(); | |
904 | + | beginBondIndex += stamp->getNBonds(); |
905 | + | beginBendIndex += stamp->getNBends(); |
906 | + | beginTorsionIndex += stamp->getNTorsions(); |
907 | + | beginInversionIndex += stamp->getNInversions(); |
908 | } | |
909 | #endif | |
910 | ||
# | Line 862 | Line 912 | namespace OpenMD { | |
912 | ||
913 | //fill globalGroupMembership | |
914 | std::vector<int> globalGroupMembership(info->getNGlobalAtoms(), 0); | |
915 | < | for(mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) { |
916 | < | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
917 | < | |
915 | > | for(mol = info->beginMolecule(mi); mol != NULL; |
916 | > | mol = info->nextMolecule(mi)) { |
917 | > | for (cg = mol->beginCutoffGroup(ci); cg != NULL; |
918 | > | cg = mol->nextCutoffGroup(ci)) { |
919 | for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { | |
920 | globalGroupMembership[atom->getGlobalIndex()] = cg->getGlobalIndex(); | |
921 | } | |
# | Line 879 | Line 930 | namespace OpenMD { | |
930 | // This would be prettier if we could use MPI_IN_PLACE like the MPI-2 | |
931 | // docs said we could. | |
932 | std::vector<int> tmpGroupMembership(info->getNGlobalAtoms(), 0); | |
933 | < | MPI::COMM_WORLD.Allreduce(&globalGroupMembership[0], |
934 | < | &tmpGroupMembership[0], nGlobalAtoms, |
935 | < | MPI::INT, MPI::SUM); |
933 | > | MPI_Allreduce(&globalGroupMembership[0], |
934 | > | &tmpGroupMembership[0], nGlobalAtoms, |
935 | > | MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
936 | > | // MPI::COMM_WORLD.Allreduce(&globalGroupMembership[0], |
937 | > | // &tmpGroupMembership[0], nGlobalAtoms, |
938 | > | // MPI::INT, MPI::SUM); |
939 | info->setGlobalGroupMembership(tmpGroupMembership); | |
940 | #else | |
941 | info->setGlobalGroupMembership(globalGroupMembership); | |
# | Line 905 | Line 959 | namespace OpenMD { | |
959 | #ifdef IS_MPI | |
960 | std::vector<int> tmpMolMembership(info->getNGlobalAtoms() + | |
961 | info->getNGlobalRigidBodies(), 0); | |
962 | < | MPI::COMM_WORLD.Allreduce(&globalMolMembership[0], &tmpMolMembership[0], |
963 | < | nGlobalAtoms + nGlobalRigidBodies, |
964 | < | MPI::INT, MPI::SUM); |
962 | > | MPI_Allreduce(&globalMolMembership[0], &tmpMolMembership[0], |
963 | > | nGlobalAtoms + nGlobalRigidBodies, |
964 | > | MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
965 | > | // MPI::COMM_WORLD.Allreduce(&globalMolMembership[0], &tmpMolMembership[0], |
966 | > | // nGlobalAtoms + nGlobalRigidBodies, |
967 | > | // MPI::INT, MPI::SUM); |
968 | ||
969 | info->setGlobalMolMembership(tmpMolMembership); | |
970 | #else | |
# | Line 925 | Line 982 | namespace OpenMD { | |
982 | ||
983 | #ifdef IS_MPI | |
984 | std::vector<int> numIntegrableObjectsPerMol(info->getNGlobalMolecules(), 0); | |
985 | < | MPI::COMM_WORLD.Allreduce(&nIOPerMol[0], &numIntegrableObjectsPerMol[0], |
986 | < | info->getNGlobalMolecules(), MPI::INT, MPI::SUM); |
985 | > | MPI_Allreduce(&nIOPerMol[0], &numIntegrableObjectsPerMol[0], |
986 | > | info->getNGlobalMolecules(), MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
987 | > | // MPI::COMM_WORLD.Allreduce(&nIOPerMol[0], &numIntegrableObjectsPerMol[0], |
988 | > | // info->getNGlobalMolecules(), MPI::INT, MPI::SUM); |
989 | #else | |
990 | std::vector<int> numIntegrableObjectsPerMol = nIOPerMol; | |
991 | #endif |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |