Révision | 95da8903d2aa702d9d6f2034a873b462b5eb33c3 (tree) |
---|---|
l'heure | 2013-07-12 20:23:58 |
Auteur | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Merge mpi-cis into trunk. #31588
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1394 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -23,6 +23,8 @@ | ||
23 | 23 | #include<stdexcept> |
24 | 24 | #include<boost/shared_ptr.hpp> |
25 | 25 | #include<boost/format.hpp> |
26 | +#include"base/Uncopyable.h" | |
27 | +#include"mpi/MpiProcess.h" | |
26 | 28 | #include"base/PrintController.h" |
27 | 29 | #include"base/MolDSException.h" |
28 | 30 | #include"base/Enums.h" |
@@ -31,10 +33,13 @@ | ||
31 | 33 | #include"base/Molecule.h" |
32 | 34 | #include"base/MolDS.h" |
33 | 35 | using namespace std; |
36 | +using namespace MolDS_base; | |
34 | 37 | int main(int argc, char *argv[]){ |
35 | 38 | try{ |
39 | + MolDS_mpi::MpiProcess::CreateInstance(argc, argv); | |
36 | 40 | boost::shared_ptr<MolDS_base::MolDS> molds(new MolDS_base::MolDS()); |
37 | 41 | molds->Run(argc, argv); |
42 | + MolDS_mpi::MpiProcess::DeleteInstance(); | |
38 | 43 | } |
39 | 44 | catch(exception ex){ |
40 | 45 | cout << ex.what(); |
@@ -17,10 +17,7 @@ | ||
17 | 17 | #// You should have received a copy of the GNU General Public License // |
18 | 18 | #// along with MolDS. If not, see <http://www.gnu.org/licenses/>. // |
19 | 19 | #//************************************************************************// |
20 | -CC = icpc | |
21 | -LIBSBASE = -lmkl_intel_thread -lmkl_core -liomp5 -lpthread | |
22 | -LIBS32 = -lmkl_intel $(LIBSBASE) | |
23 | -LIBS64 = -lmkl_intel_ilp64 $(LIBSBASE) | |
20 | +CC = mpiicpc | |
24 | 21 | CFLAGS = -O0 |
25 | 22 | override CFLAGS += -openmp -openmp-report2 -DMKL_INT=intptr_t |
26 | 23 | ifeq ($(INTEL), 64) |
@@ -28,20 +25,24 @@ override CFLAGS += -DMKL_ILP64 | ||
28 | 25 | endif |
29 | 26 | BOOST_TOP_DIR = /usr/local/boost/ |
30 | 27 | BOOST_INC_DIR = $(BOOST_TOP_DIR)include/ |
28 | +BOOST_LIB_DIR = $(BOOST_TOP_DIR)lib/ | |
29 | +BOOST_LIBS = -lboost_mpi | |
30 | +LIBSBASE = -lmkl_intel_thread -lmkl_core -liomp5 -lpthread | |
31 | +ifeq ($(INTEL), 64) | |
32 | +LIBS = -lmkl_intel_ilp64 $(LIBSBASE) $(BOOST_LIBS) | |
33 | +else | |
34 | +LIBS = -lmkl_intel $(LIBSBASE) $(BOOST_LIBS) | |
35 | +endif | |
31 | 36 | EXENAME = MolDS.out |
32 | 37 | DEPFILE = obj/objfile.dep |
33 | 38 | LDFLAGS = |
34 | 39 | |
35 | -ALL_CPP_FILES = Main.cpp base/MolDSException.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/MallocerFreer.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp | |
36 | -ALL_HEAD_FILES = base/PrintController.h base/MolDSException.h base/Uncopyable.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/MallocerFreer.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h | |
37 | -ALL_OBJ_FILES = obj/Main.o obj/MolDSException.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/MallocerFreer.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o | |
40 | +ALL_CPP_FILES = Main.cpp mpi/MpiProcess.cpp base/MolDSException.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/MallocerFreer.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp | |
41 | +ALL_HEAD_FILES = base/Uncopyable.h mpi/MpiProcess.h base/PrintController.h base/MolDSException.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/MallocerFreer.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h | |
42 | +ALL_OBJ_FILES = obj/MpiProcess.o obj/Main.o obj/MolDSException.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/MallocerFreer.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o | |
38 | 43 | |
39 | 44 | $(EXENAME): $(ALL_OBJ_FILES) |
40 | -ifeq ($(INTEL), 64) | |
41 | - $(CC) -o $@ $(LDFLAGS) $(ALL_OBJ_FILES) $(LIBS64) | |
42 | -else | |
43 | - $(CC) -o $@ $(LDFLAGS) $(ALL_OBJ_FILES) $(LIBS32) | |
44 | -endif | |
45 | + $(CC) -o $@ -Wl,-rpath=$(BOOST_LIB_DIR) -L$(BOOST_LIB_DIR) $(LDFLAGS) $(ALL_OBJ_FILES) $(LIBS) | |
45 | 46 | |
46 | 47 | -include $(DEPFILE) |
47 | 48 |
@@ -17,26 +17,29 @@ | ||
17 | 17 | #// You should have received a copy of the GNU General Public License // |
18 | 18 | #// along with MolDS. If not, see <http://www.gnu.org/licenses/>. // |
19 | 19 | #//************************************************************************// |
20 | -CC = g++ | |
21 | -LIBS = -lpthread | |
20 | +CC = mpicxx | |
22 | 21 | CFLAGS = -O0 |
23 | 22 | override CFLAGS += -fopenmp |
24 | 23 | BOOST_TOP_DIR = /usr/local/boost/ |
25 | 24 | BOOST_INC_DIR = $(BOOST_TOP_DIR)include/ |
25 | +BOOST_LIB_DIR = $(BOOST_TOP_DIR)lib/ | |
26 | +BOOST_LIBS = -lboost_mpi | |
26 | 27 | OPENBLAS_TOP_DIR = /usr/local/openblas/ |
27 | 28 | OPENBLAS_INC_DIR = $(OPENBLAS_TOP_DIR)include/ |
28 | 29 | OPENBLAS_LIB_DIR = $(OPENBLAS_TOP_DIR)lib/ |
29 | -OPENBLAS_LIBS = -lopenblas | |
30 | +OPENBLAS_LIBS = -lopenblas | |
31 | +LIBSBASE = -lpthread | |
32 | +LIBS = $(LIBSBASE) $(BOOST_LIBS) $(OPENBLAS_LIBS) | |
30 | 33 | EXENAME = MolDS.out |
31 | 34 | DEPFILE = obj/objfile.dep |
32 | 35 | LDFLAGS = |
33 | 36 | |
34 | -ALL_CPP_FILES = Main.cpp base/MolDSException.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/MallocerFreer.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp | |
35 | -ALL_HEAD_FILES = base/PrintController.h base/MolDSException.h base/Uncopyable.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/MallocerFreer.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h | |
36 | -ALL_OBJ_FILES = obj/Main.o obj/MolDSException.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/MallocerFreer.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o | |
37 | +ALL_CPP_FILES = Main.cpp mpi/MpiProcess.cpp base/MolDSException.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/MallocerFreer.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp | |
38 | +ALL_HEAD_FILES = base/Uncopyable.h mpi/MpiProcess.h base/PrintController.h base/MolDSException.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/MallocerFreer.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h | |
39 | +ALL_OBJ_FILES = obj/MpiProcess.o obj/Main.o obj/MolDSException.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/MallocerFreer.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o | |
37 | 40 | |
38 | 41 | $(EXENAME): $(ALL_OBJ_FILES) |
39 | - $(CC) -o $@ $(LDFLAGS) -Wl,-rpath=$(OPENBLAS_LIB_DIR) $(ALL_OBJ_FILES) -L$(OPENBLAS_LIB_DIR) $(LIBS) $(OPENBLAS_LIBS) | |
42 | + $(CC) -o $@ $(LDFLAGS) -Wl,-rpath=$(BOOST_LIB_DIR) -Wl,-rpath=$(OPENBLAS_LIB_DIR) $(LDFLAGS) $(ALL_OBJ_FILES) -L$(BOOST_LIB_DIR) -L$(OPENBLAS_LIB_DIR) $(LIBS) | |
40 | 43 | |
41 | 44 | -include $(DEPFILE) |
42 | 45 |
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<string> |
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | +#include"../base/Uncopyable.h" | |
28 | +#include"../mpi/MpiProcess.h" | |
27 | 29 | #include"../base/PrintController.h" |
28 | 30 | #include"../base/MolDSException.h" |
29 | -#include"../base/Uncopyable.h" | |
30 | 31 | #include"../base/Enums.h" |
31 | 32 | #include"../base/EularAngle.h" |
32 | 33 | #include"../base/Parameters.h" |
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<string> |
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | +#include"../base/Uncopyable.h" | |
28 | +#include"../mpi/MpiProcess.h" | |
27 | 29 | #include"../base/PrintController.h" |
28 | 30 | #include"../base/MolDSException.h" |
29 | -#include"../base/Uncopyable.h" | |
30 | 31 | #include"../base/Enums.h" |
31 | 32 | #include"../base/EularAngle.h" |
32 | 33 | #include"../base/Parameters.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<vector> |
29 | 29 | #include<stdexcept> |
30 | 30 | #include<boost/format.hpp> |
31 | +#include"Uncopyable.h" | |
32 | +#include"../mpi/MpiProcess.h" | |
31 | 33 | #include"PrintController.h" |
32 | 34 | #include"MolDSException.h" |
33 | -#include"Uncopyable.h" | |
34 | 35 | #include"Utilities.h" |
35 | 36 | #include"Enums.h" |
36 | 37 | #include"EularAngle.h" |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<vector> |
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/format.hpp> |
28 | +#include"Uncopyable.h" | |
29 | +#include"../mpi/MpiProcess.h" | |
28 | 30 | #include"PrintController.h" |
29 | 31 | #include"MolDSException.h" |
30 | -#include"Uncopyable.h" | |
31 | 32 | #include"Enums.h" |
32 | 33 | #include"MallocerFreer.h" |
33 | 34 | #include"EularAngle.h" |
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<stdexcept> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include<boost/math/special_functions/factorials.hpp> |
27 | +#include"Uncopyable.h" | |
28 | +#include"../mpi/MpiProcess.h" | |
27 | 29 | #include"PrintController.h" |
28 | 30 | #include"MolDSException.h" |
29 | -#include"Uncopyable.h" | |
30 | 31 | #include"../wrappers/Lapack.h" |
31 | 32 | #include"Enums.h" |
32 | 33 | #include"MathUtilities.h" |
@@ -29,9 +29,10 @@ | ||
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/shared_ptr.hpp> |
31 | 31 | #include<boost/random.hpp> |
32 | +#include"Uncopyable.h" | |
33 | +#include"../mpi/MpiProcess.h" | |
32 | 34 | #include"PrintController.h" |
33 | 35 | #include"MolDSException.h" |
34 | -#include"Uncopyable.h" | |
35 | 36 | #include"../wrappers/Blas.h" |
36 | 37 | #include"../wrappers/Lapack.h" |
37 | 38 | #include"Utilities.h" |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<vector> |
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/format.hpp> |
28 | +#include"Uncopyable.h" | |
29 | +#include"../mpi/MpiProcess.h" | |
28 | 30 | #include"PrintController.h" |
29 | 31 | #include"MolDSException.h" |
30 | -#include"Uncopyable.h" | |
31 | 32 | #include"../wrappers/Lapack.h" |
32 | 33 | #include"Enums.h" |
33 | 34 | #include"MathUtilities.h" |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<vector> |
28 | 28 | #include<stdexcept> |
29 | 29 | #include<boost/format.hpp> |
30 | +#include"Uncopyable.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
30 | 32 | #include"PrintController.h" |
31 | 33 | #include"MolDSException.h" |
32 | -#include"Uncopyable.h" | |
33 | 34 | #include"Enums.h" |
34 | 35 | #include"MallocerFreer.h" |
35 | 36 | #include"EularAngle.h" |
@@ -289,7 +289,7 @@ private: | ||
289 | 289 | std::vector<int>* electronicStateIndecesMullikenCIS; |
290 | 290 | bool requiresUnpairedPopCIS; |
291 | 291 | // Memory |
292 | - double limitHeapMemory; | |
292 | + double limitHeapMemory; // in [MB] | |
293 | 293 | // MD |
294 | 294 | int electronicStateIndexMD; |
295 | 295 | int totalStepsMD; |
@@ -42,6 +42,9 @@ protected: | ||
42 | 42 | } |
43 | 43 | void OutputLog(std::string log) const{ |
44 | 44 | if(this->canOutputLogs){ |
45 | +#ifndef MOLDS_DBG | |
46 | + if(MolDS_mpi::MpiProcess::GetInstance()->GetRank()!=0){return;} | |
47 | +#endif | |
45 | 48 | bool endl = false; |
46 | 49 | std::string::reverse_iterator iter; |
47 | 50 | for(iter = log.rbegin(); iter != log.rend(); iter++){ |
@@ -25,6 +25,8 @@ | ||
25 | 25 | #include<time.h> |
26 | 26 | #include<omp.h> |
27 | 27 | #include<boost/format.hpp> |
28 | +#include"Uncopyable.h" | |
29 | +#include"../mpi/MpiProcess.h" | |
28 | 30 | #include"PrintController.h" |
29 | 31 | #include"Utilities.h" |
30 | 32 | using namespace std; |
@@ -26,9 +26,10 @@ | ||
26 | 26 | #include<vector> |
27 | 27 | #include<stdexcept> |
28 | 28 | #include<boost/format.hpp> |
29 | +#include"../Uncopyable.h" | |
30 | +#include"../../mpi/MpiProcess.h" | |
29 | 31 | #include"../PrintController.h" |
30 | 32 | #include"../MolDSException.h" |
31 | -#include"../Uncopyable.h" | |
32 | 33 | #include"../Enums.h" |
33 | 34 | #include"../MathUtilities.h" |
34 | 35 | #include"../MallocerFreer.h" |
@@ -23,8 +23,9 @@ | ||
23 | 23 | #include<math.h> |
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | -#include"../PrintController.h" | |
27 | 26 | #include"../Uncopyable.h" |
27 | +#include"../../mpi/MpiProcess.h" | |
28 | +#include"../PrintController.h" | |
28 | 29 | #include"../Enums.h" |
29 | 30 | #include"../EularAngle.h" |
30 | 31 | #include"../Parameters.h" |
@@ -23,8 +23,9 @@ | ||
23 | 23 | #include<math.h> |
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | -#include"../PrintController.h" | |
27 | 26 | #include"../Uncopyable.h" |
27 | +#include"../../mpi/MpiProcess.h" | |
28 | +#include"../PrintController.h" | |
28 | 29 | #include"../Enums.h" |
29 | 30 | #include"../EularAngle.h" |
30 | 31 | #include"../Parameters.h" |
@@ -23,8 +23,9 @@ | ||
23 | 23 | #include<math.h> |
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | -#include"../PrintController.h" | |
27 | 26 | #include"../Uncopyable.h" |
27 | +#include"../../mpi/MpiProcess.h" | |
28 | +#include"../PrintController.h" | |
28 | 29 | #include"../Enums.h" |
29 | 30 | #include"../EularAngle.h" |
30 | 31 | #include"../Parameters.h" |
@@ -23,8 +23,9 @@ | ||
23 | 23 | #include<math.h> |
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | -#include"../PrintController.h" | |
27 | 26 | #include"../Uncopyable.h" |
27 | +#include"../../mpi/MpiProcess.h" | |
28 | +#include"../PrintController.h" | |
28 | 29 | #include"../Enums.h" |
29 | 30 | #include"../EularAngle.h" |
30 | 31 | #include"../Parameters.h" |
@@ -23,8 +23,9 @@ | ||
23 | 23 | #include<math.h> |
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | -#include"../PrintController.h" | |
27 | 26 | #include"../Uncopyable.h" |
27 | +#include"../../mpi/MpiProcess.h" | |
28 | +#include"../PrintController.h" | |
28 | 29 | #include"../Enums.h" |
29 | 30 | #include"../EularAngle.h" |
30 | 31 | #include"../Parameters.h" |
@@ -23,8 +23,9 @@ | ||
23 | 23 | #include<math.h> |
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | -#include"../PrintController.h" | |
27 | 26 | #include"../Uncopyable.h" |
27 | +#include"../../mpi/MpiProcess.h" | |
28 | +#include"../PrintController.h" | |
28 | 29 | #include"../Enums.h" |
29 | 30 | #include"../EularAngle.h" |
30 | 31 | #include"../Parameters.h" |
@@ -23,9 +23,10 @@ | ||
23 | 23 | #include<vector> |
24 | 24 | #include<stdexcept> |
25 | 25 | #include<boost/format.hpp> |
26 | +#include"../Uncopyable.h" | |
27 | +#include"../../mpi/MpiProcess.h" | |
26 | 28 | #include"../PrintController.h" |
27 | 29 | #include"../MolDSException.h" |
28 | -#include"../Uncopyable.h" | |
29 | 30 | #include"../Enums.h" |
30 | 31 | #include"../atoms/Atom.h" |
31 | 32 | #include"../atoms/Hatom.h" |
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<vector> |
25 | 25 | #include<stdexcept> |
26 | 26 | #include<boost/format.hpp> |
27 | +#include"../Uncopyable.h" | |
28 | +#include"../../mpi/MpiProcess.h" | |
27 | 29 | #include"../PrintController.h" |
28 | 30 | #include"../MolDSException.h" |
29 | -#include"../Uncopyable.h" | |
30 | 31 | #include"../Enums.h" |
31 | 32 | #include"../MallocerFreer.h" |
32 | 33 | #include"../EularAngle.h" |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<stdexcept> |
26 | 26 | #include<boost/shared_ptr.hpp> |
27 | 27 | #include<boost/format.hpp> |
28 | +#include"../Uncopyable.h" | |
29 | +#include"../../mpi/MpiProcess.h" | |
28 | 30 | #include"../PrintController.h" |
29 | 31 | #include"../MolDSException.h" |
30 | -#include"../Uncopyable.h" | |
31 | 32 | #include"../Enums.h" |
32 | 33 | #include"../MallocerFreer.h" |
33 | 34 | #include"../EularAngle.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<stdexcept> |
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | +#include"../Uncopyable.h" | |
32 | +#include"../../mpi/MpiProcess.h" | |
31 | 33 | #include"../PrintController.h" |
32 | 34 | #include"../MolDSException.h" |
33 | -#include"../Uncopyable.h" | |
34 | 35 | #include"../Utilities.h" |
35 | 36 | #include"../Enums.h" |
36 | 37 | #include"../MallocerFreer.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<stdexcept> |
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | +#include"../Uncopyable.h" | |
32 | +#include"../../mpi/MpiProcess.h" | |
31 | 33 | #include"../PrintController.h" |
32 | 34 | #include"../MolDSException.h" |
33 | -#include"../Uncopyable.h" | |
34 | 35 | #include"../Utilities.h" |
35 | 36 | #include"../Enums.h" |
36 | 37 | #include"../EularAngle.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<stdexcept> |
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | +#include"../Uncopyable.h" | |
32 | +#include"../../mpi/MpiProcess.h" | |
31 | 33 | #include"../PrintController.h" |
32 | 34 | #include"../MolDSException.h" |
33 | -#include"../Uncopyable.h" | |
34 | 35 | #include"../Utilities.h" |
35 | 36 | #include"../Enums.h" |
36 | 37 | #include"../EularAngle.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<stdexcept> |
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | +#include"../Uncopyable.h" | |
32 | +#include"../../mpi/MpiProcess.h" | |
31 | 33 | #include"../PrintController.h" |
32 | 34 | #include"../MolDSException.h" |
33 | -#include"../Uncopyable.h" | |
34 | 35 | #include"../Utilities.h" |
35 | 36 | #include"../Enums.h" |
36 | 37 | #include"../EularAngle.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<stdexcept> |
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | +#include"../base/Uncopyable.h" | |
32 | +#include"../mpi/MpiProcess.h" | |
31 | 33 | #include"../base/PrintController.h" |
32 | 34 | #include"../base/MolDSException.h" |
33 | -#include"../base/Uncopyable.h" | |
34 | 35 | #include"../wrappers/Blas.h" |
35 | 36 | #include"../wrappers/Lapack.h" |
36 | 37 | #include"../base/Enums.h" |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<vector> |
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/format.hpp> |
28 | +#include"../base/Uncopyable.h" | |
29 | +#include"../mpi/MpiProcess.h" | |
28 | 30 | #include"../base/PrintController.h" |
29 | 31 | #include"../base/MolDSException.h" |
30 | -#include"../base/Uncopyable.h" | |
31 | 32 | #include"../base/EularAngle.h" |
32 | 33 | #include"../base/Enums.h" |
33 | 34 | #include"../base/atoms/Atom.h" |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<boost/shared_ptr.hpp> |
28 | 28 | #include<boost/random.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | +#include"../base/Uncopyable.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
30 | 32 | #include"../base/PrintController.h" |
31 | 33 | #include"../base/MolDSException.h" |
32 | -#include"../base/Uncopyable.h" | |
33 | 34 | #include"../base/Enums.h" |
34 | 35 | #include"../base/EularAngle.h" |
35 | 36 | #include"../base/Parameters.h" |
@@ -26,9 +26,10 @@ | ||
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/shared_ptr.hpp> |
28 | 28 | #include<boost/format.hpp> |
29 | +#include"../base/Uncopyable.h" | |
30 | +#include"../mpi/MpiProcess.h" | |
29 | 31 | #include"../base/PrintController.h" |
30 | 32 | #include"../base/MolDSException.h" |
31 | -#include"../base/Uncopyable.h" | |
32 | 33 | #include"../base/Enums.h" |
33 | 34 | #include"../base/EularAngle.h" |
34 | 35 | #include"../base/Parameters.h" |
@@ -26,9 +26,10 @@ | ||
26 | 26 | #include<stdexcept> |
27 | 27 | #include<omp.h> |
28 | 28 | #include<boost/format.hpp> |
29 | +#include"../base/Uncopyable.h" | |
30 | +#include"../mpi/MpiProcess.h" | |
29 | 31 | #include"../base/PrintController.h" |
30 | 32 | #include"../base/MolDSException.h" |
31 | -#include"../base/Uncopyable.h" | |
32 | 33 | #include"../wrappers/Blas.h" |
33 | 34 | #include"../wrappers/Lapack.h" |
34 | 35 | #include"../base/Enums.h" |
@@ -728,21 +729,24 @@ double Mndo::GetMolecularIntegralElement(int moI, int moJ, int moK, int moL, | ||
728 | 729 | void Mndo::CalcCISMatrix(double** matrixCIS) const{ |
729 | 730 | this->OutputLog(this->messageStartCalcCISMatrix); |
730 | 731 | double ompStartTime = omp_get_wtime(); |
732 | + int mpiRank = MolDS_mpi::MpiProcess::GetInstance()->GetRank(); | |
733 | + int mpiSize = MolDS_mpi::MpiProcess::GetInstance()->GetSize(); | |
731 | 734 | |
732 | - stringstream ompErrors; | |
733 | -#pragma omp parallel for schedule(auto) | |
734 | 735 | for(int k=0; k<this->matrixCISdimension; k++){ |
735 | - try{ | |
736 | - // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
737 | - int moI = this->GetActiveOccIndex(*this->molecule, k); | |
738 | - int moA = this->GetActiveVirIndex(*this->molecule, k); | |
736 | + if(k%mpiSize != mpiRank){continue;} | |
739 | 737 | |
740 | - for(int l=k; l<this->matrixCISdimension; l++){ | |
738 | + // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
739 | + int moI = this->GetActiveOccIndex(*this->molecule, k); | |
740 | + int moA = this->GetActiveVirIndex(*this->molecule, k); | |
741 | + stringstream ompErrors; | |
742 | +#pragma omp parallel for schedule(auto) | |
743 | + for(int l=k; l<this->matrixCISdimension; l++){ | |
744 | + try{ | |
741 | 745 | // single excitation from J-th (occupied)MO to B-th (virtual)MO |
742 | 746 | int moJ = this->GetActiveOccIndex(*this->molecule, l); |
743 | 747 | int moB = this->GetActiveVirIndex(*this->molecule, l); |
744 | 748 | double value=0.0; |
745 | - | |
749 | + | |
746 | 750 | // Fast algorith, but this is not easy to read. |
747 | 751 | // Slow algorithm is alos written below. |
748 | 752 | for(int A=0; A<molecule->GetNumberAtoms(); A++){ |
@@ -862,13 +866,13 @@ void Mndo::CalcCISMatrix(double** matrixCIS) const{ | ||
862 | 866 | } |
863 | 867 | } |
864 | 868 | // End of the fast algorith. |
865 | - | |
869 | + | |
866 | 870 | /* |
867 | 871 | // Slow algorith, but this is easy to read. Fast altorithm is also written above. |
868 | 872 | value = 2.0*this->GetMolecularIntegralElement(moA, moI, moJ, moB, |
869 | - this->molecule, this->fockMatrix, NULL) | |
873 | + *this->molecule, this->fockMatrix, NULL) | |
870 | 874 | -this->GetMolecularIntegralElement(moA, moB, moI, moJ, |
871 | - this->molecule, this->fockMatrix, NULL); | |
875 | + *this->molecule, this->fockMatrix, NULL); | |
872 | 876 | // End of the slow algorith. |
873 | 877 | */ |
874 | 878 | // Diagonal term |
@@ -876,17 +880,42 @@ void Mndo::CalcCISMatrix(double** matrixCIS) const{ | ||
876 | 880 | value += this->energiesMO[moA] - this->energiesMO[moI]; |
877 | 881 | } |
878 | 882 | matrixCIS[k][l] = value; |
883 | + } | |
884 | + catch(MolDSException ex){ | |
885 | +#pragma omp critical | |
886 | + ompErrors << ex.what() << endl ; | |
879 | 887 | } |
888 | + }// end of l-loop | |
889 | + // Exception throwing for omp-region | |
890 | + if(!ompErrors.str().empty()){ | |
891 | + throw MolDSException(ompErrors.str()); | |
880 | 892 | } |
881 | - catch(MolDSException ex){ | |
882 | -#pragma omp critical | |
883 | - ompErrors << ex.what() << endl ; | |
893 | + } // end of k-loop | |
894 | + | |
895 | + // communication to collect all matrix data on rank 0 | |
896 | + if(mpiRank == 0){ | |
897 | + // receive the matrix data from other ranks | |
898 | + for(int k=0; k<this->matrixCISdimension; k++){ | |
899 | + if(k%mpiSize == 0){continue;} | |
900 | + int source = k%mpiSize; | |
901 | + int tag = k; | |
902 | + MolDS_mpi::MpiProcess::GetInstance()->Recv(source, tag, matrixCIS[k], this->matrixCISdimension); | |
884 | 903 | } |
885 | 904 | } |
886 | - // Exception throwing for omp-region | |
887 | - if(!ompErrors.str().empty()){ | |
888 | - throw MolDSException(ompErrors.str()); | |
905 | + else{ | |
906 | + // send the matrix data to rank-0 | |
907 | + for(int k=0; k<this->matrixCISdimension; k++){ | |
908 | + if(k%mpiSize != mpiRank){continue;} | |
909 | + int dest = 0; | |
910 | + int tag = k; | |
911 | + MolDS_mpi::MpiProcess::GetInstance()->Send(dest, tag, matrixCIS[k], this->matrixCISdimension); | |
912 | + } | |
889 | 913 | } |
914 | + // broadcast all matrix data to all rank | |
915 | + int root=0; | |
916 | + MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&matrixCIS[0][0], this->matrixCISdimension*this->matrixCISdimension, root); | |
917 | + | |
918 | + | |
890 | 919 | double ompEndTime = omp_get_wtime(); |
891 | 920 | this->OutputLog(boost::format("%s%lf%s\n%s") % this->messageOmpElapsedTimeCalcCISMarix.c_str() |
892 | 921 | % (ompEndTime - ompStartTime) |
@@ -0,0 +1,75 @@ | ||
1 | +//************************************************************************// | |
2 | +// Copyright (C) 2011-2012 Mikiya Fujii // | |
3 | +// // | |
4 | +// This file is part of MolDS. // | |
5 | +// // | |
6 | +// MolDS is free software: you can redistribute it and/or modify // | |
7 | +// it under the terms of the GNU General Public License as published by // | |
8 | +// the Free Software Foundation, either version 3 of the License, or // | |
9 | +// (at your option) any later version. // | |
10 | +// // | |
11 | +// MolDS is distributed in the hope that it will be useful, // | |
12 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of // | |
13 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | |
14 | +// GNU General Public License for more details. // | |
15 | +// // | |
16 | +// You should have received a copy of the GNU General Public License // | |
17 | +// along with MolDS. If not, see <http://www.gnu.org/licenses/>. // | |
18 | +//************************************************************************// | |
19 | +#include<stdio.h> | |
20 | +#include<stdlib.h> | |
21 | +#include<iostream> | |
22 | +#include<sstream> | |
23 | +#include<math.h> | |
24 | +#include<string> | |
25 | +#include<stdexcept> | |
26 | +#include"../base/MolDSException.h" | |
27 | +#include"../base/Uncopyable.h" | |
28 | +#include"MpiProcess.h" | |
29 | +using namespace std; | |
30 | +namespace MolDS_mpi{ | |
31 | + | |
32 | +MpiProcess* MpiProcess::mpiProcess = NULL; | |
33 | + | |
34 | +MpiProcess::MpiProcess(){ | |
35 | +} | |
36 | + | |
37 | +MpiProcess::MpiProcess(int argc, char *argv[]){ | |
38 | + this->environment = new boost::mpi::environment(argc, argv); | |
39 | + this->communicator = new boost::mpi::communicator(); | |
40 | + this->messageLimit = INT_MAX; | |
41 | +} | |
42 | + | |
43 | +MpiProcess::~MpiProcess(){ | |
44 | + delete this->environment; | |
45 | + delete this->communicator; | |
46 | +} | |
47 | + | |
48 | +void MpiProcess::CreateInstance(int argc, char *argv[]){ | |
49 | + if(mpiProcess != NULL){ | |
50 | + // ToDo: error | |
51 | + } | |
52 | + mpiProcess = new MpiProcess(argc, argv); | |
53 | +} | |
54 | + | |
55 | +void MpiProcess::DeleteInstance(){ | |
56 | + if(mpiProcess != NULL){ | |
57 | + delete mpiProcess; | |
58 | + } | |
59 | + mpiProcess = NULL; | |
60 | +} | |
61 | + | |
62 | +MpiProcess* MpiProcess::GetInstance(){ | |
63 | + if(mpiProcess == NULL){ | |
64 | + //mpiProcess = new MpiProcess(); | |
65 | + // ToDo: error | |
66 | + } | |
67 | + return mpiProcess; | |
68 | +} | |
69 | + | |
70 | +} | |
71 | + | |
72 | + | |
73 | + | |
74 | + | |
75 | + |
@@ -0,0 +1,90 @@ | ||
1 | +//************************************************************************// | |
2 | +// Copyright (C) 2011-2012 Mikiya Fujii // | |
3 | +// // | |
4 | +// This file is part of MolDS. // | |
5 | +// // | |
6 | +// MolDS is free software: you can redistribute it and/or modify // | |
7 | +// it under the terms of the GNU General Public License as published by // | |
8 | +// the Free Software Foundation, either version 3 of the License, or // | |
9 | +// (at your option) any later version. // | |
10 | +// // | |
11 | +// MolDS is distributed in the hope that it will be useful, // | |
12 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of // | |
13 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | |
14 | +// GNU General Public License for more details. // | |
15 | +// // | |
16 | +// You should have received a copy of the GNU General Public License // | |
17 | +// along with MolDS. If not, see <http://www.gnu.org/licenses/>. // | |
18 | +//************************************************************************// | |
19 | +#ifndef INCLUDED_MPIPROCESS | |
20 | +#define INCLUDED_MPIPROCESS | |
21 | +#include<limits.h> | |
22 | +#include<boost/mpi.hpp> | |
23 | +namespace MolDS_mpi{ | |
24 | +// MpiProcess is singleton | |
25 | +class MpiProcess: private MolDS_base::Uncopyable{ | |
26 | +public: | |
27 | + static void CreateInstance(int argc, char *argv[]); | |
28 | + static void DeleteInstance(); | |
29 | + static MpiProcess* GetInstance(); | |
30 | + int GetRank() const{return this->communicator->rank();} | |
31 | + int GetSize() const{return this->communicator->size();} | |
32 | + template<typename T> void Send(int dest, int tag, const T* values, intptr_t num) const{ | |
33 | + std::vector<Chunk> chunks; | |
34 | + this->SplitMessage2Chunks(chunks, tag, values, num); | |
35 | + for(intptr_t i=0; i<chunks.size(); i++){ | |
36 | + this->communicator->send(dest, chunks[i].tag, &values[chunks[i].first], chunks[i].num); | |
37 | + } | |
38 | + } | |
39 | + template<typename T> void Recv(int source, int tag, T* values, intptr_t num) const{ | |
40 | + std::vector<Chunk> chunks; | |
41 | + this->SplitMessage2Chunks(chunks, tag, values, num); | |
42 | + for(intptr_t i=0; i<chunks.size(); i++){ | |
43 | + this->communicator->recv(source, chunks[i].tag, &values[chunks[i].first], chunks[i].num); | |
44 | + } | |
45 | + } | |
46 | + template<typename T> void Broadcast(T* values, intptr_t num, int root) const{ | |
47 | + std::vector<Chunk> chunks; | |
48 | + intptr_t tag=0; | |
49 | + this->SplitMessage2Chunks(chunks, tag, values, num); | |
50 | + for(intptr_t i=0; i<chunks.size(); i++){ | |
51 | + broadcast(*this->communicator, &values[chunks[i].first], chunks[i].num, root); | |
52 | + } | |
53 | + } | |
54 | +private: | |
55 | + static MpiProcess* mpiProcess; | |
56 | + MpiProcess(); | |
57 | + MpiProcess(int argc, char *argv[]); | |
58 | + ~MpiProcess(); | |
59 | + boost::mpi::environment* environment; | |
60 | + boost::mpi::communicator* communicator; | |
61 | + struct Chunk{int tag; intptr_t first; int num;}; | |
62 | + double messageLimit; | |
63 | + template<typename T> void SplitMessage2Chunks(std::vector<Chunk>& chunks, const int origianlTag, T* values, intptr_t num) const{ | |
64 | + if(this->messageLimit < static_cast<double>(sizeof(T))*static_cast<double>(num) ){ | |
65 | + int elementsLimit = static_cast<intptr_t>(messageLimit/sizeof(T)); | |
66 | + intptr_t numChunks = num/elementsLimit; | |
67 | + int remaining = num%elementsLimit; | |
68 | + if(0 < remaining){ | |
69 | + numChunks++; | |
70 | + } | |
71 | + int tagBase = origianlTag*numChunks; | |
72 | + for(intptr_t i=0; i<numChunks; i++){ | |
73 | + int tag = tagBase+i; | |
74 | + Chunk chunk = {tag, i*elementsLimit, elementsLimit}; | |
75 | + chunks.push_back(chunk); | |
76 | + } | |
77 | + if(0 < remaining){ | |
78 | + chunks[numChunks-1].num = remaining; | |
79 | + } | |
80 | + } | |
81 | + else{ | |
82 | + Chunk chunk = {origianlTag, 0, num}; | |
83 | + chunks.push_back(chunk); | |
84 | + } | |
85 | + } | |
86 | +}; | |
87 | + | |
88 | +} | |
89 | +#endif | |
90 | + |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<boost/shared_ptr.hpp> |
28 | 28 | #include<boost/random.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | +#include"../base/Uncopyable.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
30 | 32 | #include"../base/PrintController.h" |
31 | 33 | #include"../base/MolDSException.h" |
32 | -#include"../base/Uncopyable.h" | |
33 | 34 | #include"../base/Enums.h" |
34 | 35 | #include"../base/MallocerFreer.h" |
35 | 36 | #include"../base/EularAngle.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<stdexcept> |
29 | 29 | #include<boost/shared_ptr.hpp> |
30 | 30 | #include<boost/format.hpp> |
31 | +#include"../base/Uncopyable.h" | |
32 | +#include"../mpi/MpiProcess.h" | |
31 | 33 | #include"../base/PrintController.h" |
32 | 34 | #include"../base/MolDSException.h" |
33 | -#include"../base/Uncopyable.h" | |
34 | 35 | #include"../wrappers/Blas.h" |
35 | 36 | #include"../wrappers/Lapack.h" |
36 | 37 | #include"../base/Enums.h" |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<stdexcept> |
28 | 28 | #include<boost/shared_ptr.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | +#include"../base/Uncopyable.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
30 | 32 | #include"../base/PrintController.h" |
31 | 33 | #include"../base/MolDSException.h" |
32 | -#include"../base/Uncopyable.h" | |
33 | 34 | #include"../base/Enums.h" |
34 | 35 | #include"../base/MallocerFreer.h" |
35 | 36 | #include"../base/EularAngle.h" |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<stdexcept> |
28 | 28 | #include<boost/shared_ptr.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | +#include"../base/Uncopyable.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
30 | 32 | #include"../base/PrintController.h" |
31 | 33 | #include"../base/MolDSException.h" |
32 | -#include"../base/Uncopyable.h" | |
33 | 34 | #include"../base/Enums.h" |
34 | 35 | #include"../base/EularAngle.h" |
35 | 36 | #include"../base/Parameters.h" |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<stdexcept> |
28 | 28 | #include<boost/shared_ptr.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | +#include"../base/Uncopyable.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
30 | 32 | #include"../base/PrintController.h" |
31 | 33 | #include"../base/MolDSException.h" |
32 | -#include"../base/Uncopyable.h" | |
33 | 34 | #include"../base/Enums.h" |
34 | 35 | #include"../base/EularAngle.h" |
35 | 36 | #include"../base/Parameters.h" |
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<string> |
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | +#include"../base/Uncopyable.h" | |
28 | +#include"../mpi/MpiProcess.h" | |
27 | 29 | #include"../base/PrintController.h" |
28 | 30 | #include"../base/MolDSException.h" |
29 | -#include"../base/Uncopyable.h" | |
30 | 31 | #include"../base/Enums.h" |
31 | 32 | #include"../base/EularAngle.h" |
32 | 33 | #include"../base/Parameters.h" |
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<string> |
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | +#include"../base/Uncopyable.h" | |
28 | +#include"../mpi/MpiProcess.h" | |
27 | 29 | #include"../base/PrintController.h" |
28 | 30 | #include"../base/MolDSException.h" |
29 | -#include"../base/Uncopyable.h" | |
30 | 31 | #include"../base/Enums.h" |
31 | 32 | #include"../base/EularAngle.h" |
32 | 33 | #include"../base/Parameters.h" |
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<string> |
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | +#include"../base/Uncopyable.h" | |
28 | +#include"../mpi/MpiProcess.h" | |
27 | 29 | #include"../base/PrintController.h" |
28 | 30 | #include"../base/MolDSException.h" |
29 | -#include"../base/Uncopyable.h" | |
30 | 31 | #include"../base/Enums.h" |
31 | 32 | #include"../base/EularAngle.h" |
32 | 33 | #include"../base/Parameters.h" |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<boost/shared_ptr.hpp> |
28 | 28 | #include<boost/random.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | +#include"../base/Uncopyable.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
30 | 32 | #include"../base/PrintController.h" |
31 | 33 | #include"../base/MolDSException.h" |
32 | -#include"../base/Uncopyable.h" | |
33 | 34 | #include"../base/Enums.h" |
34 | 35 | #include"../base/EularAngle.h" |
35 | 36 | #include"../base/Parameters.h" |
@@ -25,16 +25,19 @@ | ||
25 | 25 | #include<string> |
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/format.hpp> |
28 | +#include"../base/Uncopyable.h" | |
29 | +#include"../mpi/MpiProcess.h" | |
30 | +#include"../base/PrintController.h" | |
31 | +#include"../base/MolDSException.h" | |
32 | +#include"../base/MallocerFreer.h" | |
33 | +#include"Blas.h" | |
34 | + | |
28 | 35 | #ifdef __INTEL_COMPILER |
29 | 36 | #include"mkl.h" |
30 | 37 | #else |
31 | 38 | #include"cblas.h" |
32 | 39 | #endif |
33 | -#include"../base/PrintController.h" | |
34 | -#include"../base/MolDSException.h" | |
35 | -#include"../base/Uncopyable.h" | |
36 | -#include"../base/MallocerFreer.h" | |
37 | -#include"Blas.h" | |
40 | + | |
38 | 41 | using namespace std; |
39 | 42 | using namespace MolDS_base; |
40 | 43 |
@@ -24,6 +24,13 @@ | ||
24 | 24 | #include<string> |
25 | 25 | #include<stdexcept> |
26 | 26 | #include<boost/format.hpp> |
27 | +#include"../base/Uncopyable.h" | |
28 | +#include"../mpi/MpiProcess.h" | |
29 | +#include"../base/PrintController.h" | |
30 | +#include"../base/MolDSException.h" | |
31 | +#include"../base/Enums.h" | |
32 | +#include"Lapack.h" | |
33 | + | |
27 | 34 | #ifdef __INTEL_COMPILER |
28 | 35 | #include"mkl.h" |
29 | 36 | #else |
@@ -34,11 +41,6 @@ | ||
34 | 41 | #endif |
35 | 42 | #include"lapacke.h" |
36 | 43 | #endif |
37 | -#include"../base/PrintController.h" | |
38 | -#include"../base/MolDSException.h" | |
39 | -#include"../base/Uncopyable.h" | |
40 | -#include"../base/Enums.h" | |
41 | -#include"Lapack.h" | |
42 | 44 | |
43 | 45 | #ifdef __INTEL_COMPILER |
44 | 46 | #define MOLDS_LAPACK_malloc(a,b) mkl_malloc(a,b) |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<algorithm> |
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | +#include"../base/Uncopyable.h" | |
32 | +#include"../mpi/MpiProcess.h" | |
31 | 33 | #include"../base/PrintController.h" |
32 | 34 | #include"../base/MolDSException.h" |
33 | -#include"../base/Uncopyable.h" | |
34 | 35 | #include"../wrappers/Blas.h" |
35 | 36 | #include"../wrappers/Lapack.h" |
36 | 37 | #include"../base/Enums.h" |
@@ -1084,131 +1085,185 @@ void ZindoS::DoCIS(){ | ||
1084 | 1085 | void ZindoS::CalcCISProperties(){ |
1085 | 1086 | //calculate dipole moments and transitiondipolemoment |
1086 | 1087 | { |
1087 | - double*** dipoleMOs = NULL; | |
1088 | - double** overlapMOs = NULL; | |
1089 | 1088 | int totalNumberAOs = this->molecule->GetTotalNumberAOs(); |
1090 | 1089 | int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2; |
1091 | 1090 | int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS(); |
1092 | 1091 | int numberActiveVir = Parameters::GetInstance()->GetActiveVirCIS(); |
1093 | - MallocerFreer::GetInstance()->Malloc<double>(&dipoleMOs, CartesianType_end, totalNumberAOs, totalNumberAOs); | |
1094 | - MallocerFreer::GetInstance()->Malloc<double>(&overlapMOs, totalNumberAOs, totalNumberAOs); | |
1095 | - double alpha=1.0; | |
1096 | - double beta =0.0; | |
1097 | - //double ompStartTime = omp_get_wtime(); | |
1098 | - MolDS_wrappers::Blas::GetInstance()->Dgemmm(false, false, true, totalNumberAOs, totalNumberAOs, totalNumberAOs, totalNumberAOs, | |
1099 | - alpha, | |
1100 | - this->fockMatrix, | |
1101 | - this->cartesianMatrix[XAxis], | |
1102 | - this->fockMatrix, | |
1103 | - beta, | |
1104 | - dipoleMOs[XAxis]); | |
1105 | - MolDS_wrappers::Blas::GetInstance()->Dgemmm(false, false, true, totalNumberAOs, totalNumberAOs, totalNumberAOs, totalNumberAOs, | |
1106 | - alpha, | |
1107 | - this->fockMatrix, | |
1108 | - this->cartesianMatrix[YAxis], | |
1109 | - this->fockMatrix, | |
1110 | - beta, | |
1111 | - dipoleMOs[YAxis]); | |
1112 | - MolDS_wrappers::Blas::GetInstance()->Dgemmm(false, false, true, totalNumberAOs, totalNumberAOs, totalNumberAOs, totalNumberAOs, | |
1113 | - alpha, | |
1114 | - this->fockMatrix, | |
1115 | - this->cartesianMatrix[ZAxis], | |
1116 | - this->fockMatrix, | |
1117 | - beta, | |
1118 | - dipoleMOs[ZAxis]); | |
1119 | - | |
1120 | - double const* centerOfDipole = this->molecule->GetXyzCOC(); | |
1121 | - // set orign of dipole | |
1122 | - MolDS_wrappers::Blas::GetInstance()->Dgemmm(false, false, true, totalNumberAOs, totalNumberAOs, totalNumberAOs, totalNumberAOs, | |
1123 | - alpha, | |
1124 | - this->fockMatrix, | |
1125 | - this->overlapAOs, | |
1126 | - this->fockMatrix, | |
1127 | - beta, | |
1128 | - overlapMOs); | |
1129 | - MolDS_wrappers::Blas::GetInstance()->Daxpy(totalNumberAOs*totalNumberAOs, | |
1130 | - -centerOfDipole[XAxis], | |
1131 | - &overlapMOs[0][0], | |
1132 | - &dipoleMOs[XAxis][0][0]); | |
1133 | - MolDS_wrappers::Blas::GetInstance()->Daxpy(totalNumberAOs*totalNumberAOs, | |
1134 | - -centerOfDipole[YAxis], | |
1135 | - &overlapMOs[0][0], | |
1136 | - &dipoleMOs[YAxis][0][0]); | |
1137 | - MolDS_wrappers::Blas::GetInstance()->Daxpy(totalNumberAOs*totalNumberAOs, | |
1138 | - -centerOfDipole[ZAxis], | |
1139 | - &overlapMOs[0][0], | |
1140 | - &dipoleMOs[ZAxis][0][0]); | |
1141 | - | |
1142 | - | |
1143 | - // dipole moments of excited states | |
1144 | - //this->CalcElectronicDipoleMomentsExcitedStates(this->electronicTransitionDipoleMoments, | |
1145 | - // this->fockMatrix, | |
1146 | - // this->matrixCIS, | |
1147 | - // this->cartesianMatrix, | |
1148 | - // *this->molecule, | |
1149 | - // this->orbitalElectronPopulation, | |
1150 | - // this->overlapAOs); | |
1151 | - int groundState = 0; | |
1152 | - for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS(); k++){ | |
1153 | - int excitedState = k+1; // (k+1)-th excited state | |
1154 | - this->electronicTransitionDipoleMoments[excitedState][excitedState][XAxis] = this->electronicTransitionDipoleMoments[groundState][groundState][XAxis]; | |
1155 | - this->electronicTransitionDipoleMoments[excitedState][excitedState][YAxis] = this->electronicTransitionDipoleMoments[groundState][groundState][YAxis]; | |
1156 | - this->electronicTransitionDipoleMoments[excitedState][excitedState][ZAxis] = this->electronicTransitionDipoleMoments[groundState][groundState][ZAxis]; | |
1157 | - for(int l=0; l<this->matrixCISdimension; l++){ | |
1158 | - // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
1159 | - int moI = this->GetActiveOccIndex(*this->molecule, l); | |
1160 | - int moA = this->GetActiveVirIndex(*this->molecule, l); | |
1161 | - double temp = matrixCIS[k][l]*matrixCIS[k][l]; | |
1162 | - this->electronicTransitionDipoleMoments[excitedState][excitedState][XAxis] += temp*(-dipoleMOs[XAxis][moI][moI]+dipoleMOs[XAxis][moA][moA]); | |
1163 | - this->electronicTransitionDipoleMoments[excitedState][excitedState][YAxis] += temp*(-dipoleMOs[YAxis][moI][moI]+dipoleMOs[YAxis][moA][moA]); | |
1164 | - this->electronicTransitionDipoleMoments[excitedState][excitedState][ZAxis] += temp*(-dipoleMOs[ZAxis][moI][moI]+dipoleMOs[ZAxis][moA][moA]); | |
1165 | - } | |
1166 | - } | |
1167 | - | |
1168 | - // transition dipole moment | |
1169 | - //this->CalcElectronicTransitionDipoleMoments(this->electronicTransitionDipoleMoments, | |
1170 | - // this->fockMatrix, | |
1171 | - // this->matrixCIS, | |
1172 | - // this->cartesianMatrix, | |
1173 | - // *this->molecule, | |
1174 | - // this->orbitalElectronPopulation, | |
1175 | - // this->overlapAOs); | |
1176 | - for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS(); k++){ | |
1177 | - int excitedState = k+1; // (k+1)-th excited state | |
1178 | - this->electronicTransitionDipoleMoments[excitedState][groundState][XAxis] = 0.0; | |
1179 | - this->electronicTransitionDipoleMoments[excitedState][groundState][YAxis] = 0.0; | |
1180 | - this->electronicTransitionDipoleMoments[excitedState][groundState][ZAxis] = 0.0; | |
1181 | - for(int l=0; l<this->matrixCISdimension; l++){ | |
1182 | - // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
1183 | - int moI = this->GetActiveOccIndex(*this->molecule, l); | |
1184 | - int moA = this->GetActiveVirIndex(*this->molecule, l); | |
1185 | - //double temp = matrixCIS[k][l]*matrixCIS[k][l]; | |
1186 | - double temp = this->matrixCIS[k][l]*sqrt(2.0); | |
1187 | - this->electronicTransitionDipoleMoments[excitedState][groundState][XAxis] += temp*dipoleMOs[XAxis][moA][moI]; | |
1188 | - this->electronicTransitionDipoleMoments[excitedState][groundState][YAxis] += temp*dipoleMOs[YAxis][moA][moI]; | |
1189 | - this->electronicTransitionDipoleMoments[excitedState][groundState][ZAxis] += temp*dipoleMOs[ZAxis][moA][moI]; | |
1190 | - } | |
1191 | - } | |
1192 | - if(Parameters::GetInstance()->RequiresAllTransitionDipoleMomentsCIS()){ | |
1092 | + int mpiRank = MolDS_mpi::MpiProcess::GetInstance()->GetRank(); | |
1093 | + int mpiSize = MolDS_mpi::MpiProcess::GetInstance()->GetSize(); | |
1094 | + double*** dipoleMOs = NULL; | |
1095 | + double** overlapMOs = NULL; | |
1096 | + try{ | |
1097 | + MallocerFreer::GetInstance()->Malloc<double>(&dipoleMOs, CartesianType_end, totalNumberAOs, totalNumberAOs); | |
1098 | + MallocerFreer::GetInstance()->Malloc<double>(&overlapMOs, totalNumberAOs, totalNumberAOs); | |
1099 | + double alpha=1.0; | |
1100 | + double beta =0.0; | |
1101 | + //double ompStartTime = omp_get_wtime(); | |
1102 | + MolDS_wrappers::Blas::GetInstance()->Dgemmm(false, false, true, totalNumberAOs, totalNumberAOs, totalNumberAOs, totalNumberAOs, | |
1103 | + alpha, | |
1104 | + this->fockMatrix, | |
1105 | + this->cartesianMatrix[XAxis], | |
1106 | + this->fockMatrix, | |
1107 | + beta, | |
1108 | + dipoleMOs[XAxis]); | |
1109 | + MolDS_wrappers::Blas::GetInstance()->Dgemmm(false, false, true, totalNumberAOs, totalNumberAOs, totalNumberAOs, totalNumberAOs, | |
1110 | + alpha, | |
1111 | + this->fockMatrix, | |
1112 | + this->cartesianMatrix[YAxis], | |
1113 | + this->fockMatrix, | |
1114 | + beta, | |
1115 | + dipoleMOs[YAxis]); | |
1116 | + MolDS_wrappers::Blas::GetInstance()->Dgemmm(false, false, true, totalNumberAOs, totalNumberAOs, totalNumberAOs, totalNumberAOs, | |
1117 | + alpha, | |
1118 | + this->fockMatrix, | |
1119 | + this->cartesianMatrix[ZAxis], | |
1120 | + this->fockMatrix, | |
1121 | + beta, | |
1122 | + dipoleMOs[ZAxis]); | |
1123 | + | |
1124 | + double const* centerOfDipole = this->molecule->GetXyzCOC(); | |
1125 | + // set orign of dipole | |
1126 | + MolDS_wrappers::Blas::GetInstance()->Dgemmm(false, false, true, totalNumberAOs, totalNumberAOs, totalNumberAOs, totalNumberAOs, | |
1127 | + alpha, | |
1128 | + this->fockMatrix, | |
1129 | + this->overlapAOs, | |
1130 | + this->fockMatrix, | |
1131 | + beta, | |
1132 | + overlapMOs); | |
1133 | + MolDS_wrappers::Blas::GetInstance()->Daxpy(totalNumberAOs*totalNumberAOs, | |
1134 | + -centerOfDipole[XAxis], | |
1135 | + &overlapMOs[0][0], | |
1136 | + &dipoleMOs[XAxis][0][0]); | |
1137 | + MolDS_wrappers::Blas::GetInstance()->Daxpy(totalNumberAOs*totalNumberAOs, | |
1138 | + -centerOfDipole[YAxis], | |
1139 | + &overlapMOs[0][0], | |
1140 | + &dipoleMOs[YAxis][0][0]); | |
1141 | + MolDS_wrappers::Blas::GetInstance()->Daxpy(totalNumberAOs*totalNumberAOs, | |
1142 | + -centerOfDipole[ZAxis], | |
1143 | + &overlapMOs[0][0], | |
1144 | + &dipoleMOs[ZAxis][0][0]); | |
1145 | + | |
1146 | + | |
1147 | + // dipole moments of excited states | |
1148 | + //this->CalcElectronicDipoleMomentsExcitedStates(this->electronicTransitionDipoleMoments, | |
1149 | + // this->fockMatrix, | |
1150 | + // this->matrixCIS, | |
1151 | + // this->cartesianMatrix, | |
1152 | + // *this->molecule, | |
1153 | + // this->orbitalElectronPopulation, | |
1154 | + // this->overlapAOs); | |
1155 | + int groundState = 0; | |
1193 | 1156 | for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS(); k++){ |
1194 | - int departureExcitedState = k+1; // (k+1)-th excited state | |
1195 | - for(int l=k+1; l<Parameters::GetInstance()->GetNumberExcitedStatesCIS(); l++){ | |
1196 | - int destinationExcitedState = l+1; // (l+1)-th excited state | |
1197 | - this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][XAxis] = 0.0; | |
1198 | - this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][YAxis] = 0.0; | |
1199 | - this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][ZAxis] = 0.0; | |
1200 | - for(int l=0; l<this->matrixCISdimension; l++){ | |
1201 | - // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
1202 | - int moI = this->GetActiveOccIndex(*this->molecule, l); | |
1203 | - int moA = this->GetActiveVirIndex(*this->molecule, l); | |
1204 | - double temp = matrixCIS[departureExcitedState-1][l]*matrixCIS[destinationExcitedState-1][l]; | |
1205 | - this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][XAxis] += temp*(-dipoleMOs[XAxis][moI][moI]+dipoleMOs[XAxis][moA][moA]); | |
1206 | - this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][YAxis] += temp*(-dipoleMOs[YAxis][moI][moI]+dipoleMOs[YAxis][moA][moA]); | |
1207 | - this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][ZAxis] += temp*(-dipoleMOs[ZAxis][moI][moI]+dipoleMOs[ZAxis][moA][moA]); | |
1157 | + int excitedState = k+1; // (k+1)-th excited state | |
1158 | + if(excitedState%mpiSize != mpiRank){continue;} | |
1159 | + this->electronicTransitionDipoleMoments[excitedState][excitedState][XAxis] = this->electronicTransitionDipoleMoments[groundState][groundState][XAxis]; | |
1160 | + this->electronicTransitionDipoleMoments[excitedState][excitedState][YAxis] = this->electronicTransitionDipoleMoments[groundState][groundState][YAxis]; | |
1161 | + this->electronicTransitionDipoleMoments[excitedState][excitedState][ZAxis] = this->electronicTransitionDipoleMoments[groundState][groundState][ZAxis]; | |
1162 | + double tmpX=0.0, tmpY=0.0, tmpZ=0.0; | |
1163 | +#pragma omp parallel for reduction(+:tmpX,tmpY,tmpZ) schedule(auto) | |
1164 | + for(int l=0; l<this->matrixCISdimension; l++){ | |
1165 | + // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
1166 | + int moI = this->GetActiveOccIndex(*this->molecule, l); | |
1167 | + int moA = this->GetActiveVirIndex(*this->molecule, l); | |
1168 | + double temp = matrixCIS[k][l]*matrixCIS[k][l]; | |
1169 | + tmpX += temp*(-dipoleMOs[XAxis][moI][moI]+dipoleMOs[XAxis][moA][moA]); | |
1170 | + tmpY += temp*(-dipoleMOs[YAxis][moI][moI]+dipoleMOs[YAxis][moA][moA]); | |
1171 | + tmpZ += temp*(-dipoleMOs[ZAxis][moI][moI]+dipoleMOs[ZAxis][moA][moA]); | |
1172 | + } | |
1173 | + this->electronicTransitionDipoleMoments[excitedState][excitedState][XAxis] += tmpX; | |
1174 | + this->electronicTransitionDipoleMoments[excitedState][excitedState][YAxis] += tmpY; | |
1175 | + this->electronicTransitionDipoleMoments[excitedState][excitedState][ZAxis] += tmpZ; | |
1176 | + | |
1177 | + } | |
1178 | + | |
1179 | + // transition dipole moment | |
1180 | + //this->CalcElectronicTransitionDipoleMoments(this->electronicTransitionDipoleMoments, | |
1181 | + // this->fockMatrix, | |
1182 | + // this->matrixCIS, | |
1183 | + // this->cartesianMatrix, | |
1184 | + // *this->molecule, | |
1185 | + // this->orbitalElectronPopulation, | |
1186 | + // this->overlapAOs); | |
1187 | + for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS(); k++){ | |
1188 | + int excitedState = k+1; // (k+1)-th excited state | |
1189 | + if(excitedState%mpiSize != mpiRank){continue;} | |
1190 | + this->electronicTransitionDipoleMoments[excitedState][groundState][XAxis] = 0.0; | |
1191 | + this->electronicTransitionDipoleMoments[excitedState][groundState][YAxis] = 0.0; | |
1192 | + this->electronicTransitionDipoleMoments[excitedState][groundState][ZAxis] = 0.0; | |
1193 | + double tmpX=0.0, tmpY=0.0, tmpZ=0.0; | |
1194 | +#pragma omp parallel for reduction(+:tmpX,tmpY,tmpZ) schedule(auto) | |
1195 | + for(int l=0; l<this->matrixCISdimension; l++){ | |
1196 | + // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
1197 | + int moI = this->GetActiveOccIndex(*this->molecule, l); | |
1198 | + int moA = this->GetActiveVirIndex(*this->molecule, l); | |
1199 | + //double temp = matrixCIS[k][l]*matrixCIS[k][l]; | |
1200 | + double tmp = this->matrixCIS[k][l]*sqrt(2.0); | |
1201 | + tmpX += tmp*dipoleMOs[XAxis][moA][moI]; | |
1202 | + tmpY += tmp*dipoleMOs[YAxis][moA][moI]; | |
1203 | + tmpZ += tmp*dipoleMOs[ZAxis][moA][moI]; | |
1204 | + } | |
1205 | + this->electronicTransitionDipoleMoments[excitedState][groundState][XAxis] += tmpX; | |
1206 | + this->electronicTransitionDipoleMoments[excitedState][groundState][YAxis] += tmpY; | |
1207 | + this->electronicTransitionDipoleMoments[excitedState][groundState][ZAxis] += tmpZ; | |
1208 | + } | |
1209 | + if(Parameters::GetInstance()->RequiresAllTransitionDipoleMomentsCIS()){ | |
1210 | + for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS(); k++){ | |
1211 | + int departureExcitedState = k+1; // (k+1)-th excited state | |
1212 | + for(int l=k+1; l<Parameters::GetInstance()->GetNumberExcitedStatesCIS(); l++){ | |
1213 | + int destinationExcitedState = l+1; // (l+1)-th excited state | |
1214 | + if(destinationExcitedState%mpiSize != mpiRank){continue;} | |
1215 | + this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][XAxis] = 0.0; | |
1216 | + this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][YAxis] = 0.0; | |
1217 | + this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][ZAxis] = 0.0; | |
1218 | + double tmpX=0.0, tmpY=0.0, tmpZ=0.0; | |
1219 | +#pragma omp parallel for reduction(+:tmpX,tmpY,tmpZ) schedule(auto) | |
1220 | + for(int l=0; l<this->matrixCISdimension; l++){ | |
1221 | + // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
1222 | + int moI = this->GetActiveOccIndex(*this->molecule, l); | |
1223 | + int moA = this->GetActiveVirIndex(*this->molecule, l); | |
1224 | + double tmp = matrixCIS[departureExcitedState-1][l]*matrixCIS[destinationExcitedState-1][l]; | |
1225 | + tmpX += tmp*(-dipoleMOs[XAxis][moI][moI]+dipoleMOs[XAxis][moA][moA]); | |
1226 | + tmpY += tmp*(-dipoleMOs[YAxis][moI][moI]+dipoleMOs[YAxis][moA][moA]); | |
1227 | + tmpZ += tmp*(-dipoleMOs[ZAxis][moI][moI]+dipoleMOs[ZAxis][moA][moA]); | |
1228 | + } | |
1229 | + this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][XAxis] += tmpX; | |
1230 | + this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][YAxis] += tmpY; | |
1231 | + this->electronicTransitionDipoleMoments[destinationExcitedState][departureExcitedState][ZAxis] += tmpZ; | |
1208 | 1232 | } |
1209 | 1233 | } |
1210 | 1234 | } |
1235 | + } | |
1236 | + catch(MolDSException ex){ | |
1237 | + MallocerFreer::GetInstance()->Free<double>(&dipoleMOs, CartesianType_end, totalNumberAOs, totalNumberAOs); | |
1238 | + MallocerFreer::GetInstance()->Free<double>(&overlapMOs, totalNumberAOs, totalNumberAOs); | |
1239 | + throw ex; | |
1240 | + } | |
1241 | + MallocerFreer::GetInstance()->Free<double>(&dipoleMOs, CartesianType_end, totalNumberAOs, totalNumberAOs); | |
1242 | + MallocerFreer::GetInstance()->Free<double>(&overlapMOs, totalNumberAOs, totalNumberAOs); | |
1211 | 1243 | |
1244 | + // communication to collect all matrix data on rank 0 | |
1245 | + int numTransported = (Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1)*CartesianType_end; | |
1246 | + if(mpiRank == 0){ | |
1247 | + // receive the matrix data from other ranks | |
1248 | + for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; k++){ | |
1249 | + if(k%mpiSize == 0){continue;} | |
1250 | + int source = k%mpiSize; | |
1251 | + int tag = k; | |
1252 | + MolDS_mpi::MpiProcess::GetInstance()->Recv(source, tag, &this->electronicTransitionDipoleMoments[k][0][0], numTransported); | |
1253 | + } | |
1254 | + } | |
1255 | + else{ | |
1256 | + // send the matrix data to rank-0 | |
1257 | + for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; k++){ | |
1258 | + if(k%mpiSize != mpiRank){continue;} | |
1259 | + int dest = 0; | |
1260 | + int tag = k; | |
1261 | + MolDS_mpi::MpiProcess::GetInstance()->Send(dest, tag, &this->electronicTransitionDipoleMoments[k][0][0], numTransported); | |
1262 | + } | |
1263 | + } | |
1264 | + | |
1265 | + // right upper part of the matrix is copied from left lower part. | |
1266 | + if(mpiRank == 0 && Parameters::GetInstance()->RequiresAllTransitionDipoleMomentsCIS()){ | |
1212 | 1267 | for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; k++){ |
1213 | 1268 | for(int l=k+1; l<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; l++){ |
1214 | 1269 | for(int axis=0; axis<CartesianType_end; axis++){ |
@@ -1218,8 +1273,13 @@ void ZindoS::CalcCISProperties(){ | ||
1218 | 1273 | } |
1219 | 1274 | } |
1220 | 1275 | } |
1221 | - MallocerFreer::GetInstance()->Free<double>(&dipoleMOs, CartesianType_end, totalNumberAOs, totalNumberAOs); | |
1222 | - MallocerFreer::GetInstance()->Free<double>(&overlapMOs, totalNumberAOs, totalNumberAOs); | |
1276 | + | |
1277 | + // broadcast all matrix data to all ranks | |
1278 | + numTransported *= (Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1); | |
1279 | + int root=0; | |
1280 | + MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&this->electronicTransitionDipoleMoments[0][0][0], numTransported, root); | |
1281 | + | |
1282 | + | |
1223 | 1283 | }// end of "calculate dipole moments and transitiondipolemoment" |
1224 | 1284 | |
1225 | 1285 |
@@ -2277,16 +2337,19 @@ void ZindoS::DoCISDirect(){ | ||
2277 | 2337 | void ZindoS::CalcCISMatrix(double** matrixCIS) const{ |
2278 | 2338 | this->OutputLog(this->messageStartCalcCISMatrix); |
2279 | 2339 | double ompStartTime = omp_get_wtime(); |
2340 | + int mpiRank = MolDS_mpi::MpiProcess::GetInstance()->GetRank(); | |
2341 | + int mpiSize = MolDS_mpi::MpiProcess::GetInstance()->GetSize(); | |
2280 | 2342 | |
2281 | - stringstream ompErrors; | |
2282 | -#pragma omp parallel for schedule(auto) | |
2283 | 2343 | for(int k=0; k<this->matrixCISdimension; k++){ |
2284 | - try{ | |
2285 | - // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
2286 | - int moI = this->GetActiveOccIndex(*this->molecule, k); | |
2287 | - int moA = this->GetActiveVirIndex(*this->molecule, k); | |
2344 | + if(k%mpiSize != mpiRank){continue;} | |
2288 | 2345 | |
2289 | - for(int l=k; l<this->matrixCISdimension; l++){ | |
2346 | + // single excitation from I-th (occupied)MO to A-th (virtual)MO | |
2347 | + int moI = this->GetActiveOccIndex(*this->molecule, k); | |
2348 | + int moA = this->GetActiveVirIndex(*this->molecule, k); | |
2349 | + stringstream ompErrors; | |
2350 | +#pragma omp parallel for schedule(auto) | |
2351 | + for(int l=k; l<this->matrixCISdimension; l++){ | |
2352 | + try{ | |
2290 | 2353 | // single excitation from J-th (occupied)MO to B-th (virtual)MO |
2291 | 2354 | int moJ = this->GetActiveOccIndex(*this->molecule, l); |
2292 | 2355 | int moB = this->GetActiveVirIndex(*this->molecule, l); |
@@ -2318,16 +2381,42 @@ void ZindoS::CalcCISMatrix(double** matrixCIS) const{ | ||
2318 | 2381 | matrixCIS[k][l] = value; |
2319 | 2382 | // End of the slow algorith. */ |
2320 | 2383 | } |
2321 | - } | |
2322 | - catch(MolDSException ex){ | |
2384 | + catch(MolDSException ex){ | |
2323 | 2385 | #pragma omp critical |
2324 | - ompErrors << ex.what() << endl ; | |
2386 | + ompErrors << ex.what() << endl ; | |
2387 | + } | |
2388 | + } // end of l-loop | |
2389 | + // Exception throwing for omp-region | |
2390 | + if(!ompErrors.str().empty()){ | |
2391 | + throw MolDSException(ompErrors.str()); | |
2325 | 2392 | } |
2326 | 2393 | } // end of k-loop |
2327 | - // Exception throwing for omp-region | |
2328 | - if(!ompErrors.str().empty()){ | |
2329 | - throw MolDSException(ompErrors.str()); | |
2394 | + | |
2395 | + | |
2396 | + // communication to collect all matrix data on rank 0 | |
2397 | + if(mpiRank == 0){ | |
2398 | + // receive the matrix data from other ranks | |
2399 | + for(int k=0; k<this->matrixCISdimension; k++){ | |
2400 | + if(k%mpiSize == 0){continue;} | |
2401 | + int source = k%mpiSize; | |
2402 | + int tag = k; | |
2403 | + MolDS_mpi::MpiProcess::GetInstance()->Recv(source, tag, matrixCIS[k], this->matrixCISdimension); | |
2404 | + } | |
2405 | + } | |
2406 | + else{ | |
2407 | + // send the matrix data to rank-0 | |
2408 | + for(int k=0; k<this->matrixCISdimension; k++){ | |
2409 | + if(k%mpiSize != mpiRank){continue;} | |
2410 | + int dest = 0; | |
2411 | + int tag = k; | |
2412 | + MolDS_mpi::MpiProcess::GetInstance()->Send(dest, tag, matrixCIS[k], this->matrixCISdimension); | |
2413 | + } | |
2330 | 2414 | } |
2415 | + | |
2416 | + // broadcast all matrix data to all rank | |
2417 | + int root=0; | |
2418 | + MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&matrixCIS[0][0], this->matrixCISdimension*this->matrixCISdimension, root); | |
2419 | + | |
2331 | 2420 | double ompEndTime = omp_get_wtime(); |
2332 | 2421 | this->OutputLog(boost::format("%s%lf%s\n%s") % this->messageOmpElapsedTimeCalcCISMarix.c_str() |
2333 | 2422 | % (ompEndTime - ompStartTime) |