-
Notifications
You must be signed in to change notification settings - Fork 9
/
dumps2hdf5.c
100 lines (75 loc) · 1.93 KB
/
dumps2hdf5.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*KORAL - dumps2hdf5.c
Converts .head and .dat dumpfiles in ./dumps folder to .h5
files in the same folder
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "ko.h"
#include "hdf5.h"
#ifdef FOLDER_HDF5
#undef FOLDER_HDF5
#endif
#define FOLDER_HDF5 "./dumps"
int main(int argc, char **argv)
{
#ifdef MPI
printf("dumps2hdf5 does not work with MPI. Please undefine MPI and rerun\n");
exit(1);
#endif
#if defined DUMPS_READ_HDF5 || !defined DUMPS_WRITE_HDF5
printf("Please correct define.h\nYou must undefine DUMPS_READ_HDF5 and define DUMPS_WRITE_HDF5\n");
exit(1);
#endif
//initialize pointers to functions
init_pointers();
//initialize constants
initialize_constants();
//which files to read
int no1, no2, nostep;
if(argc != 4)
{
printf("Wrong number of input arguments. Command is ./dumps2hdf5 init final step\n");
exit(1);
}
else
{
no1=atof(argv[1]);
no2=atof(argv[2]);
nostep=atof(argv[3]);
}
char folder[100],bufer[100];
sprintf(folder,"%s","./dumps");
//no gsl error messages
gsl_set_error_handler_off();
//preparing arrays
initialize_arrays();
//sets the grid
set_grid(&min_dx,&min_dy,&min_dz,&max_dt);
alloc_loops(1, 0., 0.);
//precalculates metric etc.
//calc_metric();
#ifdef RELELECTRONS
set_relel_gammas();
#endif
//precalculating problem related numbers
int j;
#ifdef PR_PREPINIT
#include PR_PREPINIT
#endif
int ifile;
int ret;
ldouble t;
printf("Working on files #%04d to #%04d with %d step \n", no1, no2, nostep);
for(ifile = no1; ifile <= no2; ifile += nostep)
{
// Read in .head and binary .dat dump data
ret = fread_restartfile_bin(ifile, folder, &t);
printf("Finished reading file %d ret = %d\n", ifile, ret);
// Write out .h5 dump file
nfout1 = ifile;
ret = fprint_restartfile_serial_hdf5(t, folder);
printf("Finished writing file %d ret = %d\n", ifile, ret);
}
return 0;
}