int ncvarputs( int ncid, int varid, const long* start, const long* count, const long* stride, const void* value ) { if(stride == NULL) return ncvarput(ncid, varid, start, count, value); /* else */ { NDIMS_DECL A_DECL(stp, size_t, ndims, start); A_DECL(cntp, size_t, ndims, count); A_DECL(strdp, ptrdiff_t, ndims, stride); A_INIT(stp, size_t, ndims, start); A_INIT(cntp, size_t, ndims, count); A_INIT(strdp, ptrdiff_t, ndims, stride); { const int status = nc_put_vars(ncid, varid, stp, cntp, strdp, value); A_FREE(strdp); A_FREE(cntp); A_FREE(stp); if(status != NC_NOERR) { nc_advise("ncvarputs", status, "ncid %d", ncid); return -1; } } return 0; } }
static void write_cdf(pccluster t, size_t clusters, size_t coeffs, size_t * clusteridx, size_t * coeffidx, int nc_file, int nc_sons, int nc_size, int nc_coeff) { size_t start, count; ptrdiff_t stride; int val, result; uint i; assert(*clusteridx <= clusters); /* Write number of sons to nc_sons[*clusteridx] */ start = *clusteridx; count = 1; stride = 1; val = t->sons; result = nc_put_vars(nc_file, nc_sons, &start, &count, &stride, &val); assert(result == NC_NOERR); /* Write size of cluster to nc_size[*clusteridx] */ val = t->size; result = nc_put_vars(nc_file, nc_size, &start, &count, &stride, &val); assert(result == NC_NOERR); /* Increase cluster index */ (*clusteridx)++; /* Handle sons */ for (i = 0; i < t->sons; i++) write_cdf(t->son[i], clusters, coeffs, clusteridx, coeffidx, nc_file, nc_sons, nc_size, nc_coeff); /* Write bounding box */ start = *coeffidx; assert(start + 2 * t->dim <= coeffs); count = t->dim; result = nc_put_vars(nc_file, nc_coeff, &start, &count, &stride, t->bmin); assert(result == NC_NOERR); start += t->dim; result = nc_put_vars(nc_file, nc_coeff, &start, &count, &stride, t->bmax); assert(result == NC_NOERR); start += t->dim; (*coeffidx) = start; }