示例#1
0
文件: v2i.c 项目: stcorp/harp
int
ncvargets(
    int		ncid,
    int		varid,
    const long*	start,
    const long*	count,
    const long*	stride,
    void*	value
)
{
	if(stride == NULL)
		return ncvarget(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_get_vars(ncid, varid, stp, cntp, strdp, value);
	A_FREE(strdp);
	A_FREE(cntp);
	A_FREE(stp);
	if(status != NC_NOERR)
	{
		nc_advise("ncvargets", status, "ncid %d", ncid);
		return -1;
	}
	}
	return 0;
	}
}
示例#2
0
文件: cluster.c 项目: H2Lib/H2Lib
static pcluster
read_cdf_part(int nc_file, size_t clusters, size_t coeffs,
	      int nc_sons, int nc_size, int nc_coeff,
	      uint * idx, int dim, size_t * clusteridx, size_t * coeffidx)
{
  pcluster  t, t1;
  uint     *idx1;
  uint      size;
  uint      sons;
  uint      i;
  size_t    start, count;
  ptrdiff_t stride;
  int       val, result;

  /* Get number of sons */
  start = *clusteridx;
  count = 1;
  stride = 1;
  result = nc_get_vars(nc_file, nc_sons, &start, &count, &stride, &val);
  assert(result == NC_NOERR);
  sons = val;

  /* Get size of cluster */
  result = nc_get_vars(nc_file, nc_size, &start, &count, &stride, &val);
  assert(result == NC_NOERR);
  size = val;

  /* Create new cluster */
  t = new_cluster(size, idx, sons, dim);

  /* Increase cluster index */
  (*clusteridx)++;

  /* Handle sons */
  if (sons > 0) {
    idx1 = idx;
    for (i = 0; i < sons; i++) {
      t1 = read_cdf_part(nc_file, clusters, coeffs,
			 nc_sons, nc_size, nc_coeff,
			 idx1, dim, clusteridx, coeffidx);
      t->son[i] = t1;

      idx1 += t1->size;
    }
    assert(idx1 == idx + size);
  }

  /* Get bounding box */
  start = (*coeffidx);
  count = dim;
  result = nc_get_vars(nc_file, nc_coeff, &start, &count, &stride, t->bmin);
  start += dim;

  result = nc_get_vars(nc_file, nc_coeff, &start, &count, &stride, t->bmax);
  start += dim;
  (*coeffidx) = start;

  /* Finish initialization */
  update_cluster(t);

  return t;
}