25.5 Benefits of Iterators
Use of an iterator simplifies the code and makes it general.
Benefits of using this iterator API include:
- treats variables of all types, sizes, and shapes uniformly, whether
they fit in memory or not, even if a single row won't fit in memory
- makes recursion unnecessary in handling arrays of arbitrary
accesses data efficiently, using largest blocks that will
fit in memory buffer of designated size
- takes care of pesky leftovers, when smaller
pieces are needed at
the end of a loop to finish what's left
- works for either netCDF-3 or netCDF-4 enabled
- takes advantage of chunking when present, reading
a chunk-at-a-time rather than along dimension axes
- supports iterating over multiple variables concurrently, because
each variable's iteration state is maintained in its own iterator
Other iterator functions used in nccopy iterate through all
groups in an arbitrary group hierachy for netCDF-4 files, eliminating
need for recursion to traverse groups.
These iterator APIs are available now in C source, but will be exposed
and documented in a future version of the APIs, including Fortran support.