• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision95da8903d2aa702d9d6f2034a873b462b5eb33c3 (tree)
l'heure2013-07-12 20:23:58
AuteurMikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Message de Log

Merge mpi-cis into trunk. #31588

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1394 1136aad2-a195-0410-b898-f5ea1d11b9d8

Change Summary

Modification

--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -23,6 +23,8 @@
2323 #include<stdexcept>
2424 #include<boost/shared_ptr.hpp>
2525 #include<boost/format.hpp>
26+#include"base/Uncopyable.h"
27+#include"mpi/MpiProcess.h"
2628 #include"base/PrintController.h"
2729 #include"base/MolDSException.h"
2830 #include"base/Enums.h"
@@ -31,10 +33,13 @@
3133 #include"base/Molecule.h"
3234 #include"base/MolDS.h"
3335 using namespace std;
36+using namespace MolDS_base;
3437 int main(int argc, char *argv[]){
3538 try{
39+ MolDS_mpi::MpiProcess::CreateInstance(argc, argv);
3640 boost::shared_ptr<MolDS_base::MolDS> molds(new MolDS_base::MolDS());
3741 molds->Run(argc, argv);
42+ MolDS_mpi::MpiProcess::DeleteInstance();
3843 }
3944 catch(exception ex){
4045 cout << ex.what();
--- a/src/Makefile
+++ b/src/Makefile
@@ -17,10 +17,7 @@
1717 #// You should have received a copy of the GNU General Public License //
1818 #// along with MolDS. If not, see <http://www.gnu.org/licenses/>. //
1919 #//************************************************************************//
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
2421 CFLAGS = -O0
2522 override CFLAGS += -openmp -openmp-report2 -DMKL_INT=intptr_t
2623 ifeq ($(INTEL), 64)
@@ -28,20 +25,24 @@ override CFLAGS += -DMKL_ILP64
2825 endif
2926 BOOST_TOP_DIR = /usr/local/boost/
3027 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
3136 EXENAME = MolDS.out
3237 DEPFILE = obj/objfile.dep
3338 LDFLAGS =
3439
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
3843
3944 $(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)
4546
4647 -include $(DEPFILE)
4748
--- a/src/Makefile_GNU
+++ b/src/Makefile_GNU
@@ -17,26 +17,29 @@
1717 #// You should have received a copy of the GNU General Public License //
1818 #// along with MolDS. If not, see <http://www.gnu.org/licenses/>. //
1919 #//************************************************************************//
20-CC = g++
21-LIBS = -lpthread
20+CC = mpicxx
2221 CFLAGS = -O0
2322 override CFLAGS += -fopenmp
2423 BOOST_TOP_DIR = /usr/local/boost/
2524 BOOST_INC_DIR = $(BOOST_TOP_DIR)include/
25+BOOST_LIB_DIR = $(BOOST_TOP_DIR)lib/
26+BOOST_LIBS = -lboost_mpi
2627 OPENBLAS_TOP_DIR = /usr/local/openblas/
2728 OPENBLAS_INC_DIR = $(OPENBLAS_TOP_DIR)include/
2829 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)
3033 EXENAME = MolDS.out
3134 DEPFILE = obj/objfile.dep
3235 LDFLAGS =
3336
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
3740
3841 $(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)
4043
4144 -include $(DEPFILE)
4245
--- a/src/am1/Am1.cpp
+++ b/src/am1/Am1.cpp
@@ -24,9 +24,10 @@
2424 #include<string>
2525 #include<vector>
2626 #include<boost/format.hpp>
27+#include"../base/Uncopyable.h"
28+#include"../mpi/MpiProcess.h"
2729 #include"../base/PrintController.h"
2830 #include"../base/MolDSException.h"
29-#include"../base/Uncopyable.h"
3031 #include"../base/Enums.h"
3132 #include"../base/EularAngle.h"
3233 #include"../base/Parameters.h"
--- a/src/am1/Am1D.cpp
+++ b/src/am1/Am1D.cpp
@@ -24,9 +24,10 @@
2424 #include<string>
2525 #include<vector>
2626 #include<boost/format.hpp>
27+#include"../base/Uncopyable.h"
28+#include"../mpi/MpiProcess.h"
2729 #include"../base/PrintController.h"
2830 #include"../base/MolDSException.h"
29-#include"../base/Uncopyable.h"
3031 #include"../base/Enums.h"
3132 #include"../base/EularAngle.h"
3233 #include"../base/Parameters.h"
--- a/src/base/InputParser.cpp
+++ b/src/base/InputParser.cpp
@@ -28,9 +28,10 @@
2828 #include<vector>
2929 #include<stdexcept>
3030 #include<boost/format.hpp>
31+#include"Uncopyable.h"
32+#include"../mpi/MpiProcess.h"
3133 #include"PrintController.h"
3234 #include"MolDSException.h"
33-#include"Uncopyable.h"
3435 #include"Utilities.h"
3536 #include"Enums.h"
3637 #include"EularAngle.h"
--- a/src/base/MallocerFreer.cpp
+++ b/src/base/MallocerFreer.cpp
@@ -25,9 +25,10 @@
2525 #include<vector>
2626 #include<stdexcept>
2727 #include<boost/format.hpp>
28+#include"Uncopyable.h"
29+#include"../mpi/MpiProcess.h"
2830 #include"PrintController.h"
2931 #include"MolDSException.h"
30-#include"Uncopyable.h"
3132 #include"Enums.h"
3233 #include"MallocerFreer.h"
3334 #include"EularAngle.h"
--- a/src/base/MathUtilities.cpp
+++ b/src/base/MathUtilities.cpp
@@ -24,9 +24,10 @@
2424 #include<stdexcept>
2525 #include<boost/format.hpp>
2626 #include<boost/math/special_functions/factorials.hpp>
27+#include"Uncopyable.h"
28+#include"../mpi/MpiProcess.h"
2729 #include"PrintController.h"
2830 #include"MolDSException.h"
29-#include"Uncopyable.h"
3031 #include"../wrappers/Lapack.h"
3132 #include"Enums.h"
3233 #include"MathUtilities.h"
--- a/src/base/MolDS.cpp
+++ b/src/base/MolDS.cpp
@@ -29,9 +29,10 @@
2929 #include<omp.h>
3030 #include<boost/shared_ptr.hpp>
3131 #include<boost/random.hpp>
32+#include"Uncopyable.h"
33+#include"../mpi/MpiProcess.h"
3234 #include"PrintController.h"
3335 #include"MolDSException.h"
34-#include"Uncopyable.h"
3536 #include"../wrappers/Blas.h"
3637 #include"../wrappers/Lapack.h"
3738 #include"Utilities.h"
--- a/src/base/Molecule.cpp
+++ b/src/base/Molecule.cpp
@@ -25,9 +25,10 @@
2525 #include<vector>
2626 #include<stdexcept>
2727 #include<boost/format.hpp>
28+#include"Uncopyable.h"
29+#include"../mpi/MpiProcess.h"
2830 #include"PrintController.h"
2931 #include"MolDSException.h"
30-#include"Uncopyable.h"
3132 #include"../wrappers/Lapack.h"
3233 #include"Enums.h"
3334 #include"MathUtilities.h"
--- a/src/base/Parameters.cpp
+++ b/src/base/Parameters.cpp
@@ -27,9 +27,10 @@
2727 #include<vector>
2828 #include<stdexcept>
2929 #include<boost/format.hpp>
30+#include"Uncopyable.h"
31+#include"../mpi/MpiProcess.h"
3032 #include"PrintController.h"
3133 #include"MolDSException.h"
32-#include"Uncopyable.h"
3334 #include"Enums.h"
3435 #include"MallocerFreer.h"
3536 #include"EularAngle.h"
--- a/src/base/Parameters.h
+++ b/src/base/Parameters.h
@@ -289,7 +289,7 @@ private:
289289 std::vector<int>* electronicStateIndecesMullikenCIS;
290290 bool requiresUnpairedPopCIS;
291291 // Memory
292- double limitHeapMemory;
292+ double limitHeapMemory; // in [MB]
293293 // MD
294294 int electronicStateIndexMD;
295295 int totalStepsMD;
--- a/src/base/PrintController.h
+++ b/src/base/PrintController.h
@@ -42,6 +42,9 @@ protected:
4242 }
4343 void OutputLog(std::string log) const{
4444 if(this->canOutputLogs){
45+#ifndef MOLDS_DBG
46+ if(MolDS_mpi::MpiProcess::GetInstance()->GetRank()!=0){return;}
47+#endif
4548 bool endl = false;
4649 std::string::reverse_iterator iter;
4750 for(iter = log.rbegin(); iter != log.rend(); iter++){
--- a/src/base/Utilities.cpp
+++ b/src/base/Utilities.cpp
@@ -25,6 +25,8 @@
2525 #include<time.h>
2626 #include<omp.h>
2727 #include<boost/format.hpp>
28+#include"Uncopyable.h"
29+#include"../mpi/MpiProcess.h"
2830 #include"PrintController.h"
2931 #include"Utilities.h"
3032 using namespace std;
--- a/src/base/atoms/Atom.cpp
+++ b/src/base/atoms/Atom.cpp
@@ -26,9 +26,10 @@
2626 #include<vector>
2727 #include<stdexcept>
2828 #include<boost/format.hpp>
29+#include"../Uncopyable.h"
30+#include"../../mpi/MpiProcess.h"
2931 #include"../PrintController.h"
3032 #include"../MolDSException.h"
31-#include"../Uncopyable.h"
3233 #include"../Enums.h"
3334 #include"../MathUtilities.h"
3435 #include"../MallocerFreer.h"
--- a/src/base/atoms/Catom.cpp
+++ b/src/base/atoms/Catom.cpp
@@ -23,8 +23,9 @@
2323 #include<math.h>
2424 #include<vector>
2525 #include<boost/format.hpp>
26-#include"../PrintController.h"
2726 #include"../Uncopyable.h"
27+#include"../../mpi/MpiProcess.h"
28+#include"../PrintController.h"
2829 #include"../Enums.h"
2930 #include"../EularAngle.h"
3031 #include"../Parameters.h"
--- a/src/base/atoms/Hatom.cpp
+++ b/src/base/atoms/Hatom.cpp
@@ -23,8 +23,9 @@
2323 #include<math.h>
2424 #include<vector>
2525 #include<boost/format.hpp>
26-#include"../PrintController.h"
2726 #include"../Uncopyable.h"
27+#include"../../mpi/MpiProcess.h"
28+#include"../PrintController.h"
2829 #include"../Enums.h"
2930 #include"../EularAngle.h"
3031 #include"../Parameters.h"
--- a/src/base/atoms/Liatom.cpp
+++ b/src/base/atoms/Liatom.cpp
@@ -23,8 +23,9 @@
2323 #include<math.h>
2424 #include<vector>
2525 #include<boost/format.hpp>
26-#include"../PrintController.h"
2726 #include"../Uncopyable.h"
27+#include"../../mpi/MpiProcess.h"
28+#include"../PrintController.h"
2829 #include"../Enums.h"
2930 #include"../EularAngle.h"
3031 #include"../Parameters.h"
--- a/src/base/atoms/Natom.cpp
+++ b/src/base/atoms/Natom.cpp
@@ -23,8 +23,9 @@
2323 #include<math.h>
2424 #include<vector>
2525 #include<boost/format.hpp>
26-#include"../PrintController.h"
2726 #include"../Uncopyable.h"
27+#include"../../mpi/MpiProcess.h"
28+#include"../PrintController.h"
2829 #include"../Enums.h"
2930 #include"../EularAngle.h"
3031 #include"../Parameters.h"
--- a/src/base/atoms/Oatom.cpp
+++ b/src/base/atoms/Oatom.cpp
@@ -23,8 +23,9 @@
2323 #include<math.h>
2424 #include<vector>
2525 #include<boost/format.hpp>
26-#include"../PrintController.h"
2726 #include"../Uncopyable.h"
27+#include"../../mpi/MpiProcess.h"
28+#include"../PrintController.h"
2829 #include"../Enums.h"
2930 #include"../EularAngle.h"
3031 #include"../Parameters.h"
--- a/src/base/atoms/Satom.cpp
+++ b/src/base/atoms/Satom.cpp
@@ -23,8 +23,9 @@
2323 #include<math.h>
2424 #include<vector>
2525 #include<boost/format.hpp>
26-#include"../PrintController.h"
2726 #include"../Uncopyable.h"
27+#include"../../mpi/MpiProcess.h"
28+#include"../PrintController.h"
2829 #include"../Enums.h"
2930 #include"../EularAngle.h"
3031 #include"../Parameters.h"
--- a/src/base/factories/AtomFactory.cpp
+++ b/src/base/factories/AtomFactory.cpp
@@ -23,9 +23,10 @@
2323 #include<vector>
2424 #include<stdexcept>
2525 #include<boost/format.hpp>
26+#include"../Uncopyable.h"
27+#include"../../mpi/MpiProcess.h"
2628 #include"../PrintController.h"
2729 #include"../MolDSException.h"
28-#include"../Uncopyable.h"
2930 #include"../Enums.h"
3031 #include"../atoms/Atom.h"
3132 #include"../atoms/Hatom.h"
--- a/src/base/factories/ElectronicStructureFactory.cpp
+++ b/src/base/factories/ElectronicStructureFactory.cpp
@@ -24,9 +24,10 @@
2424 #include<vector>
2525 #include<stdexcept>
2626 #include<boost/format.hpp>
27+#include"../Uncopyable.h"
28+#include"../../mpi/MpiProcess.h"
2729 #include"../PrintController.h"
2830 #include"../MolDSException.h"
29-#include"../Uncopyable.h"
3031 #include"../Enums.h"
3132 #include"../MallocerFreer.h"
3233 #include"../EularAngle.h"
--- a/src/base/factories/OptimizerFactory.cpp
+++ b/src/base/factories/OptimizerFactory.cpp
@@ -25,9 +25,10 @@
2525 #include<stdexcept>
2626 #include<boost/shared_ptr.hpp>
2727 #include<boost/format.hpp>
28+#include"../Uncopyable.h"
29+#include"../../mpi/MpiProcess.h"
2830 #include"../PrintController.h"
2931 #include"../MolDSException.h"
30-#include"../Uncopyable.h"
3132 #include"../Enums.h"
3233 #include"../MallocerFreer.h"
3334 #include"../EularAngle.h"
--- a/src/base/loggers/DensityLogger.cpp
+++ b/src/base/loggers/DensityLogger.cpp
@@ -28,9 +28,10 @@
2828 #include<stdexcept>
2929 #include<omp.h>
3030 #include<boost/format.hpp>
31+#include"../Uncopyable.h"
32+#include"../../mpi/MpiProcess.h"
3133 #include"../PrintController.h"
3234 #include"../MolDSException.h"
33-#include"../Uncopyable.h"
3435 #include"../Utilities.h"
3536 #include"../Enums.h"
3637 #include"../MallocerFreer.h"
--- a/src/base/loggers/HoleDensityLogger.cpp
+++ b/src/base/loggers/HoleDensityLogger.cpp
@@ -28,9 +28,10 @@
2828 #include<stdexcept>
2929 #include<omp.h>
3030 #include<boost/format.hpp>
31+#include"../Uncopyable.h"
32+#include"../../mpi/MpiProcess.h"
3133 #include"../PrintController.h"
3234 #include"../MolDSException.h"
33-#include"../Uncopyable.h"
3435 #include"../Utilities.h"
3536 #include"../Enums.h"
3637 #include"../EularAngle.h"
--- a/src/base/loggers/MOLogger.cpp
+++ b/src/base/loggers/MOLogger.cpp
@@ -28,9 +28,10 @@
2828 #include<stdexcept>
2929 #include<omp.h>
3030 #include<boost/format.hpp>
31+#include"../Uncopyable.h"
32+#include"../../mpi/MpiProcess.h"
3133 #include"../PrintController.h"
3234 #include"../MolDSException.h"
33-#include"../Uncopyable.h"
3435 #include"../Utilities.h"
3536 #include"../Enums.h"
3637 #include"../EularAngle.h"
--- a/src/base/loggers/ParticleDensityLogger.cpp
+++ b/src/base/loggers/ParticleDensityLogger.cpp
@@ -28,9 +28,10 @@
2828 #include<stdexcept>
2929 #include<omp.h>
3030 #include<boost/format.hpp>
31+#include"../Uncopyable.h"
32+#include"../../mpi/MpiProcess.h"
3133 #include"../PrintController.h"
3234 #include"../MolDSException.h"
33-#include"../Uncopyable.h"
3435 #include"../Utilities.h"
3536 #include"../Enums.h"
3637 #include"../EularAngle.h"
--- a/src/cndo/Cndo2.cpp
+++ b/src/cndo/Cndo2.cpp
@@ -28,9 +28,10 @@
2828 #include<stdexcept>
2929 #include<omp.h>
3030 #include<boost/format.hpp>
31+#include"../base/Uncopyable.h"
32+#include"../mpi/MpiProcess.h"
3133 #include"../base/PrintController.h"
3234 #include"../base/MolDSException.h"
33-#include"../base/Uncopyable.h"
3435 #include"../wrappers/Blas.h"
3536 #include"../wrappers/Lapack.h"
3637 #include"../base/Enums.h"
--- a/src/indo/Indo.cpp
+++ b/src/indo/Indo.cpp
@@ -25,9 +25,10 @@
2525 #include<vector>
2626 #include<stdexcept>
2727 #include<boost/format.hpp>
28+#include"../base/Uncopyable.h"
29+#include"../mpi/MpiProcess.h"
2830 #include"../base/PrintController.h"
2931 #include"../base/MolDSException.h"
30-#include"../base/Uncopyable.h"
3132 #include"../base/EularAngle.h"
3233 #include"../base/Enums.h"
3334 #include"../base/atoms/Atom.h"
--- a/src/mc/MC.cpp
+++ b/src/mc/MC.cpp
@@ -27,9 +27,10 @@
2727 #include<boost/shared_ptr.hpp>
2828 #include<boost/random.hpp>
2929 #include<boost/format.hpp>
30+#include"../base/Uncopyable.h"
31+#include"../mpi/MpiProcess.h"
3032 #include"../base/PrintController.h"
3133 #include"../base/MolDSException.h"
32-#include"../base/Uncopyable.h"
3334 #include"../base/Enums.h"
3435 #include"../base/EularAngle.h"
3536 #include"../base/Parameters.h"
--- a/src/md/MD.cpp
+++ b/src/md/MD.cpp
@@ -26,9 +26,10 @@
2626 #include<stdexcept>
2727 #include<boost/shared_ptr.hpp>
2828 #include<boost/format.hpp>
29+#include"../base/Uncopyable.h"
30+#include"../mpi/MpiProcess.h"
2931 #include"../base/PrintController.h"
3032 #include"../base/MolDSException.h"
31-#include"../base/Uncopyable.h"
3233 #include"../base/Enums.h"
3334 #include"../base/EularAngle.h"
3435 #include"../base/Parameters.h"
--- a/src/mndo/Mndo.cpp
+++ b/src/mndo/Mndo.cpp
@@ -26,9 +26,10 @@
2626 #include<stdexcept>
2727 #include<omp.h>
2828 #include<boost/format.hpp>
29+#include"../base/Uncopyable.h"
30+#include"../mpi/MpiProcess.h"
2931 #include"../base/PrintController.h"
3032 #include"../base/MolDSException.h"
31-#include"../base/Uncopyable.h"
3233 #include"../wrappers/Blas.h"
3334 #include"../wrappers/Lapack.h"
3435 #include"../base/Enums.h"
@@ -728,21 +729,24 @@ double Mndo::GetMolecularIntegralElement(int moI, int moJ, int moK, int moL,
728729 void Mndo::CalcCISMatrix(double** matrixCIS) const{
729730 this->OutputLog(this->messageStartCalcCISMatrix);
730731 double ompStartTime = omp_get_wtime();
732+ int mpiRank = MolDS_mpi::MpiProcess::GetInstance()->GetRank();
733+ int mpiSize = MolDS_mpi::MpiProcess::GetInstance()->GetSize();
731734
732- stringstream ompErrors;
733-#pragma omp parallel for schedule(auto)
734735 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;}
739737
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{
741745 // single excitation from J-th (occupied)MO to B-th (virtual)MO
742746 int moJ = this->GetActiveOccIndex(*this->molecule, l);
743747 int moB = this->GetActiveVirIndex(*this->molecule, l);
744748 double value=0.0;
745-
749+
746750 // Fast algorith, but this is not easy to read.
747751 // Slow algorithm is alos written below.
748752 for(int A=0; A<molecule->GetNumberAtoms(); A++){
@@ -862,13 +866,13 @@ void Mndo::CalcCISMatrix(double** matrixCIS) const{
862866 }
863867 }
864868 // End of the fast algorith.
865-
869+
866870 /*
867871 // Slow algorith, but this is easy to read. Fast altorithm is also written above.
868872 value = 2.0*this->GetMolecularIntegralElement(moA, moI, moJ, moB,
869- this->molecule, this->fockMatrix, NULL)
873+ *this->molecule, this->fockMatrix, NULL)
870874 -this->GetMolecularIntegralElement(moA, moB, moI, moJ,
871- this->molecule, this->fockMatrix, NULL);
875+ *this->molecule, this->fockMatrix, NULL);
872876 // End of the slow algorith.
873877 */
874878 // Diagonal term
@@ -876,17 +880,42 @@ void Mndo::CalcCISMatrix(double** matrixCIS) const{
876880 value += this->energiesMO[moA] - this->energiesMO[moI];
877881 }
878882 matrixCIS[k][l] = value;
883+ }
884+ catch(MolDSException ex){
885+#pragma omp critical
886+ ompErrors << ex.what() << endl ;
879887 }
888+ }// end of l-loop
889+ // Exception throwing for omp-region
890+ if(!ompErrors.str().empty()){
891+ throw MolDSException(ompErrors.str());
880892 }
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);
884903 }
885904 }
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+ }
889913 }
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+
890919 double ompEndTime = omp_get_wtime();
891920 this->OutputLog(boost::format("%s%lf%s\n%s") % this->messageOmpElapsedTimeCalcCISMarix.c_str()
892921 % (ompEndTime - ompStartTime)
--- /dev/null
+++ b/src/mpi/MpiProcess.cpp
@@ -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+
--- /dev/null
+++ b/src/mpi/MpiProcess.h
@@ -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+
--- a/src/nasco/NASCO.cpp
+++ b/src/nasco/NASCO.cpp
@@ -27,9 +27,10 @@
2727 #include<boost/shared_ptr.hpp>
2828 #include<boost/random.hpp>
2929 #include<boost/format.hpp>
30+#include"../base/Uncopyable.h"
31+#include"../mpi/MpiProcess.h"
3032 #include"../base/PrintController.h"
3133 #include"../base/MolDSException.h"
32-#include"../base/Uncopyable.h"
3334 #include"../base/Enums.h"
3435 #include"../base/MallocerFreer.h"
3536 #include"../base/EularAngle.h"
--- a/src/optimization/BFGS.cpp
+++ b/src/optimization/BFGS.cpp
@@ -28,9 +28,10 @@
2828 #include<stdexcept>
2929 #include<boost/shared_ptr.hpp>
3030 #include<boost/format.hpp>
31+#include"../base/Uncopyable.h"
32+#include"../mpi/MpiProcess.h"
3133 #include"../base/PrintController.h"
3234 #include"../base/MolDSException.h"
33-#include"../base/Uncopyable.h"
3435 #include"../wrappers/Blas.h"
3536 #include"../wrappers/Lapack.h"
3637 #include"../base/Enums.h"
--- a/src/optimization/ConjugateGradient.cpp
+++ b/src/optimization/ConjugateGradient.cpp
@@ -27,9 +27,10 @@
2727 #include<stdexcept>
2828 #include<boost/shared_ptr.hpp>
2929 #include<boost/format.hpp>
30+#include"../base/Uncopyable.h"
31+#include"../mpi/MpiProcess.h"
3032 #include"../base/PrintController.h"
3133 #include"../base/MolDSException.h"
32-#include"../base/Uncopyable.h"
3334 #include"../base/Enums.h"
3435 #include"../base/MallocerFreer.h"
3536 #include"../base/EularAngle.h"
--- a/src/optimization/Optimizer.cpp
+++ b/src/optimization/Optimizer.cpp
@@ -27,9 +27,10 @@
2727 #include<stdexcept>
2828 #include<boost/shared_ptr.hpp>
2929 #include<boost/format.hpp>
30+#include"../base/Uncopyable.h"
31+#include"../mpi/MpiProcess.h"
3032 #include"../base/PrintController.h"
3133 #include"../base/MolDSException.h"
32-#include"../base/Uncopyable.h"
3334 #include"../base/Enums.h"
3435 #include"../base/EularAngle.h"
3536 #include"../base/Parameters.h"
--- a/src/optimization/SteepestDescent.cpp
+++ b/src/optimization/SteepestDescent.cpp
@@ -27,9 +27,10 @@
2727 #include<stdexcept>
2828 #include<boost/shared_ptr.hpp>
2929 #include<boost/format.hpp>
30+#include"../base/Uncopyable.h"
31+#include"../mpi/MpiProcess.h"
3032 #include"../base/PrintController.h"
3133 #include"../base/MolDSException.h"
32-#include"../base/Uncopyable.h"
3334 #include"../base/Enums.h"
3435 #include"../base/EularAngle.h"
3536 #include"../base/Parameters.h"
--- a/src/pm3/Pm3.cpp
+++ b/src/pm3/Pm3.cpp
@@ -24,9 +24,10 @@
2424 #include<string>
2525 #include<vector>
2626 #include<boost/format.hpp>
27+#include"../base/Uncopyable.h"
28+#include"../mpi/MpiProcess.h"
2729 #include"../base/PrintController.h"
2830 #include"../base/MolDSException.h"
29-#include"../base/Uncopyable.h"
3031 #include"../base/Enums.h"
3132 #include"../base/EularAngle.h"
3233 #include"../base/Parameters.h"
--- a/src/pm3/Pm3D.cpp
+++ b/src/pm3/Pm3D.cpp
@@ -24,9 +24,10 @@
2424 #include<string>
2525 #include<vector>
2626 #include<boost/format.hpp>
27+#include"../base/Uncopyable.h"
28+#include"../mpi/MpiProcess.h"
2729 #include"../base/PrintController.h"
2830 #include"../base/MolDSException.h"
29-#include"../base/Uncopyable.h"
3031 #include"../base/Enums.h"
3132 #include"../base/EularAngle.h"
3233 #include"../base/Parameters.h"
--- a/src/pm3/Pm3Pddg.cpp
+++ b/src/pm3/Pm3Pddg.cpp
@@ -24,9 +24,10 @@
2424 #include<string>
2525 #include<vector>
2626 #include<boost/format.hpp>
27+#include"../base/Uncopyable.h"
28+#include"../mpi/MpiProcess.h"
2729 #include"../base/PrintController.h"
2830 #include"../base/MolDSException.h"
29-#include"../base/Uncopyable.h"
3031 #include"../base/Enums.h"
3132 #include"../base/EularAngle.h"
3233 #include"../base/Parameters.h"
--- a/src/rpmd/RPMD.cpp
+++ b/src/rpmd/RPMD.cpp
@@ -27,9 +27,10 @@
2727 #include<boost/shared_ptr.hpp>
2828 #include<boost/random.hpp>
2929 #include<boost/format.hpp>
30+#include"../base/Uncopyable.h"
31+#include"../mpi/MpiProcess.h"
3032 #include"../base/PrintController.h"
3133 #include"../base/MolDSException.h"
32-#include"../base/Uncopyable.h"
3334 #include"../base/Enums.h"
3435 #include"../base/EularAngle.h"
3536 #include"../base/Parameters.h"
--- a/src/wrappers/Blas.cpp
+++ b/src/wrappers/Blas.cpp
@@ -25,16 +25,19 @@
2525 #include<string>
2626 #include<stdexcept>
2727 #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+
2835 #ifdef __INTEL_COMPILER
2936 #include"mkl.h"
3037 #else
3138 #include"cblas.h"
3239 #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+
3841 using namespace std;
3942 using namespace MolDS_base;
4043
--- a/src/wrappers/Lapack.cpp
+++ b/src/wrappers/Lapack.cpp
@@ -24,6 +24,13 @@
2424 #include<string>
2525 #include<stdexcept>
2626 #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+
2734 #ifdef __INTEL_COMPILER
2835 #include"mkl.h"
2936 #else
@@ -34,11 +41,6 @@
3441 #endif
3542 #include"lapacke.h"
3643 #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"
4244
4345 #ifdef __INTEL_COMPILER
4446 #define MOLDS_LAPACK_malloc(a,b) mkl_malloc(a,b)
--- a/src/zindo/ZindoS.cpp
+++ b/src/zindo/ZindoS.cpp
@@ -28,9 +28,10 @@
2828 #include<algorithm>
2929 #include<omp.h>
3030 #include<boost/format.hpp>
31+#include"../base/Uncopyable.h"
32+#include"../mpi/MpiProcess.h"
3133 #include"../base/PrintController.h"
3234 #include"../base/MolDSException.h"
33-#include"../base/Uncopyable.h"
3435 #include"../wrappers/Blas.h"
3536 #include"../wrappers/Lapack.h"
3637 #include"../base/Enums.h"
@@ -1084,131 +1085,185 @@ void ZindoS::DoCIS(){
10841085 void ZindoS::CalcCISProperties(){
10851086 //calculate dipole moments and transitiondipolemoment
10861087 {
1087- double*** dipoleMOs = NULL;
1088- double** overlapMOs = NULL;
10891088 int totalNumberAOs = this->molecule->GetTotalNumberAOs();
10901089 int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
10911090 int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS();
10921091 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;
11931156 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;
12081232 }
12091233 }
12101234 }
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);
12111243
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()){
12121267 for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; k++){
12131268 for(int l=k+1; l<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; l++){
12141269 for(int axis=0; axis<CartesianType_end; axis++){
@@ -1218,8 +1273,13 @@ void ZindoS::CalcCISProperties(){
12181273 }
12191274 }
12201275 }
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+
12231283 }// end of "calculate dipole moments and transitiondipolemoment"
12241284
12251285
@@ -2277,16 +2337,19 @@ void ZindoS::DoCISDirect(){
22772337 void ZindoS::CalcCISMatrix(double** matrixCIS) const{
22782338 this->OutputLog(this->messageStartCalcCISMatrix);
22792339 double ompStartTime = omp_get_wtime();
2340+ int mpiRank = MolDS_mpi::MpiProcess::GetInstance()->GetRank();
2341+ int mpiSize = MolDS_mpi::MpiProcess::GetInstance()->GetSize();
22802342
2281- stringstream ompErrors;
2282-#pragma omp parallel for schedule(auto)
22832343 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;}
22882345
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{
22902353 // single excitation from J-th (occupied)MO to B-th (virtual)MO
22912354 int moJ = this->GetActiveOccIndex(*this->molecule, l);
22922355 int moB = this->GetActiveVirIndex(*this->molecule, l);
@@ -2318,16 +2381,42 @@ void ZindoS::CalcCISMatrix(double** matrixCIS) const{
23182381 matrixCIS[k][l] = value;
23192382 // End of the slow algorith. */
23202383 }
2321- }
2322- catch(MolDSException ex){
2384+ catch(MolDSException ex){
23232385 #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());
23252392 }
23262393 } // 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+ }
23302414 }
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+
23312420 double ompEndTime = omp_get_wtime();
23322421 this->OutputLog(boost::format("%s%lf%s\n%s") % this->messageOmpElapsedTimeCalcCISMarix.c_str()
23332422 % (ompEndTime - ompStartTime)