int NC3_def_dim(int ncid, const char *name, size_t size, int *dimidp) { int status; NC *nc; NC3_INFO* ncp; int dimid; NC_dim *dimp; status = NC_check_id(ncid, &nc); if(status != NC_NOERR) return status; ncp = NC3_DATA(nc); if(!NC_indef(ncp)) return NC_ENOTINDEFINE; status = NC_check_name(name); if(status != NC_NOERR) return status; if(ncp->flags & NC_64BIT_DATA) {/*CDF-5*/ if((sizeof(size_t) > 4) && (size > X_UINT64_MAX - 3)) /* "- 3" handles rounded-up size */ return NC_EDIMSIZE; } else if(ncp->flags & NC_64BIT_OFFSET) {/* CDF2 format and LFS */ if((sizeof(size_t) > 4) && (size > X_UINT_MAX - 3)) /* "- 3" handles rounded-up size */ return NC_EDIMSIZE; } else {/*CDF-1*/ if(size > X_INT_MAX - 3) return NC_EDIMSIZE; } if(size == NC_UNLIMITED) { dimid = find_NC_Udim(&ncp->dims, &dimp); if(dimid != -1) { assert(dimid != -1); return NC_EUNLIMIT; } } dimid = NC_finddim(&ncp->dims, name, &dimp); if(dimid != -1) return NC_ENAMEINUSE; dimp = new_NC_dim(name, size); if(dimp == NULL) return NC_ENOMEM; status = incr_NC_dimarray(&ncp->dims, dimp); if(status != NC_NOERR) { free_NC_dim(dimp); return status; } if(dimidp != NULL) *dimidp = (int)ncp->dims.nelems -1; return NC_NOERR; }
int nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *xtendimp) { int status; NC *ncp; status = NC_check_id(ncid, &ncp); if(status != NC_NOERR) return status; if(ndimsp != NULL) *ndimsp = (int) ncp->dims.nelems; if(nvarsp != NULL) *nvarsp = (int) ncp->vars.nelems; if(nattsp != NULL) *nattsp = (int) ncp->attrs.nelems; if(xtendimp != NULL) *xtendimp = find_NC_Udim(&ncp->dims, NULL); return NC_NOERR; }
int nc_inq_unlimdim(int ncid, int *xtendimp) { int status; NC *ncp; status = NC_check_id(ncid, &ncp); if(status != NC_NOERR) return status; if(xtendimp != NULL) *xtendimp = find_NC_Udim(&ncp->dims, NULL); return NC_NOERR; }