29 int nv, single_file, origin,
nlines=0;
31 char fname[512], fout[512], str[512];
43 if (output->
type == type)
break;
56 fbin = fopen (fout,
"r");
58 sprintf (fout,
"%s/dbl.h5.out",ini->
output_dir);
59 fbin = fopen (fout,
"r");
62 print1 (
"! Restart: cannot find dbl.out or dbl.h5.out\n");
66 while (fgets(str, 512, fbin) != 0) nlines++;
68 if (nrestart > nlines-1){
69 printf (
"! Restart: position too large\n");
72 origin = (nrestart >= 0 ? nrestart:(nlines+nrestart));
73 for (nv = origin; nv--; )
while ( fgetc(fbin) !=
'\n'){}
74 fscanf(fbin,
"%d %lf %lf %d %s %s\n",&nv, &dbl, &dbl, &nv, str, str);
78 print1 (
"> Restart: endianity is reversed\n");
83 MPI_Bcast (&swap_endian, 1, MPI_INT, 0, MPI_COMM_WORLD);
98 print1 (
"> restarting from file #%d (dbl)\n",output->
nfile);
99 single_file = strcmp(output->
mode,
"single_file") == 0;
109 sprintf (fname,
"%s/data.%04d.dbl", output->
dir, output->
nfile);
114 for (nv = 0; nv < output->
nvar; nv++) {
115 if (!output->
dump_var[nv])
continue;
119 Vpt = (
void *)output->
V[nv][0][0];
120 }
else if (output->
stag_var[nv] == 0) {
122 Vpt = (
void *)(output->
V[nv][0][0]-1);
123 }
else if (output->
stag_var[nv] == 1) {
125 Vpt = (
void *)output->
V[nv][0][-1];
126 }
else if (output->
stag_var[nv] == 2) {
128 Vpt = (
void *)output->
V[nv][-1][0];
148 for (nv = 0; nv < output->
nvar; nv++) {
149 if (!output->
dump_var[nv])
continue;
150 sprintf (fname,
"%s/%s.%04d.%s", output->
dir, output->
var_name[nv],
155 Vpt = (
void *)output->
V[nv][0][0];
156 }
else if (output->
stag_var[nv] == 0) {
158 Vpt = (
void *)(output->
V[nv][0][0]-1);
159 }
else if (output->
stag_var[nv] == 1) {
161 Vpt = (
void *)output->
V[nv][0][-1];
162 }
else if (output->
stag_var[nv] == 2) {
164 Vpt = (
void *)output->
V[nv][-1][0];
191 printf (
"! negative restart file temporarily disabled\n");
204 sprintf (fout,
"%s/restart.out",ini->
output_dir);
205 fr = fopen (fout,
"rb");
207 print1 (
"! RestartGet: cannot find restart.out\n");
211 origin = (nrestart < 0 ? SEEK_END:SEEK_SET);
215 print(
"! RestartGet: end of file encountered.\n");
218 fseek (fr, k*
sizeof(
Restart), origin);
219 fread (&restart,
sizeof (
Restart), 1, fr);
239 MPI_Bcast (&restart,
sizeof (
Restart), MPI_BYTE, 0, MPI_COMM_WORLD);
279 sprintf (fout,
"%s/restart.out",ini->
output_dir);
281 fr = fopen (fout,
"wb");
283 fr = fopen (fout,
"r+b");
287 fwrite (&restart,
sizeof(
Restart), 1, fr);
void RestartGet(Runtime *ini, int nrestart, int out_type, int swap_endian)
void ReadHDF5(Output *output, Grid *grid)
double *** V[64]
pointer to arrays being written - same for all
long long AL_Get_offset(int sz_ptr)
Output output[MAX_OUTPUT_TYPES]
void print1(const char *fmt,...)
FILE * OpenBinaryFile(char *filename, int sz, char *mode)
int nfile
current number being saved - one per output
char output_dir[256]
The name of the output directory (output_dir for static PLUTO, Output_dir for PLUTO-Chombo) ...
double g_dt
The current integration time step.
int AL_Set_offset(int sz_ptr, long long offset)
char dir[256]
output directory name
static int nlines
The total number of lines (including empty ones) contained in the file.
char ext[8]
output extension
void ReadBinaryArray(void *V, size_t dsize, int sz, FILE *fl, int istag, int swap_endian)
long int g_stepNumber
Gives the current integration step number.
void print(const char *fmt,...)
int * dump_var
select vars being written - one per output
void RestartDump(Runtime *ini)
double g_time
The current integration time.
char mode[32]
single or multiple files - one per output
int type
output format (DBL, FLT, ...) - one per output
int * stag_var
centered or staggered variable - same for all
int nfile[MAX_OUTPUT_TYPES]
void RestartFromFile(Runtime *ini, int nrestart, int type, Grid *grid)
int CloseBinaryFile(FILE *fbin, int sz)
#define QUIT_PLUTO(e_code)
char ** var_name
variable names - same for all