aboutsummaryrefslogtreecommitdiff
path: root/src/ioFlexGH.h
blob: 48359456fd93ed9ef1800af433fccf4dfc8e3cb6 (plain)
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
124
125
126
 /*@@
   @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


/* attribute name for storing parameters
   Parameters are stored as a single string attached to the very first dataset
   in an IEEEIO file. */
#define GLOBAL_PARAMETERS  "global_parameters"

/* Check error flags from IOFlexIO */
#define CACTUS_IEEEIO_ERROR(fn_call)                                          \
    do {                                                                      \
                                                                              \
      int error_code = fn_call;                                               \
                                                                              \
      if (error_code < 0)                                                     \
        CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,                  \
                    "IEEEIO call '%s' returned error code %d\n",              \
                    #fn_call, error_code);                                    \
    } while (0)


/* structure holding necessary information about a recovery file */
typedef struct { 
  int is_IEEEIO_file;       /* flag indicating valid file info */
  IOFile fid;               /* IEEEIO file handle */
  char filename [1024];     /* complete file name for recovery */
  int nprocs;               /* number of total processors */
  int ioproc;               /* the associated IO processor */
  int ioproc_every;         /* how many IO processors there are */
  int unchunked;            /* whether data was written chunked or unchunked */
} fileinfo_t;


/* IOFlexIO GH extension structure */
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;

  /* 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);