Loading CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ set(DCA_LIBS cluster_domains quantum_domains time_and_frequency_domains signals symmetrization coarsegraining ${DCA_CONCURRENCY_LIB} Loading applications/dca/main_dca.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "dca/io/json/json_reader.hpp" #include "dca/util/git_version.hpp" #include "dca/util/modules.hpp" #include "dca/util/signal_handler.hpp" int main(int argc, char** argv) { if (argc < 2) { Loading @@ -30,6 +31,8 @@ int main(int argc, char** argv) { Concurrency concurrency(argc, argv); try { dca::util::SignalHandler::init(concurrency.id() == concurrency.first()); std::string input_file(argv[1]); Profiler::start(); Loading include/dca/phys/dca_loop/dca_loop.hpp +26 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "dca/phys/domains/quantum/electron_band_domain.hpp" #include "dca/phys/domains/quantum/electron_spin_domain.hpp" #include "dca/util/print_time.hpp" #include "dca/util/signal_handler.hpp" namespace dca { namespace phys { Loading Loading @@ -91,6 +92,7 @@ protected: void update_DCA_loop_data_functions(int DCA_iteration); void writeWalkerData(int i); void logSelfEnergy(int i); ParametersType& parameters; DcaDataType& MOMS; Loading Loading @@ -136,6 +138,7 @@ DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::DcaLoop(ParametersType& if (concurrency.id() == concurrency.first()) { file_name_ = parameters.get_directory() + parameters.get_filename_dca(); output_file_.open_file(file_name_); dca::util::SignalHandler::registerFile(output_file_); std::cout << "\n\n\t" << __FUNCTION__ << " has started \t" << dca::util::print_time() << "\n\n"; } Loading @@ -156,6 +159,8 @@ void DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::write() { MOMS.write(output_file_); monte_carlo_integrator_.write(output_file_); DCA_info_struct.write(output_file_); output_file_.close_file(); } } Loading Loading @@ -186,6 +191,8 @@ void DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::execute() { perform_lattice_mapping(); logSelfEnergy(i); // Write a check point. update_DCA_loop_data_functions(i); if (L2_Sigma_difference < Loading Loading @@ -363,6 +370,25 @@ void DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::writeWalkerData(int } } template <typename ParametersType, typename DcaDataType, typename MCIntegratorType> void DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::logSelfEnergy(int i) { if (output_file_) { output_file_.open_group("functions"); output_file_.execute(MOMS.Sigma); output_file_.close_group(); output_file_.open_group("parameters"); output_file_.open_group("physics"); output_file_.execute("chemical-potential", parameters.get_chemical_potential()); output_file_.close_group(); output_file_.close_group(); output_file_.open_group("DCA-loop-functions"); output_file_.execute("completed-iteration", i); output_file_.close_group(); } } } // namespace phys } // namespace dca Loading include/dca/util/signal_handler.hpp 0 → 100644 +38 −0 Original line number Diff line number Diff line // Copyright (C) 2019 ETH Zurich // Copyright (C) 2019 UT-Battelle, LLC // All rights reserved. // See LICENSE.txt for terms of usage./ // See CITATION.md for citation guidelines, if DCA++ is used for scientific publications. // // Author: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch) // // This singleton class organizes the handling of signals. #ifndef DCA_UTIL_SIGNAL_HANDLER_HPP #define DCA_UTIL_SIGNAL_HANDLER_HPP #include <vector> #include "dca/io/hdf5/hdf5_writer.hpp" namespace dca { namespace util { // dca::util:: class SignalHandler{ public: static void init(bool verbose = false); static void registerFile(io::HDF5Writer& writer); private: static void sigintHandler(int signum); static inline bool verbose_; static inline std::vector<io::HDF5Writer*> file_ptrs_; }; } // namespace util } // namespace dca #endif // DCA_UTIL_SIGNAL_HANDLER_HPP src/io/hdf5/hdf5_writer.cpp +6 −47 Original line number Diff line number Diff line Loading @@ -87,68 +87,27 @@ std::string HDF5Writer::get_path() { void HDF5Writer::execute(const std::string& name, const std::string& value) //, H5File& file, std::string path) { if (value.size() > 0) { H5::H5File& file = (*file_); std::string path = get_path(); hsize_t dims[1]; H5::DataSet* dataset = NULL; H5::DataSpace* dataspace = NULL; { dims[0] = value.size(); dataspace = new H5::DataSpace(1, dims); std::string full_name = get_path() + '/' + name; std::string full_name = path + "/" + name; dataset = new H5::DataSet( file.createDataSet(full_name.c_str(), HDF5_TYPE<char>::get_PredType(), *dataspace)); H5Dwrite(dataset->getId(), HDF5_TYPE<char>::get(), dataspace->getId(), H5S_ALL, H5P_DEFAULT, &value[0]); } delete dataset; delete dataspace; } write(full_name, std::vector<hsize_t>{value.size()}, HDF5_TYPE<char>::get_PredType(), value.data()); } void HDF5Writer::execute(const std::string& name, const std::vector<std::string>& value) //, H5File& file, std::string path) { if (value.size() > 0) { H5::H5File& file = (*file_); open_group(name); execute("size", value.size()); //, file, new_path); execute("size", value.size()); open_group("data"); hsize_t dims[1]; H5::DataSet* dataset = NULL; H5::DataSpace* dataspace = NULL; for (size_t l = 0; l < value.size(); l++) { dims[0] = value[l].size(); dataspace = new H5::DataSpace(1, dims); const auto path = get_path(); std::stringstream ss; ss << get_path() << "/" << l; dataset = new H5::DataSet( file.createDataSet(ss.str().c_str(), HDF5_TYPE<char>::get_PredType(), *dataspace)); H5Dwrite(dataset->getId(), HDF5_TYPE<char>::get(), dataspace->getId(), H5S_ALL, H5P_DEFAULT, &(value[l][0])); for (int i = 0; i < value.size(); ++i) { execute(get_path() + "/" + std::to_string(i), value[i]); } close_group(); delete dataset; delete dataspace; close_group(); } } Loading Loading
CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ set(DCA_LIBS cluster_domains quantum_domains time_and_frequency_domains signals symmetrization coarsegraining ${DCA_CONCURRENCY_LIB} Loading
applications/dca/main_dca.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "dca/io/json/json_reader.hpp" #include "dca/util/git_version.hpp" #include "dca/util/modules.hpp" #include "dca/util/signal_handler.hpp" int main(int argc, char** argv) { if (argc < 2) { Loading @@ -30,6 +31,8 @@ int main(int argc, char** argv) { Concurrency concurrency(argc, argv); try { dca::util::SignalHandler::init(concurrency.id() == concurrency.first()); std::string input_file(argv[1]); Profiler::start(); Loading
include/dca/phys/dca_loop/dca_loop.hpp +26 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "dca/phys/domains/quantum/electron_band_domain.hpp" #include "dca/phys/domains/quantum/electron_spin_domain.hpp" #include "dca/util/print_time.hpp" #include "dca/util/signal_handler.hpp" namespace dca { namespace phys { Loading Loading @@ -91,6 +92,7 @@ protected: void update_DCA_loop_data_functions(int DCA_iteration); void writeWalkerData(int i); void logSelfEnergy(int i); ParametersType& parameters; DcaDataType& MOMS; Loading Loading @@ -136,6 +138,7 @@ DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::DcaLoop(ParametersType& if (concurrency.id() == concurrency.first()) { file_name_ = parameters.get_directory() + parameters.get_filename_dca(); output_file_.open_file(file_name_); dca::util::SignalHandler::registerFile(output_file_); std::cout << "\n\n\t" << __FUNCTION__ << " has started \t" << dca::util::print_time() << "\n\n"; } Loading @@ -156,6 +159,8 @@ void DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::write() { MOMS.write(output_file_); monte_carlo_integrator_.write(output_file_); DCA_info_struct.write(output_file_); output_file_.close_file(); } } Loading Loading @@ -186,6 +191,8 @@ void DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::execute() { perform_lattice_mapping(); logSelfEnergy(i); // Write a check point. update_DCA_loop_data_functions(i); if (L2_Sigma_difference < Loading Loading @@ -363,6 +370,25 @@ void DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::writeWalkerData(int } } template <typename ParametersType, typename DcaDataType, typename MCIntegratorType> void DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::logSelfEnergy(int i) { if (output_file_) { output_file_.open_group("functions"); output_file_.execute(MOMS.Sigma); output_file_.close_group(); output_file_.open_group("parameters"); output_file_.open_group("physics"); output_file_.execute("chemical-potential", parameters.get_chemical_potential()); output_file_.close_group(); output_file_.close_group(); output_file_.open_group("DCA-loop-functions"); output_file_.execute("completed-iteration", i); output_file_.close_group(); } } } // namespace phys } // namespace dca Loading
include/dca/util/signal_handler.hpp 0 → 100644 +38 −0 Original line number Diff line number Diff line // Copyright (C) 2019 ETH Zurich // Copyright (C) 2019 UT-Battelle, LLC // All rights reserved. // See LICENSE.txt for terms of usage./ // See CITATION.md for citation guidelines, if DCA++ is used for scientific publications. // // Author: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch) // // This singleton class organizes the handling of signals. #ifndef DCA_UTIL_SIGNAL_HANDLER_HPP #define DCA_UTIL_SIGNAL_HANDLER_HPP #include <vector> #include "dca/io/hdf5/hdf5_writer.hpp" namespace dca { namespace util { // dca::util:: class SignalHandler{ public: static void init(bool verbose = false); static void registerFile(io::HDF5Writer& writer); private: static void sigintHandler(int signum); static inline bool verbose_; static inline std::vector<io::HDF5Writer*> file_ptrs_; }; } // namespace util } // namespace dca #endif // DCA_UTIL_SIGNAL_HANDLER_HPP
src/io/hdf5/hdf5_writer.cpp +6 −47 Original line number Diff line number Diff line Loading @@ -87,68 +87,27 @@ std::string HDF5Writer::get_path() { void HDF5Writer::execute(const std::string& name, const std::string& value) //, H5File& file, std::string path) { if (value.size() > 0) { H5::H5File& file = (*file_); std::string path = get_path(); hsize_t dims[1]; H5::DataSet* dataset = NULL; H5::DataSpace* dataspace = NULL; { dims[0] = value.size(); dataspace = new H5::DataSpace(1, dims); std::string full_name = get_path() + '/' + name; std::string full_name = path + "/" + name; dataset = new H5::DataSet( file.createDataSet(full_name.c_str(), HDF5_TYPE<char>::get_PredType(), *dataspace)); H5Dwrite(dataset->getId(), HDF5_TYPE<char>::get(), dataspace->getId(), H5S_ALL, H5P_DEFAULT, &value[0]); } delete dataset; delete dataspace; } write(full_name, std::vector<hsize_t>{value.size()}, HDF5_TYPE<char>::get_PredType(), value.data()); } void HDF5Writer::execute(const std::string& name, const std::vector<std::string>& value) //, H5File& file, std::string path) { if (value.size() > 0) { H5::H5File& file = (*file_); open_group(name); execute("size", value.size()); //, file, new_path); execute("size", value.size()); open_group("data"); hsize_t dims[1]; H5::DataSet* dataset = NULL; H5::DataSpace* dataspace = NULL; for (size_t l = 0; l < value.size(); l++) { dims[0] = value[l].size(); dataspace = new H5::DataSpace(1, dims); const auto path = get_path(); std::stringstream ss; ss << get_path() << "/" << l; dataset = new H5::DataSet( file.createDataSet(ss.str().c_str(), HDF5_TYPE<char>::get_PredType(), *dataspace)); H5Dwrite(dataset->getId(), HDF5_TYPE<char>::get(), dataspace->getId(), H5S_ALL, H5P_DEFAULT, &(value[l][0])); for (int i = 0; i < value.size(); ++i) { execute(get_path() + "/" + std::to_string(i), value[i]); } close_group(); delete dataset; delete dataspace; close_group(); } } Loading