SCORPIO  1.7.0
pio.h
Go to the documentation of this file.
1 
10 #ifndef _PIO_H_
11 #define _PIO_H_
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <stdbool.h>
15 #include <string.h> /* memcpy */
16 
17 #ifdef MPI_SERIAL
18 #if defined(__cplusplus)
19 extern "C" {
20 #endif
21 #endif
22 
23 #include <mpi.h>
24 
25 #ifdef MPI_SERIAL
26 #if defined(__cplusplus)
27 }
28 #endif
29 #endif
30 
31 #include "pio_config.h"
32 #if PIO_USE_PNETCDF
33  #define _PNETCDF 1
34 #endif
35 #if PIO_USE_NETCDF
36  #define _NETCDF 1
37  #if PIO_USE_NETCDF4
38  #define _NETCDF4 1
39  #endif
40 #endif
41 #if PIO_USE_ADIOS
42  #define _ADIOS2 1
43 #endif
44 #if PIO_USE_HDF5
45  #define _HDF5 1
46 #endif
47 #if PIO_USE_MICRO_TIMING
48  #define PIO_MICRO_TIMING 1
49 #endif
50 #if PIO_ENABLE_IO_STATS
51  #define SPIO_IO_STATS 1
52 #endif
53 
54 #ifdef _NETCDF
55 #include <netcdf.h>
56 #ifdef _NETCDF4
57 #include <netcdf_par.h>
58 #endif
59 #endif
60 #ifdef _PNETCDF
61 #include <pnetcdf.h>
62 #endif
63 
64 #ifdef _ADIOS2
65 #include <sys/types.h>
66 #include <sys/stat.h>
67 #include <unistd.h>
68 #include <limits.h>
69 #include <adios2_c.h>
70 
71 #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 */
72 #define BLOCK_MAX_BUFFER ((unsigned long)INT_MAX) /* 2GB limit of MPI_Gatherv */
73 /* adios end step is called if the number of blocks written out exceeds BLOCK_COUNT_THRESHOLD */
74 #define BLOCK_COUNT_THRESHOLD ((unsigned long)(1024 * 1024 * 1024 * 1.9))
75 #define BLOCK_METADATA_SIZE 70 /* Size of adios block metadata */
76 
77 #endif
78 #ifdef _HDF5
79 #include <hdf5.h>
80 #include <hdf5_hl.h>
81 #include <unistd.h>
82 #endif
83 
84 /* PIO_OFFSET_C_TYPENAME is defined in pio_config.h */
85 typedef PIO_OFFSET_C_TYPENAME PIO_Offset;
86 
87 /* The MPI typename corresponding to PIO_Offset, PIO_OFFSET, is defined in pio_config.h */
88 
90 #define PIO_IODESC_START_ID 512
91 #define PIO_IODESC_MAX_IDS 65536
92 
94 #define PIO_MAX_VARS_UB 8192
95 #if NC_MAX_VARS > PIO_MAX_VARS_UB
96 #define PIO_MAX_VARS PIO_MAX_VARS_UB
97 #else
98 #define PIO_MAX_VARS NC_MAX_VARS
99 #endif
100 
102 #define PIO_MAX_DIMS_UB 1024
103 #if NC_MAX_DIMS > PIO_MAX_DIMS_UB
104 #define PIO_MAX_DIMS PIO_MAX_DIMS_UB
105 #else
106 #define PIO_MAX_DIMS NC_MAX_DIMS
107 #endif
108 
110 #define PIO_MAX_ATTRS_UB 8192
111 #if NC_MAX_ATTRS > PIO_MAX_ATTRS_UB
112 #define PIO_MAX_ATTRS PIO_MAX_ATTRS_UB
113 #else
114 #define PIO_MAX_ATTRS NC_MAX_ATTRS
115 #endif
116 
119 #define PIO_DEFAULT (-1)
120 
123 /* Holds the version of the decomposition file. */
124 #define DECOMP_VERSION_ATT_NAME "version"
125 
126 /* Holds the maximum length of any task map. */
127 #define DECOMP_MAX_MAPLEN_ATT_NAME "max_maplen"
128 
129 /* Name of title attribute. */
130 #define DECOMP_TITLE_ATT_NAME "title"
131 
132 /* Name of history attribute. */
133 #define DECOMP_HISTORY_ATT_NAME "history"
134 
135 /* Name of source attribute. */
136 #define DECOMP_SOURCE_ATT_NAME "source"
137 
138 /* Name of array order (C or Fortran) attribute. */
139 #define DECOMP_ORDER_ATT_NAME "array_order"
140 
141 /* Name of backtrace attribute. */
142 #define DECOMP_BACKTRACE_ATT_NAME "backtrace"
143 
144 /* Name for the dim dim in decomp file. */
145 #define DECOMP_DIM_DIM "dims"
146 
147 /* Name for the npes dim in decomp file. */
148 #define DECOMP_TASK_DIM_NAME "task"
149 
150 /* Name for the npes dim in decomp file. */
151 #define DECOMP_MAPELEM_DIM_NAME "map_element"
152 
153 #define DECOMP_NDIMS "ndims"
154 
155 /* Name of var in decomp file that holds global array sizes. */
156 #define DECOMP_GLOBAL_SIZE_VAR_NAME "global_size"
157 
158 /* Name of var in decomp file that holds the length of the map for
159  * each task. */
160 #define DECOMP_MAPLEN_VAR_NAME "maplen"
161 
162 /* Name of var in decomp file that holds map. */
163 #define DECOMP_MAP_VAR_NAME "map"
164 
165 /* String used to indicate a decomposition file is in C
166  * array-order. */
167 #define DECOMP_C_ORDER_STR "C"
168 
169 /* String used to indicate a decomposition file is in Fortran
170  * array-order. */
171 #define DECOMP_FORTRAN_ORDER_STR "Fortran"
172 
173 #if defined( _PNETCDF) || defined(_NETCDF)
174 
175 #define PIO_GLOBAL NC_GLOBAL
176 #define PIO_UNLIMITED NC_UNLIMITED
177 
178 /* NetCDF types. */
179 #define PIO_NAT NC_NAT
180 #define PIO_BYTE NC_BYTE
181 #define PIO_CHAR NC_CHAR
182 #define PIO_SHORT NC_SHORT
183 #define PIO_INT NC_INT
184 #define PIO_FLOAT NC_FLOAT
185 #define PIO_REAL NC_FLOAT
186 #define PIO_DOUBLE NC_DOUBLE
187 #define PIO_UBYTE NC_UBYTE
188 #define PIO_USHORT NC_USHORT
189 #define PIO_UINT NC_UINT
190 #define PIO_INT64 NC_INT64
191 #define PIO_UINT64 NC_UINT64
192 #define PIO_STRING NC_STRING
193 
194 /* NetCDF flags. */
195 #define PIO_WRITE NC_WRITE
196 #define PIO_NOWRITE NC_NOWRITE
197 #define PIO_CLOBBER NC_CLOBBER
198 #define PIO_NOCLOBBER NC_NOCLOBBER
199 #define PIO_FILL NC_FILL
200 #define PIO_NOFILL NC_NOFILL
201 #define PIO_MAX_NAME_UB 1024
202 #if NC_MAX_NAME > PIO_MAX_NAME_UB
203 #define PIO_MAX_NAME PIO_MAX_NAME_UB
204 #else
205 #define PIO_MAX_NAME NC_MAX_NAME
206 #endif
207 #define PIO_MAX_VAR_DIMS_UB 1024
208 #if NC_MAX_VAR_DIMS > PIO_MAX_VAR_DIMS_UB
209 #define PIO_MAX_VAR_DIMS PIO_MAX_VAR_DIMS_UB
210 #else
211 #define PIO_MAX_VAR_DIMS NC_MAX_VAR_DIMS
212 #endif
213 #define PIO_64BIT_OFFSET NC_64BIT_OFFSET
214 #define PIO_64BIT_DATA NC_64BIT_DATA
215 
217 #define PIO_NOERR NC_NOERR
218 #define PIO_EBADID NC_EBADID
219 #define PIO_ENFILE NC_ENFILE
220 #define PIO_EEXIST NC_EEXIST
221 #define PIO_EINVAL NC_EINVAL
222 #define PIO_EPERM NC_EPERM
223 #define PIO_ENOTINDEFINE NC_ENOTINDEFINE
224 #define PIO_EINDEFINE NC_EINDEFINE
225 #define PIO_EINVALCOORDS NC_EINVALCOORDS
226 #define PIO_EMAXDIMS NC_EMAXDIMS
227 #define PIO_ENAMEINUSE NC_ENAMEINUSE
228 #define PIO_ENOTATT NC_ENOTATT
229 #define PIO_EMAXATTS NC_EMAXATTS
230 #define PIO_EBADTYPE NC_EBADTYPE
231 #define PIO_EBADDIM NC_EBADDIM
232 #define PIO_EUNLIMPOS NC_EUNLIMPOS
233 #define PIO_EMAXVARS NC_EMAXVARS
234 #define PIO_ENOTVAR NC_ENOTVAR
235 #define PIO_EGLOBAL NC_EGLOBAL
236 #define PIO_ENOTNC NC_ENOTNC
237 #define PIO_ESTS NC_ESTS
238 #define PIO_EMAXNAME NC_EMAXNAME
239 #define PIO_EUNLIMIT NC_EUNLIMIT
240 #define PIO_ENORECVARS NC_ENORECVARS
241 #define PIO_ECHAR NC_ECHAR
242 #define PIO_EEDGE NC_EEDGE
243 #define PIO_ESTRIDE NC_ESTRIDE
244 #define PIO_EBADNAME NC_EBADNAME
245 #define PIO_ERANGE NC_ERANGE
246 #define PIO_ENOMEM NC_ENOMEM
247 #define PIO_EVARSIZE NC_EVARSIZE
248 #define PIO_EDIMSIZE NC_EDIMSIZE
249 #define PIO_ETRUNC NC_ETRUNC
250 #define PIO_EAXISTYPE NC_EAXISTYPE
251 #define PIO_EDAP NC_EDAP
252 #define PIO_ECURL NC_ECURL
253 #define PIO_EIO NC_EIO
254 #define PIO_ENODATA NC_ENODATA
255 #define PIO_EDAPSVC NC_EDAPSVC
256 #define PIO_EDAS NC_EDAS
257 #define PIO_EDDS NC_EDDS
258 #define PIO_EDATADDS NC_EDATADDS
259 #define PIO_EDAPURL NC_EDAPURL
260 #define PIO_EDAPCONSTRAINT NC_EDAPCONSTRAINT
261 #define PIO_ETRANSLATION NC_ETRANSLATION
262 #define PIO_EHDFERR NC_EHDFERR
263 #define PIO_ECANTREAD NC_ECANTREAD
264 #define PIO_ECANTWRITE NC_ECANTWRITE
265 #define PIO_ECANTCREATE NC_ECANTCREATE
266 #define PIO_EFILEMETA NC_EFILEMETA
267 #define PIO_EDIMMETA NC_EDIMMETA
268 #define PIO_EATTMETA NC_EATTMETA
269 #define PIO_EVARMETA NC_EVARMETA
270 #define PIO_ENOCOMPOUND NC_ENOCOMPOUND
271 #define PIO_EATTEXISTS NC_EATTEXISTS
272 #define PIO_ENOTNC4 NC_ENOTNC4
273 #define PIO_ESTRICTNC3 NC_ESTRICTNC3
274 #define PIO_ENOTNC3 NC_ENOTNC3
275 #define PIO_ENOPAR NC_ENOPAR
276 #define PIO_EPARINIT NC_EPARINIT
277 #define PIO_EBADGRPID NC_EBADGRPID
278 #define PIO_EBADTYPID NC_EBADTYPID
279 #define PIO_ETYPDEFINED NC_ETYPDEFINED
280 #define PIO_EBADFIELD NC_EBADFIELD
281 #define PIO_EBADCLASS NC_EBADCLASS
282 #define PIO_EMAPTYPE NC_EMAPTYPE
283 #define PIO_ELATEFILL NC_ELATEFILL
284 #define PIO_ELATEDEF NC_ELATEDEF
285 #define PIO_EDIMSCALE NC_EDIMSCALE
286 #define PIO_ENOGRP NC_ENOGRP
287 #define PIO_ESTORAGE NC_ESTORAGE
288 #define PIO_EBADCHUNK NC_EBADCHUNK
289 #define PIO_ENOTBUILT NC_ENOTBUILT
290 #define PIO_EDISKLESS NC_EDISKLESS
291 
292 /* These are the netCDF default fill values. */
293 #define PIO_FILL_BYTE NC_FILL_BYTE
294 #define PIO_FILL_CHAR NC_FILL_CHAR
295 #define PIO_FILL_SHORT NC_FILL_SHORT
296 #define PIO_FILL_INT NC_FILL_INT
297 #define PIO_FILL_FLOAT NC_FILL_FLOAT
298 #define PIO_FILL_DOUBLE NC_FILL_DOUBLE
299 #define PIO_FILL_UBYTE NC_FILL_UBYTE
300 #define PIO_FILL_USHORT NC_FILL_USHORT
301 #define PIO_FILL_UINT NC_FILL_UINT
302 #define PIO_FILL_INT64 NC_FILL_INT64
303 #define PIO_FILL_UINT64 NC_FILL_UINT64
304 #endif /* defined( _PNETCDF) || defined(_NETCDF) */
305 
307 #ifdef _PNETCDF
308 #define PIO_EINDEP NC_EINDEP
309 #define PIO_REQ_NULL NC_REQ_NULL
310 #else /* _PNETCDF */
311 #define PIO_EINDEP (-203)
312 #define PIO_REQ_NULL (-1)
313 #endif /* _PNETCDF */
314 
316 #define PIO_FIRST_ERROR_CODE (-500)
317 #define PIO_EBADIOTYPE (-500)
318 #define PIO_EINTERNAL (-501)
319 
320 #ifdef _ADIOS2
322 #define PIO_EADIOSREAD (-300)
323 #define PIO_EADIOS2ERR (-301)
324 #endif
325 
326 #ifdef _HDF5
328 #define PIO_EHDF5ERR (-700)
329 #endif
330 
331 #ifdef PIO_MICRO_TIMING
333 typedef struct mtimer_info *mtimer_t;
334 #endif
335 
336 /* Forward decl of hash map used for ADIOS reads */
337 struct spio_hmap;
338 
342 typedef struct var_desc_t
343 {
344  /* Variable ID. */
345  int varid;
346 
347  /* Variable name - cached */
348  char vname[PIO_MAX_NAME + 1];
349 
350  /* Variable description */
351  char vdesc[PIO_MAX_NAME + 1];
352 
353  /* Non-zero if this is a record var (i.e. uses unlimited
354  * dimension). */
355  int rec_var;
356 
357  /* Number of dimensions for this variable - cached data */
358  int ndims;
359 
362  int record;
363 
366  int *request;
367 
370 
372  int nreqs;
373 
374  /* Holds the fill value of this var. */
375  void *fillvalue;
376 
377  /* The PIO data type (PIO_INT, PIO_FLOAT, etc.) */
378  int pio_type;
379 
380  /* The size of the data type (2 for PIO_SHORT, 4 for PIO_INT, etc.) */
382 
383  /* Size of one record of the variable (number of bytes)*/
385 
386  /* Bytes pending to be read */
388 
389  /* Bytes pending to be written out */
391 
392 #ifdef PIO_MICRO_TIMING
393  mtimer_t rd_mtimer;
394  mtimer_t rd_rearr_mtimer;
395 
396  mtimer_t wr_mtimer;
397  mtimer_t wr_rearr_mtimer;
398 #endif
399 
401  int use_fill;
402 
405  void *fillbuf;
407 
420 typedef struct io_region
421 {
424  int loffset;
425 
428 
431 
433  struct io_region *next;
435 
441 {
444 
447 };
448 
454 {
457 
460 
463 
466 };
467 
468 /* Constant to indicate unlimited requests. */
469 #define PIO_REARR_COMM_UNLIMITED_PEND_REQ -1
470 
474 typedef struct rearr_comm_fc_opt
475 {
477  bool hs;
478 
480  bool isend;
481 
490 
494 typedef struct rearr_opt
495 {
498 
500  int fcd;
501 
504 
508 
515 typedef struct io_desc_t
516 {
518  int ioid;
519 
521  int maplen;
522 
526 
529  int nrecvs;
530 
532  int ndof;
533 
536  int ndims;
537 
539  int *dimlen;
540 
543 
546 
549 
552  bool needsfill;
553 
555  int maxbytes;
556 
558  int piotype;
559 
562 
564  MPI_Datatype mpitype;
565 
568 
575 
578 
580  int *rfrom;
581 
584  int *rcount;
585 
588  int *scount;
589 
593 
596 
598  MPI_Datatype *rtype;
599 
601  MPI_Datatype *stype;
602 
605 
608 
611 
614 
617 
620 
625 
629  MPI_Comm subset_comm;
630 
631 #if PIO_SAVE_DECOMPS
632  /* Indicates whether this iodesc has been saved to disk (the
633  * decomposition is dumped to disk)
634  */
635  bool is_saved;
636 #endif
637 
639  struct io_desc_t *next;
641 
642 /* Forward decl for I/O file summary stats info */
643 struct spio_io_fstats_summary;
644 
651 typedef struct iosystem_desc_t
652 {
655  int iosysid;
656 
657  /* I/O System name */
658  char sname[PIO_MAX_NAME + 1];
659 
662  MPI_Comm union_comm;
663 
666  MPI_Comm io_comm;
667 
670  MPI_Comm comp_comm;
671 
674  MPI_Comm intercomm;
675 
678  MPI_Comm my_comm;
679 
682  MPI_Group compgroup;
683 
685  MPI_Group iogroup;
686 
689 
692 
697 
700 
704 
707  int io_rank;
708 
711  int iomaster;
712 
716 
719  int ioroot;
720 
724  int comproot;
725 
728  int *ioranks;
729 
732  int *compranks;
733 
736 
740 
742  bool async;
743 
745  bool ioproc;
746 
749  bool compproc;
750 
752  MPI_Info info;
753 
756  int seq_num;
757  int prev_msg;
759 
761  int comp_idx;
762 
765 
766 #ifdef _ADIOS2
767  /* ADIOS handles */
768  adios2_adios *adiosH; /* Handle for ADIOS write */
769  adios2_adios *adios_readerH; /* Handle for ADIOS read */
770  int adios_io_process;
771  MPI_Comm adios_comm;
772  int adios_rank, num_adiostasks;
773  /* Block merging setup */
774  MPI_Comm block_comm;
775  int block_myrank, block_nprocs;
776  #ifdef _SPIO_ADIOS_USE_COMPRESSION
777  /* ADIOS operator for applying a specific lossless compression method (e.g., Blosc2, BZip2) */
778  adios2_operator* lossless_compression_operator;
779  int adios_lossless_compression_method;
780  #ifdef _SPIO_ADIOS_USE_LOSSY_COMPRESSION
781  /* ADIOS operator for applying a specific lossy compression method (e.g., SZ, MGARD, ZFP) */
782  adios2_operator* lossy_compression_operator;
783  int adios_lossy_compression_method;
784  #endif
785  #endif
786 #endif
787 
789  struct spio_io_fstats_summary *io_fstats;
790 
794 
799 typedef struct wmulti_buffer
800 {
803  int ioid;
804 
807 
812 
815  int arraylen;
816 
818  int *vid;
819 
822  int *frame;
823 
825  void *fillvalue;
826 
828  void *data;
829 
833 
834 #ifdef _ADIOS2
835 /* Interval map for ADIOS read */
836 typedef struct adios_interval_map_t
837 {
838  int n_adios_steps;
839  short **map;
840 } adios_interval_map_t;
841 
842 /* Maximum char array length to store "darray" or "put_var", for ADIOS read */
843 #define NC_OP_TAG_MAX_LEN 8
844 
849 typedef struct adios_var_desc_t
850 {
852  char * name;
853 
855  int nc_type;
856 
858  adios2_type adios_type;
859  size_t adios_type_size;
860 
862  int ndims;
863 
865  int * gdimids;
866 
868  int nattrs;
869 
873  adios2_variable* adios_varid; // 0: undefined yet
874 
875  /* to handle PIOc_setframe with different decompositions */
876  adios2_variable* decomp_varid;
877  adios2_variable* frame_varid;
878  adios2_variable* fillval_varid;
879  adios2_variable* num_block_writers_varid;
880 
881  /* to handle multi-dimensional temporal variables */
882  adios2_variable* start_varid;
883  adios2_variable* count_varid;
884 
885  /* to buffer decomp id, frame id, fill value, and writer blocks */
886  int32_t *decomp_buffer;
887  int32_t *frame_buffer;
888  char *fillval_buffer;
889  int32_t fillval_size;
890  int32_t *num_wb_buffer;
891  int32_t decomp_cnt, frame_cnt, fillval_cnt, num_wb_cnt;
892  int32_t max_buffer_cnt;
893 
894  /* Simplified version of an interval map implementation
895  * index is a frame_id and the value is the adios_step */
896  adios_interval_map_t* interval_map; /* For ADIOS read */
897 
898  /* Is this variable written with put_var or darray? */
899  char nc_op_tag[NC_OP_TAG_MAX_LEN]; /* For ADIOS read */
900 } adios_var_desc_t;
901 
902 /* Track attributes */
903 typedef struct adios_att_desc_t
904 {
906  char *att_name;
907 
909  nc_type att_type;
910 
912  PIO_Offset att_len;
913 
915  int att_ncid;
916 
918  int att_varid;
919 
921  adios2_type adios_type;
922 } adios_att_desc_t;
923 
924 #ifdef _SPIO_ADIOS_USE_COMPRESSION
925 enum ADIOS_COMPRESSION_METHOD
926 {
927  ADIOS_COMPRESSION_METHOD_BLOSC2 = 1,
928 
929  ADIOS_COMPRESSION_METHOD_BZIP2 = 2,
930 
931  ADIOS_COMPRESSION_METHOD_MGARD = 3,
932 
933  ADIOS_COMPRESSION_METHOD_SZ = 4,
934 
935  ADIOS_COMPRESSION_METHOD_ZFP = 5
936 };
937 #endif
938 #endif /* _ADIOS2 */
939 
940 #ifdef _HDF5
941 typedef struct hdf5_dim_desc_t
942 {
944  char* name;
945 
947  PIO_Offset len;
948 
950  bool has_coord_var;
951 
952  hid_t hdf5_dataset_id;
953 } hdf5_dim_desc_t;
954 
955 typedef struct hdf5_var_desc_t
956 {
958  char* name;
959 
960  /* Alternative name for a non-coordinate variable with the same name as a dimension */
961  char* alt_name;
962 
964  int nc_type;
965 
967  hid_t hdf5_type;
968 
970  int ndims;
971 
973  int* hdf5_dimids;
974 
976  bool is_coord_var;
977 
978  hid_t hdf5_dataset_id;
979 } hdf5_var_desc_t;
980 
981 typedef struct hdf5_att_desc_t
982 {
984  char *att_name;
985 
987  nc_type att_type;
988 
990  PIO_Offset att_len;
991 
993  int att_ncid;
994 
996  int att_varid;
997 } hdf5_att_desc_t;
998 #endif
999 
1005 typedef struct file_desc_t
1006 {
1009 
1012  int fh;
1013 
1014 #ifdef _ADIOS2
1016  char *filename;
1017 
1019  adios2_engine *engineH;
1020 
1022  int begin_step_called;
1023  int num_step_calls;;
1024  int max_step_calls;
1025 
1026  /*
1027  * Used to call adios2_end_step to avoid buffer overflow in MPI_Gatherv
1028  * during ADIOS metadata write operation.
1029  *
1030  * if num_written_blocks * BLOCK_METADATA_SIZE >= BLOCK_COUNT_THRESHOLD, call adios2_end_step
1031  * (Not implemented in this version. adios2_end_step is called if num_step_calls >= max_step_calls (= PIO_MAX_CACHED_STEPS_FOR_ADIOS))
1032  */
1033  unsigned int num_written_blocks;
1034 
1035  int write_decomp_id;
1036  int write_frame_id;
1037  int write_fillval_id;
1038 
1040  adios2_io *ioH;
1041 
1043  char transport[PIO_MAX_NAME];
1044 
1047  char params[PIO_MAX_NAME];
1048 
1050  char *dim_names[PIO_MAX_DIMS];
1051  PIO_Offset dim_values[PIO_MAX_DIMS];
1052 
1054  int num_dim_vars;
1055 
1057  struct adios_var_desc_t adios_vars[PIO_MAX_VARS];
1058 
1060  int num_vars;
1061 
1063  int num_gattrs;
1064 
1065  /* all procs rank, etc */
1066  MPI_Comm all_comm;
1067  int all_rank, num_alltasks;
1068 
1069  /* ADIOS rank, etc */
1070  int adios_io_process;
1071  MPI_Comm adios_comm;
1072  int adios_rank, num_adiostasks;
1073 
1074  /* Merging distributed array blocks to reduce I/O overhead */
1075  /* Grouping of processes for block merging */
1076  MPI_Comm block_comm;
1077  int block_myrank, block_nprocs;
1078  int *block_list;
1079 
1080  /* Buffers for merging distributed array blocks */
1081  unsigned int *array_counts;
1082  unsigned int array_counts_size;
1083  unsigned int *array_disp;
1084  unsigned int array_disp_size;
1085  char *block_array;
1086  size_t block_array_size;
1087 
1088  /* Track attributes */
1090  struct adios_att_desc_t adios_attrs[PIO_MAX_ATTRS];
1091  int num_attrs;
1092 
1093  int fillmode;
1094 
1095  /* Handle PIO_Offset */
1096  int pio_offset_size;
1097  adios2_type pio_offset_type;
1098 
1100  int n_written_ioids;
1101  int written_ioids[PIO_MAX_ADIOS_DECOMPS]; /* written_ioids[N] = ioid if that decomp has been already written, */
1102 
1104  int current_frame;
1105 
1106  /* Some caches (hash tables) for ADIOS read */
1107  struct spio_hmap *cache_data_blocks;
1108  struct spio_hmap *cache_block_sizes;
1109  struct spio_hmap *cache_darray_info;
1110 
1111  char io_name_reader[PIO_MAX_NAME + 1]; /* Name of io object, for ADIOS read */
1112  size_t adios_reader_num_decomp_blocks; /* Number of decomposition blocks, for ADIOS read */
1113 
1114  /* Indicates whether the decomposition maps (for ADIOS write) need to be stored in BP files. Default is true. */
1115  bool store_adios_decomp;
1116 #endif /* _ADIOS2 */
1117 
1118 #ifdef _HDF5
1119  hid_t hdf5_file_id;
1120 
1121  /* Collective dataset transfer property list, used by H5Dwrite */
1122  hid_t dxplid_coll;
1123 
1124  /* Independent dataset transfer property list, used by H5Dwrite */
1125  hid_t dxplid_indep;
1126 
1127  struct hdf5_dim_desc_t hdf5_dims[PIO_MAX_DIMS];
1128 
1130  int hdf5_num_dims;
1131 
1132  struct hdf5_var_desc_t hdf5_vars[PIO_MAX_VARS];
1133 
1135  int hdf5_num_vars;
1136 
1137  struct hdf5_att_desc_t hdf5_attrs[PIO_MAX_ATTRS];
1138 
1140  int hdf5_num_attrs;
1141 
1143  int hdf5_num_gattrs;
1144 #endif /* _HDF5 */
1145 
1146  /* File name - cached */
1147  char fname[PIO_MAX_NAME + 1];
1148 
1151 
1153  int iotype;
1154 
1157 
1158  /* Number of unlimited dim ids, if no unlimited id present = 0 */
1160 
1161  /* Unlimited dim ids, if no unlimited id present = NULL */
1163 
1165  int mode;
1166 
1169  struct wmulti_buffer buffer;
1170 
1171  /* Bytes pending to be read on this file*/
1173 
1174  /* Bytes pending to be written out for this file */
1176 
1181  void *mvcache;
1182 
1184  struct spio_io_fstats_summary *io_fstats;
1185 
1188 
1191  int do_io;
1192 
1197 
1203 {
1206 
1209 
1212 
1215 
1218 
1221 
1224 
1226  PIO_IOTYPE_HDF5 = 8
1227 };
1228 
1233 {
1236 
1239 
1241  PIO_REARR_ANY = 3
1242 };
1243 
1248 {
1251 
1255 
1258 
1260  PIO_RETURN_ERROR = (-54)
1261 };
1262 
1263 #include "pio_api.h"
1264 
1265 #endif // _PIO_H_
struct wmulti_buffer wmulti_buffer
The multi buffer holds data from one or more variables.
PIO_OFFSET_C_TYPENAME PIO_Offset
Definition: pio.h:85
#define PIO_MAX_DIMS
Definition: pio.h:106
struct rearr_opt rearr_opt_t
Rearranger options.
struct io_desc_t io_desc_t
IO descriptor structure.
struct file_desc_t file_desc_t
File descriptor structure.
#define PIO_MAX_ATTRS
Definition: pio.h:114
struct iosystem_desc_t iosystem_desc_t
IO system descriptor structure.
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:454
@ PIO_REARR_COMM_FC_2D_DISABLE
Disable flow control.
Definition: pio.h:465
@ PIO_REARR_COMM_FC_1D_IO2COMP
IO procs to comp procs only.
Definition: pio.h:462
@ PIO_REARR_COMM_FC_1D_COMP2IO
Comp procs to io procs only.
Definition: pio.h:459
@ PIO_REARR_COMM_FC_2D_ENABLE
Comp procs to io procs and vice versa.
Definition: pio.h:456
PIO_ERROR_HANDLERS
These are the supported error handlers.
Definition: pio.h:1248
@ PIO_INTERNAL_ERROR
Errors cause abort.
Definition: pio.h:1250
@ PIO_REDUCE_ERROR
Error codes are reduced across all processes.
Definition: pio.h:1257
@ PIO_RETURN_ERROR
Errors are returned to caller with no internal action.
Definition: pio.h:1260
@ PIO_BCAST_ERROR
Error codes from io process with rank 0 is broadcasted to all processes.
Definition: pio.h:1254
PIO_IOTYPE
These are the supported methods of reading/writing netCDF files.
Definition: pio.h:1203
@ PIO_IOTYPE_NETCDF4P_NCZARR
NetCDF4 (HDF5) parallel NCZarr.
Definition: pio.h:1217
@ PIO_IOTYPE_NETCDF4P
NetCDF4 (HDF5) parallel.
Definition: pio.h:1214
@ PIO_IOTYPE_HDF5
HDF5 parallel.
Definition: pio.h:1226
@ PIO_IOTYPE_NETCDF4C
NetCDF4 (HDF5) compressed format (serial)
Definition: pio.h:1211
@ PIO_IOTYPE_ADIOS
ADIOS parallel.
Definition: pio.h:1220
@ PIO_IOTYPE_ADIOSC
ADIOS parallel with compression.
Definition: pio.h:1223
@ PIO_IOTYPE_NETCDF
Netcdf3 Classic format (serial)
Definition: pio.h:1208
@ PIO_IOTYPE_PNETCDF
Parallel Netcdf (parallel)
Definition: pio.h:1205
PIO_REARRANGERS
These are the supported output data rearrangement methods.
Definition: pio.h:1233
@ PIO_REARR_BOX
Box rearranger.
Definition: pio.h:1235
@ PIO_REARR_SUBSET
Subset rearranger.
Definition: pio.h:1238
@ PIO_REARR_ANY
Let the library choose the rearranger.
Definition: pio.h:1241
PIO_REARR_COMM_TYPE
Rearranger comm type.
Definition: pio.h:441
@ PIO_REARR_COMM_COLL
Collective.
Definition: pio.h:446
@ PIO_REARR_COMM_P2P
Point to point.
Definition: pio.h:443
struct var_desc_t var_desc_t
Variable description structure.
#define PIO_MAX_VARS
Definition: pio.h:98
struct io_region io_region
IO region structure.
File descriptor structure.
Definition: pio.h:1006
iosystem_desc_t * iosystem
The IO system ID used to open this file.
Definition: pio.h:1008
char fname[PIO_MAX_NAME+1]
Definition: pio.h:1147
PIO_Offset rb_pend
Definition: pio.h:1172
int do_io
True if this task should participate in IO (only true for one task with netcdf serial files.
Definition: pio.h:1191
int num_unlim_dimids
Definition: pio.h:1159
int iotype
The PIO_TYPE value that was used to open this file.
Definition: pio.h:1153
bool reserve_extra_header_space
True if we need reserve some extra space in the header when creating NetCDF files to accommodate anti...
Definition: pio.h:1195
int mode
Mode used when file was opened.
Definition: pio.h:1165
int pio_ncid
The ncid that will be returned to the user.
Definition: pio.h:1150
int * unlim_dimids
Definition: pio.h:1162
struct wmulti_buffer buffer
The wmulti_buffer is used to aggregate multiple variables with the same communication pattern prior t...
Definition: pio.h:1169
int fh
The ncid returned for this file by the underlying library (netcdf or pnetcdf).
Definition: pio.h:1012
struct spio_io_fstats_summary * io_fstats
I/O statistics associated with this file.
Definition: pio.h:1184
PIO_Offset wb_pend
Definition: pio.h:1175
struct var_desc_t varlist[PIO_MAX_VARS]
List of variables in this file (deprecated).
Definition: pio.h:1156
struct file_desc_t * next
Pointer to the next file_desc_t in the list of open files.
Definition: pio.h:1187
void * mvcache
Data buffer per IO decomposition for this file.
Definition: pio.h:1181
IO descriptor structure.
Definition: pio.h:516
int rearranger
The rearranger in use for this variable.
Definition: pio.h:545
io_region * firstregion
Linked list of regions.
Definition: pio.h:616
io_region * fillregion
Used when writing fill data.
Definition: pio.h:619
PIO_Offset * rindex
Index for the IO tasks (receive side during writes).
Definition: pio.h:595
int ndims
All vars included in this io_desc_t have the same number of dimensions.
Definition: pio.h:536
int ioid
The ID of this io_desc_t.
Definition: pio.h:518
struct io_desc_t * next
Pointer to the next io_desc_t in the list.
Definition: pio.h:639
int holegridsize
Used when writing fill data.
Definition: pio.h:607
MPI_Datatype * rtype
Array (of length nrecvs) of receive MPI types in pio_swapm() call.
Definition: pio.h:598
PIO_Offset * map
A 1-D array with iodesc->maplen elements, which are the 1-based mappings to the global array for that...
Definition: pio.h:525
PIO_Offset maxiobuflen
Maximum llen participating.
Definition: pio.h:577
MPI_Datatype * stype
Array of send MPI types in pio_swapm() call.
Definition: pio.h:601
int maxfillregions
Used when writing fill data.
Definition: pio.h:613
int nrecvs
Number of tasks involved in the communication between comp and io tasks.
Definition: pio.h:529
int num_stypes
Number of send MPI types in pio_swapm() call.
Definition: pio.h:604
int * dimlen
An array of size ndims with the length of each dimension.
Definition: pio.h:539
int ndof
Local size of the decomposition array on the compute node.
Definition: pio.h:532
int mpitype_size
The size in bytes of a datum of MPI type mpitype.
Definition: pio.h:567
PIO_Offset * sindex
Array (length ndof) for the BOX rearranger with the index for computation taks (send side during writ...
Definition: pio.h:592
int maplen
The length of the decomposition map.
Definition: pio.h:521
int maxbytes
The maximum number of bytes of this iodesc before flushing.
Definition: pio.h:555
int * scount
Array (length numiotasks) of data counts to send to each task in the communication in pio_swapm().
Definition: pio.h:588
int piotype
The PIO type of the data.
Definition: pio.h:558
int maxregions
Maximum number of regions in the decomposition.
Definition: pio.h:548
int num_aiotasks
The actual number of IO tasks participating.
Definition: pio.h:542
PIO_Offset llen
Length of the iobuffer on this task for a single field on the IO node.
Definition: pio.h:574
int maxholegridsize
max holegridsize across all io tasks, needed for netcdf and netcdf4c serial
Definition: pio.h:610
int piotype_size
The size of one element of the piotype.
Definition: pio.h:561
MPI_Datatype mpitype
The MPI type of the data.
Definition: pio.h:564
bool needsfill
Does this decomp leave holes in the field (true) or write everywhere (false)
Definition: pio.h:552
MPI_Comm subset_comm
In the subset communicator each io task is associated with a unique group of comp tasks this is the c...
Definition: pio.h:629
int * rfrom
Array (length nrecvs) of computation tasks received from.
Definition: pio.h:580
rearr_opt_t rearr_opts
Rearranger flow control options (handshake, non-blocking sends, pending requests)
Definition: pio.h:624
int * rcount
Array (length nrecvs) of counts of data to be received from each computation task by the IO tasks.
Definition: pio.h:584
IO region structure.
Definition: pio.h:421
struct io_region * next
Pointer to the next io_region in the list.
Definition: pio.h:433
int loffset
The offset from the beginning of the data buffer to the beginning of this region.
Definition: pio.h:424
PIO_Offset * start
Start array for this region.
Definition: pio.h:427
PIO_Offset * count
Count array for this region.
Definition: pio.h:430
Async I/O service message info.
Definition: pio.h:755
int prev_msg
Definition: pio.h:757
int seq_num
Definition: pio.h:756
IO system descriptor structure.
Definition: pio.h:652
MPI_Comm my_comm
This is a copy (but not an MPI copy) of either the comp (for non-async) or the union (for async) comm...
Definition: pio.h:678
int iosysid
The ID of this iosystem_desc_t.
Definition: pio.h:655
MPI_Comm comp_comm
This is an MPI intra communicator that includes all the tasks involved in computation.
Definition: pio.h:670
int union_rank
Rank of this task in the union communicator.
Definition: pio.h:699
int num_uniontasks
The number of tasks in the union communicator (will be num_comptasks for non-async,...
Definition: pio.h:696
struct iosystem_desc_t::async_ios_msg_info_ async_ios_msg_info
MPI_Group iogroup
This MPI group contains the processors involved in I/O.
Definition: pio.h:685
bool compproc
True if this task is a member of a computation communicator.
Definition: pio.h:749
char sname[PIO_MAX_NAME+1]
Definition: pio.h:658
int comp_idx
Index of this component in the list of components.
Definition: pio.h:761
MPI_Comm union_comm
This is an MPI intra communicator that includes all the tasks in both the IO and the computation comm...
Definition: pio.h:662
int error_handler
Controls handling errors.
Definition: pio.h:735
MPI_Info info
MPI Info object.
Definition: pio.h:752
int * ioranks
An array of the ranks of all IO tasks within the union communicator.
Definition: pio.h:728
int default_rearranger
The rearranger decides which parts of a distributed array are handled by which IO tasks.
Definition: pio.h:739
MPI_Group compgroup
This MPI group contains the processors involved in computation.
Definition: pio.h:682
MPI_Comm intercomm
This is an MPI inter communicator between IO communicator and computation communicator.
Definition: pio.h:674
int comp_rank
The rank of this process in the computation communicator, or -1 if this process is not part of the co...
Definition: pio.h:703
bool ioproc
True if this task is a member of the IO communicator.
Definition: pio.h:745
rearr_opt_t rearr_opts
Rearranger options.
Definition: pio.h:764
int io_rank
The rank of this process in the IO communicator, or -1 if this process is not part of the IO communic...
Definition: pio.h:707
MPI_Comm io_comm
This is an MPI intra communicator that includes all the tasks involved in IO.
Definition: pio.h:666
int num_comptasks
The number of tasks in the computation communicator.
Definition: pio.h:691
struct spio_io_fstats_summary * io_fstats
I/O statistics associated with this I/O system.
Definition: pio.h:789
struct iosystem_desc_t * next
Pointer to the next iosystem_desc_t in the list.
Definition: pio.h:792
int ioroot
Rank of IO root task (which is rank 0 in io_comm) in the union communicator.
Definition: pio.h:719
int iomaster
Set to MPI_ROOT if this task is the master of IO communicator, 0 otherwise.
Definition: pio.h:711
int compmaster
Set to MPI_ROOT if this task is the master of comp communicator, 0 otherwise.
Definition: pio.h:715
int * compranks
An array of the ranks of all computation tasks within the union communicator.
Definition: pio.h:732
bool async
True if asynchronous interface is in use.
Definition: pio.h:742
int comproot
Rank of computation root task (which is rank 0 in comm_comms[cmp]) in the union communicator.
Definition: pio.h:724
int num_iotasks
The number of tasks in the IO communicator.
Definition: pio.h:688
Rearranger comm flow control options.
Definition: pio.h:475
bool isend
Enable isends - if false use blocking sends.
Definition: pio.h:480
bool hs
Enable handshake.
Definition: pio.h:477
int max_pend_req
Max pending requests (PIO_REARR_COMM_UNLIMITED_PEND_REQ => unlimited pend req).
Definition: pio.h:488
Rearranger options.
Definition: pio.h:495
int comm_type
Comm type - see PIO_REARR_COMM_TYPE.
Definition: pio.h:497
int fcd
Comm flow control dir - see PIO_REARR_COMM_FC_DIR.
Definition: pio.h:500
rearr_comm_fc_opt_t io2comp
flow control opts, io to comp procs
Definition: pio.h:506
rearr_comm_fc_opt_t comp2io
flow control opts, comp to io procs
Definition: pio.h:503
Variable description structure.
Definition: pio.h:343
int use_fill
Non-zero if fill mode is turned on for this var.
Definition: pio.h:401
int ndims
Definition: pio.h:358
PIO_Offset * request_sz
Size of each outstanding pnetcdf request for this variable.
Definition: pio.h:369
int varid
Definition: pio.h:345
PIO_Offset vrsize
Definition: pio.h:384
char vname[PIO_MAX_NAME+1]
Definition: pio.h:348
PIO_Offset rb_pend
Definition: pio.h:387
PIO_Offset wb_pend
Definition: pio.h:390
int nreqs
Number of requests bending with pnetcdf.
Definition: pio.h:372
int record
The record number to be written.
Definition: pio.h:362
void * fillvalue
Definition: pio.h:375
int rec_var
Definition: pio.h:355
int pio_type
Definition: pio.h:378
void * fillbuf
Buffer that contains the holegrid fill values used to fill in missing sections of data when using the...
Definition: pio.h:405
char vdesc[PIO_MAX_NAME+1]
Definition: pio.h:351
PIO_Offset type_size
Definition: pio.h:381
int * request
FIXME: Combine request related members to a separate struct.
Definition: pio.h:366
The multi buffer holds data from one or more variables.
Definition: pio.h:800
int arraylen
Size of this variables data on local task.
Definition: pio.h:815
int recordvar
Non-zero if this is a buffer for a record var.
Definition: pio.h:806
int ioid
The ID that describes the decomposition, as returned from PIOc_Init_Decomp().
Definition: pio.h:803
void * fillvalue
Array of fill values used for each var.
Definition: pio.h:825
void * data
Pointer to the data.
Definition: pio.h:828
struct wmulti_buffer * next
Pointer to the next multi-buffer in the list.
Definition: pio.h:831
int * vid
Array of varids.
Definition: pio.h:818
int * frame
An array of current record numbers, for record vars.
Definition: pio.h:822
int num_arrays
Number of arrays of data in the multibuffer.
Definition: pio.h:811