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

this appears to fix the hdf5 multiple ranks multiple iterations crash

parent a09c9971
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@
#include "dca/io/adios2/adios2_writer.hpp"
#endif

#define RETURN_IF_NOT_PARALLEL(x) if(concurrency_.id() != concurrency_.first() && !isADIOS2()) \
                                      return x

namespace dca::io {

template <class Concurrency>
@@ -89,19 +92,23 @@ public:
  bool isOpen() { return is_open_; }
  
  void begin_step() {
    RETURN_IF_NOT_PARALLEL();
    std::visit([&](auto& var) { var.begin_step(); }, writer_);
  }

  void end_step() {
    RETURN_IF_NOT_PARALLEL();
    std::visit([&](auto& var) { var.end_step(); }, writer_);
  }

  void open_file(const std::string& file_name, bool overwrite = true) {
    RETURN_IF_NOT_PARALLEL();
    std::visit([&](auto& var) { var.open_file(file_name, overwrite); }, writer_);
    is_open_ = true;
  }

  void close_file() {
    RETURN_IF_NOT_PARALLEL();
    std::visit([&](auto& var) { var.close_file(); }, writer_);
    is_open_ = false;
  }
@@ -109,24 +116,29 @@ public:
  /** For writing open_group is expected to always return true
   */
  bool open_group(const std::string& new_path) {
    RETURN_IF_NOT_PARALLEL(true);
    return std::visit([&](auto& var) -> bool { return var.open_group(new_path); }, writer_);
  }

  void close_group() {
    RETURN_IF_NOT_PARALLEL();
    std::visit([&](auto& var) { var.close_group(); }, writer_);
  }

  void flush() {
    RETURN_IF_NOT_PARALLEL();
    std::visit([&](auto& var) { var.flush(); }, writer_);
  }

  template <class... Args>
  bool execute(const Args&... args) {
    RETURN_IF_NOT_PARALLEL(true);
    return std::visit([&](auto& var) ->bool { return var.execute(args...); }, writer_);
  }

  template <class... Args>
  void executePartial(const Args&... args) {
    RETURN_IF_NOT_PARALLEL();
    std::visit([&](auto& var) { var.executePartial(args...); }, writer_);
  }

@@ -147,10 +159,12 @@ public:
  }

  void lock() {
    RETURN_IF_NOT_PARALLEL();
    mutex_.lock();
  }

  void unlock() {
    RETURN_IF_NOT_PARALLEL();
    mutex_.unlock();
  }

+5 −2
Original line number Diff line number Diff line
@@ -628,8 +628,11 @@ void DcaData<Parameters, DT>::initializeSigma(const std::string& filename) {
    io::IOType sigma_file_io = io::extensionToIOType(filename);
    io::Reader reader(concurrency_, sigma_file_io);
    reader.open_file(filename);
    if (sigma_file_io == io::IOType::ADIOS2)
      throw std::runtime_error("DCA++ not built with ADIOS2 support");
    std::size_t step_count = reader.getStepCount();
      for (std::size_t i = 0; i < step_count; ++i) {
        reader.begin_step();
        reader.end_step();
      }
    readSigmaFile(reader);
  }
  concurrency_.broadcast(parameters_.get_chemical_potential());
+4 −8
Original line number Diff line number Diff line
@@ -147,16 +147,12 @@ DcaLoop<ParametersType, DcaDataType, MCIntegratorType, DIST>::DcaLoop(
          parameters.get_output_format() == "ADIOS2"
              ? std::make_shared<io::Writer<concurrency_type>>(
                    concurrency.get_adios(), concurrency_ref, parameters.get_output_format(), false)
              : (concurrency.id() == concurrency.first()
                     ? std::make_shared<io::Writer<concurrency_type>>(
              : std::make_shared<io::Writer<concurrency_type>>(
                           concurrency.get_adios(), concurrency_ref, parameters.get_output_format(),
                           false)
                     : nullptr)),
                           false)),
#else
      output_file_(concurrency.id() == concurrency.first()
                       ? std::make_shared<io::Writer<concurrency_type>>(
                             concurrency_ref, parameters.get_output_format(), false)
                       : nullptr),
      output_file_(std::make_shared<io::Writer<concurrency_type>>(
								  concurrency_ref, parameters.get_output_format(), false)),
#endif
      monte_carlo_integrator_(parameters_ref, MOMS_ref, output_file_) {
  file_name_ = parameters.get_directory() + parameters.get_filename_dca();