1 /********************************************************************* 2 * Copyright 2018, University Corporation for Atmospheric Research 3 * See netcdf/README file for copying and redistribution conditions. 4 * "$Id: nciter.h 400 2010-08-27 21:02:52Z russ $" 5 *********************************************************************/ 6 7 #ifndef _NCITER_ 8 #define _NCITER_ 9 10 #include "netcdf.h" 11 12 #if defined(__cplusplus) 13 extern "C" { 14 #endif 15 16 /* 17 * The opaque structure to hold per-variable state of data iteration 18 */ 19 typedef struct { 20 int first; /* false after first invocation of nc_next_iter() */ 21 int right_dim; /* rightmost dimension for start of variable pieces */ 22 size_t rows; /* how many subpiece rows in bufsiz */ 23 size_t numrows; /* how many row pieces in right_dim dimension */ 24 size_t cur; /* current "row" in loop over row pieces */ 25 size_t leftover; /* how many rows left over after partitioning 26 * bufsiz into subpiece blocks */ 27 int more; /* whether there is more data still to get */ 28 size_t to_get; /* number of values to get on this access */ 29 int rank; /* number of dimensions */ 30 size_t inc; /* increment for right_dim element of start vector */ 31 int chunked; /* 1 if chunked, 0 if contiguous */ 32 size_t *dimsizes; 33 size_t *chunksizes; /* ignored if not chunked */ 34 } nciter_t; 35 36 /* 37 * The Interfaces 38 */ 39 40 /* Get iterator for variable data. Returns pointer to malloc'd 41 * nciter_t, which caller must later release using nc_free_iter(), not 42 * free(). */ 43 extern int 44 nc_get_iter(int ncid, int varid, size_t bufsize, nciter_t **iterpp); 45 46 /* Iterate over blocks of variable values, using start and count 47 * vectors. Returns number of values to access (product of counts), 48 * or 0 if done. */ 49 extern size_t 50 nc_next_iter(nciter_t *iterp, size_t *start, size_t *count); 51 52 /* Release memory allocated for iterator */ 53 extern int 54 nc_free_iter(nciter_t *iterp); 55 56 #if defined(__cplusplus) 57 } 58 #endif 59 60 #endif /* _NCITER_ */ 61