Grid 0.7.0
NerscCheckpointer.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/hmc/NerscCheckpointer.h
6
7Copyright (C) 2015
8
9Author: paboyle <paboyle@ph.ed.ac.uk>
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along
22with this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25See the full license in the file "LICENSE" in the top level distribution
26directory
27*************************************************************************************/
28 /* END LEGAL */
29#ifndef NERSC_CHECKPOINTER
30#define NERSC_CHECKPOINTER
31
32#include <iostream>
33#include <sstream>
34#include <string>
35
37
38// Only for Gauge fields
39template <class Gimpl>
41private:
43
44public:
45 INHERIT_GIMPL_TYPES(Gimpl); // only for gauge configurations
47
49
50 void initialize(const CheckpointerParameters &Params_) {
51 Params = Params_;
52 Params.format = "IEEE64BIG"; // fixed, overwrite any other choice
53 }
54
55 virtual void TrajectoryComplete(int traj,
57 GridSerialRNG &sRNG,
58 GridParallelRNG &pRNG)
59 {
60 if ((traj % Params.saveInterval) == 0) {
61 std::string config, rng, smr;
62 this->build_filenames(traj, Params, config, smr, rng);
63
64 int precision32 = 1;
65 int tworow = 0;
66 NerscIO::writeRNGState(sRNG, pRNG, rng);
67 NerscIO::writeConfiguration<GaugeStats>(SmartConfig.get_U(false), config, tworow, precision32);
68 if ( Params.saveSmeared ) {
69 NerscIO::writeConfiguration<GaugeStats>(SmartConfig.get_U(true), smr, tworow, precision32);
70 }
71 }
72 };
73
74 void CheckpointRestore(int traj, GaugeField &U, GridSerialRNG &sRNG,
75 GridParallelRNG &pRNG) {
76 std::string config, rng, smr;
77 this->build_filenames(traj, Params, config, smr, rng );
78 this->check_filename(rng);
79 this->check_filename(config);
80
81
83 NerscIO::readRNGState(sRNG, pRNG, header, rng);
85 };
86};
87
89#endif
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
#define header
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
void build_filenames(int traj, CheckpointerParameters &Params, std::string &conf_file, std::string &smear_file, std::string &rng_file)
void check_filename(const std::string &filename)
Base class for "smart configuration", a container for a gauge configuration holding unsmeared and sme...
Definition ActionBase.h:51
virtual Field & get_U(bool smeared=false)=0
GaugeStatistics< Gimpl > GaugeStats
CheckpointerParameters Params
void initialize(const CheckpointerParameters &Params_)
virtual void TrajectoryComplete(int traj, ConfigurationBase< GaugeField > &SmartConfig, GridSerialRNG &sRNG, GridParallelRNG &pRNG)
void CheckpointRestore(int traj, GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG)
NerscHmcCheckpointer(const CheckpointerParameters &Params_)
static void readRNGState(GridSerialRNG &serial, GridParallelRNG &parallel, FieldMetaData &header, std::string file)
Definition NerscIO.h:344
static void readConfiguration(GaugeField &Umu, FieldMetaData &header, std::string file, GaugeStats GaugeStatisticsCalculator=GaugeStats())
Definition NerscIO.h:140
static void writeRNGState(GridSerialRNG &serial, GridParallelRNG &parallel, std::string file)
Definition NerscIO.h:292
static void writeConfiguration(Lattice< vLorentzColourMatrixD > &Umu, std::string file, std::string ens_label=std::string("DWF"), std::string ens_id=std::string("UKQCD"), unsigned int sequence_number=1)
Definition NerscIO.h:217