Commit a05699bd authored by Doak, Peter W.'s avatar Doak, Peter W.
Browse files

fix hdf5 reading of initial-self-energy when adios2 is present

parent c13a5107
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -283,11 +283,14 @@ bool ADIOS2Writer<CT>::execute(const std::string& name,
  for (int i = 0; i < n; ++i) {
    sizes[i] = value[i].size();
    nTotal += sizes[i];
    if (verbose_) {
      std::cout << sizes[i];
      if (i < n - 1) {
        std::cout << ", ";
      }
    }
  }

  if (verbose_) {
    std::cout << ")\n";
  }
+3 −5
Original line number Diff line number Diff line
@@ -22,16 +22,14 @@ namespace io {
 *  dummy at 0 debug automatic initialization of int to 0
 *  causes a bug. That is not a good code smell.
 */
enum class IOType : int {
  JSON = 0,
  HDF5,
  ADIOS2
};
enum class IOType : int { JSON = 0, HDF5, ADIOS2, UNKNOWN };

IOType stringToIOType(const std::string& name);

std::string toString(const IOType type);

IOType extensionToIOType(const std::string& file_name);

}  // namespace io
}  // namespace dca

+32 −29
Original line number Diff line number Diff line
@@ -205,38 +205,41 @@ template <typename ParametersType, typename DDT, typename MCIntegratorType, Dist
void DcaLoop<ParametersType, DDT, MCIntegratorType, DIST>::initialize() {
  static_assert(std::is_same<DDT, dca::phys::DcaData<ParametersType, DIST>>::value);
  int last_completed = -1;

  auto& autoresume_filename = parameters.get_autoresume_filename();
  io::IOType iotype = io::extensionToIOType(autoresume_filename);
  if (parameters.autoresume()) {  // Try to read state of previous run.
    auto& dca_filename = parameters.get_filename_dca();
    std::size_t extension_start = dca_filename.rfind('.');
    std::string extension{dca_filename.substr(extension_start, dca_filename.size())};
    std::cout << extension << '\n';
    // This is not complete, how do we want to decide what format we are reading?  Just from output format?
                                  // This is not complete we should work based on extension
    // do we want to decide what format we are reading?  Just from output format?
#ifdef DCA_HAVE_ADIOS2
    if (io::stringToIOType(parameters.get_output_format()) == io::IOType::ADIOS2)
      last_completed =
          DCA_info_struct.readData(file_name_, parameters.get_output_format(), concurrency, adios_);
    if (iotype == io::IOType::ADIOS2)
      last_completed = DCA_info_struct.readData(
          autoresume_filename, parameters.get_output_format(), concurrency, adios_);
    else
#endif
      last_completed =
          DCA_info_struct.readData(file_name_ + ".tmp", parameters.get_output_format(), concurrency);
  }
      last_completed = DCA_info_struct.readData(autoresume_filename,
                                                parameters.get_output_format(), concurrency);
    if (last_completed >= 0) {
      if (concurrency.id() == concurrency.first())
      std::cout << "\n   *******  Resuming DCA from iteration " << last_completed + 1 << "  *******\n"
        std::cout << "\n   *******  Resuming DCA from iteration " << last_completed + 1
                  << "  *******\n"
                  << std::endl;

      dca_iteration_ = std::min(last_completed + 1, parameters.get_dca_iterations() - 1);
#ifdef DCA_HAVE_ADIOS2
    MOMS.initializeSigma(adios_, file_name_ + ".tmp");
      if (iotype == io::IOType::ADIOS2)
        MOMS.initializeSigma(adios_, autoresume_filename);
      else
#else
    MOMS.initializeSigma(file_name_ + ".tmp");
      MOMS.initializeSigma(autoresume_filename);
#endif
        perform_lattice_mapping();
    }
  }
  else if (parameters.get_initial_self_energy() != "zero") {
#ifdef DCA_HAVE_ADIOS2
    if (io::extensionToIOType(parameters.get_initial_self_energy()) == io::IOType::ADIOS2)
      MOMS.initializeSigma(adios_, parameters.get_initial_self_energy());
    else
#else
    MOMS.initializeSigma(parameters.get_initial_self_energy());
#endif
+6 −6
Original line number Diff line number Diff line
@@ -89,7 +89,8 @@ public:

  auto transformMFunction(const MFuncAndSign& mfs) const;
  auto computeSingleMeasurement_G_k_w(const SpGreensFunction& M_k_w) const;
  void logSingleMeasurement(StdThreadAccumulatorType& accumulator, int stamping_period, bool log_MFunction) const;
  void logSingleMeasurement(StdThreadAccumulatorType& accumulator, int stamping_period,
                            bool log_MFunction) const;

private:
  void startWalker(int id);
@@ -230,9 +231,7 @@ void StdThreadQmciClusterSolver<QmciSolver>::integrate() {
      throw std::logic_error("Thread task is undefined.");
  }
  auto print_metadata = [&]() {
    std::cout << "walk_finished_: " << walk_finished_ << " params: " << parameters_.get_walkers()
              << std::endl;
    // assert(walk_finished_ == parameters_.get_walkers());
    assert(walk_finished_ == parameters_.get_walkers());

    dca::profiling::WallTime end_time;

@@ -445,7 +444,8 @@ auto StdThreadQmciClusterSolver<QmciSolver>::computeSingleMeasurement_G_k_w(
}

template <class QmciSolver>
void StdThreadQmciClusterSolver<QmciSolver>::logSingleMeasurement(StdThreadAccumulatorType& accumulator_obj, int stamping_period, bool log_MFunction) const {
void StdThreadQmciClusterSolver<QmciSolver>::logSingleMeasurement(
    StdThreadAccumulatorType& accumulator_obj, int stamping_period, bool log_MFunction) const {
  if (accumulator_obj.get_meas_id() % stamping_period == 0) {
    auto mfs = ThisType::getSingleMFunc(accumulator_obj);
    auto M_k_w = ThisType::transformMFunction(mfs);
+1 −3
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@ public:
        walkers_(1),
        accumulators_(1),
        shared_walk_and_accumulation_thread_(false),
        // TODO: consider setting default do true.
        fix_meas_per_walker_(false),
        adjust_self_energy_for_double_counting_(false),
        error_computation_type_(ErrorComputationType::NONE),
        store_configuration_(true),
@@ -155,7 +153,7 @@ private:
  int accumulators_;
  bool shared_walk_and_accumulation_thread_;
  bool distributed_g4_enabled_;
  bool fix_meas_per_walker_;
  bool fix_meas_per_walker_ = true;
  bool adjust_self_energy_for_double_counting_;
  ErrorComputationType error_computation_type_;
  bool store_configuration_;
Loading