SCORPIO  2.0.1
pio.h
Go to the documentation of this file.
1 
7 #ifndef _PIO_H_
8 #define _PIO_H_
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <stdbool.h>
12 #include <string.h> /* memcpy */
13 
14 #ifdef MPI_SERIAL
15 #if defined(__cplusplus)
16 extern "C" {
17 #endif
18 #endif
19 
20 #include <mpi.h>
21 
22 #ifdef MPI_SERIAL
23 #if defined(__cplusplus)
24 }
25 #endif
26 #endif
27 
28 #include "pio_config.h"
29 #if PIO_USE_PNETCDF
30  #define _PNETCDF 1
31 #endif
32 #if PIO_USE_NETCDF
33  #define _NETCDF 1
34  #if PIO_USE_NETCDF4
35  #define _NETCDF4 1
36  #endif
37 #endif
38 #if PIO_USE_ADIOS
39  #define _ADIOS2 1
40 #endif
41 #if PIO_USE_HDF5
42  #define _HDF5 1
43 #endif
44 #if PIO_USE_MICRO_TIMING
45  #define PIO_MICRO_TIMING 1
46 #endif
47 #if PIO_ENABLE_IO_STATS
48  #define SPIO_IO_STATS 1
49 #endif
50 
51 #ifdef _NETCDF
52 #include <netcdf.h>
53 #ifdef _NETCDF4
54 #include <netcdf_par.h>
55 #endif
56 #endif
57 #ifdef _PNETCDF
58 #include <pnetcdf.h>
59 #endif
60 
61 #ifdef _ADIOS2
62 #include <sys/types.h>
63 #include <sys/stat.h>
64 #include <unistd.h>
65 #include <limits.h>
66 #include <adios2_c.h>
67 
68 #define MAX_ADIOS_BUFFER_COUNT (PIO_MAX_CACHED_STEPS_FOR_ADIOS + 16) /* Maximum buffer size for aggregating decomp_id, frame_id, and fillval_id values */
69 #define BLOCK_MAX_BUFFER ((unsigned long)INT_MAX) /* 2GB limit of MPI_Gatherv */
70 /* adios end step is called if the number of blocks written out exceeds BLOCK_COUNT_THRESHOLD */
71 #define BLOCK_COUNT_THRESHOLD ((unsigned long)(1024 * 1024 * 1024 * 1.9))
72 #define BLOCK_METADATA_SIZE 70 /* Size of adios block metadata */
73 
74 #endif
75 #ifdef _HDF5
76 #include <hdf5.h>
77 #include <hdf5_hl.h>
78 #include <unistd.h>
79 #endif
80 
81 /* PIO_OFFSET_C_TYPENAME is defined in pio_config.h */
82 typedef PIO_OFFSET_C_TYPENAME PIO_Offset;
83 
84 /* The MPI typename corresponding to PIO_Offset, PIO_OFFSET, is defined in pio_config.h */
85 
87 #define PIO_IODESC_START_ID 512
88 #define PIO_IODESC_MAX_IDS 65536
89 
91 #define PIO_MAX_VARS_UB 8192
92 #if NC_MAX_VARS > PIO_MAX_VARS_UB
93 #define PIO_MAX_VARS PIO_MAX_VARS_UB
94 #else
95 #define PIO_MAX_VARS NC_MAX_VARS
96 #endif
97 
99 #define PIO_MAX_DIMS_UB 1024
100 #if NC_MAX_DIMS > PIO_MAX_DIMS_UB
101 #define PIO_MAX_DIMS PIO_MAX_DIMS_UB
102 #else
103 #define PIO_MAX_DIMS NC_MAX_DIMS
104 #endif
105 
107 #define PIO_MAX_ATTRS_UB 8192
108 #if NC_MAX_ATTRS > PIO_MAX_ATTRS_UB
109 #define PIO_MAX_ATTRS PIO_MAX_ATTRS_UB
110 #else
111 #define PIO_MAX_ATTRS NC_MAX_ATTRS
112 #endif
113 
116 #define PIO_DEFAULT (-1)
117 
120 /* Holds the version of the decomposition file. */
121 #define DECOMP_VERSION_ATT_NAME "version"
122 
123 /* Holds the maximum length of any task map. */
124 #define DECOMP_MAX_MAPLEN_ATT_NAME "max_maplen"
125 
126 /* Name of title attribute. */
127 #define DECOMP_TITLE_ATT_NAME "title"
128 
129 /* Name of history attribute. */
130 #define DECOMP_HISTORY_ATT_NAME "history"
131 
132 /* Name of source attribute. */
133 #define DECOMP_SOURCE_ATT_NAME "source"
134 
135 /* Name of array order (C or Fortran) attribute. */
136 #define DECOMP_ORDER_ATT_NAME "array_order"
137 
138 /* Name of backtrace attribute. */
139 #define DECOMP_BACKTRACE_ATT_NAME "backtrace"
140 
141 /* Name for the dim dim in decomp file. */
142 #define DECOMP_DIM_DIM "dims"
143 
144 /* Name for the npes dim in decomp file. */
145 #define DECOMP_TASK_DIM_NAME "task"
146 
147 /* Name for the npes dim in decomp file. */
148 #define DECOMP_MAPELEM_DIM_NAME "map_element"
149 
150 #define DECOMP_NDIMS "ndims"
151 
152 /* Name of var in decomp file that holds global array sizes. */
153 #define DECOMP_GLOBAL_SIZE_VAR_NAME "global_size"
154 
155 /* Name of var in decomp file that holds the length of the map for
156  * each task. */
157 #define DECOMP_MAPLEN_VAR_NAME "maplen"
158 
159 /* Name of var in decomp file that holds map. */
160 #define DECOMP_MAP_VAR_NAME "map"
161 
162 /* String used to indicate a decomposition file is in C
163  * array-order. */
164 #define DECOMP_C_ORDER_STR "C"
165 
166 /* String used to indicate a decomposition file is in Fortran
167  * array-order. */
168 #define DECOMP_FORTRAN_ORDER_STR "Fortran"
169 
170 #if defined( _PNETCDF) || defined(_NETCDF)
171 
172 #define PIO_GLOBAL NC_GLOBAL
173 #define PIO_UNLIMITED NC_UNLIMITED
174 
175 /* NetCDF types. */
176 #define PIO_NAT NC_NAT
177 #define PIO_BYTE NC_BYTE
178 #define PIO_CHAR NC_CHAR
179 #define PIO_SHORT NC_SHORT
180 #define PIO_INT NC_INT
181 #define PIO_FLOAT NC_FLOAT
182 #define PIO_REAL NC_FLOAT
183 #define PIO_DOUBLE NC_DOUBLE
184 #define PIO_UBYTE NC_UBYTE
185 #define PIO_USHORT NC_USHORT
186 #define PIO_UINT NC_UINT
187 #define PIO_INT64 NC_INT64
188 #define PIO_UINT64 NC_UINT64
189 #define PIO_STRING NC_STRING
190 
191 /* NetCDF flags. */
192 #define PIO_WRITE NC_WRITE
193 #define PIO_NOWRITE NC_NOWRITE
194 #define PIO_CLOBBER NC_CLOBBER
195 #define PIO_NOCLOBBER NC_NOCLOBBER
196 #define PIO_FILL NC_FILL
197 #define PIO_NOFILL NC_NOFILL
198 #define PIO_MAX_NAME_UB 1024
199 #if NC_MAX_NAME > PIO_MAX_NAME_UB
200 #define PIO_MAX_NAME PIO_MAX_NAME_UB
201 #else
202 #define PIO_MAX_NAME NC_MAX_NAME
203 #endif
204 #define PIO_MAX_VAR_DIMS_UB 1024
205 #if NC_MAX_VAR_DIMS > PIO_MAX_VAR_DIMS_UB
206 #define PIO_MAX_VAR_DIMS PIO_MAX_VAR_DIMS_UB
207 #else
208 #define PIO_MAX_VAR_DIMS NC_MAX_VAR_DIMS
209 #endif
210 #define PIO_64BIT_OFFSET NC_64BIT_OFFSET
211 #define PIO_64BIT_DATA NC_64BIT_DATA
212 
214 #define PIO_NOERR NC_NOERR
215 #define PIO_EBADID NC_EBADID
216 #define PIO_ENFILE NC_ENFILE
217 #define PIO_EEXIST NC_EEXIST
218 #define PIO_EINVAL NC_EINVAL
219 #define PIO_EPERM NC_EPERM
220 #define PIO_ENOTINDEFINE NC_ENOTINDEFINE
221 #define PIO_EINDEFINE NC_EINDEFINE
222 #define PIO_EINVALCOORDS NC_EINVALCOORDS
223 #define PIO_EMAXDIMS NC_EMAXDIMS
224 #define PIO_ENAMEINUSE NC_ENAMEINUSE
225 #define PIO_ENOTATT NC_ENOTATT
226 #define PIO_EMAXATTS NC_EMAXATTS
227 #define PIO_EBADTYPE NC_EBADTYPE
228 #define PIO_EBADDIM NC_EBADDIM
229 #define PIO_EUNLIMPOS NC_EUNLIMPOS
230 #define PIO_EMAXVARS NC_EMAXVARS
231 #define PIO_ENOTVAR NC_ENOTVAR
232 #define PIO_EGLOBAL NC_EGLOBAL
233 #define PIO_ENOTNC NC_ENOTNC
234 #define PIO_ESTS NC_ESTS
235 #define PIO_EMAXNAME NC_EMAXNAME
236 #define PIO_EUNLIMIT NC_EUNLIMIT
237 #define PIO_ENORECVARS NC_ENORECVARS
238 #define PIO_ECHAR NC_ECHAR
239 #define PIO_EEDGE NC_EEDGE
240 #define PIO_ESTRIDE NC_ESTRIDE
241 #define PIO_EBADNAME NC_EBADNAME
242 #define PIO_ERANGE NC_ERANGE
243 #define PIO_ENOMEM NC_ENOMEM
244 #define PIO_EVARSIZE NC_EVARSIZE
245 #define PIO_EDIMSIZE NC_EDIMSIZE
246 #define PIO_ETRUNC NC_ETRUNC
247 #define PIO_EAXISTYPE NC_EAXISTYPE
248 #define PIO_EDAP NC_EDAP
249 #define PIO_ECURL NC_ECURL
250 #define PIO_EIO NC_EIO
251 #define PIO_ENODATA NC_ENODATA
252 #define PIO_EDAPSVC NC_EDAPSVC
253 #define PIO_EDAS NC_EDAS
254 #define PIO_EDDS NC_EDDS
255 #define PIO_EDATADDS NC_EDATADDS
256 #define PIO_EDAPURL NC_EDAPURL
257 #define PIO_EDAPCONSTRAINT NC_EDAPCONSTRAINT
258 #define PIO_ETRANSLATION NC_ETRANSLATION
259 #define PIO_EHDFERR NC_EHDFERR
260 #define PIO_ECANTREAD NC_ECANTREAD
261 #define PIO_ECANTWRITE NC_ECANTWRITE
262 #define PIO_ECANTCREATE NC_ECANTCREATE
263 #define PIO_EFILEMETA NC_EFILEMETA
264 #define PIO_EDIMMETA NC_EDIMMETA
265 #define PIO_EATTMETA NC_EATTMETA
266 #define PIO_EVARMETA NC_EVARMETA
267 #define PIO_ENOCOMPOUND NC_ENOCOMPOUND
268 #define PIO_EATTEXISTS NC_EATTEXISTS
269 #define PIO_ENOTNC4 NC_ENOTNC4
270 #define PIO_ESTRICTNC3 NC_ESTRICTNC3
271 #define PIO_ENOTNC3 NC_ENOTNC3
272 #define PIO_ENOPAR NC_ENOPAR
273 #define PIO_EPARINIT NC_EPARINIT
274 #define PIO_EBADGRPID NC_EBADGRPID
275 #define PIO_EBADTYPID NC_EBADTYPID
276 #define PIO_ETYPDEFINED NC_ETYPDEFINED
277 #define PIO_EBADFIELD NC_EBADFIELD
278 #define PIO_EBADCLASS NC_EBADCLASS
279 #define PIO_EMAPTYPE NC_EMAPTYPE
280 #define PIO_ELATEFILL NC_ELATEFILL
281 #define PIO_ELATEDEF NC_ELATEDEF
282 #define PIO_EDIMSCALE NC_EDIMSCALE
283 #define PIO_ENOGRP NC_ENOGRP
284 #define PIO_ESTORAGE NC_ESTORAGE
285 #define PIO_EBADCHUNK NC_EBADCHUNK
286 #define PIO_ENOTBUILT NC_ENOTBUILT
287 #define PIO_EDISKLESS NC_EDISKLESS
288 
289 /* These are the netCDF default fill values. */
290 #define PIO_FILL_BYTE NC_FILL_BYTE
291 #define PIO_FILL_CHAR NC_FILL_CHAR
292 #define PIO_FILL_SHORT NC_FILL_SHORT
293 #define PIO_FILL_INT NC_FILL_INT
294 #define PIO_FILL_FLOAT NC_FILL_FLOAT
295 #define PIO_FILL_DOUBLE NC_FILL_DOUBLE
296 #define PIO_FILL_UBYTE NC_FILL_UBYTE
297 #define PIO_FILL_USHORT NC_FILL_USHORT
298 #define PIO_FILL_UINT NC_FILL_UINT
299 #define PIO_FILL_INT64 NC_FILL_INT64
300 #define PIO_FILL_UINT64 NC_FILL_UINT64
301 #endif /* defined( _PNETCDF) || defined(_NETCDF) */
302 
304 #ifdef _PNETCDF
305 #define PIO_EINDEP NC_EINDEP
306 #define PIO_REQ_NULL NC_REQ_NULL
307 #else /* _PNETCDF */
308 #define PIO_EINDEP (-203)
309 #define PIO_REQ_NULL (-1)
310 #endif /* _PNETCDF */
311 
313 #define PIO_FIRST_ERROR_CODE (-500)
314 #define PIO_EBADIOTYPE (-500)
315 #define PIO_EINTERNAL (-501)
316 
317 #ifdef _ADIOS2
319 #define PIO_EADIOSREAD (-300)
320 #define PIO_EADIOS2ERR (-301)
321 #endif
322 
323 #ifdef _HDF5
325 #define PIO_EHDF5ERR (-700)
326 #endif
327 
333 {
336 
339 };
340 
346 {
349 
352 
355 
358 };
359 
360 /* Constant to indicate unlimited requests. */
361 #define PIO_REARR_COMM_UNLIMITED_PEND_REQ -1
362 
366 typedef struct rearr_comm_fc_opt
367 {
369  bool hs;
370 
372  bool isend;
373 
382 
386 typedef struct rearr_opt
387 {
390 
392  int fcd;
393 
396 
400 
408 {
411 
414 
417 
420 
423 
426 
429 
432 
434  PIO_IOTYPE_HDF5C = 9
435 };
436 
441 {
444 
447 
450 
453 };
454 
459 {
462 
466 
469 
471  PIO_RETURN_ERROR = (-54)
472 };
473 
474 #include "pio_api.h"
475 
476 #endif // _PIO_H_
PIO_OFFSET_C_TYPENAME PIO_Offset
Definition: pio.h:82
struct rearr_opt rearr_opt_t
Rearranger options.
struct rearr_comm_fc_opt rearr_comm_fc_opt_t
Rearranger comm flow control options.
PIO_REARR_COMM_FC_DIR
Rearranger comm flow control direction.
Definition: pio.h:346
@ PIO_REARR_COMM_FC_2D_DISABLE
Disable flow control.
Definition: pio.h:357
@ PIO_REARR_COMM_FC_1D_IO2COMP
IO procs to comp procs only.
Definition: pio.h:354
@ PIO_REARR_COMM_FC_1D_COMP2IO
Comp procs to io procs only.
Definition: pio.h:351
@ PIO_REARR_COMM_FC_2D_ENABLE
Comp procs to io procs and vice versa.
Definition: pio.h:348
PIO_ERROR_HANDLERS
These are the supported error handlers.
Definition: pio.h:459
@ PIO_INTERNAL_ERROR
Errors cause abort.
Definition: pio.h:461
@ PIO_REDUCE_ERROR
Error codes are reduced across all processes.
Definition: pio.h:468
@ PIO_RETURN_ERROR
Errors are returned to caller with no internal action.
Definition: pio.h:471
@ PIO_BCAST_ERROR
Error codes from io process with rank 0 is broadcasted to all processes.
Definition: pio.h:465
PIO_IOTYPE
These are the supported methods of reading/writing input/output files.
Definition: pio.h:408
@ PIO_IOTYPE_NETCDF4P_NCZARR
NetCDF library (Parallel I/O, NCZarr file format)
Definition: pio.h:422
@ PIO_IOTYPE_NETCDF4P
NetCDF library (Parallel I/O, NetCDF4/HDF5 file format)
Definition: pio.h:419
@ PIO_IOTYPE_HDF5
HDF5 library (Parallel I/O, NetCDF4/HDF5 file format)
Definition: pio.h:431
@ PIO_IOTYPE_NETCDF4C
NetCDF library (Serial I/O, NetCDF4/HDF5 compressed file format)
Definition: pio.h:416
@ PIO_IOTYPE_HDF5C
HDF5 library (Parallel I/O, NetCDF4/HDF5 compressed file format)
Definition: pio.h:434
@ PIO_IOTYPE_ADIOS
ADIOS library (Parallel I/O, ADIOS BP file format)
Definition: pio.h:425
@ PIO_IOTYPE_ADIOSC
ADIOS library (Parallel I/O, ADIOS BP compressed file format)
Definition: pio.h:428
@ PIO_IOTYPE_NETCDF
NetCDF library (Serial I/O, NetCDF3 classic file format)
Definition: pio.h:413
@ PIO_IOTYPE_PNETCDF
Parallel NetCDF library (Parallel I/O, NetCDF3 classic file format)
Definition: pio.h:410
PIO_REARRANGERS
These are the supported output data rearrangement methods.
Definition: pio.h:441
@ PIO_REARR_CONTIG
Contig rearranger (data aggregation + contiguous data)
Definition: pio.h:452
@ PIO_REARR_BOX
Box rearranger.
Definition: pio.h:443
@ PIO_REARR_SUBSET
Subset rearranger.
Definition: pio.h:446
@ PIO_REARR_ANY
Let the library choose the rearranger.
Definition: pio.h:449
PIO_REARR_COMM_TYPE
Rearranger comm type.
Definition: pio.h:333
@ PIO_REARR_COMM_COLL
Collective.
Definition: pio.h:338
@ PIO_REARR_COMM_P2P
Point to point.
Definition: pio.h:335
Rearranger comm flow control options.
Definition: pio.h:367
bool isend
Enable isends - if false use blocking sends.
Definition: pio.h:372
bool hs
Enable handshake.
Definition: pio.h:369
int max_pend_req
Max pending requests (PIO_REARR_COMM_UNLIMITED_PEND_REQ => unlimited pend req).
Definition: pio.h:380
Rearranger options.
Definition: pio.h:387
int comm_type
Comm type - see PIO_REARR_COMM_TYPE.
Definition: pio.h:389
int fcd
Comm flow control dir - see PIO_REARR_COMM_FC_DIR.
Definition: pio.h:392
rearr_comm_fc_opt_t io2comp
flow control opts, io to comp procs
Definition: pio.h:398
rearr_comm_fc_opt_t comp2io
flow control opts, comp to io procs
Definition: pio.h:395