18template <
typename group>
20 int trajectory,
bool save_old =
true) {
24 if (save_old &&
hila::myrank() == 0 && filesys_ns::exists(config_file)) {
25 filesys_ns::rename(config_file, config_file +
".prev");
38 if (status.
open(
"run_status",
false,
false)) {
39 int ntraj = status.
get(
"trajectories");
40 if (ntraj != n_trajectories) {
41 hila::out0 <<
"* NUMBER OF TRAJECTORIES " << n_trajectories <<
" -> " << ntraj <<
'\n';
42 n_trajectories = ntraj;
51 outf.open(
"run_status", std::ios::out | std::ios::trunc);
52 outf <<
"trajectories " << n_trajectories
53 <<
" # CHANGE TO ADJUST NUMBER OF TRAJECTORIES IN THIS RUN\n";
54 outf <<
"trajectory " << trajectory + 1 <<
'\n';
55 outf <<
"seed " <<
static_cast<uint64_t
>(
hila::random() * (1UL << 61)) <<
'\n';
59 std::stringstream msg;
61 hila::timestamp(msg.str());
67template <
typename group>
68bool restore_checkpoint(
GaugeField<group> &U,
const std::string &config_file,
int &n_trajectories,
73 if (status.
open(
"run_status",
false,
false)) {
75 int traj = status.
get(
"trajectories");
76 if (traj != n_trajectories) {
77 hila::out0 <<
"Number of trajectories set in 'run_status' " << n_trajectories <<
" -> "
79 n_trajectories = traj;
82 trajectory = status.
get(
"trajectory");
83 seed = status.
get(
"seed");
89 U.config_read(config_file);
94 bool exists =
hila::myrank() == 0 && filesys_ns::exists(config_file);
98 U.config_read(config_file);
void config_write(const std::string &filename) const
config_write writes the gauge field to file, with additional "verifying" header
double random()
Real valued uniform random number generator.
int myrank()
rank of this node
std::ostream out0
This writes output only from main process (node 0)
void seed_random(uint64_t seed, bool device_rng=true)
Seed random generators with 64-bit unsigned value. On MPI shuffles the seed so that different MPI ran...
T broadcast(T &var, int rank=0)
Broadcast the value of var to all MPI ranks from rank (default=0).