diff --git a/src/context/config.hpp b/src/context/config.hpp index d811be185..86c27dec6 100644 --- a/src/context/config.hpp +++ b/src/context/config.hpp @@ -799,18 +799,6 @@ class config_t } dict_["/control/num_bands_to_print"_json_pointer] = num_bands_to_print__; } - /// If true then the hash sums of some arrays will be printed. - inline auto print_hash() const - { - return dict_.at("/control/print_hash"_json_pointer).get(); - } - inline void print_hash(bool print_hash__) - { - if (dict_.contains("locked")) { - throw std::runtime_error(locked_msg); - } - dict_["/control/print_hash"_json_pointer] = print_hash__; - } /// If true then the stress tensor components are printed at the end of SCF run. inline auto print_stress() const { diff --git a/src/context/input_schema.json b/src/context/input_schema.json index 1413894ab..a1db47031 100644 --- a/src/context/input_schema.json +++ b/src/context/input_schema.json @@ -382,11 +382,6 @@ "default" : 10, "title" : "Number of eigen-values that are printed to the standard output." }, - "print_hash" : { - "type" : "boolean", - "default" : false, - "title" : "If true then the hash sums of some arrays will be printed." - }, "print_stress" : { "type" : "boolean", "default" : false, diff --git a/src/density/density.cpp b/src/density/density.cpp index a7ade0bac..d8b0022dc 100644 --- a/src/density/density.cpp +++ b/src/density/density.cpp @@ -188,7 +188,7 @@ Density::initial_density_pseudo() } std::copy(v.begin(), v.end(), &rho().rg().f_pw_local(0)); - if (ctx_.cfg().control().print_hash() && ctx_.comm().rank() == 0) { + if (env::print_hash() && ctx_.comm().rank() == 0) { auto h = sddk::mdarray, 1>(&v[0], ctx_.gvec().count()).hash(); utils::print_hash("rho_pw_init", h); } @@ -205,7 +205,7 @@ Density::initial_density_pseudo() } } rho().rg().fft_transform(1); - if (ctx_.cfg().control().print_hash() && ctx_.comm().rank() == 0) { + if (env::print_hash() && ctx_.comm().rank() == 0) { auto h = rho().rg().values().hash(); utils::print_hash("rho_rg_init", h); } @@ -1342,7 +1342,7 @@ Density::generate_valence(K_point_set const& ks__) rho().rg().f_pw_local(0) += ctx_.cfg().parameters().extra_charge() / ctx_.unit_cell().omega(); } - if (ctx_.cfg().control().print_hash() && ctx_.comm().rank() == 0) { + if (env::print_hash() && ctx_.comm().rank() == 0) { auto h = sddk::mdarray, 1>(&rho().rg().f_pw_local(0), ctx_.gvec().count()).hash(); utils::print_hash("rho", h); } @@ -1524,7 +1524,7 @@ Density::generate_rho_aug() utils::print_checksum("rho_aug", cs, ctx_.out()); } - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { auto h = rho_aug.hash(); if (ctx_.comm().rank() == 0) { utils::print_hash("rho_aug", h); diff --git a/src/potential/potential.cpp b/src/potential/potential.cpp index 37b22638b..ae5c26789 100644 --- a/src/potential/potential.cpp +++ b/src/potential/potential.cpp @@ -252,7 +252,7 @@ void Potential::generate(Density const& density__, bool use_symmetry__, bool tra /* add Hartree potential to the total potential */ effective_potential() += hartree_potential(); - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { auto h = effective_potential().rg().hash_f_rg(); if (ctx_.comm().rank() == 0) { utils::print_hash("Vha", h); @@ -270,7 +270,7 @@ void Potential::generate(Density const& density__, bool use_symmetry__, bool tra /* add XC potential to the effective potential */ effective_potential() += xc_potential(); - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { auto h = effective_potential().rg().hash_f_rg(); if (ctx_.comm().rank() == 0) { utils::print_hash("Vha+Vxc", h); @@ -308,7 +308,7 @@ void Potential::generate(Density const& density__, bool use_symmetry__, bool tra } } - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { auto h = effective_potential().rg().hash_f_pw(); if (ctx_.comm().rank() == 0) { utils::print_hash("V(G)", h); diff --git a/src/potential/xc.cpp b/src/potential/xc.cpp index 6815fdb8d..f9dab28d8 100644 --- a/src/potential/xc.cpp +++ b/src/potential/xc.cpp @@ -75,7 +75,7 @@ void Potential::xc_rg_nonmagnetic(Density const& density__) WARNING(s); } - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { auto h = rho.hash_f_rg(); if (ctx_.comm().rank() == 0) { utils::print_hash("rho", h); @@ -114,7 +114,7 @@ void Potential::xc_rg_nonmagnetic(Density const& density__) /* product of gradients */ grad_rho_grad_rho = dot(grad_rho, grad_rho); - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { //auto h1 = lapl_rho.hash_f_rg(); auto h2 = grad_rho_grad_rho.hash_f_rg(); if (ctx_.comm().rank() == 0) { @@ -261,7 +261,7 @@ void Potential::xc_rg_magnetic(Density const& density__) auto& rho_up = *result[0]; auto& rho_dn = *result[1]; - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { auto h1 = rho_up.hash_f_rg(); auto h2 = rho_dn.hash_f_rg(); if (ctx_.comm().rank() == 0) { @@ -297,7 +297,7 @@ void Potential::xc_rg_magnetic(Density const& density__) grad_rho_up_grad_rho_dn = dot(grad_rho_up, grad_rho_dn); grad_rho_dn_grad_rho_dn = dot(grad_rho_dn, grad_rho_dn); - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { auto h3 = grad_rho_up_grad_rho_up.hash_f_rg(); auto h4 = grad_rho_up_grad_rho_dn.hash_f_rg(); auto h5 = grad_rho_dn_grad_rho_dn.hash_f_rg(); @@ -465,7 +465,7 @@ void Potential::xc(Density const& density__) xc_rg_magnetic(density__); } - if (ctx_.cfg().control().print_hash()) { + if (env::print_hash()) { auto h = xc_energy_density_->rg().hash_f_rg(); if (ctx_.comm().rank() == 0) { utils::print_hash("Exc", h); diff --git a/src/utils/env.hpp b/src/utils/env.hpp index 6c36302e7..0ac17027d 100644 --- a/src/utils/env.hpp +++ b/src/utils/env.hpp @@ -65,6 +65,13 @@ print_checksum() return val && *val; } +inline bool +print_hash() +{ + auto val = get_value_ptr("SIRIUS_PRINT_HASH"); + return val && *val; +} + inline bool print_mpi_layout() {