GADGET-4
restart.h
Go to the documentation of this file.
1/*******************************************************************************
2 * \copyright This file is part of the GADGET4 N-body/SPH code developed
3 * \copyright by Volker Springel. Copyright (C) 2014-2020 by Volker Springel
4 * \copyright (vspringel@mpa-garching.mpg.de) and all contributing authors.
5 *******************************************************************************/
6
12#ifndef RESTART_H
13#define RESTART_H
14
15#define MODUS_WRITE 0
16#define MODUS_READ 1
17
18#define BLKSIZE (1024 * 1024)
19
20#include "../io/io_streamcount.h"
21#include "../main/simulation.h"
22
23class restart : public io_streamcount, public setcomm
24{
25 public:
26 restart(MPI_Comm comm) : setcomm(comm) /* constructor */ { determine_compute_nodes(); }
27
28 void load(sim *Sim_ptr);
29 void write(sim *Sim_ptr);
30
31 private:
32 sim *Sim;
33
34 FILE *fd;
35
36 struct seq_data
37 {
38 int thistask;
39 int rankinnode;
40 int thisnode;
41 bool operator<(const seq_data &other) const
42 {
43 if(rankinnode < other.rankinnode)
44 return true;
45 if(rankinnode > other.rankinnode)
46 return false;
47 if(thisnode < other.thisnode)
48 return true;
49 if(thisnode > other.thisnode)
50 return false;
51 return thistask < other.thistask;
52 }
53 };
54 seq_data *seq;
55
56 int files_started;
57 int files_completed;
58 int files_concurrent;
59 int files_groups;
60
61 void do_restart(int modus);
62
63 void readjust_timebase(double TimeMax_old, double TimeMax_new);
64 void work_files(int modus);
65 void contents_restart_file(int modus);
66 void backup_restartfiles(int task);
67 void polling(int modus);
68 void in(int *x, int modus);
69 void byten(void *x, size_t n, int modus);
70 void byten_doit(void *x, size_t n, int modus);
71};
72
73#endif /* RESTART_H */
restart(MPI_Comm comm)
Definition: restart.h:26
void write(sim *Sim_ptr)
Definition: restart.cc:37
void load(sim *Sim_ptr)
This function loads the last restart file.
Definition: restart.cc:50
void determine_compute_nodes(void)
Definition: setcomm.h:98
Definition: simulation.h:50
bool operator<(const location &left, const location &right)
Definition: dtypes.h:172