ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
restart.h
Go to the documentation of this file.
1#ifndef RESTART_H
2#define RESTART_H
3
4#include <string>
6#ifdef __EXX
7#include <RI/global/Tensor.h>
8#endif
9
11{
12public:
13 struct Info_Save
14 {
15 bool save_charge = false;
16 bool save_H = false; // save H means save Hexx now, will be changed in the future.
17 };
19
20 struct Info_Load
21 {
22 bool load_charge = false;
23 bool load_charge_finish = false;
24 bool load_H = false;
25 bool load_H_finish = false;
26 bool restart_exx = false; // to avoid the repeated load in MD/Relax
27 };
29
30 std::string folder;
31
32 template<typename T>
33 bool save_disk(const std::string label, const int index, const int size, T* data, const bool error_quit = true) const
34 {
37 data,
38 size * sizeof(T),
39 error_quit);
40 }
41 template<typename T>
42 bool load_disk(const std::string label, const int index, const int size, T* data, const bool error_quit = true) const
43 {
46 data,
47 size * sizeof(T),
48 error_quit);
49 }
50private:
51 void write_file1(const std::string &file_name, const void*const ptr, const size_t size) const;
52 void read_file1(const std::string &file_name, void*const ptr, const size_t size) const;
53 bool write_file2(const std::string& file_name, const void* const ptr, const size_t size, const bool error_quit = true) const;
54 bool read_file2(const std::string& file_name, void* const ptr, const size_t size, const bool error_quit = true) const;
55};
56
57namespace GlobalC
58{
59extern Restart restart; // Peize Lin add 2020.04.04
60} // namespace GlobalC
61
62#endif
Definition restart.h:11
std::string folder
Definition restart.h:30
void read_file1(const std::string &file_name, void *const ptr, const size_t size) const
Definition restart.cpp:17
Info_Load info_load
Definition restart.h:28
bool write_file2(const std::string &file_name, const void *const ptr, const size_t size, const bool error_quit=true) const
Definition restart.cpp:23
bool read_file2(const std::string &file_name, void *const ptr, const size_t size, const bool error_quit=true) const
Definition restart.cpp:50
bool load_disk(const std::string label, const int index, const int size, T *data, const bool error_quit=true) const
Definition restart.h:42
Info_Save info_save
Definition restart.h:18
bool save_disk(const std::string label, const int index, const int size, T *data, const bool error_quit=true) const
Definition restart.h:33
void write_file1(const std::string &file_name, const void *const ptr, const size_t size) const
Definition restart.cpp:11
#define T
Definition exp.cpp:237
Definition cal_epsilon_test.cpp:31
Restart restart
Definition restart.cpp:47
int MY_RANK
global index of process
Definition global_variable.cpp:21
std::string TO_STRING(const T &t, const int n=20)
Definition global_function.h:239
Definition restart.h:21
bool load_charge
Definition restart.h:22
bool load_charge_finish
Definition restart.h:23
bool restart_exx
Definition restart.h:26
bool load_H
Definition restart.h:24
bool load_H_finish
Definition restart.h:25
Definition restart.h:14
bool save_H
Definition restart.h:16
bool save_charge
Definition restart.h:15