aboutsummaryrefslogtreecommitdiff
path: root/src/ioGH.h
blob: 98e3059d48b4210c71c47bc21d90a533797e16a8 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
 /*@@
   @header    ioGH.h
   @date      Tue 9th Jan 1999
   @author    Gabrielle Allen
   @desc 
   The extensions to the GH structure from IOUtil.
   @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 -> FlexIO
   @hauthor Thomas Radke @hdate 30 Mar 1999
   @hdesc Undefined DI macro
   @endhistory
   @version $Header$
 @@*/


#ifdef __cplusplus
extern "C"
{
#endif


#include "StoreNamedData.h"


/* structure describing an advertised file
   It contains pointer to strings holding
     - the thorn which created the file
     - the variable name the file contents data belongs to
     - the MIME type for the file format used
     - a short slice string indication the dimensionality of the data
     - an arbitrary additional description of the file contents */
typedef struct
{
  char *thorn;
  char *varname;
  char *mimetype;
  char *slice;
  char *description;
} IOUtil_AdvertisedFileDesc_t;


/* structure containing function pointers for handling with advertised files
   For the moment it contains only a registration routine for new files to
   be advertised. In the future we might also want something like
   unadvertising, or notification when the contents of the file changed. */
typedef struct
{
  int (*advertise) (cGH *GH, const char *filename,
                    const IOUtil_AdvertisedFileDesc_t *description);
} IOUtil_AdvertisedFileListenerCallbacks_t;


/* IOUtil's GH extension structure */
typedef struct IOGH {

#if 0
  /* TR: commented these things out because they were moved into the other
         IO thorns' GH extensions
         But maybe someday we want them back here, eg. if the user 
         wants to say how often to do 3D output in general for all IO thorns
         that can produce 3D output; of course they should still be able
         override this with their own parameters.
   */
  /* How often to output */
  int  infoevery;
  int  IO_0Devery;
  int  IO_1Devery;
  int  IO_2Devery;
  int  IO_3Devery;

  /* Directory in which to output */
  char  *outpfx_0D;
  char  *outpfx_1D;
  char  *outpfx_2D;
  char  *outpfx_3D;
#endif

  /* for 3D output */
  int ioproc;       /* the IO processor each proc belongs to */
  int nioprocs;     /* total number of IO processors */
  int ioproc_every; /* output by every N'th processor */
  int unchunked;    /* if true generate unchunked output file */
  int *downsample;  /* downsampling parameters array of size cctk_maxdim */
  int out_single;   /* if true output 3D data in single precision */

  /* for recovery */
  int recovered;    /* flag indicating restart after successful recovery */

  /* for data file reader */
  char *do_inVars;  /* flags indicating to read in variable [i] */

  
  /* database holding all registered listeners for file advertising */
  pNamedData *listener_DB;

} ioGH;

/* enums for checkpointing/recovery and filereader functions */
enum {CP_INITIAL_DATA, CP_EVOLUTION_DATA, CP_RECOVER_PARAMETERS,
      CP_RECOVER_DATA, FILEREADER_DATA};

/* prototypes of routines that are exported by IOUtil to other IO thorns */

extern int  IOUtil_1DLines (cGH *GH, 
			    int dimension, 
			    int **index, 
			    CCTK_REAL **coord, 
			    int **spxyz);

extern int  IOUtil_2DPlanes (cGH *GH, 
			     int dimension, 
			     int *index, 
			     CCTK_REAL *coord, 
			     int *spxyz);

extern void IOUtil_ParseVarsForOutput (const char *var_list, 
				       char do_output []);

extern void IOUtil_PrepareFilename (cGH *GH, 
				    const char *basename, 
				    char *fname,
				    int called_from, 
				    int ioproc,
				    int file_unchunked);

extern int  IOUtil_RegisterRecover (const char *name,
                                   int (*func) (cGH *, const char *, int));

extern void IOUtil_RecoverVarsFromDatafiles (cGH *GH,
                                             const char *in_files,
                                             const char *in_vars);

extern int  IOUtil_RecoverParameters (int (*recoverFn) (cGH *GH,
							const char *basename,
							int called_from),
				      const char *fileExtension,
				      const char *fileType);

extern char *IOUtil_GetAllParameters (cGH *GH);

extern void IOUtil_SetAllParameters (char *parameters);

/*** routines to handle with file advertising ***/

/* register a new listener with its own callbacks for file advertising */

extern int IOUtil_RegisterAdvertisedFileListener (cGH *GH,
                                                  const char *listener,
                    const IOUtil_AdvertisedFileListenerCallbacks_t *callbacks);

/* advertise a file */

extern int IOUtil_AdvertiseFile (cGH *GH,
                                 const char *filename,
                                 const IOUtil_AdvertisedFileDesc_t *desc);

/*** routine to output timing information ***/

extern void IOUtil_PrintTimings (const char *description,
                                 int ntimers,
                                 int timers[/* ntimers */],
                                 const char *timer_descriptions[/* ntimers */]);

#ifdef __cplusplus
}
#endif