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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*@@
@header IOFlexIOGH.h
@date Tue 9th Jan 1999
@author Gabrielle Allen
@desc
The extensions to the GH structure from IO.
@history
@hauthor Thomas Radke @hdate 16 Mar 1999
@hdesc Added parameters for 2D and 3D output
@hauthor Thomas Radke @hdate 17 Mar 1999
@hdesc Changed naming: IEEEIO -> IOFlexIO
@hauthor Thomas Radke @hdate 30 Mar 1999
@hdesc Undefined DI macro
@endhistory
@version $Header$
@@*/
#include <string.h>
#include "StoreNamedData.h"
#include "external/IEEEIO/src/IOProtos.h"
#include "external/IEEEIO/src/IEEEIO.h"
#include "external/IEEEIO/src/MPIO.h"
/* define the IOFlexIO datatypes according to CCTK_??? datatypes */
#define FLEXIO_REAL4 FLOAT32
#ifdef CCTK_REAL_PRECISION_16
#error "128-bit precision floating point types are not supported by IOFlexIO !"
#elif CCTK_REAL_PRECISION_8
#define FLEXIO_REAL FLOAT64
#elif CCTK_REAL_PRECISION_4
#define FLEXIO_REAL FLOAT32
#endif
#ifdef CCTK_INTEGER_PRECISION_8
#define FLEXIO_INT INT64
#elif CCTK_INTEGER_PRECISION_4
#define FLEXIO_INT INT32
#elif CCTK_INTEGER_PRECISION_2
#define FLEXIO_INT INT16
#endif
#define FLEXIO_INT4 INT32
#define FLEXIO_CHAR CHAR
/* name prefix for storing parameters
Parameters are stored as attributes attached to the very first dataset
in an IEEEIO file. The prefix is used to distinguish them from other
attributes (eg. GH extensions). */
#define PARAMETER_PREFIX "PARAM"
#define ANAME_DELIMITER "::"
/* Check error flags from IOFlexIO */
#define CACTUS_IEEEIO_ERROR(fn_call) \
do { \
\
int error_code = fn_call; \
\
if (error_code < 0) { \
char *msg = (char*) malloc(strlen(__FILE__) + strlen(#fn_call) + 160);\
\
sprintf (msg, \
"IEEEIO call %s returned error code %d, file %s, line %d\n", \
#fn_call, error_code, __FILE__, __LINE__); \
CCTK_WARN (1, msg); \
free (msg); \
} \
} while (0)
typedef struct IOFlexIOGH {
/* flags indicating output for var [i] */
char *do_out2D;
char *do_out3D;
/* how often to output */
int out2D_every;
int out3D_every;
/* directory in which to output */
char *outdir2D;
char *outdir3D;
/* the last iteration output */
int *out2D_last;
int *out3D_last;
/* IEEEIO file name and pointer for 3D output */
char **IEEEfname_3D;
IOFile *IEEEfile_3D;
/* reuse filehandles during IEEEIO */
int out3d_reuse_filehandles;
/* filename database for opened files */
pNamedData *filenameList2D;
pNamedData *fileList_3D;
/* slice point for 2D output */
int sp2xyz [3];
/* handles for different timers */
int dumpVarsTimer;
int dumpParamsTimer;
int checkpointTotalTimer;
int recoverVarsTimer;
int recoverParamsTimer;
int recoverTotalTimer;
} flexioGH;
/* function prototypes */
void IOFlexIO_Write2D (cGH *GH, int index, const char *alias);
void IOFlexIO_Write3D (cGH *GH, int index, const char *alias);
void IOFlexIO_DumpVar (cGH *GH, int index, int timelevel, IOFile iof);
void IOFlexIO_IEEEIOStructDump (cGH *GH, IOFile iof);
void IOFlexIO_DumpGH (cGH *GH, int called_from);
|