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
|
/*@@
@file GHExtension.c
@date Fri May 21 1999
@author Thomas Radke
@desc
StreamedHDF5 GH extension stuff.
@enddesc
@history
@hauthor Thomas Radke @hdate May 21 1999
@hdesc Just copied from thorn FlexIO.
@endhistory
@@*/
/*#define DEBUG_IO*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "CactusBase/IOUtil/src/ioGH.h"
#include "StreamedHDF5GH.h"
void *StreamedHDF5_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
{
int numvars;
StreamedHDF5GH *newGH;
numvars = CCTK_NumVars ();
newGH = (StreamedHDF5GH *) malloc (sizeof (StreamedHDF5GH));
newGH->do_output = (char *) malloc (numvars * sizeof (char));
newGH->geo_output = (StreamGeo_t*) malloc (numvars * sizeof (StreamGeo_t));
newGH->out_last = (int *) malloc (numvars * sizeof (int));
/* save the original error printing routine and its argument */
CACTUS_IOHDF5_ERROR (H5Eget_auto (&newGH->printErrorFn,
&newGH->printErrorFnArg));
/* predefine dataspaces for writing scalar and array attributes */
/* the dimension of the array dataspace is set when used */
CACTUS_IOHDF5_ERROR (newGH->scalarDataspace = H5Screate (H5S_SCALAR));
CACTUS_IOHDF5_ERROR (newGH->arrayDataspace = H5Screate (H5S_SIMPLE));
/* predefine a IOHDF5_COMPLEX datatype */
CACTUS_IOHDF5_ERROR (newGH->IOHDF5_COMPLEX =
H5Tcreate (H5T_COMPOUND, sizeof (CCTK_COMPLEX)));
CACTUS_IOHDF5_ERROR (H5Tinsert (newGH->IOHDF5_COMPLEX, "real",
offsetof (CCTK_COMPLEX, Re), IOHDF5_REAL));
CACTUS_IOHDF5_ERROR (H5Tinsert (newGH->IOHDF5_COMPLEX, "imag",
offsetof (CCTK_COMPLEX, Im), IOHDF5_REAL));
/* predefine a C string datatype */
CACTUS_IOHDF5_ERROR (newGH->IOHDF5_STRING = H5Tcopy (H5T_C_S1));
return (newGH);
}
int StreamedHDF5_InitGH (cGH *GH)
{
DECLARE_CCTK_PARAMETERS
int i;
StreamedHDF5GH *myGH;
const cParamData *paramdata;
myGH = (StreamedHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("StreamedHDF5")];
/* How often to output */
myGH->out_every = out_every > 0 ? out_every : -1;
if (outHDF5_every > 0)
myGH->out_every = outHDF5_every;
IOUtil_ParseVarsForOutput (out_vars, myGH->do_output);
for (i = 0; i < CCTK_NumVars (); i++)
myGH->out_last [i] = -1;
return (0);
}
|