• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revisãof68202403659b55e093da1045d06af88122c8a26 (tree)
Hora2013-07-31 20:06:38
AutorMikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Mensagem de Log

Calculating of forces of ZindoS is partially MPI-parallelized. #31814

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

Mudança Sumário

Diff

--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -24,9 +24,10 @@
2424 #include<boost/shared_ptr.hpp>
2525 #include<boost/format.hpp>
2626 #include"base/Uncopyable.h"
27-#include"mpi/MpiProcess.h"
2827 #include"base/PrintController.h"
2928 #include"base/MolDSException.h"
29+#include"base/MallocerFreer.h"
30+#include"mpi/MpiProcess.h"
3031 #include"base/Enums.h"
3132 #include"base/EularAngle.h"
3233 #include"base/atoms/Atom.h"
--- a/src/Makefile
+++ b/src/Makefile
@@ -37,9 +37,9 @@ EXENAME = MolDS.out
3737 DEPFILE = obj/objfile.dep
3838 LDFLAGS =
3939
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
40+ALL_CPP_FILES = base/PrintController.cpp base/MolDSException.cpp base/MallocerFreer.cpp mpi/MpiProcess.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.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 Main.cpp
41+ALL_HEAD_FILES = base/Uncopyable.h base/PrintController.h base/MolDSException.h base/MallocerFreer.h mpi/MpiProcess.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.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/PrintController.o obj/MolDSException.o obj/MallocerFreer.o obj/MpiProcess.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.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 obj/Main.o
4343
4444 $(EXENAME): $(ALL_OBJ_FILES)
4545 $(CC) -o $@ -Wl,-rpath=$(BOOST_LIB_DIR) -L$(BOOST_LIB_DIR) $(LDFLAGS) $(ALL_OBJ_FILES) $(LIBS)
--- a/src/Makefile_GNU
+++ b/src/Makefile_GNU
@@ -34,9 +34,9 @@ EXENAME = MolDS.out
3434 DEPFILE = obj/objfile.dep
3535 LDFLAGS =
3636
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+ALL_CPP_FILES = base/PrintController.cpp base/MolDSException.cpp base/MallocerFreer.cpp mpi/MpiProcess.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.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 Main.cpp
38+ALL_HEAD_FILES = base/Uncopyable.h base/PrintController.h base/MolDSException.h base/MallocerFreer.h mpi/MpiProcess.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.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/PrintController.o obj/MolDSException.o obj/MallocerFreer.o obj/MpiProcess.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.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 obj/Main.o
4040
4141 $(EXENAME): $(ALL_OBJ_FILES)
4242 $(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)
--- a/src/am1/Am1.cpp
+++ b/src/am1/Am1.cpp
@@ -25,9 +25,10 @@
2525 #include<vector>
2626 #include<boost/format.hpp>
2727 #include"../base/Uncopyable.h"
28-#include"../mpi/MpiProcess.h"
2928 #include"../base/PrintController.h"
3029 #include"../base/MolDSException.h"
30+#include"../base/MallocerFreer.h"
31+#include"../mpi/MpiProcess.h"
3132 #include"../base/Enums.h"
3233 #include"../base/EularAngle.h"
3334 #include"../base/Parameters.h"
--- a/src/am1/Am1D.cpp
+++ b/src/am1/Am1D.cpp
@@ -25,9 +25,10 @@
2525 #include<vector>
2626 #include<boost/format.hpp>
2727 #include"../base/Uncopyable.h"
28-#include"../mpi/MpiProcess.h"
2928 #include"../base/PrintController.h"
3029 #include"../base/MolDSException.h"
30+#include"../base/MallocerFreer.h"
31+#include"../mpi/MpiProcess.h"
3132 #include"../base/Enums.h"
3233 #include"../base/EularAngle.h"
3334 #include"../base/Parameters.h"
--- a/src/base/InputParser.cpp
+++ b/src/base/InputParser.cpp
@@ -29,9 +29,10 @@
2929 #include<stdexcept>
3030 #include<boost/format.hpp>
3131 #include"Uncopyable.h"
32-#include"../mpi/MpiProcess.h"
3332 #include"PrintController.h"
3433 #include"MolDSException.h"
34+#include"MallocerFreer.h"
35+#include"../mpi/MpiProcess.h"
3536 #include"Utilities.h"
3637 #include"Enums.h"
3738 #include"EularAngle.h"
--- a/src/base/MallocerFreer.cpp
+++ b/src/base/MallocerFreer.cpp
@@ -26,11 +26,11 @@
2626 #include<stdexcept>
2727 #include<boost/format.hpp>
2828 #include"Uncopyable.h"
29-#include"../mpi/MpiProcess.h"
3029 #include"PrintController.h"
3130 #include"MolDSException.h"
32-#include"Enums.h"
3331 #include"MallocerFreer.h"
32+#include"../mpi/MpiProcess.h"
33+#include"Enums.h"
3434 #include"EularAngle.h"
3535 #include"Parameters.h"
3636 using namespace std;
--- a/src/base/MathUtilities.cpp
+++ b/src/base/MathUtilities.cpp
@@ -25,9 +25,10 @@
2525 #include<boost/format.hpp>
2626 #include<boost/math/special_functions/factorials.hpp>
2727 #include"Uncopyable.h"
28-#include"../mpi/MpiProcess.h"
2928 #include"PrintController.h"
3029 #include"MolDSException.h"
30+#include"MallocerFreer.h"
31+#include"../mpi/MpiProcess.h"
3132 #include"../wrappers/Lapack.h"
3233 #include"Enums.h"
3334 #include"MathUtilities.h"
--- a/src/base/MolDS.cpp
+++ b/src/base/MolDS.cpp
@@ -31,14 +31,14 @@
3131 #include<boost/random.hpp>
3232 #include<boost/format.hpp>
3333 #include"Uncopyable.h"
34-#include"../mpi/MpiProcess.h"
3534 #include"PrintController.h"
3635 #include"MolDSException.h"
36+#include"MallocerFreer.h"
37+#include"../mpi/MpiProcess.h"
3738 #include"../wrappers/Blas.h"
3839 #include"../wrappers/Lapack.h"
3940 #include"Utilities.h"
4041 #include"Enums.h"
41-#include"MallocerFreer.h"
4242 #include"EularAngle.h"
4343 #include"Parameters.h"
4444 #include"atoms/Atom.h"
--- a/src/base/Molecule.cpp
+++ b/src/base/Molecule.cpp
@@ -26,13 +26,13 @@
2626 #include<stdexcept>
2727 #include<boost/format.hpp>
2828 #include"Uncopyable.h"
29-#include"../mpi/MpiProcess.h"
3029 #include"PrintController.h"
3130 #include"MolDSException.h"
31+#include"MallocerFreer.h"
32+#include"../mpi/MpiProcess.h"
3233 #include"../wrappers/Lapack.h"
3334 #include"Enums.h"
3435 #include"MathUtilities.h"
35-#include"MallocerFreer.h"
3636 #include"EularAngle.h"
3737 #include"Parameters.h"
3838 #include"atoms/Atom.h"
--- a/src/base/Parameters.cpp
+++ b/src/base/Parameters.cpp
@@ -28,9 +28,10 @@
2828 #include<stdexcept>
2929 #include<boost/format.hpp>
3030 #include"Uncopyable.h"
31-#include"../mpi/MpiProcess.h"
3231 #include"PrintController.h"
3332 #include"MolDSException.h"
33+#include"MallocerFreer.h"
34+#include"../mpi/MpiProcess.h"
3435 #include"Enums.h"
3536 #include"MallocerFreer.h"
3637 #include"EularAngle.h"
--- /dev/null
+++ b/src/base/PrintController.cpp
@@ -0,0 +1,64 @@
1+//************************************************************************//
2+// Copyright (C) 2011-2013 Mikiya Fujii //
3+// Copyright (C) 2011-2013 Katsuhiko Nishimra //
4+// //
5+// This file is part of MolDS. //
6+// //
7+// MolDS is free software: you can redistribute it and/or modify //
8+// it under the terms of the GNU General Public License as published by //
9+// the Free Software Foundation, either version 3 of the License, or //
10+// (at your option) any later version. //
11+// //
12+// MolDS is distributed in the hope that it will be useful, //
13+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
14+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
15+// GNU General Public License for more details. //
16+// //
17+// You should have received a copy of the GNU General Public License //
18+// along with MolDS. If not, see <http://www.gnu.org/licenses/>. //
19+//************************************************************************//
20+#include<sstream>
21+#include<string>
22+#include<iostream>
23+#include<cctype>
24+#include<boost/format.hpp>
25+#include"Uncopyable.h"
26+#include"PrintController.h"
27+#include"MolDSException.h"
28+#include"MallocerFreer.h"
29+#include"../mpi/MpiProcess.h"
30+using namespace std;
31+namespace MolDS_base{
32+
33+PrintController::PrintController(){
34+ this->canOutputLogs = true;
35+ //this->OutputLog("printController is created.\n");
36+}
37+
38+PrintController::~PrintController(){
39+ //this->OutputLog("printController is destructed.\n";
40+}
41+
42+void PrintController::OutputLog(string log) const{
43+ if(this->canOutputLogs){
44+#ifndef MOLDS_DBG
45+ if(MolDS_mpi::MpiProcess::GetInstance()->GetRank()!=0){return;}
46+#endif
47+ bool endl = false;
48+ string::reverse_iterator iter;
49+ for(iter = log.rbegin(); iter != log.rend(); iter++){
50+ if(*iter == '\n'){
51+ string::iterator fwditer = iter.base();
52+ log.erase(--fwditer);
53+ endl = true;
54+ break;
55+ }
56+ else if(*iter != '\0'){
57+ break;
58+ }
59+ }
60+ cout << log;
61+ if(endl){cout << std::endl;}
62+ }
63+}
64+}
--- a/src/base/PrintController.h
+++ b/src/base/PrintController.h
@@ -23,45 +23,13 @@ namespace MolDS_base{
2323
2424 class PrintController{
2525 public:
26- PrintController(){
27- this->canOutputLogs = true;
28- //this->OutputLog("printController is created.\n");
29- }
30- virtual ~PrintController(){
31- //this->OutputLog("printController is destructed.\n";
32- }
33- bool CanOutputLogs() const{
34- return this->canOutputLogs;
35- }
36- void SetCanOutputLogs(bool canOutputLogs){
37- this->canOutputLogs = canOutputLogs;
38- }
26+ PrintController();
27+ virtual ~PrintController();
28+ bool CanOutputLogs() const {return this->canOutputLogs;}
29+ void SetCanOutputLogs(bool canOutputLogs){this->canOutputLogs = canOutputLogs;}
3930 protected:
40- void OutputLog(const boost::format& log) const{
41- this->OutputLog(log.str());
42- }
43- void OutputLog(std::string log) const{
44- if(this->canOutputLogs){
45-#ifndef MOLDS_DBG
46- if(MolDS_mpi::MpiProcess::GetInstance()->GetRank()!=0){return;}
47-#endif
48- bool endl = false;
49- std::string::reverse_iterator iter;
50- for(iter = log.rbegin(); iter != log.rend(); iter++){
51- if(*iter == '\n'){
52- std::string::iterator fwditer = iter.base();
53- log.erase(--fwditer);
54- endl = true;
55- break;
56- }
57- else if(*iter != '\0'){
58- break;
59- }
60- }
61- std::cout << log;
62- if(endl){std::cout << std::endl;}
63- }
64- }
31+ void OutputLog(const boost::format& log) const{this->OutputLog(log.str());}
32+ void OutputLog(std::string log) const;
6533 private:
6634 bool canOutputLogs;
6735 };
--- a/src/base/Utilities.cpp
+++ b/src/base/Utilities.cpp
@@ -26,8 +26,10 @@
2626 #include<omp.h>
2727 #include<boost/format.hpp>
2828 #include"Uncopyable.h"
29-#include"../mpi/MpiProcess.h"
3029 #include"PrintController.h"
30+#include"MolDSException.h"
31+#include"MallocerFreer.h"
32+#include"../mpi/MpiProcess.h"
3133 #include"Utilities.h"
3234 using namespace std;
3335
--- a/src/base/atoms/Atom.cpp
+++ b/src/base/atoms/Atom.cpp
@@ -27,9 +27,10 @@
2727 #include<stdexcept>
2828 #include<boost/format.hpp>
2929 #include"../Uncopyable.h"
30-#include"../../mpi/MpiProcess.h"
3130 #include"../PrintController.h"
3231 #include"../MolDSException.h"
32+#include"../MallocerFreer.h"
33+#include"../../mpi/MpiProcess.h"
3334 #include"../Enums.h"
3435 #include"../MathUtilities.h"
3536 #include"../MallocerFreer.h"
--- a/src/base/atoms/Catom.cpp
+++ b/src/base/atoms/Catom.cpp
@@ -24,8 +24,10 @@
2424 #include<vector>
2525 #include<boost/format.hpp>
2626 #include"../Uncopyable.h"
27-#include"../../mpi/MpiProcess.h"
2827 #include"../PrintController.h"
28+#include"../MolDSException.h"
29+#include"../MallocerFreer.h"
30+#include"../../mpi/MpiProcess.h"
2931 #include"../Enums.h"
3032 #include"../EularAngle.h"
3133 #include"../Parameters.h"
--- a/src/base/atoms/Hatom.cpp
+++ b/src/base/atoms/Hatom.cpp
@@ -24,8 +24,10 @@
2424 #include<vector>
2525 #include<boost/format.hpp>
2626 #include"../Uncopyable.h"
27-#include"../../mpi/MpiProcess.h"
2827 #include"../PrintController.h"
28+#include"../MolDSException.h"
29+#include"../MallocerFreer.h"
30+#include"../../mpi/MpiProcess.h"
2931 #include"../Enums.h"
3032 #include"../EularAngle.h"
3133 #include"../Parameters.h"
--- a/src/base/atoms/Liatom.cpp
+++ b/src/base/atoms/Liatom.cpp
@@ -24,8 +24,10 @@
2424 #include<vector>
2525 #include<boost/format.hpp>
2626 #include"../Uncopyable.h"
27-#include"../../mpi/MpiProcess.h"
2827 #include"../PrintController.h"
28+#include"../MolDSException.h"
29+#include"../MallocerFreer.h"
30+#include"../../mpi/MpiProcess.h"
2931 #include"../Enums.h"
3032 #include"../EularAngle.h"
3133 #include"../Parameters.h"
--- a/src/base/atoms/Natom.cpp
+++ b/src/base/atoms/Natom.cpp
@@ -24,8 +24,10 @@
2424 #include<vector>
2525 #include<boost/format.hpp>
2626 #include"../Uncopyable.h"
27-#include"../../mpi/MpiProcess.h"
2827 #include"../PrintController.h"
28+#include"../MolDSException.h"
29+#include"../MallocerFreer.h"
30+#include"../../mpi/MpiProcess.h"
2931 #include"../Enums.h"
3032 #include"../EularAngle.h"
3133 #include"../Parameters.h"
--- a/src/base/atoms/Oatom.cpp
+++ b/src/base/atoms/Oatom.cpp
@@ -24,8 +24,10 @@
2424 #include<vector>
2525 #include<boost/format.hpp>
2626 #include"../Uncopyable.h"
27-#include"../../mpi/MpiProcess.h"
2827 #include"../PrintController.h"
28+#include"../MolDSException.h"
29+#include"../MallocerFreer.h"
30+#include"../../mpi/MpiProcess.h"
2931 #include"../Enums.h"
3032 #include"../EularAngle.h"
3133 #include"../Parameters.h"
--- a/src/base/atoms/Satom.cpp
+++ b/src/base/atoms/Satom.cpp
@@ -24,8 +24,10 @@
2424 #include<vector>
2525 #include<boost/format.hpp>
2626 #include"../Uncopyable.h"
27-#include"../../mpi/MpiProcess.h"
2827 #include"../PrintController.h"
28+#include"../MolDSException.h"
29+#include"../MallocerFreer.h"
30+#include"../../mpi/MpiProcess.h"
2931 #include"../Enums.h"
3032 #include"../EularAngle.h"
3133 #include"../Parameters.h"
--- a/src/base/factories/AtomFactory.cpp
+++ b/src/base/factories/AtomFactory.cpp
@@ -24,9 +24,10 @@
2424 #include<stdexcept>
2525 #include<boost/format.hpp>
2626 #include"../Uncopyable.h"
27-#include"../../mpi/MpiProcess.h"
2827 #include"../PrintController.h"
2928 #include"../MolDSException.h"
29+#include"../MallocerFreer.h"
30+#include"../../mpi/MpiProcess.h"
3031 #include"../Enums.h"
3132 #include"../atoms/Atom.h"
3233 #include"../atoms/Hatom.h"
--- a/src/base/factories/ElectronicStructureFactory.cpp
+++ b/src/base/factories/ElectronicStructureFactory.cpp
@@ -25,11 +25,11 @@
2525 #include<stdexcept>
2626 #include<boost/format.hpp>
2727 #include"../Uncopyable.h"
28-#include"../../mpi/MpiProcess.h"
2928 #include"../PrintController.h"
3029 #include"../MolDSException.h"
31-#include"../Enums.h"
3230 #include"../MallocerFreer.h"
31+#include"../../mpi/MpiProcess.h"
32+#include"../Enums.h"
3333 #include"../EularAngle.h"
3434 #include"../Parameters.h"
3535 #include"../atoms/Atom.h"
--- a/src/base/factories/OptimizerFactory.cpp
+++ b/src/base/factories/OptimizerFactory.cpp
@@ -26,11 +26,11 @@
2626 #include<boost/shared_ptr.hpp>
2727 #include<boost/format.hpp>
2828 #include"../Uncopyable.h"
29-#include"../../mpi/MpiProcess.h"
3029 #include"../PrintController.h"
3130 #include"../MolDSException.h"
32-#include"../Enums.h"
3331 #include"../MallocerFreer.h"
32+#include"../../mpi/MpiProcess.h"
33+#include"../Enums.h"
3434 #include"../EularAngle.h"
3535 #include"../Parameters.h"
3636 #include"../atoms/Atom.h"
--- a/src/base/loggers/DensityLogger.cpp
+++ b/src/base/loggers/DensityLogger.cpp
@@ -29,9 +29,10 @@
2929 #include<omp.h>
3030 #include<boost/format.hpp>
3131 #include"../Uncopyable.h"
32-#include"../../mpi/MpiProcess.h"
3332 #include"../PrintController.h"
3433 #include"../MolDSException.h"
34+#include"../MallocerFreer.h"
35+#include"../../mpi/MpiProcess.h"
3536 #include"../Utilities.h"
3637 #include"../Enums.h"
3738 #include"../MallocerFreer.h"
--- a/src/base/loggers/HoleDensityLogger.cpp
+++ b/src/base/loggers/HoleDensityLogger.cpp
@@ -29,9 +29,10 @@
2929 #include<omp.h>
3030 #include<boost/format.hpp>
3131 #include"../Uncopyable.h"
32-#include"../../mpi/MpiProcess.h"
3332 #include"../PrintController.h"
3433 #include"../MolDSException.h"
34+#include"../MallocerFreer.h"
35+#include"../../mpi/MpiProcess.h"
3536 #include"../Utilities.h"
3637 #include"../Enums.h"
3738 #include"../EularAngle.h"
--- a/src/base/loggers/MOLogger.cpp
+++ b/src/base/loggers/MOLogger.cpp
@@ -29,9 +29,10 @@
2929 #include<omp.h>
3030 #include<boost/format.hpp>
3131 #include"../Uncopyable.h"
32-#include"../../mpi/MpiProcess.h"
3332 #include"../PrintController.h"
3433 #include"../MolDSException.h"
34+#include"../MallocerFreer.h"
35+#include"../../mpi/MpiProcess.h"
3536 #include"../Utilities.h"
3637 #include"../Enums.h"
3738 #include"../EularAngle.h"
--- a/src/base/loggers/ParticleDensityLogger.cpp
+++ b/src/base/loggers/ParticleDensityLogger.cpp
@@ -29,9 +29,10 @@
2929 #include<omp.h>
3030 #include<boost/format.hpp>
3131 #include"../Uncopyable.h"
32-#include"../../mpi/MpiProcess.h"
3332 #include"../PrintController.h"
3433 #include"../MolDSException.h"
34+#include"../MallocerFreer.h"
35+#include"../../mpi/MpiProcess.h"
3536 #include"../Utilities.h"
3637 #include"../Enums.h"
3738 #include"../EularAngle.h"
--- a/src/cndo/Cndo2.cpp
+++ b/src/cndo/Cndo2.cpp
@@ -29,9 +29,10 @@
2929 #include<omp.h>
3030 #include<boost/format.hpp>
3131 #include"../base/Uncopyable.h"
32-#include"../mpi/MpiProcess.h"
3332 #include"../base/PrintController.h"
3433 #include"../base/MolDSException.h"
34+#include"../base/MallocerFreer.h"
35+#include"../mpi/MpiProcess.h"
3536 #include"../wrappers/Blas.h"
3637 #include"../wrappers/Lapack.h"
3738 #include"../base/Enums.h"
--- a/src/indo/Indo.cpp
+++ b/src/indo/Indo.cpp
@@ -26,9 +26,10 @@
2626 #include<stdexcept>
2727 #include<boost/format.hpp>
2828 #include"../base/Uncopyable.h"
29-#include"../mpi/MpiProcess.h"
3029 #include"../base/PrintController.h"
3130 #include"../base/MolDSException.h"
31+#include"../base/MallocerFreer.h"
32+#include"../mpi/MpiProcess.h"
3233 #include"../base/EularAngle.h"
3334 #include"../base/Enums.h"
3435 #include"../base/atoms/Atom.h"
--- a/src/mc/MC.cpp
+++ b/src/mc/MC.cpp
@@ -28,9 +28,10 @@
2828 #include<boost/random.hpp>
2929 #include<boost/format.hpp>
3030 #include"../base/Uncopyable.h"
31-#include"../mpi/MpiProcess.h"
3231 #include"../base/PrintController.h"
3332 #include"../base/MolDSException.h"
33+#include"../base/MallocerFreer.h"
34+#include"../mpi/MpiProcess.h"
3435 #include"../base/Enums.h"
3536 #include"../base/EularAngle.h"
3637 #include"../base/Parameters.h"
--- a/src/md/MD.cpp
+++ b/src/md/MD.cpp
@@ -27,9 +27,10 @@
2727 #include<boost/shared_ptr.hpp>
2828 #include<boost/format.hpp>
2929 #include"../base/Uncopyable.h"
30-#include"../mpi/MpiProcess.h"
3130 #include"../base/PrintController.h"
3231 #include"../base/MolDSException.h"
32+#include"../base/MallocerFreer.h"
33+#include"../mpi/MpiProcess.h"
3334 #include"../base/Enums.h"
3435 #include"../base/EularAngle.h"
3536 #include"../base/Parameters.h"
--- a/src/mndo/Mndo.cpp
+++ b/src/mndo/Mndo.cpp
@@ -27,9 +27,10 @@
2727 #include<omp.h>
2828 #include<boost/format.hpp>
2929 #include"../base/Uncopyable.h"
30-#include"../mpi/MpiProcess.h"
3130 #include"../base/PrintController.h"
3231 #include"../base/MolDSException.h"
32+#include"../base/MallocerFreer.h"
33+#include"../mpi/MpiProcess.h"
3334 #include"../wrappers/Blas.h"
3435 #include"../wrappers/Lapack.h"
3536 #include"../base/Enums.h"
--- a/src/mpi/MpiProcess.cpp
+++ b/src/mpi/MpiProcess.cpp
@@ -23,8 +23,11 @@
2323 #include<math.h>
2424 #include<string>
2525 #include<stdexcept>
26-#include"../base/MolDSException.h"
26+#include<boost/format.hpp>
2727 #include"../base/Uncopyable.h"
28+#include"../base/PrintController.h"
29+#include"../base/MolDSException.h"
30+#include"../base/MallocerFreer.h"
2831 #include"MpiProcess.h"
2932 using namespace std;
3033 namespace MolDS_mpi{
--- a/src/mpi/MpiProcess.h
+++ b/src/mpi/MpiProcess.h
@@ -51,6 +51,38 @@ public:
5151 broadcast(*this->communicator, &values[chunks[i].first], chunks[i].num, root);
5252 }
5353 }
54+ template<typename T, typename Op> void Reduce(const T* inValues, intptr_t num, T* outValues, Op op, int root) const{
55+ std::vector<Chunk> chunks;
56+ intptr_t tag=0;
57+ this->SplitMessage2Chunks(chunks, tag, inValues, num);
58+ for(intptr_t i=0; i<chunks.size(); i++){
59+ reduce(*this->communicator, &inValues[chunks[i].first], chunks[i].num, &outValues[chunks[i].first], op, root);
60+ }
61+ }
62+ template<typename T, typename Op> void AllReduce(const T* inValues, intptr_t num, T* outValues, Op op) const{
63+ std::vector<Chunk> chunks;
64+ intptr_t tag=0;
65+ this->SplitMessage2Chunks(chunks, tag, inValues, num);
66+ for(intptr_t i=0; i<chunks.size(); i++){
67+ all_reduce(*this->communicator, &inValues[chunks[i].first], chunks[i].num, &outValues[chunks[i].first], op);
68+ }
69+ }
70+ template<typename T, typename Op> void AllReduce(T* values, intptr_t num, Op op) const{
71+ double* tmpValues=NULL;
72+ try{
73+ MolDS_base::MallocerFreer::GetInstance()->Malloc<double>(&tmpValues, num);
74+ this->AllReduce(values, num, tmpValues, op);
75+ for(intptr_t i=0; i<num; i++){
76+ values[i] = tmpValues[i];
77+ }
78+ }
79+ catch(MolDS_base::MolDSException ex){
80+ MolDS_base::MallocerFreer::GetInstance()->Free<double>(&tmpValues, num);
81+ throw ex;
82+ }
83+ MolDS_base::MallocerFreer::GetInstance()->Free<double>(&tmpValues, num);
84+ }
85+
5486 private:
5587 static MpiProcess* mpiProcess;
5688 MpiProcess();
--- a/src/nasco/NASCO.cpp
+++ b/src/nasco/NASCO.cpp
@@ -28,11 +28,11 @@
2828 #include<boost/random.hpp>
2929 #include<boost/format.hpp>
3030 #include"../base/Uncopyable.h"
31-#include"../mpi/MpiProcess.h"
3231 #include"../base/PrintController.h"
3332 #include"../base/MolDSException.h"
34-#include"../base/Enums.h"
3533 #include"../base/MallocerFreer.h"
34+#include"../mpi/MpiProcess.h"
35+#include"../base/Enums.h"
3636 #include"../base/EularAngle.h"
3737 #include"../base/Parameters.h"
3838 #include"../base/atoms/Atom.h"
--- a/src/optimization/BFGS.cpp
+++ b/src/optimization/BFGS.cpp
@@ -29,13 +29,13 @@
2929 #include<boost/shared_ptr.hpp>
3030 #include<boost/format.hpp>
3131 #include"../base/Uncopyable.h"
32-#include"../mpi/MpiProcess.h"
3332 #include"../base/PrintController.h"
3433 #include"../base/MolDSException.h"
34+#include"../base/MallocerFreer.h"
35+#include"../mpi/MpiProcess.h"
3536 #include"../wrappers/Blas.h"
3637 #include"../wrappers/Lapack.h"
3738 #include"../base/Enums.h"
38-#include"../base/MallocerFreer.h"
3939 #include"../base/EularAngle.h"
4040 #include"../base/Parameters.h"
4141 #include"../base/atoms/Atom.h"
--- a/src/optimization/ConjugateGradient.cpp
+++ b/src/optimization/ConjugateGradient.cpp
@@ -28,11 +28,11 @@
2828 #include<boost/shared_ptr.hpp>
2929 #include<boost/format.hpp>
3030 #include"../base/Uncopyable.h"
31-#include"../mpi/MpiProcess.h"
3231 #include"../base/PrintController.h"
3332 #include"../base/MolDSException.h"
34-#include"../base/Enums.h"
3533 #include"../base/MallocerFreer.h"
34+#include"../mpi/MpiProcess.h"
35+#include"../base/Enums.h"
3636 #include"../base/EularAngle.h"
3737 #include"../base/Parameters.h"
3838 #include"../base/atoms/Atom.h"
--- a/src/optimization/Optimizer.cpp
+++ b/src/optimization/Optimizer.cpp
@@ -28,9 +28,10 @@
2828 #include<boost/shared_ptr.hpp>
2929 #include<boost/format.hpp>
3030 #include"../base/Uncopyable.h"
31-#include"../mpi/MpiProcess.h"
3231 #include"../base/PrintController.h"
3332 #include"../base/MolDSException.h"
33+#include"../base/MallocerFreer.h"
34+#include"../mpi/MpiProcess.h"
3435 #include"../base/Enums.h"
3536 #include"../base/EularAngle.h"
3637 #include"../base/Parameters.h"
--- a/src/optimization/SteepestDescent.cpp
+++ b/src/optimization/SteepestDescent.cpp
@@ -28,9 +28,10 @@
2828 #include<boost/shared_ptr.hpp>
2929 #include<boost/format.hpp>
3030 #include"../base/Uncopyable.h"
31-#include"../mpi/MpiProcess.h"
3231 #include"../base/PrintController.h"
3332 #include"../base/MolDSException.h"
33+#include"../base/MallocerFreer.h"
34+#include"../mpi/MpiProcess.h"
3435 #include"../base/Enums.h"
3536 #include"../base/EularAngle.h"
3637 #include"../base/Parameters.h"
--- a/src/pm3/Pm3.cpp
+++ b/src/pm3/Pm3.cpp
@@ -25,9 +25,10 @@
2525 #include<vector>
2626 #include<boost/format.hpp>
2727 #include"../base/Uncopyable.h"
28-#include"../mpi/MpiProcess.h"
2928 #include"../base/PrintController.h"
3029 #include"../base/MolDSException.h"
30+#include"../base/MallocerFreer.h"
31+#include"../mpi/MpiProcess.h"
3132 #include"../base/Enums.h"
3233 #include"../base/EularAngle.h"
3334 #include"../base/Parameters.h"
--- a/src/pm3/Pm3D.cpp
+++ b/src/pm3/Pm3D.cpp
@@ -25,9 +25,10 @@
2525 #include<vector>
2626 #include<boost/format.hpp>
2727 #include"../base/Uncopyable.h"
28-#include"../mpi/MpiProcess.h"
2928 #include"../base/PrintController.h"
3029 #include"../base/MolDSException.h"
30+#include"../base/MallocerFreer.h"
31+#include"../mpi/MpiProcess.h"
3132 #include"../base/Enums.h"
3233 #include"../base/EularAngle.h"
3334 #include"../base/Parameters.h"
--- a/src/pm3/Pm3Pddg.cpp
+++ b/src/pm3/Pm3Pddg.cpp
@@ -25,9 +25,10 @@
2525 #include<vector>
2626 #include<boost/format.hpp>
2727 #include"../base/Uncopyable.h"
28-#include"../mpi/MpiProcess.h"
2928 #include"../base/PrintController.h"
3029 #include"../base/MolDSException.h"
30+#include"../base/MallocerFreer.h"
31+#include"../mpi/MpiProcess.h"
3132 #include"../base/Enums.h"
3233 #include"../base/EularAngle.h"
3334 #include"../base/Parameters.h"
--- a/src/rpmd/RPMD.cpp
+++ b/src/rpmd/RPMD.cpp
@@ -28,9 +28,10 @@
2828 #include<boost/random.hpp>
2929 #include<boost/format.hpp>
3030 #include"../base/Uncopyable.h"
31-#include"../mpi/MpiProcess.h"
3231 #include"../base/PrintController.h"
3332 #include"../base/MolDSException.h"
33+#include"../base/MallocerFreer.h"
34+#include"../mpi/MpiProcess.h"
3435 #include"../base/Enums.h"
3536 #include"../base/EularAngle.h"
3637 #include"../base/Parameters.h"
--- a/src/wrappers/Blas.cpp
+++ b/src/wrappers/Blas.cpp
@@ -26,10 +26,10 @@
2626 #include<stdexcept>
2727 #include<boost/format.hpp>
2828 #include"../base/Uncopyable.h"
29-#include"../mpi/MpiProcess.h"
3029 #include"../base/PrintController.h"
3130 #include"../base/MolDSException.h"
3231 #include"../base/MallocerFreer.h"
32+#include"../mpi/MpiProcess.h"
3333 #include"Blas.h"
3434
3535 #ifdef __INTEL_COMPILER
--- a/src/wrappers/Lapack.cpp
+++ b/src/wrappers/Lapack.cpp
@@ -25,9 +25,10 @@
2525 #include<stdexcept>
2626 #include<boost/format.hpp>
2727 #include"../base/Uncopyable.h"
28-#include"../mpi/MpiProcess.h"
2928 #include"../base/PrintController.h"
3029 #include"../base/MolDSException.h"
30+#include"../base/MallocerFreer.h"
31+#include"../mpi/MpiProcess.h"
3132 #include"../base/Enums.h"
3233 #include"Lapack.h"
3334
--- a/src/zindo/ZindoS.cpp
+++ b/src/zindo/ZindoS.cpp
@@ -29,14 +29,14 @@
2929 #include<omp.h>
3030 #include<boost/format.hpp>
3131 #include"../base/Uncopyable.h"
32-#include"../mpi/MpiProcess.h"
3332 #include"../base/PrintController.h"
3433 #include"../base/MolDSException.h"
34+#include"../base/MallocerFreer.h"
35+#include"../mpi/MpiProcess.h"
3536 #include"../wrappers/Blas.h"
3637 #include"../wrappers/Lapack.h"
3738 #include"../base/Enums.h"
3839 #include"../base/MathUtilities.h"
39-#include"../base/MallocerFreer.h"
4040 #include"../base/EularAngle.h"
4141 #include"../base/Parameters.h"
4242 #include"../base/atoms/Atom.h"
@@ -3574,31 +3574,35 @@ void ZindoS::CalcDiatomicTwoElecTwoCore1stDerivatives(double*** matrix,
35743574 // elecStates is indeces of the electroinc eigen states.
35753575 // The index = 0 means electronic ground state.
35763576 void ZindoS::CalcForce(const vector<int>& elecStates){
3577+ int mpiRank = MolDS_mpi::MpiProcess::GetInstance()->GetRank();
3578+ int mpiSize = MolDS_mpi::MpiProcess::GetInstance()->GetSize();
35773579 this->CheckMatrixForce(elecStates);
35783580 if(this->RequiresExcitedStatesForce(elecStates)){
35793581 this->CalcEtaMatrixForce(elecStates);
35803582 this->CalcZMatrixForce(elecStates);
35813583 }
3582- stringstream ompErrors;
3584+
3585+ // this loop is MPI-parallelized
3586+ for(int a=0; a<this->molecule->GetNumberAtoms(); a++){
3587+ if(a%mpiSize != mpiRank){continue;}
3588+ const Atom& atomA = *molecule->GetAtom(a);
3589+ int firstAOIndexA = atomA.GetFirstAOIndex();
3590+ int lastAOIndexA = atomA.GetLastAOIndex();
3591+ stringstream ompErrors;
35833592 #pragma omp parallel
3584- {
3585- double*** diatomicTwoElecTwoCore1stDerivs = NULL;
3586- double*** diatomicOverlapAOs1stDerivs = NULL;
3587- try{
3588- MallocerFreer::GetInstance()->Malloc<double>(&diatomicTwoElecTwoCore1stDerivs,
3589- OrbitalType_end,
3590- OrbitalType_end,
3591- CartesianType_end);
3592- MallocerFreer::GetInstance()->Malloc<double>(&diatomicOverlapAOs1stDerivs,
3593- OrbitalType_end,
3594- OrbitalType_end,
3595- CartesianType_end);
3596-
3593+ {
3594+ double*** diatomicTwoElecTwoCore1stDerivs = NULL;
3595+ double*** diatomicOverlapAOs1stDerivs = NULL;
3596+ try{
3597+ MallocerFreer::GetInstance()->Malloc<double>(&diatomicTwoElecTwoCore1stDerivs,
3598+ OrbitalType_end,
3599+ OrbitalType_end,
3600+ CartesianType_end);
3601+ MallocerFreer::GetInstance()->Malloc<double>(&diatomicOverlapAOs1stDerivs,
3602+ OrbitalType_end,
3603+ OrbitalType_end,
3604+ CartesianType_end);
35973605 #pragma omp for schedule(auto)
3598- for(int a=0; a<this->molecule->GetNumberAtoms(); a++){
3599- const Atom& atomA = *molecule->GetAtom(a);
3600- int firstAOIndexA = atomA.GetFirstAOIndex();
3601- int lastAOIndexA = atomA.GetLastAOIndex();
36023606 for(int b=0; b<this->molecule->GetNumberAtoms(); b++){
36033607 if(a == b){continue;}
36043608 const Atom& atomB = *molecule->GetAtom(b);
@@ -3713,27 +3717,60 @@ void ZindoS::CalcForce(const vector<int>& elecStates){
37133717 }
37143718 }
37153719 }
3716- } // end of for(int b)
3717- } // end of for(int a)
3718- } // end of try
3719- catch(MolDSException ex){
3720+ } // end of for(int b) with omp parallelization
3721+ }// end of try for omp-for
3722+ catch(MolDSException ex){
37203723 #pragma omp critical
3721- ex.Serialize(ompErrors);
3724+ ex.Serialize(ompErrors);
3725+ }
3726+ MallocerFreer::GetInstance()->Free<double>(&diatomicTwoElecTwoCore1stDerivs,
3727+ OrbitalType_end,
3728+ OrbitalType_end,
3729+ CartesianType_end);
3730+ MallocerFreer::GetInstance()->Free<double>(&diatomicOverlapAOs1stDerivs,
3731+ OrbitalType_end,
3732+ OrbitalType_end,
3733+ CartesianType_end);
3734+ } //end of parallelized region
3735+ // Exception throwing for omp-region
3736+ if(!ompErrors.str().empty()){
3737+ throw MolDSException::Deserialize(ompErrors);
3738+ }
3739+ } // end of for(int a) with MPI parallelization
3740+
3741+ // communication to reduce thsi->matrixForce on all node (namely, all_reduce)
3742+ int numTransported = elecStates.size()*this->molecule->GetNumberAtoms()*CartesianType_end;
3743+ MolDS_mpi::MpiProcess::GetInstance()->AllReduce(&this->matrixForce[0][0][0], numTransported, std::plus<double>());
3744+ /*
3745+ double*** tmp=NULL;
3746+ try{
3747+ MallocerFreer::GetInstance()->Malloc<double>(&tmp,
3748+ elecStates.size(),
3749+ this->molecule->GetNumberAtoms(),
3750+ CartesianType_end);
3751+ MolDS_mpi::MpiProcess::GetInstance()->AllReduce(&this->matrixForce[0][0][0], numTransported, &tmp[0][0][0], std::plus<double>());
3752+ for(int n=0; n<elecStates.size(); n++){
3753+ for(int a=0; a<this->molecule->GetNumberAtoms(); a++){
3754+ for(int i=0; i<CartesianType_end; i++){
3755+ this->matrixForce[n][a][i] = tmp[n][a][i];
3756+ }
3757+ }
37223758 }
3723- MallocerFreer::GetInstance()->Free<double>(&diatomicTwoElecTwoCore1stDerivs,
3724- OrbitalType_end,
3725- OrbitalType_end,
3726- CartesianType_end);
3727- MallocerFreer::GetInstance()->Free<double>(&diatomicOverlapAOs1stDerivs,
3728- OrbitalType_end,
3729- OrbitalType_end,
3730- CartesianType_end);
37313759 }
3732- // Exception throwing for omp-region
3733- if(!ompErrors.str().empty()){
3734- throw MolDSException::Deserialize(ompErrors);
3760+ catch(MolDSException ex){
3761+ MallocerFreer::GetInstance()->Free<double>(&tmp,
3762+ elecStates.size(),
3763+ this->molecule->GetNumberAtoms(),
3764+ CartesianType_end);
3765+ throw ex;
37353766 }
3736-
3767+ MallocerFreer::GetInstance()->Free<double>(&tmp,
3768+ elecStates.size(),
3769+ this->molecule->GetNumberAtoms(),
3770+ CartesianType_end);
3771+ */
3772+ // end of communication
3773+
37373774 /*
37383775 // Calculate force (on the ground state only).
37393776 // First derivative of overlapAOs integral is