Doxygen Source Code Documentation
nc.h File Reference
#include "ncconfig.h"
#include <stddef.h>
#include <sys/types.h>
#include "netcdf.h"
#include "ncio.h"
#include "fbits.h"
Go to the source code of this file.
Data Structures | |
struct | NC |
struct | NC_attr |
struct | NC_attrarray |
struct | NC_dim |
struct | NC_dimarray |
struct | NC_string |
struct | NC_var |
struct | NC_vararray |
Defines | |
#define | NC_ARRAY_GROWBY 4 |
#define | MIN_NC_XSZ 32 |
#define | IS_RECVAR(vp) ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 ) |
#define | NC_CREAT 2 |
#define | NC_INDEF 8 |
#define | NC_NSYNC 0x10 |
#define | NC_HSYNC 0x20 |
#define | NC_NDIRTY 0x40 |
#define | NC_HDIRTY 0x80 |
#define | NC_readonly(ncp) (!fIsSet(ncp->nciop->ioflags, NC_WRITE)) |
#define | NC_IsNew(ncp) fIsSet((ncp)->flags, NC_CREAT) |
#define | NC_indef(ncp) (NC_IsNew(ncp) || fIsSet((ncp)->flags, NC_INDEF)) |
#define | set_NC_ndirty(ncp) fSet((ncp)->flags, NC_NDIRTY) |
#define | NC_ndirty(ncp) fIsSet((ncp)->flags, NC_NDIRTY) |
#define | set_NC_hdirty(ncp) fSet((ncp)->flags, NC_HDIRTY) |
#define | NC_hdirty(ncp) fIsSet((ncp)->flags, NC_HDIRTY) |
#define | NC_dofill(ncp) (!fIsSet((ncp)->flags, NC_NOFILL)) |
#define | NC_doHsync(ncp) fIsSet((ncp)->flags, NC_HSYNC) |
#define | NC_doNsync(ncp) fIsSet((ncp)->flags, NC_NSYNC) |
#define | NC_get_numrecs(ncp) ((ncp)->numrecs) |
#define | NC_set_numrecs(ncp, nrecs) {((ncp)->numrecs = (nrecs));} |
#define | NC_increase_numrecs(ncp, nrecs) {if((nrecs) > (ncp)->numrecs) ((ncp)->numrecs = (nrecs));} |
Typedefs | |
typedef NC | NC |
typedef NC_dimarray | NC_dimarray |
typedef NC_attrarray | NC_attrarray |
typedef NC_vararray | NC_vararray |
Enumerations | |
enum | NCtype { NC_UNSPECIFIED = 0, NC_DIMENSION = 10, NC_VARIABLE = 11, NC_ATTRIBUTE = 12 } |
Functions | |
void | free_NC_string (NC_string *ncstrp) |
int | NC_check_name (const char *name) |
NC_string * | new_NC_string (size_t slen, const char *str) |
int | set_NC_string (NC_string *ncstrp, const char *str) |
void | free_NC_dim (NC_dim *dimp) |
NC_dim * | new_x_NC_dim (NC_string *name) |
int | find_NC_Udim (const NC_dimarray *ncap, NC_dim **dimpp) |
void | free_NC_dimarrayV0 (NC_dimarray *ncap) |
void | free_NC_dimarrayV (NC_dimarray *ncap) |
int | dup_NC_dimarrayV (NC_dimarray *ncap, const NC_dimarray *ref) |
NC_dim * | elem_NC_dimarray (const NC_dimarray *ncap, size_t elem) |
void | free_NC_attr (NC_attr *attrp) |
NC_attr * | new_x_NC_attr (NC_string *strp, nc_type type, size_t nelems) |
NC_attr ** | NC_findattr (const NC_attrarray *ncap, const char *name) |
void | free_NC_attrarrayV0 (NC_attrarray *ncap) |
void | free_NC_attrarrayV (NC_attrarray *ncap) |
int | dup_NC_attrarrayV (NC_attrarray *ncap, const NC_attrarray *ref) |
NC_attr * | elem_NC_attrarray (const NC_attrarray *ncap, size_t elem) |
void | free_NC_var (NC_var *varp) |
NC_var * | new_x_NC_var (NC_string *strp, size_t ndims) |
void | free_NC_vararrayV0 (NC_vararray *ncap) |
void | free_NC_vararrayV (NC_vararray *ncap) |
int | dup_NC_vararrayV (NC_vararray *ncap, const NC_vararray *ref) |
int | NC_var_shape (NC_var *varp, const NC_dimarray *dims) |
int | NC_findvar (const NC_vararray *ncap, const char *name, NC_var **varpp) |
NC_var * | NC_lookupvar (NC *ncp, int varid) |
int | NC_check_id (int ncid, NC **ncpp) |
int | nc_cktype (nc_type datatype) |
size_t | ncx_howmany (nc_type type, size_t xbufsize) |
int | read_numrecs (NC *ncp) |
int | write_numrecs (NC *ncp) |
int | NC_sync (NC *ncp) |
size_t | ncx_len_NC (const NC *ncp) |
int | ncx_put_NC (const NC *ncp, void **xpp, off_t offset, size_t extent) |
int | nc_get_NC (NC *ncp) |
int | fill_NC_var (NC *ncp, const NC_var *varp, size_t recno) |
int | nc_inq_rec (int ncid, size_t *nrecvars, int *recvarids, size_t *recsizes) |
int | nc_get_rec (int ncid, size_t recnum, void **datap) |
int | nc_put_rec (int ncid, size_t recnum, void *const *datap) |
int | nc_put_att (int ncid, int varid, const char *name, nc_type datatype, size_t len, const void *value) |
int | nc_get_att (int ncid, int varid, const char *name, void *value) |
int | nc_put_var1 (int ncid, int varid, const size_t *index, const void *value) |
int | nc_get_var1 (int ncid, int varid, const size_t *index, void *value) |
int | nc_put_vara (int ncid, int varid, const size_t *start, const size_t *count, const void *value) |
int | nc_get_vara (int ncid, int varid, const size_t *start, const size_t *count, void *value) |
int | nc_put_vars (int ncid, int varid, const size_t *start, const size_t *count, const ptrdiff_t *stride, const void *value) |
int | nc_get_vars (int ncid, int varid, const size_t *start, const size_t *count, const ptrdiff_t *stride, void *value) |
int | nc_put_varm (int ncid, int varid, const size_t *start, const size_t *count, const ptrdiff_t *stride, const ptrdiff_t *map, const void *value) |
int | nc_get_varm (int ncid, int varid, const size_t *start, const size_t *count, const ptrdiff_t *stride, const ptrdiff_t *map, void *value) |
Define Documentation
|
|
Definition at line 29 of file nc.h. Referenced by nc_get_NC(), ncx_put_NC(), and new_NC(). |
|
Definition at line 21 of file nc.h. Referenced by incr_NC_attrarray(), incr_NC_dimarray(), and incr_NC_vararray(). |
|
Definition at line 242 of file nc.h. Referenced by nc__create_mp(), and NC_endef(). |
|
Definition at line 296 of file nc.h. Referenced by fillerup(), NC_endef(), and NCvnrecs(). |
|
Definition at line 299 of file nc.h. Referenced by nc_copy_att(), nc_put_att_double(), nc_put_att_float(), nc_put_att_int(), nc_put_att_long(), nc_put_att_schar(), nc_put_att_short(), nc_put_att_text(), nc_put_att_uchar(), nc_rename_att(), nc_rename_dim(), and nc_rename_var(). |
|
Definition at line 302 of file nc.h. Referenced by NCcoordck(), and NCvnrecs(). |
|
|
Definition at line 293 of file nc.h. Referenced by NC_sync(). |
|
Definition at line 247 of file nc.h. Referenced by read_NC(), and write_NC(). |
|
|
|
Definition at line 312 of file nc.h. Referenced by NCvnrecs(). |
|
|
Definition at line 243 of file nc.h. Referenced by nc_abort(), NC_endef(), and nc_redef(). |
|
Definition at line 278 of file nc.h. Referenced by nc_abort(), NC_begins(), and NC_endef(). |
|
Definition at line 287 of file nc.h. Referenced by NC_sync(). |
|
Definition at line 246 of file nc.h. Referenced by read_NC(), read_numrecs(), write_NC(), and write_numrecs(). |
|
Definition at line 244 of file nc.h. Referenced by nc__create_mp(), and nc__open_mp(). |
|
|
Definition at line 309 of file nc.h. Referenced by dup_NC(), move_recs_r(), NC_begins(), nc_get_NC(), NCvnrecs(), and read_numrecs(). |
|
Definition at line 290 of file nc.h. Referenced by nc_copy_att(), nc_put_att_double(), nc_put_att_float(), nc_put_att_int(), nc_put_att_long(), nc_put_att_schar(), nc_put_att_short(), nc_put_att_text(), nc_put_att_uchar(), nc_rename_att(), nc_rename_dim(), and nc_rename_var(). |
|
Definition at line 284 of file nc.h. Referenced by NCvnrecs(). |
Typedef Documentation
|
|
|
|
|
|
|
|
Enumeration Type Documentation
|
Definition at line 36 of file nc.h. Referenced by v1h_get_NC_attrarray(), v1h_get_NC_dimarray(), v1h_get_NC_vararray(), v1h_get_NCtype(), and v1h_put_NCtype().
00036 { 00037 NC_UNSPECIFIED = 0, 00038 /* future NC_BITFIELD = 7, */ 00039 /* NC_STRING = 8, */ 00040 NC_DIMENSION = 10, 00041 NC_VARIABLE = 11, 00042 NC_ATTRIBUTE = 12 00043 } NCtype; |
Function Documentation
|
Definition at line 184 of file attr.c. References dup_NC_attr(), free_NC_attrarrayV(), malloc, NC_attrarray::nalloc, NC_attrarray::nelems, ref, and NC_attrarray::value. Referenced by dup_NC(), and dup_NC_var().
00185 { 00186 int status = NC_NOERR; 00187 00188 assert(ref != NULL); 00189 assert(ncap != NULL); 00190 00191 if(ref->nelems != 0) 00192 { 00193 const size_t sz = ref->nelems * sizeof(NC_attr *); 00194 ncap->value = (NC_attr **) malloc(sz); 00195 if(ncap->value == NULL) 00196 return NC_ENOMEM; 00197 00198 (void) memset(ncap->value, 0, sz); 00199 ncap->nalloc = ref->nelems; 00200 } 00201 00202 ncap->nelems = 0; 00203 { 00204 NC_attr **app = ncap->value; 00205 const NC_attr **drpp = (const NC_attr **)ref->value; 00206 NC_attr *const *const end = &app[ref->nelems]; 00207 for( /*NADA*/; app < end; drpp++, app++, ncap->nelems++) 00208 { 00209 *app = dup_NC_attr(*drpp); 00210 if(*app == NULL) 00211 { 00212 status = NC_ENOMEM; 00213 break; 00214 } 00215 } 00216 } 00217 00218 if(status != NC_NOERR) 00219 { 00220 free_NC_attrarrayV(ncap); 00221 return status; 00222 } 00223 00224 assert(ncap->nelems == ref->nelems); 00225 00226 return NC_NOERR; 00227 } |
|
Definition at line 203 of file dim.c. References dup_NC_dim(), free_NC_dimarrayV(), malloc, NC_dimarray::nalloc, NC_dimarray::nelems, ref, and NC_dimarray::value. Referenced by dup_NC().
00204 { 00205 int status = NC_NOERR; 00206 00207 assert(ref != NULL); 00208 assert(ncap != NULL); 00209 00210 if(ref->nelems != 0) 00211 { 00212 const size_t sz = ref->nelems * sizeof(NC_dim *); 00213 ncap->value = (NC_dim **) malloc(sz); 00214 if(ncap->value == NULL) 00215 return NC_ENOMEM; 00216 (void) memset(ncap->value, 0, sz); 00217 ncap->nalloc = ref->nelems; 00218 } 00219 00220 ncap->nelems = 0; 00221 { 00222 NC_dim **dpp = ncap->value; 00223 const NC_dim **drpp = (const NC_dim **)ref->value; 00224 NC_dim *const *const end = &dpp[ref->nelems]; 00225 for( /*NADA*/; dpp < end; drpp++, dpp++, ncap->nelems++) 00226 { 00227 *dpp = dup_NC_dim(*drpp); 00228 if(*dpp == NULL) 00229 { 00230 status = NC_ENOMEM; 00231 break; 00232 } 00233 } 00234 } 00235 00236 if(status != NC_NOERR) 00237 { 00238 free_NC_dimarrayV(ncap); 00239 return status; 00240 } 00241 00242 assert(ncap->nelems == ref->nelems); 00243 00244 return NC_NOERR; 00245 } |
|
Definition at line 185 of file var.c. References dup_NC_var(), free_NC_vararrayV(), malloc, NC_vararray::nalloc, NC_vararray::nelems, ref, and NC_vararray::value. Referenced by dup_NC().
00186 { 00187 int status = NC_NOERR; 00188 00189 assert(ref != NULL); 00190 assert(ncap != NULL); 00191 00192 if(ref->nelems != 0) 00193 { 00194 const size_t sz = ref->nelems * sizeof(NC_var *); 00195 ncap->value = (NC_var **) malloc(sz); 00196 if(ncap->value == NULL) 00197 return NC_ENOMEM; 00198 (void) memset(ncap->value, 0, sz); 00199 ncap->nalloc = ref->nelems; 00200 } 00201 00202 ncap->nelems = 0; 00203 { 00204 NC_var **vpp = ncap->value; 00205 const NC_var **drpp = (const NC_var **)ref->value; 00206 NC_var *const *const end = &vpp[ref->nelems]; 00207 for( /*NADA*/; vpp < end; drpp++, vpp++, ncap->nelems++) 00208 { 00209 *vpp = dup_NC_var(*drpp); 00210 if(*vpp == NULL) 00211 { 00212 status = NC_ENOMEM; 00213 break; 00214 } 00215 } 00216 } 00217 00218 if(status != NC_NOERR) 00219 { 00220 free_NC_vararrayV(ncap); 00221 return status; 00222 } 00223 00224 assert(ncap->nelems == ref->nelems); 00225 00226 return NC_NOERR; 00227 } |
|
Definition at line 273 of file attr.c. References NC_attrarray::nelems, and NC_attrarray::value. Referenced by nc_inq_attname().
|
|
Definition at line 289 of file dim.c. References NC_dimarray::nelems, and NC_dimarray::value. Referenced by nc_inq_dim(), nc_inq_dimlen(), nc_inq_dimname(), nc_rename_dim(), and NC_var_shape().
|
|
Definition at line 221 of file putget.c. References NC_var::attrs, NC_var::begin, NC::chunk, ncio::get, IS_RECVAR, NC_var::len, MIN, NC_fill_char(), NC_fill_double(), NC_fill_float(), NC_fill_int(), NC_fill_schar(), NC_fill_short(), NC_findattr(), NC::nciop, NFILL, offset, NC::recsize, ncio::rel, RGN_MODIFIED, RGN_WRITE, NC_var::type, X_ALIGN, X_SIZEOF_DOUBLE, and NC_var::xsz. Referenced by fill_added(), fill_added_recs(), fillerup(), and NCfillrecord().
00222 { 00223 char xfillp[NFILL * X_SIZEOF_DOUBLE]; 00224 const size_t step = varp->xsz; 00225 const size_t nelems = sizeof(xfillp)/step; 00226 const size_t xsz = varp->xsz * nelems; 00227 NC_attr **attrpp = NULL; 00228 off_t offset; 00229 size_t remaining = varp->len; 00230 00231 void *xp; 00232 int status = NC_NOERR; 00233 00234 /* 00235 * Set up fill value 00236 */ 00237 attrpp = NC_findattr(&varp->attrs, _FillValue); 00238 if( attrpp != NULL ) 00239 { 00240 /* User defined fill value */ 00241 if( (*attrpp)->type != varp->type || (*attrpp)->nelems != 1 ) 00242 { 00243 return NC_EBADTYPE; 00244 } 00245 else 00246 { 00247 /* Use the user defined value */ 00248 char *cp = xfillp; 00249 const char *const end = &xfillp[sizeof(xfillp)]; 00250 00251 assert(step <= (*attrpp)->xsz); 00252 00253 for( /*NADA*/; cp < end; cp += step) 00254 { 00255 (void) memcpy(cp, (*attrpp)->xvalue, step); 00256 } 00257 } 00258 } 00259 else 00260 { 00261 /* use the default */ 00262 00263 assert(xsz % X_ALIGN == 0); 00264 assert(xsz <= sizeof(xfillp)); 00265 00266 xp = xfillp; 00267 00268 switch(varp->type){ 00269 case NC_BYTE : 00270 status = NC_fill_schar(&xp, nelems); 00271 break; 00272 case NC_CHAR : 00273 status = NC_fill_char(&xp, nelems); 00274 break; 00275 case NC_SHORT : 00276 status = NC_fill_short(&xp, nelems); 00277 break; 00278 case NC_INT : 00279 status = NC_fill_int(&xp, nelems); 00280 break; 00281 case NC_FLOAT : 00282 status = NC_fill_float(&xp, nelems); 00283 break; 00284 case NC_DOUBLE : 00285 status = NC_fill_double(&xp, nelems); 00286 break; 00287 default : 00288 assert("fill_NC_var invalid type" == 0); 00289 status = NC_EBADTYPE; 00290 break; 00291 } 00292 if(status != NC_NOERR) 00293 return status; 00294 00295 assert(xp == xfillp + xsz); 00296 } 00297 00298 /* 00299 * copyout: 00300 * xfillp now contains 'nelems' elements of the fill value 00301 * in external representation. 00302 */ 00303 00304 /* 00305 * Copy it out. 00306 */ 00307 00308 offset = varp->begin; 00309 if(IS_RECVAR(varp)) 00310 { 00311 offset += (off_t)ncp->recsize * recno; 00312 } 00313 00314 assert(remaining > 0); 00315 for(;;) 00316 { 00317 const size_t chunksz = MIN(remaining, ncp->chunk); 00318 size_t ii; 00319 assert(chunksz % X_ALIGN == 0); 00320 00321 status = ncp->nciop->get(ncp->nciop, offset, chunksz, 00322 RGN_WRITE, &xp); 00323 if(status != NC_NOERR) 00324 { 00325 return status; 00326 } 00327 00328 /* 00329 * fill the chunksz buffer in units of xsz 00330 */ 00331 for(ii = 0; ii < chunksz/xsz; ii++) 00332 { 00333 (void) memcpy(xp, xfillp, xsz); 00334 xp = (char *)xp + xsz; 00335 } 00336 /* 00337 * Deal with any remainder 00338 */ 00339 { 00340 const size_t rem = chunksz % xsz; 00341 if(rem != 0) 00342 { 00343 (void) memcpy(xp, xfillp, rem); 00344 /* xp = (char *)xp + xsz; */ 00345 } 00346 00347 } 00348 00349 status = ncp->nciop->rel(ncp->nciop, offset, RGN_MODIFIED); 00350 00351 if(status != NC_NOERR) 00352 { 00353 break; 00354 } 00355 00356 remaining -= chunksz; 00357 if(remaining == 0) 00358 break; /* normal loop exit */ 00359 offset += chunksz; 00360 00361 } 00362 00363 return status; 00364 } |
|
Definition at line 85 of file dim.c. References NC_dimarray::nelems, and NC_dimarray::value. Referenced by nc_def_dim(), nc_inq(), and nc_inq_unlimdim().
00086 { 00087 assert(ncap != NULL); 00088 00089 if(ncap->nelems == 0) 00090 return -1; 00091 00092 { 00093 int dimid = 0; 00094 NC_dim **loc = ncap->value; 00095 00096 for(; (size_t) dimid < ncap->nelems 00097 && (*loc)->size != NC_UNLIMITED; dimid++, loc++) 00098 { 00099 /*EMPTY*/ 00100 } 00101 if(dimid >= ncap->nelems) 00102 return(-1); /* not found */ 00103 /* else, normal return */ 00104 if(dimpp != NULL) 00105 *dimpp = *loc; 00106 return dimid; 00107 } 00108 } |
|
Definition at line 22 of file attr.c. References free, free_NC_string(), and NC_attr::name. Referenced by free_NC_attrarrayV0(), nc_copy_att(), nc_del_att(), nc_put_att_double(), nc_put_att_float(), nc_put_att_int(), nc_put_att_long(), nc_put_att_schar(), nc_put_att_short(), nc_put_att_text(), nc_put_att_uchar(), and v1h_get_NC_attr().
00023 { 00024 00025 if(attrp == NULL) 00026 return; 00027 free_NC_string(attrp->name); 00028 free(attrp); 00029 } |
|
Definition at line 166 of file attr.c. References free, free_NC_attrarrayV0(), NC_attrarray::nalloc, and NC_attrarray::value. Referenced by dup_NC_attrarrayV(), free_NC(), free_NC_var(), read_NC(), and v1h_get_NC_attrarray().
|
|
Definition at line 138 of file attr.c. References free_NC_attr(), NC_attrarray::nelems, and NC_attrarray::value. Referenced by free_NC_attrarrayV().
00139 { 00140 assert(ncap != NULL); 00141 00142 if(ncap->nelems == 0) 00143 return; 00144 00145 assert(ncap->value != NULL); 00146 00147 { 00148 NC_attr **app = ncap->value; 00149 NC_attr *const *const end = &app[ncap->nelems]; 00150 for( /*NADA*/; app < end; app++) 00151 { 00152 free_NC_attr(*app); 00153 *app = NULL; 00154 } 00155 } 00156 ncap->nelems = 0; 00157 } |
|
Definition at line 19 of file dim.c. References free, free_NC_string(), and NC_dim::name. Referenced by free_NC_dimarrayV0(), nc_def_dim(), and v1h_get_NC_dim().
00020 { 00021 if(dimp == NULL) 00022 return; 00023 free_NC_string(dimp->name); 00024 free(dimp); 00025 } |
|
Definition at line 185 of file dim.c. References free, free_NC_dimarrayV0(), NC_dimarray::nalloc, and NC_dimarray::value. Referenced by dup_NC_dimarrayV(), free_NC(), read_NC(), and v1h_get_NC_dimarray().
|
|
Definition at line 157 of file dim.c. References free_NC_dim(), NC_dimarray::nelems, and NC_dimarray::value. Referenced by free_NC_dimarrayV().
00158 { 00159 assert(ncap != NULL); 00160 00161 if(ncap->nelems == 0) 00162 return; 00163 00164 assert(ncap->value != NULL); 00165 00166 { 00167 NC_dim **dpp = ncap->value; 00168 NC_dim *const *const end = &dpp[ncap->nelems]; 00169 for( /*NADA*/; dpp < end; dpp++) 00170 { 00171 free_NC_dim(*dpp); 00172 *dpp = NULL; 00173 } 00174 } 00175 ncap->nelems = 0; 00176 } |
|
Definition at line 21 of file string.c. References free. Referenced by free_NC_attr(), free_NC_dim(), free_NC_var(), nc_rename_att(), nc_rename_dim(), nc_rename_var(), new_NC_attr(), new_NC_dim(), new_NC_var(), v1h_get_NC_attr(), v1h_get_NC_dim(), v1h_get_NC_string(), and v1h_get_NC_var().
00022 { 00023 if(ncstrp==NULL) 00024 return; 00025 free(ncstrp); 00026 } |
|
Definition at line 20 of file var.c. References NC_var::attrs, free, free_NC_attrarrayV(), free_NC_string(), and NC_var::name. Referenced by dup_NC_var(), free_NC_vararrayV0(), nc_def_var(), and v1h_get_NC_var().
00021 { 00022 if(varp == NULL) 00023 return; 00024 free_NC_attrarrayV(&varp->attrs); 00025 free_NC_string(varp->name); 00026 free(varp); 00027 } |
|
Definition at line 167 of file var.c. References free, free_NC_vararrayV0(), NC_vararray::nalloc, and NC_vararray::value. Referenced by dup_NC_vararrayV(), free_NC(), read_NC(), and v1h_get_NC_vararray().
|
|
Definition at line 139 of file var.c. References free_NC_var(), NC_vararray::nelems, and NC_vararray::value. Referenced by free_NC_vararrayV().
00140 { 00141 assert(ncap != NULL); 00142 00143 if(ncap->nelems == 0) 00144 return; 00145 00146 assert(ncap->value != NULL); 00147 00148 { 00149 NC_var **vpp = ncap->value; 00150 NC_var *const *const end = &vpp[ncap->nelems]; 00151 for( /*NADA*/; vpp < end; vpp++) 00152 { 00153 free_NC_var(*vpp); 00154 *vpp = NULL; 00155 } 00156 } 00157 ncap->nelems = 0; 00158 } |
|
|
Definition at line 35 of file string.c. References name. Referenced by nc_def_dim(), nc_def_var(), nc_put_att_double(), nc_put_att_float(), nc_put_att_int(), nc_put_att_long(), nc_put_att_schar(), nc_put_att_short(), nc_put_att_text(), nc_put_att_uchar(), nc_rename_att(), nc_rename_dim(), and nc_rename_var().
00036 { 00037 const char *cp = name; 00038 assert(name != NULL); 00039 00040 if(*name == 0) 00041 return NC_EBADNAME; /* empty names disallowed */ 00042 00043 for(; *cp != 0; cp++) 00044 { 00045 int ch = *cp; 00046 if(!isalnum(ch)) 00047 { 00048 if(ch != '_' && ch != '-' && ch != '.') 00049 return NC_EBADNAME; 00050 } 00051 } 00052 if(cp - name > NC_MAX_NAME) 00053 return NC_EMAXNAME; 00054 00055 return NC_NOERR; 00056 } |
|
Definition at line 157 of file nc.c. Referenced by nc_def_var(), nc_put_att_double(), nc_put_att_float(), nc_put_att_int(), nc_put_att_long(), nc_put_att_schar(), nc_put_att_short(), and nc_put_att_uchar().
00158 { 00159 switch((int)type){ 00160 case NC_BYTE: 00161 case NC_CHAR: 00162 case NC_SHORT: 00163 case NC_INT: 00164 case NC_FLOAT: 00165 case NC_DOUBLE: 00166 return(NC_NOERR); 00167 } 00168 return(NC_EBADTYPE); 00169 } |
|
Definition at line 318 of file attr.c. References name, NC_attrarray::nelems, and NC_attrarray::value. Referenced by fill_NC_var(), nc_copy_att(), nc_inq_attid(), NC_lookupattr(), nc_put_att_double(), nc_put_att_float(), nc_put_att_int(), nc_put_att_long(), nc_put_att_schar(), nc_put_att_short(), nc_put_att_text(), nc_put_att_uchar(), and nc_rename_att().
00319 { 00320 NC_attr **attrpp; 00321 size_t attrid; 00322 size_t slen; 00323 00324 assert(ncap != NULL); 00325 00326 if(ncap->nelems == 0) 00327 return NULL; 00328 00329 attrpp = (NC_attr **) ncap->value; 00330 00331 slen = strlen(name); 00332 00333 for(attrid = 0; attrid < ncap->nelems; attrid++, attrpp++) 00334 { 00335 if(strlen((*attrpp)->name->cp) == slen && 00336 strncmp((*attrpp)->name->cp, name, slen) == 0) 00337 { 00338 return(attrpp); /* Normal return */ 00339 } 00340 } 00341 return(NULL); 00342 } |
|
Definition at line 295 of file var.c. References name, NC_vararray::nelems, and NC_vararray::value. Referenced by nc_copy_var(), nc_def_var(), nc_inq_varid(), and nc_rename_var().
00296 { 00297 NC_var **loc; 00298 size_t slen; 00299 int varid; 00300 00301 assert(ncap != NULL); 00302 00303 if(ncap->nelems == 0) 00304 return -1; 00305 00306 loc = (NC_var **) ncap->value; 00307 00308 slen = strlen(name); 00309 00310 for(varid = 0; (size_t) varid < ncap->nelems; varid++, loc++) 00311 { 00312 if(strlen((*loc)->name->cp) == slen && 00313 strncmp((*loc)->name->cp, name, slen) == 0) 00314 { 00315 if(varpp != NULL) 00316 *varpp = *loc; 00317 return(varid); /* Normal return */ 00318 } 00319 } 00320 return(-1); /* not found */ 00321 } |
|
Definition at line 2214 of file attr.c.
02215 { 02216 int status; 02217 NC_attr *attrp; 02218 02219 status = NC_lookupattr(ncid, varid, name, &attrp); 02220 if(status != NC_NOERR) 02221 return status; 02222 02223 switch (attrp->type) { 02224 case NC_BYTE: 02225 return nc_get_att_schar(ncid, varid, name, 02226 (schar *)value); 02227 case NC_CHAR: 02228 return nc_get_att_text(ncid, varid, name, 02229 (char *)value); 02230 case NC_SHORT: 02231 return nc_get_att_short(ncid, varid, name, 02232 (short *)value); 02233 case NC_INT: 02234 #if (SIZEOF_INT >= X_SIZEOF_INT) 02235 return nc_get_att_int(ncid, varid, name, 02236 (int *)value); 02237 #elif SIZEOF_LONG == X_SIZEOF_INT 02238 return nc_get_att_long(ncid, varid, name, 02239 (long *)value); 02240 #endif 02241 case NC_FLOAT: 02242 return nc_get_att_float(ncid, varid, name, 02243 (float *)value); 02244 case NC_DOUBLE: 02245 return nc_get_att_double(ncid, varid, name, 02246 (double *)value); 02247 } 02248 return NC_EBADTYPE; 02249 } |
|
Definition at line 1233 of file v1hpg.c. References NC::attrs, v1hs::base, NC::chunk, NC::dims, v1hs::end, v1hs::extent, fault_v1hs(), v1hs::flags, memcmp(), MIN_NC_XSZ, NC_computeshapes(), NC_set_numrecs, v1hs::nciop, NC::nciop, ncmagic, ncx_get_size_t(), ncx_getn_schar_schar(), ncx_len_NC(), v1hs::offset, v1hs::pos, rel_v1hs(), v1h_get_NC_attrarray(), v1h_get_NC_dimarray(), v1h_get_NC_vararray(), NC::vars, and NC::xsz. Referenced by nc__open_mp(), nc_delete_mp(), and read_NC().
01234 { 01235 int status; 01236 v1hs gs; /* the get stream */ 01237 01238 assert(ncp != NULL); 01239 01240 /* Initialize stream gs */ 01241 01242 gs.nciop = ncp->nciop; 01243 gs.offset = 0; /* beginning of file */ 01244 gs.extent = 0; 01245 gs.flags = 0; 01246 gs.base = NULL; 01247 gs.pos = gs.base; 01248 01249 { 01250 /* 01251 * Come up with a reasonable stream read size. 01252 */ 01253 size_t extent = ncp->xsz; 01254 if(extent <= MIN_NC_XSZ) 01255 { 01256 /* first time read */ 01257 extent = ncp->chunk; 01258 /* Protection for when ncp->chunk is huge; 01259 * no need to read hugely. */ 01260 if(extent > 4096) 01261 extent = 4096; 01262 } 01263 else if(extent > ncp->chunk) 01264 { 01265 extent = ncp->chunk; 01266 } 01267 01268 status = fault_v1hs(&gs, extent); 01269 if(status) 01270 return status; 01271 } 01272 01273 /* get the header from the stream gs */ 01274 01275 { 01276 /* Get & check magic number */ 01277 schar magic[sizeof(ncmagic)]; 01278 (void) memset(magic, 0, sizeof(magic)); 01279 01280 status = ncx_getn_schar_schar( 01281 (const void **)(&gs.pos), sizeof(magic), magic); 01282 if(status != ENOERR) 01283 goto unwind_get; 01284 01285 if(memcmp(magic, ncmagic, sizeof(ncmagic)) != 0) 01286 { 01287 status = NC_ENOTNC; 01288 goto unwind_get; 01289 } 01290 } 01291 01292 { 01293 size_t nrecs = 0; 01294 status = ncx_get_size_t((const void **)(&gs.pos), &nrecs); 01295 if(status != ENOERR) 01296 goto unwind_get; 01297 NC_set_numrecs(ncp, nrecs); 01298 } 01299 01300 assert((char *)gs.pos < (char *)gs.end); 01301 01302 status = v1h_get_NC_dimarray(&gs, &ncp->dims); 01303 if(status != ENOERR) 01304 goto unwind_get; 01305 01306 status = v1h_get_NC_attrarray(&gs, &ncp->attrs); 01307 if(status != ENOERR) 01308 goto unwind_get; 01309 01310 status = v1h_get_NC_vararray(&gs, &ncp->vars); 01311 if(status != ENOERR) 01312 goto unwind_get; 01313 01314 ncp->xsz = ncx_len_NC(ncp); 01315 01316 status = NC_computeshapes(ncp); 01317 01318 unwind_get: 01319 (void) rel_v1hs(&gs); 01320 return status; 01321 } |
|
Definition at line 11633 of file putget.c. References NC_check_id(), NC_get_numrecs, NC_indef, and NCrecget(). Referenced by ncrecget().
11637 { 11638 int status; 11639 NC *ncp; 11640 11641 status = NC_check_id(ncid, &ncp); 11642 if(status != NC_NOERR) 11643 return status; 11644 11645 if(NC_indef(ncp)) 11646 { 11647 return NC_EINDEFINE; 11648 } 11649 11650 if(recnum >= NC_get_numrecs(ncp)) 11651 { 11652 return NC_EINVALCOORDS; 11653 } 11654 11655 return( NCrecget(ncp, recnum, datap) ); 11656 } |
|
Definition at line 4920 of file putget.c.
04921 { 04922 int status; 04923 NC *ncp; 04924 const NC_var *varp; 04925 04926 status = NC_check_id(ncid, &ncp); 04927 if(status != NC_NOERR) 04928 return status; 04929 04930 varp = NC_lookupvar(ncp, varid); 04931 if(varp == NULL) 04932 return NC_ENOTVAR; 04933 04934 switch(varp->type){ 04935 case NC_CHAR: 04936 return nc_get_var1_text(ncid, varid, coord, 04937 (char *) value); 04938 case NC_BYTE: 04939 return nc_get_var1_schar(ncid, varid, coord, 04940 (schar *) value); 04941 case NC_SHORT: 04942 return nc_get_var1_short(ncid, varid, coord, 04943 (short *) value); 04944 case NC_INT: 04945 return nc_get_var1_int(ncid, varid, coord, 04946 (int *) value); 04947 case NC_FLOAT: 04948 return nc_get_var1_float(ncid, varid, coord, 04949 (float *) value); 04950 case NC_DOUBLE: 04951 return nc_get_var1_double(ncid, varid, coord, 04952 (double *) value); 04953 } 04954 return NC_EBADTYPE; 04955 } |
|
Definition at line 6663 of file putget.c.
06665 { 06666 int status; 06667 NC *ncp; 06668 const NC_var *varp; 06669 06670 status = NC_check_id(ncid, &ncp); 06671 if(status != NC_NOERR) 06672 return status; 06673 06674 if(NC_indef(ncp)) 06675 return NC_EINDEFINE; 06676 06677 varp = NC_lookupvar(ncp, varid); 06678 if(varp == NULL) 06679 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */ 06680 06681 switch(varp->type){ 06682 case NC_CHAR: 06683 return nc_get_vara_text(ncid, varid, start, edges, 06684 (char *) value); 06685 case NC_BYTE: 06686 return nc_get_vara_schar(ncid, varid, start, edges, 06687 (schar *) value); 06688 case NC_SHORT: 06689 return nc_get_vara_short(ncid, varid, start, edges, 06690 (short *) value); 06691 case NC_INT: 06692 #if (SIZEOF_INT >= X_SIZEOF_INT) 06693 return nc_get_vara_int(ncid, varid, start, edges, 06694 (int *) value); 06695 #elif SIZEOF_LONG == X_SIZEOF_INT 06696 return nc_get_vara_long(ncid, varid, start, edges, 06697 (long *) value); 06698 #else 06699 #error "nc_get_vara implementation" 06700 #endif 06701 case NC_FLOAT: 06702 return nc_get_vara_float(ncid, varid, start, edges, 06703 (float *) value); 06704 case NC_DOUBLE: 06705 return nc_get_vara_double(ncid, varid, start, edges, 06706 (double *) value); 06707 } 06708 return NC_EBADTYPE; 06709 } |
|
Definition at line 9707 of file putget.c.
09715 { 09716 int status; 09717 NC *ncp; 09718 const NC_var *varp; 09719 ptrdiff_t *cvtmap = NULL; 09720 09721 status = NC_check_id(ncid, &ncp); 09722 if(status != NC_NOERR) 09723 return status; 09724 09725 varp = NC_lookupvar(ncp, varid); 09726 if(varp == NULL) 09727 return NC_ENOTVAR; 09728 09729 if(map != NULL && varp->ndims != 0) 09730 { 09731 /* 09732 * convert map units from bytes to units of sizeof(type) 09733 */ 09734 size_t ii; 09735 const ptrdiff_t szof = (ptrdiff_t) nctypelen(varp->type); 09736 cvtmap = (ptrdiff_t *)calloc(varp->ndims, sizeof(ptrdiff_t)); 09737 if(cvtmap == NULL) 09738 return NC_ENOMEM; 09739 for(ii = 0; ii < varp->ndims; ii++) 09740 { 09741 if(map[ii] % szof != 0) 09742 { 09743 free(cvtmap); 09744 return NC_EINVAL; 09745 } 09746 cvtmap[ii] = map[ii] / szof; 09747 } 09748 map = cvtmap; 09749 } 09750 09751 switch(varp->type){ 09752 case NC_CHAR: 09753 status = nc_get_varm_text(ncid, varid, start, edges, 09754 stride, map, 09755 (char *) value); 09756 break; 09757 case NC_BYTE: 09758 status = nc_get_varm_schar(ncid, varid, start, edges, 09759 stride, map, 09760 (schar *) value); 09761 break; 09762 case NC_SHORT: 09763 status = nc_get_varm_short(ncid, varid, start, edges, 09764 stride, map, 09765 (short *) value); 09766 break; 09767 case NC_INT: 09768 #if (SIZEOF_INT >= X_SIZEOF_INT) 09769 status = nc_get_varm_int(ncid, varid, start, edges, 09770 stride, map, 09771 (int *) value); 09772 #elif SIZEOF_LONG == X_SIZEOF_INT 09773 status = nc_get_varm_long(ncid, varid, start, edges, 09774 stride, map, 09775 (long *) value); 09776 #else 09777 #error "nc_get_varm implementation" 09778 #endif 09779 break; 09780 case NC_FLOAT: 09781 status = nc_get_varm_float(ncid, varid, start, edges, 09782 stride, map, 09783 (float *) value); 09784 break; 09785 case NC_DOUBLE: 09786 status = nc_get_varm_double(ncid, varid, start, edges, 09787 stride, map, 09788 (double *) value); 09789 break; 09790 default: 09791 status = NC_EBADTYPE; 09792 break; 09793 } 09794 09795 if(cvtmap != NULL) 09796 { 09797 free(cvtmap); 09798 } 09799 return status; 09800 } |
|
Definition at line 8069 of file putget.c.
08076 { 08077 return nc_get_varm (ncid, varid, start, edges, 08078 stride, 0, value); 08079 } |
|
Definition at line 11462 of file putget.c. References IS_RECVAR, NC_check_id(), NCelemsPerRec(), nctypelen(), NC_vararray::nelems, NC_var::type, NC_vararray::value, and NC::vars. Referenced by ncrecinq().
11467 { 11468 NC *ncp; 11469 11470 { 11471 const int status = NC_check_id(ncid, &ncp); 11472 if(status != NC_NOERR) 11473 return status; 11474 } 11475 11476 { 11477 size_t nrvars = 0; 11478 size_t ii = 0; 11479 for(; ii < ncp->vars.nelems; ii++) 11480 { 11481 const NC_var *const varp = ncp->vars.value[ii]; 11482 if(!IS_RECVAR(varp)) 11483 continue; 11484 11485 if(recvarids != NULL) 11486 recvarids[nrvars] = (int) ii; 11487 if(recsizes != NULL) 11488 { 11489 *recsizes++ = nctypelen(varp->type) 11490 * NCelemsPerRec(varp); 11491 } 11492 nrvars++; 11493 } 11494 11495 if(nrecvars != NULL) 11496 *nrecvars = nrvars; 11497 } 11498 11499 return NC_NOERR; 11500 } |
|
|
Definition at line 2175 of file attr.c.
02182 { 02183 switch (type) { 02184 case NC_BYTE: 02185 return nc_put_att_schar(ncid, varid, name, type, nelems, 02186 (schar *)value); 02187 case NC_CHAR: 02188 return nc_put_att_text(ncid, varid, name, nelems, 02189 (char *)value); 02190 case NC_SHORT: 02191 return nc_put_att_short(ncid, varid, name, type, nelems, 02192 (short *)value); 02193 case NC_INT: 02194 #if (SIZEOF_INT >= X_SIZEOF_INT) 02195 return nc_put_att_int(ncid, varid, name, type, nelems, 02196 (int *)value); 02197 #elif SIZEOF_LONG == X_SIZEOF_INT 02198 return nc_put_att_long(ncid, varid, name, type, nelems, 02199 (long *)value); 02200 #endif 02201 case NC_FLOAT: 02202 return nc_put_att_float(ncid, varid, name, type, nelems, 02203 (float *)value); 02204 case NC_DOUBLE: 02205 return nc_put_att_double(ncid, varid, name, type, nelems, 02206 (double *)value); 02207 } 02208 return NC_EBADTYPE; 02209 } |
|
Definition at line 11598 of file putget.c. References NC_check_id(), NC_indef, NC_readonly, NCrecput(), and NCvnrecs(). Referenced by ncrecput().
11602 { 11603 int status; 11604 NC *ncp; 11605 11606 status = NC_check_id(ncid, &ncp); 11607 if(status != NC_NOERR) 11608 return status; 11609 11610 if(NC_readonly(ncp)) 11611 { 11612 return NC_EPERM; 11613 } 11614 11615 if(NC_indef(ncp)) 11616 { 11617 return NC_EINDEFINE; 11618 } 11619 11620 status = NCvnrecs(ncp, recnum +1); 11621 if(status != NC_NOERR) 11622 return status; 11623 11624 return( NCrecput(ncp, recnum, datap) ); 11625 } |
|
Definition at line 4653 of file putget.c.
04654 { 04655 int status; 04656 NC *ncp; 04657 const NC_var *varp; 04658 04659 status = NC_check_id(ncid, &ncp); 04660 if(status != NC_NOERR) 04661 return status; 04662 04663 varp = NC_lookupvar(ncp, varid); 04664 if(varp == NULL) 04665 return NC_ENOTVAR; 04666 04667 switch(varp->type){ 04668 case NC_CHAR: 04669 return nc_put_var1_text(ncid, varid, coord, 04670 (const char *) value); 04671 case NC_BYTE: 04672 return nc_put_var1_schar(ncid, varid, coord, 04673 (const schar *) value); 04674 case NC_SHORT: 04675 return nc_put_var1_short(ncid, varid, coord, 04676 (const short *) value); 04677 case NC_INT: 04678 return nc_put_var1_int(ncid, varid, coord, 04679 (const int *) value); 04680 case NC_FLOAT: 04681 return nc_put_var1_float(ncid, varid, coord, 04682 (const float *) value); 04683 case NC_DOUBLE: 04684 return nc_put_var1_double(ncid, varid, coord, 04685 (const double *) value); 04686 } 04687 return NC_EBADTYPE; 04688 } |
|
Definition at line 5812 of file putget.c.
05814 { 05815 int status; 05816 NC *ncp; 05817 const NC_var *varp; 05818 05819 status = NC_check_id(ncid, &ncp); 05820 if(status != NC_NOERR) 05821 return status; 05822 05823 if(NC_readonly(ncp)) 05824 return NC_EPERM; 05825 05826 if(NC_indef(ncp)) 05827 return NC_EINDEFINE; 05828 05829 varp = NC_lookupvar(ncp, varid); 05830 if(varp == NULL) 05831 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */ 05832 05833 switch(varp->type){ 05834 case NC_CHAR: 05835 return nc_put_vara_text(ncid, varid, start, edges, 05836 (const char *) value); 05837 case NC_BYTE: 05838 return nc_put_vara_schar(ncid, varid, start, edges, 05839 (const schar *) value); 05840 case NC_SHORT: 05841 return nc_put_vara_short(ncid, varid, start, edges, 05842 (const short *) value); 05843 case NC_INT: 05844 return nc_put_vara_int(ncid, varid, start, edges, 05845 (const int *) value); 05846 case NC_FLOAT: 05847 return nc_put_vara_float(ncid, varid, start, edges, 05848 (const float *) value); 05849 case NC_DOUBLE: 05850 return nc_put_vara_double(ncid, varid, start, edges, 05851 (const double *) value); 05852 } 05853 return NC_EBADTYPE; 05854 } |
|
Definition at line 11268 of file putget.c.
11276 { 11277 int status; 11278 NC *ncp; 11279 const NC_var *varp; 11280 ptrdiff_t *cvtmap = NULL; 11281 11282 status = NC_check_id(ncid, &ncp); 11283 if(status != NC_NOERR) 11284 return status; 11285 11286 varp = NC_lookupvar(ncp, varid); 11287 if(varp == NULL) 11288 return NC_ENOTVAR; 11289 11290 if(map != NULL && varp->ndims != 0) 11291 { 11292 /* 11293 * convert map units from bytes to units of sizeof(type) 11294 */ 11295 size_t ii; 11296 const ptrdiff_t szof = (ptrdiff_t) nctypelen(varp->type); 11297 cvtmap = (ptrdiff_t *)calloc(varp->ndims, sizeof(ptrdiff_t)); 11298 if(cvtmap == NULL) 11299 return NC_ENOMEM; 11300 for(ii = 0; ii < varp->ndims; ii++) 11301 { 11302 if(map[ii] % szof != 0) 11303 { 11304 free(cvtmap); 11305 return NC_EINVAL; 11306 } 11307 cvtmap[ii] = map[ii] / szof; 11308 } 11309 map = cvtmap; 11310 } 11311 11312 switch(varp->type){ 11313 case NC_CHAR: 11314 status = nc_put_varm_text(ncid, varid, start, edges, 11315 stride, map, 11316 (const char *) value); 11317 break; 11318 case NC_BYTE: 11319 status = nc_put_varm_schar(ncid, varid, start, edges, 11320 stride, map, 11321 (const schar *) value); 11322 break; 11323 case NC_SHORT: 11324 status = nc_put_varm_short(ncid, varid, start, edges, 11325 stride, map, 11326 (const short *) value); 11327 break; 11328 case NC_INT: 11329 #if (SIZEOF_INT >= X_SIZEOF_INT) 11330 status = nc_put_varm_int(ncid, varid, start, edges, 11331 stride, map, 11332 (const int *) value); 11333 #elif SIZEOF_LONG == X_SIZEOF_INT 11334 status = nc_put_varm_long(ncid, varid, start, edges, 11335 stride, map, 11336 (const long *) value); 11337 #else 11338 #error "nc_put_varm implementation" 11339 #endif 11340 break; 11341 case NC_FLOAT: 11342 status = nc_put_varm_float(ncid, varid, start, edges, 11343 stride, map, 11344 (const float *) value); 11345 break; 11346 case NC_DOUBLE: 11347 status = nc_put_varm_double(ncid, varid, start, edges, 11348 stride, map, 11349 (const double *) value); 11350 break; 11351 default: 11352 status = NC_EBADTYPE; 11353 break; 11354 } 11355 11356 if(cvtmap != NULL) 11357 { 11358 free(cvtmap); 11359 } 11360 return status; 11361 } |
|
Definition at line 8190 of file putget.c.
08197 { 08198 return nc_put_varm (ncid, varid, start, edges, 08199 stride, 0, value); 08200 } |
|
Definition at line 411 of file nc.c. References NC_hdirty, NC_ndirty, NC_readonly, write_NC(), and write_numrecs(). Referenced by nc_abort(), nc_close(), nc_copy_att(), nc_put_att_double(), nc_put_att_float(), nc_put_att_int(), nc_put_att_long(), nc_put_att_schar(), nc_put_att_short(), nc_put_att_text(), nc_put_att_uchar(), nc_redef(), nc_rename_att(), nc_rename_dim(), nc_rename_var(), nc_set_fill(), and nc_sync().
00412 { 00413 assert(!NC_readonly(ncp)); 00414 00415 if(NC_hdirty(ncp)) 00416 { 00417 return write_NC(ncp); 00418 } 00419 /* else */ 00420 00421 if(NC_ndirty(ncp)) 00422 { 00423 return write_numrecs(ncp); 00424 } 00425 /* else */ 00426 00427 return NC_NOERR; 00428 } |
|
Definition at line 359 of file var.c. References NC_var::dimids, NC_var::dsizes, elem_NC_dimarray(), IS_RECVAR, NC_var::len, ncx_szof(), NC_var::ndims, NC_dimarray::nelems, NC_var::shape, NC_dim::size, NC_var::type, and NC_var::xsz. Referenced by NC_computeshapes(), and nc_def_var().
00360 { 00361 size_t *shp, *dsp, *op; 00362 int *ip; 00363 const NC_dim *dimp; 00364 size_t product = 1; 00365 00366 varp->xsz = ncx_szof(varp->type); 00367 00368 if(varp->ndims == 0) 00369 { 00370 goto out; 00371 } 00372 00373 /* 00374 * use the user supplied dimension indices 00375 * to determine the shape 00376 */ 00377 for(ip = varp->dimids, op = varp->shape 00378 ; ip < &varp->dimids[varp->ndims]; ip++, op++) 00379 { 00380 if(*ip < 0 || (size_t) (*ip) >= ((dims != NULL) ? dims->nelems : 1) ) 00381 return NC_EBADDIM; 00382 00383 dimp = elem_NC_dimarray(dims, (size_t)*ip); 00384 *op = dimp->size; 00385 if(*op == NC_UNLIMITED && ip != varp->dimids) 00386 return NC_EUNLIMPOS; 00387 } 00388 00389 /* 00390 * Compute the dsizes 00391 */ 00392 /* ndims is > 0 here */ 00393 for(shp = varp->shape + varp->ndims -1, 00394 dsp = varp->dsizes + varp->ndims -1; 00395 shp >= varp->shape; 00396 shp--, dsp--) 00397 { 00398 if(!(shp == varp->shape && IS_RECVAR(varp))) 00399 product *= *shp; 00400 *dsp = product; 00401 } 00402 00403 00404 out : 00405 varp->len = product * varp->xsz; 00406 switch(varp->type) { 00407 case NC_BYTE : 00408 case NC_CHAR : 00409 case NC_SHORT : 00410 if( varp->len%4 != 0 ) 00411 { 00412 varp->len += 4 - varp->len%4; /* round up */ 00413 /* *dsp += 4 - *dsp%4; */ 00414 } 00415 break; 00416 default: 00417 /* already aligned */ 00418 break; 00419 } 00420 #if 0 00421 arrayp("\tshape", varp->ndims, varp->shape); 00422 arrayp("\tdsizes", varp->ndims, varp->dsizes); 00423 #endif 00424 return NC_NOERR; 00425 } |
|
|
Definition at line 1134 of file v1hpg.c. References NC::attrs, NC::dims, ncx_len_NC_attrarray(), ncx_len_NC_dimarray(), ncx_len_NC_vararray(), NC::vars, and X_SIZEOF_SIZE_T. Referenced by NC_begins(), and nc_get_NC().
01135 { 01136 size_t xlen = sizeof(ncmagic); 01137 01138 assert(ncp != NULL); 01139 01140 xlen += X_SIZEOF_SIZE_T; /* numrecs */ 01141 xlen += ncx_len_NC_dimarray(&ncp->dims); 01142 xlen += ncx_len_NC_attrarray(&ncp->attrs); 01143 xlen += ncx_len_NC_vararray(&ncp->vars); 01144 01145 return xlen; 01146 } |
|
Definition at line 1150 of file v1hpg.c. References NC::attrs, v1hs::base, NC::chunk, NC::dims, v1hs::end, v1hs::extent, fault_v1hs(), v1hs::flags, MIN_NC_XSZ, NC_get_numrecs, v1hs::nciop, NC::nciop, ncmagic, ncx_put_size_t(), ncx_putn_schar_schar(), offset, v1hs::offset, v1hs::pos, rel_v1hs(), RGN_WRITE, v1h_put_NC_attrarray(), v1h_put_NC_dimarray(), v1h_put_NC_vararray(), NC::vars, and NC::xsz. Referenced by nc__create_mp(), and write_NC().
01151 { 01152 int status = ENOERR; 01153 v1hs ps; /* the get stream */ 01154 01155 assert(ncp != NULL); 01156 01157 /* Initialize stream ps */ 01158 01159 ps.nciop = ncp->nciop; 01160 ps.flags = RGN_WRITE; 01161 01162 if(xpp == NULL) 01163 { 01164 /* 01165 * Come up with a reasonable stream read size. 01166 */ 01167 extent = ncp->xsz; 01168 if(extent <= MIN_NC_XSZ) 01169 { 01170 /* first time read */ 01171 extent = ncp->chunk; 01172 /* Protection for when ncp->chunk is huge; 01173 * no need to read hugely. */ 01174 if(extent > 4096) 01175 extent = 4096; 01176 } 01177 else if(extent > ncp->chunk) 01178 { 01179 extent = ncp->chunk; 01180 } 01181 01182 ps.offset = 0; 01183 ps.extent = extent; 01184 ps.base = NULL; 01185 ps.pos = ps.base; 01186 01187 status = fault_v1hs(&ps, extent); 01188 if(status) 01189 return status; 01190 } 01191 else 01192 { 01193 ps.offset = offset; 01194 ps.extent = extent; 01195 ps.base = *xpp; 01196 ps.pos = ps.base; 01197 ps.end = (char *)ps.base + ps.extent; 01198 } 01199 01200 status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic), ncmagic); 01201 if(status != ENOERR) 01202 goto release; 01203 01204 { 01205 const size_t nrecs = NC_get_numrecs(ncp); 01206 status = ncx_put_size_t(&ps.pos, &nrecs); 01207 if(status != ENOERR) 01208 goto release; 01209 } 01210 01211 assert((char *)ps.pos < (char *)ps.end); 01212 01213 status = v1h_put_NC_dimarray(&ps, &ncp->dims); 01214 if(status != ENOERR) 01215 goto release; 01216 01217 status = v1h_put_NC_attrarray(&ps, &ncp->attrs); 01218 if(status != ENOERR) 01219 goto release; 01220 01221 status = v1h_put_NC_vararray(&ps, &ncp->vars); 01222 if(status != ENOERR) 01223 goto release; 01224 01225 release: 01226 (void) rel_v1hs(&ps); 01227 01228 return status; 01229 } |
|
Definition at line 66 of file string.c. References _RNDUP, NC_string::cp, M_RNDUP, malloc, NC_string::nchars, and X_ALIGN. Referenced by nc_rename_att(), nc_rename_dim(), nc_rename_var(), new_NC_attr(), new_NC_dim(), new_NC_var(), and v1h_get_NC_string().
00067 { 00068 NC_string *ncstrp; 00069 size_t sz = M_RNDUP(sizeof(NC_string)) + slen + 1; 00070 00071 #if 0 00072 sz = _RNDUP(sz, X_ALIGN); 00073 #endif 00074 00075 ncstrp = (NC_string *)malloc(sz); 00076 if( ncstrp == NULL ) 00077 return NULL; 00078 (void) memset(ncstrp, 0, sz); 00079 00080 ncstrp->nchars = sz - M_RNDUP(sizeof(NC_string)) - 1; 00081 assert(ncstrp->nchars + 1 > slen); 00082 ncstrp->cp = (char *)ncstrp + M_RNDUP(sizeof(NC_string)); 00083 00084 if(str != NULL && *str != 0) 00085 { 00086 (void) strncpy(ncstrp->cp, str, ncstrp->nchars +1); 00087 ncstrp->cp[ncstrp->nchars] = 0; 00088 } 00089 00090 return(ncstrp); 00091 } |
|
Definition at line 59 of file attr.c. References M_RNDUP, malloc, NC_attr::name, ncx_len_NC_attrV(), NC_attr::nelems, strp, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by new_NC_attr(), and v1h_get_NC_attr().
00063 { 00064 NC_attr *attrp; 00065 const size_t xsz = ncx_len_NC_attrV(type, nelems); 00066 size_t sz = M_RNDUP(sizeof(NC_attr)); 00067 00068 assert(!(xsz == 0 && nelems != 0)); 00069 00070 sz += xsz; 00071 00072 attrp = (NC_attr *) malloc(sz); 00073 if(attrp == NULL ) 00074 return NULL; 00075 00076 attrp->xsz = xsz; 00077 00078 attrp->name = strp; 00079 attrp->type = type; 00080 attrp->nelems = nelems; 00081 if(xsz != 0) 00082 attrp->xvalue = (char *)attrp + M_RNDUP(sizeof(NC_attr)); 00083 else 00084 attrp->xvalue = NULL; 00085 00086 return(attrp); 00087 } |
|
Definition at line 29 of file dim.c. References malloc, NC_dim::name, name, and NC_dim::size. Referenced by new_NC_dim(), and v1h_get_NC_dim().
|
|
Definition at line 35 of file var.c. References NC_var::begin, NC_var::dimids, NC_var::dsizes, NC_var::len, M_RNDUP, malloc, NC_var::name, ndims, NC_var::ndims, NC_var::shape, strp, and NC_var::xsz. Referenced by new_NC_var(), and v1h_get_NC_var().
00038 { 00039 NC_var *varp; 00040 const size_t o1 = M_RNDUP(ndims * sizeof(int)); 00041 const size_t o2 = M_RNDUP(ndims * sizeof(size_t)); 00042 const size_t sz = M_RNDUP(sizeof(NC_var)) + 00043 o1 + o2 + ndims * sizeof(size_t); 00044 00045 varp = (NC_var *) malloc(sz); 00046 if(varp == NULL ) 00047 return NULL; 00048 (void) memset(varp, 0, sz); 00049 00050 varp->name = strp; 00051 varp->ndims = ndims; 00052 00053 if(ndims != 0) 00054 { 00055 /* 00056 * NOTE: lint may complain about the next 3 lines: 00057 * "pointer cast may result in improper alignment". 00058 * We use the M_RNDUP() macro to get the proper alignment. 00059 */ 00060 varp->dimids = (int *)((char *)varp + M_RNDUP(sizeof(NC_var))); 00061 varp->shape = (size_t *)((char *)varp->dimids + o1); 00062 varp->dsizes = (size_t *)((char *)varp->shape + o2); 00063 } 00064 00065 varp->xsz = 0; 00066 varp->len = 0; 00067 varp->begin = 0; 00068 00069 return varp; 00070 } |
|
Definition at line 304 of file nc.c. References fClr, NC::flags, ncio::get, NC_get_numrecs, NC_indef, NC_NDIRTY, NC_set_numrecs, NC::nciop, ncx_get_size_t(), and ncio::rel. Referenced by NCcoordck().
00305 { 00306 int status = NC_NOERR; 00307 const void *xp; 00308 size_t nrecs = NC_get_numrecs(ncp); 00309 00310 assert(!NC_indef(ncp)); 00311 00312 #define NC_NUMRECS_OFFSET 4 00313 #define NC_NUMRECS_EXTENT 4 00314 status = ncp->nciop->get(ncp->nciop, 00315 NC_NUMRECS_OFFSET, NC_NUMRECS_EXTENT, 0, (void **)&xp); 00316 /* cast away const */ 00317 if(status != NC_NOERR) 00318 return status; 00319 00320 status = ncx_get_size_t(&xp, &nrecs); 00321 00322 (void) ncp->nciop->rel(ncp->nciop, NC_NUMRECS_OFFSET, 0); 00323 00324 if(status == NC_NOERR) 00325 { 00326 NC_set_numrecs(ncp, nrecs); 00327 fClr(ncp->flags, NC_NDIRTY); 00328 } 00329 00330 return status; 00331 } |
|
Definition at line 101 of file string.c. References NC_string::cp, and NC_string::nchars. Referenced by nc_rename_att(), nc_rename_dim(), and nc_rename_var().
00102 { 00103 size_t slen; 00104 size_t diff; 00105 00106 assert(str != NULL && *str != 0); 00107 00108 slen = strlen(str); 00109 00110 if(ncstrp->nchars < slen) 00111 return NC_ENOTINDEFINE; 00112 00113 (void) memcpy(ncstrp->cp, str, slen); 00114 diff = ncstrp->nchars - slen; 00115 if(diff != 0) 00116 (void) memset(ncstrp->cp + slen, 0, diff); 00117 00118 return NC_NOERR; 00119 } |
|
Definition at line 339 of file nc.c. References fClr, NC::flags, ncio::get, NC_get_numrecs, NC_indef, NC_NDIRTY, NC_readonly, NC::nciop, ncx_put_size_t(), ncio::rel, RGN_MODIFIED, and RGN_WRITE. Referenced by NC_sync(), and NCvnrecs().
00340 { 00341 int status = NC_NOERR; 00342 void *xp; 00343 00344 assert(!NC_readonly(ncp)); 00345 assert(!NC_indef(ncp)); 00346 00347 status = ncp->nciop->get(ncp->nciop, 00348 NC_NUMRECS_OFFSET, NC_NUMRECS_EXTENT, RGN_WRITE, &xp); 00349 if(status != NC_NOERR) 00350 return status; 00351 00352 { 00353 const size_t nrecs = NC_get_numrecs(ncp); 00354 status = ncx_put_size_t(&xp, &nrecs); 00355 } 00356 00357 (void) ncp->nciop->rel(ncp->nciop, NC_NUMRECS_OFFSET, RGN_MODIFIED); 00358 00359 if(status == NC_NOERR) 00360 fClr(ncp->flags, NC_NDIRTY); 00361 00362 return status; 00363 } |